@medway-ui/core 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +9 -7
- package/dist/index.d.ts +9 -7
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/dist/note-editor.d.mts +121 -0
- package/dist/note-editor.d.ts +121 -0
- package/dist/note-editor.js +3 -0
- package/dist/note-editor.js.map +1 -0
- package/dist/note-editor.mjs +3 -0
- package/dist/note-editor.mjs.map +1 -0
- package/package.json +58 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/NoteEditor.tsx","../src/lib/utils.ts"],"names":["customTwMerge","extendTailwindMerge","cn","inputs","clsx","toImageFiles","list","file","sanitizeTitle","value","isSelectionAtDocStart","state","selection","Selection","extractImageSrcs","json","srcs","walk","node","_a","record","src","toEditorDocument","input","generateJSON","buildExtensions","toEditorContent","normalizeDocument","EMPTY_DOCUMENT","DEFAULT_IMAGE_DELETE_GRACE_MS","runUndo","editor","runRedo","canUndo","canRedo","setLink","previousHref","url","chain","href","sanitizeLinkHref","TOOLBAR_GROUPS","Bold","Italic","Underline","Strikethrough","Code","HeadingH2","HeadingH3","ListUnordered","ListOrdered","DoubleQuotesL","WindowCodeBlock","LinkIcon","ArrowUndoUpLeft","Redo","ToolbarSep","jsx","visibleSlashCommandIds","commandIds","canUploadImage","id","wrapperClasses","titleClasses","NoteEditor","forwardRef","ref","_b","initialDocument","initialTitle","titlePlaceholder","showTitle","onChange","editable","autofocus","extraExtensions","toolbar","onImageUpload","onImageRemoved","imageDeleteGraceMs","className","divProps","__objRest","initial","useMemo","title","setTitle","useState","titleRef","useRef","autofocusTitleRef","resizeTitle","useCallback","el","useLayoutEffect","useEffect","handleTitleChange","event","focusTitleAtEnd","end","showTitleRef","slashState","setSlashState","EMPTY_SLASH_STATE","selectedIndex","setSelectedIndex","slashRef","createSlashCommand","slashCommand","slashStateRef","selectedIndexRef","onImageUploadRef","onImageRemovedRef","imageDeleteGraceMsRef","uploadedThisSessionRef","previousImageUrlsRef","pendingDeletesRef","isMountedRef","scheduleImageDelete","existing","timeoutId","cancelScheduledImageDelete","pending","fileInputRef","openImageFilePicker","uploadCount","setUploadCount","insertImageFileRef","extensions","editorProps","view","slash","index","files","pos","_view","useEditor","instance","currentSrcs","handleTitleKeyDown","missing","assertSchemaContract","insertImageFile","upload","count","error","handleImageFileInputChange","frame","handleViewportChange","rerenderToolbar","useReducer","update","useImperativeHandle","position","html","generateHTML","doc","options","jsxs","__spreadProps","__spreadValues","group","groupIndex","item","_c","_d","Icon","active","disabled","ImageIcon","EditorContent","createPortal","command","getSlashCommand"],"mappings":"yyBAEA,IAAA,EAAA,CAAA,MAAA,CAAA,cAAA,CAAA,EAAA,CAAA,MAAA,CAAA,gBAAA,CAAA,IAAA,EAAA,CAAA,MAAA,CAAA,yBAAA,CAAA,IAAA,CAAA,CAAA,MAAA,CAAA,qBAAA,CAAA,IAAA,EAAA,CAAA,MAAA,CAAA,SAAA,CAAA,cAAA,CAAA,EAAA,CAAA,MAAA,CAAA,SAAA,CAAA,oBAAA,CAAA,IAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,UAAA,CAAA,IAAA,CAAA,YAAA,CAAA,IAAA,CAAA,QAAA,CAAA,IAAA,CAAA,KAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,GAAA,CAAA,IAAA,IAAA,CAAA,IAAA,CAAA,GAAA,CAAA,CAAA,EAAA,CAAA,CAAA,EAAA,CAAA,IAAA,CAAA,CAAA,CAAA,CAAA,CAAA,EAAA,EAAA,CAAA,CAAA,CA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QAAA,CAAA,CAAAnE,GAAAA,CAAC,QAAK,SAAA,CAAU,aAAA,CAAe,QAAA,CAAAmH,CAAAA,CAAQ,MAAM,CAAA,CAC7CnH,GAAAA,CAAC,MAAA,CAAA,CAAK,SAAA,CAAU,qCACb,QAAA,CAAAmH,CAAAA,CAAQ,WAAA,CACX,CAAA,CAAA,CAAA,CAtBK/G,CAuBP,CAAA,CA3BmB,IA6BvB,CAAC,CACH,IAAG,CACL,CAAA,CACA,QAAA,CAAS,IACX,EACA,IAAA,CAAA,CAAA,CACN,CAEJ,CACF,EAEAG,GAAW,WAAA,CAAc,YAAA","file":"note-editor.mjs","sourcesContent":["\"use client\";\n\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n type ChangeEvent,\n type ComponentProps,\n type KeyboardEvent,\n} from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { EditorContent, useEditor } from \"@tiptap/react\";\nimport { Selection, type EditorState } from \"@tiptap/pm/state\";\nimport type { EditorView } from \"@tiptap/pm/view\";\nimport type {\n EditorDocument,\n SlashCommandId,\n SlashMenuState,\n} from \"@medway-ui/notes-core\";\nimport {\n EMPTY_DOCUMENT,\n EMPTY_SLASH_STATE,\n getSlashCommand,\n normalizeDocument,\n sanitizeLinkHref,\n toEditorContent,\n} from \"@medway-ui/notes-core\";\nimport {\n Editor,\n assertSchemaContract,\n buildExtensions,\n createSlashCommand,\n generateHTML,\n generateJSON,\n type BuildExtensionsOptions,\n type SlashCommandController,\n} from \"@medway-ui/notes-core/schema\";\n\nimport { cn } from \"@/lib/utils\";\nimport {\n ArrowUndoUpLeft,\n Bold,\n Code,\n DoubleQuotesL,\n HeadingH2,\n HeadingH3,\n Image as ImageIcon,\n Italic,\n Link as LinkIcon,\n ListOrdered,\n ListUnordered,\n Redo,\n Strikethrough,\n Underline,\n WindowCodeBlock,\n} from \"@medway-ui/icons\";\n\n/**\n * What `getSaveData` returns: the title (its own state, never a node in the\n * Tiptap document) plus both content formats, computed only when asked.\n */\nexport type NoteEditorValue = {\n title: string;\n json: EditorDocument;\n html: string;\n};\n\n/** @deprecated Alias of `NoteEditorValue`, kept for existing imports. */\nexport type NoteEditorSaveData = NoteEditorValue;\n\n/**\n * Imperative handle exposed via ref. Exposes the underlying Tiptap editor so a\n * host can wire its own toolbar or shortcuts — the editor runs in-process here,\n * unlike the WebView-backed mobile counterpart.\n */\nexport type NoteEditorHandle = {\n editor: Editor | null;\n focus: (position?: \"start\" | \"end\") => void;\n blur: () => void;\n getDocument: () => EditorDocument;\n /**\n * Everything needed to persist the note: title, the JSON (source of truth)\n * and its HTML rendering, for backends with an HTML-shaped field.\n *\n * Call only from the host's save action, never per keystroke: `generateHTML`\n * walks the whole document through a throwaway schema.\n */\n getSaveData: () => NoteEditorValue;\n /**\n * Accepts JSON or an HTML string, same as the `document` prop. HTML is parsed\n * through the editor's schema and whitelisted the same way.\n */\n setDocument: (\n doc: EditorDocument | string,\n options?: { focus?: boolean }\n ) => void;\n};\n\ntype NoteEditorProps = Omit<ComponentProps<\"div\">, \"onChange\"> & {\n /**\n * Initial document: the note's JSON, or an HTML string (parsed through the\n * editor's own schema via `generateJSON` + `normalizeDocument`, so a host\n * reading an HTML-backed field need not convert it).\n *\n * Changing it replaces the content but keeps the instance — pass a new React\n * `key` for a fresh undo stack, as when switching notes.\n */\n document?: EditorDocument | string;\n /**\n * Initial title, shown above the content. Kept entirely separate from the\n * Tiptap document — never a node in `json`/`html`. Read once, like\n * `document`.\n */\n initialTitle?: string;\n /** Purely visual; `getSaveData().title` stays `\"\"` while it shows. */\n titlePlaceholder?: string;\n /**\n * Renders the title area. Set `false` for a document that already carries its\n * own heading as the first block. Only the UI is hidden — `initialTitle` and\n * `getSaveData().title` behave the same — but `autofocus` no longer routes to\n * the title, and Backspace at the start of the content falls through to the\n * editor's normal behavior. Defaults to `true`.\n */\n showTitle?: boolean;\n onChange?: (doc: EditorDocument) => void;\n editable?: boolean;\n /**\n * Focuses on mount, routed to the title if there is no `initialTitle` yet\n * (a brand-new note) and to the content otherwise.\n */\n autofocus?: boolean | \"start\" | \"end\";\n /**\n * Extra Tiptap extensions merged on top of the note schema, for UX-only\n * behaviour (floating menu, mention…). The `/` menu is already wired in.\n */\n extraExtensions?: BuildExtensionsOptions[\"extra\"];\n /**\n * Shows the formatting bar above the editor. Off by default and independent\n * of the `/` menu.\n */\n toolbar?: boolean;\n /**\n * Called with a file the student picked, dropped or pasted; resolves to the\n * URL used as the image's `src` (R2, S3, a `data:` URL — this component has\n * no opinion). Every way of *adding* an image (slash command, toolbar button,\n * drag & drop, paste) requires this; without it a document can still contain\n * images loaded from `document`.\n */\n onImageUpload?: (file: File) => Promise<string>;\n /**\n * Fires only for images `onImageUpload` produced *this session*, and only\n * after `imageDeleteGraceMs` elapses with the image still gone (an undo\n * inside that window cancels it).\n *\n * Images already present when the document loaded never trigger this: this\n * component cannot know whether another note references the same file, so\n * cleaning those up is the backend's job.\n */\n onImageRemoved?: (src: string) => void;\n /** Grace period before `onImageRemoved` fires, in ms. Long enough for undo. */\n imageDeleteGraceMs?: number;\n};\n\n/** Files a user actually dropped or pasted an image with, nothing else. */\nconst toImageFiles = (list: FileList | null | undefined): File[] =>\n Array.from(list ?? []).filter((file) => file.type.startsWith(\"image/\"));\n\n/**\n * The title holds one logical line, so a multi-line paste degrades to spaces\n * instead of silently becoming a second, invisible line.\n */\nconst sanitizeTitle = (value: string): string => value.replace(/\\r?\\n/g, \" \");\n\n/**\n * The \"nothing left to backspace into\" spot, where Backspace hands focus back\n * to the title instead.\n */\nconst isSelectionAtDocStart = (state: EditorState): boolean => {\n const { selection } = state;\n return selection.empty && selection.from === Selection.atStart(state.doc).from;\n};\n\nconst extractImageSrcs = (json: unknown): Set<string> => {\n const srcs = new Set<string>();\n\n const walk = (node: unknown) => {\n if (!node || typeof node !== \"object\") return;\n const record = node as { type?: unknown; attrs?: unknown; content?: unknown };\n\n if (record.type === \"image\") {\n const src = (record.attrs as { src?: unknown } | undefined)?.src;\n if (typeof src === \"string\") srcs.add(src);\n }\n\n if (Array.isArray(record.content)) record.content.forEach(walk);\n };\n\n walk(json);\n return srcs;\n};\n\n/**\n * Resolves the `document` prop / `setDocument` argument into a document safe to\n * hand the editor: JSON as-is, HTML parsed through the note schema first, both\n * through `normalizeDocument`.\n *\n * Extensions are rebuilt fresh rather than taken from the live `editor`, since\n * `generateJSON` only needs the schema they describe — which keeps this\n * callable before the editor exists, for the initial `document` prop.\n */\nconst toEditorDocument = (\n input: EditorDocument | string | undefined\n): EditorDocument => {\n const json =\n typeof input === \"string\" ? generateJSON(input, buildExtensions()) : input;\n // `normalizeDocument` can return a zero-block document, which ProseMirror's\n // `block+` rejects; `toEditorContent` expands it to an empty paragraph.\n return toEditorContent(normalizeDocument(json ?? EMPTY_DOCUMENT));\n};\n\nconst DEFAULT_IMAGE_DELETE_GRACE_MS = 4000;\n\n/** Every icon exported from `@medway-ui/icons` shares this component shape. */\ntype IconComponent = typeof Bold;\n\ntype ToolbarItem = {\n id: string;\n title: string;\n icon: IconComponent;\n run: (editor: Editor) => void;\n isActive?: (editor: Editor) => boolean;\n isDisabled?: (editor: Editor) => boolean;\n};\n\n// Local cast: the undo/redo augmentation doesn't reach this package's DTS build.\ntype HistoryChain = { undo: () => HistoryChain; redo: () => HistoryChain; run: () => boolean };\ntype HistoryCheck = { undo: () => boolean; redo: () => boolean };\nconst runUndo = (editor: Editor): void => {\n (editor.chain().focus() as unknown as HistoryChain).undo().run();\n};\nconst runRedo = (editor: Editor): void => {\n (editor.chain().focus() as unknown as HistoryChain).redo().run();\n};\nconst canUndo = (editor: Editor): boolean =>\n (editor.can() as unknown as HistoryCheck).undo();\nconst canRedo = (editor: Editor): boolean =>\n (editor.can() as unknown as HistoryCheck).redo();\n\n// Local cast, same reason as `HistoryChain`: the `declare module` that adds\n// `setLink`/`unsetLink` to `ChainedCommands` lives in `@tiptap/extension-link`,\n// imported only from `@medway-ui/notes-core` — external to this package's\n// `tsconfig.build.json` (`include: [\"src\"]`). It never reaches the DTS build,\n// so calling the shortcuts untyped breaks `yarn build:lib` with TS2339 and no\n// `dist/index.d.ts` is emitted. Don't drop the cast without re-running it.\ntype LinkChain = {\n setLink: (attrs: { href: string }) => LinkChain;\n unsetLink: () => LinkChain;\n run: () => boolean;\n};\n\n/**\n * Uses the Link extension's `setLink`/`unsetLink` rather than the generic\n * `setMark`/`unsetMark`: only `setLink` runs the extension's protocol check\n * (`isAllowedUri`) and sets `preventAutolink` on the transaction, so the\n * autolink plugin (`autolink: true`) can't reprocess the href just written.\n * `href` additionally goes through the same `sanitizeLinkHref` whitelist\n * `normalizeDocument` applies on load, so a prompt cannot persist a scheme the\n * app rejects elsewhere. Invalid URLs are rejected outright, never silently\n * degraded.\n */\nconst setLink = (editor: Editor): void => {\n const previousHref = (editor.getAttributes(\"link\") as { href?: string }).href;\n const url = window.prompt(\"URL do link\", previousHref || \"https://\");\n if (url === null) return;\n\n const chain = editor\n .chain()\n .focus()\n .extendMarkRange(\"link\") as unknown as LinkChain;\n\n if (url.trim() === \"\") {\n chain.unsetLink().run();\n return;\n }\n\n const href = sanitizeLinkHref(url);\n if (!href) {\n // eslint-disable-next-line no-console\n console.error(\"@medway-ui/core NoteEditor: rejected invalid link URL\", url);\n return;\n }\n\n chain.setLink({ href }).run();\n};\n\n/**\n * Generic `@tiptap/core` commands (`toggleMark`, `toggleNode`, …) rather than\n * the per-extension shortcuts, whose augmentations break the `tsup` DTS build.\n */\nconst TOOLBAR_GROUPS: ToolbarItem[][] = [\n [\n {\n id: \"bold\",\n title: \"Negrito (Ctrl/Cmd+B)\",\n icon: Bold,\n isActive: (editor) => editor.isActive(\"bold\"),\n run: (editor) => editor.chain().focus().toggleMark(\"bold\").run(),\n },\n {\n id: \"italic\",\n title: \"Itálico (Ctrl/Cmd+I)\",\n icon: Italic,\n isActive: (editor) => editor.isActive(\"italic\"),\n run: (editor) => editor.chain().focus().toggleMark(\"italic\").run(),\n },\n {\n id: \"underline\",\n title: \"Sublinhado (Ctrl/Cmd+U)\",\n icon: Underline,\n isActive: (editor) => editor.isActive(\"underline\"),\n run: (editor) => editor.chain().focus().toggleMark(\"underline\").run(),\n },\n {\n id: \"strike\",\n title: \"Tachado (Ctrl/Cmd+Shift+S)\",\n icon: Strikethrough,\n isActive: (editor) => editor.isActive(\"strike\"),\n run: (editor) => editor.chain().focus().toggleMark(\"strike\").run(),\n },\n {\n id: \"code\",\n title: \"Código\",\n icon: Code,\n isActive: (editor) => editor.isActive(\"code\"),\n run: (editor) => editor.chain().focus().toggleMark(\"code\").run(),\n },\n ],\n [\n {\n id: \"heading2\",\n title: \"Título 2\",\n icon: HeadingH2,\n isActive: (editor) => editor.isActive(\"heading\", { level: 2 }),\n run: (editor) =>\n editor.chain().focus().toggleNode(\"heading\", \"paragraph\", { level: 2 }).run(),\n },\n {\n id: \"heading3\",\n title: \"Título 3\",\n icon: HeadingH3,\n isActive: (editor) => editor.isActive(\"heading\", { level: 3 }),\n run: (editor) =>\n editor.chain().focus().toggleNode(\"heading\", \"paragraph\", { level: 3 }).run(),\n },\n ],\n [\n {\n id: \"bulletList\",\n title: \"Lista com marcadores\",\n icon: ListUnordered,\n isActive: (editor) => editor.isActive(\"bulletList\"),\n run: (editor) =>\n editor.chain().focus().toggleList(\"bulletList\", \"listItem\").run(),\n },\n {\n id: \"orderedList\",\n title: \"Lista numerada\",\n icon: ListOrdered,\n isActive: (editor) => editor.isActive(\"orderedList\"),\n run: (editor) =>\n editor.chain().focus().toggleList(\"orderedList\", \"listItem\").run(),\n },\n {\n id: \"blockquote\",\n title: \"Citação\",\n icon: DoubleQuotesL,\n isActive: (editor) => editor.isActive(\"blockquote\"),\n run: (editor) => editor.chain().focus().toggleWrap(\"blockquote\").run(),\n },\n {\n id: \"codeBlock\",\n title: \"Bloco de código\",\n icon: WindowCodeBlock,\n isActive: (editor) => editor.isActive(\"codeBlock\"),\n run: (editor) =>\n editor.chain().focus().toggleNode(\"codeBlock\", \"paragraph\").run(),\n },\n ],\n [\n {\n id: \"link\",\n title: \"Inserir link\",\n icon: LinkIcon,\n isActive: (editor) => editor.isActive(\"link\"),\n run: (editor) => setLink(editor),\n },\n ],\n [\n {\n id: \"undo\",\n title: \"Desfazer\",\n icon: ArrowUndoUpLeft,\n isDisabled: (editor) => !canUndo(editor),\n run: (editor) => runUndo(editor),\n },\n {\n id: \"redo\",\n title: \"Refazer\",\n icon: Redo,\n isDisabled: (editor) => !canRedo(editor),\n run: (editor) => runRedo(editor),\n },\n ],\n];\n\nfunction ToolbarSep() {\n return <div className=\"mx-1 h-5 w-px bg-gray-stroke-muted\" />;\n}\n\n// \"Imagem\" depends on a host upload; the shared catalog can't know if there is one.\nconst visibleSlashCommandIds = (\n commandIds: SlashCommandId[],\n canUploadImage: boolean\n): SlashCommandId[] =>\n canUploadImage ? commandIds : commandIds.filter((id) => id !== \"image\");\n\n/**\n * Utilities rather than a stylesheet: `tsup` ships this with no CSS loader.\n * `prose`/`prose-sm` are unavailable here — `@tailwindcss/typography` is not\n * installed and cannot be assumed in a host app.\n */\nconst wrapperClasses = [\n \"max-w-none focus:outline-none\",\n \"[&_.ProseMirror]:min-h-[8rem] [&_.ProseMirror]:outline-none\",\n \"[&_.ProseMirror]:text-content-paragraph [&_.ProseMirror]:text-md [&_.ProseMirror]:leading-md\",\n \"[&_.ProseMirror>*+*]:mt-3\",\n \"[&_.ProseMirror_p]:my-0\",\n\n \"[&_.ProseMirror_h1]:mt-4 [&_.ProseMirror_h1]:text-title-lg [&_.ProseMirror_h1]:font-bold [&_.ProseMirror_h1]:leading-title-lg [&_.ProseMirror_h1]:text-content-title\",\n \"[&_.ProseMirror_h2]:mt-3 [&_.ProseMirror_h2]:text-title-md [&_.ProseMirror_h2]:font-bold [&_.ProseMirror_h2]:leading-title-md [&_.ProseMirror_h2]:text-content-title\",\n \"[&_.ProseMirror_h3]:mt-3 [&_.ProseMirror_h3]:text-title-sm [&_.ProseMirror_h3]:font-semibold [&_.ProseMirror_h3]:leading-title-sm [&_.ProseMirror_h3]:text-content-title\",\n \"[&_.ProseMirror>h1:first-child]:mt-0 [&_.ProseMirror>h2:first-child]:mt-0 [&_.ProseMirror>h3:first-child]:mt-0\",\n\n // Lists — Tailwind's own preflight zeroes out `list-style`/margin/padding\n // on every `ul`/`ol`, which is what made \"Lista\" look like plain text.\n \"[&_.ProseMirror_ul]:list-disc [&_.ProseMirror_ol]:list-decimal [&_.ProseMirror_ul]:pl-5 [&_.ProseMirror_ol]:pl-5\",\n \"[&_.ProseMirror_li]:my-1 [&_.ProseMirror_li_p]:my-0\",\n \"[&_.ProseMirror_ul[data-type=taskList]]:list-none [&_.ProseMirror_ul[data-type=taskList]]:pl-0\",\n \"[&_.ProseMirror_ul[data-type=taskList]_li]:flex [&_.ProseMirror_ul[data-type=taskList]_li]:items-start [&_.ProseMirror_ul[data-type=taskList]_li]:gap-2\",\n \"[&_.ProseMirror_ul[data-type=taskList]_li>label]:mt-0.5\",\n \"[&_.ProseMirror_ul[data-type=taskList]_li[data-checked=true]>div>p]:text-gray-foreground-muted [&_.ProseMirror_ul[data-type=taskList]_li[data-checked=true]>div>p]:line-through\",\n\n \"[&_.ProseMirror_blockquote]:border-l-2 [&_.ProseMirror_blockquote]:border-gray-stroke-muted [&_.ProseMirror_blockquote]:pl-3 [&_.ProseMirror_blockquote]:text-gray-foreground-muted\",\n\n \"[&_.ProseMirror_code]:rounded [&_.ProseMirror_code]:bg-gray-background-soft [&_.ProseMirror_code]:px-1 [&_.ProseMirror_code]:py-0.5 [&_.ProseMirror_code]:font-mono [&_.ProseMirror_code]:text-xs\",\n \"[&_.ProseMirror_pre]:rounded-md [&_.ProseMirror_pre]:bg-gray-background-soft [&_.ProseMirror_pre]:p-3 [&_.ProseMirror_pre_code]:bg-transparent [&_.ProseMirror_pre_code]:p-0\",\n\n \"[&_.ProseMirror_hr]:my-4 [&_.ProseMirror_hr]:border-gray-stroke-muted\",\n\n \"[&_.ProseMirror_a]:text-content-link [&_.ProseMirror_a]:underline\",\n\n // Images — `.ProseMirror-selectednode` is ProseMirror's own atom-selection\n // class, and the only way to show an image is selected (e.g. before\n // Backspace deletes it), since an `<img>` cannot show a text caret.\n \"[&_.ProseMirror_img]:max-w-full [&_.ProseMirror_img]:rounded-md\",\n \"[&_.ProseMirror_img.ProseMirror-selectednode]:outline [&_.ProseMirror_img.ProseMirror-selectednode]:outline-2 [&_.ProseMirror_img.ProseMirror-selectednode]:outline-offset-2 [&_.ProseMirror_img.ProseMirror-selectednode]:outline-gray-stroke\",\n\n // Placeholder (Tiptap's extension ships no CSS) and the `/query` highlight.\n //\n // `before:opacity-50` is load-bearing: in dark mode\n // `--color-gray-foreground-muted` resolves to the same `gray-150` as\n // `--color-content-paragraph` (see `tokens.css`), so the placeholder would be\n // indistinguishable from typed text and the caret hint would read as\n // permanent content. Drop it if those tokens are fixed upstream.\n \"[&_.ProseMirror_p.is-empty]:before:content-[attr(data-placeholder)] [&_.ProseMirror_p.is-empty]:before:pointer-events-none [&_.ProseMirror_p.is-empty]:before:float-left [&_.ProseMirror_p.is-empty]:before:h-0 [&_.ProseMirror_p.is-empty]:before:text-gray-foreground-muted [&_.ProseMirror_p.is-empty]:before:opacity-50\",\n \"[&_.ProseMirror_.medway-slash]:rounded [&_.ProseMirror_.medway-slash]:bg-gray-background-soft\",\n].join(\" \");\n\n/**\n * The title area's typography. No border, background or outline, and sized like\n * the content's own `h1`, so it reads as the top of the same sheet rather than\n * an `<input>` above an editor. `placeholder:opacity-50` is the same dark-mode\n * token workaround as `wrapperClasses` above.\n */\nconst titleClasses = [\n \"mb-1 block w-full resize-none overflow-hidden border-0 bg-transparent p-0\",\n \"text-title-lg font-bold leading-title-lg text-content-title\",\n \"focus:outline-none focus:ring-0\",\n \"placeholder:text-gray-foreground-muted placeholder:opacity-50\",\n].join(\" \");\n\n/**\n * Web viewport for the Medway note editor. Runs Tiptap directly against the\n * DOM using the same schema the mobile bundle ships, so a document created on\n * one platform opens without conversion on the other.\n *\n * A title sits above the content by default (`showTitle`): plain local state,\n * never a node in the Tiptap document, styled to look like the top of the same\n * sheet as the editor below it.\n *\n * `/` menu *detection* comes from `createSlashCommand`, shared with the mobile\n * bundle; each host draws its own menu UI. This is the web one.\n */\nconst NoteEditor = forwardRef<NoteEditorHandle, NoteEditorProps>(\n (\n {\n document: initialDocument,\n initialTitle,\n titlePlaceholder = \"Title\",\n showTitle = true,\n onChange,\n editable = true,\n autofocus = false,\n extraExtensions,\n toolbar = false,\n onImageUpload,\n onImageRemoved,\n imageDeleteGraceMs = DEFAULT_IMAGE_DELETE_GRACE_MS,\n className,\n ...divProps\n },\n ref\n ) => {\n const initial = useMemo(\n () => toEditorDocument(initialDocument),\n // Only the first document seeds the editor. Later updates go through\n // `setDocument` on the ref so the host controls the undo behavior.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n // Own state, never a node in the Tiptap document. Typing can't produce a\n // newline (Enter is intercepted below); `sanitizeTitle` catches pastes.\n const [title, setTitle] = useState(() => sanitizeTitle(initialTitle ?? \"\"));\n const titleRef = useRef<HTMLTextAreaElement>(null);\n\n // Computed once, from the *initial* title: a brand-new note focuses the\n // title first, one with an existing title focuses the content (handled\n // where `autofocus` reaches `useEditor`). Never the title if `showTitle`\n // is false — there is no title UI mounted to focus.\n const autofocusTitleRef = useRef(\n showTitle && Boolean(autofocus) && title.length === 0\n );\n\n const resizeTitle = useCallback(() => {\n const el = titleRef.current;\n if (!el) return;\n el.style.height = \"auto\";\n el.style.height = `${el.scrollHeight}px`;\n }, []);\n\n // Runs before paint so the title never flashes at its single-line\n // default height and then jumps once content is measured.\n useLayoutEffect(() => {\n resizeTitle();\n }, [title, resizeTitle]);\n\n useEffect(() => {\n if (autofocusTitleRef.current) titleRef.current?.focus();\n // Mount-only: this is the one-time \"new note\" autofocus decision.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const handleTitleChange = useCallback(\n (event: ChangeEvent<HTMLTextAreaElement>) => {\n setTitle(sanitizeTitle(event.target.value));\n },\n []\n );\n\n /** The Backspace-at-doc-start half lives in `handleKeyDown` below. */\n const focusTitleAtEnd = useCallback(() => {\n const el = titleRef.current;\n if (!el) return;\n el.focus();\n const end = el.value.length;\n el.setSelectionRange(end, end);\n }, []);\n\n // Editor callbacks are captured once at creation, so anything they read later\n // goes through a ref.\n const showTitleRef = useRef(showTitle);\n useEffect(() => {\n showTitleRef.current = showTitle;\n }, [showTitle]);\n\n const [slashState, setSlashState] = useState<SlashMenuState>(\n EMPTY_SLASH_STATE\n );\n const [selectedIndex, setSelectedIndex] = useState(0);\n\n // Created once, lazily. `createSlashCommand` is pure — it only closes over\n // local state — so calling it during render is safe.\n const slashRef = useRef<SlashCommandController | null>(null);\n if (!slashRef.current) {\n slashRef.current = createSlashCommand(setSlashState);\n }\n // Narrowed once here: TS drops the narrowing from the block above inside\n // any callback, since `ref.current` is mutable and the callback may run\n // later. Reading it through this const keeps `extensions` free of a `!`.\n const slashCommand = slashRef.current;\n\n const slashStateRef = useRef(slashState);\n const selectedIndexRef = useRef(selectedIndex);\n useEffect(() => {\n slashStateRef.current = slashState;\n }, [slashState]);\n useEffect(() => {\n selectedIndexRef.current = selectedIndex;\n }, [selectedIndex]);\n\n // A new query means a new (possibly shorter) list — keep the highlight\n // in range instead of pointing at whatever used to be at this index.\n useEffect(() => {\n setSelectedIndex(0);\n }, [slashState.query, slashState.active]);\n\n const onImageUploadRef = useRef(onImageUpload);\n const onImageRemovedRef = useRef(onImageRemoved);\n const imageDeleteGraceMsRef = useRef(imageDeleteGraceMs);\n useEffect(() => {\n onImageUploadRef.current = onImageUpload;\n }, [onImageUpload]);\n useEffect(() => {\n onImageRemovedRef.current = onImageRemoved;\n }, [onImageRemoved]);\n useEffect(() => {\n imageDeleteGraceMsRef.current = imageDeleteGraceMs;\n }, [imageDeleteGraceMs]);\n\n const uploadedThisSessionRef = useRef<Set<string>>(new Set());\n const previousImageUrlsRef = useRef<Set<string>>(new Set());\n const pendingDeletesRef = useRef<Map<string, ReturnType<typeof setTimeout>>>(\n new Map()\n );\n\n // Guards `insertImageFile`'s upload promise against resolving after\n // unmount. Used instead of `editor.isDestroyed` because `@tiptap/react`\n // defers the destroy by a tick (`scheduleDestroy`), while this flips\n // synchronously in the cleanup below.\n const isMountedRef = useRef(true);\n\n const scheduleImageDelete = useCallback((src: string) => {\n const existing = pendingDeletesRef.current.get(src);\n if (existing) clearTimeout(existing);\n\n const timeoutId = setTimeout(() => {\n pendingDeletesRef.current.delete(src);\n uploadedThisSessionRef.current.delete(src);\n onImageRemovedRef.current?.(src);\n }, imageDeleteGraceMsRef.current);\n\n pendingDeletesRef.current.set(src, timeoutId);\n }, []);\n\n const cancelScheduledImageDelete = useCallback((src: string) => {\n const existing = pendingDeletesRef.current.get(src);\n if (existing) {\n clearTimeout(existing);\n pendingDeletesRef.current.delete(src);\n }\n }, []);\n\n // Cancel removals still inside the grace window on unmount, rather than\n // firing `onImageRemoved` after the editor is already gone.\n useEffect(() => {\n const pending = pendingDeletesRef.current;\n return () => {\n isMountedRef.current = false;\n pending.forEach((timeoutId) => clearTimeout(timeoutId));\n pending.clear();\n };\n }, []);\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const openImageFilePicker = useCallback(() => {\n fileInputRef.current?.click();\n }, []);\n\n const [uploadCount, setUploadCount] = useState(0);\n\n // Needs `editor.chain()`, which doesn't exist yet where the handlers are built.\n const insertImageFileRef = useRef<(file: File, pos?: number) => void>(\n () => {}\n );\n\n // Must be memoized: `useEditor` compares `extensions` by array-index\n // instance identity every render, so a fresh array (~25 instances) never\n // compares equal and forces `setOptions` → `view.updateState()` on every\n // keystroke, for nothing — `setOptions` never rebuilds the extension\n // manager, so the new array is discarded.\n //\n // The empty dep array is intentional: `extraExtensions` and\n // `slashCommand.extension` are only read at editor creation.\n const extensions = useMemo(\n () =>\n buildExtensions({\n extra: [...(extraExtensions ?? []), slashCommand.extension],\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n // Same reasoning as `extensions`: a new object every render fails the same\n // reference-equality check and forces the same wasted `setOptions`. The\n // handlers below read everything else through refs or stable callbacks, so\n // they stay current without appearing in this dep array.\n const editorProps = useMemo(\n () => ({\n attributes: { \"aria-label\": \"Conteúdo da anotação\" },\n // `globalThis.KeyboardEvent`, not React's: ProseMirror hands the DOM\n // event straight through, and this module imports React's\n // `KeyboardEvent` for the title handler, which shadows the global.\n handleKeyDown: (view: EditorView, event: globalThis.KeyboardEvent) => {\n const slash = slashStateRef.current;\n\n // Backspace at doc start hands focus back to the title — the inverse\n // of the title's own Enter handler. Skipped while the slash menu is\n // open (so Backspace edits the `/query`) and when `showTitle` is\n // false (nothing to focus, so it falls through).\n if (\n showTitleRef.current &&\n event.key === \"Backspace\" &&\n !slash.active &&\n isSelectionAtDocStart(view.state)\n ) {\n event.preventDefault();\n focusTitleAtEnd();\n return true;\n }\n\n const commandIds = visibleSlashCommandIds(\n slash.commandIds,\n Boolean(onImageUploadRef.current)\n );\n if (!slash.active || commandIds.length === 0) return false;\n\n switch (event.key) {\n case \"ArrowDown\":\n event.preventDefault();\n setSelectedIndex((index) => (index + 1) % commandIds.length);\n return true;\n case \"ArrowUp\":\n event.preventDefault();\n setSelectedIndex(\n (index) => (index - 1 + commandIds.length) % commandIds.length\n );\n return true;\n case \"Enter\":\n case \"Tab\": {\n event.preventDefault();\n const id =\n commandIds[selectedIndexRef.current] ?? commandIds[0];\n slashRef.current?.run(id);\n if (id === \"image\") openImageFilePicker();\n return true;\n }\n default:\n return false;\n }\n },\n handleDrop: (view: EditorView, event: DragEvent) => {\n const files = toImageFiles(event.dataTransfer?.files);\n if (!files.length || !onImageUploadRef.current) return false;\n\n event.preventDefault();\n const pos = view.posAtCoords({\n left: event.clientX,\n top: event.clientY,\n })?.pos;\n files.forEach((file) => insertImageFileRef.current(file, pos));\n return true;\n },\n handlePaste: (_view: EditorView, event: ClipboardEvent) => {\n const files = toImageFiles(event.clipboardData?.files);\n if (!files.length || !onImageUploadRef.current) return false;\n\n event.preventDefault();\n files.forEach((file) => insertImageFileRef.current(file));\n return true;\n },\n }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n []\n );\n\n const editor = useEditor({\n extensions,\n content: initial,\n editable,\n // Title wins the initial focus for a brand-new note.\n autofocus: autofocusTitleRef.current ? false : autofocus,\n editorProps,\n onUpdate: ({ editor: instance }) => {\n const json = instance.getJSON() as EditorDocument;\n onChange?.(json);\n\n const currentSrcs = extractImageSrcs(json);\n previousImageUrlsRef.current.forEach((src) => {\n if (!currentSrcs.has(src) && uploadedThisSessionRef.current.has(src)) {\n scheduleImageDelete(src);\n }\n });\n currentSrcs.forEach((src) => cancelScheduledImageDelete(src));\n previousImageUrlsRef.current = currentSrcs;\n },\n });\n\n /**\n * Enter in the title moves into the content's first block; it never\n * inserts `\\n` or adds a second title line. Skipped while composing (IME)\n * so committing a candidate doesn't also jump focus away.\n */\n const handleTitleKeyDown = useCallback(\n (event: KeyboardEvent<HTMLTextAreaElement>) => {\n if (event.key !== \"Enter\" || event.nativeEvent.isComposing) return;\n event.preventDefault();\n editor?.commands.focus(\"start\");\n },\n [editor]\n );\n\n // Enforce the schema contract in dev, so drift breaks the same way it does\n // on mobile.\n useEffect(() => {\n if (!editor) return;\n const missing = assertSchemaContract(editor.schema);\n if (missing.length && process.env.NODE_ENV !== \"production\") {\n // eslint-disable-next-line no-console\n console.error(\n `@medway-ui/core NoteEditor: schema is missing ${missing.join(\", \")}`\n );\n }\n }, [editor]);\n\n useEffect(() => {\n if (editor && editor.isEditable !== editable) {\n editor.setEditable(editable);\n }\n }, [editor, editable]);\n\n // The actual \"upload, then insert\", reached through `insertImageFileRef`.\n const insertImageFile = useCallback(\n (file: File, pos?: number) => {\n const upload = onImageUploadRef.current;\n if (!upload || !editor) return;\n\n setUploadCount((count) => count + 1);\n upload(file)\n .then((src) => {\n // The upload can outlive this component, leaving `editor` pointing\n // at a destroyed instance. `src` is a real stored file by now, and\n // inserting into a dead editor silently does nothing — so report it\n // as removed immediately, or it stays orphaned in storage with\n // nothing left to ever fire `onImageRemoved` for it.\n if (!isMountedRef.current || editor.isDestroyed) {\n onImageRemovedRef.current?.(src);\n return;\n }\n\n uploadedThisSessionRef.current.add(src);\n const chain = editor.chain().focus();\n if (typeof pos === \"number\") {\n chain\n .insertContentAt(pos, {\n type: \"image\",\n attrs: { src, alt: file.name },\n })\n .run();\n } else {\n chain.setImage({ src, alt: file.name }).run();\n }\n })\n .catch((error: unknown) => {\n // eslint-disable-next-line no-console\n console.error(\n \"@medway-ui/core NoteEditor: onImageUpload failed\",\n error\n );\n })\n .finally(() => {\n if (!isMountedRef.current) return;\n setUploadCount((count) => count - 1);\n });\n },\n [editor]\n );\n useEffect(() => {\n insertImageFileRef.current = insertImageFile;\n }, [insertImageFile]);\n\n const handleImageFileInputChange = useCallback(\n (event: ChangeEvent<HTMLInputElement>) => {\n const files = toImageFiles(event.target.files);\n event.target.value = \"\";\n files.forEach((file) => insertImageFile(file));\n },\n [insertImageFile]\n );\n\n // The caret rect is viewport-relative (the menu is `position: fixed`) and\n // only typing recomputes it, so scroll and resize have to refresh it.\n useEffect(() => {\n if (!editor) return;\n\n let frame = 0;\n const handleViewportChange = () => {\n if (frame) return;\n frame = requestAnimationFrame(() => {\n frame = 0;\n slashRef.current?.refreshCaret();\n });\n };\n\n window.addEventListener(\"scroll\", handleViewportChange, true);\n window.addEventListener(\"resize\", handleViewportChange);\n return () => {\n window.removeEventListener(\"scroll\", handleViewportChange, true);\n window.removeEventListener(\"resize\", handleViewportChange);\n if (frame) cancelAnimationFrame(frame);\n };\n }, [editor]);\n\n // Button active state depends on the selection, which changes without any\n // document edit (clicks, arrow keys) — and only content changes re-render\n // via `onUpdate`. Skipped when the toolbar isn't rendered.\n const [, rerenderToolbar] = useReducer((count: number) => count + 1, 0);\n useEffect(() => {\n if (!editor || !toolbar) return;\n const update = () => rerenderToolbar();\n editor.on(\"transaction\", update);\n editor.on(\"selectionUpdate\", update);\n return () => {\n editor.off(\"transaction\", update);\n editor.off(\"selectionUpdate\", update);\n };\n }, [editor, toolbar]);\n\n useImperativeHandle(\n ref,\n () => ({\n editor: editor ?? null,\n focus: (position) => editor?.commands.focus(position ?? \"end\"),\n blur: () => editor?.commands.blur(),\n getDocument: () =>\n (editor?.getJSON() as EditorDocument | undefined) ?? EMPTY_DOCUMENT,\n getSaveData: () => {\n const json =\n (editor?.getJSON() as EditorDocument | undefined) ?? EMPTY_DOCUMENT;\n const html = editor ? generateHTML(json, buildExtensions()) : \"\";\n return { title, json, html };\n },\n setDocument: (doc, options) => {\n if (!editor) return;\n\n // Switching documents in the same instance must not carry over the\n // previous note's image bookkeeping: an image merely absent from the\n // new content would be scheduled for deletion, and the still-saved\n // previous note would lose a file it references.\n pendingDeletesRef.current.forEach((timeoutId) => clearTimeout(timeoutId));\n pendingDeletesRef.current.clear();\n uploadedThisSessionRef.current = new Set();\n previousImageUrlsRef.current = new Set();\n\n editor.commands.setContent(toEditorDocument(doc), {\n emitUpdate: false,\n });\n if (options?.focus) editor.commands.focus(\"end\");\n },\n }),\n [editor, title]\n );\n\n return (\n <div className={cn(wrapperClasses, className)} {...divProps}>\n {toolbar && editor && (\n <div\n role=\"toolbar\"\n aria-label=\"Formatação\"\n // Sticky so the bar stays at the top while content scrolls;\n // `bg-surface-elevated` keeps scrolled-past text from showing\n // through underneath it.\n className=\"sticky top-0 z-10 mb-2 flex flex-wrap items-center gap-0.5 border-b border-gray-stroke-muted bg-surface-elevated pb-2\"\n >\n {TOOLBAR_GROUPS.map((group, groupIndex) => (\n <div key={groupIndex} className=\"flex items-center gap-0.5\">\n {groupIndex > 0 ? <ToolbarSep /> : null}\n {group.map((item) => {\n const Icon = item.icon;\n const active = item.isActive?.(editor) ?? false;\n const disabled = item.isDisabled?.(editor) ?? false;\n return (\n <button\n key={item.id}\n type=\"button\"\n title={item.title}\n aria-label={item.title}\n aria-pressed={active}\n disabled={disabled}\n // `onMouseDown` + `preventDefault`, not `onClick`, so the\n // editor's selection survives the click.\n onMouseDown={(event) => {\n event.preventDefault();\n item.run(editor);\n }}\n className={cn(\n \"flex h-8 w-8 items-center justify-center rounded-md transition-colors\",\n \"disabled:cursor-not-allowed disabled:opacity-40\",\n active\n ? \"bg-primary-background-soft text-primary-foreground\"\n : \"text-content-paragraph hover:bg-state-hover\"\n )}\n >\n <Icon size={16} />\n </button>\n );\n })}\n </div>\n ))}\n {onImageUpload ? (\n <div className=\"flex items-center gap-0.5\">\n <ToolbarSep />\n <button\n type=\"button\"\n title=\"Inserir imagem\"\n aria-label=\"Inserir imagem\"\n disabled={uploadCount > 0}\n onMouseDown={(event) => {\n event.preventDefault();\n openImageFilePicker();\n }}\n className={cn(\n \"flex h-8 w-8 items-center justify-center rounded-md transition-colors\",\n \"disabled:cursor-not-allowed disabled:opacity-40\",\n \"text-content-paragraph hover:bg-state-hover\"\n )}\n >\n <ImageIcon size={16} />\n </button>\n {uploadCount > 0 && (\n <span className=\"ml-2 flex items-center gap-1.5 text-xs text-content-paragraph\">\n <span className=\"h-3 w-3 animate-spin rounded-full border-2 border-primary-stroke border-t-transparent\" />\n enviando imagem…\n </span>\n )}\n </div>\n ) : null}\n </div>\n ) }\n {showTitle ? (\n <textarea\n ref={titleRef}\n rows={1}\n value={title}\n onChange={handleTitleChange}\n onKeyDown={handleTitleKeyDown}\n placeholder={titlePlaceholder}\n aria-label=\"Título da anotação\"\n readOnly={!editable}\n className={titleClasses}\n />\n ) : null}\n\n {onImageUpload ? (\n <input\n ref={fileInputRef}\n type=\"file\"\n accept=\"image/*\"\n multiple\n hidden\n onChange={handleImageFileInputChange}\n />\n ) : null}\n <EditorContent editor={editor} />\n {slashState.active && slashState.caret\n ? createPortal(\n <div\n role=\"listbox\"\n aria-label=\"Comandos\"\n className=\"fixed z-50 max-h-72 w-64 overflow-auto rounded-md border bg-surface-elevated p-1 text-sm shadow-lg\"\n style={{\n left: slashState.caret.x,\n top: slashState.caret.y + slashState.caret.height + 6,\n }}\n >\n {(() => {\n const commandIds = visibleSlashCommandIds(\n slashState.commandIds,\n Boolean(onImageUpload)\n );\n\n if (commandIds.length === 0) {\n return (\n <div className=\"px-3 py-2 text-gray-foreground-muted\">\n Nenhum resultado\n </div>\n );\n }\n\n return commandIds.map((id, index) => {\n const command = getSlashCommand(id);\n if (!command) return null;\n\n return (\n <button\n key={id}\n type=\"button\"\n role=\"option\"\n aria-selected={index === selectedIndex}\n className={cn(\n \"flex w-full cursor-pointer flex-col items-start gap-0.5 rounded-sm px-3 py-1.5 text-left font-medium text-gray-foreground\",\n index === selectedIndex &&\n \"bg-secondary-background-soft-emphasis\"\n )}\n onMouseEnter={() => setSelectedIndex(index)}\n onMouseDown={(event) => {\n // `onMouseDown` (not `onClick`) + `preventDefault`\n // so the editor never loses focus/selection before\n // `run` deletes the typed `/query` range.\n event.preventDefault();\n slashRef.current?.run(id);\n if (id === \"image\") openImageFilePicker();\n }}\n >\n <span className=\"font-medium\">{command.label}</span>\n <span className=\"text-xs text-gray-foreground-muted\">\n {command.description}\n </span>\n </button>\n );\n });\n })()}\n </div>,\n document.body\n )\n : null}\n </div>\n );\n }\n);\n\nNoteEditor.displayName = \"NoteEditor\";\n\nexport { NoteEditor };\n","import { clsx, type ClassValue } from \"clsx\";\nimport { extendTailwindMerge } from \"tailwind-merge\";\n\nconst customTwMerge = extendTailwindMerge({\n extend: {\n classGroups: {\n \"font-size\": [\n \"text-xxs\",\n \"text-xs\",\n \"text-sm\",\n \"text-base\",\n \"text-md\",\n \"text-lg\",\n \"text-xl\",\n \"text-title-xs\",\n \"text-title-sm\",\n \"text-title-md\",\n \"text-title-lg\",\n \"text-title-xl\",\n \"text-title-xxl\",\n \"text-display-sm\",\n \"text-display-md\",\n \"text-display-lg\",\n ],\n \"leading\": [\n \"leading-xxs\",\n \"leading-xs\",\n \"leading-sm\",\n \"leading-md\",\n \"leading-lg\",\n \"leading-title-xs\",\n \"leading-title-sm\",\n \"leading-title-md\",\n \"leading-title-lg\",\n \"leading-title-xl\",\n \"leading-title-xxl\",\n \"leading-display-sm\",\n \"leading-display-md\",\n \"leading-display-lg\",\n ],\n \"font-weight\": [\n \"font-regular\",\n \"font-medium\",\n \"font-semibold\",\n \"font-bold\",\n \"font-extrabold\",\n ],\n \"rounded\": [\n \"rounded-none\",\n \"rounded-sm\",\n \"rounded-md\",\n \"rounded-lg\",\n \"rounded-pill\",\n \"rounded-circular\",\n \"rounded-full\",\n ],\n },\n },\n});\n\nexport function cn(...inputs: ClassValue[]) {\n return customTwMerge(clsx(inputs));\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medway-ui/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Biblioteca de componentes e assets para o sistema Medway",
|
|
6
6
|
"author": "Alekcarvalho",
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"sideEffects": false,
|
|
18
18
|
"scripts": {
|
|
19
|
+
"predev": "npm run build:notes-core",
|
|
19
20
|
"dev": "next dev",
|
|
21
|
+
"prebuild": "npm run build:notes-core",
|
|
20
22
|
"build": "next build",
|
|
21
23
|
"start": "npx serve@latest out",
|
|
22
24
|
"lint": "next lint",
|
|
@@ -24,8 +26,14 @@
|
|
|
24
26
|
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,md}\"",
|
|
25
27
|
"postbuild": "pagefind --site out --output-path out/_pagefind",
|
|
26
28
|
"prepare": "husky install || true",
|
|
29
|
+
"prebuild:lib": "npm run build:notes-core",
|
|
27
30
|
"build:lib": "tsup",
|
|
31
|
+
"prebuild:native": "npm run build:notes-core",
|
|
28
32
|
"build:native": "cd native && bob build",
|
|
33
|
+
"build:notes-core": "node_modules/.bin/tsc -p notes-core/tsconfig.build.json",
|
|
34
|
+
"notes-core:typecheck": "node_modules/.bin/tsc -p notes-core/tsconfig.json --noEmit",
|
|
35
|
+
"build:editor-bundle": "npm --prefix editor-bundle ci && npm --prefix editor-bundle run build",
|
|
36
|
+
"typecheck:editor-bundle": "npm --prefix editor-bundle ci && npm --prefix editor-bundle run typecheck",
|
|
29
37
|
"typecheck:native": "cd native && tsc --noEmit",
|
|
30
38
|
"release:native": "cd native && npm run release",
|
|
31
39
|
"generate:docs": "tsx scripts/generate-component-docs.ts",
|
|
@@ -39,15 +47,46 @@
|
|
|
39
47
|
},
|
|
40
48
|
"peerDependencies": {
|
|
41
49
|
"@medway-ui/icons": "^1.12.0",
|
|
50
|
+
"@medway-ui/notes-core": ">=0.1.0",
|
|
51
|
+
"@tiptap/react": "^3.31.3",
|
|
42
52
|
"react": ">=18.0.0",
|
|
43
53
|
"react-dom": ">=18.0.0",
|
|
44
54
|
"tailwindcss": "3"
|
|
45
55
|
},
|
|
56
|
+
"peerDependenciesMeta": {
|
|
57
|
+
"@medway-ui/notes-core": {
|
|
58
|
+
"optional": true
|
|
59
|
+
},
|
|
60
|
+
"@tiptap/react": {
|
|
61
|
+
"optional": true
|
|
62
|
+
}
|
|
63
|
+
},
|
|
46
64
|
"devDependencies": {
|
|
47
65
|
"@commitlint/cli": "^19.8.1",
|
|
48
66
|
"@commitlint/config-conventional": "^19.8.1",
|
|
49
67
|
"@eslint/eslintrc": "^3",
|
|
50
68
|
"@medway-ui/icons": "^1.12.0",
|
|
69
|
+
"@medway-ui/notes-core": "link:notes-core",
|
|
70
|
+
"@tiptap/core": "^3.31.3",
|
|
71
|
+
"@tiptap/extension-blockquote": "^3.31.3",
|
|
72
|
+
"@tiptap/extension-bold": "^3.31.3",
|
|
73
|
+
"@tiptap/extension-code": "^3.31.3",
|
|
74
|
+
"@tiptap/extension-code-block": "^3.31.3",
|
|
75
|
+
"@tiptap/extension-document": "^3.31.3",
|
|
76
|
+
"@tiptap/extension-hard-break": "^3.31.3",
|
|
77
|
+
"@tiptap/extension-heading": "^3.31.3",
|
|
78
|
+
"@tiptap/extension-horizontal-rule": "^3.31.3",
|
|
79
|
+
"@tiptap/extension-italic": "^3.31.3",
|
|
80
|
+
"@tiptap/extension-link": "^3.31.3",
|
|
81
|
+
"@tiptap/extension-list": "^3.31.3",
|
|
82
|
+
"@tiptap/extension-paragraph": "^3.31.3",
|
|
83
|
+
"@tiptap/extension-strike": "^3.31.3",
|
|
84
|
+
"@tiptap/extension-text": "^3.31.3",
|
|
85
|
+
"@tiptap/extension-underline": "^3.31.3",
|
|
86
|
+
"@tiptap/extensions": "^3.31.3",
|
|
87
|
+
"@tiptap/pm": "^3.31.3",
|
|
88
|
+
"@tiptap/react": "^3.31.3",
|
|
89
|
+
"@tiptap/suggestion": "^3.31.3",
|
|
51
90
|
"@types/node": "^20",
|
|
52
91
|
"@types/react": "^19",
|
|
53
92
|
"@types/react-dom": "^19",
|
|
@@ -82,9 +121,15 @@
|
|
|
82
121
|
},
|
|
83
122
|
"exports": {
|
|
84
123
|
".": {
|
|
124
|
+
"types": "./dist/index.d.ts",
|
|
85
125
|
"import": "./dist/index.mjs",
|
|
86
126
|
"require": "./dist/index.js"
|
|
87
127
|
},
|
|
128
|
+
"./note-editor": {
|
|
129
|
+
"types": "./dist/note-editor.d.ts",
|
|
130
|
+
"import": "./dist/note-editor.mjs",
|
|
131
|
+
"require": "./dist/note-editor.js"
|
|
132
|
+
},
|
|
88
133
|
"./tokens.css": {
|
|
89
134
|
"default": "./dist/assets/css/tokens.css"
|
|
90
135
|
},
|
|
@@ -96,8 +141,20 @@
|
|
|
96
141
|
"access": "public",
|
|
97
142
|
"exports": {
|
|
98
143
|
".": {
|
|
144
|
+
"types": "./dist/index.d.ts",
|
|
99
145
|
"import": "./dist/index.mjs",
|
|
100
146
|
"require": "./dist/index.js"
|
|
147
|
+
},
|
|
148
|
+
"./note-editor": {
|
|
149
|
+
"types": "./dist/note-editor.d.ts",
|
|
150
|
+
"import": "./dist/note-editor.mjs",
|
|
151
|
+
"require": "./dist/note-editor.js"
|
|
152
|
+
},
|
|
153
|
+
"./tokens.css": {
|
|
154
|
+
"default": "./dist/assets/css/tokens.css"
|
|
155
|
+
},
|
|
156
|
+
"./tokens": {
|
|
157
|
+
"default": "./dist/assets/js/tokens.ts"
|
|
101
158
|
}
|
|
102
159
|
}
|
|
103
160
|
},
|