Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content): attach spreadsheets, Word, Markdown, HTML and text files to a draft (#1261)

Cihan127f7c94b065
diff --git a/web/messages/en.json b/web/messages/en.json
index 284af63ad..a819ec04d 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -3132,6 +3132,30 @@
"copyHtmlHint": "Copy the page as HTML to publish, HTML blocks and schema included",
"copyHtmlDone": "HTML copied",
"copyHtmlFailed": "Couldn't copy. Open {html} and copy it from there.",
+ "attach": {
+ "dropTitle": "Drop files to add them",
+ "dropHint": "Excel, CSV, Word, Markdown, HTML or text · up to 10 MB each",
+ "previewSummary": "{rows} rows · {columns} columns · the first row is the header",
+ "previewMore": "and {count} more rows",
+ "sheet": "Sheet",
+ "insertTable": "Insert as table",
+ "confirmLong": "This table has {count} rows. That's a lot for a page: insert all of them?",
+ "insertAll": "Insert all {count} rows",
+ "confirmCut": "Only the first {fit} of {count} rows fit in the page's size limit. A page over it can't be saved.",
+ "insertFirst": "Insert the first {count} rows",
+ "noRoom": "The page is too close to its size limit for this table. Shorten the page, or attach a smaller sheet.",
+ "cancel": "Cancel",
+ "tableInserted": "Table inserted from {name} · {count, plural, one {# row} other {# rows}}",
+ "imported": "{name} imported",
+ "unsafeRemoved": "{count, plural, one {# unsafe tag} other {# unsafe tags}} removed",
+ "imagesLeftOut": "{count, plural, one {# image} other {# images}} left out",
+ "empty": "Nothing to import from {name}.",
+ "tooLarge": "{name} is over 10 MB.",
+ "imageLater": "Images can't be attached yet. Add {name} with Insert an image, by its address.",
+ "legacyOffice": "Save {name} as .xlsx or .docx, then attach it.",
+ "unsupported": "{name} isn't a file the editor reads: attach Excel, CSV, Word, Markdown, HTML or text.",
+ "readFailed": "Couldn't read {name}."
+ },
"htmlBlock": {
"label": "HTML block",
"lines": "{count, plural, one {# line} other {# lines}}",
@@ -3186,6 +3210,7 @@
"addColumn": "Add a column to the right",
"deleteTable": "Delete the table",
"htmlBlock": "Add an HTML block",
+ "attach": "Attach a file: Excel, CSV, Word, Markdown, HTML or text",
"html": "Edit as HTML",
"htmlBack": "Back to visual",
"openLink": "Open the link in a new tab (or ⌘/Ctrl + click it in the page)",
diff --git a/web/package.json b/web/package.json
index f5f5e4232..c6fe81d6f 100644
--- a/web/package.json
+++ b/web/package.json
@@ -44,6 +44,7 @@
"dompurify": "3.4.16",
"fflate": "^0.8.3",
"lucide-react": "^0.577.0",
+ "mammoth": "1.13.0",
"marked": "^18.0.0",
"next": "16.4.2",
"next-intl": "^4.8.3",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_attach.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_attach.tsx
new file mode 100644
index 000000000..ad2756aa7
--- /dev/null
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_attach.tsx
@@ -0,0 +1,351 @@
+'use client';
+
+import { useRef, useState } from 'react';
+import { useTranslations } from 'next-intl';
+import { toast } from 'sonner';
+import type { Editor } from '@tiptap/react';
+import { Upload } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import {
+ Dialog,
+ DialogClose,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from '@/components/ui/dialog';
+import {
+ Select,
+ SelectContent,
+ SelectItem,
+ SelectTrigger,
+ SelectValue,
+} from '@/components/ui/select';
+import { cleanHtml } from '@/lib/content/clean-html';
+import {
+ ATTACHMENT_ACCEPT,
+ CONFIRM_TABLE_ROWS,
+ MAX_ATTACHMENT_BYTES,
+ attachmentKind,
+ rowsThatFit,
+ tableHtml,
+ tableRows,
+ textToHtml,
+} from '@/lib/content/attachments';
+import { MAX_BODY_HTML_LENGTH } from '@/lib/content/editor';
+import { formatNumber } from '@/lib/format';
+import { cellsToText, parseCsv } from '@/lib/prompt-import';
+
+/** A spreadsheet waiting in the preview: its sheets, each as table rows. */
+interface SheetFile {
+ name: string;
+ sheets: { name: string; rows: string[][] }[];
+}
+
+/** Rows the preview shows. */
+const PREVIEW_ROWS = 10;
+
+/**
+ * Puts imported content where the cursor is, except inside a table: there it
+ * goes under the table, as a table or a Word page in a cell would nest one in
+ * another (and a table just inserted leaves the cursor in its last cell).
+ */
+function insertImported(editor: Editor, html: string) {
+ const { $from } = editor.state.selection;
+ let afterTable: number | null = null;
+ for (let depth = $from.depth; depth > 0; depth--) {
+ if ($from.node(depth).type.name === 'table') afterTable = $from.after(depth);
+ }
+ const chain = editor.chain().focus();
+ if (afterTable === null) chain.insertContent(html);
+ else chain.insertContentAt(afterTable, html);
+ chain.run();
+}
+
+/**
+ * Attaching files to a draft (Content Editor CE-006, spec §9), from the
+ * toolbar's Attach file or by dropping them on the page, up to 10 MB each:
+ *
+ * * Excel (.xlsx) and CSV open a preview (the sheet, its first rows) and go
+ * in as a table, the first row as the header; over 200 rows asks first.
+ * * Markdown, HTML, Word (.docx) and text are imported where the cursor
+ * is, cleaned like a paste.
+ *
+ * Images wait for file storage; the old .xls and .doc formats are asked for
+ * as .xlsx and .docx.
+ */
+export function useAttachments(editor: Editor | null) {
+ const t = useTranslations('contentEditor.editor.attach');
+ const inputRef = useRef<HTMLInputElement>(null);
+ const [queue, setQueue] = useState<SheetFile[]>([]);
+
+ const insert = (html: string, name: string, note?: string) => {
+ if (!editor) return;
+ if (!html.trim()) {
+ toast.error(t('empty', { name }));
+ return;
+ }
+ insertImported(editor, html);
+ toast.success(note ? `${t('imported', { name })} · ${note}` : t('imported', { name }));
+ };
+
+ const readOne = async (file: File) => {
+ const name = file.name;
+ const kind = attachmentKind(name);
+ if (file.size > MAX_ATTACHMENT_BYTES) {
+ toast.error(t('tooLarge', { name }));
+ return;
+ }
+ switch (kind) {
+ case 'spreadsheet': {
+ // Loaded on demand: the readers are only needed when someone attaches.
+ const { default: readXlsxFile } = await import('read-excel-file/browser');
+ const sheets = (await readXlsxFile(file))
+ .map((s) => ({ name: s.sheet, rows: tableRows(cellsToText(s.data as unknown[][])) }))
+ .filter((s) => s.rows.length > 0);
+ if (!sheets.length) toast.error(t('empty', { name }));
+ else setQueue((q) => [...q, { name, sheets }]);
+ return;
+ }
+ case 'csv': {
+ const rows = tableRows(parseCsv(await file.text()));
+ if (!rows.length) toast.error(t('empty', { name }));
+ else setQueue((q) => [...q, { name, sheets: [{ name, rows }] }]);
+ return;
+ }
+ case 'markdown': {
+ const { marked } = await import('marked');
+ insert(cleanHtml(await marked.parse(await file.text()), { keepImages: true }).html, name);
+ return;
+ }
+ case 'html': {
+ const cleaned = cleanHtml(await file.text(), { keepImages: true });
+ insert(
+ cleaned.html,
+ name,
+ cleaned.unsafeRemoved ? t('unsafeRemoved', { count: cleaned.unsafeRemoved }) : undefined,
+ );
+ return;
+ }
+ case 'text':
+ insert(textToHtml(await file.text()), name);
+ return;
+ case 'word': {
+ const { default: mammoth } = await import('mammoth');
+ const { value } = await mammoth.convertToHtml({ arrayBuffer: await file.arrayBuffer() });
+ // Word's images are embedded data: they wait for file storage.
+ const cleaned = cleanHtml(value, { keepImages: false });
+ insert(
+ cleaned.html,
+ name,
+ cleaned.imagesRemoved ? t('imagesLeftOut', { count: cleaned.imagesRemoved }) : undefined,
+ );
+ return;
+ }
+ case 'image':
+ toast.info(t('imageLater', { name }));
+ return;
+ case 'legacyOffice':
+ toast.error(t('legacyOffice', { name }));
+ return;
+ default:
+ toast.error(t('unsupported', { name }));
+ }
+ };
+
+ const attach = async (files: File[]) => {
+ for (const file of files) {
+ try {
+ await readOne(file);
+ } catch (err) {
+ console.error('Failed to attach a file:', err);
+ toast.error(t('readFailed', { name: file.name }));
+ }
+ }
+ };
+
+ const insertTable = (rows: string[][], name: string) => {
+ if (!editor) return;
+ insertImported(editor, tableHtml(rows));
+ toast.success(t('tableInserted', { name, count: rows.length - 1 }));
+ };
+
+ const ui = (
+ <>
+ <input
+ ref={inputRef}
+ type="file"
+ multiple
+ accept={ATTACHMENT_ACCEPT}
+ className="hidden"
+ aria-hidden="true"
+ tabIndex={-1}
+ onChange={(e) => {
+ const files = [...(e.target.files ?? [])];
+ // The same file can be attached again.
+ e.target.value = '';
+ void attach(files);
+ }}
+ />
+ {queue[0] && (
+ <SheetPreviewDialog
+ key={queue[0].name + queue.length}
+ file={queue[0]}
+ room={editor ? MAX_BODY_HTML_LENGTH - editor.getHTML().length : 0}
+ onInsert={(rows) => insertTable(rows, queue[0].name)}
+ onClose={() => setQueue((q) => q.slice(1))}
+ />
+ )}
+ </>
+ );
+
+ return { open: () => inputRef.current?.click(), attach, ui };
+}
+
+/**
+ * A sheet before it goes in: its first rows, and how many there are. A table
+ * the page can't hold is cut to the rows that fit, said so first, since a
+ * page over the size limit can't be saved; one with no room at all can't go
+ * in.
+ */
+function SheetPreviewDialog({
+ file,
+ room,
+ onInsert,
+ onClose,
+}: {
+ file: SheetFile;
+ /** Characters the page can still take before its size limit. */
+ room: number;
+ onInsert: (rows: string[][]) => void;
+ onClose: () => void;
+}) {
+ const t = useTranslations('contentEditor.editor.attach');
+ const [sheetName, setSheetName] = useState(file.sheets[0].name);
+ const [confirming, setConfirming] = useState(false);
+ const sheet = file.sheets.find((s) => s.name === sheetName) ?? file.sheets[0];
+ const dataRows = sheet.rows.length - 1;
+ const [header, ...rest] = sheet.rows;
+ const fit = rowsThatFit(sheet.rows, room);
+ const noRoom = fit < 1 && dataRows > 0;
+ const cut = !noRoom && fit < dataRows;
+ const inserted = cut ? fit : dataRows;
+
+ const insert = () => {
+ if ((inserted > CONFIRM_TABLE_ROWS || cut) && !confirming) {
+ setConfirming(true);
+ return;
+ }
+ onInsert(sheet.rows.slice(0, inserted + 1));
+ onClose();
+ };
+
+ return (
+ <Dialog open onOpenChange={(next) => !next && onClose()}>
+ <DialogContent className="sm:max-w-3xl">
+ <DialogHeader>
+ <DialogTitle className="truncate">{file.name}</DialogTitle>
+ <DialogDescription>
+ {t('previewSummary', {
+ rows: formatNumber(dataRows),
+ columns: formatNumber(header.length),
+ })}
+ </DialogDescription>
+ </DialogHeader>
+ {file.sheets.length > 1 && (
+ <div className="flex items-center gap-2 text-sm">
+ <span className="text-muted-foreground">{t('sheet')}</span>
+ <Select
+ value={sheetName}
+ items={file.sheets.map((s) => ({ value: s.name, label: s.name }))}
+ onValueChange={(v) => {
+ if (!v) return;
+ setSheetName(v);
+ setConfirming(false);
+ }}
+ >
+ <SelectTrigger className="w-60">
+ <SelectValue />
+ </SelectTrigger>
+ <SelectContent>
+ {file.sheets.map((s) => (
+ <SelectItem key={s.name} value={s.name}>
+ {s.name}
+ </SelectItem>
+ ))}
+ </SelectContent>
+ </Select>
+ </div>
+ )}
+ <div className="max-h-80 overflow-auto rounded-md border">
+ <table className="w-full text-left text-xs">
+ <thead className="sticky top-0 bg-muted">
+ <tr>
+ {header.map((cell, i) => (
+ <th key={i} className="whitespace-nowrap border-b px-2 py-1.5 font-medium">
+ {cell}
+ </th>
+ ))}
+ </tr>
+ </thead>
+ <tbody>
+ {rest.slice(0, PREVIEW_ROWS).map((row, r) => (
+ <tr key={r} className="border-b last:border-0">
+ {row.map((cell, i) => (
+ <td key={i} className="max-w-[220px] truncate px-2 py-1.5">
+ {cell}
+ </td>
+ ))}
+ </tr>
+ ))}
+ </tbody>
+ </table>
+ </div>
+ {dataRows > PREVIEW_ROWS && (
+ <p className="text-xs text-muted-foreground">
+ {t('previewMore', { count: formatNumber(dataRows - PREVIEW_ROWS) })}
+ </p>
+ )}
+ {noRoom ? (
+ <p className="rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-sm text-destructive">
+ {t('noRoom')}
+ </p>
+ ) : (
+ confirming && (
+ <p className="rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-400">
+ {cut
+ ? t('confirmCut', { fit: formatNumber(fit), count: formatNumber(dataRows) })
+ : t('confirmLong', { count: formatNumber(dataRows) })}
+ </p>
+ )
+ )}
+ <DialogFooter>
+ <DialogClose render={<Button variant="outline" />}>{t('cancel')}</DialogClose>
+ <Button onClick={insert} disabled={noRoom}>
+ {!confirming
+ ? t('insertTable')
+ : cut
+ ? t('insertFirst', { count: formatNumber(fit) })
+ : t('insertAll', { count: formatNumber(dataRows) })}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+ );
+}
+
+/**
+ * The page under a drag with files: says they can be dropped. Pointer events
+ * pass through, so the drop reaches the editor where the cursor should go.
+ */
+export function DropOverlay() {
+ const t = useTranslations('contentEditor.editor.attach');
+ return (
+ <div className="pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-1 border-2 border-dashed border-primary/40 bg-background/80 text-sm">
+ <Upload className="h-6 w-6 text-muted-foreground" aria-hidden="true" />
+ <span className="font-medium">{t('dropTitle')}</span>
+ <span className="text-xs text-muted-foreground">{t('dropHint')}</span>
+ </div>
+ );
+}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
index 6fa162704..357b53725 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_draft-editor.tsx
@@ -1,9 +1,10 @@
'use client';
-import { useEffect, useState } from 'react';
+import { useEffect, useRef, useState } from 'react';
import { useTranslations } from 'next-intl';
import { toast } from 'sonner';
import { EditorContent, useEditor } from '@tiptap/react';
+import { TextSelection } from '@tiptap/pm/state';
import StarterKit from '@tiptap/starter-kit';
import { TableKit } from '@tiptap/extension-table';
import Image from '@tiptap/extension-image';
@@ -25,6 +26,7 @@ import {
import { draftTitleFromDoc, lengthTarget, safeLinkHref } from '@/lib/content/editor';
import { JsonLd } from '@/lib/content/json-ld-node';
import { cn } from '@/lib/utils';
+import { DropOverlay, useAttachments } from './_attach';
import { HtmlBlock, copyToClipboard } from './_html-block';
import { EditorToolbar } from './_toolbar';
import { useDraftAutosave, type SaveState } from './_use-autosave';
@@ -68,6 +70,10 @@ export function DraftEditor({ draft }: { draft: ContentDraft }) {
// The HTML view's text while it is open; null in the visual editor.
const [htmlSource, setHtmlSource] = useState<string | null>(null);
const [htmlEdited, setHtmlEdited] = useState(false);
+ // Files dropped on the page go in where they land (CE-006).
+ const attachRef = useRef<(files: File[]) => void>(undefined);
+ const [dragging, setDragging] = useState(false);
+ const dragDepth = useRef(0);
const editor = useEditor({
extensions: [
@@ -122,6 +128,19 @@ export function DraftEditor({ draft }: { draft: ContentDraft }) {
window.open(href, '_blank', 'noopener,noreferrer');
return true;
},
+ handleDrop: (view, event, _slice, moved) => {
+ const files = [...(event.dataTransfer?.files ?? [])];
+ if (moved || !files.length) return false;
+ event.preventDefault();
+ const at = view.posAtCoords({ left: event.clientX, top: event.clientY });
+ if (at) {
+ view.dispatch(
+ view.state.tr.setSelection(TextSelection.near(view.state.doc.resolve(at.pos))),
+ );
+ }
+ attachRef.current?.(files);
+ return true;
+ },
},
onUpdate: ({ editor: e }) => {
const next = draftTitleFromDoc(e.getJSON());
@@ -130,6 +149,38 @@ export function DraftEditor({ draft }: { draft: ContentDraft }) {
},
});
+ const attachments = useAttachments(editor);
+ useEffect(() => {
+ attachRef.current = (files) => void attachments.attach(files);
+ });
+
+ // A drag with files over the page shows where they go; one dropped beside
+ // the page (not on its text) goes in at the cursor.
+ const withFiles = (e: React.DragEvent) =>
+ htmlSource === null && [...e.dataTransfer.types].includes('Files');
+ const dropHandlers = {
+ onDragEnter: (e: React.DragEvent) => {
+ if (!withFiles(e)) return;
+ dragDepth.current += 1;
+ setDragging(true);
+ },
+ onDragLeave: (e: React.DragEvent) => {
+ if (!withFiles(e)) return;
+ dragDepth.current -= 1;
+ if (dragDepth.current <= 0) setDragging(false);
+ },
+ onDragOver: (e: React.DragEvent) => {
+ if (withFiles(e)) e.preventDefault();
+ },
+ onDrop: (e: React.DragEvent) => {
+ dragDepth.current = 0;
+ setDragging(false);
+ if (e.defaultPrevented || !withFiles(e)) return;
+ e.preventDefault();
+ void attachments.attach([...e.dataTransfer.files]);
+ },
+ };
+
const openHtmlView = () => {
if (!editor) return;
setHtmlSource(formatHtmlSource(editor.getHTML()));
@@ -263,6 +314,7 @@ export function DraftEditor({ draft }: { draft: ContentDraft }) {
target={lengthTarget(draft.pageType)}
htmlView={htmlSource !== null}
onToggleHtml={htmlSource === null ? openHtmlView : applyHtmlView}
+ onAttach={attachments.open}
/>
)}
@@ -278,25 +330,29 @@ export function DraftEditor({ draft }: { draft: ContentDraft }) {
</div>
)}
- <div className="min-h-0 flex-1 overflow-y-auto">
- {htmlSource !== null && (
- <textarea
- value={htmlSource}
- onChange={(e) => {
- setHtmlSource(e.target.value);
- setHtmlEdited(true);
- }}
- spellCheck={false}
- aria-label={t('html.label')}
- className="block h-full min-h-[600px] w-full resize-none bg-muted/20 px-7 py-5 font-mono text-[12.5px] leading-relaxed outline-none"
- />
- )}
- <div
- className={cn('mx-auto max-w-[720px] px-7 pt-7 pb-20', htmlSource !== null && 'hidden')}
- >
- <EditorContent editor={editor} />
+ <div className="relative min-h-0 flex-1" {...dropHandlers}>
+ <div className="h-full overflow-y-auto">
+ {htmlSource !== null && (
+ <textarea
+ value={htmlSource}
+ onChange={(e) => {
+ setHtmlSource(e.target.value);
+ setHtmlEdited(true);
+ }}
+ spellCheck={false}
+ aria-label={t('html.label')}
+ className="block h-full min-h-[600px] w-full resize-none bg-muted/20 px-7 py-5 font-mono text-[12.5px] leading-relaxed outline-none"
+ />
+ )}
+ <div
+ className={cn('mx-auto max-w-[720px] px-7 pt-7 pb-20', htmlSource !== null && 'hidden')}
+ >
+ <EditorContent editor={editor} />
+ </div>
</div>
+ {dragging && <DropOverlay />}
</div>
+ {attachments.ui}
</div>
);
}
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx
index 66368d77c..76619ab85 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/_toolbar.tsx
@@ -16,6 +16,7 @@ import {
Link2,
List,
ListOrdered,
+ Paperclip,
Quote,
Rows3,
Table2,
@@ -39,7 +40,7 @@ import { HtmlBlockDialog } from './_html-block';
/**
* The editor's toolbar (CE-004, spec §6): H1 H2 H3 · B I link · lists,
- * quote · table, image, HTML block · </> HTML, and the length counter against the page
+ * quote · table, image, HTML block, attach a file · </> HTML, and the length counter against the page
* type's target. Inside a table it adds a row, a column, or removes the
* table. While the HTML view is open, only its own button works.
*/
@@ -48,11 +49,13 @@ export function EditorToolbar({
target,
htmlView,
onToggleHtml,
+ onAttach,
}: {
editor: Editor;
target: number;
htmlView: boolean;
onToggleHtml: () => void;
+ onAttach: () => void;
}) {
const t = useTranslations('contentEditor.editor.toolbar');
const [dialog, setDialog] = useState<'link' | 'image' | 'htmlBlock' | null>(null);
@@ -134,6 +137,7 @@ export function EditorToolbar({
},
{ key: 'image', icon: ImagePlus, on: false, run: () => setDialog('image') },
{ key: 'htmlBlock', icon: Code2, on: false, run: () => setDialog('htmlBlock') },
+ { key: 'attach', icon: Paperclip, on: false, run: onAttach },
],
];
const tableTools = [
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
index 020241690..895add911 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
@@ -30,7 +30,17 @@ const brandState = vi.hoisted(() => ({
vi.mock('@/stores/use-brand-store', () => ({
useBrandStore: (selector: (state: typeof brandState) => unknown) => selector(brandState),
}));
-const toast = vi.hoisted(() => Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn() }));
+const toast = vi.hoisted(() =>
+ Object.assign(vi.fn(), { success: vi.fn(), error: vi.fn(), info: vi.fn() }),
+);
+vi.mock('mammoth', () => ({
+ default: {
+ convertToHtml: async () => ({
+ value:
+ '<h2>From Word</h2><p>Body <strong>bold</strong> <img src="data:image/png;base64,AA"></p>',
+ }),
+ },
+}));
vi.mock('sonner', () => ({ toast }));
(
@@ -42,6 +52,25 @@ vi.mock('sonner', () => ({ toast }));
// jsdom has no layout, and its ranges can't be measured. ProseMirror measures
// one when it scrolls the cursor into view (after inserting a block), which
// otherwise throws after the test, on a timer.
+// Nor can jsdom's files be read as text or bytes, as browsers' can.
+function readBlob<T>(blob: Blob, read: (reader: FileReader) => void): Promise<T> {
+ return new Promise((resolve, reject) => {
+ const reader = new FileReader();
+ reader.onload = () => resolve(reader.result as T);
+ reader.onerror = () => reject(reader.error);
+ read(reader);
+ });
+}
+if (!('text' in Blob.prototype)) {
+ Object.assign(Blob.prototype, {
+ text(this: Blob) {
+ return readBlob<string>(this, (r) => r.readAsText(this));
+ },
+ arrayBuffer(this: Blob) {
+ return readBlob<ArrayBuffer>(this, (r) => r.readAsArrayBuffer(this));
+ },
+ });
+}
if (!('getClientRects' in Range.prototype)) {
Object.assign(Range.prototype, {
getClientRects: () => [] as unknown as DOMRectList,
@@ -93,6 +122,8 @@ beforeEach(() => {
brandState.setActiveBrand.mockReset();
toast.mockReset();
toast.success.mockReset();
+ toast.error.mockReset();
+ toast.info.mockReset();
});
afterEach(() => {
@@ -258,6 +289,127 @@ describe('the content editor', () => {
expect(target.textContent).toBe('gartner.com/x');
});
+ describe('attaching files', () => {
+ const said = () =>
+ toast.success.mock.calls.length +
+ toast.error.mock.calls.length +
+ toast.info.mock.calls.length;
+ /** Attaches the files, and waits until each has said something or a preview opened. */
+ async function attach(...files: File[]) {
+ const input = container.querySelector<HTMLInputElement>('input[type="file"]')!;
+ Object.defineProperty(input, 'files', { value: files, configurable: true });
+ const before = said();
+ await act(async () => {
+ input.dispatchEvent(new Event('change', { bubbles: true }));
+ });
+ // Reading a file, and loading its reader the first time, take real time.
+ for (let i = 0; i < 80; i++) {
+ if (said() - before >= files.length || document.querySelector('[role="dialog"]')) break;
+ await act(() => new Promise((resolve) => setTimeout(resolve, 25)));
+ }
+ }
+ const dialogButton = (name: string) =>
+ [...document.querySelectorAll<HTMLButtonElement>('[role="dialog"] button')].find(
+ (b) => b.textContent === name,
+ );
+
+ beforeEach(async () => {
+ getContentDraft.mockResolvedValue(draft({ bodyHtml: '<p>Intro</p>' }));
+ await renderPage();
+ });
+
+ it('previews a CSV and inserts it as a table, its first row the header', async () => {
+ await attach(new File(['Keyword,Volume\ncrm forecasting,210\npipeline,96\n'], 'kw.csv'));
+ const dialog = document.querySelector('[role="dialog"]')!;
+ expect(dialog.textContent).toContain('kw.csv');
+ expect(dialog.textContent).toContain('2 rows · 2 columns');
+
+ await act(async () => dialogButton('Insert as table')!.click());
+ const table = container.querySelector('.ProseMirror table')!;
+ expect([...table.querySelectorAll('th')].map((c) => c.textContent)).toEqual([
+ 'Keyword',
+ 'Volume',
+ ]);
+ expect(table.querySelectorAll('tr')).toHaveLength(3);
+ expect(toast.success).toHaveBeenCalledWith('Table inserted from kw.csv · 2 rows');
+ });
+
+ it('puts the next import under a table, not in its cell', async () => {
+ await attach(new File(['A,B\n1,2\n'], 'one.csv'));
+ await act(async () => dialogButton('Insert as table')!.click());
+ await attach(new File(['After the table'], 'note.txt'));
+ const page = container.querySelector('.ProseMirror')!;
+ expect(page.querySelectorAll('table')).toHaveLength(1);
+ expect(page.querySelector('table')!.textContent).not.toContain('After the table');
+ expect(page.textContent).toContain('After the table');
+ });
+
+ it('asks before inserting a table over 200 rows', async () => {
+ const csv = ['n', ...Array.from({ length: 250 }, (_, i) => String(i))].join('\n');
+ await attach(new File([csv], 'long.csv'));
+ await act(async () => dialogButton('Insert as table')!.click());
+ expect(container.querySelector('.ProseMirror table')).toBeNull();
+ expect(document.querySelector('[role="dialog"]')!.textContent).toContain(
+ 'This table has 250 rows.',
+ );
+ await act(async () => dialogButton('Insert all 250 rows')!.click());
+ expect(container.querySelectorAll('.ProseMirror table tr')).toHaveLength(251);
+ });
+
+ it('inserts only the rows that fit in the page’s size limit, after saying so', async () => {
+ const cell = 'x'.repeat(1000);
+ const csv = ['a,b,c', ...Array.from({ length: 1000 }, () => `${cell},${cell},${cell}`)].join(
+ '\n',
+ );
+ await attach(new File([csv], 'big.csv'));
+ await act(async () => dialogButton('Insert as table')!.click());
+ expect(container.querySelector('.ProseMirror table')).toBeNull();
+ const note = document.querySelector('[role="dialog"]')!.textContent!;
+ const fit = Number(
+ /Only the first ([\d,]+) of 1,000 rows fit/.exec(note)![1].replace(',', ''),
+ );
+ expect(fit).toBeGreaterThan(100);
+ expect(fit).toBeLessThan(1000);
+ await act(async () => dialogButton(`Insert the first ${fit} rows`)!.click());
+ expect(container.querySelectorAll('.ProseMirror table tr')).toHaveLength(fit + 1);
+ // As the editor saves it, the page stays under the limit.
+ const editorHtml = container.querySelector('.ProseMirror')!.innerHTML;
+ expect(editorHtml.length).toBeLessThan(500_000);
+ });
+
+ it('imports Markdown and Word as content, cleaned like a paste', async () => {
+ await attach(
+ new File(
+ ['## From Markdown\n\nA *note* with a [link](https://acme.com/?utm_source=x).'],
+ 'notes.md',
+ ),
+ );
+ const page = container.querySelector('.ProseMirror')!;
+ expect(page.querySelector('h2')!.textContent).toBe('From Markdown');
+ expect(page.querySelector('a')!.getAttribute('href')).toBe('https://acme.com/');
+ expect(toast.success).toHaveBeenLastCalledWith('notes.md imported');
+
+ await attach(new File(['PK'], 'brief.docx'));
+ expect([...page.querySelectorAll('h2')].map((h) => h.textContent)).toContain('From Word');
+ expect(page.querySelector('img')).toBeNull();
+ expect(toast.success).toHaveBeenLastCalledWith('brief.docx imported · 1 image left out');
+ });
+
+ it('says what it can’t take: images, old formats, large files', async () => {
+ await attach(
+ new File(['x'], 'shoe.png'),
+ new File(['x'], 'old.xls'),
+ new File(['x'.repeat(10 * 1024 * 1024 + 1)], 'huge.txt'),
+ );
+ expect(toast.info).toHaveBeenCalledWith(
+ "Images can't be attached yet. Add shoe.png with Insert an image, by its address.",
+ );
+ expect(toast.error).toHaveBeenCalledWith('Save old.xls as .xlsx or .docx, then attach it.');
+ expect(toast.error).toHaveBeenCalledWith('huge.txt is over 10 MB.');
+ expect(container.querySelector('.ProseMirror')!.textContent).toBe('Intro');
+ });
+ });
+
it('follows the draft’s brand in the sidebar', async () => {
getContentDraft.mockResolvedValue(draft({ brandId: 'b2' }));
await renderPage();
diff --git a/web/src/lib/content/attachments.test.ts b/web/src/lib/content/attachments.test.ts
new file mode 100644
index 000000000..94def1dc1
--- /dev/null
+++ b/web/src/lib/content/attachments.test.ts
@@ -0,0 +1,85 @@
+import { describe, expect, it } from 'vitest';
+import { attachmentKind, rowsThatFit, tableHtml, tableRows, textToHtml } from './attachments';
+
+describe('attachmentKind', () => {
+ it('reads a file’s kind from its extension, whatever its case', () => {
+ expect(attachmentKind('Q3 keywords.XLSX')).toBe('spreadsheet');
+ expect(attachmentKind('products.csv')).toBe('csv');
+ expect(attachmentKind('notes.md')).toBe('markdown');
+ expect(attachmentKind('page.htm')).toBe('html');
+ expect(attachmentKind('brief.docx')).toBe('word');
+ expect(attachmentKind('readme.txt')).toBe('text');
+ expect(attachmentKind('shoe.webp')).toBe('image');
+ });
+
+ it('asks for the old Office formats as new ones, and names the rest unsupported', () => {
+ expect(attachmentKind('old.xls')).toBe('legacyOffice');
+ expect(attachmentKind('old.doc')).toBe('legacyOffice');
+ expect(attachmentKind('deck.pptx')).toBe('unsupported');
+ expect(attachmentKind('no-extension')).toBe('unsupported');
+ });
+});
+
+describe('tableRows', () => {
+ it('pads short rows, and drops empty rows and empty trailing columns', () => {
+ expect(
+ tableRows([
+ ['Keyword', 'Volume', '', ''],
+ ['crm forecasting', '210'],
+ ['', '', ''],
+ [' pipeline ', '96', '', ''],
+ ]),
+ ).toEqual([
+ ['Keyword', 'Volume'],
+ ['crm forecasting', '210'],
+ ['pipeline', '96'],
+ ]);
+ });
+
+ it('keeps at most 30 columns', () => {
+ const wide = [Array.from({ length: 40 }, (_, i) => `c${i}`)];
+ expect(tableRows(wide)[0]).toHaveLength(30);
+ });
+});
+
+describe('tableHtml', () => {
+ it('makes the first row the header and escapes every cell', () => {
+ expect(
+ tableHtml([
+ ['Name', 'Note'],
+ ['<b>X</b>', 'A & "B"'],
+ ]),
+ ).toBe(
+ '<table><tbody><tr><th><p>Name</p></th><th><p>Note</p></th></tr>' +
+ '<tr><td><p>&lt;b&gt;X&lt;/b&gt;</p></td><td><p>A &amp; &quot;B&quot;</p></td></tr></tbody></table>',
+ );
+ });
+});
+
+describe('rowsThatFit', () => {
+ // As the editor saves them: 350 for the table, 9 a row, 40 a cell plus its text.
+ const rows = [['a'], ['xx'], ['xx']];
+
+ it('counts the data rows that fit after the header, as the editor saves a table', () => {
+ expect(rowsThatFit(rows, 10_000)).toBe(2);
+ expect(rowsThatFit(rows, 400 + 51)).toBe(1);
+ expect(rowsThatFit(rows, 400 + 50)).toBe(0);
+ });
+
+ it('says when not even the header fits', () => {
+ expect(rowsThatFit(rows, 399)).toBe(-1);
+ });
+
+ it('counts a cell’s text as it is escaped', () => {
+ expect(rowsThatFit([['a'], ['<<']], 400 + 9 + 40 + 8)).toBe(1);
+ expect(rowsThatFit([['a'], ['<<']], 400 + 9 + 40 + 7)).toBe(0);
+ });
+});
+
+describe('textToHtml', () => {
+ it('parts paragraphs at blank lines and breaks lines within them', () => {
+ expect(textToHtml('First line\nsame paragraph\r\n\r\nSecond <one>\n\n\n')).toBe(
+ '<p>First line<br>same paragraph</p><p>Second &lt;one&gt;</p>',
+ );
+ });
+});
diff --git a/web/src/lib/content/attachments.ts b/web/src/lib/content/attachments.ts
new file mode 100644
index 000000000..7829855b5
--- /dev/null
+++ b/web/src/lib/content/attachments.ts
@@ -0,0 +1,134 @@
+/**
+ * Files attached to a draft (Content Editor CE-006, spec §9): what each kind
+ * becomes in the page. A spreadsheet is previewed and inserted as a table;
+ * Markdown, HTML, Word and text are imported as content, cleaned like a
+ * paste. Files are data, never instructions (CHAT-05): they only ever become
+ * page content.
+ */
+
+/** The most a file can be, as the spec's attachment limit. */
+export const MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;
+
+/** A table this long asks before it goes into the page. */
+export const CONFIRM_TABLE_ROWS = 200;
+
+/** Columns a table keeps; a wider sheet is cut at this many. */
+export const MAX_TABLE_COLUMNS = 30;
+
+export type AttachmentKind =
+ | 'spreadsheet'
+ | 'csv'
+ | 'markdown'
+ | 'html'
+ | 'text'
+ | 'word'
+ | 'image'
+ | 'legacyOffice'
+ | 'unsupported';
+
+const KINDS: Record<string, AttachmentKind> = {
+ xlsx: 'spreadsheet',
+ csv: 'csv',
+ md: 'markdown',
+ markdown: 'markdown',
+ html: 'html',
+ htm: 'html',
+ txt: 'text',
+ docx: 'word',
+ png: 'image',
+ jpg: 'image',
+ jpeg: 'image',
+ gif: 'image',
+ webp: 'image',
+ svg: 'image',
+ // The old binary formats: saved again as .xlsx or .docx, they import.
+ xls: 'legacyOffice',
+ doc: 'legacyOffice',
+};
+
+/** What a file is, by its extension. */
+export function attachmentKind(fileName: string): AttachmentKind {
+ const ext = fileName.toLowerCase().split('.').pop() ?? '';
+ return KINDS[ext] ?? 'unsupported';
+}
+
+/** What the file picker offers. */
+export const ATTACHMENT_ACCEPT = '.xlsx,.csv,.md,.markdown,.html,.htm,.txt,.docx';
+
+function escapeHtml(text: string) {
+ return text
+ .replace(/&/g, '&amp;')
+ .replace(/</g, '&lt;')
+ .replace(/>/g, '&gt;')
+ .replace(/"/g, '&quot;');
+}
+
+/**
+ * A sheet's rows as they go into a table: as wide as its widest row (up to
+ * MAX_TABLE_COLUMNS), short rows padded, empty rows and empty trailing
+ * columns dropped.
+ */
+export function tableRows(rows: string[][]): string[][] {
+ const kept = rows.filter((row) => row.some((cell) => cell.trim() !== ''));
+ let width = 0;
+ for (const row of kept) {
+ for (let i = row.length - 1; i >= 0; i--) {
+ if (row[i].trim() !== '') {
+ width = Math.max(width, i + 1);
+ break;
+ }
+ }
+ }
+ width = Math.min(width, MAX_TABLE_COLUMNS);
+ return kept.map((row) => Array.from({ length: width }, (_, i) => (row[i] ?? '').trim()));
+}
+
+/** A table for the editor, its first row as the header; cell text escaped. */
+export function tableHtml(rows: string[][]): string {
+ const body = rows
+ .map((row, r) => {
+ const tag = r === 0 ? 'th' : 'td';
+ return `<tr>${row.map((cell) => `<${tag}><p>${escapeHtml(cell)}</p></${tag}>`).join('')}</tr>`;
+ })
+ .join('');
+ return `<table><tbody>${body}</tbody></table>`;
+}
+
+/** What the editor adds around each cell's text when it saves a table. */
+const SAVED_CELL_OVERHEAD = '<td colspan="1" rowspan="1"><p></p></td>'.length;
+const SAVED_ROW_OVERHEAD = '<tr></tr>'.length;
+/** The table's own tags, its column widths included: a generous allowance. */
+const SAVED_TABLE_OVERHEAD = 200 + MAX_TABLE_COLUMNS * '<col>'.length;
+
+/**
+ * How many of a sheet's data rows fit in `room` characters of the saved
+ * page, the header always going in. Measured as the editor saves a table
+ * (`<td colspan="1" rowspan="1"><p>…</p></td>` for each cell), so a table
+ * that fits here doesn't put the page over its size limit. -1 when not even
+ * the header fits.
+ */
+export function rowsThatFit(rows: string[][], room: number): number {
+ const rowLength = (row: string[]) =>
+ SAVED_ROW_OVERHEAD +
+ row.reduce((sum, cell) => sum + SAVED_CELL_OVERHEAD + escapeHtml(cell).length, 0);
+ let used = SAVED_TABLE_OVERHEAD + (rows[0] ? rowLength(rows[0]) : 0);
+ if (used > room) return -1;
+ let fit = 0;
+ for (const row of rows.slice(1)) {
+ used += rowLength(row);
+ if (used > room) break;
+ fit++;
+ }
+ return fit;
+}
+
+/** Plain text as paragraphs: blank lines part them, a single newline breaks a line. */
+export function textToHtml(text: string): string {
+ return text
+ .replace(/^/, '')
+ .split(/\r?\n\s*\r?\n/)
+ .map((block) => block.trim())
+ .filter(Boolean)
+ .map((block) => `<p>${escapeHtml(block).replace(/\r?\n/g, '<br>')}</p>`)
+ .join('');
+}
diff --git a/web/yarn.lock b/web/yarn.lock
index 8f1a68773..d835066ec 100644
--- a/web/yarn.lock
+++ b/web/yarn.lock
@@ -2818,6 +2818,11 @@
loupe "^3.1.4"
tinyrainbow "^2.0.0"
+"@xmldom/xmldom@^0.8.6":
+ version "0.8.15"
+ resolved "https://registry.yarnpkg.com/@xmldom/xmldom/-/xmldom-0.8.15.tgz#71ebf80729e4e95221d519ac9b1e1eaea7784907"
+ integrity sha512-/5NV/vDALVFDXgLmfsy9TRCBlKwO2LNBFzpzvb9iIj+jR+eSc6DLYYvVOdivT/jm7MtU6TebYuRmzEOI7w40UA==
+
abs-svg-path@^0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/abs-svg-path/-/abs-svg-path-0.1.1.tgz#df601c8e8d2ba10d4a76d625e236a9a39c2723bf"
@@ -2910,6 +2915,13 @@ argparse@^2.0.1:
resolved "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
+argparse@~1.0.3:
+ version "1.0.10"
+ resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
+ integrity sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==
+ dependencies:
+ sprintf-js "~1.0.2"
+
aria-query@^5.3.2:
version "5.3.2"
resolved "https://registry.npmjs.org/aria-query/-/aria-query-5.3.2.tgz"
@@ -3065,7 +3077,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-0.0.8.tgz#1101e9544f4a76b1bc3b26d452ca96d7a35e7978"
integrity sha512-3XSA2cR/h/73EzlXXdU6YNycmYI7+kicTxks4eJg2g39biHR84slg2+des+p7iHYhbRg/udIS4TD53WabcOUkw==
-base64-js@^1.1.2, base64-js@^1.3.0:
+base64-js@^1.1.2, base64-js@^1.3.0, base64-js@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
@@ -3388,6 +3400,11 @@ core-js@^3.38.1:
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.49.0.tgz#8b4d520ac034311fa21aa616f017ada0e0dbbddd"
integrity sha512-es1U2+YTtzpwkxVLwAFdSpaIMyQaq0PBgm3YD1W3Qpsn1NAmO3KSgZfu+oGSWVu6NvLHoHCV/aYcsE5wiB7ALg==
+core-util-is@~1.0.0:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.3.tgz#a6042d3634c2b27e9328f837b965fac83808db85"
+ integrity sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==
+
cors@^2.8.5:
version "2.8.6"
resolved "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz"
@@ -3668,6 +3685,11 @@ diff@^8.0.2:
resolved "https://registry.npmjs.org/diff/-/diff-8.0.3.tgz"
integrity sha512-qejHi7bcSD4hQAZE0tNAawRK1ZtafHDmMTMkrrIGgSLl7hTnQHmKCeB45xAcbfTqK2zowkM3j3bHt/4b/ARbYQ==
+dingbat-to-unicode@^1.0.1:
+ version "1.0.2"
+ resolved "https://registry.yarnpkg.com/dingbat-to-unicode/-/dingbat-to-unicode-1.0.2.tgz#3c2ee8421480f2c136a82b284aaf45a5a6f36034"
+ integrity sha512-R0bRerYzy/EZP6QzD3Hkl6JjUDA1Mnn+pd928w0nWjPzihnbAR6dcjGJGiRyznj5E4S1duEKzWrTqw02DPcdzg==
+
doctrine@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz"
@@ -3724,6 +3746,13 @@ dotenv@^17.2.1:
resolved "https://registry.npmjs.org/dotenv/-/dotenv-17.3.1.tgz"
integrity sha512-IO8C/dzEb6O3F9/twg6ZLXz164a2fhTnEWb95H23Dm4OuN+92NmEAlTrupP9VW6Jm3sO26tQlqyvyi4CsnY9GA==
+duck@^0.1.12:
+ version "0.1.12"
+ resolved "https://registry.yarnpkg.com/duck/-/duck-0.1.12.tgz#de7adf758421230b6d7aee799ce42670586b9efa"
+ integrity sha512-wkctla1O6VfP89gQ+J/yDesM0S7B7XLXjKGzXxMDVFg7uEn706niAtyYovKbyq1oT9YwDcly721/iUWoc8MVRg==
+ dependencies:
+ underscore "^1.13.1"
+
dunder-proto@^1.0.0, dunder-proto@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz"
@@ -4922,6 +4951,11 @@ ignore@^7.0.5:
resolved "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz"
integrity sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==
+immediate@~3.0.5:
+ version "3.0.6"
+ resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
+ integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==
+
immer@^10.1.1:
version "10.2.0"
resolved "https://registry.npmjs.org/immer/-/immer-10.2.0.tgz"
@@ -5306,6 +5340,11 @@ isarray@^2.0.5:
resolved "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz"
integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==
+isarray@~1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
+ integrity sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==
+
isexe@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz"
@@ -5464,6 +5503,16 @@ jsonfile@^6.0.1:
object.assign "^4.1.4"
object.values "^1.1.6"
+jszip@^3.7.1:
+ version "3.10.2"
+ resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.2.tgz#9fee8cfaaffb601f6c8796ecc522e4f81cbe88bf"
+ integrity sha512-3l+rb15IOWtUhU0H5MFqES/T6Kh7abYwjosBey/vD6hDt8zoEffkSC5Ws5SGtgVw3gBx2NEbhTeSW1+kWkpyTQ==
+ dependencies:
+ lie "~3.3.0"
+ pako "~1.0.2"
+ readable-stream "~2.3.6"
+ setimmediate "^1.0.5"
+
keyv@^4.5.4:
version "4.5.4"
resolved "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz"
@@ -5501,6 +5550,13 @@ levn@^0.4.1:
prelude-ls "^1.2.1"
type-check "~0.4.0"
+lie@~3.3.0:
+ version "3.3.0"
+ resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a"
+ integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==
+ dependencies:
+ immediate "~3.0.5"
+
version "1.31.1"
resolved "https://registry.yarnpkg.com/lightningcss-android-arm64/-/lightningcss-android-arm64-1.31.1.tgz#609ff48332adff452a8157a7c2842fd692a8eac4"
@@ -5630,6 +5686,15 @@ loose-envify@^1.4.0:
dependencies:
js-tokens "^3.0.0 || ^4.0.0"
+lop@^0.4.2:
+ version "0.4.2"
+ resolved "https://registry.yarnpkg.com/lop/-/lop-0.4.2.tgz#c9c2f958a39b9da1c2f36ca9ad66891a9fe84640"
+ integrity sha512-RefILVDQ4DKoRZsJ4Pj22TxE3omDO47yFpkIBoDKzkqPRISs5U1cnAdg/5583YPkWPaLIYHOKRMQSvjFsO26cw==
+ dependencies:
+ duck "^0.1.12"
+ option "~0.2.1"
+ underscore "^1.13.1"
+
loupe@^3.1.0, loupe@^3.1.4:
version "3.2.1"
resolved "https://registry.yarnpkg.com/loupe/-/loupe-3.2.1.tgz#0095cf56dc5b7a9a7c08ff5b1a8796ec8ad17e76"
@@ -5659,6 +5724,20 @@ magic-string@^0.30.17, magic-string@^0.30.21:
dependencies:
"@jridgewell/sourcemap-codec" "^1.5.5"
+ version "1.13.0"
+ resolved "https://registry.yarnpkg.com/mammoth/-/mammoth-1.13.0.tgz#c054d53bfe4f47ca4713f2e9af93abf5b10bd1f2"
+ integrity sha512-2cawcYFcP7ISfXbBcL9lmVgTNWo88v/52ND1gnywHtVT/pX0//puPnf0iMPV9ZgmuvNOE+zkIhDgZ9M2c2dDDg==
+ dependencies:
+ "@xmldom/xmldom" "^0.8.6"
+ argparse "~1.0.3"
+ base64-js "^1.5.1"
+ dingbat-to-unicode "^1.0.1"
+ jszip "^3.7.1"
+ lop "^0.4.2"
+ underscore "^1.13.1"
+ xmlbuilder "^10.0.0"
+
markdown-table@^3.0.0:
version "3.0.4"
resolved "https://registry.yarnpkg.com/markdown-table/-/markdown-table-3.0.4.tgz#fe44d6d410ff9d6f2ea1797a3f60aa4d2b631c2a"
@@ -6505,6 +6584,11 @@ open@^11.0.0:
powershell-utils "^0.1.0"
wsl-utils "^0.3.0"
+option@~0.2.1:
+ version "0.2.4"
+ resolved "https://registry.yarnpkg.com/option/-/option-0.2.4.tgz#fd475cdf98dcabb3cb397a3ba5284feb45edbfe4"
+ integrity sha512-pkEqbDyl8ou5cpq+VsnQbe/WlEy5qS7xPzMS1U55OCG9KPvwFD46zDbxQIj3egJSFc3D+XhYOPUzz49zQAVy7A==
+
optionator@^0.9.3:
version "0.9.4"
resolved "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz"
@@ -6575,7 +6659,7 @@ pako@^0.2.5:
resolved "https://registry.yarnpkg.com/pako/-/pako-0.2.9.tgz#f3f7522f4ef782348da8161bad9ecfd51bf83a75"
integrity sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA==
-pako@~1.0.5:
+pako@~1.0.2, pako@~1.0.5:
version "1.0.11"
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf"
integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==
@@ -6818,6 +6902,11 @@ pretty-ms@^9.2.0:
dependencies:
parse-ms "^4.0.0"
+process-nextick-args@~2.0.0:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
+ integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==
+
prompts@^2.4.2:
version "2.4.2"
resolved "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz"
@@ -7080,6 +7169,19 @@ [email protected]:
unzipper-esm "^0.13.3"
worker-f "^0.1.12"
+readable-stream@~2.3.6:
+ version "2.3.8"
+ resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b"
+ integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==
+ dependencies:
+ core-util-is "~1.0.0"
+ inherits "~2.0.3"
+ isarray "~1.0.0"
+ process-nextick-args "~2.0.0"
+ safe-buffer "~5.1.1"
+ string_decoder "~1.1.1"
+ util-deprecate "~1.0.1"
+
recast@^0.23.11:
version "0.23.11"
resolved "https://registry.npmjs.org/recast/-/recast-0.23.11.tgz"
@@ -7361,6 +7463,11 @@ safe-array-concat@^1.1.3:
has-symbols "^1.1.0"
isarray "^2.0.5"
+safe-buffer@~5.1.0, safe-buffer@~5.1.1:
+ version "5.1.2"
+ resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
+ integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
+
safe-buffer@~5.2.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
@@ -7495,6 +7602,11 @@ set-proto@^1.0.0:
es-errors "^1.3.0"
es-object-atoms "^1.0.0"
+setimmediate@^1.0.5:
+ version "1.0.5"
+ resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
+ integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==
+
setprototypeof@~1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz"
@@ -7687,6 +7799,11 @@ space-separated-tokens@^2.0.0:
resolved "https://registry.yarnpkg.com/space-separated-tokens/-/space-separated-tokens-2.0.2.tgz#1ecd9d2350a3844572c3f4a312bceb018348859f"
integrity sha512-PEGlAwrG8yXGXRjW32fGbg66JAlOAwbObuqVoJpv/mRgoWDQfgH1wDPvtzWyUSNAXBGSk8h755YDbbcEy3SH2Q==
+sprintf-js@~1.0.2:
+ version "1.0.3"
+ resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
+ integrity sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==
+
stable-hash@^0.0.5:
version "0.0.5"
resolved "https://registry.npmjs.org/stable-hash/-/stable-hash-0.0.5.tgz"
@@ -7818,6 +7935,13 @@ string_decoder@^1.1.1:
dependencies:
safe-buffer "~5.2.0"
+string_decoder@~1.1.1:
+ version "1.1.1"
+ resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8"
+ integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==
+ dependencies:
+ safe-buffer "~5.1.0"
+
stringify-entities@^4.0.0:
version "4.0.4"
resolved "https://registry.yarnpkg.com/stringify-entities/-/stringify-entities-4.0.4.tgz#b3b79ef5f277cc4ac73caeb0236c5ba939b3a4f3"
@@ -8220,6 +8344,11 @@ unbox-primitive@^1.1.0:
has-symbols "^1.1.0"
which-boxed-primitive "^1.1.1"
+underscore@^1.13.1:
+ version "1.13.8"
+ resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.8.tgz#a93a21186c049dbf0e847496dba72b7bd8c1e92b"
+ integrity sha512-DXtD3ZtEQzc7M8m4cXotyHR+FAS18C64asBYY5vqZexfYryNNnDc02W4hKg3rdQuqOYas1jkseX0+nZXjTXnvQ==
+
undici-types@~6.21.0:
version "6.21.0"
resolved "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz"
@@ -8387,7 +8516,7 @@ use-sync-external-store@^1.2.2, use-sync-external-store@^1.4.0, use-sync-externa
resolved "https://registry.npmjs.org/use-sync-external-store/-/use-sync-external-store-1.6.0.tgz"
integrity sha512-Pp6GSwGP/NrPIrxVFAIkOQeyw8lFenOHijQWkUTrDvrF4ALqylP2C/KCkeS9dpUM3KvYRQhna5vt7IL95+ZQ9w==
-util-deprecate@^1.0.1, util-deprecate@^1.0.2:
+util-deprecate@^1.0.1, util-deprecate@^1.0.2, util-deprecate@~1.0.1:
version "1.0.2"
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==
@@ -8686,6 +8815,11 @@ xml-name-validator@^5.0.0:
resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-5.0.0.tgz#82be9b957f7afdacf961e5980f1bf227c0bf7673"
integrity sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==
+xmlbuilder@^10.0.0:
+ version "10.1.1"
+ resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-10.1.1.tgz#8cae6688cc9b38d850b7c8d3c0a4161dcaf475b0"
+ integrity sha512-OyzrcFLL/nb6fMGHbiRDuPup9ljBycsdCypwuyg5AAHvyWzGfChJpCXMG88AGTIMFhGZ9RccFN1e6lhg3hkwKg==
+
xmlchars@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/xmlchars/-/xmlchars-2.2.0.tgz#060fe1bcb7f9c76fe2a17db86a9bc3ab894210cb"