@lakamark/modulo-editor 0.2.0-alpha.1
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/LICENSE +21 -0
- package/README.md +73 -0
- package/dist/modulo-editor.js +1018 -0
- package/dist/modulo-editor.js.map +1 -0
- package/dist/modulo-editor.umd.cjs +5 -0
- package/dist/modulo-editor.umd.cjs.map +1 -0
- package/dist/types/commands/builtin/BoldCommand.d.ts +9 -0
- package/dist/types/commands/builtin/BoldCommand.d.ts.map +1 -0
- package/dist/types/commands/builtin/HeadingCommand.d.ts +8 -0
- package/dist/types/commands/builtin/HeadingCommand.d.ts.map +1 -0
- package/dist/types/commands/builtin/ItalicCommand.d.ts +6 -0
- package/dist/types/commands/builtin/ItalicCommand.d.ts.map +1 -0
- package/dist/types/commands/builtin/index.d.ts +11 -0
- package/dist/types/commands/builtin/index.d.ts.map +1 -0
- package/dist/types/commands/contracts/EditorCommand.d.ts +18 -0
- package/dist/types/commands/contracts/EditorCommand.d.ts.map +1 -0
- package/dist/types/commands/contracts/EditorCommandContext.d.ts +15 -0
- package/dist/types/commands/contracts/EditorCommandContext.d.ts.map +1 -0
- package/dist/types/commands/contracts/EditorInput.d.ts +14 -0
- package/dist/types/commands/contracts/EditorInput.d.ts.map +1 -0
- package/dist/types/commands/contracts/index.d.ts +4 -0
- package/dist/types/commands/contracts/index.d.ts.map +1 -0
- package/dist/types/commands/index.d.ts +5 -0
- package/dist/types/commands/index.d.ts.map +1 -0
- package/dist/types/commands/registry/EditorCommandRegistry.d.ts +28 -0
- package/dist/types/commands/registry/EditorCommandRegistry.d.ts.map +1 -0
- package/dist/types/commands/registry/EditorCommandsApi.d.ts +14 -0
- package/dist/types/commands/registry/EditorCommandsApi.d.ts.map +1 -0
- package/dist/types/commands/registry/RegistryEditorCommandsApi.d.ts +20 -0
- package/dist/types/commands/registry/RegistryEditorCommandsApi.d.ts.map +1 -0
- package/dist/types/commands/registry/index.d.ts +4 -0
- package/dist/types/commands/registry/index.d.ts.map +1 -0
- package/dist/types/commands/setup/assertCustomCommandsAreValid.d.ts +12 -0
- package/dist/types/commands/setup/assertCustomCommandsAreValid.d.ts.map +1 -0
- package/dist/types/commands/setup/builtin-command-names.d.ts +16 -0
- package/dist/types/commands/setup/builtin-command-names.d.ts.map +1 -0
- package/dist/types/commands/setup/index.d.ts +6 -0
- package/dist/types/commands/setup/index.d.ts.map +1 -0
- package/dist/types/commands/setup/resolveBuiltinCommands.d.ts +4 -0
- package/dist/types/commands/setup/resolveBuiltinCommands.d.ts.map +1 -0
- package/dist/types/commands/setup/setupEditorCommands.d.ts +30 -0
- package/dist/types/commands/setup/setupEditorCommands.d.ts.map +1 -0
- package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts +117 -0
- package/dist/types/core/Builder/DefaultModuloEditorBuilder.d.ts.map +1 -0
- package/dist/types/core/Builder/index.d.ts +2 -0
- package/dist/types/core/Builder/index.d.ts.map +1 -0
- package/dist/types/core/DefaultEditorDocument.d.ts +11 -0
- package/dist/types/core/DefaultEditorDocument.d.ts.map +1 -0
- package/dist/types/core/ModuloEditor.d.ts +93 -0
- package/dist/types/core/ModuloEditor.d.ts.map +1 -0
- package/dist/types/core/contracts/EditorDocument.d.ts +16 -0
- package/dist/types/core/contracts/EditorDocument.d.ts.map +1 -0
- package/dist/types/core/contracts/ModuloEditorBuilder.d.ts +23 -0
- package/dist/types/core/contracts/ModuloEditorBuilder.d.ts.map +1 -0
- package/dist/types/core/contracts/ModuloEditorOptions.d.ts +52 -0
- package/dist/types/core/contracts/ModuloEditorOptions.d.ts.map +1 -0
- package/dist/types/core/contracts/index.d.ts +4 -0
- package/dist/types/core/contracts/index.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/dom/DefaultEditorDomResolver.d.ts +42 -0
- package/dist/types/dom/DefaultEditorDomResolver.d.ts.map +1 -0
- package/dist/types/dom/contracts/EditorDomResolver.d.ts +20 -0
- package/dist/types/dom/contracts/EditorDomResolver.d.ts.map +1 -0
- package/dist/types/dom/contracts/EditorDomSlots.d.ts +62 -0
- package/dist/types/dom/contracts/EditorDomSlots.d.ts.map +1 -0
- package/dist/types/dom/contracts/index.d.ts +3 -0
- package/dist/types/dom/contracts/index.d.ts.map +1 -0
- package/dist/types/dom/index.d.ts +2 -0
- package/dist/types/dom/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +7 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/input/EditorInputAdapter.d.ts +17 -0
- package/dist/types/input/EditorInputAdapter.d.ts.map +1 -0
- package/dist/types/input/EditorInputState.d.ts +6 -0
- package/dist/types/input/EditorInputState.d.ts.map +1 -0
- package/dist/types/input/TextareaInputAdapter.d.ts +18 -0
- package/dist/types/input/TextareaInputAdapter.d.ts.map +1 -0
- package/dist/types/input/index.d.ts +4 -0
- package/dist/types/input/index.d.ts.map +1 -0
- package/dist/types/markdown/config/ConfigurableHtmlSanitizer.d.ts +23 -0
- package/dist/types/markdown/config/ConfigurableHtmlSanitizer.d.ts.map +1 -0
- package/dist/types/markdown/config/DefaultHtmlSanitizerConfig.d.ts +6 -0
- package/dist/types/markdown/config/DefaultHtmlSanitizerConfig.d.ts.map +1 -0
- package/dist/types/markdown/config/HtmlSanitizerConfig.d.ts +14 -0
- package/dist/types/markdown/config/HtmlSanitizerConfig.d.ts.map +1 -0
- package/dist/types/markdown/config/index.d.ts +4 -0
- package/dist/types/markdown/config/index.d.ts.map +1 -0
- package/dist/types/markdown/contracts/HtmlSanitizer.d.ts +15 -0
- package/dist/types/markdown/contracts/HtmlSanitizer.d.ts.map +1 -0
- package/dist/types/markdown/contracts/MarkdownParser.d.ts +12 -0
- package/dist/types/markdown/contracts/MarkdownParser.d.ts.map +1 -0
- package/dist/types/markdown/contracts/MarkdownProcessor.d.ts +12 -0
- package/dist/types/markdown/contracts/MarkdownProcessor.d.ts.map +1 -0
- package/dist/types/markdown/contracts/index.d.ts +4 -0
- package/dist/types/markdown/contracts/index.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +6 -0
- package/dist/types/markdown/index.d.ts.map +1 -0
- package/dist/types/markdown/parser/DefaultMarkdownProcessor.d.ts +18 -0
- package/dist/types/markdown/parser/DefaultMarkdownProcessor.d.ts.map +1 -0
- package/dist/types/markdown/parser/PlainTextMarkdownParser.d.ts +11 -0
- package/dist/types/markdown/parser/PlainTextMarkdownParser.d.ts.map +1 -0
- package/dist/types/markdown/parser/index.d.ts +3 -0
- package/dist/types/markdown/parser/index.d.ts.map +1 -0
- package/dist/types/markdown/sanitizers/DomPurifyHtmlSanitizer.d.ts +27 -0
- package/dist/types/markdown/sanitizers/DomPurifyHtmlSanitizer.d.ts.map +1 -0
- package/dist/types/markdown/sanitizers/NoopHtmlSanitizer.d.ts +11 -0
- package/dist/types/markdown/sanitizers/NoopHtmlSanitizer.d.ts.map +1 -0
- package/dist/types/markdown/sanitizers/index.d.ts +3 -0
- package/dist/types/markdown/sanitizers/index.d.ts.map +1 -0
- package/dist/types/output/EditorOutputAdapter.d.ts +25 -0
- package/dist/types/output/EditorOutputAdapter.d.ts.map +1 -0
- package/dist/types/output/HtmlPreviewAdapter.d.ts +20 -0
- package/dist/types/output/HtmlPreviewAdapter.d.ts.map +1 -0
- package/dist/types/output/index.d.ts +3 -0
- package/dist/types/output/index.d.ts.map +1 -0
- package/dist/types/plugins/contracts/EditorPlugin.d.ts +19 -0
- package/dist/types/plugins/contracts/EditorPlugin.d.ts.map +1 -0
- package/dist/types/plugins/contracts/EditorPluginApi.d.ts +11 -0
- package/dist/types/plugins/contracts/EditorPluginApi.d.ts.map +1 -0
- package/dist/types/plugins/contracts/index.d.ts +3 -0
- package/dist/types/plugins/contracts/index.d.ts.map +1 -0
- package/dist/types/plugins/index.d.ts +3 -0
- package/dist/types/plugins/index.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/base/CommandButtonPlugin.d.ts +31 -0
- package/dist/types/plugins/toolbar/base/CommandButtonPlugin.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/base/CommandButtonPluginOptions.d.ts +23 -0
- package/dist/types/plugins/toolbar/base/CommandButtonPluginOptions.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/base/index.d.ts +3 -0
- package/dist/types/plugins/toolbar/base/index.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/buttons/BoldToolbarPlugin.d.ts +8 -0
- package/dist/types/plugins/toolbar/buttons/BoldToolbarPlugin.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/buttons/HeadingToolbarPlugin.d.ts +5 -0
- package/dist/types/plugins/toolbar/buttons/HeadingToolbarPlugin.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/buttons/ItalicToolbarPlugin.d.ts +5 -0
- package/dist/types/plugins/toolbar/buttons/ItalicToolbarPlugin.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/buttons/index.d.ts +4 -0
- package/dist/types/plugins/toolbar/buttons/index.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/createDefaultToolbarPlugins.d.ts +6 -0
- package/dist/types/plugins/toolbar/createDefaultToolbarPlugins.d.ts.map +1 -0
- package/dist/types/plugins/toolbar/index.d.ts +4 -0
- package/dist/types/plugins/toolbar/index.d.ts.map +1 -0
- package/dist/types/textarea/HiddenTextareaBridge.d.ts +12 -0
- package/dist/types/textarea/HiddenTextareaBridge.d.ts.map +1 -0
- package/dist/types/textarea/TextareaBridge.d.ts +24 -0
- package/dist/types/textarea/TextareaBridge.d.ts.map +1 -0
- package/dist/types/textarea/index.d.ts +3 -0
- package/dist/types/textarea/index.d.ts.map +1 -0
- package/package.json +71 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modulo-editor.umd.cjs","names":[],"sources":["../src/commands/registry/EditorCommandRegistry.ts","../src/commands/registry/RegistryEditorCommandsApi.ts","../src/commands/setup/builtin-command-names.ts","../src/commands/setup/assertCustomCommandsAreValid.ts","../src/commands/builtin/BoldCommand.ts","../src/commands/builtin/ItalicCommand.ts","../src/commands/builtin/HeadingCommand.ts","../src/commands/builtin/index.ts","../src/commands/setup/resolveBuiltinCommands.ts","../src/dom/DefaultEditorDomResolver.ts","../src/core/DefaultEditorDocument.ts","../src/commands/setup/setupEditorCommands.ts","../src/input/TextareaInputAdapter.ts","../src/output/HtmlPreviewAdapter.ts","../src/textarea/HiddenTextareaBridge.ts","../src/plugins/toolbar/base/CommandButtonPlugin.ts","../src/plugins/toolbar/buttons/BoldToolbarPlugin.ts","../src/plugins/toolbar/buttons/ItalicToolbarPlugin.ts","../src/plugins/toolbar/buttons/HeadingToolbarPlugin.ts","../src/plugins/toolbar/createDefaultToolbarPlugins.ts","../src/markdown/config/DefaultHtmlSanitizerConfig.ts","../src/markdown/parser/PlainTextMarkdownParser.ts","../src/markdown/parser/DefaultMarkdownProcessor.ts","../node_modules/dompurify/dist/purify.es.mjs","../src/markdown/sanitizers/DomPurifyHtmlSanitizer.ts","../src/core/Builder/DefaultModuloEditorBuilder.ts","../src/core/ModuloEditor.ts"],"sourcesContent":["import type {\r\n EditorCommand,\r\n EditorCommandContext\r\n} from \"../contracts\";\r\n\r\n/**\r\n * Registry responsible for storing and executing editor commands.\r\n */\r\nexport class EditorCommandRegistry {\r\n private readonly commands = new Map<string, EditorCommand>();\r\n\r\n /**\r\n * Registers a command in the registry.\r\n */\r\n public register(command: EditorCommand): void {\r\n if (this.commands.has(command.name)) {\r\n throw new Error(`Editor command \"${command.name}\" is already registered.`);\r\n }\r\n\r\n this.commands.set(command.name, command);\r\n }\r\n\r\n /**\r\n * Returns a registered command by name.\r\n */\r\n public get(name: string): EditorCommand | undefined {\r\n return this.commands.get(name);\r\n }\r\n\r\n /**\r\n * Returns whether a command exists.\r\n */\r\n public has(name: string): boolean {\r\n return this.commands.has(name);\r\n }\r\n\r\n /**\r\n * Returns all registered commands.\r\n */\r\n public all(): readonly EditorCommand[] {\r\n return Array.from(this.commands.values());\r\n }\r\n\r\n /**\r\n * Executes a registered command.\r\n */\r\n public execute(name: string, context: EditorCommandContext): void {\r\n const command:EditorCommand | undefined = this.get(name);\r\n\r\n if (!command) {\r\n throw new Error(`Unknown editor command \"${name}\".`);\r\n }\r\n\r\n command.execute(context);\r\n }\r\n}","import type {EditorCommandsApi} from \"./EditorCommandsApi\";\r\nimport type {EditorCommandRegistry} from \"./EditorCommandRegistry\";\r\nimport type {EditorCommandContext} from \"../contracts\";\r\n\r\n/**\r\n * Adapter exposing registry commands as a public API.\r\n */\r\nexport class RegistryEditorCommandsApi implements EditorCommandsApi {\r\n private readonly registry: EditorCommandRegistry;\r\n private readonly contextResolver: () => EditorCommandContext;\r\n\r\n public constructor(\r\n registry: EditorCommandRegistry,\r\n contextResolver: () => EditorCommandContext\r\n ) {\r\n this.contextResolver = contextResolver;\r\n this.registry = registry;\r\n }\r\n\r\n /**\r\n * Executes a command.\r\n */\r\n public execute(name: string): void {\r\n const context = this.contextResolver();\r\n this.registry.execute(name, context);\r\n }\r\n\r\n /**\r\n * Checks if a command exists.\r\n */\r\n public has(name: string): boolean {\r\n return this.registry.has(name);\r\n }\r\n}","/**\r\n * List of builtin command names reserved by the editor core.\r\n *\r\n * These names cannot be overridden by user-defined commands,\r\n * even if the builtin command is not enabled.\r\n */\r\nexport const BUILTIN_COMMAND_NAMES = [\r\n 'bold',\r\n 'italic',\r\n 'heading'\r\n] as const;\r\n\r\n/**\r\n * Type representing a builtin command name.\r\n */\r\nexport type BuiltinCommandName = typeof BUILTIN_COMMAND_NAMES[number];\r\n\r\n/**\r\n * Checks whether a command name is reserved by the editor core.\r\n */\r\nexport function isBuiltinCommandName(name: string): name is BuiltinCommandName {\r\n return BUILTIN_COMMAND_NAMES.includes(name as BuiltinCommandName);\r\n}","import {isBuiltinCommandName} from './builtin-command-names';\r\nimport type {EditorCommand} from \"../contracts\";\r\n\r\n/**\r\n * Validates custom commands provided by the user.\r\n *\r\n * This function ensures that:\r\n * - no command overrides a reserved builtin command name\r\n * - no duplicate command names are defined\r\n *\r\n * Throws an error if a rule is violated.\r\n */\r\nexport function assertCustomCommandsAreValid(\r\n commands: readonly EditorCommand[]\r\n): void {\r\n /**\r\n * Tracks command names to detect duplicates.\r\n */\r\n const names = new Set<string>();\r\n\r\n for (const command of commands) {\r\n /**\r\n * Prevent overriding builtin commands.\r\n */\r\n if (isBuiltinCommandName(command.name)) {\r\n throw new Error(\r\n `Editor command \"${command.name}\" is reserved by the editor core.`\r\n );\r\n }\r\n\r\n /**\r\n * Prevent duplicate custom commands.\r\n */\r\n if (names.has(command.name)) {\r\n throw new Error(\r\n `Editor command \"${command.name}\" is already defined.`\r\n );\r\n }\r\n\r\n names.add(command.name);\r\n }\r\n}","import type {\r\n EditorCommand,\r\n EditorCommandContext\r\n} from \"../contracts\";\r\n\r\n/**\r\n * Wraps the current selection with Markdown bold markers.\r\n */\r\nexport class BoldCommand implements EditorCommand {\r\n public readonly name = \"bold\";\r\n\r\n public execute(context: EditorCommandContext): void {\r\n const { input, state } = context;\r\n const { value, selectionStart, selectionEnd } = state;\r\n\r\n const before = value.slice(0, selectionStart);\r\n const selected = value.slice(selectionStart, selectionEnd);\r\n const after = value.slice(selectionEnd);\r\n\r\n if (selected.length > 0) {\r\n const wrapped = `**${selected}**`;\r\n const nextValue = `${before}${wrapped}${after}`;\r\n\r\n input.setValue(nextValue);\r\n input.focus();\r\n input.setSelection(\r\n selectionStart + 2,\r\n selectionEnd + 2\r\n );\r\n\r\n return;\r\n }\r\n\r\n const nextValue = `${before}****${after}`;\r\n const cursor = selectionStart + 2;\r\n\r\n input.setValue(nextValue);\r\n input.focus();\r\n input.setSelection(cursor, cursor);\r\n }\r\n}","import type {\r\n EditorCommand,\r\n EditorCommandContext\r\n} from \"../contracts\";\r\n\r\nexport class ItalicCommand implements EditorCommand {\r\n public readonly name = \"italic\";\r\n\r\n public execute(context: EditorCommandContext): void {\r\n const {input, state} = context;\r\n const {value, selectionStart, selectionEnd} = state;\r\n\r\n const before = value.slice(0, selectionStart);\r\n const selected = value.slice(selectionStart, selectionEnd);\r\n const after = value.slice(selectionEnd);\r\n\r\n if (selectionStart === selectionEnd) {\r\n input.setValue(`${before}**${after}`);\r\n input.setSelection(selectionStart + 1, selectionStart + 1);\r\n input.focus();\r\n\r\n return;\r\n }\r\n\r\n input.setValue(`${before}*${selected}*${after}`);\r\n input.setSelection(selectionStart + 1, selectionEnd + 1);\r\n input.focus();\r\n }\r\n}","import type {\r\n EditorCommand,\r\n EditorCommandContext\r\n} from \"../contracts\";\r\n\r\nexport class HeadingCommand implements EditorCommand {\r\n public readonly name: string;\r\n private readonly level: number;\r\n\r\n public constructor(level: number) {\r\n if (level < 1 || level > 6) {\r\n throw new Error(\"Heading level must be between 1 and 6.\");\r\n }\r\n\r\n this.level = level;\r\n this.name = `heading-${level}`;\r\n }\r\n\r\n public execute(context: EditorCommandContext): void {\r\n const {input, state} = context;\r\n const {value, selectionStart} = state;\r\n\r\n const lineStart = value.lastIndexOf(\"\\n\", selectionStart - 1) + 1;\r\n const nextLineBreak = value.indexOf(\"\\n\", selectionStart);\r\n const lineEnd = nextLineBreak === -1 ? value.length : nextLineBreak;\r\n\r\n const line = value.slice(lineStart, lineEnd);\r\n const prefix = `${\"#\".repeat(this.level)} `;\r\n\r\n const newValue =\r\n value.slice(0, lineStart) +\r\n prefix +\r\n line +\r\n value.slice(lineEnd);\r\n\r\n input.setValue(newValue);\r\n input.setSelection(\r\n selectionStart + prefix.length,\r\n selectionStart + prefix.length\r\n );\r\n input.focus();\r\n }\r\n}","import {BoldCommand} from \"./BoldCommand\";\r\nimport {ItalicCommand} from \"./ItalicCommand\";\r\nimport {HeadingCommand} from \"./HeadingCommand\";\r\nimport type {EditorCommand} from \"../contracts\";\r\n\r\nexport {BoldCommand} from \"./BoldCommand\";\r\nexport {ItalicCommand} from \"./ItalicCommand\";\r\nexport {HeadingCommand} from \"./HeadingCommand\";\r\n\r\n/**\r\n * Creates all builtin editor commands.\r\n *\r\n * This function is used internally to register default commands.\r\n */\r\nexport function createBuiltinCommands(): readonly EditorCommand[] {\r\n return [\r\n new BoldCommand(),\r\n new ItalicCommand(),\r\n new HeadingCommand(1),\r\n new HeadingCommand(2),\r\n new HeadingCommand(3),\r\n new HeadingCommand(4),\r\n new HeadingCommand(5),\r\n new HeadingCommand(6),\r\n ];\r\n}\r\n","import type {BuiltinCommandName} from \"./builtin-command-names\";\r\nimport {createBuiltinCommands} from \"../builtin\";\r\nimport type {EditorCommand} from \"../contracts\";\r\n\r\n\r\nexport function resolveBuiltinCommands(\r\n option: boolean | readonly BuiltinCommandName[] | undefined\r\n): readonly EditorCommand[] {\r\n const commands = createBuiltinCommands();\r\n\r\n if (option === false) {\r\n return [];\r\n }\r\n\r\n if (option === true || option === undefined) {\r\n return commands;\r\n }\r\n\r\n const allowedNames = new Set(option);\r\n\r\n return commands.filter((command) =>\r\n allowedNames.has(command.name as BuiltinCommandName)\r\n );\r\n}","import type {\r\n EditorDomResolver,\r\n EditorDomSlots\r\n} from \"./contracts\";\r\n\r\n/**\r\n * Default implementation of EditorDomResolver.\r\n *\r\n * This resolver expects the following data attributes:\r\n *\r\n * Required:\r\n * - data-mo-editor-input\r\n * - data-mo-editor-preview\r\n * - data-mo-editor-textarea\r\n *\r\n * Optional:\r\n * - data-mo-editor-header\r\n * - data-mo-editor-toolbar\r\n * - data-mo-editor-body\r\n * - data-mo-editor-footer\r\n * - data-mo-editor-status\r\n *\r\n * Example structure:\r\n *\r\n * <div data-mo-editor>\r\n * <div data-mo-editor-header></div>\r\n * <div data-mo-editor-toolbar></div>\r\n * <div data-mo-editor-input></div>\r\n * <div data-mo-editor-preview></div>\r\n * <textarea data-mo-editor-textarea></textarea>\r\n * </div>\r\n */\r\nexport class DefaultEditorDomResolver implements EditorDomResolver {\r\n\r\n /**\r\n * Resolves DOM slots from the provided root element.\r\n */\r\n public resolve(root: HTMLElement): EditorDomSlots {\r\n const header = this.getDataAttribute(root, 'header');\r\n const toolbar = this.getDataAttribute(root, 'toolbar');\r\n const body = this.getDataAttribute(root, 'body');\r\n const input = this.getDataAttribute(root, 'input');\r\n const preview = this.getDataAttribute(root, 'preview');\r\n const footer = this.getDataAttribute(root, 'footer');\r\n const status = this.getDataAttribute(root, 'status');\r\n const textarea = this.getDataAttribute<HTMLTextAreaElement>(root, 'textarea');\r\n\r\n if (!input) {\r\n throw new Error('ModuloEditor: missing [data-mo-editor-input].');\r\n }\r\n\r\n if (!preview) {\r\n throw new Error('ModuloEditor: missing [data-mo-editor-preview].');\r\n }\r\n\r\n if (!textarea) {\r\n throw new Error('ModuloEditor: missing [data-mo-editor-textarea].');\r\n }\r\n\r\n return {\r\n root,\r\n header: header ?? null,\r\n toolbar: toolbar ?? null,\r\n body: body ?? null,\r\n input,\r\n preview,\r\n footer: footer ?? null,\r\n status: status ?? null,\r\n textarea\r\n };\r\n }\r\n\r\n /**\r\n * Finds a DOM element using the data-mo-editor-* convention.\r\n *\r\n * @param root - Root element\r\n * @param attributeName - Slot name\r\n */\r\n private getDataAttribute<T extends HTMLElement>(\r\n root: HTMLElement,\r\n attributeName: string\r\n ): T | null {\r\n const prefix = 'data-mo-editor';\r\n const selector = `[${prefix}-${attributeName}]`;\r\n\r\n return root.querySelector<T>(selector);\r\n }\r\n}","import type {EditorDocument} from \"./contracts\";\r\n\r\n/**\r\n * Default implementation of EditorDocument.\r\n */\r\nexport class DefaultEditorDocument implements EditorDocument {\r\n private content: string;\r\n\r\n public constructor(content: string = \"\") {\r\n this.content = content;\r\n }\r\n\r\n public getRawContent(): string {\r\n return this.content;\r\n }\r\n\r\n public setRawContent(content: string): void {\r\n this.content = content;\r\n }\r\n}","import type {BuiltinCommandName} from \"./builtin-command-names\";\r\nimport type {EditorCommand} from \"../contracts\";\r\nimport {EditorCommandRegistry} from \"../registry\";\r\nimport {resolveBuiltinCommands} from \"./resolveBuiltinCommands\";\r\nimport {assertCustomCommandsAreValid} from \"./assertCustomCommandsAreValid\";\r\n\r\n/**\r\n * Options used to configure editor commands.\r\n */\r\nexport interface SetupEditorCommandsOptions {\r\n /**\r\n * Controls which builtin commands are enabled.\r\n *\r\n * - true / undefined → enable all builtin commands\r\n * - false → disable all builtin commands\r\n * - string[] → enable only specified builtin commands\r\n */\r\n readonly builtinCommands?: boolean | readonly BuiltinCommandName[];\r\n\r\n /**\r\n * Custom commands provided by the user.\r\n */\r\n readonly commands?: readonly EditorCommand[];\r\n}\r\n\r\n/**\r\n * Registers builtin and custom commands into the registry.\r\n *\r\n * This function:\r\n * - resolves builtin commands\r\n * - validates custom commands\r\n * - registers commands in the correct order\r\n */\r\nexport function setupEditorCommands(\r\n registry: EditorCommandRegistry,\r\n options: SetupEditorCommandsOptions\r\n): void {\r\n /**\r\n * Resolve builtin commands based on configuration.\r\n */\r\n const builtinCommands = resolveBuiltinCommands(options.builtinCommands);\r\n\r\n /**\r\n * Custom commands defined by the user.\r\n */\r\n const customCommands = options.commands ?? [];\r\n\r\n /**\r\n * Validate custom commands.\r\n * This prevents overriding builtin commands\r\n * and duplicate custom commands.\r\n */\r\n assertCustomCommandsAreValid(customCommands);\r\n\r\n /**\r\n * Register builtin commands first.\r\n */\r\n for (const command of builtinCommands) {\r\n registry.register(command);\r\n }\r\n\r\n /**\r\n * Register custom commands.\r\n */\r\n for (const command of customCommands) {\r\n registry.register(command);\r\n }\r\n}","import type {EditorInputAdapter} from \"./EditorInputAdapter\";\r\nimport type {EditorInputState} from \"./EditorInputState\";\r\n\r\nexport class TextareaInputAdapter implements EditorInputAdapter {\r\n private textarea: HTMLTextAreaElement | null = null;\r\n private listeners: Array<(value: string) => void> = [];\r\n\r\n public mount(element: HTMLElement, initialValue: string): void {\r\n const textarea = document.createElement('textarea');\r\n\r\n this.setTextareaAttributes(textarea, initialValue);\r\n\r\n textarea.addEventListener('input', () => {\r\n const value = textarea.value;\r\n\r\n this.listeners.forEach((listener) => {\r\n listener(value);\r\n });\r\n });\r\n\r\n element.appendChild(textarea);\r\n\r\n this.textarea = textarea;\r\n }\r\n\r\n public getState(): EditorInputState {\r\n const element = this.getElement();\r\n\r\n return {\r\n value: element.value,\r\n selectionStart: element.selectionStart ?? 0,\r\n selectionEnd: element.selectionEnd ?? 0\r\n }\r\n }\r\n\r\n public setSelection(start: number, end: number): void {\r\n this.getElement().setSelectionRange(start, end);\r\n }\r\n\r\n public getValue(): string {\r\n return this.textarea?.value ?? '';\r\n }\r\n\r\n public setValue(value: string): void {\r\n if (!this.textarea) {\r\n return;\r\n }\r\n\r\n this.textarea.value = value;\r\n }\r\n\r\n public focus(): void {\r\n this.textarea?.focus();\r\n }\r\n\r\n public onChange(listener: (value: string) => void): () => void {\r\n this.listeners.push(listener);\r\n\r\n return () => {\r\n this.listeners = this.listeners.filter(\r\n (l) => l !== listener\r\n );\r\n };\r\n }\r\n\r\n public destroy(): void {\r\n this.textarea?.remove();\r\n this.textarea = null;\r\n this.listeners = [];\r\n }\r\n\r\n private generateId(): string {\r\n return `mo-editor-${Math.random().toString(36).slice(2)}`;\r\n }\r\n\r\n private setTextareaAttributes(\r\n textarea: HTMLTextAreaElement,\r\n initialValue: string\r\n ): void {\r\n textarea.id = this.generateId();\r\n textarea.className = 'mo-editor__textarea';\r\n textarea.value = initialValue;\r\n textarea.spellcheck = false;\r\n textarea.ariaLabel = 'Markdown editor';\r\n }\r\n\r\n private getElement(): HTMLTextAreaElement {\r\n if (!this.textarea) {\r\n throw new Error(\"Textarea input adapter is not mounted.\");\r\n }\r\n\r\n return this.textarea;\r\n }\r\n}","import type {EditorOutputAdapter} from \"./EditorOutputAdapter\";\r\n\r\n/**\r\n * Default output adapter that renders HTML inside a preview container.\r\n */\r\nexport class HtmlPreviewAdapter implements EditorOutputAdapter {\r\n private element: HTMLElement | null = null;\r\n\r\n /**\r\n * Attaches the adapter to a preview container.\r\n */\r\n public mount(element: HTMLElement):void {\r\n this.element = element;\r\n }\r\n\r\n /**\r\n * Renders HTML inside the mounted preview container.\r\n */\r\n public render(html: string) {\r\n if (!this.element) {\r\n return;\r\n }\r\n\r\n this.element.innerHTML = html;\r\n }\r\n\r\n /**\r\n * Clears the mounted element reference.\r\n */\r\n public destroy(): void {\r\n if (this.element) {\r\n this.element.innerHTML = '';\r\n }\r\n\r\n this.element = null;\r\n }\r\n}","import type {TextareaBridge} from \"./TextareaBridge\";\r\n\r\n/**\r\n * Default textarea bridge implementation.\r\n */\r\nexport class HiddenTextareaBridge implements TextareaBridge {\r\n private textarea: HTMLTextAreaElement | null = null;\r\n\r\n public mount(textarea: HTMLTextAreaElement): void {\r\n this.textarea = textarea;\r\n }\r\n\r\n public getValue(): string {\r\n return this.textarea?.value ?? '';\r\n }\r\n\r\n public setValue(value: string): void {\r\n if (!this.textarea) {\r\n return;\r\n }\r\n\r\n this.textarea.value = value;\r\n }\r\n\r\n public destroy(): void {\r\n this.textarea = null;\r\n }\r\n}","import type {\r\n EditorPlugin,\r\n EditorPluginApi\r\n} from \"../../contracts\";\r\nimport type {CommandButtonPluginOptions} from \"./CommandButtonPluginOptions\";\r\n\r\n/**\r\n * Generic toolbar plugin responsible for rendering\r\n * a button that executes a command.\r\n */\r\nexport class CommandButtonPlugin implements EditorPlugin {\r\n public readonly name: string;\r\n\r\n private readonly commandName: string;\r\n private readonly content: string | HTMLElement | (() => HTMLElement);\r\n\r\n private button: HTMLButtonElement | null = null;\r\n private api: EditorPluginApi | null = null;\r\n\r\n public constructor(options: CommandButtonPluginOptions) {\r\n this.name = options.pluginName;\r\n this.commandName = options.commandName;\r\n this.content = options.content;\r\n }\r\n\r\n /**\r\n * Mounts the button and binds click interaction.\r\n */\r\n public setup(api: EditorPluginApi):void {\r\n const toolbar = api.slots.toolbar;\r\n\r\n if (!toolbar) {\r\n return;\r\n }\r\n\r\n this.api = api;\r\n\r\n const button = document.createElement(\"button\");\r\n button.type = \"button\";\r\n\r\n this.renderButtonContent(button);\r\n\r\n button.addEventListener(\"click\", this.handleClick);\r\n\r\n toolbar.appendChild(button);\r\n this.button = button;\r\n }\r\n\r\n /**\r\n * Removes the button and cleans up listeners.\r\n */\r\n public destroy(): void {\r\n if (this.button) {\r\n this.button.removeEventListener(\"click\", this.handleClick);\r\n this.button.remove();\r\n this.button = null;\r\n }\r\n\r\n this.api = null;\r\n }\r\n\r\n /**\r\n * Renders the configured button content.\r\n */\r\n private renderButtonContent(button: HTMLButtonElement): void {\r\n const content =\r\n typeof this.content === \"function\"\r\n ? this.content()\r\n : this.content;\r\n\r\n if (typeof content === \"string\") {\r\n button.textContent = content;\r\n\r\n return;\r\n }\r\n\r\n button.appendChild(content);\r\n }\r\n\r\n /**\r\n * Executes the configured command when available.\r\n */\r\n private readonly handleClick = (): void => {\r\n if (!this.api?.commands.has(this.commandName)) {\r\n return;\r\n }\r\n\r\n this.api.executeCommand(this.commandName);\r\n };\r\n}","import {CommandButtonPlugin} from \"../base\";\r\n\r\n/**\r\n * Toolbar plugin rendering a button for the bold command.\r\n */\r\nexport class BoldToolbarPlugin extends CommandButtonPlugin {\r\n public constructor() {\r\n super({\r\n pluginName: \"toolbar-bold\",\r\n commandName: \"bold\",\r\n content: \"Bold\",\r\n });\r\n }\r\n}","import {CommandButtonPlugin} from \"../base\";\r\n\r\nexport class ItalicToolbarPlugin extends CommandButtonPlugin {\r\n public constructor() {\r\n super({\r\n pluginName: \"toolbar-italic\",\r\n commandName: \"italic\",\r\n content: \"Italic\",\r\n });\r\n }\r\n}","import {CommandButtonPlugin} from \"../base\";\r\n\r\nexport class HeadingToolbarPlugin extends CommandButtonPlugin {\r\n public constructor(level: number) {\r\n super({\r\n pluginName: `toolbar-heading-${level}`,\r\n commandName: `heading-${level}`,\r\n content: `H${level}`,\r\n });\r\n }\r\n}","import type {EditorPlugin} from \"../contracts\";\r\nimport {\r\n BoldToolbarPlugin,\r\n HeadingToolbarPlugin,\r\n ItalicToolbarPlugin\r\n} from \"./buttons\";\r\n\r\n\r\nexport type ToolbarPresetOptions = {\r\n headings?: number[];\r\n};\r\n\r\nexport function createDefaultToolbarPlugins(\r\n options: ToolbarPresetOptions = {}\r\n): readonly EditorPlugin[] {\r\n const { headings = [1, 2, 3] } = options;\r\n\r\n return [\r\n new BoldToolbarPlugin(),\r\n new ItalicToolbarPlugin(),\r\n ...headings.map(level => new HeadingToolbarPlugin(level)),\r\n ];\r\n}","import type {HtmlSanitizerConfig} from \"./HtmlSanitizerConfig\";\r\n\r\n/**\r\n * Default strict sanitizer configuration.\r\n */\r\nexport const DEFAULT_HTML_SANITIZER_CONFIG: HtmlSanitizerConfig = {\r\n allowedTags: [\r\n 'p',\r\n 'strong',\r\n 'em',\r\n 'code',\r\n 'pre',\r\n 'ul',\r\n 'ol',\r\n 'li',\r\n 'blockquote',\r\n 'a'\r\n ],\r\n allowedAttributes: {\r\n a: ['href', 'title']\r\n }\r\n}","import type {MarkdownParser} from \"../contracts\";\r\n\r\n/**\r\n * Temporary Markdown parser used for development.\r\n *\r\n * This implementation does not parse real Markdown yet.\r\n * It simply wraps text inside a paragraph.\r\n */\r\nexport class PlainTextMarkdownParser implements MarkdownParser {\r\n public parse(markdown: string): string {\r\n const p = document.createElement(\"p\");\r\n p.textContent = markdown;\r\n return p.outerHTML;\r\n }\r\n}","import type {\r\n HtmlSanitizer,\r\n MarkdownParser,\r\n MarkdownProcessor\r\n} from \"../contracts\";\r\n\r\n/**\r\n * Default Markdown processor implementation.\r\n *\r\n * This class delegates Markdown parsing and HTML sanitization\r\n * to dedicated abstractions and keeps those concerns outside\r\n * the editor core.\r\n */\r\nexport class DefaultMarkdownProcessor implements MarkdownProcessor {\r\n private readonly parser: MarkdownParser;\r\n private readonly sanitize: HtmlSanitizer;\r\n\r\n public constructor(\r\n parser: MarkdownParser,\r\n sanitize: HtmlSanitizer\r\n ) {\r\n this.parser = parser;\r\n this.sanitize = sanitize;\r\n }\r\n\r\n /**\r\n * Converts Markdown into safe HTML.\r\n */\r\n public toHtml(markdown: string): string {\r\n const unsafeHTML = this.parser.parse(markdown);\r\n\r\n return this.sanitize.sanitize(unsafeHTML);\r\n }\r\n}","/*! @license DOMPurify 3.3.3 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.3/LICENSE */\n\nconst {\n entries,\n setPrototypeOf,\n isFrozen,\n getPrototypeOf,\n getOwnPropertyDescriptor\n} = Object;\nlet {\n freeze,\n seal,\n create\n} = Object; // eslint-disable-line import/no-mutable-exports\nlet {\n apply,\n construct\n} = typeof Reflect !== 'undefined' && Reflect;\nif (!freeze) {\n freeze = function freeze(x) {\n return x;\n };\n}\nif (!seal) {\n seal = function seal(x) {\n return x;\n };\n}\nif (!apply) {\n apply = function apply(func, thisArg) {\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n return func.apply(thisArg, args);\n };\n}\nif (!construct) {\n construct = function construct(Func) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return new Func(...args);\n };\n}\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySplice = unapply(Array.prototype.splice);\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\nconst regExpTest = unapply(RegExp.prototype.test);\nconst typeErrorCreate = unconstruct(TypeError);\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param func - The function to be wrapped and called.\n * @returns A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return function (thisArg) {\n if (thisArg instanceof RegExp) {\n thisArg.lastIndex = 0;\n }\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n return apply(func, thisArg, args);\n };\n}\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param func - The constructor function to be wrapped and called.\n * @returns A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(Func) {\n return function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return construct(Func, args);\n };\n}\n/**\n * Add properties to a lookup table\n *\n * @param set - The set to which elements will be added.\n * @param array - The array containing elements to be added to the set.\n * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns The modified set with added elements.\n */\nfunction addToSet(set, array) {\n let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n element = lcElement;\n }\n }\n set[element] = true;\n }\n return set;\n}\n/**\n * Clean up an array to harden against CSPP\n *\n * @param array - The array to be cleaned.\n * @returns The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n return array;\n}\n/**\n * Shallow clone an object\n *\n * @param object - The object to be cloned.\n * @returns A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n for (const [property, value] of entries(object)) {\n const isPropertyExist = objectHasOwnProperty(object, property);\n if (isPropertyExist) {\n if (Array.isArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (value && typeof value === 'object' && value.constructor === Object) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n return newObject;\n}\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param object - The object to look up the getter function in its prototype chain.\n * @param prop - The property name for which to find the getter function.\n * @returns The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n object = getPrototypeOf(object);\n }\n function fallbackValue() {\n return null;\n }\n return fallbackValue;\n}\n\nconst html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);\nconst svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);\nconst svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nconst svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);\nconst mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nconst mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);\nconst text = freeze(['#text']);\n\nconst html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns', 'slot']);\nconst svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);\nconst mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnsalign', 'columnlines', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lspace', 'lquote', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);\nconst xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);\n\n// eslint-disable-next-line unicorn/better-regex\nconst MUSTACHE_EXPR = seal(/\\{\\{[\\w\\W]*|[\\w\\W]*\\}\\}/gm); // Specify template detection regex for SAFE_FOR_TEMPLATES mode\nconst ERB_EXPR = seal(/<%[\\w\\W]*|[\\w\\W]*%>/gm);\nconst TMPLIT_EXPR = seal(/\\$\\{[\\w\\W]*/gm); // eslint-disable-line unicorn/better-regex\nconst DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/); // eslint-disable-line no-useless-escape\nconst ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nconst IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nconst IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nconst ATTR_WHITESPACE = seal(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nconst DOCTYPE_NAME = seal(/^html$/i);\nconst CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n\nvar EXPRESSIONS = /*#__PURE__*/Object.freeze({\n __proto__: null,\n ARIA_ATTR: ARIA_ATTR,\n ATTR_WHITESPACE: ATTR_WHITESPACE,\n CUSTOM_ELEMENT: CUSTOM_ELEMENT,\n DATA_ATTR: DATA_ATTR,\n DOCTYPE_NAME: DOCTYPE_NAME,\n ERB_EXPR: ERB_EXPR,\n IS_ALLOWED_URI: IS_ALLOWED_URI,\n IS_SCRIPT_OR_DATA: IS_SCRIPT_OR_DATA,\n MUSTACHE_EXPR: MUSTACHE_EXPR,\n TMPLIT_EXPR: TMPLIT_EXPR\n});\n\n/* eslint-disable @typescript-eslint/indent */\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5,\n // Deprecated\n entityNode: 6,\n // Deprecated\n progressingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12 // Deprecated\n};\nconst getGlobal = function getGlobal() {\n return typeof window === 'undefined' ? null : window;\n};\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param trustedTypes The policy factory.\n * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {\n if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {\n return null;\n }\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n }\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn('TrustedTypes policy ' + policyName + ' could not be created.');\n return null;\n }\n};\nconst _createHooksMap = function _createHooksMap() {\n return {\n afterSanitizeAttributes: [],\n afterSanitizeElements: [],\n afterSanitizeShadowDOM: [],\n beforeSanitizeAttributes: [],\n beforeSanitizeElements: [],\n beforeSanitizeShadowDOM: [],\n uponSanitizeAttribute: [],\n uponSanitizeElement: [],\n uponSanitizeShadowNode: []\n };\n};\nfunction createDOMPurify() {\n let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();\n const DOMPurify = root => createDOMPurify(root);\n DOMPurify.version = '3.3.3';\n DOMPurify.removed = [];\n if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n return DOMPurify;\n }\n let {\n document\n } = window;\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n const {\n DocumentFragment,\n HTMLTemplateElement,\n Node,\n Element,\n NodeFilter,\n NamedNodeMap = window.NamedNodeMap || window.MozNamedAttrMap,\n HTMLFormElement,\n DOMParser,\n trustedTypes\n } = window;\n const ElementPrototype = Element.prototype;\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n let trustedTypesPolicy;\n let emptyHTML = '';\n const {\n implementation,\n createNodeIterator,\n createDocumentFragment,\n getElementsByTagName\n } = document;\n const {\n importNode\n } = originalDocument;\n let hooks = _createHooksMap();\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;\n const {\n MUSTACHE_EXPR,\n ERB_EXPR,\n TMPLIT_EXPR,\n DATA_ATTR,\n ARIA_ATTR,\n IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE,\n CUSTOM_ELEMENT\n } = EXPRESSIONS;\n let {\n IS_ALLOWED_URI: IS_ALLOWED_URI$1\n } = EXPRESSIONS;\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);\n /*\n * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false\n }\n }));\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */\n const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {\n tagCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n }\n }));\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n /* Decide if document with <html>... should be returned */\n let WHOLE_DOCUMENT = false;\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);\n let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, ['mi', 'mo', 'mn', 'ms', 'mtext']);\n let HTML_INTEGRATION_POINTS = addToSet({}, ['annotation-xml']);\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n const formElement = document.createElement('form');\n const isRegexOrFunction = function isRegexOrFunction(testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n /**\n * _parseConfig\n *\n * @param cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function _parseConfig() {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;\n /* Set configuration parameters */\n ALLOWED_TAGS = objectHasOwnProperty(cfg, 'ALLOWED_TAGS') ? addToSet({}, cfg.ALLOWED_TAGS, transformCaseFunc) : DEFAULT_ALLOWED_TAGS;\n ALLOWED_ATTR = objectHasOwnProperty(cfg, 'ALLOWED_ATTR') ? addToSet({}, cfg.ALLOWED_ATTR, transformCaseFunc) : DEFAULT_ALLOWED_ATTR;\n ALLOWED_NAMESPACES = objectHasOwnProperty(cfg, 'ALLOWED_NAMESPACES') ? addToSet({}, cfg.ALLOWED_NAMESPACES, stringToString) : DEFAULT_ALLOWED_NAMESPACES;\n URI_SAFE_ATTRIBUTES = objectHasOwnProperty(cfg, 'ADD_URI_SAFE_ATTR') ? addToSet(clone(DEFAULT_URI_SAFE_ATTRIBUTES), cfg.ADD_URI_SAFE_ATTR, transformCaseFunc) : DEFAULT_URI_SAFE_ATTRIBUTES;\n DATA_URI_TAGS = objectHasOwnProperty(cfg, 'ADD_DATA_URI_TAGS') ? addToSet(clone(DEFAULT_DATA_URI_TAGS), cfg.ADD_DATA_URI_TAGS, transformCaseFunc) : DEFAULT_DATA_URI_TAGS;\n FORBID_CONTENTS = objectHasOwnProperty(cfg, 'FORBID_CONTENTS') ? addToSet({}, cfg.FORBID_CONTENTS, transformCaseFunc) : DEFAULT_FORBID_CONTENTS;\n FORBID_TAGS = objectHasOwnProperty(cfg, 'FORBID_TAGS') ? addToSet({}, cfg.FORBID_TAGS, transformCaseFunc) : clone({});\n FORBID_ATTR = objectHasOwnProperty(cfg, 'FORBID_ATTR') ? addToSet({}, cfg.FORBID_ATTR, transformCaseFunc) : clone({});\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI$1 = cfg.ALLOWED_URI_REGEXP || IS_ALLOWED_URI;\n NAMESPACE = cfg.NAMESPACE || HTML_NAMESPACE;\n MATHML_TEXT_INTEGRATION_POINTS = cfg.MATHML_TEXT_INTEGRATION_POINTS || MATHML_TEXT_INTEGRATION_POINTS;\n HTML_INTEGRATION_POINTS = cfg.HTML_INTEGRATION_POINTS || HTML_INTEGRATION_POINTS;\n CUSTOM_ELEMENT_HANDLING = cfg.CUSTOM_ELEMENT_HANDLING || {};\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.tagNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && isRegexOrFunction(cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck = cfg.CUSTOM_ELEMENT_HANDLING.attributeNameCheck;\n }\n if (cfg.CUSTOM_ELEMENT_HANDLING && typeof cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements === 'boolean') {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = cfg.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements;\n }\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, text);\n ALLOWED_ATTR = create(null);\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, html$1);\n addToSet(ALLOWED_ATTR, html);\n }\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, svg$1);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, svgFilters);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, mathMl$1);\n addToSet(ALLOWED_ATTR, mathMl);\n addToSet(ALLOWED_ATTR, xml);\n }\n }\n /* Prevent function-based ADD_ATTR / ADD_TAGS from leaking across calls */\n if (!objectHasOwnProperty(cfg, 'ADD_TAGS')) {\n EXTRA_ELEMENT_HANDLING.tagCheck = null;\n }\n if (!objectHasOwnProperty(cfg, 'ADD_ATTR')) {\n EXTRA_ELEMENT_HANDLING.attributeCheck = null;\n }\n /* Merge configuration parameters */\n if (cfg.ADD_TAGS) {\n if (typeof cfg.ADD_TAGS === 'function') {\n EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;\n } else {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n }\n if (cfg.ADD_ATTR) {\n if (typeof cfg.ADD_ATTR === 'function') {\n EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;\n } else {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n }\n if (cfg.ADD_URI_SAFE_ATTR) {\n addToSet(URI_SAFE_ATTRIBUTES, cfg.ADD_URI_SAFE_ATTR, transformCaseFunc);\n }\n if (cfg.FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.FORBID_CONTENTS, transformCaseFunc);\n }\n if (cfg.ADD_FORBID_CONTENTS) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);\n }\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');\n }\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');\n }\n // Overwrite existing TrustedTypes policy.\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n // Sign local variables required by `sanitize`.\n emptyHTML = trustedTypesPolicy.createHTML('');\n } else {\n // Uninitialized policy, attempt to initialize the internal dompurify policy.\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);\n }\n // If creating the internal policy succeeded sign internal variables.\n if (trustedTypesPolicy !== null && typeof emptyHTML === 'string') {\n emptyHTML = trustedTypesPolicy.createHTML('');\n }\n }\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n CONFIG = cfg;\n };\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);\n const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);\n /**\n * @param element a DOM element whose namespace is being checked\n * @returns Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function _checkValidNamespace(element) {\n let parent = getParentNode(element);\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template'\n };\n }\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n if (element.namespaceURI === SVG_NAMESPACE) {\n // The only way to switch from HTML namespace to SVG\n // is via <svg>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n // The only way to switch from MathML to SVG is via`\n // svg if parent is either <annotation-xml> or MathML\n // text integration points.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);\n }\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n }\n if (element.namespaceURI === MATHML_NAMESPACE) {\n // The only way to switch from HTML namespace to MathML\n // is via <math>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n // The only way to switch from SVG to MathML is via\n // <math> and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n }\n if (element.namespaceURI === HTML_NAMESPACE) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);\n }\n // For XHTML and XML documents that support custom namespaces\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {\n return true;\n }\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n /**\n * _forceRemove\n *\n * @param node a DOM node\n */\n const _forceRemove = function _forceRemove(node) {\n arrayPush(DOMPurify.removed, {\n element: node\n });\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n remove(node);\n }\n };\n /**\n * _removeAttribute\n *\n * @param name an Attribute name\n * @param element a DOM node\n */\n const _removeAttribute = function _removeAttribute(name, element) {\n try {\n arrayPush(DOMPurify.removed, {\n attribute: element.getAttributeNode(name),\n from: element\n });\n } catch (_) {\n arrayPush(DOMPurify.removed, {\n attribute: null,\n from: element\n });\n }\n element.removeAttribute(name);\n // We void attribute values for unremovable \"is\" attributes\n if (name === 'is') {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(element);\n } catch (_) {}\n } else {\n try {\n element.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n /**\n * _initDocument\n *\n * @param dirty - a string of dirty markup\n * @return a DOM, filled with the dirty markup\n */\n const _initDocument = function _initDocument(dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n if (FORCE_BODY) {\n dirty = '<remove></remove>' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty = '<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>' + dirty + '</body></html>';\n }\n const dirtyPayload = trustedTypesPolicy ? trustedTypesPolicy.createHTML(dirty) : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n const body = doc.body || doc.documentElement;\n if (dirty && leadingWhitespace) {\n body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);\n }\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];\n }\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param root The root element or node to start traversing on.\n * @return The created NodeIterator\n */\n const _createNodeIterator = function _createNodeIterator(root) {\n return createNodeIterator.call(root.ownerDocument || root, root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);\n };\n /**\n * _isClobbered\n *\n * @param element element to check for clobbering attacks\n * @return true if clobbered, false if safe\n */\n const _isClobbered = function _isClobbered(element) {\n return element instanceof HTMLFormElement && (typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' || !(element.attributes instanceof NamedNodeMap) || typeof element.removeAttribute !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function');\n };\n /**\n * Checks whether the given object is a DOM node.\n *\n * @param value object to check whether it's a DOM node\n * @return true is object is a DOM node\n */\n const _isNode = function _isNode(value) {\n return typeof Node === 'function' && value instanceof Node;\n };\n function _executeHooks(hooks, currentNode, data) {\n arrayForEach(hooks, hook => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n }\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n * @param currentNode to check for permission to exist\n * @return true if node was killed, false if left alive\n */\n const _sanitizeElements = function _sanitizeElements(currentNode) {\n let content = null;\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeElements, currentNode, null);\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(currentNode.nodeName);\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeElement, currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS\n });\n /* Detect mXSS attempts abusing namespace confusion */\n if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(/<[/\\w!]/g, currentNode.innerHTML) && regExpTest(/<[/\\w!]/g, currentNode.textContent)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.progressingInstruction) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove any kind of possibly harmful comments */\n if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(/<[/\\w]/g, currentNode.data)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove element if anything forbids its presence */\n if (!(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName])) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName)) {\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {\n return false;\n }\n if (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(tagName)) {\n return false;\n }\n }\n /* Keep content except for bad-listed elements */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode) || currentNode.parentNode;\n const childNodes = getChildNodes(currentNode) || currentNode.childNodes;\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n for (let i = childCount - 1; i >= 0; --i) {\n const childClone = cloneNode(childNodes[i], true);\n childClone.__removalCount = (currentNode.__removalCount || 0) + 1;\n parentNode.insertBefore(childClone, getNextSibling(currentNode));\n }\n }\n }\n _forceRemove(currentNode);\n return true;\n }\n /* Check whether element has a valid namespace */\n if (currentNode instanceof Element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(/<\\/no(script|embed|frames)/i, currentNode.innerHTML)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n content = currentNode.textContent;\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n content = stringReplace(content, expr, ' ');\n });\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, {\n element: currentNode.cloneNode()\n });\n currentNode.textContent = content;\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n return false;\n };\n /**\n * _isValidAttribute\n *\n * @param lcTag Lowercase tag name of containing element.\n * @param lcName Lowercase attribute name.\n * @param value Attribute value.\n * @return Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {\n /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */\n if (FORBID_ATTR[lcName]) {\n return false;\n }\n /* Make sure attribute cannot clobber */\n if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {\n return false;\n }\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (ALLOW_DATA_ATTR && !FORBID_ATTR[lcName] && regExpTest(DATA_ATTR, lcName)) ; else if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR, lcName)) ; else if (EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag)) ; else if (!ALLOWED_ATTR[lcName] || FORBID_ATTR[lcName]) {\n if (\n // First condition does a very basic check if a) it's basically a valid custom element tagname AND\n // b) if the tagName passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n // and c) if the attribute name passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.attributeNameCheck\n _isBasicCustomElement(lcTag) && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(lcTag)) && (CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName) || CUSTOM_ELEMENT_HANDLING.attributeNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.attributeNameCheck(lcName, lcTag)) ||\n // Alternative, second condition checks if it's an `is`-attribute, AND\n // the value passes whatever the user has configured for CUSTOM_ELEMENT_HANDLING.tagNameCheck\n lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && (CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof RegExp && regExpTest(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value) || CUSTOM_ELEMENT_HANDLING.tagNameCheck instanceof Function && CUSTOM_ELEMENT_HANDLING.tagNameCheck(value))) ; else {\n return false;\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n } else if (URI_SAFE_ATTRIBUTES[lcName]) ; else if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) ; else if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA, stringReplace(value, ATTR_WHITESPACE, ''))) ; else if (value) {\n return false;\n } else ;\n return true;\n };\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param tagName name of the tag of the node to sanitize\n * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function _isBasicCustomElement(tagName) {\n return tagName !== 'annotation-xml' && stringMatch(tagName, CUSTOM_ELEMENT);\n };\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param currentNode to sanitize\n */\n const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);\n const {\n attributes\n } = currentNode;\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes || _isClobbered(currentNode)) {\n return;\n }\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n forceKeepAttr: undefined\n };\n let l = attributes.length;\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const {\n name,\n namespaceURI,\n value: attrValue\n } = attr;\n const lcName = transformCaseFunc(name);\n const initValue = attrValue;\n let value = name === 'value' ? initValue : stringTrim(initValue);\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);\n value = hookEvent.attrValue;\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name')) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode);\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n }\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Make sure we cannot easily use animated hrefs, even if animations are allowed */\n if (lcName === 'attributename' && stringMatch(value, 'href')) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(/\\/>/i, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n value = stringReplace(value, expr, ' ');\n });\n }\n /* Is `value` valid for this attribute? */\n const lcTag = transformCaseFunc(currentNode.nodeName);\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode);\n continue;\n }\n /* Handle attributes that require Trusted Types */\n if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function') {\n if (namespaceURI) ; else {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML':\n {\n value = trustedTypesPolicy.createHTML(value);\n break;\n }\n case 'TrustedScriptURL':\n {\n value = trustedTypesPolicy.createScriptURL(value);\n break;\n }\n }\n }\n }\n /* Handle invalid data-* attribute set by try-catching it */\n if (value !== initValue) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n } else {\n arrayPop(DOMPurify.removed);\n }\n } catch (_) {\n _removeAttribute(name, currentNode);\n }\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);\n };\n /**\n * _sanitizeShadowDOM\n *\n * @param fragment to iterate over recursively\n */\n const _sanitizeShadowDOM = function _sanitizeShadowDOM(fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);\n while (shadowNode = shadowIterator.nextNode()) {\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);\n /* Sanitize tags and elements */\n _sanitizeElements(shadowNode);\n /* Check attributes next */\n _sanitizeAttributes(shadowNode);\n /* Deep shadow DOM detected */\n if (shadowNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(shadowNode.content);\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);\n };\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty) {\n let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '<!-->';\n }\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n if (typeof dirty.toString === 'function') {\n dirty = dirty.toString();\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n } else {\n throw typeErrorCreate('toString is not a function');\n }\n }\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n /* Assign config vars */\n if (!SET_CONFIG) {\n _parseConfig(cfg);\n }\n /* Clean up removed elements */\n DOMPurify.removed = [];\n /* Check if dirty is correctly typed for IN_PLACE */\n if (typeof dirty === 'string') {\n IN_PLACE = false;\n }\n if (IN_PLACE) {\n /* Do some early pre-sanitization to avoid unsafe root nodes */\n if (dirty.nodeName) {\n const tagName = transformCaseFunc(dirty.nodeName);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');\n }\n }\n } else if (dirty instanceof Node) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('<!---->');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n } else {\n /* Exit directly if we have nothing to do */\n if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(dirty) : dirty;\n }\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n /* Get node iterator */\n const nodeIterator = _createNodeIterator(IN_PLACE ? dirty : body);\n /* Now start iterating over the created document */\n while (currentNode = nodeIterator.nextNode()) {\n /* Sanitize tags and elements */\n _sanitizeElements(currentNode);\n /* Check attributes next */\n _sanitizeAttributes(currentNode);\n /* Shadow DOM detected, sanitize it */\n if (currentNode.content instanceof DocumentFragment) {\n _sanitizeShadowDOM(currentNode.content);\n }\n }\n /* If we sanitized `dirty` in-place, return it. */\n if (IN_PLACE) {\n return dirty;\n }\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n return returnNode;\n }\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n /* Serialize doctype if allowed */\n if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {\n serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\\n' + serializedHTML;\n }\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n arrayForEach([MUSTACHE_EXPR, ERB_EXPR, TMPLIT_EXPR], expr => {\n serializedHTML = stringReplace(serializedHTML, expr, ' ');\n });\n }\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? trustedTypesPolicy.createHTML(serializedHTML) : serializedHTML;\n };\n DOMPurify.setConfig = function () {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _parseConfig(cfg);\n SET_CONFIG = true;\n };\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n };\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n arrayPush(hooks[entryPoint], hookFunction);\n };\n DOMPurify.removeHook = function (entryPoint, hookFunction) {\n if (hookFunction !== undefined) {\n const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);\n return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];\n }\n return arrayPop(hooks[entryPoint]);\n };\n DOMPurify.removeHooks = function (entryPoint) {\n hooks[entryPoint] = [];\n };\n DOMPurify.removeAllHooks = function () {\n hooks = _createHooksMap();\n };\n return DOMPurify;\n}\nvar purify = createDOMPurify();\n\nexport { purify as default };\n//# sourceMappingURL=purify.es.mjs.map\n","import type {HtmlSanitizer} from \"../contracts\";\r\nimport type {HtmlSanitizerConfig} from \"../config\";\r\n\r\nimport DOMPurify from \"dompurify\";\r\n\r\n/**\r\n * HTML sanitizer implementation backed by DOMPurify.\r\n *\r\n * This class is isolated from the editor core and is only responsible\r\n * for transforming unsafe HTML into safe HTML according to the provided\r\n * configuration.\r\n */\r\nexport class DomPurifyHtmlSanitizer implements HtmlSanitizer {\r\n private readonly config: HtmlSanitizerConfig;\r\n\r\n public constructor(config: HtmlSanitizerConfig) {\r\n this.config = config;\r\n }\r\n\r\n /**\r\n * Sanitizes raw HTML output.\r\n *\r\n * @param html - Raw HTML string\r\n */\r\n public sanitize(html: string): string {\r\n return DOMPurify.sanitize(html, {\r\n USE_PROFILES: {html: true},\r\n ALLOWED_TAGS: this.config.allowedTags\r\n ? [...this.config.allowedTags]\r\n : undefined,\r\n ALLOWED_ATTR: this.flattenAllowedAttributes(this.config)\r\n });\r\n }\r\n\r\n /**\r\n * Flattens per-tag allowed attributes into a DOMPurify-compatible list.\r\n *\r\n * DOMPurify's ALLOWED_ATTR is global, so this is a first clean step.\r\n * If you later want stricter per-tag control, you can move to hooks.\r\n */\r\n private flattenAllowedAttributes(\r\n config: HtmlSanitizerConfig\r\n ): string[] | undefined {\r\n if (!config.allowedAttributes) {\r\n return undefined;\r\n }\r\n\r\n const attributes = new Set<string>();\r\n\r\n Object.values(config.allowedAttributes).forEach((names) => {\r\n names.forEach((name) => {\r\n attributes.add(name);\r\n })\r\n });\r\n\r\n return [...attributes];\r\n }\r\n}","import { ModuloEditor } from \"../ModuloEditor\";\r\nimport type { EditorPlugin } from \"../../plugins\";\r\n\r\nimport { DefaultEditorDomResolver } from \"../../dom\";\r\nimport { TextareaInputAdapter } from \"../../input\";\r\nimport { HtmlPreviewAdapter } from \"../../output\";\r\nimport { HiddenTextareaBridge } from \"../../textarea\";\r\nimport { createDefaultToolbarPlugins } from \"../../plugins\";\r\n\r\nimport {\r\n DEFAULT_HTML_SANITIZER_CONFIG,\r\n DefaultMarkdownProcessor,\r\n DomPurifyHtmlSanitizer,\r\n PlainTextMarkdownParser\r\n} from \"../../markdown\";\r\nimport type {ModuloEditorBuilder} from \"../contracts\";\r\n\r\n/**\r\n * Default fluent builder implementation for ModuloEditor.\r\n *\r\n * This builder provides a high-level API for common editor setups.\r\n * It creates a fully configured editor instance using the default\r\n * DOM resolver, adapters, Markdown processor, sanitizer, textarea bridge,\r\n * and default toolbar plugins.\r\n *\r\n * For advanced and fully manual setups, the `ModuloEditor` constructor\r\n * can still be used directly.\r\n *\r\n * @example\r\n * ```ts\r\n * const editor = ModuloEditor\r\n * .create('[data-mo-editor]')\r\n * .init();\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * const editor = ModuloEditor\r\n * .create('[data-mo-editor]')\r\n * .withoutPlugins()\r\n * .init();\r\n * ```\r\n *\r\n * @example\r\n * ```ts\r\n * const editor = ModuloEditor\r\n * .create('[data-mo-editor]')\r\n * .use(new BoldToolbarPlugin(), new ItalicToolbarPlugin())\r\n * .init();\r\n * ```\r\n */\r\nexport class DefaultModuloEditorBuilder implements ModuloEditorBuilder {\r\n /**\r\n * Optional custom plugins explicitly configured by the user.\r\n *\r\n * - `undefined` means: use default toolbar plugins\r\n * - `false` means: disable all plugins\r\n * - `EditorPlugin[]` means: use the provided plugin list\r\n */\r\n private plugins: EditorPlugin[] | false | undefined;\r\n\r\n /**\r\n * Root editor selector or HTMLElement used to initialize the editor.\r\n */\r\n private readonly root: string | HTMLElement;\r\n\r\n /**\r\n * Indicates whether the builder has already been initialized.\r\n *\r\n * Used to prevent multiple init() calls and configuration changes\r\n * after initialization.\r\n */\r\n private initialized = false;\r\n\r\n /**\r\n * Creates a new builder bound to the provided root selector or element.\r\n *\r\n * @param root CSS selector or root HTMLElement used to resolve the editor DOM.\r\n */\r\n public constructor(root: string | HTMLElement) {\r\n this.root = root;\r\n }\r\n\r\n /**\r\n * Replaces the default plugin list with the provided plugins.\r\n *\r\n * Calling this method disables the automatic default toolbar plugin setup\r\n * and uses only the plugins passed here.\r\n *\r\n * @param plugins Plugins to mount on the editor instance.\r\n *\r\n * @returns The current builder instance.\r\n *\r\n * @throws Error When called after init().\r\n */\r\n public use(...plugins: EditorPlugin[]): this {\r\n this.assertNotInitialized();\r\n\r\n this.plugins = plugins;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Disables all plugins for the editor instance.\r\n *\r\n * @returns The current builder instance.\r\n *\r\n * @throws Error When called after init().\r\n */\r\n public withoutPlugins(): this {\r\n this.assertNotInitialized();\r\n\r\n this.plugins = false;\r\n\r\n return this;\r\n }\r\n\r\n /**\r\n * Builds and initializes a new ModuloEditor instance.\r\n *\r\n * This method resolves the root element, creates all default editor\r\n * dependencies, mounts the configured plugin list, initializes the editor,\r\n * and returns the initialized instance.\r\n *\r\n * @returns The initialized editor instance.\r\n *\r\n * @throws Error When the configured root selector does not match any element.\r\n */\r\n public init(): ModuloEditor {\r\n if (this.initialized) {\r\n throw new Error('ModuloEditorBuilder: already initialized.');\r\n }\r\n\r\n const root = this.resolveRoot(this.root);\r\n const domResolver = new DefaultEditorDomResolver();\r\n\r\n const plugins = this.plugins === false\r\n ? []\r\n : this.plugins ?? createDefaultToolbarPlugins();\r\n\r\n this.initialized = true;\r\n\r\n const editor = new ModuloEditor({\r\n root,\r\n domResolver,\r\n input: new TextareaInputAdapter(),\r\n output: new HtmlPreviewAdapter(),\r\n markdown: new DefaultMarkdownProcessor(\r\n new PlainTextMarkdownParser(),\r\n new DomPurifyHtmlSanitizer(DEFAULT_HTML_SANITIZER_CONFIG)\r\n ),\r\n textareaBridge: new HiddenTextareaBridge(),\r\n plugins,\r\n });\r\n\r\n editor.init();\r\n\r\n return editor;\r\n }\r\n\r\n /**\r\n * Resolves the configured root into a concrete HTMLElement.\r\n *\r\n * When a selector string is provided, the element is queried from the DOM.\r\n * When an HTMLElement is provided directly, it is returned as-is.\r\n *\r\n * @param root CSS selector or root HTMLElement.\r\n *\r\n * @returns The resolved root HTMLElement.\r\n *\r\n * @throws Error When the selector does not match any HTMLElement.\r\n */\r\n private resolveRoot(root: string | HTMLElement): HTMLElement {\r\n if (typeof root !== \"string\") {\r\n return root;\r\n }\r\n\r\n const element = document.querySelector(root);\r\n\r\n if (!(element instanceof HTMLElement)) {\r\n throw new Error(`ModuloEditor: root element \"${root}\" not found.`);\r\n }\r\n\r\n return element;\r\n }\r\n\r\n /**\r\n * Ensures the builder has not been initialized yet.\r\n *\r\n * @throws Error When a configuration method is called after init().\r\n */\r\n private assertNotInitialized(): void {\r\n if (this.initialized) {\r\n throw new Error(\r\n 'ModuloEditorBuilder: configuration cannot be modified after init().'\r\n );\r\n }\r\n }\r\n}","import type {\r\n EditorDocument,\r\n ModuloEditorBuilder,\r\n ModuloEditorOptions\r\n} from \"./contracts\";\r\nimport type {\r\n EditorPlugin,\r\n EditorPluginApi\r\n} from \"../plugins\";\r\nimport {\r\n type EditorCommandContext,\r\n EditorCommandRegistry,\r\n type EditorCommandsApi,\r\n RegistryEditorCommandsApi\r\n} from \"../commands\";\r\nimport {\r\n DefaultEditorDomResolver,\r\n} from \"../dom\";\r\nimport {DefaultEditorDocument} from \"./DefaultEditorDocument\";\r\nimport {setupEditorCommands} from \"../commands/setup/setupEditorCommands\";\r\nimport {DefaultModuloEditorBuilder} from \"./Builder\";\r\nimport type {\r\n EditorDomResolver,\r\n EditorDomSlots\r\n} from \"../dom/contracts\";\r\n\r\n\r\n/**\r\n * Main editor orchestrator.\r\n *\r\n * ModuloEditor connects:\r\n *\r\n * - EditorDocument → source of truth\r\n * - EditorInputAdapter → editing layer\r\n * - MarkdownProcessor → transforms content to HTML\r\n * - EditorOutputAdapter → preview renderer\r\n * - EditorCommandsApi → command execution\r\n * - EditorPlugin → UI extensions\r\n *\r\n * Responsibilities:\r\n *\r\n * - initialize editor state\r\n * - synchronize input → document → preview\r\n * - execute commands\r\n * - mount plugins\r\n * - manage lifecycle (init / destroy)\r\n */\r\nexport class ModuloEditor {\r\n private readonly document: EditorDocument;\r\n private readonly input: ModuloEditorOptions[\"input\"];\r\n private readonly output: ModuloEditorOptions[\"output\"];\r\n private readonly markdown: ModuloEditorOptions[\"markdown\"];\r\n private readonly plugins: readonly EditorPlugin[];\r\n private readonly commands: EditorCommandsApi;\r\n private readonly root: HTMLElement;\r\n private readonly domResolver: EditorDomResolver;\r\n private readonly textareaBridge?: ModuloEditorOptions[\"textareaBridge\"];\r\n\r\n private unsubscribeInputChange?: () => void;\r\n private initialized = false;\r\n private slots!: EditorDomSlots;\r\n\r\n /**\r\n * Creates a new ModuloEditor instance.\r\n *\r\n * Commands and plugins are registered but not initialized\r\n * until `init()` is called.\r\n */\r\n public constructor(\r\n {\r\n document = new DefaultEditorDocument(),\r\n input,\r\n output,\r\n markdown,\r\n commands = [],\r\n plugins = [],\r\n builtinCommands = true,\r\n root,\r\n domResolver,\r\n textareaBridge,\r\n }: ModuloEditorOptions) {\r\n this.document = document;\r\n this.input = input;\r\n this.output = output;\r\n this.markdown = markdown;\r\n this.plugins = plugins;\r\n this.root = root;\r\n this.domResolver = domResolver ?? new DefaultEditorDomResolver();\r\n this.textareaBridge = textareaBridge;\r\n\r\n const registry = new EditorCommandRegistry()\r\n\r\n setupEditorCommands(registry, {\r\n builtinCommands,\r\n commands\r\n });\r\n\r\n this.commands = new RegistryEditorCommandsApi(\r\n registry,\r\n () => this.createCommandContext()\r\n );\r\n }\r\n\r\n public static create(root: string | HTMLElement): ModuloEditorBuilder {\r\n return new DefaultModuloEditorBuilder(root);\r\n }\r\n\r\n /**\r\n * Initializes the editor.\r\n *\r\n * - hydrates input from document\r\n * - renders initial preview\r\n * - subscribes to input changes\r\n * - mounts plugins\r\n */\r\n public init(): void {\r\n if (this.initialized) {\r\n return;\r\n }\r\n\r\n this.slots = this.domResolver.resolve(this.root);\r\n const content = this.document.getRawContent();\r\n\r\n this.input.mount(this.slots.input, content);\r\n this.textareaBridge?.mount(this.slots.textarea);\r\n this.textareaBridge?.setValue(content);\r\n\r\n const html = this.markdown.toHtml(content);\r\n this.output.render(html);\r\n this.output.mount(this.slots.preview);\r\n\r\n this.unsubscribeInputChange = this.input.onChange((value: string) => {\r\n this.handleInputChange(value);\r\n });\r\n\r\n const pluginApi = this.createPluginApi();\r\n\r\n for (const plugin of this.plugins) {\r\n plugin.setup(pluginApi);\r\n }\r\n\r\n this.initialized = true;\r\n }\r\n\r\n /**\r\n * Destroys the editor.\r\n *\r\n * - unsubscribes input listeners\r\n * - destroys plugins\r\n * - destroys adapters\r\n */\r\n public destroy(): void {\r\n if (!this.initialized) {\r\n return;\r\n }\r\n\r\n this.unsubscribeInputChange?.();\r\n this.unsubscribeInputChange = undefined;\r\n\r\n for (const plugin of this.plugins) {\r\n plugin.destroy();\r\n }\r\n\r\n this.textareaBridge?.destroy();\r\n\r\n this.input.destroy();\r\n this.output.destroy();\r\n\r\n this.initialized = false;\r\n }\r\n\r\n /**\r\n * Sets the editor value and synchronizes all layers.\r\n */\r\n public setValue(value: string): void {\r\n this.document.setRawContent(value);\r\n this.input.setValue(value);\r\n this.textareaBridge?.setValue(value);\r\n\r\n this.output.render(this.markdown.toHtml(value));\r\n }\r\n\r\n /**\r\n * Returns the current editor raw value.\r\n */\r\n public getValue(): string {\r\n return this.document.getRawContent();\r\n }\r\n\r\n /**\r\n * Executes a registered command and synchronizes editor state.\r\n */\r\n public executeCommand(name: string): void {\r\n if (!this.commands.has(name)) {\r\n return;\r\n }\r\n\r\n this.commands.execute(name);\r\n this.syncFromInput();\r\n }\r\n\r\n /**\r\n * Focuses the editor input.\r\n */\r\n public focus(): void {\r\n this.input.focus();\r\n }\r\n\r\n /**\r\n * Handles input changes by synchronizing the document and preview.\r\n */\r\n private handleInputChange(value: string): void {\r\n this.document.setRawContent(value);\r\n this.textareaBridge?.setValue(value);\r\n this.output.render(this.markdown.toHtml(value));\r\n }\r\n\r\n /**\r\n * Synchronizes document and preview from the current input value.\r\n */\r\n private syncFromInput(): void {\r\n const value = this.input.getValue();\r\n\r\n this.document.setRawContent(value);\r\n this.output.render(this.markdown.toHtml(value));\r\n }\r\n\r\n /**\r\n * Creates the current command execution context.\r\n */\r\n private createCommandContext(): EditorCommandContext {\r\n return {\r\n input: this.input,\r\n state: this.input.getState()\r\n };\r\n }\r\n\r\n /**\r\n * Creates the API exposed to plugins.\r\n */\r\n private createPluginApi(): EditorPluginApi {\r\n return {\r\n commands: this.commands,\r\n slots: this.slots,\r\n executeCommand: (name: string): void => {\r\n this.executeCommand(name);\r\n }\r\n }\r\n }\r\n}"],"x_google_ignoreList":[23],"mappings":"oRAQA,IAAa,EAAb,KAAmC,CAC/B,SAA4B,IAAI,I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Markdown bold markers.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BoldCommand implements EditorCommand {
|
|
6
|
+
readonly name = "bold";
|
|
7
|
+
execute(context: EditorCommandContext): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=BoldCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BoldCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/builtin/BoldCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,qBAAa,WAAY,YAAW,aAAa;IAC7C,SAAgB,IAAI,UAAU;IAEvB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;CA6BtD"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { EditorCommand, EditorCommandContext } from "../contracts";
|
|
2
|
+
export declare class HeadingCommand implements EditorCommand {
|
|
3
|
+
readonly name: string;
|
|
4
|
+
private readonly level;
|
|
5
|
+
constructor(level: number);
|
|
6
|
+
execute(context: EditorCommandContext): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=HeadingCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeadingCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/builtin/HeadingCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAEtB,qBAAa,cAAe,YAAW,aAAa;IAChD,SAAgB,IAAI,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEZ,KAAK,EAAE,MAAM;IASzB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;CAwBtD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ItalicCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/builtin/ItalicCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAEtB,qBAAa,aAAc,YAAW,aAAa;IAC/C,SAAgB,IAAI,YAAY;IAEzB,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI;CAoBtD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EditorCommand } from "../contracts";
|
|
2
|
+
export { BoldCommand } from "./BoldCommand";
|
|
3
|
+
export { ItalicCommand } from "./ItalicCommand";
|
|
4
|
+
export { HeadingCommand } from "./HeadingCommand";
|
|
5
|
+
/**
|
|
6
|
+
* Creates all builtin editor commands.
|
|
7
|
+
*
|
|
8
|
+
* This function is used internally to register default commands.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createBuiltinCommands(): readonly EditorCommand[];
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/builtin/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhD,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,cAAc,EAAC,MAAM,kBAAkB,CAAC;AAEhD;;;;GAIG;AACH,wBAAgB,qBAAqB,IAAI,SAAS,aAAa,EAAE,CAWhE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { EditorCommandContext } from "./EditorCommandContext";
|
|
2
|
+
/**
|
|
3
|
+
* Contract implemented by editor commands.
|
|
4
|
+
*
|
|
5
|
+
* A command encapsulates one editor action such as bold, italic,
|
|
6
|
+
* heading insertion, or list creation.
|
|
7
|
+
*/
|
|
8
|
+
export interface EditorCommand {
|
|
9
|
+
/**
|
|
10
|
+
* Unique command name.
|
|
11
|
+
*/
|
|
12
|
+
readonly name: string;
|
|
13
|
+
/**
|
|
14
|
+
* Executes the command using the provided editor context.
|
|
15
|
+
*/
|
|
16
|
+
execute(context: EditorCommandContext): void;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=EditorCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/contracts/EditorCommand.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,oBAAoB,GAAG,IAAI,CAAC;CAChD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { EditorInputAdapter, EditorInputState } from "../../input";
|
|
2
|
+
/**
|
|
3
|
+
* Runtime context provided to editor commands.
|
|
4
|
+
*/
|
|
5
|
+
export interface EditorCommandContext {
|
|
6
|
+
/**
|
|
7
|
+
* Input adapter used to read and write the editor value.
|
|
8
|
+
*/
|
|
9
|
+
readonly input: EditorInputAdapter;
|
|
10
|
+
/**
|
|
11
|
+
* Snapshot of the current editor state.
|
|
12
|
+
*/
|
|
13
|
+
readonly state: EditorInputState;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=EditorCommandContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorCommandContext.d.ts","sourceRoot":"","sources":["../../../../src/commands/contracts/EditorCommandContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,kBAAkB,EAAE,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IAEnC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,gBAAgB,CAAC;CACpC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { EditorInputState } from "../../input";
|
|
2
|
+
/**
|
|
3
|
+
* Contract describing editable input behavior required by commands.
|
|
4
|
+
*/
|
|
5
|
+
export interface EditorInput {
|
|
6
|
+
getValue(): string;
|
|
7
|
+
setValue(value: string): void;
|
|
8
|
+
getState(): EditorInputState;
|
|
9
|
+
focus(): void;
|
|
10
|
+
setSelection(start: number, end: number): void;
|
|
11
|
+
onChange(listener: (value: string) => void): () => void;
|
|
12
|
+
destroy(): void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=EditorInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorInput.d.ts","sourceRoot":"","sources":["../../../../src/commands/contracts/EditorInput.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,aAAa,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,QAAQ,IAAI,MAAM,CAAC;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,IAAI,gBAAgB,CAAC;IAC7B,KAAK,IAAI,IAAI,CAAC;IACd,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACxD,OAAO,IAAI,IAAI,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/contracts/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AACnD,YAAY,EAAC,oBAAoB,EAAC,MAAM,wBAAwB,CAAC;AACjE,YAAY,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EditorCommand, EditorCommandContext } from "../contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Registry responsible for storing and executing editor commands.
|
|
4
|
+
*/
|
|
5
|
+
export declare class EditorCommandRegistry {
|
|
6
|
+
private readonly commands;
|
|
7
|
+
/**
|
|
8
|
+
* Registers a command in the registry.
|
|
9
|
+
*/
|
|
10
|
+
register(command: EditorCommand): void;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a registered command by name.
|
|
13
|
+
*/
|
|
14
|
+
get(name: string): EditorCommand | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* Returns whether a command exists.
|
|
17
|
+
*/
|
|
18
|
+
has(name: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Returns all registered commands.
|
|
21
|
+
*/
|
|
22
|
+
all(): readonly EditorCommand[];
|
|
23
|
+
/**
|
|
24
|
+
* Executes a registered command.
|
|
25
|
+
*/
|
|
26
|
+
execute(name: string, context: EditorCommandContext): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=EditorCommandRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorCommandRegistry.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/EditorCommandRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,aAAa,EACb,oBAAoB,EACvB,MAAM,cAAc,CAAC;AAEtB;;GAEG;AACH,qBAAa,qBAAqB;IAC9B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAE7D;;OAEG;IACI,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,IAAI;IAQ7C;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS;IAInD;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIjC;;OAEG;IACI,GAAG,IAAI,SAAS,aAAa,EAAE;IAItC;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,oBAAoB,GAAG,IAAI;CASpE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public API used by plugins to interact with editor commands.
|
|
3
|
+
*/
|
|
4
|
+
export interface EditorCommandsApi {
|
|
5
|
+
/**
|
|
6
|
+
* Executes a command by name.
|
|
7
|
+
*/
|
|
8
|
+
execute(name: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Checks whether a command is registered.
|
|
11
|
+
*/
|
|
12
|
+
has(name: string): boolean;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=EditorCommandsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorCommandsApi.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/EditorCommandsApi.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B;;OAEG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;OAEG;IACH,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EditorCommandsApi } from "./EditorCommandsApi";
|
|
2
|
+
import type { EditorCommandRegistry } from "./EditorCommandRegistry";
|
|
3
|
+
import type { EditorCommandContext } from "../contracts";
|
|
4
|
+
/**
|
|
5
|
+
* Adapter exposing registry commands as a public API.
|
|
6
|
+
*/
|
|
7
|
+
export declare class RegistryEditorCommandsApi implements EditorCommandsApi {
|
|
8
|
+
private readonly registry;
|
|
9
|
+
private readonly contextResolver;
|
|
10
|
+
constructor(registry: EditorCommandRegistry, contextResolver: () => EditorCommandContext);
|
|
11
|
+
/**
|
|
12
|
+
* Executes a command.
|
|
13
|
+
*/
|
|
14
|
+
execute(name: string): void;
|
|
15
|
+
/**
|
|
16
|
+
* Checks if a command exists.
|
|
17
|
+
*/
|
|
18
|
+
has(name: string): boolean;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=RegistryEditorCommandsApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RegistryEditorCommandsApi.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/RegistryEditorCommandsApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,EAAC,oBAAoB,EAAC,MAAM,cAAc,CAAC;AAEvD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,iBAAiB;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAwB;IACjD,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA6B;gBAGzD,QAAQ,EAAE,qBAAqB,EAC/B,eAAe,EAAE,MAAM,oBAAoB;IAM/C;;OAEG;IACI,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAKlC;;OAEG;IACI,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAGpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/registry/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,EAAC,yBAAyB,EAAC,MAAM,6BAA6B,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditorCommand } from "../contracts";
|
|
2
|
+
/**
|
|
3
|
+
* Validates custom commands provided by the user.
|
|
4
|
+
*
|
|
5
|
+
* This function ensures that:
|
|
6
|
+
* - no command overrides a reserved builtin command name
|
|
7
|
+
* - no duplicate command names are defined
|
|
8
|
+
*
|
|
9
|
+
* Throws an error if a rule is violated.
|
|
10
|
+
*/
|
|
11
|
+
export declare function assertCustomCommandsAreValid(commands: readonly EditorCommand[]): void;
|
|
12
|
+
//# sourceMappingURL=assertCustomCommandsAreValid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertCustomCommandsAreValid.d.ts","sourceRoot":"","sources":["../../../../src/commands/setup/assertCustomCommandsAreValid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,cAAc,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,4BAA4B,CACxC,QAAQ,EAAE,SAAS,aAAa,EAAE,GACnC,IAAI,CA2BN"}
|