@azlib/editor 0.2.0 → 0.3.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.cjs +861 -226
- package/dist/index.d.cts +43 -4
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +43 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +860 -229
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/core/errors.ts","../src/core/commandDiagnostics.ts","../src/core/formattingCommands.ts","../src/core/commands.ts","../src/core/history.ts","../src/transforms/html.ts","../src/transforms/diagnostics.ts","../src/transforms/importFallback.ts","../src/transforms/markdown.ts","../src/transforms/representationSwitch.ts","../src/core/createEditor.ts","../src/core/schema.ts","../src/core/toolbarModel.ts","../src/rich-text/mountEditor.ts","../src/adapters/dom/createDomAdapter.ts","../src/adapters/react/useEditorAdapter.tsx"],"sourcesContent":["import type { EditorErrorEnvelope, RepresentationDiagnostic } from \"./types\";\n\nexport const createDiagnostic = (\n code: string,\n severity: RepresentationDiagnostic[\"severity\"],\n message: string,\n location?: RepresentationDiagnostic[\"location\"],\n): RepresentationDiagnostic => ({\n code,\n severity,\n message,\n location,\n});\n\nexport const createRecoverableError = (\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): EditorErrorEnvelope => ({\n code,\n message,\n severity: \"warning\",\n recoverable: true,\n details,\n});\n\nexport const createFatalError = (\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): EditorErrorEnvelope => ({\n code,\n message,\n severity: \"error\",\n recoverable: false,\n details,\n});\n","import { createDiagnostic } from \"./errors\";\nimport type { RepresentationDiagnostic } from \"./types\";\n\nexport const createUnknownCommandDiagnostic = (commandName: string): RepresentationDiagnostic =>\n createDiagnostic(\"UNKNOWN_COMMAND\", \"warning\", `Command '${commandName}' is not available in current editor capabilities.`);\n\nexport const createNoHistoryDiagnostic = (type: \"undo\" | \"redo\"): RepresentationDiagnostic =>\n createDiagnostic(\"NO_HISTORY\", \"info\", `No ${type} history entry is available for this editor session.`);\n","import type { EditorCommandHandler } from \"./commands\";\n\nconst withCommandMetadata = (commandName: string): EditorCommandHandler => ({ document }) => ({\n document: {\n ...document,\n revision: document.revision + 1,\n metadata: {\n ...document.metadata,\n lastCommand: commandName,\n },\n },\n});\n\nexport const createFormattingCommandHandlers = (): Record<string, EditorCommandHandler> => ({\n bold: withCommandMetadata(\"bold\"),\n italic: withCommandMetadata(\"italic\"),\n underline: withCommandMetadata(\"underline\"),\n heading: withCommandMetadata(\"heading\"),\n list: withCommandMetadata(\"list\"),\n align: withCommandMetadata(\"align\"),\n link: withCommandMetadata(\"link\"),\n});\n","import { createUnknownCommandDiagnostic } from \"./commandDiagnostics\";\nimport { createFormattingCommandHandlers } from \"./formattingCommands\";\nimport type { EditorDocument, RepresentationDiagnostic } from \"./types\";\n\nexport interface EditorCommandContext {\n document: EditorDocument;\n}\n\nexport interface EditorCommandOutcome {\n document: EditorDocument;\n diagnostics?: RepresentationDiagnostic[];\n}\n\nexport type EditorCommandHandler = (\n context: EditorCommandContext,\n params?: Record<string, unknown>,\n) => EditorCommandOutcome;\n\nexport type EditorCommandRegistry = Map<string, EditorCommandHandler>;\n\nexport const createCommandRegistry = (capabilities?: string[]): EditorCommandRegistry => {\n const allowed = new Set(capabilities && capabilities.length > 0 ? capabilities : [\"bold\", \"italic\", \"underline\", \"heading\", \"list\", \"align\", \"link\", \"undo\", \"redo\"]);\n\n const registry: EditorCommandRegistry = new Map();\n const formattingHandlers = createFormattingCommandHandlers();\n\n const registerIfAllowed = (name: string, handler: EditorCommandHandler) => {\n if (allowed.has(name)) {\n registry.set(name, handler);\n }\n };\n\n Object.entries(formattingHandlers).forEach(([commandName, handler]) => {\n registerIfAllowed(commandName, handler);\n });\n\n return registry;\n};\n\nexport const executeCommand = (\n registry: EditorCommandRegistry,\n commandName: string,\n context: EditorCommandContext,\n params?: Record<string, unknown>,\n): EditorCommandOutcome => {\n const handler = registry.get(commandName);\n\n if (!handler) {\n return {\n document: context.document,\n diagnostics: [createUnknownCommandDiagnostic(commandName)],\n };\n }\n\n return handler(context, params);\n};\n","import type { EditorDocument } from \"./types\";\n\nexport class EditorHistory {\n private readonly undoStack: EditorDocument[] = [];\n\n private readonly redoStack: EditorDocument[] = [];\n\n public record(snapshot: EditorDocument): void {\n this.undoStack.push(snapshot);\n this.redoStack.length = 0;\n }\n\n public undo(current: EditorDocument): EditorDocument {\n const previous = this.undoStack.pop();\n\n if (!previous) {\n return current;\n }\n\n this.redoStack.push(current);\n\n return {\n ...previous,\n revision: current.revision + 1,\n metadata: {\n ...previous.metadata,\n lastCommand: \"undo\",\n },\n };\n }\n\n public redo(current: EditorDocument): EditorDocument {\n const next = this.redoStack.pop();\n\n if (!next) {\n return current;\n }\n\n this.undoStack.push(current);\n\n return {\n ...next,\n revision: current.revision + 1,\n metadata: {\n ...next.metadata,\n lastCommand: \"redo\",\n },\n };\n }\n}\n","import DOMPurify from \"isomorphic-dompurify\";\n\nimport { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\n\nconst stripHtml = (value: string): string => value.replace(/<[^>]*>/g, \" \").replace(/\\s+/g, \" \").trim();\n\nconst allowedStyleProperties = new Set([\"font-family\", \"font-size\", \"text-align\", \"margin-left\"]);\n\nconst normalizeStyleValue = (property: string, value: string): string | null => {\n const next = value.trim().toLowerCase();\n\n if (property === \"font-family\") {\n return next === \"serif\" || next === \"monospace\" ? next : null;\n }\n\n if (property === \"font-size\") {\n return [\"12px\", \"16px\", \"20px\", \"28px\"].includes(next) ? next : null;\n }\n\n if (property === \"text-align\") {\n return [\"left\", \"center\", \"right\", \"justify\"].includes(next) ? next : null;\n }\n\n if (property === \"margin-left\") {\n const match = /^([0-9]{1,3})px$/.exec(next);\n\n if (!match) {\n return null;\n }\n\n const amount = Number.parseInt(match[1], 10);\n return amount >= 0 && amount % 24 === 0 ? `${amount}px` : null;\n }\n\n return null;\n};\n\nconst normalizeStyleAttribute = (styleValue: string): string | null => {\n const entries = styleValue\n .split(\";\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0)\n .map((entry) => {\n const separator = entry.indexOf(\":\");\n\n if (separator < 0) {\n return null;\n }\n\n const property = entry.slice(0, separator).trim().toLowerCase();\n const value = entry.slice(separator + 1).trim();\n\n if (!allowedStyleProperties.has(property)) {\n return null;\n }\n\n const normalized = normalizeStyleValue(property, value);\n\n if (!normalized) {\n return null;\n }\n\n return `${property}:${normalized}`;\n })\n .filter((entry): entry is string => Boolean(entry));\n\n if (entries.length === 0) {\n return null;\n }\n\n return entries.join(\";\");\n};\n\nconst normalizeHtml = (value: string): string => {\n if (typeof DOMParser === \"undefined\") {\n return value.trim().length > 0 ? value : \"<p></p>\";\n }\n\n const parser = new DOMParser();\n const doc = parser.parseFromString(`<div>${value}</div>`, \"text/html\");\n const root = doc.body.firstElementChild;\n\n if (!root) {\n return \"<p></p>\";\n }\n\n root.querySelectorAll(\"b\").forEach((element) => {\n const replacement = doc.createElement(\"strong\");\n replacement.innerHTML = element.innerHTML;\n element.replaceWith(replacement);\n });\n\n root.querySelectorAll(\"i\").forEach((element) => {\n const replacement = doc.createElement(\"em\");\n replacement.innerHTML = element.innerHTML;\n element.replaceWith(replacement);\n });\n\n root.querySelectorAll(\"strike\").forEach((element) => {\n const replacement = doc.createElement(\"s\");\n replacement.innerHTML = element.innerHTML;\n element.replaceWith(replacement);\n });\n\n root.querySelectorAll(\"*\").forEach((element) => {\n const tag = element.tagName.toLowerCase();\n\n Array.from(element.attributes).forEach((attribute) => {\n const name = attribute.name.toLowerCase();\n const valueAttr = attribute.value;\n\n if (name === \"style\") {\n const normalized = normalizeStyleAttribute(valueAttr);\n\n if (normalized) {\n element.setAttribute(\"style\", normalized);\n } else {\n element.removeAttribute(\"style\");\n }\n\n return;\n }\n\n if (name === \"href\" || name === \"src\") {\n if (!/^(https?:|mailto:|tel:)/i.test(valueAttr.trim())) {\n element.removeAttribute(attribute.name);\n }\n\n return;\n }\n\n if (name === \"target\" || name === \"rel\" || name === \"alt\" || name === \"data-formula\" || name === \"controls\" || name === \"dir\") {\n return;\n }\n\n element.removeAttribute(attribute.name);\n });\n\n if (tag === \"a\") {\n element.setAttribute(\"rel\", \"noopener noreferrer\");\n element.setAttribute(\"target\", \"_blank\");\n }\n\n if (tag === \"video\") {\n element.setAttribute(\"controls\", \"true\");\n }\n });\n\n Array.from(root.childNodes).forEach((node) => {\n if (node.nodeType === Node.TEXT_NODE && (node.textContent?.trim().length ?? 0) > 0) {\n const paragraph = doc.createElement(\"p\");\n paragraph.textContent = node.textContent ?? \"\";\n root.replaceChild(paragraph, node);\n }\n });\n\n const normalized = root.innerHTML.trim();\n return normalized.length > 0 ? normalized : \"<p></p>\";\n};\n\nexport interface HtmlImportResult {\n richText: string;\n sanitizedHtml: string;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const sanitizeHtml = (payload: string): string =>\n DOMPurify.sanitize(payload, {\n ALLOWED_TAGS: [\n \"p\",\n \"br\",\n \"b\",\n \"i\",\n \"strike\",\n \"strong\",\n \"em\",\n \"u\",\n \"s\",\n \"code\",\n \"pre\",\n \"blockquote\",\n \"h1\",\n \"h2\",\n \"ul\",\n \"ol\",\n \"li\",\n \"a\",\n \"img\",\n \"video\",\n \"span\",\n \"sub\",\n \"sup\",\n \"div\",\n ],\n ALLOWED_ATTR: [\"href\", \"src\", \"alt\", \"target\", \"rel\", \"style\", \"data-formula\", \"controls\", \"dir\"],\n FORBID_TAGS: [\"script\", \"style\", \"iframe\", \"object\", \"embed\", \"form\", \"input\", \"button\", \"textarea\", \"select\"],\n });\n\nexport const importHtml = (payload: string): HtmlImportResult => {\n const diagnostics: RepresentationDiagnostic[] = [];\n const sanitized = sanitizeHtml(payload);\n const normalized = normalizeHtml(sanitized);\n\n if (normalized !== payload) {\n diagnostics.push(\n createDiagnostic(\n \"SANITIZED_CONTENT\",\n \"warning\",\n \"Input HTML was sanitized to remove unsupported or unsafe markup.\",\n ),\n );\n }\n\n if (normalized.trim().length === 0) {\n diagnostics.push(createDiagnostic(\"EMPTY_HTML\", \"info\", \"The provided HTML content is empty after normalization.\"));\n }\n\n return {\n richText: stripHtml(normalized),\n sanitizedHtml: normalized,\n diagnostics,\n };\n};\n\nexport const exportHtml = (richText: string): string => {\n const escaped = richText\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\\n/g, \"<br>\");\n\n return normalizeHtml(`<p>${escaped}</p>`);\n};\n\nexport { normalizeHtml };\n","import { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\n\nexport const createUnsupportedMarkupDiagnostic = (details?: string): RepresentationDiagnostic =>\n createDiagnostic(\n \"UNSUPPORTED_MARKUP\",\n \"warning\",\n details ?? \"Some markup could not be fully represented and was normalized.\",\n );\n\nexport const createRecoverableParseDiagnostic = (format: \"markdown\" | \"html\", details?: string): RepresentationDiagnostic =>\n createDiagnostic(\n \"RECOVERABLE_PARSE\",\n \"warning\",\n details ?? `Some ${format.toUpperCase()} content was partially recovered during import.`,\n );\n","import type { EditorDocument, EditorInput, RepresentationDiagnostic } from \"../core/types\";\n\nimport { createRecoverableParseDiagnostic, createUnsupportedMarkupDiagnostic } from \"./diagnostics\";\n\nexport const applyImportFallback = (\n input: EditorInput,\n base: EditorDocument,\n): { document: EditorDocument; diagnostics: RepresentationDiagnostic[] } => {\n const payload = input.payload.trim();\n const diagnostics: RepresentationDiagnostic[] = [\n createRecoverableParseDiagnostic(input.format === \"html\" ? \"html\" : \"markdown\"),\n ];\n\n const stripped = input.format === \"html\" ? payload.replace(/<[^>]*>/g, \" \").replace(/\\s+/g, \" \").trim() : payload;\n\n if (stripped.length === 0) {\n diagnostics.push(createUnsupportedMarkupDiagnostic(\"Input produced no recoverable text content after normalization.\"));\n }\n\n return {\n document: {\n ...base,\n content: {\n richText: stripped,\n html: input.format === \"html\" ? payload : base.content.html,\n },\n metadata: {\n ...base.metadata,\n importFallback: true,\n },\n },\n diagnostics,\n };\n};\n","import { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\n\nconst normalizeMarkdown = (value: string) => value.replace(/\\r\\n?/g, \"\\n\");\n\nexport interface MarkdownImportResult {\n richText: string;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const importMarkdown = (payload: string): MarkdownImportResult => {\n const diagnostics: RepresentationDiagnostic[] = [];\n const normalized = normalizeMarkdown(payload);\n\n if (normalized.trim().length === 0) {\n diagnostics.push(createDiagnostic(\"EMPTY_MARKDOWN\", \"info\", \"The provided markdown content is empty.\"));\n }\n\n return {\n richText: normalized,\n diagnostics,\n };\n};\n\nexport const exportMarkdown = (richText: string): string => normalizeMarkdown(richText);\n","import type { ContentFormat, EditorDocument, EditorExport, EditorInput, RepresentationDiagnostic } from \"../core/types\";\n\nimport { exportHtml, importHtml, normalizeHtml } from \"./html\";\nimport { applyImportFallback } from \"./importFallback\";\nimport { exportMarkdown, importMarkdown } from \"./markdown\";\n\nexport interface ImportResult {\n document: EditorDocument;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const importRepresentation = (input: EditorInput, base: EditorDocument): ImportResult => {\n if (input.format === \"rich\") {\n const normalizedHtml = normalizeHtml(exportHtml(input.payload));\n\n return {\n document: {\n ...base,\n content: {\n richText: input.payload,\n html: normalizedHtml,\n },\n },\n diagnostics: [],\n };\n }\n\n if (input.format === \"markdown\") {\n try {\n const result = importMarkdown(input.payload);\n\n return {\n document: {\n ...base,\n content: {\n richText: result.richText,\n },\n metadata: {\n ...base.metadata,\n importedFrom: \"markdown\",\n },\n },\n diagnostics: result.diagnostics,\n };\n } catch {\n return applyImportFallback(input, base);\n }\n }\n\n try {\n const result = importHtml(input.payload);\n\n return {\n document: {\n ...base,\n content: {\n richText: result.richText,\n html: result.sanitizedHtml,\n },\n metadata: {\n ...base.metadata,\n importedFrom: \"html\",\n },\n },\n diagnostics: result.diagnostics,\n };\n } catch {\n return applyImportFallback(input, base);\n }\n};\n\nexport const exportRepresentation = (document: EditorDocument, format: ContentFormat): EditorExport => {\n if (format === \"rich\") {\n return {\n format,\n payload: document.content.richText,\n diagnostics: [],\n };\n }\n\n if (format === \"markdown\") {\n return {\n format,\n payload: exportMarkdown(document.content.richText),\n diagnostics: [],\n };\n }\n\n const htmlPayload = document.content.html\n ? normalizeHtml(document.content.html)\n : normalizeHtml(exportHtml(document.content.richText));\n\n return {\n format,\n payload: htmlPayload,\n diagnostics: [],\n };\n};\n","import { createCommandRegistry, executeCommand } from \"./commands\";\nimport { createNoHistoryDiagnostic } from \"./commandDiagnostics\";\nimport { createRecoverableError } from \"./errors\";\nimport { EditorHistory } from \"./history\";\nimport type { CommandResult, ContentFormat, EditorConfig, EditorDocument, EditorExport, EditorInput, EditorInstance, RepresentationDiagnostic } from \"./types\";\nimport { exportRepresentation, importRepresentation } from \"../transforms/representationSwitch\";\n\nconst createDefaultDocument = (): EditorDocument => ({\n id: crypto.randomUUID(),\n content: {\n richText: \"\",\n },\n metadata: {},\n revision: 0,\n});\n\nconst fromInput = (input: EditorInput, base: EditorDocument): { document: EditorDocument; diagnostics: RepresentationDiagnostic[] } =>\n importRepresentation(input, base);\n\nconst toExport = (document: EditorDocument, format: ContentFormat): EditorExport =>\n exportRepresentation(document, format);\n\nexport const createEditor = (config: EditorConfig = {}): EditorInstance => {\n const registry = createCommandRegistry(config.commandCapabilities);\n const history = new EditorHistory();\n let mountedTarget: Element | null = null;\n let isDestroyed = false;\n let currentDocument = createDefaultDocument();\n\n if (config.initialContent) {\n const initialized = fromInput(config.initialContent, currentDocument);\n currentDocument = initialized.document;\n\n if (initialized.diagnostics.length > 0) {\n config.onError?.(\n createRecoverableError(\"INITIAL_CONTENT_DIAGNOSTIC\", \"Initial content was normalized during editor initialization.\", {\n diagnostics: initialized.diagnostics,\n }),\n );\n }\n }\n\n const ensureActive = (): boolean => {\n if (!isDestroyed) {\n return true;\n }\n\n config.onError?.(createRecoverableError(\"EDITOR_DESTROYED\", \"This editor instance has already been destroyed.\"));\n return false;\n };\n\n const emitChange = () => {\n config.onChange?.(currentDocument);\n };\n\n return {\n getDocument: () => currentDocument,\n\n execute: (commandName, params) => {\n if (!ensureActive()) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n const result = executeCommand(registry, commandName, { document: currentDocument }, params);\n\n if (commandName === \"undo\") {\n const next = history.undo(currentDocument);\n\n if (next === currentDocument) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [createNoHistoryDiagnostic(\"undo\")],\n };\n }\n\n currentDocument = next;\n emitChange();\n\n return {\n ok: true,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n if (commandName === \"redo\") {\n const next = history.redo(currentDocument);\n\n if (next === currentDocument) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [createNoHistoryDiagnostic(\"redo\")],\n };\n }\n\n currentDocument = next;\n emitChange();\n\n return {\n ok: true,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n history.record(currentDocument);\n currentDocument = result.document;\n emitChange();\n\n return {\n ok: (result.diagnostics?.length ?? 0) === 0,\n document: currentDocument,\n diagnostics: result.diagnostics ?? [],\n };\n },\n\n export: (format) => toExport(currentDocument, format),\n\n import: (input) => {\n if (!ensureActive()) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n const result = fromInput(input, {\n ...currentDocument,\n revision: currentDocument.revision + 1,\n });\n\n currentDocument = result.document;\n emitChange();\n\n return {\n ok: result.diagnostics.length === 0,\n document: currentDocument,\n diagnostics: result.diagnostics,\n };\n },\n\n mount: (target) => {\n if (!ensureActive()) {\n return;\n }\n\n mountedTarget = target;\n },\n\n unmount: () => {\n mountedTarget = null;\n },\n\n destroy: () => {\n mountedTarget = null;\n isDestroyed = true;\n },\n };\n};\n","import { Schema } from \"prosemirror-model\";\n\nexport const editorNodeNames = {\n doc: \"doc\",\n paragraph: \"paragraph\",\n heading: \"heading\",\n text: \"text\",\n bulletList: \"bullet_list\",\n orderedList: \"ordered_list\",\n listItem: \"list_item\",\n hardBreak: \"hard_break\",\n} as const;\n\nexport const editorMarkNames = {\n strong: \"strong\",\n em: \"em\",\n underline: \"underline\",\n link: \"link\",\n} as const;\n\nexport const createEditorSchema = () =>\n new Schema({\n nodes: {\n doc: { content: \"block+\" },\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n parseDOM: [{ tag: \"p\" }],\n toDOM: () => [\"p\", 0],\n },\n heading: {\n attrs: { level: { default: 1 } },\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [{ tag: \"h1\", attrs: { level: 1 } }, { tag: \"h2\", attrs: { level: 2 } }, { tag: \"h3\", attrs: { level: 3 } }],\n toDOM: (node) => [`h${Math.max(1, Math.min(3, Number(node.attrs.level) || 1))}`, 0],\n },\n bullet_list: {\n content: \"list_item+\",\n group: \"block\",\n parseDOM: [{ tag: \"ul\" }],\n toDOM: () => [\"ul\", 0],\n },\n ordered_list: {\n attrs: { order: { default: 1 } },\n content: \"list_item+\",\n group: \"block\",\n parseDOM: [\n {\n tag: \"ol\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLOListElement)) {\n return { order: 1 };\n }\n\n return { order: dom.start || 1 };\n },\n },\n ],\n toDOM: (node) => [\"ol\", { start: node.attrs.order || 1 }, 0],\n },\n list_item: {\n content: \"paragraph block*\",\n parseDOM: [{ tag: \"li\" }],\n toDOM: () => [\"li\", 0],\n },\n text: { group: \"inline\" },\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{ tag: \"br\" }],\n toDOM: () => [\"br\"],\n },\n },\n marks: {\n strong: {\n parseDOM: [{ tag: \"strong\" }, { tag: \"b\", getAttrs: () => null }],\n toDOM: () => [\"strong\", 0],\n },\n em: {\n parseDOM: [{ tag: \"em\" }, { tag: \"i\", getAttrs: () => null }],\n toDOM: () => [\"em\", 0],\n },\n underline: {\n parseDOM: [{ tag: \"u\" }],\n toDOM: () => [\"u\", 0],\n },\n link: {\n attrs: { href: {}, title: { default: null } },\n inclusive: false,\n parseDOM: [\n {\n tag: \"a[href]\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLAnchorElement)) {\n return false;\n }\n\n return {\n href: dom.getAttribute(\"href\"),\n title: dom.getAttribute(\"title\"),\n };\n },\n },\n ],\n toDOM: (node) => [\"a\", { href: node.attrs.href, title: node.attrs.title }, 0],\n },\n },\n });\n\nexport const editorSchema = createEditorSchema();\n","export interface ToolbarAction {\n command: string;\n label: string;\n group: \"inline\" | \"block\" | \"history\";\n}\n\nexport const defaultToolbarActions: ToolbarAction[] = [\n { command: \"bold\", label: \"Bold\", group: \"inline\" },\n { command: \"italic\", label: \"Italic\", group: \"inline\" },\n { command: \"underline\", label: \"Underline\", group: \"inline\" },\n { command: \"heading\", label: \"Heading\", group: \"block\" },\n { command: \"list\", label: \"List\", group: \"block\" },\n { command: \"align\", label: \"Align\", group: \"block\" },\n { command: \"link\", label: \"Link\", group: \"inline\" },\n { command: \"undo\", label: \"Undo\", group: \"history\" },\n { command: \"redo\", label: \"Redo\", group: \"history\" },\n];\n","type EmbedType = \"link\" | \"image\" | \"video\" | \"formula\";\n\ntype MountRichTextEditorOptions = {\n host: HTMLElement;\n initialHtml: string;\n disabled?: boolean;\n onChange: (html: string) => void;\n requestEmbedValue?: (type: EmbedType) => Promise<string | null> | string | null;\n};\n\ntype MountedRichTextEditor = {\n destroy: () => void;\n getHtml: () => string;\n setHtml: (html: string) => void;\n};\n\nconst commandLabels: Record<string, string> = {\n bold: \"Bold\",\n italic: \"Italic\",\n underline: \"Underline\",\n strike: \"Strike\",\n code: \"Inline code\",\n blockquote: \"Blockquote\",\n \"code-block\": \"Code block\",\n \"indent-\": \"Outdent\",\n \"indent+\": \"Indent\",\n link: \"Link\",\n image: \"Image\",\n video: \"Video\",\n formula: \"Formula\",\n clean: \"Remove formatting\",\n};\n\nconst commandIconSvg: Record<string, string> = {\n bold: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M4 2.5h4.5a2.5 2.5 0 010 5H4z\"/><path d=\"M4 7.5h5a3 3 0 010 6H4z\"/></svg>',\n italic: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"><path d=\"M9.8 2.5H5.5\"/><path d=\"M10.5 13.5H6.2\"/><path d=\"M9.3 2.5 6.7 13.5\"/></svg>',\n underline: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M4 2.5v4.2a4 4 0 008 0V2.5\"/><path d=\"M3 13.5h10\"/></svg>',\n strike: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M4 4.5c.8-1.2 2-1.9 3.7-1.9 2 0 3.3 1 3.3 2.5 0 3-6.5 1.8-6.5 4.6 0 1.5 1.3 2.3 3.4 2.3 1.6 0 2.9-.6 3.8-1.7\"/><path d=\"M2.5 8h11\"/></svg>',\n code: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 4 2.5 8 6 12\"/><path d=\"M10 4 13.5 8 10 12\"/><path d=\"M8.7 2.8 7.3 13.2\"/></svg>',\n blockquote: '<svg viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M3 3h4v4H4.8c.1 1.8-.7 3.2-1.8 4L2 10c1-.7 1.5-1.7 1.4-3H3zM9 3h4v4h-2.2c.1 1.8-.7 3.2-1.8 4L8 10c1-.7 1.5-1.7 1.4-3H9z\"/></svg>',\n \"code-block\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.5\" y=\"2.5\" width=\"11\" height=\"11\" rx=\"1.8\"/><path d=\"M6.2 6 4.5 8l1.7 2\"/><path d=\"M9.8 6 11.5 8l-1.7 2\"/><path d=\"M8.6 5.5 7.4 10.5\"/></svg>',\n \"indent-\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M9 4h4\"/><path d=\"M9 8h4\"/><path d=\"M9 12h4\"/><path d=\"M7 5.5 4 8l3 2.5\"/></svg>',\n \"indent+\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4h4\"/><path d=\"M3 8h4\"/><path d=\"M3 12h4\"/><path d=\"M9 5.5 12 8l-3 2.5\"/></svg>',\n link: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M6.3 9.7 4.9 11a2.4 2.4 0 103.4 3.4l1.5-1.4\"/><path d=\"M9.7 6.3 11 4.9a2.4 2.4 0 10-3.4-3.4L6.1 2.9\"/><path d=\"M5.9 10.1 10.1 5.9\"/></svg>',\n image: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.3\" y=\"2.5\" width=\"11.4\" height=\"11\" rx=\"1.8\"/><circle cx=\"6\" cy=\"6\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><path d=\"m3.8 11 2.8-2.8 2.2 2.2 1.6-1.6 1.8 2.2\"/></svg>',\n video: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.2\" y=\"3\" width=\"8.8\" height=\"10\" rx=\"1.6\"/><path d=\"M11 6.2 13.8 4.8v6.4L11 9.8z\"/><path d=\"M6.2 6.4v3.2l2.7-1.6z\" fill=\"currentColor\" stroke=\"none\"/></svg>',\n formula: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4h5\"/><path d=\"M3 12h5\"/><path d=\"M8 4 5 8l3 4\"/><path d=\"M10.3 5.8v4.4\"/><path d=\"M12.5 8h-4.4\"/></svg>',\n clean: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2.8 12.5h6.8\"/><path d=\"m4.2 3.3 6 6\"/><path d=\"m10.2 2.7 3 3-2 2-3-3z\"/><path d=\"M6.2 11.2 4.1 13.3\"/></svg>',\n};\n\nconst createToolbarIcon = (command: string, fallback: string): HTMLElement => {\n const icon = document.createElement(\"span\");\n icon.className = \"az-rich-editor-toolbar-icon\";\n\n const svgMarkup = commandIconSvg[command];\n if (svgMarkup) {\n icon.innerHTML = svgMarkup;\n } else {\n icon.textContent = fallback;\n }\n\n return icon;\n};\n\nconst selectOptionLabels: Record<string, Record<string, string>> = {\n font: {\n default: \"A\",\n serif: \"As\",\n monospace: \"Am\",\n },\n size: {\n small: \"S\",\n normal: \"N\",\n large: \"L\",\n huge: \"XL\",\n },\n header: {\n normal: \"P\",\n h1: \"H1\",\n h2: \"H2\",\n },\n script: {\n normal: \"x\",\n sub: \"x_\",\n super: \"x^\",\n },\n align: {\n left: \"L\",\n center: \"C\",\n right: \"R\",\n justify: \"J\",\n },\n list: {\n none: \"-\",\n ordered: \"1.\",\n bullet: \"o\",\n },\n direction: {\n ltr: \"->\",\n rtl: \"<-\",\n },\n};\n\nconst safeUrl = (value: string): string | null => {\n const trimmed = value.trim();\n\n if (!trimmed) {\n return null;\n }\n\n if (/^(https?:|mailto:|tel:)/i.test(trimmed)) {\n return trimmed;\n }\n\n return null;\n};\n\nconst escapeHtml = (value: string): string =>\n value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\\\"/g, \""\");\n\nconst closestElement = (node: Node | null, root: HTMLElement): HTMLElement | null => {\n let current: Node | null = node;\n\n while (current && current !== root) {\n if (current instanceof HTMLElement) {\n return current;\n }\n\n current = current.parentNode;\n }\n\n return null;\n};\n\nconst closestByTag = (node: Node | null, tagName: string, root: HTMLElement): HTMLElement | null => {\n const desired = tagName.toLowerCase();\n let current: Node | null = node;\n\n while (current && current !== root) {\n if (current instanceof HTMLElement && current.tagName.toLowerCase() === desired) {\n return current;\n }\n\n current = current.parentNode;\n }\n\n return null;\n};\n\nconst unwrapElement = (element: HTMLElement) => {\n const parent = element.parentNode;\n\n if (!parent) {\n return;\n }\n\n while (element.firstChild) {\n parent.insertBefore(element.firstChild, element);\n }\n\n parent.removeChild(element);\n};\n\nconst placeCaretInside = (element: HTMLElement) => {\n const selection = window.getSelection();\n\n if (!selection) {\n return;\n }\n\n const range = document.createRange();\n range.selectNodeContents(element);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n};\n\nconst getSelectionRange = (root: HTMLElement): Range | null => {\n const selection = window.getSelection();\n\n if (!selection || selection.rangeCount === 0) {\n return null;\n }\n\n const range = selection.getRangeAt(0);\n\n if (!root.contains(range.commonAncestorContainer)) {\n return null;\n }\n\n return range;\n};\n\nconst wrapRange = (range: Range, tagName: string, attrs?: Record<string, string>): HTMLElement => {\n const wrapper = document.createElement(tagName);\n\n if (attrs) {\n Object.entries(attrs).forEach(([key, value]) => wrapper.setAttribute(key, value));\n }\n\n if (range.collapsed) {\n wrapper.append(document.createTextNode(\"\\u200B\"));\n range.insertNode(wrapper);\n placeCaretInside(wrapper);\n return wrapper;\n }\n\n const fragment = range.extractContents();\n wrapper.append(fragment);\n range.insertNode(wrapper);\n\n const selection = window.getSelection();\n if (selection) {\n const nextRange = document.createRange();\n nextRange.selectNodeContents(wrapper);\n selection.removeAllRanges();\n selection.addRange(nextRange);\n }\n\n return wrapper;\n};\n\nconst blockTags = new Set([\"p\", \"div\", \"h1\", \"h2\", \"blockquote\", \"pre\", \"li\"]);\n\nconst getBlockElement = (range: Range, root: HTMLElement): HTMLElement => {\n const start = closestElement(range.startContainer, root);\n\n if (!start) {\n return root;\n }\n\n let current: HTMLElement | null = start;\n while (current && current !== root) {\n if (blockTags.has(current.tagName.toLowerCase())) {\n return current;\n }\n\n current = current.parentElement;\n }\n\n return root;\n};\n\nconst replaceBlockTag = (block: HTMLElement, tagName: string): HTMLElement => {\n if (block.tagName.toLowerCase() === tagName.toLowerCase()) {\n return block;\n }\n\n const replacement = document.createElement(tagName);\n while (block.firstChild) {\n replacement.append(block.firstChild);\n }\n\n Array.from(block.attributes).forEach((attribute) => {\n if (attribute.name === \"style\" || attribute.name === \"dir\") {\n replacement.setAttribute(attribute.name, attribute.value);\n }\n });\n\n block.parentNode?.replaceChild(replacement, block);\n return replacement;\n};\n\nconst applyInlineTag = (tagName: string, root: HTMLElement, range: Range) => {\n const existing = closestByTag(range.commonAncestorContainer, tagName, root);\n\n if (existing) {\n unwrapElement(existing);\n return;\n }\n\n wrapRange(range, tagName);\n};\n\nconst applyScript = (value: \"normal\" | \"sub\" | \"super\", root: HTMLElement, range: Range) => {\n const sub = closestByTag(range.commonAncestorContainer, \"sub\", root);\n const sup = closestByTag(range.commonAncestorContainer, \"sup\", root);\n\n if (sub) {\n unwrapElement(sub);\n }\n\n if (sup) {\n unwrapElement(sup);\n }\n\n if (value === \"sub\") {\n wrapRange(range, \"sub\");\n }\n\n if (value === \"super\") {\n wrapRange(range, \"sup\");\n }\n};\n\nconst applyHeader = (value: \"normal\" | \"h1\" | \"h2\", root: HTMLElement, range: Range) => {\n const block = getBlockElement(range, root);\n\n if (value === \"h1\" || value === \"h2\") {\n replaceBlockTag(block, value);\n return;\n }\n\n replaceBlockTag(block, \"p\");\n};\n\nconst toggleBlockTag = (tagName: \"blockquote\" | \"pre\", root: HTMLElement, range: Range) => {\n const block = getBlockElement(range, root);\n\n if (block.tagName.toLowerCase() === tagName) {\n replaceBlockTag(block, \"p\");\n return;\n }\n\n replaceBlockTag(block, tagName);\n};\n\nconst ensureList = (tagName: \"ol\" | \"ul\", root: HTMLElement, range: Range, remove: boolean) => {\n const block = getBlockElement(range, root);\n const li = closestByTag(block, \"li\", root);\n\n if (li) {\n const list = li.parentElement;\n\n if (!list) {\n return;\n }\n\n if (remove || list.tagName.toLowerCase() === tagName) {\n const paragraph = document.createElement(\"p\");\n paragraph.textContent = li.textContent ?? \"\";\n list.parentNode?.insertBefore(paragraph, list);\n li.remove();\n\n if (!list.querySelector(\"li\")) {\n list.remove();\n }\n\n return;\n }\n\n const nextList = document.createElement(tagName);\n const nextLi = document.createElement(\"li\");\n nextLi.textContent = li.textContent ?? \"\";\n nextList.append(nextLi);\n list.parentNode?.insertBefore(nextList, list.nextSibling);\n li.remove();\n\n if (!list.querySelector(\"li\")) {\n list.remove();\n }\n\n return;\n }\n\n if (remove) {\n return;\n }\n\n const list = document.createElement(tagName);\n const listItem = document.createElement(\"li\");\n listItem.innerHTML = block.innerHTML;\n list.append(listItem);\n block.parentNode?.replaceChild(list, block);\n};\n\nconst applyIndent = (root: HTMLElement, range: Range, direction: \"-\" | \"+\") => {\n const block = getBlockElement(range, root);\n const current = Number.parseInt(block.style.marginLeft || \"0\", 10) || 0;\n const next = direction === \"+\" ? current + 24 : Math.max(0, current - 24);\n\n block.style.marginLeft = next === 0 ? \"\" : `${next}px`;\n};\n\nconst applyAlign = (root: HTMLElement, range: Range, align: \"left\" | \"center\" | \"right\" | \"justify\") => {\n const block = getBlockElement(range, root);\n block.style.textAlign = align;\n};\n\nconst applyDirection = (root: HTMLElement, range: Range, value: \"ltr\" | \"rtl\") => {\n const block = getBlockElement(range, root);\n block.setAttribute(\"dir\", value);\n};\n\nconst clearFormatting = (root: HTMLElement, range: Range) => {\n if (range.collapsed) {\n const block = getBlockElement(range, root);\n const text = block.textContent ?? \"\";\n block.replaceChildren(document.createTextNode(text));\n return;\n }\n\n const selectedText = range.toString();\n range.deleteContents();\n range.insertNode(document.createTextNode(selectedText));\n};\n\nconst insertNodeAtRange = (range: Range, node: Node) => {\n range.deleteContents();\n range.insertNode(node);\n\n const selection = window.getSelection();\n if (selection) {\n const after = document.createRange();\n after.setStartAfter(node);\n after.collapse(true);\n selection.removeAllRanges();\n selection.addRange(after);\n }\n};\n\nconst applyEmbed = async (\n type: EmbedType,\n range: Range,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n) => {\n const value = await Promise.resolve(requestEmbedValue?.(type) ?? null);\n\n if (!value || value.trim().length === 0) {\n return;\n }\n\n if (type === \"formula\") {\n const formula = document.createElement(\"span\");\n formula.setAttribute(\"data-formula\", \"true\");\n formula.textContent = value.trim();\n insertNodeAtRange(range, formula);\n return;\n }\n\n const url = safeUrl(value);\n\n if (!url) {\n return;\n }\n\n if (type === \"link\") {\n const selected = range.toString().trim();\n const anchor = document.createElement(\"a\");\n anchor.href = url;\n anchor.rel = \"noopener noreferrer\";\n anchor.target = \"_blank\";\n anchor.textContent = selected.length > 0 ? selected : url;\n insertNodeAtRange(range, anchor);\n return;\n }\n\n if (type === \"image\") {\n const image = document.createElement(\"img\");\n image.src = url;\n image.alt = \"embedded image\";\n insertNodeAtRange(range, image);\n return;\n }\n\n const video = document.createElement(\"video\");\n video.setAttribute(\"controls\", \"true\");\n video.src = url;\n insertNodeAtRange(range, video);\n};\n\nconst applyButtonCommand = async (\n command: string,\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n) => {\n editable.focus();\n\n const range = getSelectionRange(editable);\n\n if (!range) {\n return;\n }\n\n switch (command) {\n case \"bold\":\n applyInlineTag(\"strong\", editable, range);\n break;\n case \"italic\":\n applyInlineTag(\"em\", editable, range);\n break;\n case \"underline\":\n applyInlineTag(\"u\", editable, range);\n break;\n case \"strike\":\n applyInlineTag(\"s\", editable, range);\n break;\n case \"code\":\n applyInlineTag(\"code\", editable, range);\n break;\n case \"blockquote\":\n toggleBlockTag(\"blockquote\", editable, range);\n break;\n case \"code-block\":\n toggleBlockTag(\"pre\", editable, range);\n break;\n case \"indent-\":\n applyIndent(editable, range, \"-\");\n break;\n case \"indent+\":\n applyIndent(editable, range, \"+\");\n break;\n case \"link\":\n await applyEmbed(\"link\", range, requestEmbedValue);\n break;\n case \"image\":\n await applyEmbed(\"image\", range, requestEmbedValue);\n break;\n case \"video\":\n await applyEmbed(\"video\", range, requestEmbedValue);\n break;\n case \"formula\":\n await applyEmbed(\"formula\", range, requestEmbedValue);\n break;\n case \"clean\":\n clearFormatting(editable, range);\n break;\n default:\n break;\n }\n};\n\nconst applySelectCommand = (command: string, value: string, editable: HTMLDivElement) => {\n editable.focus();\n\n const range = getSelectionRange(editable);\n\n if (!range) {\n return;\n }\n\n switch (command) {\n case \"font\":\n if (value === \"default\") {\n clearFormatting(editable, range);\n } else {\n wrapRange(range, \"span\", {\n style: `font-family:${value === \"serif\" ? \"serif\" : \"monospace\"}`,\n });\n }\n break;\n case \"size\":\n wrapRange(range, \"span\", {\n style:\n value === \"small\"\n ? \"font-size:12px\"\n : value === \"large\"\n ? \"font-size:20px\"\n : value === \"huge\"\n ? \"font-size:28px\"\n : \"font-size:16px\",\n });\n break;\n case \"header\":\n applyHeader(value as \"normal\" | \"h1\" | \"h2\", editable, range);\n break;\n case \"script\":\n applyScript(value as \"normal\" | \"sub\" | \"super\", editable, range);\n break;\n case \"align\":\n applyAlign(editable, range, value as \"left\" | \"center\" | \"right\" | \"justify\");\n break;\n case \"list\":\n ensureList(value === \"ordered\" ? \"ol\" : \"ul\", editable, range, value === \"none\");\n break;\n case \"direction\":\n applyDirection(editable, range, value === \"rtl\" ? \"rtl\" : \"ltr\");\n break;\n default:\n break;\n }\n};\n\nconst renderButton = (\n command: string,\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n onMutate: () => void,\n) => {\n const button = document.createElement(\"button\");\n\n button.type = \"button\";\n button.className = \"az-rich-editor-toolbar-button\";\n button.setAttribute(\"aria-label\", commandLabels[command] ?? command);\n button.title = commandLabels[command] ?? command;\n button.append(createToolbarIcon(command, command));\n button.addEventListener(\"click\", async () => {\n await applyButtonCommand(command, editable, requestEmbedValue);\n onMutate();\n });\n\n return button;\n};\n\nconst createSelect = (\n format: string,\n options: string[],\n editable: HTMLDivElement,\n onMutate: () => void,\n) => {\n const select = document.createElement(\"select\");\n\n select.className = \"az-rich-editor-toolbar-select\";\n select.setAttribute(\"aria-label\", format);\n\n options.forEach((optionValue) => {\n const option = document.createElement(\"option\");\n\n option.value = optionValue;\n option.textContent = selectOptionLabels[format]?.[optionValue] ?? optionValue;\n option.title = optionValue;\n select.append(option);\n });\n\n select.addEventListener(\"change\", () => {\n applySelectCommand(format, select.value, editable);\n onMutate();\n });\n\n return select;\n};\n\nconst buildToolbar = (\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n onMutate: () => void,\n) => {\n const toolbar = document.createElement(\"div\");\n\n toolbar.className = \"az-rich-editor-toolbar\";\n toolbar.setAttribute(\"role\", \"toolbar\");\n toolbar.setAttribute(\"aria-label\", \"Rich editor toolbar\");\n\n const selectConfigs: Array<{ format: string; options: string[] }> = [\n { format: \"font\", options: [\"default\", \"serif\", \"monospace\"] },\n { format: \"size\", options: [\"small\", \"normal\", \"large\", \"huge\"] },\n { format: \"header\", options: [\"normal\", \"h1\", \"h2\"] },\n { format: \"script\", options: [\"normal\", \"sub\", \"super\"] },\n { format: \"align\", options: [\"left\", \"center\", \"right\", \"justify\"] },\n { format: \"list\", options: [\"none\", \"ordered\", \"bullet\"] },\n { format: \"direction\", options: [\"ltr\", \"rtl\"] },\n ];\n\n selectConfigs.forEach((config) => toolbar.append(createSelect(config.format, config.options, editable, onMutate)));\n\n [\n \"bold\",\n \"italic\",\n \"underline\",\n \"strike\",\n \"code\",\n \"blockquote\",\n \"code-block\",\n \"indent-\",\n \"indent+\",\n \"link\",\n \"image\",\n \"video\",\n \"formula\",\n \"clean\",\n ].forEach((command) => toolbar.append(renderButton(command, editable, requestEmbedValue, onMutate)));\n\n return toolbar;\n};\n\nexport const mountRichTextEditor = ({\n host,\n initialHtml,\n disabled = false,\n onChange,\n requestEmbedValue,\n}: MountRichTextEditorOptions): MountedRichTextEditor => {\n host.innerHTML = \"\";\n\n const wrapper = document.createElement(\"div\");\n wrapper.className = \"az-rich-editor\";\n\n const editable = document.createElement(\"div\");\n editable.className = \"az-rich-editor-input\";\n editable.setAttribute(\"aria-label\", \"Rich editor input\");\n editable.setAttribute(\"role\", \"textbox\");\n editable.setAttribute(\"aria-multiline\", \"true\");\n editable.setAttribute(\"contenteditable\", disabled ? \"false\" : \"true\");\n editable.dataset.placeholder = \"Compose an epic...\";\n editable.innerHTML = initialHtml;\n\n const emitChange = () => onChange(editable.innerHTML);\n\n const toolbar = buildToolbar(editable, requestEmbedValue, emitChange);\n\n const inputHandler = () => emitChange();\n editable.addEventListener(\"input\", inputHandler);\n\n wrapper.append(toolbar, editable);\n host.append(wrapper);\n\n return {\n destroy: () => {\n editable.removeEventListener(\"input\", inputHandler);\n host.innerHTML = \"\";\n },\n getHtml: () => editable.innerHTML,\n setHtml: (html) => {\n editable.innerHTML = html;\n },\n };\n};\n","import type { EditorInstance } from \"../../core/types\";\nimport { mountRichTextEditor } from \"../../rich-text/mountEditor\";\n\nexport interface DomEditorAdapter {\n mount: (target: Element) => void;\n unmount: () => void;\n destroy: () => void;\n}\n\nexport const createDomAdapter = (editor: EditorInstance): DomEditorAdapter => {\n let target: Element | null = null;\n let mountedEditor: ReturnType<typeof mountRichTextEditor> | null = null;\n\n return {\n mount: (nextTarget) => {\n target = nextTarget;\n editor.mount(nextTarget);\n\n if (!(nextTarget instanceof HTMLElement)) {\n return;\n }\n\n mountedEditor = mountRichTextEditor({\n host: nextTarget,\n initialHtml: editor.export(\"html\").payload,\n requestEmbedValue: () => null,\n onChange: (html) => {\n editor.import({\n format: \"html\",\n payload: html,\n });\n },\n });\n },\n unmount: () => {\n if (!target) {\n return;\n }\n\n mountedEditor?.destroy();\n mountedEditor = null;\n\n editor.unmount();\n target = null;\n },\n destroy: () => {\n mountedEditor?.destroy();\n mountedEditor = null;\n\n editor.destroy();\n target = null;\n },\n };\n};\n","import { useEffect, useMemo, useRef } from \"react\";\n\nimport { createEditor } from \"../../core/createEditor\";\nimport type { EditorConfig } from \"../../core/types\";\nimport { mountRichTextEditor } from \"../../rich-text/mountEditor\";\n\nexport const useEditorAdapter = (config: EditorConfig) => {\n const editor = useMemo(() => createEditor(config), [config]);\n\n useEffect(() => () => {\n editor.destroy();\n }, [editor]);\n\n return editor;\n};\n\nexport interface RichEditorAdapterProps extends EditorConfig {\n className?: string;\n disabled?: boolean;\n onRequestEmbedValue?: (type: \"link\" | \"image\" | \"video\" | \"formula\") => Promise<string | null> | string | null;\n}\n\nexport function RichEditorAdapter({ className, disabled = false, initialContent, onChange, onError, onRequestEmbedValue }: RichEditorAdapterProps) {\n const editor = useEditorAdapter({ initialContent, onChange, onError });\n const hostRef = useRef<HTMLDivElement | null>(null);\n\n useEffect(() => {\n const host = hostRef.current;\n\n if (!host) {\n return;\n }\n\n const mounted = mountRichTextEditor({\n host,\n initialHtml: editor.export(\"html\").payload,\n disabled,\n requestEmbedValue: onRequestEmbedValue,\n onChange: (html) => {\n editor.import({\n format: \"html\",\n payload: html,\n });\n },\n });\n\n return () => {\n mounted.destroy();\n };\n }, [disabled, editor, onRequestEmbedValue]);\n\n return (\n <div\n aria-label=\"Rich editor\"\n className={className}\n ref={hostRef}\n />\n );\n}\n"],"mappings":";;;;;AAEA,MAAa,oBACX,MACA,UACA,SACA,cAC8B;CAC9B;CACA;CACA;CACA;AACF;AAEA,MAAa,0BACX,MAC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B,CAAC;CAE1C,OACE,oBAAC,OAAD;EACE,cAAW;EACA;EACX,KAAK;CACN,CAAA;AAEL"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["PMDOMParser","PMDOMParser"],"sources":["../src/core/errors.ts","../src/core/commandDiagnostics.ts","../src/core/formattingCommands.ts","../src/core/commands.ts","../src/core/history.ts","../src/core/schema.ts","../src/transforms/html.ts","../src/transforms/diagnostics.ts","../src/transforms/importFallback.ts","../src/transforms/markdown.ts","../src/transforms/representationSwitch.ts","../src/core/createEditor.ts","../src/core/toolbarModel.ts","../src/rich-text/mountEditor.ts","../src/adapters/dom/createDomAdapter.ts","../src/adapters/react/useEditorAdapter.tsx"],"sourcesContent":["import type { EditorErrorEnvelope, RepresentationDiagnostic } from \"./types\";\n\nexport const createDiagnostic = (\n code: string,\n severity: RepresentationDiagnostic[\"severity\"],\n message: string,\n location?: RepresentationDiagnostic[\"location\"],\n): RepresentationDiagnostic => ({\n code,\n severity,\n message,\n location,\n});\n\nexport const createRecoverableError = (\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): EditorErrorEnvelope => ({\n code,\n message,\n severity: \"warning\",\n recoverable: true,\n details,\n});\n\nexport const createFatalError = (\n code: string,\n message: string,\n details?: Record<string, unknown>,\n): EditorErrorEnvelope => ({\n code,\n message,\n severity: \"error\",\n recoverable: false,\n details,\n});\n","import { createDiagnostic } from \"./errors\";\nimport type { RepresentationDiagnostic } from \"./types\";\n\nexport const createUnknownCommandDiagnostic = (commandName: string): RepresentationDiagnostic =>\n createDiagnostic(\"UNKNOWN_COMMAND\", \"warning\", `Command '${commandName}' is not available in current editor capabilities.`);\n\nexport const createNoHistoryDiagnostic = (type: \"undo\" | \"redo\"): RepresentationDiagnostic =>\n createDiagnostic(\"NO_HISTORY\", \"info\", `No ${type} history entry is available for this editor session.`);\n","import type { EditorCommandHandler } from \"./commands\";\n\nconst withCommandMetadata = (commandName: string): EditorCommandHandler => ({ document }) => ({\n document: {\n ...document,\n revision: document.revision + 1,\n metadata: {\n ...document.metadata,\n lastCommand: commandName,\n },\n },\n});\n\nexport const createFormattingCommandHandlers = (): Record<string, EditorCommandHandler> => ({\n bold: withCommandMetadata(\"bold\"),\n italic: withCommandMetadata(\"italic\"),\n underline: withCommandMetadata(\"underline\"),\n heading: withCommandMetadata(\"heading\"),\n list: withCommandMetadata(\"list\"),\n align: withCommandMetadata(\"align\"),\n link: withCommandMetadata(\"link\"),\n});\n","import { createUnknownCommandDiagnostic } from \"./commandDiagnostics\";\nimport { createFormattingCommandHandlers } from \"./formattingCommands\";\nimport type { EditorDocument, RepresentationDiagnostic } from \"./types\";\n\nexport interface EditorCommandContext {\n document: EditorDocument;\n}\n\nexport interface EditorCommandOutcome {\n document: EditorDocument;\n diagnostics?: RepresentationDiagnostic[];\n}\n\nexport type EditorCommandHandler = (\n context: EditorCommandContext,\n params?: Record<string, unknown>,\n) => EditorCommandOutcome;\n\nexport type EditorCommandRegistry = Map<string, EditorCommandHandler>;\n\nexport const createCommandRegistry = (capabilities?: string[]): EditorCommandRegistry => {\n const allowed = new Set(capabilities && capabilities.length > 0 ? capabilities : [\"bold\", \"italic\", \"underline\", \"heading\", \"list\", \"align\", \"link\", \"undo\", \"redo\"]);\n\n const registry: EditorCommandRegistry = new Map();\n const formattingHandlers = createFormattingCommandHandlers();\n\n const registerIfAllowed = (name: string, handler: EditorCommandHandler) => {\n if (allowed.has(name)) {\n registry.set(name, handler);\n }\n };\n\n Object.entries(formattingHandlers).forEach(([commandName, handler]) => {\n registerIfAllowed(commandName, handler);\n });\n\n return registry;\n};\n\nexport const executeCommand = (\n registry: EditorCommandRegistry,\n commandName: string,\n context: EditorCommandContext,\n params?: Record<string, unknown>,\n): EditorCommandOutcome => {\n const handler = registry.get(commandName);\n\n if (!handler) {\n return {\n document: context.document,\n diagnostics: [createUnknownCommandDiagnostic(commandName)],\n };\n }\n\n return handler(context, params);\n};\n","import type { EditorDocument } from \"./types\";\n\nexport class EditorHistory {\n private readonly undoStack: EditorDocument[] = [];\n\n private readonly redoStack: EditorDocument[] = [];\n\n public record(snapshot: EditorDocument): void {\n this.undoStack.push(snapshot);\n this.redoStack.length = 0;\n }\n\n public undo(current: EditorDocument): EditorDocument {\n const previous = this.undoStack.pop();\n\n if (!previous) {\n return current;\n }\n\n this.redoStack.push(current);\n\n return {\n ...previous,\n revision: current.revision + 1,\n metadata: {\n ...previous.metadata,\n lastCommand: \"undo\",\n },\n };\n }\n\n public redo(current: EditorDocument): EditorDocument {\n const next = this.redoStack.pop();\n\n if (!next) {\n return current;\n }\n\n this.undoStack.push(current);\n\n return {\n ...next,\n revision: current.revision + 1,\n metadata: {\n ...next.metadata,\n lastCommand: \"redo\",\n },\n };\n }\n}\n","import { Schema } from \"prosemirror-model\";\n\nconst allowedStyleProperties = new Set([\"font-family\", \"font-size\", \"text-align\", \"margin-left\"]);\n\nconst normalizeStyleValue = (property: string, value: string): string | null => {\n const next = value.trim().toLowerCase();\n\n if (property === \"font-family\") {\n return next === \"serif\" || next === \"monospace\" ? next : null;\n }\n\n if (property === \"font-size\") {\n return [\"12px\", \"16px\", \"20px\", \"28px\"].includes(next) ? next : null;\n }\n\n if (property === \"text-align\") {\n return [\"left\", \"center\", \"right\", \"justify\"].includes(next) ? next : null;\n }\n\n if (property === \"margin-left\") {\n const match = /^([0-9]{1,3})px$/.exec(next);\n if (!match) return null;\n const amount = Number.parseInt(match[1], 10);\n return amount >= 0 && amount % 24 === 0 ? `${amount}px` : null;\n }\n\n return null;\n};\n\nexport const normalizeStyleAttribute = (styleValue: string): string | null => {\n if (!styleValue) return null;\n const entries = styleValue\n .split(\";\")\n .map((entry) => entry.trim())\n .filter((entry) => entry.length > 0)\n .map((entry) => {\n const separator = entry.indexOf(\":\");\n if (separator < 0) return null;\n const property = entry.slice(0, separator).trim().toLowerCase();\n const value = entry.slice(separator + 1).trim();\n\n if (!allowedStyleProperties.has(property)) return null;\n const normalized = normalizeStyleValue(property, value);\n if (!normalized) return null;\n return `${property}:${normalized}`;\n })\n .filter((entry): entry is string => Boolean(entry));\n\n if (entries.length === 0) return null;\n return entries.join(\";\");\n};\n\nexport const editorNodeNames = {\n doc: \"doc\",\n paragraph: \"paragraph\",\n heading: \"heading\",\n text: \"text\",\n bulletList: \"bullet_list\",\n orderedList: \"ordered_list\",\n listItem: \"list_item\",\n hardBreak: \"hard_break\",\n blockquote: \"blockquote\",\n codeBlock: \"code_block\",\n image: \"image\",\n video: \"video\",\n} as const;\n\nexport const editorMarkNames = {\n strong: \"strong\",\n em: \"em\",\n underline: \"underline\",\n link: \"link\",\n strike: \"strike\",\n code: \"code\",\n style: \"style\",\n formula: \"formula\",\n} as const;\n\nexport const createEditorSchema = () =>\n new Schema({\n nodes: {\n doc: { content: \"block+\" },\n paragraph: {\n content: \"inline*\",\n group: \"block\",\n attrs: {\n style: { default: null },\n dir: { default: null },\n },\n parseDOM: [\n {\n tag: \"p\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n return {\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n ],\n toDOM: (node) => {\n const attrs: Record<string, string> = {};\n if (node.attrs.style) attrs.style = node.attrs.style;\n if (node.attrs.dir) attrs.dir = node.attrs.dir;\n return [\"p\", attrs, 0];\n },\n },\n heading: {\n attrs: {\n level: { default: 1 },\n style: { default: null },\n dir: { default: null },\n },\n content: \"inline*\",\n group: \"block\",\n defining: true,\n parseDOM: [\n {\n tag: \"h1\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return { level: 1 };\n return {\n level: 1,\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n {\n tag: \"h2\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return { level: 2 };\n return {\n level: 2,\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n {\n tag: \"h3\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return { level: 3 };\n return {\n level: 3,\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n ],\n toDOM: (node) => {\n const attrs: Record<string, string> = {};\n if (node.attrs.style) attrs.style = node.attrs.style;\n if (node.attrs.dir) attrs.dir = node.attrs.dir;\n const tag = `h${Math.max(1, Math.min(3, Number(node.attrs.level) || 1))}`;\n return [tag, attrs, 0];\n },\n },\n blockquote: {\n content: \"block+\",\n group: \"block\",\n attrs: {\n style: { default: null },\n dir: { default: null },\n },\n parseDOM: [\n {\n tag: \"blockquote\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n return {\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n ],\n toDOM: (node) => {\n const attrs: Record<string, string> = {};\n if (node.attrs.style) attrs.style = node.attrs.style;\n if (node.attrs.dir) attrs.dir = node.attrs.dir;\n return [\"blockquote\", attrs, 0];\n },\n },\n code_block: {\n content: \"inline*\",\n group: \"block\",\n code: true,\n defining: true,\n attrs: {\n style: { default: null },\n dir: { default: null },\n },\n parseDOM: [\n {\n tag: \"pre\",\n preserveWhitespace: \"full\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n return {\n style: normalizeStyleAttribute(dom.getAttribute(\"style\") || \"\"),\n dir: dom.getAttribute(\"dir\") || null,\n };\n },\n },\n ],\n toDOM: (node) => {\n const attrs: Record<string, string> = {};\n if (node.attrs.style) attrs.style = node.attrs.style;\n if (node.attrs.dir) attrs.dir = node.attrs.dir;\n return [\"pre\", attrs, [\"code\", 0]];\n },\n },\n bullet_list: {\n content: \"list_item+\",\n group: \"block\",\n parseDOM: [{ tag: \"ul\" }],\n toDOM: () => [\"ul\", 0],\n },\n ordered_list: {\n attrs: { order: { default: 1 } },\n content: \"list_item+\",\n group: \"block\",\n parseDOM: [\n {\n tag: \"ol\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLOListElement)) {\n return { order: 1 };\n }\n return { order: dom.start || 1 };\n },\n },\n ],\n toDOM: (node) => [\"ol\", { start: node.attrs.order || 1 }, 0],\n },\n list_item: {\n content: \"paragraph block*\",\n parseDOM: [{ tag: \"li\" }],\n toDOM: () => [\"li\", 0],\n },\n image: {\n inline: true,\n attrs: {\n src: {},\n alt: { default: null },\n },\n group: \"inline\",\n draggable: true,\n parseDOM: [\n {\n tag: \"img[src]\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n return {\n src: dom.getAttribute(\"src\"),\n alt: dom.getAttribute(\"alt\"),\n };\n },\n },\n ],\n toDOM: (node) => [\"img\", { src: node.attrs.src, alt: node.attrs.alt }],\n },\n video: {\n inline: true,\n attrs: {\n src: {},\n controls: { default: \"true\" },\n },\n group: \"inline\",\n parseDOM: [\n {\n tag: \"video[src]\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n return {\n src: dom.getAttribute(\"src\"),\n controls: dom.getAttribute(\"controls\") || \"true\",\n };\n },\n },\n ],\n toDOM: (node) => [\"video\", { src: node.attrs.src, controls: node.attrs.controls }],\n },\n text: { group: \"inline\" },\n hard_break: {\n inline: true,\n group: \"inline\",\n selectable: false,\n parseDOM: [{ tag: \"br\" }],\n toDOM: () => [\"br\"],\n },\n },\n marks: {\n strong: {\n parseDOM: [{ tag: \"strong\" }, { tag: \"b\", getAttrs: () => null }],\n toDOM: () => [\"strong\", 0],\n },\n em: {\n parseDOM: [{ tag: \"em\" }, { tag: \"i\", getAttrs: () => null }],\n toDOM: () => [\"em\", 0],\n },\n underline: {\n parseDOM: [{ tag: \"u\" }],\n toDOM: () => [\"u\", 0],\n },\n strike: {\n parseDOM: [{ tag: \"s\" }, { tag: \"del\" }, { tag: \"strike\" }],\n toDOM: () => [\"s\", 0],\n },\n code: {\n parseDOM: [{ tag: \"code\" }],\n toDOM: () => [\"code\", 0],\n },\n style: {\n attrs: { style: { default: null } },\n parseDOM: [\n {\n tag: \"span[style]\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) return null;\n const style = dom.getAttribute(\"style\") || \"\";\n const normalized = normalizeStyleAttribute(style);\n return normalized ? { style: normalized } : false;\n },\n },\n ],\n toDOM: (node) => [\"span\", { style: node.attrs.style }, 0],\n },\n link: {\n attrs: {\n href: { default: null },\n title: { default: null },\n style: { default: null },\n },\n inclusive: false,\n parseDOM: [\n {\n tag: \"a\",\n getAttrs: (dom) => {\n if (!(dom instanceof HTMLElement)) {\n return false;\n }\n const href = dom.getAttribute(\"href\");\n const style = dom.getAttribute(\"style\");\n if (!href && !style) {\n return false;\n }\n return {\n href: href || null,\n title: dom.getAttribute(\"title\") || null,\n style: normalizeStyleAttribute(style || \"\"),\n };\n },\n },\n ],\n toDOM: (node) => {\n const attrs: Record<string, string> = {};\n if (node.attrs.href) attrs.href = node.attrs.href;\n if (node.attrs.title) attrs.title = node.attrs.title;\n if (node.attrs.style) attrs.style = node.attrs.style;\n return [\"a\", attrs, 0];\n },\n },\n formula: {\n parseDOM: [{ tag: \"span[data-formula]\" }],\n toDOM: () => [\"span\", { \"data-formula\": \"true\" }, 0],\n },\n },\n });\n\nexport const editorSchema = createEditorSchema();\n","import DOMPurify from \"isomorphic-dompurify\";\nimport { DOMParser as PMDOMParser, DOMSerializer } from \"prosemirror-model\";\n\nimport { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\nimport { editorSchema } from \"../core/schema\";\n\nexport interface HtmlImportResult {\n richText: string;\n sanitizedHtml: string;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const sanitizeHtml = (payload: string): string =>\n DOMPurify.sanitize(payload, {\n ALLOWED_TAGS: [\n \"p\",\n \"br\",\n \"b\",\n \"i\",\n \"strike\",\n \"strong\",\n \"em\",\n \"u\",\n \"s\",\n \"code\",\n \"pre\",\n \"blockquote\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"ul\",\n \"ol\",\n \"li\",\n \"a\",\n \"img\",\n \"video\",\n \"span\",\n \"sub\",\n \"sup\",\n \"div\",\n ],\n ALLOWED_ATTR: [\"href\", \"src\", \"alt\", \"target\", \"rel\", \"style\", \"data-formula\", \"controls\", \"dir\"],\n FORBID_TAGS: [\"script\", \"style\", \"iframe\", \"object\", \"embed\", \"form\", \"input\", \"button\", \"textarea\", \"select\"],\n });\n\nexport const normalizeHtml = (value: string): string => {\n if (typeof globalThis.DOMParser === \"undefined\") {\n return value.trim().length > 0 ? value : \"<p></p>\";\n }\n\n const parser = new globalThis.DOMParser();\n const domDoc = parser.parseFromString(`<body>${value}</body>`, \"text/html\");\n const pmNode = PMDOMParser.fromSchema(editorSchema).parse(domDoc.body);\n const fragment = DOMSerializer.fromSchema(editorSchema).serializeFragment(pmNode.content);\n const container = document.createElement(\"div\");\n container.appendChild(fragment);\n const normalized = container.innerHTML.trim();\n return normalized.length > 0 ? normalized : \"<p></p>\";\n};\n\nexport const importHtml = (payload: string): HtmlImportResult => {\n const diagnostics: RepresentationDiagnostic[] = [];\n const sanitized = sanitizeHtml(payload);\n const normalized = normalizeHtml(sanitized);\n\n if (normalized !== payload) {\n diagnostics.push(\n createDiagnostic(\n \"SANITIZED_CONTENT\",\n \"warning\",\n \"Input HTML was sanitized to remove unsupported or unsafe markup.\",\n ),\n );\n }\n\n if (normalized.trim().length === 0) {\n diagnostics.push(createDiagnostic(\"EMPTY_HTML\", \"info\", \"The provided HTML content is empty after normalization.\"));\n }\n\n return {\n richText: normalized,\n sanitizedHtml: normalized,\n diagnostics,\n };\n};\n\nexport const exportHtml = (richText: string): string => {\n return normalizeHtml(richText);\n};\n","import { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\n\nexport const createUnsupportedMarkupDiagnostic = (details?: string): RepresentationDiagnostic =>\n createDiagnostic(\n \"UNSUPPORTED_MARKUP\",\n \"warning\",\n details ?? \"Some markup could not be fully represented and was normalized.\",\n );\n\nexport const createRecoverableParseDiagnostic = (format: \"markdown\" | \"html\", details?: string): RepresentationDiagnostic =>\n createDiagnostic(\n \"RECOVERABLE_PARSE\",\n \"warning\",\n details ?? `Some ${format.toUpperCase()} content was partially recovered during import.`,\n );\n","import type { EditorDocument, EditorInput, RepresentationDiagnostic } from \"../core/types\";\n\nimport { createRecoverableParseDiagnostic, createUnsupportedMarkupDiagnostic } from \"./diagnostics\";\n\nexport const applyImportFallback = (\n input: EditorInput,\n base: EditorDocument,\n): { document: EditorDocument; diagnostics: RepresentationDiagnostic[] } => {\n const payload = input.payload.trim();\n const diagnostics: RepresentationDiagnostic[] = [\n createRecoverableParseDiagnostic(input.format === \"html\" ? \"html\" : \"markdown\"),\n ];\n\n const stripped = input.format === \"html\" ? payload.replace(/<[^>]*>/g, \" \").replace(/\\s+/g, \" \").trim() : payload;\n\n if (stripped.length === 0) {\n diagnostics.push(createUnsupportedMarkupDiagnostic(\"Input produced no recoverable text content after normalization.\"));\n }\n\n return {\n document: {\n ...base,\n content: {\n richText: stripped,\n html: input.format === \"html\" ? payload : base.content.html,\n },\n metadata: {\n ...base.metadata,\n importFallback: true,\n },\n },\n diagnostics,\n };\n};\n","import { DOMParser as PMDOMParser } from \"prosemirror-model\";\nimport { editorSchema } from \"../core/schema\";\nimport type { Node as PMNode } from \"prosemirror-model\";\nimport { createDiagnostic } from \"../core/errors\";\nimport type { RepresentationDiagnostic } from \"../core/types\";\n\nconst normalizeMarkdown = (value: string) => value.replace(/\\r\\n?/g, \"\\n\");\n\nconst escapeHtml = (text: string): string => {\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n};\n\nconst parseInline = (text: string): string => {\n let html = escapeHtml(text);\n\n // Bold (** or __)\n html = html.replace(/\\*\\*(.*?)\\*\\*/g, \"<strong>$1</strong>\");\n html = html.replace(/__(.*?)__/g, \"<strong>$1</strong>\");\n\n // Italic (* or _)\n html = html.replace(/\\*(.*?)\\*/g, \"<em>$1</em>\");\n html = html.replace(/_(.*?)_/g, \"<em>$1</em>\");\n\n // Strike (~~)\n html = html.replace(/~~(.*?)~~/g, \"<s>$1</s>\");\n\n // Code (inline)\n html = html.replace(/`(.*?)`/g, \"<code>$1</code>\");\n\n // Links: [text](url)\n html = html.replace(/\\[(.*?)\\]\\((.*?)\\)/g, '<a href=\"$2\">$1</a>');\n\n return html;\n};\n\nexport const markdownToHtml = (markdown: string): string => {\n const lines = normalizeMarkdown(markdown).split(\"\\n\");\n const blocks: string[] = [];\n let currentBlockType: \"paragraph\" | \"blockquote\" | \"code_block\" | \"ul\" | \"ol\" | null = null;\n let blockLines: string[] = [];\n\n const closeCurrentBlock = () => {\n if (!currentBlockType) return;\n\n if (currentBlockType === \"paragraph\") {\n const content = parseInline(blockLines.join(\"\\n\"));\n blocks.push(`<p>${content}</p>`);\n } else if (currentBlockType === \"blockquote\") {\n const content = markdownToHtml(blockLines.join(\"\\n\"));\n blocks.push(`<blockquote>${content}</blockquote>`);\n } else if (currentBlockType === \"code_block\") {\n const content = escapeHtml(blockLines.join(\"\\n\"));\n blocks.push(`<pre><code>${content}</code></pre>`);\n } else if (currentBlockType === \"ul\" || currentBlockType === \"ol\") {\n const tag = currentBlockType;\n const itemBlocks: string[] = [];\n let currentItemLines: string[] = [];\n\n const closeItem = () => {\n if (currentItemLines.length > 0) {\n const innerHtml = markdownToHtml(currentItemLines.join(\"\\n\"));\n itemBlocks.push(`<li>${innerHtml}</li>`);\n currentItemLines = [];\n }\n };\n\n for (const line of blockLines) {\n const ulMatch = /^[*-+]\\s+(.*)$/.exec(line.trim());\n const olMatch = /^\\d+\\.\\s+(.*)$/.exec(line.trim());\n if (ulMatch) {\n closeItem();\n currentItemLines.push(ulMatch[1]);\n } else if (olMatch) {\n closeItem();\n currentItemLines.push(olMatch[1]);\n } else {\n currentItemLines.push(line.trimStart());\n }\n }\n closeItem();\n blocks.push(`<${tag}>${itemBlocks.join(\"\")}</${tag}>`);\n }\n\n blockLines = [];\n currentBlockType = null;\n };\n\n let i = 0;\n while (i < lines.length) {\n const line = lines[i];\n\n if (line.startsWith(\"```\")) {\n if (currentBlockType === \"code_block\") {\n closeCurrentBlock();\n } else {\n closeCurrentBlock();\n currentBlockType = \"code_block\";\n }\n i++;\n continue;\n }\n\n if (currentBlockType === \"code_block\") {\n blockLines.push(line);\n i++;\n continue;\n }\n\n const trimmed = line.trim();\n\n if (trimmed === \"\") {\n closeCurrentBlock();\n i++;\n continue;\n }\n\n const headerMatch = /^(#{1,6})\\s+(.*)$/.exec(trimmed);\n if (headerMatch) {\n closeCurrentBlock();\n const level = headerMatch[1].length;\n const content = parseInline(headerMatch[2]);\n blocks.push(`<h${level}>${content}</h${level}>`);\n i++;\n continue;\n }\n\n if (trimmed.startsWith(\">\")) {\n if (currentBlockType !== \"blockquote\") {\n closeCurrentBlock();\n currentBlockType = \"blockquote\";\n }\n const rest = line.startsWith(\"> \") ? line.slice(2) : line.slice(1);\n blockLines.push(rest);\n i++;\n continue;\n }\n\n const ulMatch = /^[*-+]\\s+(.*)$/.exec(trimmed);\n if (ulMatch) {\n if (currentBlockType !== \"ul\") {\n closeCurrentBlock();\n currentBlockType = \"ul\";\n }\n blockLines.push(line);\n i++;\n continue;\n }\n\n const olMatch = /^\\d+\\.\\s+(.*)$/.exec(trimmed);\n if (olMatch) {\n if (currentBlockType !== \"ol\") {\n closeCurrentBlock();\n currentBlockType = \"ol\";\n }\n blockLines.push(line);\n i++;\n continue;\n }\n\n if (!currentBlockType) {\n currentBlockType = \"paragraph\";\n }\n blockLines.push(line);\n i++;\n }\n\n closeCurrentBlock();\n\n return blocks.join(\"\");\n};\n\nconst serializeChild = (child: PMNode, index: number, parent: PMNode): string => {\n if (child.isText) {\n let text = child.text || \"\";\n child.marks.forEach((mark) => {\n if (mark.type.name === \"strong\") {\n text = `**${text}**`;\n } else if (mark.type.name === \"em\") {\n text = `*${text}*`;\n } else if (mark.type.name === \"strike\") {\n text = `~~${text}~~`;\n } else if (mark.type.name === \"code\") {\n text = `\\`${text}\\``;\n } else if (mark.type.name === \"link\") {\n const href = mark.attrs.href || \"\";\n text = `[${text}](${href})`;\n }\n });\n return text;\n }\n\n if (child.type.name === \"hard_break\") {\n return \"\\n\";\n }\n\n if (child.type.name === \"image\") {\n const src = child.attrs.src || \"\";\n const alt = child.attrs.alt || \"\";\n return ``;\n }\n\n if (child.type.name === \"video\") {\n const src = child.attrs.src || \"\";\n return `[Video: ${src}]`;\n }\n\n let inner = \"\";\n child.forEach((c, idx) => {\n inner += serializeChild(c, idx, child);\n });\n\n if (child.type.name === \"paragraph\") {\n return `${inner}\\n\\n`;\n }\n\n if (child.type.name === \"heading\") {\n const hashes = \"#\".repeat(child.attrs.level || 1);\n return `${hashes} ${inner}\\n\\n`;\n }\n\n if (child.type.name === \"blockquote\") {\n const lines = inner.trim().split(\"\\n\");\n const quoted = lines.map((line) => `> ${line}`).join(\"\\n\");\n return `${quoted}\\n\\n`;\n }\n\n if (child.type.name === \"code_block\") {\n return `\\`\\`\\`\\n${inner.trim()}\\n\\`\\`\\`\\n\\n`;\n }\n\n if (child.type.name === \"bullet_list\") {\n let listResult = \"\";\n child.forEach((item) => {\n const itemContent = serializeNode(item).trim();\n const indented = itemContent.split(\"\\n\").map((line, idx) => {\n if (idx === 0) return `* ${line}`;\n return ` ${line}`;\n }).join(\"\\n\");\n listResult += `${indented}\\n`;\n });\n return `${listResult}\\n`;\n }\n\n if (child.type.name === \"ordered_list\") {\n let listResult = \"\";\n let count = child.attrs.order || 1;\n child.forEach((item) => {\n const itemContent = serializeNode(item).trim();\n const indented = itemContent.split(\"\\n\").map((line, idx) => {\n if (idx === 0) return `${count}. ${line}`;\n return ` ${line}`;\n }).join(\"\\n\");\n listResult += `${indented}\\n`;\n count++;\n });\n return `${listResult}\\n`;\n }\n\n if (child.type.name === \"list_item\") {\n let itemInner = \"\";\n child.forEach((c, idx) => {\n itemInner += serializeChild(c, idx, child);\n });\n return itemInner;\n }\n\n return inner;\n};\n\nconst serializeNode = (node: PMNode): string => {\n let result = \"\";\n node.forEach((child, index) => {\n result += serializeChild(child, index, node);\n });\n return result.trim();\n};\n\nexport interface MarkdownImportResult {\n richText: string;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const importMarkdown = (payload: string): MarkdownImportResult => {\n const diagnostics: RepresentationDiagnostic[] = [];\n const normalized = normalizeMarkdown(payload);\n\n if (normalized.trim().length === 0) {\n diagnostics.push(createDiagnostic(\"EMPTY_MARKDOWN\", \"info\", \"The provided markdown content is empty.\"));\n }\n\n const html = markdownToHtml(normalized);\n\n return {\n richText: html,\n diagnostics,\n };\n};\n\nexport const exportMarkdown = (richText: string): string => {\n if (typeof globalThis.DOMParser === \"undefined\") {\n return richText;\n }\n const parser = new globalThis.DOMParser();\n const domDoc = parser.parseFromString(`<body>${richText}</body>`, \"text/html\");\n const pmNode = PMDOMParser.fromSchema(editorSchema).parse(domDoc.body);\n return serializeNode(pmNode);\n};\n","import type { ContentFormat, EditorDocument, EditorExport, EditorInput, RepresentationDiagnostic } from \"../core/types\";\n\nimport { exportHtml, importHtml, normalizeHtml } from \"./html\";\nimport { applyImportFallback } from \"./importFallback\";\nimport { exportMarkdown, importMarkdown } from \"./markdown\";\n\nexport interface ImportResult {\n document: EditorDocument;\n diagnostics: RepresentationDiagnostic[];\n}\n\nexport const importRepresentation = (input: EditorInput, base: EditorDocument): ImportResult => {\n if (input.format === \"rich\") {\n const normalizedHtml = normalizeHtml(input.payload);\n\n return {\n document: {\n ...base,\n content: {\n richText: normalizedHtml,\n html: normalizedHtml,\n },\n },\n diagnostics: [],\n };\n }\n\n if (input.format === \"markdown\") {\n try {\n const result = importMarkdown(input.payload);\n\n return {\n document: {\n ...base,\n content: {\n richText: result.richText,\n html: result.richText,\n },\n metadata: {\n ...base.metadata,\n importedFrom: \"markdown\",\n },\n },\n diagnostics: result.diagnostics,\n };\n } catch {\n return applyImportFallback(input, base);\n }\n }\n\n try {\n const result = importHtml(input.payload);\n\n return {\n document: {\n ...base,\n content: {\n richText: result.richText,\n html: result.sanitizedHtml,\n },\n metadata: {\n ...base.metadata,\n importedFrom: \"html\",\n },\n },\n diagnostics: result.diagnostics,\n };\n } catch {\n return applyImportFallback(input, base);\n }\n};\n\nexport const exportRepresentation = (document: EditorDocument, format: ContentFormat): EditorExport => {\n if (format === \"rich\") {\n return {\n format,\n payload: document.content.richText,\n diagnostics: [],\n };\n }\n\n if (format === \"markdown\") {\n return {\n format,\n payload: exportMarkdown(document.content.richText),\n diagnostics: [],\n };\n }\n\n const htmlPayload = document.content.html\n ? normalizeHtml(document.content.html)\n : normalizeHtml(exportHtml(document.content.richText));\n\n return {\n format,\n payload: htmlPayload,\n diagnostics: [],\n };\n};\n","import { createCommandRegistry, executeCommand } from \"./commands\";\nimport { createNoHistoryDiagnostic, createUnknownCommandDiagnostic } from \"./commandDiagnostics\";\nimport { createRecoverableError } from \"./errors\";\nimport { EditorHistory } from \"./history\";\nimport type { CommandResult, ContentFormat, EditorConfig, EditorDocument, EditorExport, EditorInput, EditorInstance, RepresentationDiagnostic } from \"./types\";\nimport { exportRepresentation, importRepresentation } from \"../transforms/representationSwitch\";\n\nconst createDefaultDocument = (): EditorDocument => ({\n id: crypto.randomUUID(),\n content: {\n richText: \"\",\n },\n metadata: {},\n revision: 0,\n});\n\nconst fromInput = (input: EditorInput, base: EditorDocument): { document: EditorDocument; diagnostics: RepresentationDiagnostic[] } =>\n importRepresentation(input, base);\n\nconst toExport = (document: EditorDocument, format: ContentFormat): EditorExport =>\n exportRepresentation(document, format);\n\nexport const createEditor = (config: EditorConfig = {}): EditorInstance => {\n const registry = createCommandRegistry(config.commandCapabilities);\n const history = new EditorHistory();\n let mountedTarget: Element | null = null;\n let isDestroyed = false;\n let currentDocument = createDefaultDocument();\n\n const listeners = {\n change: new Set<() => void>(),\n selectionchange: new Set<() => void>(),\n };\n\n let activeHandler: {\n isMarkActive: (name: string) => boolean;\n getActiveBlockType: () => string;\n } | null = null;\n\n if (config.initialContent) {\n const initialized = fromInput(config.initialContent, currentDocument);\n currentDocument = initialized.document;\n\n if (initialized.diagnostics.length > 0) {\n config.onError?.(\n createRecoverableError(\"INITIAL_CONTENT_DIAGNOSTIC\", \"Initial content was normalized during editor initialization.\", {\n diagnostics: initialized.diagnostics,\n }),\n );\n }\n }\n\n const ensureActive = (): boolean => {\n if (!isDestroyed) {\n return true;\n }\n\n config.onError?.(createRecoverableError(\"EDITOR_DESTROYED\", \"This editor instance has already been destroyed.\"));\n return false;\n };\n\n const emitChange = () => {\n config.onChange?.(currentDocument);\n listeners.change.forEach((cb) => cb());\n };\n\n return {\n getDocument: () => currentDocument,\n\n execute: (commandName, params) => {\n if (!ensureActive()) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n const allowed = config.commandCapabilities\n ? new Set(config.commandCapabilities)\n : new Set([\"bold\", \"italic\", \"underline\", \"heading\", \"list\", \"align\", \"link\", \"undo\", \"redo\"]);\n\n if (!allowed.has(commandName)) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [createUnknownCommandDiagnostic(commandName)],\n };\n }\n\n const result = executeCommand(registry, commandName, { document: currentDocument }, params);\n\n if (commandName === \"undo\") {\n const next = history.undo(currentDocument);\n\n if (next === currentDocument) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [createNoHistoryDiagnostic(\"undo\")],\n };\n }\n\n currentDocument = next;\n emitChange();\n\n return {\n ok: true,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n if (commandName === \"redo\") {\n const next = history.redo(currentDocument);\n\n if (next === currentDocument) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [createNoHistoryDiagnostic(\"redo\")],\n };\n }\n\n currentDocument = next;\n emitChange();\n\n return {\n ok: true,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n history.record(currentDocument);\n currentDocument = result.document;\n emitChange();\n\n return {\n ok: (result.diagnostics?.length ?? 0) === 0,\n document: currentDocument,\n diagnostics: result.diagnostics ?? [],\n };\n },\n\n export: (format) => toExport(currentDocument, format),\n\n import: (input) => {\n if (!ensureActive()) {\n return {\n ok: false,\n document: currentDocument,\n diagnostics: [],\n };\n }\n\n const result = fromInput(input, {\n ...currentDocument,\n revision: currentDocument.revision + 1,\n });\n\n currentDocument = result.document;\n emitChange();\n\n return {\n ok: result.diagnostics.length === 0,\n document: currentDocument,\n diagnostics: result.diagnostics,\n };\n },\n\n mount: (target) => {\n if (!ensureActive()) {\n return;\n }\n\n mountedTarget = target;\n },\n\n unmount: () => {\n mountedTarget = null;\n },\n\n destroy: () => {\n mountedTarget = null;\n isDestroyed = true;\n listeners.change.clear();\n listeners.selectionchange.clear();\n },\n\n isMarkActive: (name) => activeHandler?.isMarkActive(name) ?? false,\n\n getActiveBlockType: () => activeHandler?.getActiveBlockType() ?? \"paragraph\",\n\n on: (event, callback) => {\n listeners[event].add(callback);\n return () => {\n listeners[event].delete(callback);\n };\n },\n\n toolbar: config.toolbar,\n placeholder: config.placeholder,\n\n _registerActiveHandler: (handler) => {\n activeHandler = handler;\n },\n\n _triggerSelectionChange: () => {\n listeners.selectionchange.forEach((cb) => cb());\n },\n };\n};\n","export interface ToolbarAction {\n command: string;\n label: string;\n group: \"inline\" | \"block\" | \"history\";\n}\n\nexport const defaultToolbarActions: ToolbarAction[] = [\n { command: \"bold\", label: \"Bold\", group: \"inline\" },\n { command: \"italic\", label: \"Italic\", group: \"inline\" },\n { command: \"underline\", label: \"Underline\", group: \"inline\" },\n { command: \"heading\", label: \"Heading\", group: \"block\" },\n { command: \"list\", label: \"List\", group: \"block\" },\n { command: \"align\", label: \"Align\", group: \"block\" },\n { command: \"link\", label: \"Link\", group: \"inline\" },\n { command: \"undo\", label: \"Undo\", group: \"history\" },\n { command: \"redo\", label: \"Redo\", group: \"history\" },\n];\n","type EmbedType = \"link\" | \"image\" | \"video\" | \"formula\";\n\ntype MountRichTextEditorOptions = {\n host: HTMLElement;\n initialHtml: string;\n disabled?: boolean;\n onChange: (html: string) => void;\n requestEmbedValue?: (type: EmbedType) => Promise<string | null> | string | null;\n toolbar?: boolean | string[];\n placeholder?: string;\n onSelectionChange?: () => void;\n};\n\ntype MountedRichTextEditor = {\n destroy: () => void;\n getHtml: () => string;\n setHtml: (html: string) => void;\n isMarkActive: (name: string) => boolean;\n getActiveBlockType: () => string;\n};\n\nconst commandLabels: Record<string, string> = {\n bold: \"Bold\",\n italic: \"Italic\",\n underline: \"Underline\",\n strike: \"Strike\",\n code: \"Inline code\",\n blockquote: \"Blockquote\",\n \"code-block\": \"Code block\",\n \"indent-\": \"Outdent\",\n \"indent+\": \"Indent\",\n link: \"Link\",\n image: \"Image\",\n video: \"Video\",\n formula: \"Formula\",\n clean: \"Remove formatting\",\n};\n\nconst commandIconSvg: Record<string, string> = {\n bold: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M4 2.5h4.5a2.5 2.5 0 010 5H4z\"/><path d=\"M4 7.5h5a3 3 0 010 6H4z\"/></svg>',\n italic: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"><path d=\"M9.8 2.5H5.5\"/><path d=\"M10.5 13.5H6.2\"/><path d=\"M9.3 2.5 6.7 13.5\"/></svg>',\n underline: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M4 2.5v4.2a4 4 0 008 0V2.5\"/><path d=\"M3 13.5h10\"/></svg>',\n strike: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M4 4.5c.8-1.2 2-1.9 3.7-1.9 2 0 3.3 1 3.3 2.5 0 3-6.5 1.8-6.5 4.6 0 1.5 1.3 2.3 3.4 2.3 1.6 0 2.9-.6 3.8-1.7\"/><path d=\"M2.5 8h11\"/></svg>',\n code: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M6 4 2.5 8 6 12\"/><path d=\"M10 4 13.5 8 10 12\"/><path d=\"M8.7 2.8 7.3 13.2\"/></svg>',\n blockquote: '<svg viewBox=\"0 0 16 16\" fill=\"currentColor\"><path d=\"M3 3h4v4H4.8c.1 1.8-.7 3.2-1.8 4L2 10c1-.7 1.5-1.7 1.4-3H3zM9 3h4v4h-2.2c.1 1.8-.7 3.2-1.8 4L8 10c1-.7 1.5-1.7 1.4-3H9z\"/></svg>',\n \"code-block\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.5\" y=\"2.5\" width=\"11\" height=\"11\" rx=\"1.8\"/><path d=\"M6.2 6 4.5 8l1.7 2\"/><path d=\"M9.8 6 11.5 8l-1.7 2\"/><path d=\"M8.6 5.5 7.4 10.5\"/></svg>',\n \"indent-\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M9 4h4\"/><path d=\"M9 8h4\"/><path d=\"M9 12h4\"/><path d=\"M7 5.5 4 8l3 2.5\"/></svg>',\n \"indent+\": '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4h4\"/><path d=\"M3 8h4\"/><path d=\"M3 12h4\"/><path d=\"M9 5.5 12 8l-3 2.5\"/></svg>',\n link: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\"><path d=\"M6.3 9.7 4.9 11a2.4 2.4 0 103.4 3.4l1.5-1.4\"/><path d=\"M9.7 6.3 11 4.9a2.4 2.4 0 10-3.4-3.4L6.1 2.9\"/><path d=\"M5.9 10.1 10.1 5.9\"/></svg>',\n image: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.3\" y=\"2.5\" width=\"11.4\" height=\"11\" rx=\"1.8\"/><circle cx=\"6\" cy=\"6\" r=\"1.2\" fill=\"currentColor\" stroke=\"none\"/><path d=\"m3.8 11 2.8-2.8 2.2 2.2 1.6-1.6 1.8 2.2\"/></svg>',\n video: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><rect x=\"2.2\" y=\"3\" width=\"8.8\" height=\"10\" rx=\"1.6\"/><path d=\"M11 6.2 13.8 4.8v6.4L11 9.8z\"/><path d=\"M6.2 6.4v3.2l2.7-1.6z\" fill=\"currentColor\" stroke=\"none\"/></svg>',\n formula: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M3 4h5\"/><path d=\"M3 12h5\"/><path d=\"M8 4 5 8l3 4\"/><path d=\"M10.3 5.8v4.4\"/><path d=\"M12.5 8h-4.4\"/></svg>',\n clean: '<svg viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.6\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M2.8 12.5h6.8\"/><path d=\"m4.2 3.3 6 6\"/><path d=\"m10.2 2.7 3 3-2 2-3-3z\"/><path d=\"M6.2 11.2 4.1 13.3\"/></svg>',\n};\n\nconst createToolbarIcon = (command: string, fallback: string): HTMLElement => {\n const icon = document.createElement(\"span\");\n icon.className = \"az-rich-editor-toolbar-icon\";\n\n const svgMarkup = commandIconSvg[command];\n if (svgMarkup) {\n icon.innerHTML = svgMarkup;\n } else {\n icon.textContent = fallback;\n }\n\n return icon;\n};\n\nconst selectOptionLabels: Record<string, Record<string, string>> = {\n font: {\n default: \"Font\",\n serif: \"Serif\",\n monospace: \"Monospace\",\n },\n size: {\n normal: \"Normal (16px)\",\n small: \"Small (12px)\",\n large: \"Large (20px)\",\n huge: \"Huge (28px)\",\n },\n header: {\n normal: \"Normal Text\",\n h1: \"Heading 1\",\n h2: \"Heading 2\",\n },\n script: {\n normal: \"Script\",\n sub: \"Subscript\",\n super: \"Superscript\",\n },\n align: {\n left: \"Align Left\",\n center: \"Align Center\",\n right: \"Align Right\",\n justify: \"Justify\",\n },\n list: {\n none: \"No List\",\n ordered: \"Numbered List\",\n bullet: \"Bulleted List\",\n },\n direction: {\n ltr: \"Left-to-Right\",\n rtl: \"Right-to-Left\",\n },\n};\n\nconst safeUrl = (value: string): string | null => {\n const trimmed = value.trim();\n\n if (!trimmed) {\n return null;\n }\n\n if (/^(https?:|mailto:|tel:)/i.test(trimmed)) {\n return trimmed;\n }\n\n return null;\n};\n\nconst escapeHtml = (value: string): string =>\n value.replace(/&/g, \"&\").replace(/</g, \"<\").replace(/>/g, \">\").replace(/\\\"/g, \""\");\n\nconst closestElement = (node: Node | null, root: HTMLElement): HTMLElement | null => {\n let current: Node | null = node;\n\n while (current && current !== root) {\n if (current instanceof HTMLElement) {\n return current;\n }\n\n current = current.parentNode;\n }\n\n return null;\n};\n\nconst closestByTag = (node: Node | null, tagName: string, root: HTMLElement): HTMLElement | null => {\n const desired = tagName.toLowerCase();\n let current: Node | null = node;\n\n while (current && current !== root) {\n if (current instanceof HTMLElement && current.tagName.toLowerCase() === desired) {\n return current;\n }\n\n current = current.parentNode;\n }\n\n return null;\n};\n\nconst unwrapElement = (element: HTMLElement) => {\n const parent = element.parentNode;\n\n if (!parent) {\n return;\n }\n\n while (element.firstChild) {\n parent.insertBefore(element.firstChild, element);\n }\n\n parent.removeChild(element);\n};\n\nconst placeCaretInside = (element: HTMLElement) => {\n const selection = window.getSelection();\n\n if (!selection) {\n return;\n }\n\n const range = document.createRange();\n range.selectNodeContents(element);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n};\n\nconst getSelectionRange = (root: HTMLElement): Range | null => {\n const selection = window.getSelection();\n\n if (!selection || selection.rangeCount === 0) {\n return null;\n }\n\n const range = selection.getRangeAt(0);\n\n if (!root.contains(range.commonAncestorContainer)) {\n return null;\n }\n\n return range;\n};\n\nconst wrapRange = (range: Range, tagName: string, attrs?: Record<string, string>): HTMLElement => {\n const wrapper = document.createElement(tagName);\n\n if (attrs) {\n Object.entries(attrs).forEach(([key, value]) => wrapper.setAttribute(key, value));\n }\n\n if (range.collapsed) {\n wrapper.append(document.createTextNode(\"\\u200B\"));\n range.insertNode(wrapper);\n placeCaretInside(wrapper);\n return wrapper;\n }\n\n const fragment = range.extractContents();\n wrapper.append(fragment);\n range.insertNode(wrapper);\n\n const selection = window.getSelection();\n if (selection) {\n const nextRange = document.createRange();\n nextRange.selectNodeContents(wrapper);\n selection.removeAllRanges();\n selection.addRange(nextRange);\n }\n\n return wrapper;\n};\n\nconst blockTags = new Set([\"p\", \"div\", \"h1\", \"h2\", \"blockquote\", \"pre\", \"li\"]);\n\nconst getBlockElement = (range: Range, root: HTMLElement): HTMLElement => {\n const start = closestElement(range.startContainer, root);\n\n if (!start) {\n return root;\n }\n\n let current: HTMLElement | null = start;\n while (current && current !== root) {\n if (blockTags.has(current.tagName.toLowerCase())) {\n return current;\n }\n\n current = current.parentElement;\n }\n\n return root;\n};\n\nconst replaceBlockTag = (block: HTMLElement, tagName: string): HTMLElement => {\n if (block.tagName.toLowerCase() === tagName.toLowerCase()) {\n return block;\n }\n\n const replacement = document.createElement(tagName);\n while (block.firstChild) {\n replacement.append(block.firstChild);\n }\n\n Array.from(block.attributes).forEach((attribute) => {\n if (attribute.name === \"style\" || attribute.name === \"dir\") {\n replacement.setAttribute(attribute.name, attribute.value);\n }\n });\n\n block.parentNode?.replaceChild(replacement, block);\n return replacement;\n};\n\nconst applyInlineTag = (tagName: string, root: HTMLElement, range: Range) => {\n const existing = closestByTag(range.commonAncestorContainer, tagName, root);\n\n if (existing) {\n unwrapElement(existing);\n return;\n }\n\n wrapRange(range, tagName);\n};\n\nconst applyScript = (value: \"normal\" | \"sub\" | \"super\", root: HTMLElement, range: Range) => {\n const sub = closestByTag(range.commonAncestorContainer, \"sub\", root);\n const sup = closestByTag(range.commonAncestorContainer, \"sup\", root);\n\n if (sub) {\n unwrapElement(sub);\n }\n\n if (sup) {\n unwrapElement(sup);\n }\n\n if (value === \"sub\") {\n wrapRange(range, \"sub\");\n }\n\n if (value === \"super\") {\n wrapRange(range, \"sup\");\n }\n};\n\nconst applyHeader = (value: \"normal\" | \"h1\" | \"h2\", root: HTMLElement, range: Range) => {\n const block = getBlockElement(range, root);\n\n if (value === \"h1\" || value === \"h2\") {\n replaceBlockTag(block, value);\n return;\n }\n\n replaceBlockTag(block, \"p\");\n};\n\nconst toggleBlockTag = (tagName: \"blockquote\" | \"pre\", root: HTMLElement, range: Range) => {\n const block = getBlockElement(range, root);\n\n if (block.tagName.toLowerCase() === tagName) {\n replaceBlockTag(block, \"p\");\n return;\n }\n\n replaceBlockTag(block, tagName);\n};\n\nconst ensureList = (tagName: \"ol\" | \"ul\", root: HTMLElement, range: Range, remove: boolean) => {\n const block = getBlockElement(range, root);\n const li = closestByTag(block, \"li\", root);\n\n if (li) {\n const list = li.parentElement;\n\n if (!list) {\n return;\n }\n\n if (remove || list.tagName.toLowerCase() === tagName) {\n const paragraph = document.createElement(\"p\");\n paragraph.textContent = li.textContent ?? \"\";\n list.parentNode?.insertBefore(paragraph, list);\n li.remove();\n\n if (!list.querySelector(\"li\")) {\n list.remove();\n }\n\n return;\n }\n\n const nextList = document.createElement(tagName);\n const nextLi = document.createElement(\"li\");\n nextLi.textContent = li.textContent ?? \"\";\n nextList.append(nextLi);\n list.parentNode?.insertBefore(nextList, list.nextSibling);\n li.remove();\n\n if (!list.querySelector(\"li\")) {\n list.remove();\n }\n\n return;\n }\n\n if (remove) {\n return;\n }\n\n const list = document.createElement(tagName);\n const listItem = document.createElement(\"li\");\n listItem.innerHTML = block.innerHTML;\n list.append(listItem);\n block.parentNode?.replaceChild(list, block);\n};\n\nconst applyIndent = (root: HTMLElement, range: Range, direction: \"-\" | \"+\") => {\n const block = getBlockElement(range, root);\n const current = Number.parseInt(block.style.marginLeft || \"0\", 10) || 0;\n const next = direction === \"+\" ? current + 24 : Math.max(0, current - 24);\n\n block.style.marginLeft = next === 0 ? \"\" : `${next}px`;\n};\n\nconst applyAlign = (root: HTMLElement, range: Range, align: \"left\" | \"center\" | \"right\" | \"justify\") => {\n const block = getBlockElement(range, root);\n block.style.textAlign = align;\n};\n\nconst applyDirection = (root: HTMLElement, range: Range, value: \"ltr\" | \"rtl\") => {\n const block = getBlockElement(range, root);\n block.setAttribute(\"dir\", value);\n};\n\nconst clearFormatting = (root: HTMLElement, range: Range) => {\n if (range.collapsed) {\n const block = getBlockElement(range, root);\n const text = block.textContent ?? \"\";\n block.replaceChildren(document.createTextNode(text));\n return;\n }\n\n const selectedText = range.toString();\n range.deleteContents();\n range.insertNode(document.createTextNode(selectedText));\n};\n\nconst insertNodeAtRange = (range: Range, node: Node) => {\n range.deleteContents();\n range.insertNode(node);\n\n const selection = window.getSelection();\n if (selection) {\n const after = document.createRange();\n after.setStartAfter(node);\n after.collapse(true);\n selection.removeAllRanges();\n selection.addRange(after);\n }\n};\n\nconst applyEmbed = async (\n type: EmbedType,\n range: Range,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n) => {\n const value = await Promise.resolve(requestEmbedValue?.(type) ?? null);\n\n if (!value || value.trim().length === 0) {\n return;\n }\n\n if (type === \"formula\") {\n const formula = document.createElement(\"span\");\n formula.setAttribute(\"data-formula\", \"true\");\n formula.textContent = value.trim();\n insertNodeAtRange(range, formula);\n return;\n }\n\n const url = safeUrl(value);\n\n if (!url) {\n return;\n }\n\n if (type === \"link\") {\n const selected = range.toString().trim();\n const anchor = document.createElement(\"a\");\n anchor.href = url;\n anchor.rel = \"noopener noreferrer\";\n anchor.target = \"_blank\";\n anchor.textContent = selected.length > 0 ? selected : url;\n insertNodeAtRange(range, anchor);\n return;\n }\n\n if (type === \"image\") {\n const image = document.createElement(\"img\");\n image.src = url;\n image.alt = \"embedded image\";\n insertNodeAtRange(range, image);\n return;\n }\n\n const video = document.createElement(\"video\");\n video.setAttribute(\"controls\", \"true\");\n video.src = url;\n insertNodeAtRange(range, video);\n};\n\nconst applyButtonCommand = async (\n command: string,\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n) => {\n editable.focus();\n\n const range = getSelectionRange(editable);\n\n if (!range) {\n return;\n }\n\n switch (command) {\n case \"bold\":\n applyInlineTag(\"strong\", editable, range);\n break;\n case \"italic\":\n applyInlineTag(\"em\", editable, range);\n break;\n case \"underline\":\n applyInlineTag(\"u\", editable, range);\n break;\n case \"strike\":\n applyInlineTag(\"s\", editable, range);\n break;\n case \"code\":\n applyInlineTag(\"code\", editable, range);\n break;\n case \"blockquote\":\n toggleBlockTag(\"blockquote\", editable, range);\n break;\n case \"code-block\":\n toggleBlockTag(\"pre\", editable, range);\n break;\n case \"indent-\":\n applyIndent(editable, range, \"-\");\n break;\n case \"indent+\":\n applyIndent(editable, range, \"+\");\n break;\n case \"link\":\n await applyEmbed(\"link\", range, requestEmbedValue);\n break;\n case \"image\":\n await applyEmbed(\"image\", range, requestEmbedValue);\n break;\n case \"video\":\n await applyEmbed(\"video\", range, requestEmbedValue);\n break;\n case \"formula\":\n await applyEmbed(\"formula\", range, requestEmbedValue);\n break;\n case \"clean\":\n clearFormatting(editable, range);\n break;\n default:\n break;\n }\n};\n\nconst applySelectCommand = (command: string, value: string, editable: HTMLDivElement) => {\n editable.focus();\n\n const range = getSelectionRange(editable);\n\n if (!range) {\n return;\n }\n\n switch (command) {\n case \"font\":\n if (value === \"default\") {\n clearFormatting(editable, range);\n } else {\n wrapRange(range, \"span\", {\n style: `font-family:${value === \"serif\" ? \"serif\" : \"monospace\"}`,\n });\n }\n break;\n case \"size\":\n wrapRange(range, \"span\", {\n style:\n value === \"small\"\n ? \"font-size:12px\"\n : value === \"large\"\n ? \"font-size:20px\"\n : value === \"huge\"\n ? \"font-size:28px\"\n : \"font-size:16px\",\n });\n break;\n case \"header\":\n applyHeader(value as \"normal\" | \"h1\" | \"h2\", editable, range);\n break;\n case \"script\":\n applyScript(value as \"normal\" | \"sub\" | \"super\", editable, range);\n break;\n case \"align\":\n applyAlign(editable, range, value as \"left\" | \"center\" | \"right\" | \"justify\");\n break;\n case \"list\":\n ensureList(value === \"ordered\" ? \"ol\" : \"ul\", editable, range, value === \"none\");\n break;\n case \"direction\":\n applyDirection(editable, range, value === \"rtl\" ? \"rtl\" : \"ltr\");\n break;\n default:\n break;\n }\n};\n\nconst renderButton = (\n command: string,\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n onMutate: () => void,\n) => {\n const button = document.createElement(\"button\");\n\n button.type = \"button\";\n button.className = \"az-rich-editor-toolbar-button\";\n button.setAttribute(\"aria-label\", commandLabels[command] ?? command);\n button.title = commandLabels[command] ?? command;\n button.append(createToolbarIcon(command, command));\n button.addEventListener(\"click\", async () => {\n await applyButtonCommand(command, editable, requestEmbedValue);\n onMutate();\n });\n\n return button;\n};\n\nconst createSelect = (\n format: string,\n options: string[],\n editable: HTMLDivElement,\n onMutate: () => void,\n) => {\n const select = document.createElement(\"select\");\n\n select.className = \"az-rich-editor-toolbar-select\";\n select.setAttribute(\"aria-label\", format);\n\n options.forEach((optionValue) => {\n const option = document.createElement(\"option\");\n\n option.value = optionValue;\n option.textContent = selectOptionLabels[format]?.[optionValue] ?? optionValue;\n option.title = optionValue;\n select.append(option);\n });\n\n select.addEventListener(\"change\", () => {\n applySelectCommand(format, select.value, editable);\n onMutate();\n });\n\n return select;\n};\n\nconst buildToolbar = (\n editable: HTMLDivElement,\n requestEmbedValue: MountRichTextEditorOptions[\"requestEmbedValue\"],\n onMutate: () => void,\n toolbarOption?: boolean | string[],\n) => {\n if (toolbarOption === false) {\n return null;\n }\n\n const toolbar = document.createElement(\"div\");\n\n toolbar.className = \"az-rich-editor-toolbar\";\n toolbar.setAttribute(\"role\", \"toolbar\");\n toolbar.setAttribute(\"aria-label\", \"Rich editor toolbar\");\n\n const allowed = Array.isArray(toolbarOption) ? new Set(toolbarOption) : null;\n\n const selectConfigs: Array<{ format: string; options: string[] }> = [\n { format: \"font\", options: [\"default\", \"serif\", \"monospace\"] },\n { format: \"size\", options: [\"normal\", \"small\", \"large\", \"huge\"] },\n { format: \"header\", options: [\"normal\", \"h1\", \"h2\"] },\n { format: \"script\", options: [\"normal\", \"sub\", \"super\"] },\n { format: \"align\", options: [\"left\", \"center\", \"right\", \"justify\"] },\n { format: \"list\", options: [\"none\", \"ordered\", \"bullet\"] },\n { format: \"direction\", options: [\"ltr\", \"rtl\"] },\n ];\n\n selectConfigs.forEach((config) => {\n if (!allowed || allowed.has(config.format)) {\n toolbar.append(createSelect(config.format, config.options, editable, onMutate));\n }\n });\n\n const buttons = [\n \"bold\",\n \"italic\",\n \"underline\",\n \"strike\",\n \"code\",\n \"blockquote\",\n \"code-block\",\n \"indent-\",\n \"indent+\",\n \"link\",\n \"image\",\n \"video\",\n \"formula\",\n \"clean\",\n ];\n\n buttons.forEach((command) => {\n if (!allowed || allowed.has(command)) {\n toolbar.append(renderButton(command, editable, requestEmbedValue, onMutate));\n }\n });\n\n return toolbar.childNodes.length > 0 ? toolbar : null;\n};\n\nexport const mountRichTextEditor = ({\n host,\n initialHtml,\n disabled = false,\n onChange,\n requestEmbedValue,\n toolbar: toolbarOption,\n placeholder,\n onSelectionChange,\n}: MountRichTextEditorOptions): MountedRichTextEditor => {\n host.innerHTML = \"\";\n\n const wrapper = document.createElement(\"div\");\n wrapper.className = \"az-rich-editor\";\n\n const editable = document.createElement(\"div\");\n editable.className = \"az-rich-editor-input\";\n editable.setAttribute(\"aria-label\", \"Rich editor input\");\n editable.setAttribute(\"role\", \"textbox\");\n editable.setAttribute(\"aria-multiline\", \"true\");\n editable.setAttribute(\"contenteditable\", disabled ? \"false\" : \"true\");\n editable.dataset.placeholder = placeholder ?? \"Compose an epic...\";\n editable.innerHTML = initialHtml;\n\n const emitChange = () => onChange(editable.innerHTML);\n\n const toolbar = buildToolbar(editable, requestEmbedValue, emitChange, toolbarOption);\n\n const inputHandler = () => emitChange();\n editable.addEventListener(\"input\", inputHandler);\n\n const keydownHandler = (event: KeyboardEvent) => {\n const range = getSelectionRange(editable);\n if (!range) {\n return;\n }\n\n const isMod = event.metaKey || event.ctrlKey;\n\n if (isMod) {\n const key = event.key.toLowerCase();\n if (key === \"b\") {\n event.preventDefault();\n applyButtonCommand(\"bold\", editable, requestEmbedValue);\n emitChange();\n } else if (key === \"i\") {\n event.preventDefault();\n applyButtonCommand(\"italic\", editable, requestEmbedValue);\n emitChange();\n } else if (key === \"u\") {\n event.preventDefault();\n applyButtonCommand(\"underline\", editable, requestEmbedValue);\n emitChange();\n }\n }\n\n if (event.key === \"Tab\") {\n const block = getBlockElement(range, editable);\n const li = closestByTag(block, \"li\", editable);\n if (li) {\n event.preventDefault();\n applyIndent(editable, range, event.shiftKey ? \"-\" : \"+\");\n emitChange();\n }\n }\n };\n editable.addEventListener(\"keydown\", keydownHandler);\n\n const checkMarkActive = (markName: string): boolean => {\n const selection = window.getSelection();\n if (!selection || selection.rangeCount === 0) {\n return false;\n }\n const range = selection.getRangeAt(0);\n if (!editable.contains(range.commonAncestorContainer)) {\n return false;\n }\n\n const markTags: Record<string, string[]> = {\n strong: [\"strong\", \"b\"],\n bold: [\"strong\", \"b\"],\n em: [\"em\", \"i\"],\n italic: [\"em\", \"i\"],\n underline: [\"u\"],\n strike: [\"s\", \"del\", \"strike\"],\n code: [\"code\"],\n link: [\"a\"],\n };\n\n const tags = markTags[markName];\n if (!tags) return false;\n\n let node: Node | null = range.startContainer;\n while (node && node !== editable) {\n if (node instanceof HTMLElement) {\n const tagName = node.tagName.toLowerCase();\n if (tags.includes(tagName)) {\n return true;\n }\n if (markName === \"code\" && node.style.fontFamily === \"monospace\") {\n return true;\n }\n }\n node = node.parentNode;\n }\n return false;\n };\n\n const checkActiveBlockType = (): string => {\n const selection = window.getSelection();\n if (!selection || selection.rangeCount === 0) {\n return \"paragraph\";\n }\n const range = selection.getRangeAt(0);\n if (!editable.contains(range.commonAncestorContainer)) {\n return \"paragraph\";\n }\n\n let node: Node | null = range.startContainer;\n while (node && node !== editable) {\n if (node instanceof HTMLElement) {\n const tagName = node.tagName.toLowerCase();\n if (tagName === \"h1\" || tagName === \"h2\" || tagName === \"h3\") return \"heading\";\n if (tagName === \"blockquote\") return \"blockquote\";\n if (tagName === \"pre\") return \"code_block\";\n if (tagName === \"ol\") return \"ordered_list\";\n if (tagName === \"ul\") return \"bullet_list\";\n }\n node = node.parentNode;\n }\n return \"paragraph\";\n };\n\n const updateToolbarStates = () => {\n if (!toolbar) return;\n\n const buttons = toolbar.querySelectorAll(\".az-rich-editor-toolbar-button\");\n buttons.forEach((btn) => {\n const command = btn.getAttribute(\"aria-label\");\n if (!command) return;\n\n let isActive = false;\n if (command === \"Bold\") {\n isActive = checkMarkActive(\"strong\");\n } else if (command === \"Italic\") {\n isActive = checkMarkActive(\"em\");\n } else if (command === \"Underline\") {\n isActive = checkMarkActive(\"underline\");\n } else if (command === \"Strike\") {\n isActive = checkMarkActive(\"strike\");\n } else if (command === \"Inline code\") {\n isActive = checkMarkActive(\"code\");\n } else if (command === \"Blockquote\") {\n isActive = checkActiveBlockType() === \"blockquote\";\n } else if (command === \"Code block\") {\n isActive = checkActiveBlockType() === \"code_block\";\n }\n\n if (isActive) {\n btn.setAttribute(\"data-active\", \"true\");\n btn.classList.add(\"active\");\n } else {\n btn.removeAttribute(\"data-active\");\n btn.classList.remove(\"active\");\n }\n });\n\n const selects = toolbar.querySelectorAll(\".az-rich-editor-toolbar-select\");\n selects.forEach((select) => {\n const label = select.getAttribute(\"aria-label\");\n if (label === \"header\") {\n const blockType = checkActiveBlockType();\n if (blockType === \"heading\") {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const block = getBlockElement(range, editable);\n const level = block.tagName.toLowerCase();\n if (level === \"h1\" || level === \"h2\" || level === \"h3\") {\n (select as HTMLSelectElement).value = level;\n } else {\n (select as HTMLSelectElement).value = \"normal\";\n }\n }\n } else {\n (select as HTMLSelectElement).value = \"normal\";\n }\n } else if (label === \"align\") {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const block = getBlockElement(range, editable);\n (select as HTMLSelectElement).value = block.style.textAlign || \"left\";\n }\n } else if (label === \"direction\") {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n const block = getBlockElement(range, editable);\n (select as HTMLSelectElement).value = block.getAttribute(\"dir\") || \"ltr\";\n }\n }\n });\n };\n\n const selectionHandler = () => {\n const selection = window.getSelection();\n if (selection && selection.rangeCount > 0) {\n const range = selection.getRangeAt(0);\n if (editable.contains(range.commonAncestorContainer)) {\n onSelectionChange?.();\n updateToolbarStates();\n }\n }\n };\n document.addEventListener(\"selectionchange\", selectionHandler);\n\n if (toolbar) {\n wrapper.append(toolbar);\n updateToolbarStates();\n }\n wrapper.append(editable);\n host.append(wrapper);\n\n return {\n destroy: () => {\n editable.removeEventListener(\"input\", inputHandler);\n editable.removeEventListener(\"keydown\", keydownHandler);\n document.removeEventListener(\"selectionchange\", selectionHandler);\n host.innerHTML = \"\";\n },\n getHtml: () => editable.innerHTML,\n setHtml: (html) => {\n editable.innerHTML = html;\n updateToolbarStates();\n },\n isMarkActive: (markName) => checkMarkActive(markName),\n getActiveBlockType: () => checkActiveBlockType(),\n };\n};\n","import type { EditorInstance } from \"../../core/types\";\nimport { mountRichTextEditor } from \"../../rich-text/mountEditor\";\n\nexport interface DomEditorAdapter {\n mount: (target: Element) => void;\n unmount: () => void;\n destroy: () => void;\n}\n\nexport const createDomAdapter = (editor: EditorInstance): DomEditorAdapter => {\n let target: Element | null = null;\n let mountedEditor: ReturnType<typeof mountRichTextEditor> | null = null;\n let unsubscribeChange: (() => void) | null = null;\n\n return {\n mount: (nextTarget) => {\n target = nextTarget;\n editor.mount(nextTarget);\n\n if (!(nextTarget instanceof HTMLElement)) {\n return;\n }\n\n mountedEditor = mountRichTextEditor({\n host: nextTarget,\n initialHtml: editor.export(\"html\").payload,\n requestEmbedValue: () => null,\n toolbar: editor.toolbar,\n placeholder: editor.placeholder,\n onSelectionChange: () => {\n editor._triggerSelectionChange?.();\n },\n onChange: (html) => {\n editor.import({\n format: \"html\",\n payload: html,\n });\n },\n });\n\n editor._registerActiveHandler?.({\n isMarkActive: (name) => mountedEditor?.isMarkActive(name) ?? false,\n getActiveBlockType: () => mountedEditor?.getActiveBlockType() ?? \"paragraph\",\n });\n\n unsubscribeChange = editor.on(\"change\", () => {\n if (!mountedEditor) {\n return;\n }\n const nextHtml = editor.export(\"html\").payload;\n if (mountedEditor.getHtml() !== nextHtml) {\n mountedEditor.setHtml(nextHtml);\n }\n });\n },\n unmount: () => {\n if (!target) {\n return;\n }\n\n unsubscribeChange?.();\n unsubscribeChange = null;\n\n editor._registerActiveHandler?.(null);\n\n mountedEditor?.destroy();\n mountedEditor = null;\n\n editor.unmount();\n target = null;\n },\n destroy: () => {\n unsubscribeChange?.();\n unsubscribeChange = null;\n\n editor._registerActiveHandler?.(null);\n\n mountedEditor?.destroy();\n mountedEditor = null;\n\n editor.destroy();\n target = null;\n },\n };\n};\n","import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport { createEditor } from \"../../core/createEditor\";\nimport type { EditorConfig, EditorInstance, EditorDocument } from \"../../core/types\";\nimport { mountRichTextEditor } from \"../../rich-text/mountEditor\";\n\n// React Context for the Editor\nexport const EditorContext = createContext<EditorInstance | null>(null);\n\nexport const useEditor = () => {\n return useContext(EditorContext);\n};\n\nexport const useEditorState = () => {\n const editor = useContext(EditorContext);\n if (!editor) {\n throw new Error(\"useEditorState must be used inside an EditorProvider\");\n }\n\n const [document, setDocument] = useState<EditorDocument>(() => editor.getDocument());\n const [selectionKey, setSelectionKey] = useState(0);\n\n useEffect(() => {\n const unsubChange = editor.on(\"change\", () => {\n setDocument(editor.getDocument());\n });\n const unsubSelection = editor.on(\"selectionchange\", () => {\n setSelectionKey((k) => k + 1);\n });\n return () => {\n unsubChange();\n unsubSelection();\n };\n }, [editor]);\n\n const isMarkActive = useCallback((name: string) => editor.isMarkActive(name), [editor, selectionKey]);\n const getActiveBlockType = useCallback(() => editor.getActiveBlockType(), [editor, selectionKey]);\n\n return {\n editor,\n document,\n isMarkActive,\n activeBlockType: getActiveBlockType(),\n };\n};\n\nexport function EditorProvider({ editor, children }: { editor: EditorInstance; children: React.ReactNode }) {\n return (\n <EditorContext.Provider value={editor}>\n {children}\n </EditorContext.Provider>\n );\n}\n\nexport const useEditorAdapter = (config: EditorConfig) => {\n const editor = useMemo(() => createEditor(config), [config]);\n\n useEffect(() => () => {\n editor.destroy();\n }, [editor]);\n\n return editor;\n};\n\nexport interface RichEditorAdapterProps extends EditorConfig {\n className?: string;\n disabled?: boolean;\n onRequestEmbedValue?: (type: \"link\" | \"image\" | \"video\" | \"formula\") => Promise<string | null> | string | null;\n editor?: EditorInstance;\n}\n\nexport function RichEditorAdapter({\n className,\n disabled = false,\n initialContent,\n onChange,\n onError,\n onRequestEmbedValue,\n toolbar,\n placeholder,\n editor: propEditor,\n}: RichEditorAdapterProps) {\n const contextEditor = useEditor();\n const fallbackEditor = useEditorAdapter({ initialContent, onChange, onError, toolbar, placeholder });\n const editor = propEditor ?? contextEditor ?? fallbackEditor;\n\n const hostRef = useRef<HTMLDivElement | null>(null);\n const mountedRef = useRef<ReturnType<typeof mountRichTextEditor> | null>(null);\n\n useEffect(() => {\n if (editor._registerActiveHandler) {\n editor._registerActiveHandler({\n isMarkActive: (name) => mountedRef.current?.isMarkActive(name) ?? false,\n getActiveBlockType: () => mountedRef.current?.getActiveBlockType() ?? \"paragraph\",\n });\n }\n return () => {\n editor._registerActiveHandler?.(null);\n };\n }, [editor]);\n\n useEffect(() => {\n const host = hostRef.current;\n\n if (!host) {\n return;\n }\n\n const mounted = mountRichTextEditor({\n host,\n initialHtml: editor.export(\"html\").payload,\n disabled,\n requestEmbedValue: onRequestEmbedValue,\n toolbar: toolbar ?? editor.toolbar,\n placeholder: placeholder ?? editor.placeholder,\n onSelectionChange: () => {\n editor._triggerSelectionChange?.();\n },\n onChange: (html) => {\n editor.import({\n format: \"html\",\n payload: html,\n });\n },\n });\n\n mountedRef.current = mounted;\n\n return () => {\n mounted.destroy();\n mountedRef.current = null;\n };\n }, [disabled, editor, onRequestEmbedValue, toolbar, placeholder]);\n\n return (\n <div\n aria-label=\"Rich editor\"\n className={className}\n ref={hostRef}\n />\n );\n}\n"],"mappings":";;;;;AAEA,MAAa,oBACX,MACA,UACA,SACA,cAC8B;CAC9B;CACA;CACA;CACA;AACF;AAEA,MAAa,0BACX,MACA,SACA,aACyB;CACzB;CACA;CACA,UAAU;CACV,aAAa;CACb;AACF;;;ACrBA,MAAa,kCAAkC,gBAC7C,iBAAiB,mBAAmB,WAAW,YAAY,YAAY,mDAAmD;AAE5H,MAAa,6BAA6B,SACxC,iBAAiB,cAAc,QAAQ,MAAM,KAAK,qDAAqD;;;ACLzG,MAAM,uBAAuB,iBAA+C,EAAE,gBAAgB,EAC5F,UAAU;CACR,GAAG;CACH,UAAU,SAAS,WAAW;CAC9B,UAAU;EACR,GAAG,SAAS;EACZ,aAAa;CACf;AACF,EACF;AAEA,MAAa,yCAA+E;CAC1F,MAAM,oBAAoB,MAAM;CAChC,QAAQ,oBAAoB,QAAQ;CACpC,WAAW,oBAAoB,WAAW;CAC1C,S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