@blockslides/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/helpers/createChainableState.ts","../src/CommandManager.ts","../src/commands/index.ts","../src/commands/blur.ts","../src/commands/clearContent.ts","../src/commands/clearNodes.ts","../src/commands/command.ts","../src/commands/createParagraphNear.ts","../src/commands/cut.ts","../src/commands/deleteCurrentNode.ts","../src/helpers/getNodeType.ts","../src/commands/deleteNode.ts","../src/commands/deleteRange.ts","../src/commands/deleteSelection.ts","../src/commands/enter.ts","../src/commands/exitCode.ts","../src/commands/extendMarkRange.ts","../src/utilities/isRegExp.ts","../src/utilities/objectIncludes.ts","../src/helpers/getMarkRange.ts","../src/helpers/getMarkType.ts","../src/commands/first.ts","../src/helpers/isTextSelection.ts","../src/helpers/resolveFocusPosition.ts","../src/utilities/minMax.ts","../src/utilities/isAndroid.ts","../src/utilities/isiOS.ts","../src/commands/focus.ts","../src/commands/forEach.ts","../src/commands/insertContent.ts","../src/commands/insertContentAt.ts","../src/helpers/createNodeFromContent.ts","../src/utilities/elementFromString.ts","../src/helpers/selectionToInsertionEnd.ts","../src/commands/join.ts","../src/commands/joinItemBackward.ts","../src/commands/joinItemForward.ts","../src/commands/joinTextblockBackward.ts","../src/commands/joinTextblockForward.ts","../src/utilities/isMacOS.ts","../src/commands/keyboardShortcut.ts","../src/commands/lift.ts","../src/helpers/isNodeActive.ts","../src/commands/liftEmptyBlock.ts","../src/commands/liftListItem.ts","../src/commands/newlineInCode.ts","../src/helpers/getSchemaTypeNameByName.ts","../src/utilities/deleteProps.ts","../src/commands/resetAttributes.ts","../src/commands/scrollIntoView.ts","../src/commands/selectAll.ts","../src/commands/selectNodeBackward.ts","../src/commands/selectNodeForward.ts","../src/commands/selectParentNode.ts","../src/commands/selectTextblockEnd.ts","../src/commands/selectTextblockStart.ts","../src/helpers/createDocument.ts","../src/commands/setContent.ts","../src/helpers/getMarkAttributes.ts","../src/helpers/combineTransactionSteps.ts","../src/helpers/defaultBlockAt.ts","../src/helpers/findChildren.ts","../src/helpers/findChildrenInRange.ts","../src/helpers/findParentNodeClosestToPos.ts","../src/helpers/findParentNode.ts","../src/helpers/getExtensionField.ts","../src/helpers/flattenExtensions.ts","../src/helpers/generateHTML.ts","../src/helpers/getHTMLFromFragment.ts","../src/helpers/getSchemaByResolvedExtensions.ts","../src/utilities/isFunction.ts","../src/utilities/callOrReturn.ts","../src/utilities/isEmptyObject.ts","../src/helpers/splitExtensions.ts","../src/helpers/getAttributesFromExtensions.ts","../src/utilities/mergeAttributes.ts","../src/helpers/getRenderedAttributes.ts","../src/utilities/fromString.ts","../src/helpers/injectExtensionAttributesToParseRule.ts","../src/utilities/findDuplicates.ts","../src/helpers/sortExtensions.ts","../src/helpers/resolveExtensions.ts","../src/helpers/getSchema.ts","../src/helpers/generateJSON.ts","../src/helpers/generateText.ts","../src/helpers/getTextBetween.ts","../src/helpers/getText.ts","../src/helpers/getTextSerializersFromSchema.ts","../src/helpers/getNodeAttributes.ts","../src/helpers/getAttributes.ts","../src/utilities/removeDuplicates.ts","../src/helpers/getChangedRanges.ts","../src/helpers/getDebugJSON.ts","../src/helpers/getMarksBetween.ts","../src/helpers/getNodeAtPosition.ts","../src/helpers/getSchemaTypeByName.ts","../src/helpers/getSplittedAttributes.ts","../src/helpers/getTextContentFromNodes.ts","../src/helpers/isMarkActive.ts","../src/helpers/isActive.ts","../src/helpers/isAtEndOfNode.ts","../src/helpers/isAtStartOfNode.ts","../src/helpers/isExtensionRulesEnabled.ts","../src/helpers/isList.ts","../src/helpers/isNodeEmpty.ts","../src/helpers/isNodeSelection.ts","../src/helpers/posToDOMRect.ts","../src/helpers/rewriteUnknownContent.ts","../src/commands/setMark.ts","../src/commands/setMeta.ts","../src/commands/setNode.ts","../src/commands/setNodeSelection.ts","../src/commands/setTextSelection.ts","../src/commands/sinkListItem.ts","../src/commands/splitBlock.ts","../src/commands/splitListItem.ts","../src/commands/toggleList.ts","../src/commands/toggleMark.ts","../src/commands/toggleNode.ts","../src/commands/toggleWrap.ts","../src/commands/undoInputRule.ts","../src/commands/unsetAllMarks.ts","../src/commands/unsetMark.ts","../src/commands/updateAttributes.ts","../src/commands/wrapIn.ts","../src/commands/wrapInList.ts","../src/SlideEditor.ts","../src/EventEmitter.ts","../src/ExtensionManager.ts","../src/InputRule.ts","../src/utilities/isPlainObject.ts","../src/utilities/mergeDeep.ts","../src/Extendable.ts","../src/Mark.ts","../src/PasteRule.ts","../src/utilities/isNumber.ts","../src/extensions/index.ts","../src/extensions/clipboardTextSerializer.ts","../src/Extension.ts","../src/extensions/commands.ts","../src/extensions/delete.ts","../src/extensions/drop.ts","../src/extensions/editable.ts","../src/extensions/focusEvents.ts","../src/extensions/keymap.ts","../src/extensions/paste.ts","../src/extensions/tabindex.ts","../src/NodePos.ts","../src/style.ts","../src/themes/light.ts","../src/themes/dark.ts","../src/themes/resolver.ts","../src/utilities/createStyleTag.ts","../src/inputRules/markInputRule.ts","../src/inputRules/nodeInputRule.ts","../src/inputRules/textblockTypeInputRule.ts","../src/inputRules/textInputRule.ts","../src/inputRules/wrappingInputRule.ts","../src/jsx-runtime.ts","../src/utilities/canInsertNode.ts","../src/utilities/escapeForRegEx.ts","../src/utilities/isString.ts","../src/utilities/layoutParser.ts","../src/utilities/markdown/index.ts","../src/utilities/markdown/attributeUtils.ts","../src/utilities/markdown/createAtomBlockMarkdownSpec.ts","../src/utilities/markdown/createBlockMarkdownSpec.ts","../src/utilities/markdown/createInlineMarkdownSpec.ts","../src/utilities/markdown/parseIndentedBlocks.ts","../src/utilities/markdown/renderNestedMarkdownContent.ts","../src/MarkView.ts","../src/Node.ts","../src/NodeView.ts","../src/pasteRules/markPasteRule.ts","../src/pasteRules/nodePasteRule.ts","../src/pasteRules/textPasteRule.ts","../src/Tracker.ts"],"sourcesContent":["export * from \"./CommandManager.js\";\nexport type * from \"./commands/index.js\";\nexport * as commands from \"./commands/index.js\";\nexport * from \"./SlideEditor.js\";\nexport * from \"./Extendable.js\";\nexport * from \"./Extension.js\";\nexport * as extensions from \"./extensions/index.js\";\nexport * from \"./helpers/index.js\";\nexport * from \"./InputRule.js\";\nexport * from \"./inputRules/index.js\";\nexport { createElement, Fragment, createElement as h } from \"./jsx-runtime.js\";\nexport * from \"./Mark.js\";\nexport * from \"./MarkView.js\";\nexport * from \"./Node.js\";\nexport * from \"./NodePos.js\";\nexport * from \"./NodeView.js\";\nexport * from \"./PasteRule.js\";\nexport * from \"./pasteRules/index.js\";\nexport * from \"./Tracker.js\";\nexport * from \"./types.js\";\nexport * from \"./utilities/index.js\";\nexport * from \"./themes/index.js\";\n\n// eslint-disable-next-line\nexport interface Commands<ReturnType = any> {}\n\n// eslint-disable-next-line\nexport interface Storage {}\n","import type { EditorState, Transaction } from '@blockslides/pm/state'\n\n/**\n * Takes a Transaction & Editor State and turns it into a chainable state object\n * @param config The transaction and state to create the chainable state from\n * @returns A chainable Editor state object\n */\nexport function createChainableState(config: { transaction: Transaction; state: EditorState }): EditorState {\n const { state, transaction } = config\n let { selection } = transaction\n let { doc } = transaction\n let { storedMarks } = transaction\n\n return {\n ...state,\n apply: state.apply.bind(state),\n applyTransaction: state.applyTransaction.bind(state),\n plugins: state.plugins,\n schema: state.schema,\n reconfigure: state.reconfigure.bind(state),\n toJSON: state.toJSON.bind(state),\n get storedMarks() {\n return storedMarks\n },\n get selection() {\n return selection\n },\n get doc() {\n return doc\n },\n get tr() {\n selection = transaction.selection\n doc = transaction.doc\n storedMarks = transaction.storedMarks\n\n return transaction\n },\n }\n}\n","import type { EditorState, Transaction } from \"@blockslides/pm/state\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport { createChainableState } from \"./helpers/createChainableState.js\";\nimport type {\n AnyCommands,\n CanCommands,\n ChainedCommands,\n CommandProps,\n SingleCommands,\n} from \"./types.js\";\n\nexport class CommandManager {\n editor: Editor;\n\n rawCommands: AnyCommands;\n\n customState?: EditorState;\n\n constructor(props: { editor: Editor; state?: EditorState }) {\n this.editor = props.editor;\n this.rawCommands = this.editor.extensionManager.commands;\n this.customState = props.state;\n }\n\n get hasCustomState(): boolean {\n return !!this.customState;\n }\n\n get state(): EditorState {\n return this.customState || this.editor.state;\n }\n\n get commands(): SingleCommands {\n const { rawCommands, editor, state } = this;\n const { view } = editor;\n const { tr } = state;\n const props = this.buildProps(tr);\n\n return Object.fromEntries(\n Object.entries(rawCommands).map(([name, command]) => {\n const method = (...args: any[]) => {\n const callback = command(...args)(props);\n\n if (!tr.getMeta(\"preventDispatch\") && !this.hasCustomState) {\n view.dispatch(tr);\n }\n\n return callback;\n };\n\n return [name, method];\n })\n ) as unknown as SingleCommands;\n }\n\n get chain(): () => ChainedCommands {\n return () => this.createChain();\n }\n\n get can(): () => CanCommands {\n return () => this.createCan();\n }\n\n public createChain(\n startTr?: Transaction,\n shouldDispatch = true\n ): ChainedCommands {\n const { rawCommands, editor, state } = this;\n const { view } = editor;\n const callbacks: boolean[] = [];\n const hasStartTransaction = !!startTr;\n const tr = startTr || state.tr;\n\n const run = () => {\n if (\n !hasStartTransaction &&\n shouldDispatch &&\n !tr.getMeta(\"preventDispatch\") &&\n !this.hasCustomState\n ) {\n view.dispatch(tr);\n }\n\n return callbacks.every((callback) => callback === true);\n };\n\n const chain = {\n ...Object.fromEntries(\n Object.entries(rawCommands).map(([name, command]) => {\n const chainedCommand = (...args: never[]) => {\n const props = this.buildProps(tr, shouldDispatch);\n const callback = command(...args)(props);\n\n callbacks.push(callback);\n\n return chain;\n };\n\n return [name, chainedCommand];\n })\n ),\n run,\n } as unknown as ChainedCommands;\n\n return chain;\n }\n\n public createCan(startTr?: Transaction): CanCommands {\n const { rawCommands, state } = this;\n const dispatch = false;\n const tr = startTr || state.tr;\n const props = this.buildProps(tr, dispatch);\n const formattedCommands = Object.fromEntries(\n Object.entries(rawCommands).map(([name, command]) => {\n return [\n name,\n (...args: never[]) =>\n command(...args)({ ...props, dispatch: undefined }),\n ];\n })\n ) as unknown as SingleCommands;\n\n return {\n ...formattedCommands,\n chain: () => this.createChain(tr, dispatch),\n } as CanCommands;\n }\n\n public buildProps(tr: Transaction, shouldDispatch = true): CommandProps {\n const { rawCommands, editor, state } = this;\n const { view } = editor;\n\n const props: CommandProps = {\n tr,\n editor,\n view,\n state: createChainableState({\n state,\n transaction: tr,\n }),\n dispatch: shouldDispatch ? () => undefined : undefined,\n chain: () => this.createChain(tr, shouldDispatch),\n can: () => this.createCan(tr),\n get commands() {\n return Object.fromEntries(\n Object.entries(rawCommands).map(([name, command]) => {\n return [name, (...args: never[]) => command(...args)(props)];\n })\n ) as unknown as SingleCommands;\n },\n };\n\n return props;\n }\n}\n","export * from './blur.js'\nexport * from './clearContent.js'\nexport * from './clearNodes.js'\nexport * from './command.js'\nexport * from './createParagraphNear.js'\nexport * from './cut.js'\nexport * from './deleteCurrentNode.js'\nexport * from './deleteNode.js'\nexport * from './deleteRange.js'\nexport * from './deleteSelection.js'\nexport * from './enter.js'\nexport * from './exitCode.js'\nexport * from './extendMarkRange.js'\nexport * from './first.js'\nexport * from './focus.js'\nexport * from './forEach.js'\nexport * from './insertContent.js'\nexport * from './insertContentAt.js'\nexport * from './join.js'\nexport * from './joinItemBackward.js'\nexport * from './joinItemForward.js'\nexport * from './joinTextblockBackward.js'\nexport * from './joinTextblockForward.js'\nexport * from './keyboardShortcut.js'\nexport * from './lift.js'\nexport * from './liftEmptyBlock.js'\nexport * from './liftListItem.js'\nexport * from './newlineInCode.js'\nexport * from './resetAttributes.js'\nexport * from './scrollIntoView.js'\nexport * from './selectAll.js'\nexport * from './selectNodeBackward.js'\nexport * from './selectNodeForward.js'\nexport * from './selectParentNode.js'\nexport * from './selectTextblockEnd.js'\nexport * from './selectTextblockStart.js'\nexport * from './setContent.js'\nexport * from './setMark.js'\nexport * from './setMeta.js'\nexport * from './setNode.js'\nexport * from './setNodeSelection.js'\nexport * from './setTextSelection.js'\nexport * from './sinkListItem.js'\nexport * from './splitBlock.js'\nexport * from './splitListItem.js'\nexport * from './toggleList.js'\nexport * from './toggleMark.js'\nexport * from './toggleNode.js'\nexport * from './toggleWrap.js'\nexport * from './undoInputRule.js'\nexport * from './unsetAllMarks.js'\nexport * from './unsetMark.js'\nexport * from './updateAttributes.js'\nexport * from './wrapIn.js'\nexport * from './wrapInList.js'\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n blur: {\n /**\n * Removes focus from the editor.\n * @example editor.commands.blur()\n */\n blur: () => ReturnType\n }\n }\n}\n\nexport const blur: RawCommands['blur'] =\n () =>\n ({ editor, view }) => {\n requestAnimationFrame(() => {\n if (!editor.isDestroyed) {\n ;(view.dom as HTMLElement).blur()\n\n window?.getSelection()?.removeAllRanges()\n }\n })\n\n return true\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n clearContent: {\n /**\n * Clear the whole document.\n * @example editor.commands.clearContent()\n */\n clearContent: (\n /**\n * Whether to emit an update event.\n * @default true\n */\n emitUpdate?: boolean,\n ) => ReturnType\n }\n }\n}\n\nexport const clearContent: RawCommands['clearContent'] =\n (emitUpdate = true) =>\n ({ commands }) => {\n return commands.setContent('', { emitUpdate })\n }\n","import { liftTarget } from '@blockslides/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n clearNodes: {\n /**\n * Normalize nodes to a simple paragraph.\n * @example editor.commands.clearNodes()\n */\n clearNodes: () => ReturnType\n }\n }\n}\n\nexport const clearNodes: RawCommands['clearNodes'] =\n () =>\n ({ state, tr, dispatch }) => {\n const { selection } = tr\n const { ranges } = selection\n\n if (!dispatch) {\n return true\n }\n\n ranges.forEach(({ $from, $to }) => {\n state.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {\n if (node.type.isText) {\n return\n }\n\n const { doc, mapping } = tr\n const $mappedFrom = doc.resolve(mapping.map(pos))\n const $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize))\n const nodeRange = $mappedFrom.blockRange($mappedTo)\n\n if (!nodeRange) {\n return\n }\n\n const targetLiftDepth = liftTarget(nodeRange)\n\n if (node.type.isTextblock) {\n const { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index())\n\n tr.setNodeMarkup(nodeRange.start, defaultType)\n }\n\n if (targetLiftDepth || targetLiftDepth === 0) {\n tr.lift(nodeRange, targetLiftDepth)\n }\n })\n })\n\n return true\n }\n","import type { Command, RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n command: {\n /**\n * Define a command inline.\n * @param fn The command function.\n * @example\n * editor.commands.command(({ tr, state }) => {\n * ...\n * return true\n * })\n */\n command: (fn: (props: Parameters<Command>[0]) => boolean) => ReturnType\n }\n }\n}\n\nexport const command: RawCommands['command'] = fn => props => {\n return fn(props)\n}\n","import { createParagraphNear as originalCreateParagraphNear } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n createParagraphNear: {\n /**\n * Create a paragraph nearby.\n * @example editor.commands.createParagraphNear()\n */\n createParagraphNear: () => ReturnType\n }\n }\n}\n\nexport const createParagraphNear: RawCommands['createParagraphNear'] =\n () =>\n ({ state, dispatch }) => {\n return originalCreateParagraphNear(state, dispatch)\n }\n","import { TextSelection } from '@blockslides/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n cut: {\n /**\n * Cuts content from a range and inserts it at a given position.\n * @param range The range to cut.\n * @param range.from The start position of the range.\n * @param range.to The end position of the range.\n * @param targetPos The position to insert the content at.\n * @example editor.commands.cut({ from: 1, to: 3 }, 5)\n */\n cut: ({ from, to }: { from: number; to: number }, targetPos: number) => ReturnType\n }\n }\n}\n\nexport const cut: RawCommands['cut'] =\n (originRange, targetPos) =>\n ({ editor, tr }) => {\n const { state } = editor\n\n const contentSlice = state.doc.slice(originRange.from, originRange.to)\n\n tr.deleteRange(originRange.from, originRange.to)\n const newPos = tr.mapping.map(targetPos)\n\n tr.insert(newPos, contentSlice.content)\n\n tr.setSelection(new TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))))\n\n return true\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n deleteCurrentNode: {\n /**\n * Delete the node that currently has the selection anchor.\n * @example editor.commands.deleteCurrentNode()\n */\n deleteCurrentNode: () => ReturnType\n }\n }\n}\n\nexport const deleteCurrentNode: RawCommands['deleteCurrentNode'] =\n () =>\n ({ tr, dispatch }) => {\n const { selection } = tr\n const currentNode = selection.$anchor.node()\n\n // if there is content inside the current node, break out of this command\n if (currentNode.content.size > 0) {\n return false\n }\n\n const $pos = tr.selection.$anchor\n\n for (let depth = $pos.depth; depth > 0; depth -= 1) {\n const node = $pos.node(depth)\n\n if (node.type === currentNode.type) {\n if (dispatch) {\n const from = $pos.before(depth)\n const to = $pos.after(depth)\n\n tr.delete(from, to).scrollIntoView()\n }\n\n return true\n }\n }\n\n return false\n }\n","import type { NodeType, Schema } from '@blockslides/pm/model'\n\nexport function getNodeType(nameOrType: string | NodeType, schema: Schema): NodeType {\n if (typeof nameOrType === 'string') {\n if (!schema.nodes[nameOrType]) {\n throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`)\n }\n\n return schema.nodes[nameOrType]\n }\n\n return nameOrType\n}\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n deleteNode: {\n /**\n * Delete a node with a given type or name.\n * @param typeOrName The type or name of the node.\n * @example editor.commands.deleteNode('paragraph')\n */\n deleteNode: (typeOrName: string | NodeType) => ReturnType\n }\n }\n}\n\nexport const deleteNode: RawCommands['deleteNode'] =\n typeOrName =>\n ({ tr, state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n const $pos = tr.selection.$anchor\n\n for (let depth = $pos.depth; depth > 0; depth -= 1) {\n const node = $pos.node(depth)\n\n if (node.type === type) {\n if (dispatch) {\n const from = $pos.before(depth)\n const to = $pos.after(depth)\n\n tr.delete(from, to).scrollIntoView()\n }\n\n return true\n }\n }\n\n return false\n }\n","import type { Range, RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n deleteRange: {\n /**\n * Delete a given range.\n * @param range The range to delete.\n * @example editor.commands.deleteRange({ from: 1, to: 3 })\n */\n deleteRange: (range: Range) => ReturnType\n }\n }\n}\n\nexport const deleteRange: RawCommands['deleteRange'] =\n range =>\n ({ tr, dispatch }) => {\n const { from, to } = range\n\n if (dispatch) {\n tr.delete(from, to)\n }\n\n return true\n }\n","import { deleteSelection as originalDeleteSelection } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n deleteSelection: {\n /**\n * Delete the selection, if there is one.\n * @example editor.commands.deleteSelection()\n */\n deleteSelection: () => ReturnType\n }\n }\n}\n\nexport const deleteSelection: RawCommands['deleteSelection'] =\n () =>\n ({ state, dispatch }) => {\n return originalDeleteSelection(state, dispatch)\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n enter: {\n /**\n * Trigger enter.\n * @example editor.commands.enter()\n */\n enter: () => ReturnType\n }\n }\n}\n\nexport const enter: RawCommands['enter'] =\n () =>\n ({ commands }) => {\n return commands.keyboardShortcut('Enter')\n }\n","import { exitCode as originalExitCode } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n exitCode: {\n /**\n * Exit from a code block.\n * @example editor.commands.exitCode()\n */\n exitCode: () => ReturnType\n }\n }\n}\n\nexport const exitCode: RawCommands['exitCode'] =\n () =>\n ({ state, dispatch }) => {\n return originalExitCode(state, dispatch)\n }\n","import type { MarkType } from '@blockslides/pm/model'\nimport { TextSelection } from '@blockslides/pm/state'\n\nimport { getMarkRange } from '../helpers/getMarkRange.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n extendMarkRange: {\n /**\n * Extends the text selection to the current mark by type or name.\n * @param typeOrName The type or name of the mark.\n * @param attributes The attributes of the mark.\n * @example editor.commands.extendMarkRange('bold')\n * @example editor.commands.extendMarkRange('mention', { userId: \"1\" })\n */\n extendMarkRange: (\n /**\n * The type or name of the mark.\n */\n typeOrName: string | MarkType,\n\n /**\n * The attributes of the mark.\n */\n attributes?: Record<string, any>,\n ) => ReturnType\n }\n }\n}\n\nexport const extendMarkRange: RawCommands['extendMarkRange'] =\n (typeOrName, attributes = {}) =>\n ({ tr, state, dispatch }) => {\n const type = getMarkType(typeOrName, state.schema)\n const { doc, selection } = tr\n const { $from, from, to } = selection\n\n if (dispatch) {\n const range = getMarkRange($from, type, attributes)\n\n if (range && range.from <= from && range.to >= to) {\n const newSelection = TextSelection.create(doc, range.from, range.to)\n\n tr.setSelection(newSelection)\n }\n }\n\n return true\n }\n","export function isRegExp(value: any): value is RegExp {\n return Object.prototype.toString.call(value) === '[object RegExp]'\n}\n","import { isRegExp } from './isRegExp.js'\n\n/**\n * Check if object1 includes object2\n * @param object1 Object\n * @param object2 Object\n */\nexport function objectIncludes(\n object1: Record<string, any>,\n object2: Record<string, any>,\n options: { strict: boolean } = { strict: true },\n): boolean {\n const keys = Object.keys(object2)\n\n if (!keys.length) {\n return true\n }\n\n return keys.every(key => {\n if (options.strict) {\n return object2[key] === object1[key]\n }\n\n if (isRegExp(object2[key])) {\n return object2[key].test(object1[key])\n }\n\n return object2[key] === object1[key]\n })\n}\n","import type { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@blockslides/pm/model'\n\nimport type { Range } from '../types.js'\nimport { objectIncludes } from '../utilities/objectIncludes.js'\n\nfunction findMarkInSet(\n marks: ProseMirrorMark[],\n type: MarkType,\n attributes: Record<string, any> = {},\n): ProseMirrorMark | undefined {\n return marks.find(item => {\n return (\n item.type === type &&\n objectIncludes(\n // Only check equality for the attributes that are provided\n Object.fromEntries(Object.keys(attributes).map(k => [k, item.attrs[k]])),\n attributes,\n )\n )\n })\n}\n\nfunction isMarkInSet(marks: ProseMirrorMark[], type: MarkType, attributes: Record<string, any> = {}): boolean {\n return !!findMarkInSet(marks, type, attributes)\n}\n\n/**\n * Get the range of a mark at a resolved position.\n */\nexport function getMarkRange(\n /**\n * The position to get the mark range for.\n */\n $pos: ResolvedPos,\n /**\n * The mark type to get the range for.\n */\n type: MarkType,\n /**\n * The attributes to match against.\n * If not provided, only the first mark at the position will be matched.\n */\n attributes?: Record<string, any>,\n): Range | void {\n if (!$pos || !type) {\n return\n }\n let start = $pos.parent.childAfter($pos.parentOffset)\n\n // If the cursor is at the start of a text node that does not have the mark, look backward\n if (!start.node || !start.node.marks.some(mark => mark.type === type)) {\n start = $pos.parent.childBefore($pos.parentOffset)\n }\n\n // If there is no text node with the mark even backward, return undefined\n if (!start.node || !start.node.marks.some(mark => mark.type === type)) {\n return\n }\n\n // Default to only matching against the first mark's attributes\n attributes = attributes || start.node.marks[0]?.attrs\n\n // We now know that the cursor is either at the start, middle or end of a text node with the specified mark\n // so we can look it up on the targeted mark\n const mark = findMarkInSet([...start.node.marks], type, attributes)\n\n if (!mark) {\n return\n }\n\n let startIndex = start.index\n let startPos = $pos.start() + start.offset\n let endIndex = startIndex + 1\n let endPos = startPos + start.node.nodeSize\n\n while (startIndex > 0 && isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)) {\n startIndex -= 1\n startPos -= $pos.parent.child(startIndex).nodeSize\n }\n\n while (endIndex < $pos.parent.childCount && isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)) {\n endPos += $pos.parent.child(endIndex).nodeSize\n endIndex += 1\n }\n\n return {\n from: startPos,\n to: endPos,\n }\n}\n","import type { MarkType, Schema } from '@blockslides/pm/model'\n\nexport function getMarkType(nameOrType: string | MarkType, schema: Schema): MarkType {\n if (typeof nameOrType === 'string') {\n if (!schema.marks[nameOrType]) {\n throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`)\n }\n\n return schema.marks[nameOrType]\n }\n\n return nameOrType\n}\n","import type { Command, CommandProps, RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n first: {\n /**\n * Runs one command after the other and stops at the first which returns true.\n * @param commands The commands to run.\n * @example editor.commands.first([command1, command2])\n */\n first: (commands: Command[] | ((props: CommandProps) => Command[])) => ReturnType\n }\n }\n}\n\nexport const first: RawCommands['first'] = commands => props => {\n const items = typeof commands === 'function' ? commands(props) : commands\n\n for (let i = 0; i < items.length; i += 1) {\n if (items[i](props)) {\n return true\n }\n }\n\n return false\n}\n","import { TextSelection } from '@blockslides/pm/state'\n\nexport function isTextSelection(value: unknown): value is TextSelection {\n return value instanceof TextSelection\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\nimport { Selection, TextSelection } from '@blockslides/pm/state'\n\nimport type { FocusPosition } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\nexport function resolveFocusPosition(doc: ProseMirrorNode, position: FocusPosition = null): Selection | null {\n if (!position) {\n return null\n }\n\n const selectionAtStart = Selection.atStart(doc)\n const selectionAtEnd = Selection.atEnd(doc)\n\n if (position === 'start' || position === true) {\n return selectionAtStart\n }\n\n if (position === 'end') {\n return selectionAtEnd\n }\n\n const minPos = selectionAtStart.from\n const maxPos = selectionAtEnd.to\n\n if (position === 'all') {\n return TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos))\n }\n\n return TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos))\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n return Math.min(Math.max(value, min), max)\n}\n","export function isAndroid(): boolean {\n return navigator.platform === 'Android' || /android/i.test(navigator.userAgent)\n}\n","export function isiOS(): boolean {\n return (\n ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator.platform) ||\n // iPad on iOS 13 detection\n (navigator.userAgent.includes('Mac') && 'ontouchend' in document)\n )\n}\n","import { isTextSelection } from \"../helpers/isTextSelection.js\";\nimport { resolveFocusPosition } from \"../helpers/resolveFocusPosition.js\";\nimport type { FocusPosition, RawCommands } from \"../types.js\";\nimport { isAndroid } from \"../utilities/isAndroid.js\";\nimport { isiOS } from \"../utilities/isiOS.js\";\n\ndeclare module \"@blockslides/core\" {\n interface Commands<ReturnType> {\n focus: {\n /**\n * Focus the editor at the given position.\n * @param position The position to focus at.\n * @param options.scrollIntoView Scroll the focused position into view after focusing\n * @example editor.commands.focus()\n * @example editor.commands.focus(32, { scrollIntoView: false })\n */\n focus: (\n /**\n * The position to focus at.\n */\n position?: FocusPosition,\n\n /**\n * Optional options\n * @default { scrollIntoView: true }\n */\n options?: {\n scrollIntoView?: boolean;\n }\n ) => ReturnType;\n };\n }\n}\n\nexport const focus: RawCommands[\"focus\"] =\n (position = null, options = {}) =>\n ({ editor, view, tr, dispatch }) => {\n options = {\n scrollIntoView: true,\n ...options,\n };\n\n const delayedFocus = () => {\n // focus within `requestAnimationFrame` breaks focus on iOS and Android\n // so we have to call this\n if (isiOS() || isAndroid()) {\n (view.dom as HTMLElement).focus();\n }\n\n // For React we have to focus asynchronously. Otherwise wild things happen.\n requestAnimationFrame(() => {\n if (!editor.isDestroyed) {\n view.focus();\n\n if (options?.scrollIntoView) {\n editor.commands.scrollIntoView();\n }\n }\n });\n };\n\n if ((view.hasFocus() && position === null) || position === false) {\n return true;\n }\n\n // we don’t try to resolve a NodeSelection or CellSelection\n if (\n dispatch &&\n position === null &&\n !isTextSelection(editor.state.selection)\n ) {\n delayedFocus();\n return true;\n }\n\n // pass through tr.doc instead of editor.state.doc\n // since transactions could change the editors state before this command has been run\n const selection =\n resolveFocusPosition(tr.doc, position) || editor.state.selection;\n const isSameSelection = editor.state.selection.eq(selection);\n\n if (dispatch) {\n if (!isSameSelection) {\n tr.setSelection(selection);\n }\n\n // `tr.setSelection` resets the stored marks\n // so we’ll restore them if the selection is the same as before\n if (isSameSelection && tr.storedMarks) {\n tr.setStoredMarks(tr.storedMarks);\n }\n\n delayedFocus();\n }\n\n return true;\n };\n","import type { CommandProps, RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n forEach: {\n /**\n * Loop through an array of items.\n */\n forEach: <T>(\n items: T[],\n fn: (\n item: T,\n props: CommandProps & {\n index: number\n },\n ) => boolean,\n ) => ReturnType\n }\n }\n}\n\nexport const forEach: RawCommands['forEach'] = (items, fn) => props => {\n return items.every((item, index) => fn(item, { ...props, index }))\n}\n","import type { Fragment, Node as ProseMirrorNode, ParseOptions } from '@blockslides/pm/model'\n\nimport type { Content, RawCommands } from '../types.js'\n\nexport interface InsertContentOptions {\n /**\n * Options for parsing the content.\n */\n parseOptions?: ParseOptions\n\n /**\n * Whether to update the selection after inserting the content.\n */\n updateSelection?: boolean\n applyInputRules?: boolean\n applyPasteRules?: boolean\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n insertContent: {\n /**\n * Insert a node or string of HTML at the current position.\n * @example editor.commands.insertContent('<h1>Example</h1>')\n * @example editor.commands.insertContent('<h1>Example</h1>', { updateSelection: false })\n */\n insertContent: (\n /**\n * The ProseMirror content to insert.\n */\n value: Content | ProseMirrorNode | Fragment,\n\n /**\n * Optional options\n */\n options?: InsertContentOptions,\n ) => ReturnType\n }\n }\n}\n\nexport const insertContent: RawCommands['insertContent'] =\n (value, options) =>\n ({ tr, commands }) => {\n return commands.insertContentAt({ from: tr.selection.from, to: tr.selection.to }, value, options)\n }\n","import type { Node as ProseMirrorNode, ParseOptions } from '@blockslides/pm/model'\nimport { Fragment } from '@blockslides/pm/model'\n\nimport { createNodeFromContent } from '../helpers/createNodeFromContent.js'\nimport { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd.js'\nimport type { Content, Range, RawCommands } from '../types.js'\n\nexport interface InsertContentAtOptions {\n /**\n * Options for parsing the content.\n */\n parseOptions?: ParseOptions\n\n /**\n * Whether to update the selection after inserting the content.\n */\n updateSelection?: boolean\n\n /**\n * Whether to apply input rules after inserting the content.\n */\n applyInputRules?: boolean\n\n /**\n * Whether to apply paste rules after inserting the content.\n */\n applyPasteRules?: boolean\n\n /**\n * Whether to throw an error if the content is invalid.\n */\n errorOnInvalidContent?: boolean\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n insertContentAt: {\n /**\n * Insert a node or string of HTML at a specific position.\n * @example editor.commands.insertContentAt(0, '<h1>Example</h1>')\n */\n insertContentAt: (\n /**\n * The position to insert the content at.\n */\n position: number | Range,\n\n /**\n * The ProseMirror content to insert.\n */\n value: Content | ProseMirrorNode | Fragment,\n\n /**\n * Optional options\n */\n options?: InsertContentAtOptions,\n ) => ReturnType\n }\n }\n}\n\nconst isFragment = (nodeOrFragment: ProseMirrorNode | Fragment): nodeOrFragment is Fragment => {\n return !('type' in nodeOrFragment)\n}\n\nexport const insertContentAt: RawCommands['insertContentAt'] =\n (position, value, options) =>\n ({ tr, dispatch, editor }) => {\n if (dispatch) {\n options = {\n parseOptions: editor.options.parseOptions,\n updateSelection: true,\n applyInputRules: false,\n applyPasteRules: false,\n ...options,\n }\n\n let content: Fragment | ProseMirrorNode\n\n const emitContentError = (error: Error) => {\n editor.emit('contentError', {\n editor,\n error,\n disableCollaboration: () => {\n if (\n 'collaboration' in editor.storage &&\n typeof editor.storage.collaboration === 'object' &&\n editor.storage.collaboration\n ) {\n ;(editor.storage.collaboration as any).isDisabled = true\n }\n },\n })\n }\n\n const parseOptions: ParseOptions = {\n preserveWhitespace: 'full',\n ...options.parseOptions,\n }\n\n // If `emitContentError` is enabled, we want to check the content for errors\n // but ignore them (do not remove the invalid content from the document)\n if (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) {\n try {\n createNodeFromContent(value, editor.schema, {\n parseOptions,\n errorOnInvalidContent: true,\n })\n } catch (e) {\n emitContentError(e as Error)\n }\n }\n\n try {\n content = createNodeFromContent(value, editor.schema, {\n parseOptions,\n errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n } catch (e) {\n emitContentError(e as Error)\n return false\n }\n\n let { from, to } =\n typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to }\n\n let isOnlyTextContent = true\n let isOnlyBlockContent = true\n const nodes = isFragment(content) ? content : [content]\n\n nodes.forEach(node => {\n // check if added node is valid\n node.check()\n\n isOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false\n\n isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false\n })\n\n // check if we can replace the wrapping node by\n // the newly inserted content\n // example:\n // replace an empty paragraph by an inserted image\n // instead of inserting the image below the paragraph\n if (from === to && isOnlyBlockContent) {\n const { parent } = tr.doc.resolve(from)\n const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount\n\n if (isEmptyTextBlock) {\n from -= 1\n to += 1\n }\n }\n\n let newContent\n\n // if there is only plain text we have to use `insertText`\n // because this will keep the current marks\n if (isOnlyTextContent) {\n // if value is string, we can use it directly\n // otherwise if it is an array, we have to join it\n if (Array.isArray(value)) {\n newContent = value.map(v => v.text || '').join('')\n } else if (value instanceof Fragment) {\n let text = ''\n\n value.forEach(node => {\n if (node.text) {\n text += node.text\n }\n })\n\n newContent = text\n } else if (typeof value === 'object' && !!value && !!value.text) {\n newContent = value.text\n } else {\n newContent = value as string\n }\n\n tr.insertText(newContent, from, to)\n } else {\n newContent = content\n\n const $from = tr.doc.resolve(from)\n const $fromNode = $from.node()\n const fromSelectionAtStart = $from.parentOffset === 0\n const isTextSelection = $fromNode.isText || $fromNode.isTextblock\n const hasContent = $fromNode.content.size > 0\n\n if (fromSelectionAtStart && isTextSelection && hasContent) {\n from = Math.max(0, from - 1)\n }\n\n tr.replaceWith(from, to, newContent)\n }\n\n // set cursor at end of inserted content\n if (options.updateSelection) {\n selectionToInsertionEnd(tr, tr.steps.length - 1, -1)\n }\n\n if (options.applyInputRules) {\n tr.setMeta('applyInputRules', { from, text: newContent })\n }\n\n if (options.applyPasteRules) {\n tr.setMeta('applyPasteRules', { from, text: newContent })\n }\n }\n\n return true\n }\n","import type { ParseOptions } from '@blockslides/pm/model'\nimport { DOMParser, Fragment, Node as ProseMirrorNode, Schema } from '@blockslides/pm/model'\n\nimport type { Content } from '../types.js'\nimport { elementFromString } from '../utilities/elementFromString.js'\n\nexport type CreateNodeFromContentOptions = {\n slice?: boolean\n parseOptions?: ParseOptions\n errorOnInvalidContent?: boolean\n}\n\n/**\n * Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.\n * @param content The JSON or HTML content to create the node from\n * @param schema The Prosemirror schema to use for the node\n * @param options Options for the parser\n * @returns The created Prosemirror node or fragment\n */\nexport function createNodeFromContent(\n content: Content | ProseMirrorNode | Fragment,\n schema: Schema,\n options?: CreateNodeFromContentOptions,\n): ProseMirrorNode | Fragment {\n if (content instanceof ProseMirrorNode || content instanceof Fragment) {\n return content\n }\n options = {\n slice: true,\n parseOptions: {},\n ...options,\n }\n\n const isJSONContent = typeof content === 'object' && content !== null\n const isTextContent = typeof content === 'string'\n\n if (isJSONContent) {\n try {\n const isArrayContent = Array.isArray(content) && content.length > 0\n\n // if the JSON Content is an array of nodes, create a fragment for each node\n if (isArrayContent) {\n return Fragment.fromArray(content.map(item => schema.nodeFromJSON(item)))\n }\n\n const node = schema.nodeFromJSON(content)\n\n if (options.errorOnInvalidContent) {\n node.check()\n }\n\n return node\n } catch (error) {\n if (options.errorOnInvalidContent) {\n throw new Error('[blockslides error] Invalid JSON content', { cause: error as Error })\n }\n\n console.warn('[blockslides warn]: Invalid content.', 'Passed value:', content, 'Error:', error)\n\n return createNodeFromContent('', schema, options)\n }\n }\n\n if (isTextContent) {\n // Check for invalid content\n if (options.errorOnInvalidContent) {\n let hasInvalidContent = false\n let invalidContent = ''\n\n // A copy of the current schema with a catch-all node at the end\n const contentCheckSchema = new Schema({\n topNode: schema.spec.topNode,\n marks: schema.spec.marks,\n // Prosemirror's schemas are executed such that: the last to execute, matches last\n // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle\n nodes: schema.spec.nodes.append({\n __tiptap__private__unknown__catch__all__node: {\n content: 'inline*',\n group: 'block',\n parseDOM: [\n {\n tag: '*',\n getAttrs: e => {\n // If this is ever called, we know that the content has something that we don't know how to handle in the schema\n hasInvalidContent = true\n // Try to stringify the element for a more helpful error message\n invalidContent = typeof e === 'string' ? e : e.outerHTML\n return null\n },\n },\n ],\n },\n }),\n })\n\n if (options.slice) {\n DOMParser.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options.parseOptions)\n } else {\n DOMParser.fromSchema(contentCheckSchema).parse(elementFromString(content), options.parseOptions)\n }\n\n if (options.errorOnInvalidContent && hasInvalidContent) {\n throw new Error('[blockslides error] Invalid HTML content', {\n cause: new Error(`Invalid element found: ${invalidContent}`),\n })\n }\n }\n\n const parser = DOMParser.fromSchema(schema)\n\n if (options.slice) {\n return parser.parseSlice(elementFromString(content), options.parseOptions).content\n }\n\n return parser.parse(elementFromString(content), options.parseOptions)\n }\n\n return createNodeFromContent('', schema, options)\n}\n","const removeWhitespaces = (node: HTMLElement) => {\n const children = node.childNodes\n\n for (let i = children.length - 1; i >= 0; i -= 1) {\n const child = children[i]\n\n if (child.nodeType === 3 && child.nodeValue && /^(\\n\\s\\s|\\n)$/.test(child.nodeValue)) {\n node.removeChild(child)\n } else if (child.nodeType === 1) {\n removeWhitespaces(child as HTMLElement)\n }\n }\n\n return node\n}\n\nexport function elementFromString(value: string): HTMLElement {\n if (typeof window === 'undefined') {\n throw new Error('[blockslides error] there is no window object available, so this function cannot be used')\n }\n // add a wrapper to preserve leading and trailing whitespace\n const wrappedValue = `<body>${value}</body>`\n\n const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body\n\n return removeWhitespaces(html)\n}\n","import type { Transaction } from '@blockslides/pm/state'\nimport { Selection } from '@blockslides/pm/state'\nimport { ReplaceAroundStep, ReplaceStep } from '@blockslides/pm/transform'\n\n// source: https://github.com/ProseMirror/prosemirror-state/blob/master/src/selection.js#L466\nexport function selectionToInsertionEnd(tr: Transaction, startLen: number, bias: number) {\n const last = tr.steps.length - 1\n\n if (last < startLen) {\n return\n }\n\n const step = tr.steps[last]\n\n if (!(step instanceof ReplaceStep || step instanceof ReplaceAroundStep)) {\n return\n }\n\n const map = tr.mapping.maps[last]\n let end = 0\n\n map.forEach((_from, _to, _newFrom, newTo) => {\n if (end === 0) {\n end = newTo\n }\n })\n\n tr.setSelection(Selection.near(tr.doc.resolve(end), bias))\n}\n","import {\n joinBackward as originalJoinBackward,\n joinDown as originalJoinDown,\n joinForward as originalJoinForward,\n joinUp as originalJoinUp,\n} from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n joinUp: {\n /**\n * Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.\n * @example editor.commands.joinUp()\n */\n joinUp: () => ReturnType\n }\n joinDown: {\n /**\n * Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.\n * @example editor.commands.joinDown()\n */\n joinDown: () => ReturnType\n }\n joinBackward: {\n /**\n * If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there's a block directly before it that can be joined, join them.\n * If not, try to move the selected block closer to the next one in the document structure by lifting it out of its\n * parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.\n * @example editor.commands.joinBackward()\n */\n joinBackward: () => ReturnType\n }\n joinForward: {\n /**\n * If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it,\n * either by joining them or by moving the other block closer to this one in the tree structure.\n * Will use the view for accurate start-of-textblock detection if given.\n * @example editor.commands.joinForward()\n */\n joinForward: () => ReturnType\n }\n }\n}\n\nexport const joinUp: RawCommands['joinUp'] =\n () =>\n ({ state, dispatch }) => {\n return originalJoinUp(state, dispatch)\n }\n\nexport const joinDown: RawCommands['joinDown'] =\n () =>\n ({ state, dispatch }) => {\n return originalJoinDown(state, dispatch)\n }\n\nexport const joinBackward: RawCommands['joinBackward'] =\n () =>\n ({ state, dispatch }) => {\n return originalJoinBackward(state, dispatch)\n }\n\nexport const joinForward: RawCommands['joinForward'] =\n () =>\n ({ state, dispatch }) => {\n return originalJoinForward(state, dispatch)\n }\n","import { joinPoint } from '@blockslides/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n joinItemBackward: {\n /**\n * Join two items backward.\n * @example editor.commands.joinItemBackward()\n */\n joinItemBackward: () => ReturnType\n }\n }\n}\n\nexport const joinItemBackward: RawCommands['joinItemBackward'] =\n () =>\n ({ state, dispatch, tr }) => {\n try {\n const point = joinPoint(state.doc, state.selection.$from.pos, -1)\n\n if (point === null || point === undefined) {\n return false\n }\n\n tr.join(point, 2)\n\n if (dispatch) {\n dispatch(tr)\n }\n\n return true\n } catch {\n return false\n }\n }\n","import { joinPoint } from '@blockslides/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n joinItemForward: {\n /**\n * Join two items Forwards.\n * @example editor.commands.joinItemForward()\n */\n joinItemForward: () => ReturnType\n }\n }\n}\n\nexport const joinItemForward: RawCommands['joinItemForward'] =\n () =>\n ({ state, dispatch, tr }) => {\n try {\n const point = joinPoint(state.doc, state.selection.$from.pos, +1)\n\n if (point === null || point === undefined) {\n return false\n }\n\n tr.join(point, 2)\n\n if (dispatch) {\n dispatch(tr)\n }\n\n return true\n } catch {\n return false\n }\n }\n","import { joinTextblockBackward as originalCommand } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n joinTextblockBackward: {\n /**\n * A more limited form of joinBackward that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.\n */\n joinTextblockBackward: () => ReturnType\n }\n }\n}\n\nexport const joinTextblockBackward: RawCommands['joinTextblockBackward'] =\n () =>\n ({ state, dispatch }) => {\n return originalCommand(state, dispatch)\n }\n","import { joinTextblockForward as originalCommand } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n joinTextblockForward: {\n /**\n * A more limited form of joinForward that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.\n */\n joinTextblockForward: () => ReturnType\n }\n }\n}\n\nexport const joinTextblockForward: RawCommands['joinTextblockForward'] =\n () =>\n ({ state, dispatch }) => {\n return originalCommand(state, dispatch)\n }\n","export function isMacOS(): boolean {\n return typeof navigator !== 'undefined' ? /Mac/.test(navigator.platform) : false\n}\n","import type { RawCommands } from '../types.js'\nimport { isiOS } from '../utilities/isiOS.js'\nimport { isMacOS } from '../utilities/isMacOS.js'\n\nfunction normalizeKeyName(name: string) {\n const parts = name.split(/-(?!$)/)\n let result = parts[parts.length - 1]\n\n if (result === 'Space') {\n result = ' '\n }\n\n let alt\n let ctrl\n let shift\n let meta\n\n for (let i = 0; i < parts.length - 1; i += 1) {\n const mod = parts[i]\n\n if (/^(cmd|meta|m)$/i.test(mod)) {\n meta = true\n } else if (/^a(lt)?$/i.test(mod)) {\n alt = true\n } else if (/^(c|ctrl|control)$/i.test(mod)) {\n ctrl = true\n } else if (/^s(hift)?$/i.test(mod)) {\n shift = true\n } else if (/^mod$/i.test(mod)) {\n if (isiOS() || isMacOS()) {\n meta = true\n } else {\n ctrl = true\n }\n } else {\n throw new Error(`Unrecognized modifier name: ${mod}`)\n }\n }\n\n if (alt) {\n result = `Alt-${result}`\n }\n\n if (ctrl) {\n result = `Ctrl-${result}`\n }\n\n if (meta) {\n result = `Meta-${result}`\n }\n\n if (shift) {\n result = `Shift-${result}`\n }\n\n return result\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n keyboardShortcut: {\n /**\n * Trigger a keyboard shortcut.\n * @param name The name of the keyboard shortcut.\n * @example editor.commands.keyboardShortcut('Mod-b')\n */\n keyboardShortcut: (name: string) => ReturnType\n }\n }\n}\n\nexport const keyboardShortcut: RawCommands['keyboardShortcut'] =\n name =>\n ({ editor, view, tr, dispatch }) => {\n const keys = normalizeKeyName(name).split(/-(?!$)/)\n const key = keys.find(item => !['Alt', 'Ctrl', 'Meta', 'Shift'].includes(item))\n const event = new KeyboardEvent('keydown', {\n key: key === 'Space' ? ' ' : key,\n altKey: keys.includes('Alt'),\n ctrlKey: keys.includes('Ctrl'),\n metaKey: keys.includes('Meta'),\n shiftKey: keys.includes('Shift'),\n bubbles: true,\n cancelable: true,\n })\n\n const capturedTransaction = editor.captureTransaction(() => {\n view.someProp('handleKeyDown', f => f(view, event))\n })\n\n capturedTransaction?.steps.forEach(step => {\n const newStep = step.map(tr.mapping)\n\n if (newStep && dispatch) {\n tr.maybeStep(newStep)\n }\n })\n\n return true\n }\n","import { lift as originalLift } from '@blockslides/pm/commands'\nimport type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n lift: {\n /**\n * Removes an existing wrap if possible lifting the node out of it\n * @param typeOrName The type or name of the node.\n * @param attributes The attributes of the node.\n * @example editor.commands.lift('paragraph')\n * @example editor.commands.lift('heading', { level: 1 })\n */\n lift: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const lift: RawCommands['lift'] =\n (typeOrName, attributes = {}) =>\n ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n const isActive = isNodeActive(state, type, attributes)\n\n if (!isActive) {\n return false\n }\n\n return originalLift(state, dispatch)\n }\n","import type { NodeType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\nimport type { NodeRange } from '../types.js'\nimport { objectIncludes } from '../utilities/objectIncludes.js'\nimport { getNodeType } from './getNodeType.js'\n\nexport function isNodeActive(\n state: EditorState,\n typeOrName: NodeType | string | null,\n attributes: Record<string, any> = {},\n): boolean {\n const { from, to, empty } = state.selection\n const type = typeOrName ? getNodeType(typeOrName, state.schema) : null\n\n const nodeRanges: NodeRange[] = []\n\n state.doc.nodesBetween(from, to, (node, pos) => {\n if (node.isText) {\n return\n }\n\n const relativeFrom = Math.max(from, pos)\n const relativeTo = Math.min(to, pos + node.nodeSize)\n\n nodeRanges.push({\n node,\n from: relativeFrom,\n to: relativeTo,\n })\n })\n\n const selectionRange = to - from\n const matchedNodeRanges = nodeRanges\n .filter(nodeRange => {\n if (!type) {\n return true\n }\n\n return type.name === nodeRange.node.type.name\n })\n .filter(nodeRange => objectIncludes(nodeRange.node.attrs, attributes, { strict: false }))\n\n if (empty) {\n return !!matchedNodeRanges.length\n }\n\n const range = matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0)\n\n return range >= selectionRange\n}\n","import { liftEmptyBlock as originalLiftEmptyBlock } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n liftEmptyBlock: {\n /**\n * If the cursor is in an empty textblock that can be lifted, lift the block.\n * @example editor.commands.liftEmptyBlock()\n */\n liftEmptyBlock: () => ReturnType\n }\n }\n}\n\nexport const liftEmptyBlock: RawCommands['liftEmptyBlock'] =\n () =>\n ({ state, dispatch }) => {\n return originalLiftEmptyBlock(state, dispatch)\n }\n","import type { NodeType } from '@blockslides/pm/model'\nimport { liftListItem as originalLiftListItem } from '@blockslides/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n liftListItem: {\n /**\n * Create a command to lift the list item around the selection up into a wrapping list.\n * @param typeOrName The type or name of the node.\n * @example editor.commands.liftListItem('listItem')\n */\n liftListItem: (typeOrName: string | NodeType) => ReturnType\n }\n }\n}\n\nexport const liftListItem: RawCommands['liftListItem'] =\n typeOrName =>\n ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalLiftListItem(type)(state, dispatch)\n }\n","import { newlineInCode as originalNewlineInCode } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n newlineInCode: {\n /**\n * Add a newline character in code.\n * @example editor.commands.newlineInCode()\n */\n newlineInCode: () => ReturnType\n }\n }\n}\n\nexport const newlineInCode: RawCommands['newlineInCode'] =\n () =>\n ({ state, dispatch }) => {\n return originalNewlineInCode(state, dispatch)\n }\n","import type { Schema } from '@blockslides/pm/model'\n\n/**\n * Get the type of a schema item by its name.\n * @param name The name of the schema item\n * @param schema The Prosemiror schema to search in\n * @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist\n */\nexport function getSchemaTypeNameByName(name: string, schema: Schema): 'node' | 'mark' | null {\n if (schema.nodes[name]) {\n return 'node'\n }\n\n if (schema.marks[name]) {\n return 'mark'\n }\n\n return null\n}\n","/**\n * Remove a property or an array of properties from an object\n * @param obj Object\n * @param key Key to remove\n */\nexport function deleteProps(obj: Record<string, any>, propOrProps: string | string[]): Record<string, any> {\n const props = typeof propOrProps === 'string' ? [propOrProps] : propOrProps\n\n return Object.keys(obj).reduce((newObj: Record<string, any>, prop) => {\n if (!props.includes(prop)) {\n newObj[prop] = obj[prop]\n }\n\n return newObj\n }, {})\n}\n","import type { MarkType, NodeType } from '@blockslides/pm/model'\n\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName.js'\nimport type { RawCommands } from '../types.js'\nimport { deleteProps } from '../utilities/deleteProps.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n resetAttributes: {\n /**\n * Resets some node attributes to the default value.\n * @param typeOrName The type or name of the node.\n * @param attributes The attributes of the node to reset.\n * @example editor.commands.resetAttributes('heading', 'level')\n */\n resetAttributes: (typeOrName: string | NodeType | MarkType, attributes: string | string[]) => ReturnType\n }\n }\n}\n\nexport const resetAttributes: RawCommands['resetAttributes'] =\n (typeOrName, attributes) =>\n ({ tr, state, dispatch }) => {\n let nodeType: NodeType | null = null\n let markType: MarkType | null = null\n\n const schemaType = getSchemaTypeNameByName(\n typeof typeOrName === 'string' ? typeOrName : typeOrName.name,\n state.schema,\n )\n\n if (!schemaType) {\n return false\n }\n\n if (schemaType === 'node') {\n nodeType = getNodeType(typeOrName as NodeType, state.schema)\n }\n\n if (schemaType === 'mark') {\n markType = getMarkType(typeOrName as MarkType, state.schema)\n }\n\n if (dispatch) {\n tr.selection.ranges.forEach(range => {\n state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {\n if (nodeType && nodeType === node.type) {\n tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes))\n }\n\n if (markType && node.marks.length) {\n node.marks.forEach(mark => {\n if (markType === mark.type) {\n tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)))\n }\n })\n }\n })\n })\n }\n\n return true\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n scrollIntoView: {\n /**\n * Scroll the selection into view.\n * @example editor.commands.scrollIntoView()\n */\n scrollIntoView: () => ReturnType\n }\n }\n}\n\nexport const scrollIntoView: RawCommands['scrollIntoView'] =\n () =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n tr.scrollIntoView()\n }\n\n return true\n }\n","import { AllSelection } from '@blockslides/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectAll: {\n /**\n * Select the whole document.\n * @example editor.commands.selectAll()\n */\n selectAll: () => ReturnType\n }\n }\n}\n\nexport const selectAll: RawCommands['selectAll'] =\n () =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n const selection = new AllSelection(tr.doc)\n\n tr.setSelection(selection)\n }\n\n return true\n }\n","import { selectNodeBackward as originalSelectNodeBackward } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectNodeBackward: {\n /**\n * Select a node backward.\n * @example editor.commands.selectNodeBackward()\n */\n selectNodeBackward: () => ReturnType\n }\n }\n}\n\nexport const selectNodeBackward: RawCommands['selectNodeBackward'] =\n () =>\n ({ state, dispatch }) => {\n return originalSelectNodeBackward(state, dispatch)\n }\n","import { selectNodeForward as originalSelectNodeForward } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectNodeForward: {\n /**\n * Select a node forward.\n * @example editor.commands.selectNodeForward()\n */\n selectNodeForward: () => ReturnType\n }\n }\n}\n\nexport const selectNodeForward: RawCommands['selectNodeForward'] =\n () =>\n ({ state, dispatch }) => {\n return originalSelectNodeForward(state, dispatch)\n }\n","import { selectParentNode as originalSelectParentNode } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectParentNode: {\n /**\n * Select the parent node.\n * @example editor.commands.selectParentNode()\n */\n selectParentNode: () => ReturnType\n }\n }\n}\n\nexport const selectParentNode: RawCommands['selectParentNode'] =\n () =>\n ({ state, dispatch }) => {\n return originalSelectParentNode(state, dispatch)\n }\n","// @ts-ignore\n// TODO: add types to @types/prosemirror-commands\nimport { selectTextblockEnd as originalSelectTextblockEnd } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectTextblockEnd: {\n /**\n * Moves the cursor to the end of current text block.\n * @example editor.commands.selectTextblockEnd()\n */\n selectTextblockEnd: () => ReturnType\n }\n }\n}\n\nexport const selectTextblockEnd: RawCommands['selectTextblockEnd'] =\n () =>\n ({ state, dispatch }) => {\n return originalSelectTextblockEnd(state, dispatch)\n }\n","// @ts-ignore\n// TODO: add types to @types/prosemirror-commands\nimport { selectTextblockStart as originalSelectTextblockStart } from '@blockslides/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n selectTextblockStart: {\n /**\n * Moves the cursor to the start of current text block.\n * @example editor.commands.selectTextblockStart()\n */\n selectTextblockStart: () => ReturnType\n }\n }\n}\n\nexport const selectTextblockStart: RawCommands['selectTextblockStart'] =\n () =>\n ({ state, dispatch }) => {\n return originalSelectTextblockStart(state, dispatch)\n }\n","import type { Fragment, Node as ProseMirrorNode, ParseOptions, Schema } from '@blockslides/pm/model'\n\nimport type { Content } from '../types.js'\nimport { createNodeFromContent } from './createNodeFromContent.js'\n\n/**\n * Create a new Prosemirror document node from content.\n * @param content The JSON or HTML content to create the document from\n * @param schema The Prosemirror schema to use for the document\n * @param parseOptions Options for the parser\n * @returns The created Prosemirror document node\n */\nexport function createDocument(\n content: Content | ProseMirrorNode | Fragment,\n schema: Schema,\n parseOptions: ParseOptions = {},\n options: { errorOnInvalidContent?: boolean } = {},\n): ProseMirrorNode {\n return createNodeFromContent(content, schema, {\n slice: false,\n parseOptions,\n errorOnInvalidContent: options.errorOnInvalidContent,\n }) as ProseMirrorNode\n}\n","import type { Fragment, Node as ProseMirrorNode, ParseOptions } from '@blockslides/pm/model'\n\nimport { createDocument } from '../helpers/createDocument.js'\nimport type { Content, RawCommands } from '../types.js'\n\nexport interface SetContentOptions {\n /**\n * Options for parsing the content.\n * @default {}\n */\n parseOptions?: ParseOptions\n\n /**\n * Whether to throw an error if the content is invalid.\n */\n errorOnInvalidContent?: boolean\n\n /**\n * Whether to emit an update event.\n * @default true\n */\n emitUpdate?: boolean\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setContent: {\n /**\n * Replace the whole document with new content.\n * @param content The new content.\n * @param emitUpdate Whether to emit an update event.\n * @param parseOptions Options for parsing the content.\n * @example editor.commands.setContent('<p>Example text</p>')\n */\n setContent: (\n /**\n * The new content.\n */\n content: Content | Fragment | ProseMirrorNode,\n\n /**\n * Options for `setContent`.\n */\n options?: SetContentOptions,\n ) => ReturnType\n }\n }\n}\n\nexport const setContent: RawCommands['setContent'] =\n (content, { errorOnInvalidContent, emitUpdate = true, parseOptions = {} } = {}) =>\n ({ editor, tr, dispatch, commands }) => {\n const { doc } = tr\n\n // This is to keep backward compatibility with the previous behavior\n // TODO remove this in the next major version\n if (parseOptions.preserveWhitespace !== 'full') {\n const document = createDocument(content, editor.schema, parseOptions, {\n errorOnInvalidContent: errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n\n if (dispatch) {\n tr.replaceWith(0, doc.content.size, document).setMeta('preventUpdate', !emitUpdate)\n }\n return true\n }\n\n if (dispatch) {\n tr.setMeta('preventUpdate', !emitUpdate)\n }\n\n return commands.insertContentAt({ from: 0, to: doc.content.size }, content, {\n parseOptions,\n errorOnInvalidContent: errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n }\n","import type { Mark, MarkType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\nimport { getMarkType } from './getMarkType.js'\n\nexport function getMarkAttributes(state: EditorState, typeOrName: string | MarkType): Record<string, any> {\n const type = getMarkType(typeOrName, state.schema)\n const { from, to, empty } = state.selection\n const marks: Mark[] = []\n\n if (empty) {\n if (state.storedMarks) {\n marks.push(...state.storedMarks)\n }\n\n marks.push(...state.selection.$head.marks())\n } else {\n state.doc.nodesBetween(from, to, node => {\n marks.push(...node.marks)\n })\n }\n\n const mark = marks.find(markItem => markItem.type.name === type.name)\n\n if (!mark) {\n return {}\n }\n\n return { ...mark.attrs }\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\nimport type { Transaction } from '@blockslides/pm/state'\nimport { Transform } from '@blockslides/pm/transform'\n\n/**\n * Returns a new `Transform` based on all steps of the passed transactions.\n * @param oldDoc The Prosemirror node to start from\n * @param transactions The transactions to combine\n * @returns A new `Transform` with all steps of the passed transactions\n */\nexport function combineTransactionSteps(oldDoc: ProseMirrorNode, transactions: Transaction[]): Transform {\n const transform = new Transform(oldDoc)\n\n transactions.forEach(transaction => {\n transaction.steps.forEach(step => {\n transform.step(step)\n })\n })\n\n return transform\n}\n","import type { ContentMatch, NodeType } from '@blockslides/pm/model'\n\n/**\n * Gets the default block type at a given match\n * @param match The content match to get the default block type from\n * @returns The default block type or null\n */\nexport function defaultBlockAt(match: ContentMatch): NodeType | null {\n for (let i = 0; i < match.edgeCount; i += 1) {\n const { type } = match.edge(i)\n\n if (type.isTextblock && !type.hasRequiredAttrs()) {\n return type\n }\n }\n\n return null\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { NodeWithPos, Predicate } from '../types.js'\n\n/**\n * Find children inside a Prosemirror node that match a predicate.\n * @param node The Prosemirror node to search in\n * @param predicate The predicate to match\n * @returns An array of nodes with their positions\n */\nexport function findChildren(node: ProseMirrorNode, predicate: Predicate): NodeWithPos[] {\n const nodesWithPos: NodeWithPos[] = []\n\n node.descendants((child, pos) => {\n if (predicate(child)) {\n nodesWithPos.push({\n node: child,\n pos,\n })\n }\n })\n\n return nodesWithPos\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { NodeWithPos, Predicate, Range } from '../types.js'\n\n/**\n * Same as `findChildren` but searches only within a `range`.\n * @param node The Prosemirror node to search in\n * @param range The range to search in\n * @param predicate The predicate to match\n * @returns An array of nodes with their positions\n */\nexport function findChildrenInRange(node: ProseMirrorNode, range: Range, predicate: Predicate): NodeWithPos[] {\n const nodesWithPos: NodeWithPos[] = []\n\n // if (range.from === range.to) {\n // const nodeAt = node.nodeAt(range.from)\n\n // if (nodeAt) {\n // nodesWithPos.push({\n // node: nodeAt,\n // pos: range.from,\n // })\n // }\n // }\n\n node.nodesBetween(range.from, range.to, (child, pos) => {\n if (predicate(child)) {\n nodesWithPos.push({\n node: child,\n pos,\n })\n }\n })\n\n return nodesWithPos\n}\n","import type { Node as ProseMirrorNode, ResolvedPos } from '@blockslides/pm/model'\n\nimport type { Predicate } from '../types.js'\n\n/**\n * Finds the closest parent node to a resolved position that matches a predicate.\n * @param $pos The resolved position to search from\n * @param predicate The predicate to match\n * @returns The closest parent node to the resolved position that matches the predicate\n * @example ```js\n * findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')\n * ```\n */\nexport function findParentNodeClosestToPos(\n $pos: ResolvedPos,\n predicate: Predicate,\n):\n | {\n pos: number\n start: number\n depth: number\n node: ProseMirrorNode\n }\n | undefined {\n for (let i = $pos.depth; i > 0; i -= 1) {\n const node = $pos.node(i)\n\n if (predicate(node)) {\n return {\n pos: i > 0 ? $pos.before(i) : 0,\n start: $pos.start(i),\n depth: i,\n node,\n }\n }\n }\n}\n","import type { Selection } from '@blockslides/pm/state'\n\nimport type { Predicate } from '../types.js'\nimport { findParentNodeClosestToPos } from './findParentNodeClosestToPos.js'\n\n/**\n * Finds the closest parent node to the current selection that matches a predicate.\n * @param predicate The predicate to match\n * @returns A command that finds the closest parent node to the current selection that matches the predicate\n * @example ```js\n * findParentNode(node => node.type.name === 'paragraph')\n * ```\n */\nexport function findParentNode(\n predicate: Predicate,\n): (selection: Selection) => ReturnType<typeof findParentNodeClosestToPos> {\n return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)\n}\n","import type { ExtensionConfig } from '../Extension.js'\nimport type { MarkConfig } from '../Mark.js'\nimport type { NodeConfig } from '../Node.js'\nimport type { AnyExtension, MaybeThisParameterType, RemoveThis } from '../types.js'\n\n/**\n * Returns a field from an extension\n * @param extension The BlockSlides extension\n * @param field The field, for example `renderHTML` or `priority`\n * @param context The context object that should be passed as `this` into the function\n * @returns The field value\n */\nexport function getExtensionField<T = any, E extends AnyExtension = any>(\n extension: E,\n field: keyof ExtensionConfig | keyof MarkConfig | keyof NodeConfig,\n context?: Omit<MaybeThisParameterType<T>, 'parent'>,\n): RemoveThis<T> {\n if (extension.config[field as keyof typeof extension.config] === undefined && extension.parent) {\n return getExtensionField(extension.parent, field, context)\n }\n\n if (typeof extension.config[field as keyof typeof extension.config] === 'function') {\n const value = (extension.config[field as keyof typeof extension.config] as any).bind({\n ...context,\n parent: extension.parent ? getExtensionField(extension.parent, field, context) : null,\n })\n\n return value\n }\n\n return extension.config[field as keyof typeof extension.config] as RemoveThis<T>\n}\n","import type { AnyConfig, Extensions } from '../types.js'\nimport { getExtensionField } from './getExtensionField.js'\n\n/**\n * Create a flattened array of extensions by traversing the `addExtensions` field.\n * @param extensions An array of Tiptap extensions\n * @returns A flattened array of Tiptap extensions\n */\nexport function flattenExtensions(extensions: Extensions): Extensions {\n return (\n extensions\n .map(extension => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n\n const addExtensions = getExtensionField<AnyConfig['addExtensions']>(extension, 'addExtensions', context)\n\n if (addExtensions) {\n return [extension, ...flattenExtensions(addExtensions())]\n }\n\n return extension\n })\n // `Infinity` will break TypeScript so we set a number that is probably high enough\n .flat(10)\n )\n}\n","import { Node } from '@blockslides/pm/model'\n\nimport type { Extensions, JSONContent } from '../types.js'\nimport { getHTMLFromFragment } from './getHTMLFromFragment.js'\nimport { getSchema } from './getSchema.js'\n\n/**\n * Generate HTML from a JSONContent\n * @param doc The JSONContent to generate HTML from\n * @param extensions The extensions to use for the schema\n * @returns The generated HTML\n */\nexport function generateHTML(doc: JSONContent, extensions: Extensions): string {\n const schema = getSchema(extensions)\n const contentNode = Node.fromJSON(schema, doc)\n\n return getHTMLFromFragment(contentNode.content, schema)\n}\n","import type { Fragment, Schema } from '@blockslides/pm/model'\nimport { DOMSerializer } from '@blockslides/pm/model'\n\nexport function getHTMLFromFragment(fragment: Fragment, schema: Schema): string {\n const documentFragment = DOMSerializer.fromSchema(schema).serializeFragment(fragment)\n\n const temporaryDocument = document.implementation.createHTMLDocument()\n const container = temporaryDocument.createElement('div')\n\n container.appendChild(documentFragment)\n\n return container.innerHTML\n}\n","import type { MarkSpec, NodeSpec, TagParseRule } from '@blockslides/pm/model'\nimport { Schema } from '@blockslides/pm/model'\n\nimport type { Editor, MarkConfig, NodeConfig } from '../index.js'\nimport type { AnyConfig, Extensions } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\nimport { isEmptyObject } from '../utilities/isEmptyObject.js'\nimport { getAttributesFromExtensions } from './getAttributesFromExtensions.js'\nimport { getExtensionField } from './getExtensionField.js'\nimport { getRenderedAttributes } from './getRenderedAttributes.js'\nimport { injectExtensionAttributesToParseRule } from './injectExtensionAttributesToParseRule.js'\nimport { splitExtensions } from './splitExtensions.js'\n\nfunction cleanUpSchemaItem<T>(data: T) {\n return Object.fromEntries(\n // @ts-ignore\n Object.entries(data).filter(([key, value]) => {\n if (key === 'attrs' && isEmptyObject(value as object | undefined)) {\n return false\n }\n\n return value !== null && value !== undefined\n }),\n ) as T\n}\n\n/**\n * Creates a new Prosemirror schema based on the given extensions.\n * @param extensions An array of Tiptap extensions\n * @param editor The editor instance\n * @returns A Prosemirror schema\n */\nexport function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema {\n const allAttributes = getAttributesFromExtensions(extensions)\n const { nodeExtensions, markExtensions } = splitExtensions(extensions)\n const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name\n\n const nodes = Object.fromEntries(\n nodeExtensions.map(extension => {\n const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n editor,\n }\n\n const extraNodeFields = extensions.reduce((fields, e) => {\n const extendNodeSchema = getExtensionField<AnyConfig['extendNodeSchema']>(e, 'extendNodeSchema', context)\n\n return {\n ...fields,\n ...(extendNodeSchema ? extendNodeSchema(extension) : {}),\n }\n }, {})\n\n const schema: NodeSpec = cleanUpSchemaItem({\n ...extraNodeFields,\n content: callOrReturn(getExtensionField<NodeConfig['content']>(extension, 'content', context)),\n marks: callOrReturn(getExtensionField<NodeConfig['marks']>(extension, 'marks', context)),\n group: callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context)),\n inline: callOrReturn(getExtensionField<NodeConfig['inline']>(extension, 'inline', context)),\n atom: callOrReturn(getExtensionField<NodeConfig['atom']>(extension, 'atom', context)),\n selectable: callOrReturn(getExtensionField<NodeConfig['selectable']>(extension, 'selectable', context)),\n draggable: callOrReturn(getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context)),\n code: callOrReturn(getExtensionField<NodeConfig['code']>(extension, 'code', context)),\n whitespace: callOrReturn(getExtensionField<NodeConfig['whitespace']>(extension, 'whitespace', context)),\n linebreakReplacement: callOrReturn(\n getExtensionField<NodeConfig['linebreakReplacement']>(extension, 'linebreakReplacement', context),\n ),\n defining: callOrReturn(getExtensionField<NodeConfig['defining']>(extension, 'defining', context)),\n isolating: callOrReturn(getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context)),\n attrs: Object.fromEntries(\n extensionAttributes.map(extensionAttribute => {\n return [\n extensionAttribute.name,\n { default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },\n ]\n }),\n ),\n })\n\n const parseHTML = callOrReturn(getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context))\n\n if (parseHTML) {\n schema.parseDOM = parseHTML.map(parseRule =>\n injectExtensionAttributesToParseRule(parseRule, extensionAttributes),\n ) as TagParseRule[]\n }\n\n const renderHTML = getExtensionField<NodeConfig['renderHTML']>(extension, 'renderHTML', context)\n\n if (renderHTML) {\n schema.toDOM = node =>\n renderHTML({\n node,\n HTMLAttributes: getRenderedAttributes(node, extensionAttributes),\n })\n }\n\n const renderText = getExtensionField<NodeConfig['renderText']>(extension, 'renderText', context)\n\n if (renderText) {\n schema.toText = renderText\n }\n\n return [extension.name, schema]\n }),\n )\n\n const marks = Object.fromEntries(\n markExtensions.map(extension => {\n const extensionAttributes = allAttributes.filter(attribute => attribute.type === extension.name)\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n editor,\n }\n\n const extraMarkFields = extensions.reduce((fields, e) => {\n const extendMarkSchema = getExtensionField<AnyConfig['extendMarkSchema']>(e, 'extendMarkSchema', context)\n\n return {\n ...fields,\n ...(extendMarkSchema ? extendMarkSchema(extension as any) : {}),\n }\n }, {})\n\n const schema: MarkSpec = cleanUpSchemaItem({\n ...extraMarkFields,\n inclusive: callOrReturn(getExtensionField<MarkConfig['inclusive']>(extension, 'inclusive', context)),\n excludes: callOrReturn(getExtensionField<MarkConfig['excludes']>(extension, 'excludes', context)),\n group: callOrReturn(getExtensionField<MarkConfig['group']>(extension, 'group', context)),\n spanning: callOrReturn(getExtensionField<MarkConfig['spanning']>(extension, 'spanning', context)),\n code: callOrReturn(getExtensionField<MarkConfig['code']>(extension, 'code', context)),\n attrs: Object.fromEntries(\n extensionAttributes.map(extensionAttribute => {\n return [\n extensionAttribute.name,\n { default: extensionAttribute?.attribute?.default, validate: extensionAttribute?.attribute?.validate },\n ]\n }),\n ),\n })\n\n const parseHTML = callOrReturn(getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context))\n\n if (parseHTML) {\n schema.parseDOM = parseHTML.map(parseRule =>\n injectExtensionAttributesToParseRule(parseRule, extensionAttributes),\n )\n }\n\n const renderHTML = getExtensionField<MarkConfig['renderHTML']>(extension, 'renderHTML', context)\n\n if (renderHTML) {\n schema.toDOM = mark =>\n renderHTML({\n mark,\n HTMLAttributes: getRenderedAttributes(mark, extensionAttributes),\n })\n }\n\n return [extension.name, schema]\n }),\n )\n\n return new Schema({\n topNode,\n nodes,\n marks,\n })\n}\n","// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function isFunction(value: any): value is Function {\n return typeof value === 'function'\n}\n","import type { MaybeReturnType } from '../types.js'\nimport { isFunction } from './isFunction.js'\n\n/**\n * Optionally calls `value` as a function.\n * Otherwise it is returned directly.\n * @param value Function or any value.\n * @param context Optional context to bind to function.\n * @param props Optional props to pass to function.\n */\nexport function callOrReturn<T>(value: T, context: any = undefined, ...props: any[]): MaybeReturnType<T> {\n if (isFunction(value)) {\n if (context) {\n return value.bind(context)(...props)\n }\n\n return value(...props)\n }\n\n return value as MaybeReturnType<T>\n}\n","export function isEmptyObject(value = {}): boolean {\n return Object.keys(value).length === 0 && value.constructor === Object\n}\n","import type { Extension } from '../Extension.js'\nimport type { Mark } from '../Mark.js'\nimport type { Node } from '../Node.js'\nimport type { Extensions } from '../types.js'\n\nexport function splitExtensions(extensions: Extensions) {\n const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]\n const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]\n const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]\n\n return {\n baseExtensions,\n nodeExtensions,\n markExtensions,\n }\n}\n","import type { MarkConfig, NodeConfig } from '../index.js'\nimport type { AnyConfig, Attribute, Attributes, ExtensionAttribute, Extensions } from '../types.js'\nimport { getExtensionField } from './getExtensionField.js'\nimport { splitExtensions } from './splitExtensions.js'\n\n/**\n * Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.\n * @param extensions List of extensions\n */\nexport function getAttributesFromExtensions(extensions: Extensions): ExtensionAttribute[] {\n const extensionAttributes: ExtensionAttribute[] = []\n const { nodeExtensions, markExtensions } = splitExtensions(extensions)\n const nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions]\n const defaultAttribute: Required<Omit<Attribute, 'validate'>> & Pick<Attribute, 'validate'> = {\n default: null,\n validate: undefined,\n rendered: true,\n renderHTML: null,\n parseHTML: null,\n keepOnSplit: true,\n isRequired: false,\n }\n\n extensions.forEach(extension => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n extensions: nodeAndMarkExtensions,\n }\n\n const addGlobalAttributes = getExtensionField<AnyConfig['addGlobalAttributes']>(\n extension,\n 'addGlobalAttributes',\n context,\n )\n\n if (!addGlobalAttributes) {\n return\n }\n\n const globalAttributes = addGlobalAttributes()\n\n globalAttributes.forEach(globalAttribute => {\n globalAttribute.types.forEach(type => {\n Object.entries(globalAttribute.attributes).forEach(([name, attribute]) => {\n extensionAttributes.push({\n type,\n name,\n attribute: {\n ...defaultAttribute,\n ...attribute,\n },\n })\n })\n })\n })\n })\n\n nodeAndMarkExtensions.forEach(extension => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n\n const addAttributes = getExtensionField<NodeConfig['addAttributes'] | MarkConfig['addAttributes']>(\n extension,\n 'addAttributes',\n context,\n )\n\n if (!addAttributes) {\n return\n }\n\n // TODO: remove `as Attributes`\n const attributes = addAttributes() as Attributes\n\n Object.entries(attributes).forEach(([name, attribute]) => {\n const mergedAttr = {\n ...defaultAttribute,\n ...attribute,\n }\n\n if (typeof mergedAttr?.default === 'function') {\n mergedAttr.default = mergedAttr.default()\n }\n\n if (mergedAttr?.isRequired && mergedAttr?.default === undefined) {\n delete mergedAttr.default\n }\n\n extensionAttributes.push({\n type: extension.name,\n name,\n attribute: mergedAttr,\n })\n })\n })\n\n return extensionAttributes\n}\n","export function mergeAttributes(...objects: Record<string, any>[]): Record<string, any> {\n return objects\n .filter(item => !!item)\n .reduce((items, item) => {\n const mergedAttributes = { ...items }\n\n Object.entries(item).forEach(([key, value]) => {\n const exists = mergedAttributes[key]\n\n if (!exists) {\n mergedAttributes[key] = value\n\n return\n }\n\n if (key === 'class') {\n const valueClasses: string[] = value ? String(value).split(' ') : []\n const existingClasses: string[] = mergedAttributes[key] ? mergedAttributes[key].split(' ') : []\n\n const insertClasses = valueClasses.filter(valueClass => !existingClasses.includes(valueClass))\n\n mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ')\n } else if (key === 'style') {\n const newStyles: string[] = value\n ? value\n .split(';')\n .map((style: string) => style.trim())\n .filter(Boolean)\n : []\n const existingStyles: string[] = mergedAttributes[key]\n ? mergedAttributes[key]\n .split(';')\n .map((style: string) => style.trim())\n .filter(Boolean)\n : []\n\n const styleMap = new Map<string, string>()\n\n existingStyles.forEach(style => {\n const [property, val] = style.split(':').map(part => part.trim())\n\n styleMap.set(property, val)\n })\n\n newStyles.forEach(style => {\n const [property, val] = style.split(':').map(part => part.trim())\n\n styleMap.set(property, val)\n })\n\n mergedAttributes[key] = Array.from(styleMap.entries())\n .map(([property, val]) => `${property}: ${val}`)\n .join('; ')\n } else {\n mergedAttributes[key] = value\n }\n })\n\n return mergedAttributes\n }, {})\n}\n","import type { Mark, Node } from '@blockslides/pm/model'\n\nimport type { ExtensionAttribute } from '../types.js'\nimport { mergeAttributes } from '../utilities/mergeAttributes.js'\n\nexport function getRenderedAttributes(\n nodeOrMark: Node | Mark,\n extensionAttributes: ExtensionAttribute[],\n): Record<string, any> {\n return extensionAttributes\n .filter(attribute => attribute.type === nodeOrMark.type.name)\n .filter(item => item.attribute.rendered)\n .map(item => {\n if (!item.attribute.renderHTML) {\n return {\n [item.name]: nodeOrMark.attrs[item.name],\n }\n }\n\n return item.attribute.renderHTML(nodeOrMark.attrs) || {}\n })\n .reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {})\n}\n","export function fromString(value: any): any {\n if (typeof value !== 'string') {\n return value\n }\n\n if (value.match(/^[+-]?(?:\\d*\\.)?\\d+$/)) {\n return Number(value)\n }\n\n if (value === 'true') {\n return true\n }\n\n if (value === 'false') {\n return false\n }\n\n return value\n}\n","import type { ParseRule } from '@blockslides/pm/model'\n\nimport type { ExtensionAttribute } from '../types.js'\nimport { fromString } from '../utilities/fromString.js'\n\n/**\n * This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).\n * Cancels when `getAttrs` returned `false`.\n * @param parseRule ProseMirror ParseRule\n * @param extensionAttributes List of attributes to inject\n */\nexport function injectExtensionAttributesToParseRule(\n parseRule: ParseRule,\n extensionAttributes: ExtensionAttribute[],\n): ParseRule {\n if ('style' in parseRule) {\n return parseRule\n }\n\n return {\n ...parseRule,\n getAttrs: (node: HTMLElement) => {\n const oldAttributes = parseRule.getAttrs ? parseRule.getAttrs(node) : parseRule.attrs\n\n if (oldAttributes === false) {\n return false\n }\n\n const newAttributes = extensionAttributes.reduce((items, item) => {\n const value = item.attribute.parseHTML\n ? item.attribute.parseHTML(node)\n : fromString(node.getAttribute(item.name))\n\n if (value === null || value === undefined) {\n return items\n }\n\n return {\n ...items,\n [item.name]: value,\n }\n }, {})\n\n return { ...oldAttributes, ...newAttributes }\n },\n }\n}\n","/**\n * Find duplicates in an array.\n */\nexport function findDuplicates<T>(items: T[]): T[] {\n const filtered = items.filter((el, index) => items.indexOf(el) !== index)\n\n return Array.from(new Set(filtered))\n}\n","import type { AnyConfig, Extensions } from '../types.js'\nimport { getExtensionField } from './getExtensionField.js'\n\n/**\n * Sort extensions by priority.\n * @param extensions An array of Tiptap extensions\n * @returns A sorted array of Tiptap extensions by priority\n */\nexport function sortExtensions(extensions: Extensions): Extensions {\n const defaultPriority = 100\n\n return extensions.sort((a, b) => {\n const priorityA = getExtensionField<AnyConfig['priority']>(a, 'priority') || defaultPriority\n const priorityB = getExtensionField<AnyConfig['priority']>(b, 'priority') || defaultPriority\n\n if (priorityA > priorityB) {\n return -1\n }\n\n if (priorityA < priorityB) {\n return 1\n }\n\n return 0\n })\n}\n","import type { Extensions } from '../types.js'\nimport { findDuplicates } from '../utilities/findDuplicates.js'\nimport { flattenExtensions } from './flattenExtensions.js'\nimport { sortExtensions } from './sortExtensions.js'\n\n/**\n * Returns a flattened and sorted extension list while\n * also checking for duplicated extensions and warns the user.\n * @param extensions An array of BlockSlides extensions\n * @returns An flattened and sorted array of BlockSlides extensions\n */\nexport function resolveExtensions(extensions: Extensions): Extensions {\n const resolvedExtensions = sortExtensions(flattenExtensions(extensions))\n const duplicatedNames = findDuplicates(resolvedExtensions.map(extension => extension.name))\n\n if (duplicatedNames.length) {\n console.warn(\n `[blockslides warn]: Duplicate extension names found: [${duplicatedNames\n .map(item => `'${item}'`)\n .join(', ')}]. This can lead to issues.`,\n )\n }\n\n return resolvedExtensions\n}\n","import type { Schema } from \"@blockslides/pm/model\";\n\nimport type { SlideEditor as Editor } from \"../SlideEditor.js\";\nimport type { Extensions } from \"../types.js\";\nimport { getSchemaByResolvedExtensions } from \"./getSchemaByResolvedExtensions.js\";\nimport { resolveExtensions } from \"./resolveExtensions.js\";\n\nexport function getSchema(extensions: Extensions, editor?: Editor): Schema {\n const resolvedExtensions = resolveExtensions(extensions);\n\n return getSchemaByResolvedExtensions(resolvedExtensions, editor);\n}\n","import { DOMParser } from '@blockslides/pm/model'\n\nimport type { Extensions } from '../types.js'\nimport { elementFromString } from '../utilities/elementFromString.js'\nimport { getSchema } from './getSchema.js'\n\n/**\n * Generate JSONContent from HTML\n * @param html The HTML to generate JSONContent from\n * @param extensions The extensions to use for the schema\n * @returns The generated JSONContent\n */\nexport function generateJSON(html: string, extensions: Extensions): Record<string, any> {\n const schema = getSchema(extensions)\n const dom = elementFromString(html)\n\n return DOMParser.fromSchema(schema).parse(dom).toJSON()\n}\n","import { Node } from '@blockslides/pm/model'\n\nimport type { Extensions, JSONContent, TextSerializer } from '../types.js'\nimport { getSchema } from './getSchema.js'\nimport { getText } from './getText.js'\nimport { getTextSerializersFromSchema } from './getTextSerializersFromSchema.js'\n\n/**\n * Generate raw text from a JSONContent\n * @param doc The JSONContent to generate text from\n * @param extensions The extensions to use for the schema\n * @param options Options for the text generation f.e. blockSeparator or textSerializers\n * @returns The generated text\n */\nexport function generateText(\n doc: JSONContent,\n extensions: Extensions,\n options?: {\n blockSeparator?: string\n textSerializers?: Record<string, TextSerializer>\n },\n): string {\n const { blockSeparator = '\\n\\n', textSerializers = {} } = options || {}\n const schema = getSchema(extensions)\n const contentNode = Node.fromJSON(schema, doc)\n\n return getText(contentNode, {\n blockSeparator,\n textSerializers: {\n ...getTextSerializersFromSchema(schema),\n ...textSerializers,\n },\n })\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { Range, TextSerializer } from '../types.js'\n\n/**\n * Gets the text between two positions in a Prosemirror node\n * and serializes it using the given text serializers and block separator (see getText)\n * @param startNode The Prosemirror node to start from\n * @param range The range of the text to get\n * @param options Options for the text serializer & block separator\n * @returns The text between the two positions\n */\nexport function getTextBetween(\n startNode: ProseMirrorNode,\n range: Range,\n options?: {\n blockSeparator?: string\n textSerializers?: Record<string, TextSerializer>\n },\n): string {\n const { from, to } = range\n const { blockSeparator = '\\n\\n', textSerializers = {} } = options || {}\n let text = ''\n\n startNode.nodesBetween(from, to, (node, pos, parent, index) => {\n if (node.isBlock && pos > from) {\n text += blockSeparator\n }\n\n const textSerializer = textSerializers?.[node.type.name]\n\n if (textSerializer) {\n if (parent) {\n text += textSerializer({\n node,\n pos,\n parent,\n index,\n range,\n })\n }\n // do not descend into child nodes when there exists a serializer\n return false\n }\n\n if (node.isText) {\n text += node?.text?.slice(Math.max(from, pos) - pos, to - pos) // eslint-disable-line\n }\n })\n\n return text\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { TextSerializer } from '../types.js'\nimport { getTextBetween } from './getTextBetween.js'\n\n/**\n * Gets the text of a Prosemirror node\n * @param node The Prosemirror node\n * @param options Options for the text serializer & block separator\n * @returns The text of the node\n * @example ```js\n * const text = getText(node, { blockSeparator: '\\n' })\n * ```\n */\nexport function getText(\n node: ProseMirrorNode,\n options?: {\n blockSeparator?: string\n textSerializers?: Record<string, TextSerializer>\n },\n) {\n const range = {\n from: 0,\n to: node.content.size,\n }\n\n return getTextBetween(node, range, options)\n}\n","import type { Schema } from '@blockslides/pm/model'\n\nimport type { TextSerializer } from '../types.js'\n\n/**\n * Find text serializers `toText` in a Prosemirror schema\n * @param schema The Prosemirror schema to search in\n * @returns A record of text serializers by node name\n */\nexport function getTextSerializersFromSchema(schema: Schema): Record<string, TextSerializer> {\n return Object.fromEntries(\n Object.entries(schema.nodes)\n .filter(([, node]) => node.spec.toText)\n .map(([name, node]) => [name, node.spec.toText]),\n )\n}\n","import type { Node, NodeType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\nimport { getNodeType } from './getNodeType.js'\n\nexport function getNodeAttributes(state: EditorState, typeOrName: string | NodeType): Record<string, any> {\n const type = getNodeType(typeOrName, state.schema)\n const { from, to } = state.selection\n const nodes: Node[] = []\n\n state.doc.nodesBetween(from, to, node => {\n nodes.push(node)\n })\n\n const node = nodes.reverse().find(nodeItem => nodeItem.type.name === type.name)\n\n if (!node) {\n return {}\n }\n\n return { ...node.attrs }\n}\n","import type { MarkType, NodeType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\nimport { getMarkAttributes } from './getMarkAttributes.js'\nimport { getNodeAttributes } from './getNodeAttributes.js'\nimport { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'\n\n/**\n * Get node or mark attributes by type or name on the current editor state\n * @param state The current editor state\n * @param typeOrName The node or mark type or name\n * @returns The attributes of the node or mark or an empty object\n */\nexport function getAttributes(state: EditorState, typeOrName: string | NodeType | MarkType): Record<string, any> {\n const schemaType = getSchemaTypeNameByName(\n typeof typeOrName === 'string' ? typeOrName : typeOrName.name,\n state.schema,\n )\n\n if (schemaType === 'node') {\n return getNodeAttributes(state, typeOrName as NodeType)\n }\n\n if (schemaType === 'mark') {\n return getMarkAttributes(state, typeOrName as MarkType)\n }\n\n return {}\n}\n","/**\n * Removes duplicated values within an array.\n * Supports numbers, strings and objects.\n */\nexport function removeDuplicates<T>(array: T[], by = JSON.stringify): T[] {\n const seen: Record<any, any> = {}\n\n return array.filter(item => {\n const key = by(item)\n\n return Object.prototype.hasOwnProperty.call(seen, key) ? false : (seen[key] = true)\n })\n}\n","import type { Step, Transform } from '@blockslides/pm/transform'\n\nimport type { Range } from '../types.js'\nimport { removeDuplicates } from '../utilities/removeDuplicates.js'\n\nexport type ChangedRange = {\n oldRange: Range\n newRange: Range\n}\n\n/**\n * Removes duplicated ranges and ranges that are\n * fully captured by other ranges.\n */\nfunction simplifyChangedRanges(changes: ChangedRange[]): ChangedRange[] {\n const uniqueChanges = removeDuplicates(changes)\n\n return uniqueChanges.length === 1\n ? uniqueChanges\n : uniqueChanges.filter((change, index) => {\n const rest = uniqueChanges.filter((_, i) => i !== index)\n\n return !rest.some(otherChange => {\n return (\n change.oldRange.from >= otherChange.oldRange.from &&\n change.oldRange.to <= otherChange.oldRange.to &&\n change.newRange.from >= otherChange.newRange.from &&\n change.newRange.to <= otherChange.newRange.to\n )\n })\n })\n}\n\n/**\n * Returns a list of changed ranges\n * based on the first and last state of all steps.\n */\nexport function getChangedRanges(transform: Transform): ChangedRange[] {\n const { mapping, steps } = transform\n const changes: ChangedRange[] = []\n\n mapping.maps.forEach((stepMap, index) => {\n const ranges: Range[] = []\n\n // This accounts for step changes where no range was actually altered\n // e.g. when setting a mark, node attribute, etc.\n // @ts-ignore\n if (!stepMap.ranges.length) {\n const { from, to } = steps[index] as Step & {\n from?: number\n to?: number\n }\n\n if (from === undefined || to === undefined) {\n return\n }\n\n ranges.push({ from, to })\n } else {\n stepMap.forEach((from, to) => {\n ranges.push({ from, to })\n })\n }\n\n ranges.forEach(({ from, to }) => {\n const newStart = mapping.slice(index).map(from, -1)\n const newEnd = mapping.slice(index).map(to)\n const oldStart = mapping.invert().map(newStart, -1)\n const oldEnd = mapping.invert().map(newEnd)\n\n changes.push({\n oldRange: {\n from: oldStart,\n to: oldEnd,\n },\n newRange: {\n from: newStart,\n to: newEnd,\n },\n })\n })\n })\n\n return simplifyChangedRanges(changes)\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { JSONContent } from '../types.js'\n\ninterface DebugJSONContent extends JSONContent {\n from: number\n to: number\n}\n\nexport function getDebugJSON(node: ProseMirrorNode, startOffset = 0): DebugJSONContent {\n const isTopNode = node.type === node.type.schema.topNodeType\n const increment = isTopNode ? 0 : 1\n const from = startOffset\n const to = from + node.nodeSize\n const marks = node.marks.map(mark => {\n const output: { type: string; attrs?: Record<string, any> } = {\n type: mark.type.name,\n }\n\n if (Object.keys(mark.attrs).length) {\n output.attrs = { ...mark.attrs }\n }\n\n return output\n })\n const attrs = { ...node.attrs }\n const output: DebugJSONContent = {\n type: node.type.name,\n from,\n to,\n }\n\n if (Object.keys(attrs).length) {\n output.attrs = attrs\n }\n\n if (marks.length) {\n output.marks = marks\n }\n\n if (node.content.childCount) {\n output.content = []\n\n node.forEach((child, offset) => {\n output.content?.push(getDebugJSON(child, startOffset + offset + increment))\n })\n }\n\n if (node.text) {\n output.text = node.text\n }\n\n return output\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\nimport type { MarkRange } from '../types.js'\nimport { getMarkRange } from './getMarkRange.js'\n\nexport function getMarksBetween(from: number, to: number, doc: ProseMirrorNode): MarkRange[] {\n const marks: MarkRange[] = []\n\n // get all inclusive marks on empty selection\n if (from === to) {\n doc\n .resolve(from)\n .marks()\n .forEach(mark => {\n const $pos = doc.resolve(from)\n const range = getMarkRange($pos, mark.type)\n\n if (!range) {\n return\n }\n\n marks.push({\n mark,\n ...range,\n })\n })\n } else {\n doc.nodesBetween(from, to, (node, pos) => {\n if (!node || node?.nodeSize === undefined) {\n return\n }\n\n marks.push(\n ...node.marks.map(mark => ({\n from: pos,\n to: pos + node.nodeSize,\n mark,\n })),\n )\n })\n }\n\n return marks\n}\n","import type { Node, NodeType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\n/**\n * Finds the first node of a given type or name in the current selection.\n * @param state The editor state.\n * @param typeOrName The node type or name.\n * @param pos The position to start searching from.\n * @param maxDepth The maximum depth to search.\n * @returns The node and the depth as an array.\n */\nexport const getNodeAtPosition = (state: EditorState, typeOrName: string | NodeType, pos: number, maxDepth = 20) => {\n const $pos = state.doc.resolve(pos)\n\n let currentDepth = maxDepth\n let node: Node | null = null\n\n while (currentDepth > 0 && node === null) {\n const currentNode = $pos.node(currentDepth)\n\n if (currentNode?.type.name === typeOrName) {\n node = currentNode\n } else {\n currentDepth -= 1\n }\n }\n\n return [node, currentDepth] as [Node | null, number]\n}\n","import type { MarkType, NodeType, Schema } from '@blockslides/pm/model'\n\n/**\n * Tries to get a node or mark type by its name.\n * @param name The name of the node or mark type\n * @param schema The Prosemiror schema to search in\n * @returns The node or mark type, or null if it doesn't exist\n */\nexport function getSchemaTypeByName(name: string, schema: Schema): NodeType | MarkType | null {\n return schema.nodes[name] || schema.marks[name] || null\n}\n","import type { ExtensionAttribute } from '../types.js'\n\n/**\n * Return attributes of an extension that should be splitted by keepOnSplit flag\n * @param extensionAttributes Array of extension attributes\n * @param typeName The type of the extension\n * @param attributes The attributes of the extension\n * @returns The splitted attributes\n */\nexport function getSplittedAttributes(\n extensionAttributes: ExtensionAttribute[],\n typeName: string,\n attributes: Record<string, any>,\n): Record<string, any> {\n return Object.fromEntries(\n Object.entries(attributes).filter(([name]) => {\n const extensionAttribute = extensionAttributes.find(item => {\n return item.type === typeName && item.name === name\n })\n\n if (!extensionAttribute) {\n return false\n }\n\n return extensionAttribute.attribute.keepOnSplit\n }),\n )\n}\n","import type { ResolvedPos } from '@blockslides/pm/model'\n\n/**\n * Returns the text content of a resolved prosemirror position\n * @param $from The resolved position to get the text content from\n * @param maxMatch The maximum number of characters to match\n * @returns The text content\n */\nexport const getTextContentFromNodes = ($from: ResolvedPos, maxMatch = 500) => {\n let textBefore = ''\n\n const sliceEndPos = $from.parentOffset\n\n $from.parent.nodesBetween(Math.max(0, sliceEndPos - maxMatch), sliceEndPos, (node, pos, parent, index) => {\n const chunk =\n node.type.spec.toText?.({\n node,\n pos,\n parent,\n index,\n }) ||\n node.textContent ||\n '%leaf%'\n\n textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos))\n })\n\n return textBefore\n}\n","import type { MarkType } from '@blockslides/pm/model'\nimport type { EditorState } from '@blockslides/pm/state'\n\nimport type { MarkRange } from '../types.js'\nimport { objectIncludes } from '../utilities/objectIncludes.js'\nimport { getMarkType } from './getMarkType.js'\n\nexport function isMarkActive(\n state: EditorState,\n typeOrName: MarkType | string | null,\n attributes: Record<string, any> = {},\n): boolean {\n const { empty, ranges } = state.selection\n const type = typeOrName ? getMarkType(typeOrName, state.schema) : null\n\n if (empty) {\n return !!(state.storedMarks || state.selection.$from.marks())\n .filter(mark => {\n if (!type) {\n return true\n }\n\n return type.name === mark.type.name\n })\n .find(mark => objectIncludes(mark.attrs, attributes, { strict: false }))\n }\n\n let selectionRange = 0\n const markRanges: MarkRange[] = []\n\n ranges.forEach(({ $from, $to }) => {\n const from = $from.pos\n const to = $to.pos\n\n state.doc.nodesBetween(from, to, (node, pos) => {\n if (!node.isText && !node.marks.length) {\n return\n }\n\n const relativeFrom = Math.max(from, pos)\n const relativeTo = Math.min(to, pos + node.nodeSize)\n const range = relativeTo - relativeFrom\n\n selectionRange += range\n\n markRanges.push(\n ...node.marks.map(mark => ({\n mark,\n from: relativeFrom,\n to: relativeTo,\n })),\n )\n })\n })\n\n if (selectionRange === 0) {\n return false\n }\n\n // calculate range of matched mark\n const matchedRange = markRanges\n .filter(markRange => {\n if (!type) {\n return true\n }\n\n return type.name === markRange.mark.type.name\n })\n .filter(markRange => objectIncludes(markRange.mark.attrs, attributes, { strict: false }))\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0)\n\n // calculate range of marks that excludes the searched mark\n // for example `code` doesn’t allow any other marks\n const excludedRange = markRanges\n .filter(markRange => {\n if (!type) {\n return true\n }\n\n return markRange.mark.type !== type && markRange.mark.type.excludes(type)\n })\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0)\n\n // we only include the result of `excludedRange`\n // if there is a match at all\n const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange\n\n return range >= selectionRange\n}\n","import type { EditorState } from '@blockslides/pm/state'\n\nimport { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'\nimport { isMarkActive } from './isMarkActive.js'\nimport { isNodeActive } from './isNodeActive.js'\n\nexport function isActive(state: EditorState, name: string | null, attributes: Record<string, any> = {}): boolean {\n if (!name) {\n return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes)\n }\n\n const schemaType = getSchemaTypeNameByName(name, state.schema)\n\n if (schemaType === 'node') {\n return isNodeActive(state, name, attributes)\n }\n\n if (schemaType === 'mark') {\n return isMarkActive(state, name, attributes)\n }\n\n return false\n}\n","import type { EditorState } from '@blockslides/pm/state'\n\nimport { findParentNode } from './findParentNode.js'\n\nexport const isAtEndOfNode = (state: EditorState, nodeType?: string) => {\n const { $from, $to, $anchor } = state.selection\n\n if (nodeType) {\n const parentNode = findParentNode(node => node.type.name === nodeType)(state.selection)\n\n if (!parentNode) {\n return false\n }\n\n const $parentPos = state.doc.resolve(parentNode.pos + 1)\n\n if ($anchor.pos + 1 === $parentPos.end()) {\n return true\n }\n\n return false\n }\n\n if ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) {\n return false\n }\n\n return true\n}\n","import type { EditorState } from '@blockslides/pm/state'\n\nexport const isAtStartOfNode = (state: EditorState) => {\n const { $from, $to } = state.selection\n\n if ($from.parentOffset > 0 || $from.pos !== $to.pos) {\n return false\n }\n\n return true\n}\n","import type { AnyExtension, EnableRules } from '../types.js'\n\nexport function isExtensionRulesEnabled(extension: AnyExtension, enabled: EnableRules): boolean {\n if (Array.isArray(enabled)) {\n return enabled.some(enabledExtension => {\n const name = typeof enabledExtension === 'string' ? enabledExtension : enabledExtension.name\n\n return name === extension.name\n })\n }\n\n return enabled\n}\n","import { getExtensionField } from '../helpers/getExtensionField.js'\nimport type { NodeConfig } from '../index.js'\nimport type { Extensions } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\nimport { splitExtensions } from './splitExtensions.js'\n\nexport function isList(name: string, extensions: Extensions): boolean {\n const { nodeExtensions } = splitExtensions(extensions)\n const extension = nodeExtensions.find(item => item.name === name)\n\n if (!extension) {\n return false\n }\n\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n }\n const group = callOrReturn(getExtensionField<NodeConfig['group']>(extension, 'group', context))\n\n if (typeof group !== 'string') {\n return false\n }\n\n return group.split(' ').includes('list')\n}\n","import type { Node as ProseMirrorNode } from '@blockslides/pm/model'\n\n/**\n * Returns true if the given prosemirror node is empty.\n */\nexport function isNodeEmpty(\n node: ProseMirrorNode,\n {\n checkChildren = true,\n ignoreWhitespace = false,\n }: {\n /**\n * When true (default), it will also check if all children are empty.\n */\n checkChildren?: boolean\n /**\n * When true, it will ignore whitespace when checking for emptiness.\n */\n ignoreWhitespace?: boolean\n } = {},\n): boolean {\n if (ignoreWhitespace) {\n if (node.type.name === 'hardBreak') {\n // Hard breaks are considered empty\n return true\n }\n if (node.isText) {\n return /^\\s*$/m.test(node.text ?? '')\n }\n }\n\n if (node.isText) {\n return !node.text\n }\n\n if (node.isAtom || node.isLeaf) {\n return false\n }\n\n if (node.content.childCount === 0) {\n return true\n }\n\n if (checkChildren) {\n let isContentEmpty = true\n\n node.content.forEach(childNode => {\n if (isContentEmpty === false) {\n // Exit early for perf\n return\n }\n\n if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {\n isContentEmpty = false\n }\n })\n\n return isContentEmpty\n }\n\n return false\n}\n","import { NodeSelection } from '@blockslides/pm/state'\n\nexport function isNodeSelection(value: unknown): value is NodeSelection {\n return value instanceof NodeSelection\n}\n","import type { EditorView } from '@blockslides/pm/view'\n\nimport { minMax } from '../utilities/minMax.js'\n\nexport function posToDOMRect(view: EditorView, from: number, to: number): DOMRect {\n const minPos = 0\n const maxPos = view.state.doc.content.size\n const resolvedFrom = minMax(from, minPos, maxPos)\n const resolvedEnd = minMax(to, minPos, maxPos)\n const start = view.coordsAtPos(resolvedFrom)\n const end = view.coordsAtPos(resolvedEnd, -1)\n const top = Math.min(start.top, end.top)\n const bottom = Math.max(start.bottom, end.bottom)\n const left = Math.min(start.left, end.left)\n const right = Math.max(start.right, end.right)\n const width = right - left\n const height = bottom - top\n const x = left\n const y = top\n const data = {\n top,\n bottom,\n left,\n right,\n width,\n height,\n x,\n y,\n }\n\n return {\n ...data,\n toJSON: () => data,\n }\n}\n","import type { Schema } from '@blockslides/pm/model'\n\nimport type { JSONContent } from '../types.js'\n\ntype RewriteUnknownContentOptions = {\n /**\n * If true, unknown nodes will be treated as paragraphs\n * @default true\n */\n fallbackToParagraph?: boolean\n}\n\ntype RewrittenContent = {\n /**\n * The original JSON content that was rewritten\n */\n original: JSONContent\n /**\n * The name of the node or mark that was unsupported\n */\n unsupported: string\n}[]\n\n/**\n * The actual implementation of the rewriteUnknownContent function\n */\nfunction rewriteUnknownContentInner({\n json,\n validMarks,\n validNodes,\n options,\n rewrittenContent = [],\n}: {\n json: JSONContent\n validMarks: Set<string>\n validNodes: Set<string>\n options?: RewriteUnknownContentOptions\n rewrittenContent?: RewrittenContent\n}): {\n /**\n * The cleaned JSON content\n */\n json: JSONContent | null\n /**\n * The array of nodes and marks that were rewritten\n */\n rewrittenContent: RewrittenContent\n} {\n if (json.marks && Array.isArray(json.marks)) {\n json.marks = json.marks.filter(mark => {\n const name = typeof mark === 'string' ? mark : mark.type\n\n if (validMarks.has(name)) {\n return true\n }\n\n rewrittenContent.push({\n original: JSON.parse(JSON.stringify(mark)),\n unsupported: name,\n })\n // Just ignore any unknown marks\n return false\n })\n }\n\n if (json.content && Array.isArray(json.content)) {\n json.content = json.content\n .map(\n value =>\n rewriteUnknownContentInner({\n json: value,\n validMarks,\n validNodes,\n options,\n rewrittenContent,\n }).json,\n )\n .filter(a => a !== null && a !== undefined)\n }\n\n if (json.type && !validNodes.has(json.type)) {\n rewrittenContent.push({\n original: JSON.parse(JSON.stringify(json)),\n unsupported: json.type,\n })\n\n if (json.content && Array.isArray(json.content) && options?.fallbackToParagraph !== false) {\n // Just treat it like a paragraph and hope for the best\n json.type = 'paragraph'\n\n return {\n json,\n rewrittenContent,\n }\n }\n\n // or just omit it entirely\n return {\n json: null,\n rewrittenContent,\n }\n }\n\n return { json, rewrittenContent }\n}\n\n/**\n * Rewrite unknown nodes and marks within JSON content\n * Allowing for user within the editor\n */\nexport function rewriteUnknownContent(\n /**\n * The JSON content to clean of unknown nodes and marks\n */\n json: JSONContent,\n /**\n * The schema to use for validation\n */\n schema: Schema,\n /**\n * Options for the cleaning process\n */\n options?: RewriteUnknownContentOptions,\n): {\n /**\n * The cleaned JSON content\n */\n json: JSONContent | null\n /**\n * The array of nodes and marks that were rewritten\n */\n rewrittenContent: {\n /**\n * The original JSON content that was rewritten\n */\n original: JSONContent\n /**\n * The name of the node or mark that was unsupported\n */\n unsupported: string\n }[]\n} {\n return rewriteUnknownContentInner({\n json,\n validNodes: new Set(Object.keys(schema.nodes)),\n validMarks: new Set(Object.keys(schema.marks)),\n options,\n })\n}\n","import type { MarkType, ResolvedPos } from '@blockslides/pm/model'\nimport type { EditorState, Transaction } from '@blockslides/pm/state'\n\nimport { getMarkAttributes } from '../helpers/getMarkAttributes.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { isTextSelection } from '../helpers/index.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setMark: {\n /**\n * Add a mark with new attributes.\n * @param typeOrName The mark type or name.\n * @example editor.commands.setMark('bold', { level: 1 })\n */\n setMark: (typeOrName: string | MarkType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nfunction canSetMark(state: EditorState, tr: Transaction, newMarkType: MarkType) {\n const { selection } = tr\n let cursor: ResolvedPos | null = null\n\n if (isTextSelection(selection)) {\n cursor = selection.$cursor\n }\n\n if (cursor) {\n const currentMarks = state.storedMarks ?? cursor.marks()\n const parentAllowsMarkType = cursor.parent.type.allowsMarkType(newMarkType)\n\n // There can be no current marks that exclude the new mark, and the parent must allow this mark type\n return (\n parentAllowsMarkType &&\n (!!newMarkType.isInSet(currentMarks) || !currentMarks.some(mark => mark.type.excludes(newMarkType)))\n )\n }\n\n const { ranges } = selection\n\n return ranges.some(({ $from, $to }) => {\n let someNodeSupportsMark =\n $from.depth === 0 ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) : false\n\n state.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {\n // If we already found a mark that we can enable, return false to bypass the remaining search\n if (someNodeSupportsMark) {\n return false\n }\n\n if (node.isInline) {\n const parentAllowsMarkType = !parent || parent.type.allowsMarkType(newMarkType)\n const currentMarksAllowMarkType =\n !!newMarkType.isInSet(node.marks) || !node.marks.some(otherMark => otherMark.type.excludes(newMarkType))\n\n someNodeSupportsMark = parentAllowsMarkType && currentMarksAllowMarkType\n }\n return !someNodeSupportsMark\n })\n\n return someNodeSupportsMark\n })\n}\nexport const setMark: RawCommands['setMark'] =\n (typeOrName, attributes = {}) =>\n ({ tr, state, dispatch }) => {\n const { selection } = tr\n const { empty, ranges } = selection\n const type = getMarkType(typeOrName, state.schema)\n\n if (dispatch) {\n if (empty) {\n const oldAttributes = getMarkAttributes(state, type)\n\n tr.addStoredMark(\n type.create({\n ...oldAttributes,\n ...attributes,\n }),\n )\n } else {\n ranges.forEach(range => {\n const from = range.$from.pos\n const to = range.$to.pos\n\n state.doc.nodesBetween(from, to, (node, pos) => {\n const trimmedFrom = Math.max(pos, from)\n const trimmedTo = Math.min(pos + node.nodeSize, to)\n const someHasMark = node.marks.find(mark => mark.type === type)\n\n // if there is already a mark of this type\n // we know that we have to merge its attributes\n // otherwise we add a fresh new mark\n if (someHasMark) {\n node.marks.forEach(mark => {\n if (type === mark.type) {\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n type.create({\n ...mark.attrs,\n ...attributes,\n }),\n )\n }\n })\n } else {\n tr.addMark(trimmedFrom, trimmedTo, type.create(attributes))\n }\n })\n })\n }\n }\n\n return canSetMark(state, tr, type)\n }\n","import type { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setMeta: {\n /**\n * Store a metadata property in the current transaction.\n * @param key The key of the metadata property.\n * @param value The value to store.\n * @example editor.commands.setMeta('foo', 'bar')\n */\n setMeta: (key: string | Plugin | PluginKey, value: any) => ReturnType\n }\n }\n}\n\nexport const setMeta: RawCommands['setMeta'] =\n (key, value) =>\n ({ tr }) => {\n tr.setMeta(key, value)\n\n return true\n }\n","import { setBlockType } from '@blockslides/pm/commands'\nimport type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setNode: {\n /**\n * Replace a given range with a node.\n * @param typeOrName The type or name of the node\n * @param attributes The attributes of the node\n * @example editor.commands.setNode('paragraph')\n */\n setNode: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const setNode: RawCommands['setNode'] =\n (typeOrName, attributes = {}) =>\n ({ state, dispatch, chain }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n let attributesToCopy: Record<string, any> | undefined\n\n if (state.selection.$anchor.sameParent(state.selection.$head)) {\n // only copy attributes if the selection is pointing to a node of the same type\n attributesToCopy = state.selection.$anchor.parent.attrs\n }\n\n // TODO: use a fallback like insertContent?\n if (!type.isTextblock) {\n console.warn('[blockslides warn]: Currently \"setNode()\" only supports text block nodes.')\n\n return false\n }\n\n return (\n chain()\n // try to convert node to default node if needed\n .command(({ commands }) => {\n const canSetBlock = setBlockType(type, { ...attributesToCopy, ...attributes })(state)\n\n if (canSetBlock) {\n return true\n }\n\n return commands.clearNodes()\n })\n .command(({ state: updatedState }) => {\n return setBlockType(type, { ...attributesToCopy, ...attributes })(updatedState, dispatch)\n })\n .run()\n )\n }\n","import { NodeSelection } from '@blockslides/pm/state'\n\nimport type { RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setNodeSelection: {\n /**\n * Creates a NodeSelection.\n * @param position - Position of the node.\n * @example editor.commands.setNodeSelection(10)\n */\n setNodeSelection: (position: number) => ReturnType\n }\n }\n}\n\nexport const setNodeSelection: RawCommands['setNodeSelection'] =\n position =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n const { doc } = tr\n const from = minMax(position, 0, doc.content.size)\n const selection = NodeSelection.create(doc, from)\n\n tr.setSelection(selection)\n }\n\n return true\n }\n","import { TextSelection } from '@blockslides/pm/state'\n\nimport type { Range, RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n setTextSelection: {\n /**\n * Creates a TextSelection.\n * @param position The position of the selection.\n * @example editor.commands.setTextSelection(10)\n */\n setTextSelection: (position: number | Range) => ReturnType\n }\n }\n}\n\nexport const setTextSelection: RawCommands['setTextSelection'] =\n position =>\n ({ tr, dispatch }) => {\n if (dispatch) {\n const { doc } = tr\n const { from, to } = typeof position === 'number' ? { from: position, to: position } : position\n const minPos = TextSelection.atStart(doc).from\n const maxPos = TextSelection.atEnd(doc).to\n const resolvedFrom = minMax(from, minPos, maxPos)\n const resolvedEnd = minMax(to, minPos, maxPos)\n const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)\n\n tr.setSelection(selection)\n }\n\n return true\n }\n","import type { NodeType } from '@blockslides/pm/model'\nimport { sinkListItem as originalSinkListItem } from '@blockslides/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n sinkListItem: {\n /**\n * Sink the list item down into an inner list.\n * @param typeOrName The type or name of the node.\n * @example editor.commands.sinkListItem('listItem')\n */\n sinkListItem: (typeOrName: string | NodeType) => ReturnType\n }\n }\n}\n\nexport const sinkListItem: RawCommands['sinkListItem'] =\n typeOrName =>\n ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalSinkListItem(type)(state, dispatch)\n }\n","import type { EditorState } from '@blockslides/pm/state'\nimport { NodeSelection, TextSelection } from '@blockslides/pm/state'\nimport { canSplit } from '@blockslides/pm/transform'\n\nimport { defaultBlockAt } from '../helpers/defaultBlockAt.js'\nimport { getSplittedAttributes } from '../helpers/getSplittedAttributes.js'\nimport type { RawCommands } from '../types.js'\n\nfunction ensureMarks(state: EditorState, splittableMarks?: string[]) {\n const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks())\n\n if (marks) {\n const filteredMarks = marks.filter(mark => splittableMarks?.includes(mark.type.name))\n\n state.tr.ensureMarks(filteredMarks)\n }\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n splitBlock: {\n /**\n * Forks a new node from an existing node.\n * @param options.keepMarks Keep marks from the previous node.\n * @example editor.commands.splitBlock()\n * @example editor.commands.splitBlock({ keepMarks: true })\n */\n splitBlock: (options?: { keepMarks?: boolean }) => ReturnType\n }\n }\n}\n\nexport const splitBlock: RawCommands['splitBlock'] =\n ({ keepMarks = true } = {}) =>\n ({ tr, state, dispatch, editor }) => {\n const { selection, doc } = tr\n const { $from, $to } = selection\n const extensionAttributes = editor.extensionManager.attributes\n const newAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs)\n\n if (selection instanceof NodeSelection && selection.node.isBlock) {\n if (!$from.parentOffset || !canSplit(doc, $from.pos)) {\n return false\n }\n\n if (dispatch) {\n if (keepMarks) {\n ensureMarks(state, editor.extensionManager.splittableMarks)\n }\n\n tr.split($from.pos).scrollIntoView()\n }\n\n return true\n }\n\n if (!$from.parent.isBlock) {\n return false\n }\n\n const atEnd = $to.parentOffset === $to.parent.content.size\n\n const deflt = $from.depth === 0 ? undefined : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)))\n\n let types =\n atEnd && deflt\n ? [\n {\n type: deflt,\n attrs: newAttributes,\n },\n ]\n : undefined\n\n let can = canSplit(tr.doc, tr.mapping.map($from.pos), 1, types)\n\n if (!types && !can && canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)) {\n can = true\n types = deflt\n ? [\n {\n type: deflt,\n attrs: newAttributes,\n },\n ]\n : undefined\n }\n\n if (dispatch) {\n if (can) {\n if (selection instanceof TextSelection) {\n tr.deleteSelection()\n }\n\n tr.split(tr.mapping.map($from.pos), 1, types)\n\n if (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {\n const first = tr.mapping.map($from.before())\n const $first = tr.doc.resolve(first)\n\n if ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) {\n tr.setNodeMarkup(tr.mapping.map($from.before()), deflt)\n }\n }\n }\n\n if (keepMarks) {\n ensureMarks(state, editor.extensionManager.splittableMarks)\n }\n\n tr.scrollIntoView()\n }\n\n return can\n }\n","import type { Node as ProseMirrorNode, NodeType } from '@blockslides/pm/model'\nimport { Fragment, Slice } from '@blockslides/pm/model'\nimport { TextSelection } from '@blockslides/pm/state'\nimport { canSplit } from '@blockslides/pm/transform'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { getSplittedAttributes } from '../helpers/getSplittedAttributes.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n splitListItem: {\n /**\n * Splits one list item into two list items.\n * @param typeOrName The type or name of the node.\n * @param overrideAttrs The attributes to ensure on the new node.\n * @example editor.commands.splitListItem('listItem')\n */\n splitListItem: (typeOrName: string | NodeType, overrideAttrs?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const splitListItem: RawCommands['splitListItem'] =\n (typeOrName, overrideAttrs = {}) =>\n ({ tr, state, dispatch, editor }) => {\n const type = getNodeType(typeOrName, state.schema)\n const { $from, $to } = state.selection\n\n // @ts-ignore\n // eslint-disable-next-line\n const node: ProseMirrorNode = state.selection.node\n\n if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) {\n return false\n }\n\n const grandParent = $from.node(-1)\n\n if (grandParent.type !== type) {\n return false\n }\n\n const extensionAttributes = editor.extensionManager.attributes\n\n if ($from.parent.content.size === 0 && $from.node(-1).childCount === $from.indexAfter(-1)) {\n // In an empty block. If this is a nested list, the wrapping\n // list item should be split. Otherwise, bail out and let next\n // command handle lifting.\n if ($from.depth === 2 || $from.node(-3).type !== type || $from.index(-2) !== $from.node(-2).childCount - 1) {\n return false\n }\n\n if (dispatch) {\n let wrap = Fragment.empty\n // eslint-disable-next-line\n const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3\n\n // Build a fragment containing empty versions of the structure\n // from the outer list item to the parent node of the cursor\n for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {\n wrap = Fragment.from($from.node(d).copy(wrap))\n }\n\n const depthAfter =\n // eslint-disable-next-line no-nested-ternary\n $from.indexAfter(-1) < $from.node(-2).childCount\n ? 1\n : $from.indexAfter(-2) < $from.node(-3).childCount\n ? 2\n : 3\n\n // Add a second list item with an empty default start node\n const newNextTypeAttributes = {\n ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),\n ...overrideAttrs,\n }\n const nextType = type.contentMatch.defaultType?.createAndFill(newNextTypeAttributes) || undefined\n\n wrap = wrap.append(Fragment.from(type.createAndFill(null, nextType) || undefined))\n\n const start = $from.before($from.depth - (depthBefore - 1))\n\n tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0))\n\n let sel = -1\n\n tr.doc.nodesBetween(start, tr.doc.content.size, (n, pos) => {\n if (sel > -1) {\n return false\n }\n\n if (n.isTextblock && n.content.size === 0) {\n sel = pos + 1\n }\n })\n\n if (sel > -1) {\n tr.setSelection(TextSelection.near(tr.doc.resolve(sel)))\n }\n\n tr.scrollIntoView()\n }\n\n return true\n }\n\n const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null\n\n const newTypeAttributes = {\n ...getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs),\n ...overrideAttrs,\n }\n const newNextTypeAttributes = {\n ...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),\n ...overrideAttrs,\n }\n\n tr.delete($from.pos, $to.pos)\n\n const types = nextType\n ? [\n { type, attrs: newTypeAttributes },\n { type: nextType, attrs: newNextTypeAttributes },\n ]\n : [{ type, attrs: newTypeAttributes }]\n\n if (!canSplit(tr.doc, $from.pos, 2)) {\n return false\n }\n\n if (dispatch) {\n const { selection, storedMarks } = state\n const { splittableMarks } = editor.extensionManager\n const marks = storedMarks || (selection.$to.parentOffset && selection.$from.marks())\n\n tr.split($from.pos, 2, types).scrollIntoView()\n\n if (!marks || !dispatch) {\n return true\n }\n\n const filteredMarks = marks.filter(mark => splittableMarks.includes(mark.type.name))\n\n tr.ensureMarks(filteredMarks)\n }\n\n return true\n }\n","import type { NodeType } from '@blockslides/pm/model'\nimport type { Transaction } from '@blockslides/pm/state'\nimport { canJoin } from '@blockslides/pm/transform'\n\nimport { findParentNode } from '../helpers/findParentNode.js'\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isList } from '../helpers/isList.js'\nimport type { RawCommands } from '../types.js'\n\nconst joinListBackwards = (tr: Transaction, listType: NodeType): boolean => {\n const list = findParentNode(node => node.type === listType)(tr.selection)\n\n if (!list) {\n return true\n }\n\n const before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth)\n\n if (before === undefined) {\n return true\n }\n\n const nodeBefore = tr.doc.nodeAt(before)\n const canJoinBackwards = list.node.type === nodeBefore?.type && canJoin(tr.doc, list.pos)\n\n if (!canJoinBackwards) {\n return true\n }\n\n tr.join(list.pos)\n\n return true\n}\n\nconst joinListForwards = (tr: Transaction, listType: NodeType): boolean => {\n const list = findParentNode(node => node.type === listType)(tr.selection)\n\n if (!list) {\n return true\n }\n\n const after = tr.doc.resolve(list.start).after(list.depth)\n\n if (after === undefined) {\n return true\n }\n\n const nodeAfter = tr.doc.nodeAt(after)\n const canJoinForwards = list.node.type === nodeAfter?.type && canJoin(tr.doc, after)\n\n if (!canJoinForwards) {\n return true\n }\n\n tr.join(after)\n\n return true\n}\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n toggleList: {\n /**\n * Toggle between different list types.\n * @param listTypeOrName The type or name of the list.\n * @param itemTypeOrName The type or name of the list item.\n * @param keepMarks Keep marks when toggling.\n * @param attributes Attributes for the new list.\n * @example editor.commands.toggleList('bulletList', 'listItem')\n */\n toggleList: (\n listTypeOrName: string | NodeType,\n itemTypeOrName: string | NodeType,\n keepMarks?: boolean,\n attributes?: Record<string, any>,\n ) => ReturnType\n }\n }\n}\n\nexport const toggleList: RawCommands['toggleList'] =\n (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) =>\n ({ editor, tr, state, dispatch, chain, commands, can }) => {\n const { extensions, splittableMarks } = editor.extensionManager\n const listType = getNodeType(listTypeOrName, state.schema)\n const itemType = getNodeType(itemTypeOrName, state.schema)\n const { selection, storedMarks } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n const marks = storedMarks || (selection.$to.parentOffset && selection.$from.marks())\n\n if (!range) {\n return false\n }\n\n const parentList = findParentNode(node => isList(node.type.name, extensions))(selection)\n\n if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {\n // remove list\n if (parentList.node.type === listType) {\n return commands.liftListItem(itemType)\n }\n\n // change list type\n if (isList(parentList.node.type.name, extensions) && listType.validContent(parentList.node.content) && dispatch) {\n return chain()\n .command(() => {\n tr.setNodeMarkup(parentList.pos, listType)\n\n return true\n })\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n }\n }\n if (!keepMarks || !marks || !dispatch) {\n return (\n chain()\n // try to convert node to default node if needed\n .command(() => {\n const canWrapInList = can().wrapInList(listType, attributes)\n\n if (canWrapInList) {\n return true\n }\n\n return commands.clearNodes()\n })\n .wrapInList(listType, attributes)\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n )\n }\n\n return (\n chain()\n // try to convert node to default node if needed\n .command(() => {\n const canWrapInList = can().wrapInList(listType, attributes)\n\n const filteredMarks = marks.filter(mark => splittableMarks.includes(mark.type.name))\n\n tr.ensureMarks(filteredMarks)\n\n if (canWrapInList) {\n return true\n }\n\n return commands.clearNodes()\n })\n .wrapInList(listType, attributes)\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n )\n }\n","import type { MarkType } from '@blockslides/pm/model'\n\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { isMarkActive } from '../helpers/isMarkActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n toggleMark: {\n /**\n * Toggle a mark on and off.\n * @param typeOrName The mark type or name.\n * @param attributes The attributes of the mark.\n * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.\n * @example editor.commands.toggleMark('bold')\n */\n toggleMark: (\n /**\n * The mark type or name.\n */\n typeOrName: string | MarkType,\n\n /**\n * The attributes of the mark.\n */\n attributes?: Record<string, any>,\n\n options?: {\n /**\n * Removes the mark even across the current selection. Defaults to `false`.\n */\n extendEmptyMarkRange?: boolean\n },\n ) => ReturnType\n }\n }\n}\n\nexport const toggleMark: RawCommands['toggleMark'] =\n (typeOrName, attributes = {}, options = {}) =>\n ({ state, commands }) => {\n const { extendEmptyMarkRange = false } = options\n const type = getMarkType(typeOrName, state.schema)\n const isActive = isMarkActive(state, type, attributes)\n\n if (isActive) {\n return commands.unsetMark(type, { extendEmptyMarkRange })\n }\n\n return commands.setMark(type, attributes)\n }\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n toggleNode: {\n /**\n * Toggle a node with another node.\n * @param typeOrName The type or name of the node.\n * @param toggleTypeOrName The type or name of the node to toggle.\n * @param attributes The attributes of the node.\n * @example editor.commands.toggleNode('heading', 'paragraph')\n */\n toggleNode: (\n typeOrName: string | NodeType,\n toggleTypeOrName: string | NodeType,\n attributes?: Record<string, any>,\n ) => ReturnType\n }\n }\n}\n\nexport const toggleNode: RawCommands['toggleNode'] =\n (typeOrName, toggleTypeOrName, attributes = {}) =>\n ({ state, commands }) => {\n const type = getNodeType(typeOrName, state.schema)\n const toggleType = getNodeType(toggleTypeOrName, state.schema)\n const isActive = isNodeActive(state, type, attributes)\n\n let attributesToCopy: Record<string, any> | undefined\n\n if (state.selection.$anchor.sameParent(state.selection.$head)) {\n // only copy attributes if the selection is pointing to a node of the same type\n attributesToCopy = state.selection.$anchor.parent.attrs\n }\n\n if (isActive) {\n return commands.setNode(toggleType, attributesToCopy)\n }\n\n // If the node is not active, we want to set the new node type with the given attributes\n // Copying over the attributes from the current node if the selection is pointing to a node of the same type\n return commands.setNode(type, { ...attributesToCopy, ...attributes })\n }\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n toggleWrap: {\n /**\n * Wraps nodes in another node, or removes an existing wrap.\n * @param typeOrName The type or name of the node.\n * @param attributes The attributes of the node.\n * @example editor.commands.toggleWrap('blockquote')\n */\n toggleWrap: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const toggleWrap: RawCommands['toggleWrap'] =\n (typeOrName, attributes = {}) =>\n ({ state, commands }) => {\n const type = getNodeType(typeOrName, state.schema)\n const isActive = isNodeActive(state, type, attributes)\n\n if (isActive) {\n return commands.lift(type)\n }\n\n return commands.wrapIn(type, attributes)\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n undoInputRule: {\n /**\n * Undo an input rule.\n * @example editor.commands.undoInputRule()\n */\n undoInputRule: () => ReturnType\n }\n }\n}\n\nexport const undoInputRule: RawCommands['undoInputRule'] =\n () =>\n ({ state, dispatch }) => {\n const plugins = state.plugins\n\n for (let i = 0; i < plugins.length; i += 1) {\n const plugin = plugins[i]\n let undoable\n\n // @ts-ignore\n // eslint-disable-next-line\n if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {\n if (dispatch) {\n const tr = state.tr\n const toUndo = undoable.transform\n\n for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {\n tr.step(toUndo.steps[j].invert(toUndo.docs[j]))\n }\n\n if (undoable.text) {\n const marks = tr.doc.resolve(undoable.from).marks()\n\n tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks))\n } else {\n tr.delete(undoable.from, undoable.to)\n }\n }\n\n return true\n }\n }\n\n return false\n }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n unsetAllMarks: {\n /**\n * Remove all marks in the current selection.\n * @example editor.commands.unsetAllMarks()\n */\n unsetAllMarks: () => ReturnType\n }\n }\n}\n\nexport const unsetAllMarks: RawCommands['unsetAllMarks'] =\n () =>\n ({ tr, dispatch }) => {\n const { selection } = tr\n const { empty, ranges } = selection\n\n if (empty) {\n return true\n }\n\n if (dispatch) {\n ranges.forEach(range => {\n tr.removeMark(range.$from.pos, range.$to.pos)\n })\n }\n\n return true\n }\n","import type { MarkType } from '@blockslides/pm/model'\n\nimport { getMarkRange } from '../helpers/getMarkRange.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n unsetMark: {\n /**\n * Remove all marks in the current selection.\n * @param typeOrName The mark type or name.\n * @param options.extendEmptyMarkRange Removes the mark even across the current selection. Defaults to `false`.\n * @example editor.commands.unsetMark('bold')\n */\n unsetMark: (\n /**\n * The mark type or name.\n */\n typeOrName: string | MarkType,\n\n options?: {\n /**\n * Removes the mark even across the current selection. Defaults to `false`.\n */\n extendEmptyMarkRange?: boolean\n },\n ) => ReturnType\n }\n }\n}\n\nexport const unsetMark: RawCommands['unsetMark'] =\n (typeOrName, options = {}) =>\n ({ tr, state, dispatch }) => {\n const { extendEmptyMarkRange = false } = options\n const { selection } = tr\n const type = getMarkType(typeOrName, state.schema)\n const { $from, empty, ranges } = selection\n\n if (!dispatch) {\n return true\n }\n\n if (empty && extendEmptyMarkRange) {\n let { from, to } = selection\n const attrs = $from.marks().find(mark => mark.type === type)?.attrs\n const range = getMarkRange($from, type, attrs)\n\n if (range) {\n from = range.from\n to = range.to\n }\n\n tr.removeMark(from, to, type)\n } else {\n ranges.forEach(range => {\n tr.removeMark(range.$from.pos, range.$to.pos, type)\n })\n }\n\n tr.removeStoredMark(type)\n\n return true\n }\n","import type { Mark, MarkType, Node, NodeType } from '@blockslides/pm/model'\nimport type { SelectionRange } from '@blockslides/pm/state'\n\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { getSchemaTypeNameByName } from '../helpers/getSchemaTypeNameByName.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n updateAttributes: {\n /**\n * Update attributes of a node or mark.\n * @param typeOrName The type or name of the node or mark.\n * @param attributes The attributes of the node or mark.\n * @example editor.commands.updateAttributes('mention', { userId: \"2\" })\n */\n updateAttributes: (\n /**\n * The type or name of the node or mark.\n */\n typeOrName: string | NodeType | MarkType,\n\n /**\n * The attributes of the node or mark.\n */\n attributes: Record<string, any>,\n ) => ReturnType\n }\n }\n}\n\nexport const updateAttributes: RawCommands['updateAttributes'] =\n (typeOrName, attributes = {}) =>\n ({ tr, state, dispatch }) => {\n let nodeType: NodeType | null = null\n let markType: MarkType | null = null\n\n const schemaType = getSchemaTypeNameByName(\n typeof typeOrName === 'string' ? typeOrName : typeOrName.name,\n state.schema,\n )\n\n if (!schemaType) {\n return false\n }\n\n if (schemaType === 'node') {\n nodeType = getNodeType(typeOrName as NodeType, state.schema)\n }\n\n if (schemaType === 'mark') {\n markType = getMarkType(typeOrName as MarkType, state.schema)\n }\n\n if (dispatch) {\n tr.selection.ranges.forEach((range: SelectionRange) => {\n const from = range.$from.pos\n const to = range.$to.pos\n\n let lastPos: number | undefined\n let lastNode: Node | undefined\n let trimmedFrom: number\n let trimmedTo: number\n\n if (tr.selection.empty) {\n state.doc.nodesBetween(from, to, (node: Node, pos: number) => {\n if (nodeType && nodeType === node.type) {\n trimmedFrom = Math.max(pos, from)\n trimmedTo = Math.min(pos + node.nodeSize, to)\n lastPos = pos\n lastNode = node\n }\n })\n } else {\n state.doc.nodesBetween(from, to, (node: Node, pos: number) => {\n if (pos < from && nodeType && nodeType === node.type) {\n trimmedFrom = Math.max(pos, from)\n trimmedTo = Math.min(pos + node.nodeSize, to)\n lastPos = pos\n lastNode = node\n }\n\n if (pos >= from && pos <= to) {\n if (nodeType && nodeType === node.type) {\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n ...attributes,\n })\n }\n\n if (markType && node.marks.length) {\n node.marks.forEach((mark: Mark) => {\n if (markType === mark.type) {\n const trimmedFrom2 = Math.max(pos, from)\n const trimmedTo2 = Math.min(pos + node.nodeSize, to)\n\n tr.addMark(\n trimmedFrom2,\n trimmedTo2,\n markType.create({\n ...mark.attrs,\n ...attributes,\n }),\n )\n }\n })\n }\n }\n })\n }\n\n if (lastNode) {\n if (lastPos !== undefined) {\n tr.setNodeMarkup(lastPos, undefined, {\n ...lastNode.attrs,\n ...attributes,\n })\n }\n\n if (markType && lastNode.marks.length) {\n lastNode.marks.forEach((mark: Mark) => {\n if (markType === mark.type) {\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markType.create({\n ...mark.attrs,\n ...attributes,\n }),\n )\n }\n })\n }\n }\n })\n }\n\n return true\n }\n","import { wrapIn as originalWrapIn } from '@blockslides/pm/commands'\nimport type { NodeType } from '@blockslides/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n wrapIn: {\n /**\n * Wraps nodes in another node.\n * @param typeOrName The type or name of the node.\n * @param attributes The attributes of the node.\n * @example editor.commands.wrapIn('blockquote')\n */\n wrapIn: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const wrapIn: RawCommands['wrapIn'] =\n (typeOrName, attributes = {}) =>\n ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalWrapIn(type, attributes)(state, dispatch)\n }\n","import type { NodeType } from '@blockslides/pm/model'\nimport { wrapInList as originalWrapInList } from '@blockslides/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@blockslides/core' {\n interface Commands<ReturnType> {\n wrapInList: {\n /**\n * Wrap a node in a list.\n * @param typeOrName The type or name of the node.\n * @param attributes The attributes of the node.\n * @example editor.commands.wrapInList('bulletList')\n */\n wrapInList: (typeOrName: string | NodeType, attributes?: Record<string, any>) => ReturnType\n }\n }\n}\n\nexport const wrapInList: RawCommands['wrapInList'] =\n (typeOrName, attributes = {}) =>\n ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalWrapInList(type, attributes)(state, dispatch)\n }\n","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport type {\n MarkType,\n Node as ProseMirrorNode,\n NodeType,\n Schema,\n} from \"@blockslides/pm/model\";\nimport type { Plugin, PluginKey, Transaction } from \"@blockslides/pm/state\";\nimport { EditorState } from \"@blockslides/pm/state\";\nimport { EditorView } from \"@blockslides/pm/view\";\nimport type { Step } from \"@blockslides/pm/transform\";\n\nimport { CommandManager } from \"./CommandManager.js\";\nimport { EventEmitter } from \"./EventEmitter.js\";\nimport { ExtensionManager } from \"./ExtensionManager.js\";\nimport {\n ClipboardTextSerializer,\n Commands,\n Delete,\n Drop,\n Editable,\n FocusEvents,\n Keymap,\n Paste,\n Tabindex,\n} from \"./extensions/index.js\";\nimport { createDocument } from \"./helpers/createDocument.js\";\nimport { getAttributes } from \"./helpers/getAttributes.js\";\nimport { getHTMLFromFragment } from \"./helpers/getHTMLFromFragment.js\";\nimport { getText } from \"./helpers/getText.js\";\nimport { getTextSerializersFromSchema } from \"./helpers/getTextSerializersFromSchema.js\";\nimport { isActive } from \"./helpers/isActive.js\";\nimport { isNodeEmpty } from \"./helpers/isNodeEmpty.js\";\nimport { resolveFocusPosition } from \"./helpers/resolveFocusPosition.js\";\nimport type { Storage } from \"./index.js\";\nimport { NodePos } from \"./NodePos.js\";\nimport { style } from \"./style.js\";\nimport { resolveTheme, applyTheme } from \"./themes/index.js\";\nimport type { ResolvedTheme } from \"./themes/types.js\";\nimport type {\n CanCommands,\n ChainedCommands,\n DocumentType,\n EditorEvents,\n EditorOptions,\n NodeType as TNodeType,\n SingleCommands,\n TextSerializer,\n TextType as TTextType,\n} from \"./types.js\";\nimport { createStyleTag } from \"./utilities/createStyleTag.js\";\nimport { isFunction } from \"./utilities/isFunction.js\";\n\nexport * as extensions from \"./extensions/index.js\";\n\n// @ts-ignore\nexport interface TiptapEditorHTMLElement extends HTMLElement {\n editor?: SlideEditor;\n}\n\nexport class SlideEditor extends EventEmitter<EditorEvents> {\n private commandManager!: CommandManager;\n\n public extensionManager!: ExtensionManager;\n\n private css: HTMLStyleElement | null = null;\n\n public schema!: Schema;\n\n private editorView: EditorView | null = null;\n\n public isFocused = false;\n\n private editorState!: EditorState;\n\n /**\n * The editor is considered initialized after the `create` event has been emitted.\n */\n public isInitialized = false;\n\n public extensionStorage: Storage = {} as Storage;\n\n /**\n * Resolved editor theme (null if no theme applied)\n */\n private resolvedTheme: ResolvedTheme;\n\n /**\n * A unique ID for this editor instance.\n */\n public instanceId = Math.random().toString(36).slice(2, 9);\n\n public options: EditorOptions = {\n element:\n typeof document !== \"undefined\" ? document.createElement(\"div\") : null,\n content: \"\",\n injectCSS: true,\n injectNonce: undefined,\n extensions: [],\n autofocus: false,\n editable: true,\n editorProps: {},\n parseOptions: {},\n coreExtensionOptions: {},\n enableInputRules: true,\n enablePasteRules: true,\n enableCoreExtensions: true,\n enableContentCheck: false,\n emitContentError: false,\n onBeforeCreate: () => null,\n onCreate: () => null,\n onMount: () => null,\n onUnmount: () => null,\n onUpdate: () => null,\n onSelectionUpdate: () => null,\n onTransaction: () => null,\n onFocus: () => null,\n onBlur: () => null,\n onDestroy: () => null,\n onContentError: ({ error }) => {\n throw error;\n },\n onPaste: () => null,\n onDrop: () => null,\n onDelete: () => null,\n };\n\n constructor(options: Partial<EditorOptions> = {}) {\n super();\n this.setOptions(options);\n\n // Resolve theme early in constructor\n this.resolvedTheme = resolveTheme(this.options.theme);\n\n this.createExtensionManager();\n this.createCommandManager();\n this.createSchema();\n this.on(\"beforeCreate\", this.options.onBeforeCreate);\n this.emit(\"beforeCreate\", { editor: this });\n this.on(\"mount\", this.options.onMount);\n this.on(\"unmount\", this.options.onUnmount);\n this.on(\"contentError\", this.options.onContentError);\n this.on(\"create\", this.options.onCreate);\n this.on(\"update\", this.options.onUpdate);\n this.on(\"selectionUpdate\", this.options.onSelectionUpdate);\n this.on(\"transaction\", this.options.onTransaction);\n this.on(\"focus\", this.options.onFocus);\n this.on(\"blur\", this.options.onBlur);\n this.on(\"destroy\", this.options.onDestroy);\n this.on(\"drop\", ({ event, slice, moved }) =>\n this.options.onDrop(event, slice, moved)\n );\n this.on(\"paste\", ({ event, slice }) => this.options.onPaste(event, slice));\n this.on(\"delete\", this.options.onDelete);\n\n const initialDoc = this.createDoc();\n const selection = resolveFocusPosition(initialDoc, this.options.autofocus);\n\n // Set editor state immediately, so that it's available independently from the view\n this.editorState = EditorState.create({\n doc: initialDoc,\n schema: this.schema,\n selection: selection || undefined,\n });\n\n if (this.options.element) {\n this.mount(this.options.element);\n }\n }\n\n /**\n * Attach the editor to the DOM, creating a new editor view.\n */\n public mount(el: NonNullable<EditorOptions[\"element\"]> & {}) {\n if (typeof document === \"undefined\") {\n throw new Error(\n `[blockslides error]: The editor cannot be mounted because there is no 'document' defined in this environment.`\n );\n }\n this.createView(el);\n this.emit(\"mount\", { editor: this });\n\n if (this.css && !document.head.contains(this.css)) {\n document.head.appendChild(this.css);\n }\n\n window.setTimeout(() => {\n if (this.isDestroyed) {\n return;\n }\n\n this.commands.focus(this.options.autofocus);\n this.emit(\"create\", { editor: this });\n this.isInitialized = true;\n }, 0);\n }\n\n /**\n * Remove the editor from the DOM, but still allow remounting at a different point in time\n */\n public unmount() {\n if (this.editorView) {\n // Cleanup our reference to prevent circular references which caused memory leaks\n // @ts-ignore\n const dom = this.editorView.dom as TiptapEditorHTMLElement;\n\n if (dom?.editor) {\n delete dom.editor;\n }\n this.editorView.destroy();\n }\n this.editorView = null;\n this.isInitialized = false;\n\n // Safely remove CSS element with fallback for test environments\n if (this.css) {\n try {\n if (typeof this.css.remove === \"function\") {\n this.css.remove();\n } else if (this.css.parentNode) {\n this.css.parentNode.removeChild(this.css);\n }\n } catch (error) {\n // Silently handle any unexpected DOM removal errors in test environments\n console.warn(\"Failed to remove CSS element:\", error);\n }\n }\n this.css = null;\n this.emit(\"unmount\", { editor: this });\n }\n\n /**\n * Returns the editor storage.\n */\n public get storage(): Storage {\n return this.extensionStorage;\n }\n\n /**\n * An object of all registered commands.\n */\n public get commands(): SingleCommands {\n return this.commandManager.commands;\n }\n\n /**\n * Create a command chain to call multiple commands at once.\n */\n public chain(): ChainedCommands {\n return this.commandManager.chain();\n }\n\n /**\n * Check if a command or a command chain can be executed. Without executing it.\n */\n public can(): CanCommands {\n return this.commandManager.can();\n }\n\n /**\n * Inject CSS styles.\n */\n private injectCSS(): void {\n if (this.options.injectCSS && typeof document !== \"undefined\") {\n this.css = createStyleTag(style, this.options.injectNonce);\n }\n }\n\n /**\n * Update editor options.\n *\n * @param options A list of options\n */\n public setOptions(options: Partial<EditorOptions> = {}): void {\n this.options = {\n ...this.options,\n ...options,\n };\n\n if (!this.editorView || !this.state || this.isDestroyed) {\n return;\n }\n\n if (this.options.editorProps) {\n this.view.setProps(this.options.editorProps);\n }\n\n this.view.updateState(this.state);\n }\n\n /**\n * Update editable state of the editor.\n */\n public setEditable(editable: boolean, emitUpdate = true): void {\n this.setOptions({ editable });\n\n if (emitUpdate) {\n this.emit(\"update\", {\n editor: this,\n transaction: this.state.tr,\n appendedTransactions: [],\n });\n }\n }\n\n /**\n * Returns whether the editor is editable.\n */\n public get isEditable(): boolean {\n // since plugins are applied after creating the view\n // `editable` is always `true` for one tick.\n // that’s why we also have to check for `options.editable`\n return this.options.editable && this.view && this.view.editable;\n }\n\n /**\n * Returns the editor state.\n */\n public get view(): EditorView {\n if (this.editorView) {\n return this.editorView;\n }\n\n return new Proxy(\n {\n state: this.editorState,\n updateState: (\n state: EditorState\n ): ReturnType<EditorView[\"updateState\"]> => {\n this.editorState = state;\n },\n dispatch: (tr: Transaction): ReturnType<EditorView[\"dispatch\"]> => {\n this.dispatchTransaction(tr);\n },\n\n // Stub some commonly accessed properties to prevent errors\n composing: false,\n dragging: null,\n editable: true,\n isDestroyed: false,\n } as EditorView,\n {\n get: (obj, key) => {\n if (this.editorView) {\n // If the editor view is available, but the caller has a stale reference to the proxy,\n // Just return what the editor view has.\n return this.editorView[key as keyof EditorView];\n }\n // Specifically always return the most recent editorState\n if (key === \"state\") {\n return this.editorState;\n }\n if (key in obj) {\n return Reflect.get(obj, key);\n }\n\n // We throw an error here, because we know the view is not available\n throw new Error(\n `[blockslides error] The editor view is not available. Cannot access view['${\n key as string\n }']. The editor may not be mounted yet.`\n );\n },\n }\n ) as EditorView;\n }\n\n /**\n * Returns the editor state.\n */\n public get state(): EditorState {\n if (this.editorView) {\n this.editorState = this.view.state;\n }\n\n return this.editorState;\n }\n\n /**\n * Register a ProseMirror plugin.\n *\n * @param plugin A ProseMirror plugin\n * @param handlePlugins Control how to merge the plugin into the existing plugins.\n * @returns The new editor state\n */\n public registerPlugin(\n plugin: Plugin,\n handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]\n ): EditorState {\n const plugins = isFunction(handlePlugins)\n ? handlePlugins(plugin, [...this.state.plugins])\n : [...this.state.plugins, plugin];\n\n const state = this.state.reconfigure({ plugins });\n\n this.view.updateState(state);\n\n return state;\n }\n\n /**\n * Unregister a ProseMirror plugin.\n *\n * @param nameOrPluginKeyToRemove The plugins name\n * @returns The new editor state or undefined if the editor is destroyed\n */\n public unregisterPlugin(\n nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]\n ): EditorState | undefined {\n if (this.isDestroyed) {\n return undefined;\n }\n\n const prevPlugins = this.state.plugins;\n let plugins = prevPlugins;\n\n ([] as (string | PluginKey)[])\n .concat(nameOrPluginKeyToRemove)\n .forEach((nameOrPluginKey) => {\n // @ts-ignore\n const name =\n typeof nameOrPluginKey === \"string\"\n ? `${nameOrPluginKey}$`\n : //@ts-ignore igonoring for now since from tiptap\n nameOrPluginKey.key;\n\n // @ts-ignore\n plugins = plugins.filter((plugin) => !plugin.key.startsWith(name));\n });\n\n if (prevPlugins.length === plugins.length) {\n // No plugin was removed, so we don’t need to update the state\n return undefined;\n }\n\n const state = this.state.reconfigure({\n plugins,\n });\n\n this.view.updateState(state);\n\n return state;\n }\n\n /**\n * Creates an extension manager.\n */\n private createExtensionManager(): void {\n const coreExtensions = this.options.enableCoreExtensions\n ? [\n Editable,\n ClipboardTextSerializer.configure({\n blockSeparator:\n this.options.coreExtensionOptions?.clipboardTextSerializer\n ?.blockSeparator,\n }),\n Commands,\n FocusEvents,\n Keymap,\n Tabindex,\n Drop,\n Paste,\n Delete,\n ].filter((ext) => {\n if (typeof this.options.enableCoreExtensions === \"object\") {\n return (\n this.options.enableCoreExtensions[\n ext.name as keyof typeof this.options.enableCoreExtensions\n ] !== false\n );\n }\n return true;\n })\n : [];\n const allExtensions = [\n ...coreExtensions,\n ...this.options.extensions,\n ].filter((extension) => {\n return [\"extension\", \"node\", \"mark\"].includes(extension?.type);\n });\n\n this.extensionManager = new ExtensionManager(allExtensions, this);\n }\n\n /**\n * Creates an command manager.\n */\n private createCommandManager(): void {\n this.commandManager = new CommandManager({\n editor: this,\n });\n }\n\n /**\n * Creates a ProseMirror schema.\n */\n private createSchema(): void {\n this.schema = this.extensionManager.schema;\n }\n\n /**\n * Creates the initial document.\n */\n private createDoc(): ProseMirrorNode {\n let doc: ProseMirrorNode;\n\n try {\n doc = createDocument(\n this.options.content,\n this.schema,\n this.options.parseOptions,\n {\n errorOnInvalidContent: this.options.enableContentCheck,\n }\n );\n } catch (e) {\n if (\n !(e instanceof Error) ||\n ![\n \"[blockslides error] Invalid JSON content\",\n \"[blockslides error] Invalid HTML content\",\n ].includes(e.message)\n ) {\n // Not the content error we were expecting\n throw e;\n }\n this.emit(\"contentError\", {\n editor: this,\n error: e as Error,\n disableCollaboration: () => {\n if (\n \"collaboration\" in this.storage &&\n typeof this.storage.collaboration === \"object\" &&\n this.storage.collaboration\n ) {\n (this.storage.collaboration as any).isDisabled = true;\n }\n // To avoid syncing back invalid content, reinitialize the extensions without the collaboration extension\n this.options.extensions = this.options.extensions.filter(\n (extension) => extension.name !== \"collaboration\"\n );\n\n // Restart the initialization process by recreating the extension manager with the new set of extensions\n this.createExtensionManager();\n },\n });\n\n // Content is invalid, but attempt to create it anyway, stripping out the invalid parts\n doc = createDocument(\n this.options.content,\n this.schema,\n this.options.parseOptions,\n {\n errorOnInvalidContent: false,\n }\n );\n }\n return doc;\n }\n\n /**\n * Creates a ProseMirror view.\n */\n private createView(element: NonNullable<EditorOptions[\"element\"]>): void {\n this.editorView = new EditorView(element, {\n ...this.options.editorProps,\n attributes: {\n // add `role=\"textbox\"` to the editor element\n role: \"textbox\",\n ...this.options.editorProps?.attributes,\n },\n dispatchTransaction: this.dispatchTransaction.bind(this),\n state: this.editorState,\n markViews: this.extensionManager.markViews,\n nodeViews: this.extensionManager.nodeViews,\n });\n\n // `editor.view` is not yet available at this time.\n // Therefore we will add all plugins and node views directly afterwards.\n const newState = this.state.reconfigure({\n plugins: this.extensionManager.plugins,\n });\n\n this.view.updateState(newState);\n\n this.prependClass();\n this.injectCSS();\n\n // Apply theme to editor element\n applyTheme(this.resolvedTheme, this.view.dom as HTMLElement);\n\n // Let's store the editor instance in the DOM element.\n // So we'll have access to it for tests.\n // @ts-ignore\n const dom = this.view.dom as TiptapEditorHTMLElement;\n\n dom.editor = this;\n }\n\n /**\n * Creates all node and mark views.\n */\n public createNodeViews(): void {\n if (this.view.isDestroyed) {\n return;\n }\n\n this.view.setProps({\n markViews: this.extensionManager.markViews,\n nodeViews: this.extensionManager.nodeViews,\n });\n }\n\n /**\n * Prepend class name to element.\n */\n public prependClass(): void {\n this.view.dom.className = `blockslides-editor ${this.view.dom.className}`;\n }\n\n public isCapturingTransaction = false;\n\n private capturedTransaction: Transaction | null = null;\n\n public captureTransaction(fn: () => void) {\n this.isCapturingTransaction = true;\n fn();\n this.isCapturingTransaction = false;\n\n const tr = this.capturedTransaction;\n\n this.capturedTransaction = null;\n\n return tr;\n }\n\n /**\n * The callback over which to send transactions (state updates) produced by the view.\n *\n * @param transaction An editor state transaction\n */\n private dispatchTransaction(transaction: Transaction): void {\n // if the editor / the view of the editor was destroyed\n // the transaction should not be dispatched as there is no view anymore.\n if (this.view.isDestroyed) {\n return;\n }\n\n if (this.isCapturingTransaction) {\n if (!this.capturedTransaction) {\n this.capturedTransaction = transaction;\n\n return;\n }\n\n transaction.steps.forEach((step: Step) => this.capturedTransaction?.step(step));\n\n return;\n }\n\n // Apply transaction and get resulting state and transactions\n const { state, transactions } = this.state.applyTransaction(transaction);\n const selectionHasChanged = !this.state.selection.eq(state.selection);\n const rootTrWasApplied = transactions.includes(transaction);\n const prevState = this.state;\n\n this.emit(\"beforeTransaction\", {\n editor: this,\n transaction,\n nextState: state,\n });\n\n // If transaction was filtered out, we can return early\n if (!rootTrWasApplied) {\n return;\n }\n\n this.view.updateState(state);\n\n // Emit transaction event with appended transactions info\n this.emit(\"transaction\", {\n editor: this,\n transaction,\n appendedTransactions: transactions.slice(1),\n });\n\n if (selectionHasChanged) {\n this.emit(\"selectionUpdate\", {\n editor: this,\n transaction,\n });\n }\n\n // Only emit the latest between focus and blur events\n //@ts-ignore igonoring for now since from tiptap\n const mostRecentFocusTr = transactions.findLast(\n (tr: Transaction) => tr.getMeta(\"focus\") || tr.getMeta(\"blur\")\n );\n const focus = mostRecentFocusTr?.getMeta(\"focus\");\n const blur = mostRecentFocusTr?.getMeta(\"blur\");\n\n if (focus) {\n this.emit(\"focus\", {\n editor: this,\n event: focus.event,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n transaction: mostRecentFocusTr!,\n });\n }\n\n if (blur) {\n this.emit(\"blur\", {\n editor: this,\n event: blur.event,\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n transaction: mostRecentFocusTr!,\n });\n }\n\n // Compare states for update event\n if (\n transaction.getMeta(\"preventUpdate\") ||\n !transactions.some((tr: Transaction) => tr.docChanged) ||\n prevState.doc.eq(state.doc)\n ) {\n return;\n }\n\n this.emit(\"update\", {\n editor: this,\n transaction,\n appendedTransactions: transactions.slice(1),\n });\n }\n\n /**\n * Get attributes of the currently selected node or mark.\n */\n public getAttributes(\n nameOrType: string | NodeType | MarkType\n ): Record<string, any> {\n return getAttributes(this.state, nameOrType);\n }\n\n /**\n * Returns if the currently selected node or mark is active.\n *\n * @param name Name of the node or mark\n * @param attributes Attributes of the node or mark\n */\n public isActive(name: string, attributes?: {}): boolean;\n public isActive(attributes: {}): boolean;\n public isActive(\n nameOrAttributes: string,\n attributesOrUndefined?: {}\n ): boolean {\n const name = typeof nameOrAttributes === \"string\" ? nameOrAttributes : null;\n\n const attributes =\n typeof nameOrAttributes === \"string\"\n ? attributesOrUndefined\n : nameOrAttributes;\n\n return isActive(this.state, name, attributes);\n }\n\n /**\n * Get the document as JSON.\n */\n public getJSON(): DocumentType<\n Record<string, any> | undefined,\n TNodeType<\n string,\n undefined | Record<string, any>,\n any,\n (TNodeType | TTextType)[]\n >[]\n > {\n return this.state.doc.toJSON();\n }\n\n /**\n * Get the document as HTML.\n */\n public getHTML(): string {\n return getHTMLFromFragment(this.state.doc.content, this.schema);\n }\n\n /**\n * Get the document as text.\n */\n public getText(options?: {\n blockSeparator?: string;\n textSerializers?: Record<string, TextSerializer>;\n }): string {\n const { blockSeparator = \"\\n\\n\", textSerializers = {} } = options || {};\n\n return getText(this.state.doc, {\n blockSeparator,\n textSerializers: {\n ...getTextSerializersFromSchema(this.schema),\n ...textSerializers,\n },\n });\n }\n\n /**\n * Check if there is no content.\n */\n public get isEmpty(): boolean {\n return isNodeEmpty(this.state.doc);\n }\n\n /**\n * Set or change the editor theme\n *\n * @param theme - Theme to apply (string, full theme object, or partial theme)\n *\n * @example\n * // Switch to built-in dark theme\n * editor.setTheme('dark');\n *\n * @example\n * // Apply custom theme\n * editor.setTheme({\n * extends: 'dark',\n * colors: { background: '#0a0a0a' }\n * });\n */\n public setTheme(theme: typeof this.options.theme): void {\n this.resolvedTheme = resolveTheme(theme);\n\n if (this.editorView) {\n applyTheme(this.resolvedTheme, this.view.dom as HTMLElement);\n }\n }\n\n /**\n * Get the current theme\n *\n * @returns Current resolved theme (null if no theme applied)\n */\n public getTheme(): ResolvedTheme {\n return this.resolvedTheme;\n }\n\n /**\n * Destroy the editor.\n */\n public destroy(): void {\n this.emit(\"destroy\");\n\n this.unmount();\n\n this.removeAllListeners();\n }\n\n /**\n * Check if the editor is already destroyed.\n */\n public get isDestroyed(): boolean {\n return this.editorView?.isDestroyed ?? true;\n }\n\n public $node(\n selector: string,\n attributes?: { [key: string]: any }\n ): NodePos | null {\n return this.$doc?.querySelector(selector, attributes) || null;\n }\n\n public $nodes(\n selector: string,\n attributes?: { [key: string]: any }\n ): NodePos[] | null {\n return this.$doc?.querySelectorAll(selector, attributes) || null;\n }\n\n public $pos(pos: number) {\n const $pos = this.state.doc.resolve(pos);\n\n return new NodePos($pos, this);\n }\n\n get $doc() {\n return this.$pos(0);\n }\n}\n\n/** @deprecated Use SlideEditor instead */\nexport { SlideEditor as Editor };\n","type StringKeyOf<T> = Extract<keyof T, string>\ntype CallbackType<T extends Record<string, any>, EventName extends StringKeyOf<T>> = T[EventName] extends any[]\n ? T[EventName]\n : [T[EventName]]\ntype CallbackFunction<T extends Record<string, any>, EventName extends StringKeyOf<T>> = (\n ...props: CallbackType<T, EventName>\n) => any\n\nexport class EventEmitter<T extends Record<string, any>> {\n private callbacks: { [key: string]: Array<(...args: any[]) => void> } = {}\n\n public on<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this {\n if (!this.callbacks[event]) {\n this.callbacks[event] = []\n }\n\n this.callbacks[event].push(fn)\n\n return this\n }\n\n public emit<EventName extends StringKeyOf<T>>(event: EventName, ...args: CallbackType<T, EventName>): this {\n const callbacks = this.callbacks[event]\n\n if (callbacks) {\n callbacks.forEach(callback => callback.apply(this, args))\n }\n\n return this\n }\n\n public off<EventName extends StringKeyOf<T>>(event: EventName, fn?: CallbackFunction<T, EventName>): this {\n const callbacks = this.callbacks[event]\n\n if (callbacks) {\n if (fn) {\n this.callbacks[event] = callbacks.filter(callback => callback !== fn)\n } else {\n delete this.callbacks[event]\n }\n }\n\n return this\n }\n\n public once<EventName extends StringKeyOf<T>>(event: EventName, fn: CallbackFunction<T, EventName>): this {\n const onceFn = (...args: CallbackType<T, EventName>) => {\n this.off(event, onceFn)\n fn.apply(this, args)\n }\n\n return this.on(event, onceFn)\n }\n\n public removeAllListeners(): void {\n this.callbacks = {}\n }\n}\n","import { keymap } from \"@blockslides/pm/keymap\";\nimport type { Schema } from \"@blockslides/pm/model\";\nimport type { Plugin } from \"@blockslides/pm/state\";\nimport type {\n MarkViewConstructor,\n NodeViewConstructor,\n} from \"@blockslides/pm/view\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport {\n flattenExtensions,\n getAttributesFromExtensions,\n getExtensionField,\n getNodeType,\n getRenderedAttributes,\n getSchemaByResolvedExtensions,\n getSchemaTypeByName,\n isExtensionRulesEnabled,\n resolveExtensions,\n sortExtensions,\n splitExtensions,\n} from \"./helpers/index.js\";\nimport {\n type MarkConfig,\n type NodeConfig,\n type Storage,\n getMarkType,\n updateMarkViewAttributes,\n} from \"./index.js\";\nimport { inputRulesPlugin } from \"./InputRule.js\";\nimport { Mark } from \"./Mark.js\";\nimport { pasteRulesPlugin } from \"./PasteRule.js\";\nimport type { AnyConfig, Extensions, RawCommands } from \"./types.js\";\nimport { callOrReturn } from \"./utilities/callOrReturn.js\";\n\nexport class ExtensionManager {\n editor: Editor;\n\n schema: Schema;\n\n /**\n * A flattened and sorted array of all extensions\n */\n extensions: Extensions;\n\n /**\n * A non-flattened array of base extensions (no sub-extensions)\n */\n baseExtensions: Extensions;\n\n splittableMarks: string[] = [];\n\n constructor(extensions: Extensions, editor: Editor) {\n this.editor = editor;\n this.baseExtensions = extensions;\n this.extensions = resolveExtensions(extensions);\n this.schema = getSchemaByResolvedExtensions(this.extensions, editor);\n this.setupExtensions();\n }\n\n static resolve = resolveExtensions;\n\n static sort = sortExtensions;\n\n static flatten = flattenExtensions;\n\n /**\n * Get all commands from the extensions.\n * @returns An object with all commands where the key is the command name and the value is the command function\n */\n get commands(): RawCommands {\n return this.extensions.reduce((commands, extension) => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: this.editor.extensionStorage[extension.name as keyof Storage],\n editor: this.editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n };\n\n const addCommands = getExtensionField<AnyConfig[\"addCommands\"]>(\n extension,\n \"addCommands\",\n context\n );\n\n if (!addCommands) {\n return commands;\n }\n\n return {\n ...commands,\n ...addCommands(),\n };\n }, {} as RawCommands);\n }\n\n /**\n * Get all registered Prosemirror plugins from the extensions.\n * @returns An array of Prosemirror plugins\n */\n get plugins(): Plugin[] {\n const { editor } = this;\n\n const extensions = sortExtensions([...this.extensions].reverse());\n\n const allPlugins = extensions.flatMap((extension) => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: this.editor.extensionStorage[extension.name as keyof Storage],\n editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n };\n\n const plugins: Plugin[] = [];\n\n const addKeyboardShortcuts = getExtensionField<\n AnyConfig[\"addKeyboardShortcuts\"]\n >(extension, \"addKeyboardShortcuts\", context);\n\n let defaultBindings: Record<string, () => boolean> = {};\n\n // bind exit handling\n if (\n extension.type === \"mark\" &&\n getExtensionField<MarkConfig[\"exitable\"]>(\n extension,\n \"exitable\",\n context\n )\n ) {\n defaultBindings.ArrowRight = () =>\n Mark.handleExit({ editor, mark: extension as Mark });\n }\n\n if (addKeyboardShortcuts) {\n const bindings = Object.fromEntries(\n Object.entries(addKeyboardShortcuts()).map(([shortcut, method]) => {\n return [shortcut, () => method({ editor })];\n })\n );\n\n defaultBindings = { ...defaultBindings, ...bindings };\n }\n\n const keyMapPlugin = keymap(defaultBindings);\n\n plugins.push(keyMapPlugin);\n\n const addInputRules = getExtensionField<AnyConfig[\"addInputRules\"]>(\n extension,\n \"addInputRules\",\n context\n );\n\n if (\n isExtensionRulesEnabled(extension, editor.options.enableInputRules) &&\n addInputRules\n ) {\n const rules = addInputRules();\n\n if (rules && rules.length) {\n const inputResult = inputRulesPlugin({\n editor,\n rules,\n });\n\n const inputPlugins = Array.isArray(inputResult)\n ? inputResult\n : [inputResult];\n\n plugins.push(...inputPlugins);\n }\n }\n\n const addPasteRules = getExtensionField<AnyConfig[\"addPasteRules\"]>(\n extension,\n \"addPasteRules\",\n context\n );\n\n if (\n isExtensionRulesEnabled(extension, editor.options.enablePasteRules) &&\n addPasteRules\n ) {\n const rules = addPasteRules();\n\n if (rules && rules.length) {\n const pasteRules = pasteRulesPlugin({ editor, rules });\n\n plugins.push(...pasteRules);\n }\n }\n\n const addProseMirrorPlugins = getExtensionField<\n AnyConfig[\"addProseMirrorPlugins\"]\n >(extension, \"addProseMirrorPlugins\", context);\n\n if (addProseMirrorPlugins) {\n const proseMirrorPlugins = addProseMirrorPlugins();\n\n plugins.push(...proseMirrorPlugins);\n }\n\n return plugins;\n });\n\n return allPlugins;\n }\n\n /**\n * Get all attributes from the extensions.\n * @returns An array of attributes\n */\n get attributes() {\n return getAttributesFromExtensions(this.extensions);\n }\n\n /**\n * Get all node views from the extensions.\n * @returns An object with all node views where the key is the node name and the value is the node view function\n */\n get nodeViews(): Record<string, NodeViewConstructor> {\n const { editor } = this;\n const { nodeExtensions } = splitExtensions(this.extensions);\n\n return Object.fromEntries(\n nodeExtensions\n .filter((extension) => !!getExtensionField(extension, \"addNodeView\"))\n .map((extension) => {\n const extensionAttributes = this.attributes.filter(\n (attribute) => attribute.type === extension.name\n );\n const context = {\n name: extension.name,\n options: extension.options,\n storage:\n this.editor.extensionStorage[extension.name as keyof Storage],\n editor,\n type: getNodeType(extension.name, this.schema),\n };\n const addNodeView = getExtensionField<NodeConfig[\"addNodeView\"]>(\n extension,\n \"addNodeView\",\n context\n );\n\n if (!addNodeView) {\n return [];\n }\n\n const nodeview: NodeViewConstructor = (\n node,\n view,\n getPos,\n decorations,\n innerDecorations\n ) => {\n const HTMLAttributes = getRenderedAttributes(\n node,\n extensionAttributes\n );\n\n return addNodeView()({\n // pass-through\n node,\n view,\n getPos: getPos as () => number,\n decorations,\n innerDecorations,\n // blockslides-specific\n editor,\n extension,\n HTMLAttributes,\n });\n };\n\n return [extension.name, nodeview];\n })\n );\n }\n\n get markViews(): Record<string, MarkViewConstructor> {\n const { editor } = this;\n const { markExtensions } = splitExtensions(this.extensions);\n\n return Object.fromEntries(\n markExtensions\n .filter((extension) => !!getExtensionField(extension, \"addMarkView\"))\n .map((extension) => {\n const extensionAttributes = this.attributes.filter(\n (attribute) => attribute.type === extension.name\n );\n const context = {\n name: extension.name,\n options: extension.options,\n storage:\n this.editor.extensionStorage[extension.name as keyof Storage],\n editor,\n type: getMarkType(extension.name, this.schema),\n };\n const addMarkView = getExtensionField<MarkConfig[\"addMarkView\"]>(\n extension,\n \"addMarkView\",\n context\n );\n\n if (!addMarkView) {\n return [];\n }\n\n const markView: MarkViewConstructor = (mark, view, inline) => {\n const HTMLAttributes = getRenderedAttributes(\n mark,\n extensionAttributes\n );\n\n return addMarkView()({\n // pass-through\n mark,\n view,\n inline,\n // blockslides-specific\n editor,\n extension,\n HTMLAttributes,\n updateAttributes: (attrs: Record<string, any>) => {\n updateMarkViewAttributes(mark, editor, attrs);\n },\n });\n };\n\n return [extension.name, markView];\n })\n );\n }\n\n /**\n * Go through all extensions, create extension storages & setup marks\n * & bind editor event listener.\n */\n private setupExtensions() {\n const extensions = this.extensions;\n // re-initialize the extension storage object instance\n this.editor.extensionStorage = Object.fromEntries(\n extensions.map((extension) => [extension.name, extension.storage])\n ) as unknown as Storage;\n\n extensions.forEach((extension) => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: this.editor.extensionStorage[extension.name as keyof Storage],\n editor: this.editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n };\n\n if (extension.type === \"mark\") {\n const keepOnSplit =\n callOrReturn(getExtensionField(extension, \"keepOnSplit\", context)) ??\n true;\n\n if (keepOnSplit) {\n this.splittableMarks.push(extension.name);\n }\n }\n\n const onBeforeCreate = getExtensionField<AnyConfig[\"onBeforeCreate\"]>(\n extension,\n \"onBeforeCreate\",\n context\n );\n const onCreate = getExtensionField<AnyConfig[\"onCreate\"]>(\n extension,\n \"onCreate\",\n context\n );\n const onUpdate = getExtensionField<AnyConfig[\"onUpdate\"]>(\n extension,\n \"onUpdate\",\n context\n );\n const onSelectionUpdate = getExtensionField<\n AnyConfig[\"onSelectionUpdate\"]\n >(extension, \"onSelectionUpdate\", context);\n const onTransaction = getExtensionField<AnyConfig[\"onTransaction\"]>(\n extension,\n \"onTransaction\",\n context\n );\n const onFocus = getExtensionField<AnyConfig[\"onFocus\"]>(\n extension,\n \"onFocus\",\n context\n );\n const onBlur = getExtensionField<AnyConfig[\"onBlur\"]>(\n extension,\n \"onBlur\",\n context\n );\n const onDestroy = getExtensionField<AnyConfig[\"onDestroy\"]>(\n extension,\n \"onDestroy\",\n context\n );\n\n if (onBeforeCreate) {\n this.editor.on(\"beforeCreate\", onBeforeCreate);\n }\n\n if (onCreate) {\n this.editor.on(\"create\", onCreate);\n }\n\n if (onUpdate) {\n this.editor.on(\"update\", onUpdate);\n }\n\n if (onSelectionUpdate) {\n this.editor.on(\"selectionUpdate\", onSelectionUpdate);\n }\n\n if (onTransaction) {\n this.editor.on(\"transaction\", onTransaction);\n }\n\n if (onFocus) {\n this.editor.on(\"focus\", onFocus);\n }\n\n if (onBlur) {\n this.editor.on(\"blur\", onBlur);\n }\n\n if (onDestroy) {\n this.editor.on(\"destroy\", onDestroy);\n }\n });\n }\n}\n","import type { Node as ProseMirrorNode } from \"@blockslides/pm/model\";\nimport { Fragment } from \"@blockslides/pm/model\";\nimport type { EditorState, TextSelection } from \"@blockslides/pm/state\";\nimport { Plugin } from \"@blockslides/pm/state\";\n\nimport { CommandManager } from \"./CommandManager.js\";\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport { createChainableState } from \"./helpers/createChainableState.js\";\nimport { getHTMLFromFragment } from \"./helpers/getHTMLFromFragment.js\";\nimport { getTextContentFromNodes } from \"./helpers/getTextContentFromNodes.js\";\nimport type {\n CanCommands,\n ChainedCommands,\n ExtendedRegExpMatchArray,\n Range,\n SingleCommands,\n} from \"./types.js\";\nimport { isRegExp } from \"./utilities/isRegExp.js\";\n\nexport type InputRuleMatch = {\n index: number;\n text: string;\n replaceWith?: string;\n match?: RegExpMatchArray;\n data?: Record<string, any>;\n};\n\nexport type InputRuleFinder =\n | RegExp\n | ((text: string) => InputRuleMatch | null);\n\nexport class InputRule {\n find: InputRuleFinder;\n\n handler: (props: {\n state: EditorState;\n range: Range;\n match: ExtendedRegExpMatchArray;\n commands: SingleCommands;\n chain: () => ChainedCommands;\n can: () => CanCommands;\n }) => void | null;\n\n undoable: boolean;\n\n constructor(config: {\n find: InputRuleFinder;\n handler: (props: {\n state: EditorState;\n range: Range;\n match: ExtendedRegExpMatchArray;\n commands: SingleCommands;\n chain: () => ChainedCommands;\n can: () => CanCommands;\n }) => void | null;\n undoable?: boolean;\n }) {\n this.find = config.find;\n this.handler = config.handler;\n this.undoable = config.undoable ?? true;\n }\n}\n\nconst inputRuleMatcherHandler = (\n text: string,\n find: InputRuleFinder\n): ExtendedRegExpMatchArray | null => {\n if (isRegExp(find)) {\n return find.exec(text);\n }\n\n const inputRuleMatch = find(text);\n\n if (!inputRuleMatch) {\n return null;\n }\n\n const result: ExtendedRegExpMatchArray = [inputRuleMatch.text];\n\n result.index = inputRuleMatch.index;\n result.input = text;\n result.data = inputRuleMatch.data;\n\n if (inputRuleMatch.replaceWith) {\n if (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) {\n console.warn(\n '[blockslides warn]: \"inputRuleMatch.replaceWith\" must be part of \"inputRuleMatch.text\".'\n );\n }\n\n result.push(inputRuleMatch.replaceWith);\n }\n\n return result;\n};\n\nfunction run(config: {\n editor: Editor;\n from: number;\n to: number;\n text: string;\n rules: InputRule[];\n plugin: Plugin;\n}): boolean {\n const { editor, from, to, text, rules, plugin } = config;\n const { view } = editor;\n\n if (view.composing) {\n return false;\n }\n\n const $from = view.state.doc.resolve(from);\n\n if (\n // check for code node\n $from.parent.type.spec.code ||\n // check for code mark\n !!($from.nodeBefore || $from.nodeAfter)?.marks.find(\n (mark) => mark.type.spec.code\n )\n ) {\n return false;\n }\n\n let matched = false;\n\n const textBefore = getTextContentFromNodes($from) + text;\n\n rules.forEach((rule) => {\n if (matched) {\n return;\n }\n\n const match = inputRuleMatcherHandler(textBefore, rule.find);\n\n if (!match) {\n return;\n }\n\n const tr = view.state.tr;\n const state = createChainableState({\n state: view.state,\n transaction: tr,\n });\n const range = {\n from: from - (match[0].length - text.length),\n to,\n };\n\n const { commands, chain, can } = new CommandManager({\n editor,\n state,\n });\n\n const handler = rule.handler({\n state,\n range,\n match,\n commands,\n chain,\n can,\n });\n\n // stop if there are no changes\n if (handler === null || !tr.steps.length) {\n return;\n }\n\n // store transform as meta data\n // so we can undo input rules within the `undoInputRules` command\n if (rule.undoable) {\n tr.setMeta(plugin, {\n transform: tr,\n from,\n to,\n text,\n });\n }\n\n view.dispatch(tr);\n matched = true;\n });\n\n return matched;\n}\n\n/**\n * Create an input rules plugin. When enabled, it will cause text\n * input that matches any of the given rules to trigger the rule’s\n * action.\n */\nexport function inputRulesPlugin(props: {\n editor: Editor;\n rules: InputRule[];\n}): Plugin {\n const { editor, rules } = props;\n const plugin = new Plugin({\n state: {\n init() {\n return null;\n },\n apply(tr, prev, state) {\n const stored = tr.getMeta(plugin);\n\n if (stored) {\n return stored;\n }\n\n // if InputRule is triggered by insertContent()\n const simulatedInputMeta = tr.getMeta(\"applyInputRules\") as\n | undefined\n | {\n from: number;\n text: string | ProseMirrorNode | Fragment;\n };\n const isSimulatedInput = !!simulatedInputMeta;\n\n if (isSimulatedInput) {\n setTimeout(() => {\n let { text } = simulatedInputMeta;\n\n if (typeof text === \"string\") {\n text = text as string;\n } else {\n text = getHTMLFromFragment(Fragment.from(text), state.schema);\n }\n\n const { from } = simulatedInputMeta;\n const to = from + text.length;\n\n run({\n editor,\n from,\n to,\n text,\n rules,\n plugin,\n });\n });\n }\n\n return tr.selectionSet || tr.docChanged ? null : prev;\n },\n },\n\n props: {\n handleTextInput(view, from, to, text) {\n return run({\n editor,\n from,\n to,\n text,\n rules,\n plugin,\n });\n },\n\n handleDOMEvents: {\n compositionend: (view) => {\n setTimeout(() => {\n const { $cursor } = view.state.selection as TextSelection;\n\n if ($cursor) {\n run({\n editor,\n from: $cursor.pos,\n to: $cursor.pos,\n text: \"\",\n rules,\n plugin,\n });\n }\n });\n\n return false;\n },\n },\n\n // add support for input rules to trigger on enter\n // this is useful for example for code blocks\n handleKeyDown(view, event) {\n if (event.key !== \"Enter\") {\n return false;\n }\n\n const { $cursor } = view.state.selection as TextSelection;\n\n if ($cursor) {\n return run({\n editor,\n from: $cursor.pos,\n to: $cursor.pos,\n text: \"\\n\",\n rules,\n plugin,\n });\n }\n\n return false;\n },\n },\n\n // @ts-ignore\n isInputRules: true,\n }) as Plugin;\n\n return plugin;\n}\n","// see: https://github.com/mesqueeb/is-what/blob/88d6e4ca92fb2baab6003c54e02eedf4e729e5ab/src/index.ts\n\nfunction getType(value: any): string {\n return Object.prototype.toString.call(value).slice(8, -1)\n}\n\nexport function isPlainObject(value: any): value is Record<string, any> {\n if (getType(value) !== 'Object') {\n return false\n }\n\n return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype\n}\n","import { isPlainObject } from './isPlainObject.js'\n\nexport function mergeDeep(target: Record<string, any>, source: Record<string, any>): Record<string, any> {\n const output = { ...target }\n\n if (isPlainObject(target) && isPlainObject(source)) {\n Object.keys(source).forEach(key => {\n if (isPlainObject(source[key]) && isPlainObject(target[key])) {\n output[key] = mergeDeep(target[key], source[key])\n } else {\n output[key] = source[key]\n }\n })\n }\n\n return output\n}\n","import type { Plugin } from \"@blockslides/pm/state\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport { getExtensionField } from \"./helpers/getExtensionField.js\";\nimport type { ExtensionConfig, MarkConfig, NodeConfig } from \"./index.js\";\nimport type { InputRule } from \"./InputRule.js\";\nimport type { Mark } from \"./Mark.js\";\nimport type { Node } from \"./Node.js\";\nimport type { PasteRule } from \"./PasteRule.js\";\nimport type {\n AnyConfig,\n EditorEvents,\n Extensions,\n GlobalAttributes,\n JSONContent,\n KeyboardShortcutCommand,\n MarkdownParseHelpers,\n MarkdownParseResult,\n MarkdownRendererHelpers,\n MarkdownToken,\n MarkdownTokenizer,\n ParentConfig,\n RawCommands,\n RenderContext,\n} from \"./types.js\";\nimport { callOrReturn } from \"./utilities/callOrReturn.js\";\nimport { mergeDeep } from \"./utilities/mergeDeep.js\";\n\nexport interface ExtendableConfig<\n Options = any,\n Storage = any,\n Config extends\n | ExtensionConfig<Options, Storage>\n | NodeConfig<Options, Storage>\n | MarkConfig<Options, Storage>\n | ExtendableConfig<Options, Storage> = ExtendableConfig<\n Options,\n Storage,\n any,\n any\n >,\n PMType = any\n> {\n /**\n * The extension name - this must be unique.\n * It will be used to identify the extension.\n *\n * @example 'myExtension'\n */\n name: string;\n\n /**\n * The priority of your extension. The higher, the earlier it will be called\n * and will take precedence over other extensions with a lower priority.\n * @default 100\n * @example 101\n */\n priority?: number;\n\n addOptions?: (this: {\n name: string;\n parent: ParentConfig<Config>[\"addOptions\"];\n }) => Options;\n\n \n addStorage?: (this: {\n name: string;\n options: Options;\n parent: ParentConfig<Config>[\"addStorage\"];\n }) => Storage;\n\n addGlobalAttributes?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n extensions: (Node | Mark)[];\n parent: ParentConfig<Config>[\"addGlobalAttributes\"];\n }) => GlobalAttributes;\n\n addCommands?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"addCommands\"];\n }) => Partial<RawCommands>;\n\n addKeyboardShortcuts?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"addKeyboardShortcuts\"];\n }) => {\n [key: string]: KeyboardShortcutCommand;\n };\n\n addInputRules?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"addInputRules\"];\n }) => InputRule[];\n\n addPasteRules?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"addPasteRules\"];\n }) => PasteRule[];\n\n addProseMirrorPlugins?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"addProseMirrorPlugins\"];\n }) => Plugin[];\n\n addExtensions?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<Config>[\"addExtensions\"];\n }) => Extensions;\n\n markdownTokenName?: string;\n\n /**\n * The parse function used by the markdown parser to convert markdown tokens to ProseMirror nodes.\n */\n parseMarkdown?: (\n token: MarkdownToken,\n helpers: MarkdownParseHelpers\n ) => MarkdownParseResult;\n\n /**\n * The serializer function used by the markdown serializer to convert ProseMirror nodes to markdown tokens.\n */\n renderMarkdown?: (\n node: JSONContent,\n helpers: MarkdownRendererHelpers,\n ctx: RenderContext\n ) => string;\n\n /**\n * The markdown tokenizer responsible for turning a markdown string into tokens\n *\n * Custom tokenizers are only needed when you want to parse non-standard markdown token.\n */\n markdownTokenizer?: MarkdownTokenizer;\n\n /**\n * Optional markdown options for indentation\n */\n markdownOptions?: {\n /**\n * Defines if this markdown element should indent it's child elements\n */\n indentsContent?: boolean;\n };\n\n /**\n * This function extends the schema of the node.\n * @example\n * extendNodeSchema() {\n * return {\n * group: 'inline',\n * selectable: false,\n * }\n * }\n */\n extendNodeSchema?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<Config>[\"extendNodeSchema\"];\n },\n extension: Node\n ) => Record<string, any>)\n | null;\n\n /**\n * This function extends the schema of the mark.\n * @example\n * extendMarkSchema() {\n * return {\n * group: 'inline',\n * selectable: false,\n * }\n * }\n */\n extendMarkSchema?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<Config>[\"extendMarkSchema\"];\n },\n extension: Mark\n ) => Record<string, any>)\n | null;\n\n /**\n * The editor is not ready yet.\n */\n onBeforeCreate?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onBeforeCreate\"];\n },\n event: EditorEvents[\"beforeCreate\"]\n ) => void)\n | null;\n\n /**\n * The editor is ready.\n */\n onCreate?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onCreate\"];\n },\n event: EditorEvents[\"create\"]\n ) => void)\n | null;\n\n /**\n * The content has changed.\n */\n onUpdate?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onUpdate\"];\n },\n event: EditorEvents[\"update\"]\n ) => void)\n | null;\n\n /**\n * The selection has changed.\n */\n onSelectionUpdate?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onSelectionUpdate\"];\n },\n event: EditorEvents[\"selectionUpdate\"]\n ) => void)\n | null;\n\n /**\n * The editor state has changed.\n */\n onTransaction?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onTransaction\"];\n },\n event: EditorEvents[\"transaction\"]\n ) => void)\n | null;\n\n /**\n * The editor is focused.\n */\n onFocus?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onFocus\"];\n },\n event: EditorEvents[\"focus\"]\n ) => void)\n | null;\n\n /**\n * The editor isn’t focused anymore.\n */\n onBlur?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onBlur\"];\n },\n event: EditorEvents[\"blur\"]\n ) => void)\n | null;\n\n /**\n * The editor is destroyed.\n */\n onDestroy?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: PMType;\n parent: ParentConfig<Config>[\"onDestroy\"];\n },\n event: EditorEvents[\"destroy\"]\n ) => void)\n | null;\n}\n\nexport class Extendable<\n Options = any,\n Storage = any,\n Config =\n | ExtensionConfig<Options, Storage>\n | NodeConfig<Options, Storage>\n | MarkConfig<Options, Storage>\n> {\n type = \"extendable\";\n parent: Extendable | null = null;\n\n child: Extendable | null = null;\n\n name = \"\";\n\n config: Config = {\n name: this.name,\n } as Config;\n\n constructor(config: Partial<Config> = {}) {\n this.config = {\n ...this.config,\n ...config,\n };\n\n this.name = (this.config as any).name;\n }\n\n get options(): Options {\n return {\n ...(callOrReturn(\n getExtensionField<AnyConfig[\"addOptions\"]>(this as any, \"addOptions\", {\n name: this.name,\n })\n ) || {}),\n };\n }\n\n get storage(): Readonly<Storage> {\n return {\n ...(callOrReturn(\n getExtensionField<AnyConfig[\"addStorage\"]>(this as any, \"addStorage\", {\n name: this.name,\n options: this.options,\n })\n ) || {}),\n };\n }\n\n configure(options: Partial<Options> = {}) {\n const extension = this.extend<Options, Storage, Config>({\n ...this.config,\n addOptions: () => {\n return mergeDeep(\n this.options as Record<string, any>,\n options\n ) as Options;\n },\n });\n\n extension.name = this.name;\n extension.parent = this.parent;\n\n return extension;\n }\n\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig =\n | ExtensionConfig<ExtendedOptions, ExtendedStorage>\n | NodeConfig<ExtendedOptions, ExtendedStorage>\n | MarkConfig<ExtendedOptions, ExtendedStorage>\n >(\n extendedConfig: Partial<ExtendedConfig> = {}\n ): Extendable<ExtendedOptions, ExtendedStorage> {\n const extension = new (this.constructor as any)({\n ...this.config,\n ...extendedConfig,\n });\n\n extension.parent = this;\n this.child = extension;\n extension.name =\n \"name\" in extendedConfig ? extendedConfig.name : extension.parent.name;\n\n return extension;\n }\n}\n","import type {\n DOMOutputSpec,\n Mark as ProseMirrorMark,\n MarkSpec,\n MarkType,\n} from \"@blockslides/pm/model\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport type { ExtendableConfig } from \"./Extendable.js\";\nimport { Extendable } from \"./Extendable.js\";\nimport type { Attributes, MarkViewRenderer, ParentConfig } from \"./types.js\";\n\nexport interface MarkConfig<Options = any, Storage = any>\n extends ExtendableConfig<\n Options,\n Storage,\n MarkConfig<Options, Storage>,\n MarkType\n > {\n /**\n * Mark View\n */\n addMarkView?:\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: MarkType;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"addMarkView\"];\n }) => MarkViewRenderer)\n | null;\n\n /**\n * Keep mark after split node\n */\n keepOnSplit?: boolean | (() => boolean);\n\n /**\n * Inclusive\n */\n inclusive?:\n | MarkSpec[\"inclusive\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"inclusive\"];\n editor?: Editor;\n }) => MarkSpec[\"inclusive\"]);\n\n /**\n * Excludes\n */\n excludes?:\n | MarkSpec[\"excludes\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"excludes\"];\n editor?: Editor;\n }) => MarkSpec[\"excludes\"]);\n\n /**\n * Marks this Mark as exitable\n */\n exitable?: boolean | (() => boolean);\n\n /**\n * Group\n */\n group?:\n | MarkSpec[\"group\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"group\"];\n editor?: Editor;\n }) => MarkSpec[\"group\"]);\n\n /**\n * Spanning\n */\n spanning?:\n | MarkSpec[\"spanning\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"spanning\"];\n editor?: Editor;\n }) => MarkSpec[\"spanning\"]);\n\n /**\n * Code\n */\n code?:\n | boolean\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"code\"];\n editor?: Editor;\n }) => boolean);\n\n /**\n * Parse HTML\n */\n parseHTML?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"parseHTML\"];\n editor?: Editor;\n }) => MarkSpec[\"parseDOM\"];\n\n /**\n * Render HTML\n */\n renderHTML?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"renderHTML\"];\n editor?: Editor;\n },\n props: {\n mark: ProseMirrorMark;\n HTMLAttributes: Record<string, any>;\n }\n ) => DOMOutputSpec)\n | null;\n\n /**\n * Attributes\n */\n addAttributes?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<MarkConfig<Options, Storage>>[\"addAttributes\"];\n editor?: Editor;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n }) => Attributes | {};\n}\n\nexport class Mark<Options = any, Storage = any> extends Extendable<\n Options,\n Storage,\n MarkConfig<Options, Storage>\n> {\n type = \"mark\";\n\n /**\n * Create a new Mark instance\n * @param config - Mark configuration object or a function that returns a configuration object\n */\n static create<O = any, S = any>(\n config: Partial<MarkConfig<O, S>> | (() => Partial<MarkConfig<O, S>>) = {}\n ) {\n // If the config is a function, execute it to get the configuration object\n const resolvedConfig = typeof config === \"function\" ? config() : config;\n return new Mark<O, S>(resolvedConfig);\n }\n\n static handleExit({ editor, mark }: { editor: Editor; mark: Mark }) {\n const { tr } = editor.state;\n const currentPos = editor.state.selection.$from;\n const isAtEnd = currentPos.pos === currentPos.end();\n\n if (isAtEnd) {\n const currentMarks = currentPos.marks();\n const isInMark = !!currentMarks.find((m) => m?.type.name === mark.name);\n\n if (!isInMark) {\n return false;\n }\n\n const removeMark = currentMarks.find((m) => m?.type.name === mark.name);\n\n if (removeMark) {\n tr.removeStoredMark(removeMark);\n }\n tr.insertText(\" \", currentPos.pos);\n\n editor.view.dispatch(tr);\n\n return true;\n }\n\n return false;\n }\n\n configure(options?: Partial<Options>) {\n return super.configure(options) as Mark<Options, Storage>;\n }\n\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig = MarkConfig<ExtendedOptions, ExtendedStorage>\n >(\n extendedConfig?:\n | (() => Partial<ExtendedConfig>)\n | (Partial<ExtendedConfig> &\n ThisType<{\n name: string;\n options: ExtendedOptions;\n storage: ExtendedStorage;\n editor: Editor;\n type: MarkType;\n }>)\n ): Mark<ExtendedOptions, ExtendedStorage> {\n // If the extended config is a function, execute it to get the configuration object\n const resolvedConfig =\n typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n return super.extend(resolvedConfig) as Mark<\n ExtendedOptions,\n ExtendedStorage\n >;\n }\n}\n","import type { Node as ProseMirrorNode } from \"@blockslides/pm/model\";\nimport { Fragment } from \"@blockslides/pm/model\";\nimport type { EditorState } from \"@blockslides/pm/state\";\nimport { Plugin } from \"@blockslides/pm/state\";\n\nimport { CommandManager } from \"./CommandManager.js\";\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport { createChainableState } from \"./helpers/createChainableState.js\";\nimport { getHTMLFromFragment } from \"./helpers/getHTMLFromFragment.js\";\nimport type {\n CanCommands,\n ChainedCommands,\n ExtendedRegExpMatchArray,\n Range,\n SingleCommands,\n} from \"./types.js\";\nimport { isNumber } from \"./utilities/isNumber.js\";\nimport { isRegExp } from \"./utilities/isRegExp.js\";\n\nexport type PasteRuleMatch = {\n index: number;\n text: string;\n replaceWith?: string;\n match?: RegExpMatchArray;\n data?: Record<string, any>;\n};\n\nexport type PasteRuleFinder =\n | RegExp\n | ((\n text: string,\n event?: ClipboardEvent | null\n ) => PasteRuleMatch[] | null | undefined);\n\n\nexport class PasteRule {\n find: PasteRuleFinder;\n\n handler: (props: {\n state: EditorState;\n range: Range;\n match: ExtendedRegExpMatchArray;\n commands: SingleCommands;\n chain: () => ChainedCommands;\n can: () => CanCommands;\n pasteEvent: ClipboardEvent | null;\n dropEvent: DragEvent | null;\n }) => void | null;\n\n constructor(config: {\n find: PasteRuleFinder;\n handler: (props: {\n can: () => CanCommands;\n chain: () => ChainedCommands;\n commands: SingleCommands;\n dropEvent: DragEvent | null;\n match: ExtendedRegExpMatchArray;\n pasteEvent: ClipboardEvent | null;\n range: Range;\n state: EditorState;\n }) => void | null;\n }) {\n this.find = config.find;\n this.handler = config.handler;\n }\n}\n\nconst pasteRuleMatcherHandler = (\n text: string,\n find: PasteRuleFinder,\n event?: ClipboardEvent | null\n): ExtendedRegExpMatchArray[] => {\n if (isRegExp(find)) {\n return [...text.matchAll(find)];\n }\n\n const matches = find(text, event);\n\n if (!matches) {\n return [];\n }\n\n return matches.map((pasteRuleMatch) => {\n const result: ExtendedRegExpMatchArray = [pasteRuleMatch.text];\n\n result.index = pasteRuleMatch.index;\n result.input = text;\n result.data = pasteRuleMatch.data;\n\n if (pasteRuleMatch.replaceWith) {\n if (!pasteRuleMatch.text.includes(pasteRuleMatch.replaceWith)) {\n console.warn(\n '[blockslides warn]: \"pasteRuleMatch.replaceWith\" must be part of \"pasteRuleMatch.text\".'\n );\n }\n\n result.push(pasteRuleMatch.replaceWith);\n }\n\n return result;\n });\n};\n\nfunction run(config: {\n editor: Editor;\n state: EditorState;\n from: number;\n to: number;\n rule: PasteRule;\n pasteEvent: ClipboardEvent | null;\n dropEvent: DragEvent | null;\n}): boolean {\n const { editor, state, from, to, rule, pasteEvent, dropEvent } = config;\n\n const { commands, chain, can } = new CommandManager({\n editor,\n state,\n });\n\n const handlers: (void | null)[] = [];\n\n state.doc.nodesBetween(from, to, (node, pos) => {\n // Skip code blocks and non-textual nodes.\n // Be defensive: `node` may be a Fragment without a `type`. Only text,\n // inline, or textblock nodes are processed by paste rules.\n if (\n node.type?.spec?.code ||\n !(node.isText || node.isTextblock || node.isInline)\n ) {\n return;\n }\n\n // For textblock and inline/text nodes, compute the range relative to the node.\n // Prefer `node.nodeSize` when available (some Node shapes expose this),\n // otherwise fall back to `node.content?.size`. Default to 0 if neither exists.\n const contentSize = node.content?.size ?? node.nodeSize ?? 0;\n const resolvedFrom = Math.max(from, pos);\n const resolvedTo = Math.min(to, pos + contentSize);\n\n // If the resolved range is empty or invalid for this node, skip it. This\n // avoids calling `textBetween` with start > end which can cause internal\n // Fragment/Node traversal to access undefined `nodeSize` values.\n if (resolvedFrom >= resolvedTo) {\n return;\n }\n\n const textToMatch = node.isText\n ? node.text || \"\"\n : node.textBetween(\n resolvedFrom - pos,\n resolvedTo - pos,\n undefined,\n \"\\ufffc\"\n );\n\n const matches = pasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent);\n\n matches.forEach((match) => {\n if (match.index === undefined) {\n return;\n }\n\n const start = resolvedFrom + match.index + 1;\n const end = start + match[0].length;\n const range = {\n from: state.tr.mapping.map(start),\n to: state.tr.mapping.map(end),\n };\n\n const handler = rule.handler({\n state,\n range,\n match,\n commands,\n chain,\n can,\n pasteEvent,\n dropEvent,\n });\n\n handlers.push(handler);\n });\n });\n\n const success = handlers.every((handler) => handler !== null);\n\n return success;\n}\n\n// When dragging across editors, must get another editor instance to delete selection content.\nlet tiptapDragFromOtherEditor: Editor | null = null;\n\nconst createClipboardPasteEvent = (text: string) => {\n const event = new ClipboardEvent(\"paste\", {\n clipboardData: new DataTransfer(),\n });\n\n event.clipboardData?.setData(\"text/html\", text);\n\n return event;\n};\n\n/**\n * Create an paste rules plugin. When enabled, it will cause pasted\n * text that matches any of the given rules to trigger the rule’s\n * action.\n */\nexport function pasteRulesPlugin(props: {\n editor: Editor;\n rules: PasteRule[];\n}): Plugin[] {\n const { editor, rules } = props;\n let dragSourceElement: Element | null = null;\n let isPastedFromProseMirror = false;\n let isDroppedFromProseMirror = false;\n let pasteEvent =\n typeof ClipboardEvent !== \"undefined\" ? new ClipboardEvent(\"paste\") : null;\n let dropEvent: DragEvent | null;\n\n try {\n dropEvent = typeof DragEvent !== \"undefined\" ? new DragEvent(\"drop\") : null;\n } catch {\n dropEvent = null;\n }\n\n const processEvent = ({\n state,\n from,\n to,\n rule,\n pasteEvt,\n }: {\n state: EditorState;\n from: number;\n to: { b: number };\n rule: PasteRule;\n pasteEvt: ClipboardEvent | null;\n }) => {\n const tr = state.tr;\n const chainableState = createChainableState({\n state,\n transaction: tr,\n });\n\n const handler = run({\n editor,\n state: chainableState,\n from: Math.max(from - 1, 0),\n to: to.b - 1,\n rule,\n pasteEvent: pasteEvt,\n dropEvent,\n });\n\n if (!handler || !tr.steps.length) {\n return;\n }\n\n try {\n dropEvent =\n typeof DragEvent !== \"undefined\" ? new DragEvent(\"drop\") : null;\n } catch {\n dropEvent = null;\n }\n pasteEvent =\n typeof ClipboardEvent !== \"undefined\"\n ? new ClipboardEvent(\"paste\")\n : null;\n\n return tr;\n };\n\n const plugins = rules.map((rule) => {\n return new Plugin({\n // we register a global drag handler to track the current drag source element\n view(view) {\n const handleDragstart = (event: DragEvent) => {\n dragSourceElement = view.dom.parentElement?.contains(\n event.target as Element\n )\n ? view.dom.parentElement\n : null;\n\n if (dragSourceElement) {\n tiptapDragFromOtherEditor = editor;\n }\n };\n\n const handleDragend = () => {\n if (tiptapDragFromOtherEditor) {\n tiptapDragFromOtherEditor = null;\n }\n };\n\n window.addEventListener(\"dragstart\", handleDragstart);\n window.addEventListener(\"dragend\", handleDragend);\n\n return {\n destroy() {\n window.removeEventListener(\"dragstart\", handleDragstart);\n window.removeEventListener(\"dragend\", handleDragend);\n },\n };\n },\n\n props: {\n handleDOMEvents: {\n drop: (view, event: Event) => {\n isDroppedFromProseMirror =\n dragSourceElement === view.dom.parentElement;\n dropEvent = event as DragEvent;\n\n if (!isDroppedFromProseMirror) {\n const dragFromOtherEditor = tiptapDragFromOtherEditor;\n\n if (dragFromOtherEditor?.isEditable) {\n // setTimeout to avoid the wrong content after drop, timeout arg can't be empty or 0\n setTimeout(() => {\n const selection = dragFromOtherEditor.state.selection;\n\n if (selection) {\n dragFromOtherEditor.commands.deleteRange({\n from: selection.from,\n to: selection.to,\n });\n }\n }, 10);\n }\n }\n return false;\n },\n\n paste: (_view, event: Event) => {\n const html = (event as ClipboardEvent).clipboardData?.getData(\n \"text/html\"\n );\n\n pasteEvent = event as ClipboardEvent;\n\n isPastedFromProseMirror = !!html?.includes(\"data-pm-slice\");\n\n return false;\n },\n },\n },\n\n appendTransaction: (transactions, oldState, state) => {\n const transaction = transactions[0];\n const isPaste =\n transaction.getMeta(\"uiEvent\") === \"paste\" &&\n !isPastedFromProseMirror;\n const isDrop =\n transaction.getMeta(\"uiEvent\") === \"drop\" &&\n !isDroppedFromProseMirror;\n\n // if PasteRule is triggered by insertContent()\n const simulatedPasteMeta = transaction.getMeta(\"applyPasteRules\") as\n | undefined\n | { from: number; text: string | ProseMirrorNode | Fragment };\n const isSimulatedPaste = !!simulatedPasteMeta;\n\n if (!isPaste && !isDrop && !isSimulatedPaste) {\n return;\n }\n\n // Handle simulated paste\n if (isSimulatedPaste) {\n let { text } = simulatedPasteMeta;\n\n if (typeof text === \"string\") {\n text = text as string;\n } else {\n text = getHTMLFromFragment(Fragment.from(text), state.schema);\n }\n\n const { from } = simulatedPasteMeta;\n const to = from + text.length;\n\n const pasteEvt = createClipboardPasteEvent(text);\n\n return processEvent({\n rule,\n state,\n from,\n to: { b: to },\n pasteEvt,\n });\n }\n\n // handle actual paste/drop\n const from = oldState.doc.content.findDiffStart(state.doc.content);\n const to = oldState.doc.content.findDiffEnd(state.doc.content);\n\n // stop if there is no changed range\n if (!isNumber(from) || !to || from === to.b) {\n return;\n }\n\n return processEvent({\n rule,\n state,\n from,\n to,\n pasteEvt: pasteEvent,\n });\n },\n });\n });\n\n return plugins;\n}\n","export function isNumber(value: any): value is number {\n return typeof value === 'number'\n}\n","export { ClipboardTextSerializer } from './clipboardTextSerializer.js'\nexport { Commands } from './commands.js'\nexport { Delete } from './delete.js'\nexport { Drop } from './drop.js'\nexport { Editable } from './editable.js'\nexport { FocusEvents, focusEventsPluginKey } from './focusEvents.js'\nexport { Keymap } from './keymap.js'\nexport { Paste } from './paste.js'\nexport { Tabindex } from './tabindex.js'\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\nimport { getTextBetween } from '../helpers/getTextBetween.js'\nimport { getTextSerializersFromSchema } from '../helpers/getTextSerializersFromSchema.js'\n\nexport type ClipboardTextSerializerOptions = {\n blockSeparator?: string\n}\n\nexport const ClipboardTextSerializer = Extension.create<ClipboardTextSerializerOptions>({\n name: 'clipboardTextSerializer',\n\n addOptions() {\n return {\n blockSeparator: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('clipboardTextSerializer'),\n props: {\n clipboardTextSerializer: () => {\n const { editor } = this\n const { state, schema } = editor\n const { doc, selection } = state\n const { ranges } = selection\n const from = Math.min(...ranges.map(range => range.$from.pos))\n const to = Math.max(...ranges.map(range => range.$to.pos))\n const textSerializers = getTextSerializersFromSchema(schema)\n const range = { from, to }\n\n return getTextBetween(doc, range, {\n ...(this.options.blockSeparator !== undefined ? { blockSeparator: this.options.blockSeparator } : {}),\n textSerializers,\n })\n },\n },\n }),\n ]\n },\n})\n","import { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport { type ExtendableConfig, Extendable } from \"./Extendable.js\";\n\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface ExtensionConfig<Options = any, Storage = any>\n extends ExtendableConfig<\n Options,\n Storage,\n ExtensionConfig<Options, Storage>,\n null\n > {}\n\nexport class Extension<Options = any, Storage = any> extends Extendable<\n Options,\n Storage,\n ExtensionConfig<Options, Storage>\n> {\n type = \"extension\";\n\n /**\n * Create a new Extension instance\n * @param config - Extension configuration object or a function that returns a configuration object\n */\n static create<O = any, S = any>(\n config:\n | Partial<ExtensionConfig<O, S>>\n | (() => Partial<ExtensionConfig<O, S>>) = {}\n ) {\n // If the config is a function, execute it to get the configuration object\n const resolvedConfig = typeof config === \"function\" ? config() : config;\n return new Extension<O, S>(resolvedConfig);\n }\n\n configure(options?: Partial<Options>) {\n return super.configure(options) as Extension<Options, Storage>;\n }\n\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig = ExtensionConfig<ExtendedOptions, ExtendedStorage>\n >(\n extendedConfig?:\n | (() => Partial<ExtendedConfig>)\n | (Partial<ExtendedConfig> &\n ThisType<{\n name: string;\n options: ExtendedOptions;\n storage: ExtendedStorage;\n editor: Editor;\n type: null;\n }>)\n ): Extension<ExtendedOptions, ExtendedStorage> {\n // If the extended config is a function, execute it to get the configuration object\n const resolvedConfig =\n typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n return super.extend(resolvedConfig) as Extension<\n ExtendedOptions,\n ExtendedStorage\n >;\n }\n}\n","import * as commands from '../commands/index.js'\nimport { Extension } from '../Extension.js'\n\nexport * from '../commands/index.js'\n\nexport const Commands = Extension.create({\n name: 'commands',\n\n addCommands() {\n return {\n ...commands,\n }\n },\n})\n","import { RemoveMarkStep } from '@blockslides/pm/transform'\n\nimport { Extension } from '../Extension.js'\nimport { combineTransactionSteps, getChangedRanges } from '../helpers/index.js'\n\n/**\n * This extension allows you to be notified when the user deletes content you are interested in.\n */\nexport const Delete = Extension.create({\n name: 'delete',\n\n onUpdate({ transaction, appendedTransactions }) {\n const callback = () => {\n if (\n this.editor.options.coreExtensionOptions?.delete?.filterTransaction?.(transaction) ??\n transaction.getMeta('y-sync$')\n ) {\n return\n }\n const nextTransaction = combineTransactionSteps(transaction.before, [transaction, ...appendedTransactions])\n const changes = getChangedRanges(nextTransaction)\n\n changes.forEach(change => {\n if (\n nextTransaction.mapping.mapResult(change.oldRange.from).deletedAfter &&\n nextTransaction.mapping.mapResult(change.oldRange.to).deletedBefore\n ) {\n nextTransaction.before.nodesBetween(change.oldRange.from, change.oldRange.to, (node, from) => {\n const to = from + node.nodeSize - 2\n const isFullyWithinRange = change.oldRange.from <= from && to <= change.oldRange.to\n\n this.editor.emit('delete', {\n type: 'node',\n node,\n from,\n to,\n newFrom: nextTransaction.mapping.map(from),\n newTo: nextTransaction.mapping.map(to),\n deletedRange: change.oldRange,\n newRange: change.newRange,\n partial: !isFullyWithinRange,\n editor: this.editor,\n transaction,\n combinedTransform: nextTransaction,\n })\n })\n }\n })\n\n const mapping = nextTransaction.mapping\n nextTransaction.steps.forEach((step, index) => {\n if (step instanceof RemoveMarkStep) {\n const newStart = mapping.slice(index).map(step.from, -1)\n const newEnd = mapping.slice(index).map(step.to)\n const oldStart = mapping.invert().map(newStart, -1)\n const oldEnd = mapping.invert().map(newEnd)\n\n const foundBeforeMark = nextTransaction.doc.nodeAt(newStart - 1)?.marks.some(mark => mark.eq(step.mark))\n const foundAfterMark = nextTransaction.doc.nodeAt(newEnd)?.marks.some(mark => mark.eq(step.mark))\n\n this.editor.emit('delete', {\n type: 'mark',\n mark: step.mark,\n from: step.from,\n to: step.to,\n deletedRange: {\n from: oldStart,\n to: oldEnd,\n },\n newRange: {\n from: newStart,\n to: newEnd,\n },\n partial: Boolean(foundAfterMark || foundBeforeMark),\n editor: this.editor,\n transaction,\n combinedTransform: nextTransaction,\n })\n }\n })\n }\n\n if (this.editor.options.coreExtensionOptions?.delete?.async ?? true) {\n setTimeout(callback, 0)\n } else {\n callback()\n }\n },\n})\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const Drop = Extension.create({\n name: 'drop',\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('BlockSlidesDrop'),\n\n props: {\n handleDrop: (_, e, slice, moved) => {\n this.editor.emit('drop', {\n editor: this.editor,\n event: e,\n slice,\n moved,\n })\n },\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const Editable = Extension.create({\n name: 'editable',\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('editable'),\n props: {\n editable: () => this.editor.options.editable,\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const focusEventsPluginKey = new PluginKey('focusEvents')\n\nexport const FocusEvents = Extension.create({\n name: 'focusEvents',\n\n addProseMirrorPlugins() {\n const { editor } = this\n\n return [\n new Plugin({\n key: focusEventsPluginKey,\n props: {\n handleDOMEvents: {\n focus: (view, event: Event) => {\n editor.isFocused = true\n\n const transaction = editor.state.tr.setMeta('focus', { event }).setMeta('addToHistory', false)\n\n view.dispatch(transaction)\n\n return false\n },\n blur: (view, event: Event) => {\n editor.isFocused = false\n\n const transaction = editor.state.tr.setMeta('blur', { event }).setMeta('addToHistory', false)\n\n view.dispatch(transaction)\n\n return false\n },\n },\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey, Selection } from '@blockslides/pm/state'\n\nimport { CommandManager } from '../CommandManager.js'\nimport { Extension } from '../Extension.js'\nimport { createChainableState } from '../helpers/createChainableState.js'\nimport { isNodeEmpty } from '../helpers/isNodeEmpty.js'\nimport { isiOS } from '../utilities/isiOS.js'\nimport { isMacOS } from '../utilities/isMacOS.js'\n\nexport const Keymap = Extension.create({\n name: 'keymap',\n\n addKeyboardShortcuts() {\n const handleBackspace = () =>\n this.editor.commands.first(({ commands }) => [\n () => commands.undoInputRule(),\n\n // maybe convert first text block node to default node\n () =>\n commands.command(({ tr }) => {\n const { selection, doc } = tr\n const { empty, $anchor } = selection\n const { pos, parent } = $anchor\n const $parentPos = $anchor.parent.isTextblock && pos > 0 ? tr.doc.resolve(pos - 1) : $anchor\n const parentIsIsolating = $parentPos.parent.type.spec.isolating\n\n const parentPos = $anchor.pos - $anchor.parentOffset\n\n const isAtStart =\n parentIsIsolating && $parentPos.parent.childCount === 1\n ? parentPos === $anchor.pos\n : Selection.atStart(doc).from === pos\n\n if (\n !empty ||\n !parent.type.isTextblock ||\n parent.textContent.length ||\n !isAtStart ||\n (isAtStart && $anchor.parent.type.name === 'paragraph') // prevent clearNodes when no nodes to clear, otherwise history stack is appended\n ) {\n return false\n }\n\n return commands.clearNodes()\n }),\n\n () => commands.deleteSelection(),\n () => commands.joinBackward(),\n () => commands.selectNodeBackward(),\n ])\n\n const handleDelete = () =>\n this.editor.commands.first(({ commands }) => [\n () => commands.deleteSelection(),\n () => commands.deleteCurrentNode(),\n () => commands.joinForward(),\n () => commands.selectNodeForward(),\n ])\n\n const handleEnter = () =>\n this.editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ])\n\n const baseKeymap = {\n Enter: handleEnter,\n 'Mod-Enter': () => this.editor.commands.exitCode(),\n Backspace: handleBackspace,\n 'Mod-Backspace': handleBackspace,\n 'Shift-Backspace': handleBackspace,\n Delete: handleDelete,\n 'Mod-Delete': handleDelete,\n 'Mod-a': () => this.editor.commands.selectAll(),\n }\n\n const pcKeymap = {\n ...baseKeymap,\n }\n\n const macKeymap = {\n ...baseKeymap,\n 'Ctrl-h': handleBackspace,\n 'Alt-Backspace': handleBackspace,\n 'Ctrl-d': handleDelete,\n 'Ctrl-Alt-Backspace': handleDelete,\n 'Alt-Delete': handleDelete,\n 'Alt-d': handleDelete,\n 'Ctrl-a': () => this.editor.commands.selectTextblockStart(),\n 'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),\n }\n\n if (isiOS() || isMacOS()) {\n return macKeymap\n }\n\n return pcKeymap\n },\n\n addProseMirrorPlugins() {\n return [\n // With this plugin we check if the whole document was selected and deleted.\n // In this case we will additionally call `clearNodes()` to convert e.g. a heading\n // to a paragraph if necessary.\n // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well\n // with many other commands.\n new Plugin({\n key: new PluginKey('clearDocument'),\n appendTransaction: (transactions, oldState, newState) => {\n if (transactions.some(tr => tr.getMeta('composition'))) {\n return\n }\n\n const docChanges = transactions.some(transaction => transaction.docChanged) && !oldState.doc.eq(newState.doc)\n\n const ignoreTr = transactions.some(transaction => transaction.getMeta('preventClearDocument'))\n\n if (!docChanges || ignoreTr) {\n return\n }\n\n const { empty, from, to } = oldState.selection\n const allFrom = Selection.atStart(oldState.doc).from\n const allEnd = Selection.atEnd(oldState.doc).to\n const allWasSelected = from === allFrom && to === allEnd\n\n if (empty || !allWasSelected) {\n return\n }\n\n const isEmpty = isNodeEmpty(newState.doc)\n\n if (!isEmpty) {\n return\n }\n\n const tr = newState.tr\n const state = createChainableState({\n state: newState,\n transaction: tr,\n })\n const { commands } = new CommandManager({\n editor: this.editor,\n state,\n })\n\n commands.clearNodes()\n\n if (!tr.steps.length) {\n return\n }\n\n return tr\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const Paste = Extension.create({\n name: 'paste',\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('BlockSlidesPaste'),\n\n props: {\n handlePaste: (_view, e, slice) => {\n this.editor.emit('paste', {\n editor: this.editor,\n event: e,\n slice,\n })\n },\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey } from '@blockslides/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const Tabindex = Extension.create({\n name: 'tabindex',\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('tabindex'),\n props: {\n attributes: (): { [name: string]: string } => (this.editor.isEditable ? { tabindex: '0' } : {}),\n },\n }),\n ]\n },\n})\n","import type { Fragment, Node, ResolvedPos } from \"@blockslides/pm/model\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport type { Content, Range } from \"./types.js\";\n\nexport class NodePos {\n private resolvedPos: ResolvedPos;\n\n private isBlock: boolean;\n\n private editor: Editor;\n\n private get name(): string {\n return this.node.type.name;\n }\n\n constructor(\n pos: ResolvedPos,\n editor: Editor,\n isBlock = false,\n node: Node | null = null\n ) {\n this.isBlock = isBlock;\n this.resolvedPos = pos;\n this.editor = editor;\n this.currentNode = node;\n }\n\n private currentNode: Node | null = null;\n\n get node(): Node {\n return this.currentNode || this.resolvedPos.node();\n }\n\n get element(): HTMLElement {\n return this.editor.view.domAtPos(this.pos).node as HTMLElement;\n }\n\n public actualDepth: number | null = null;\n\n get depth(): number {\n return this.actualDepth ?? this.resolvedPos.depth;\n }\n\n get pos(): number {\n return this.resolvedPos.pos;\n }\n\n get content(): Fragment {\n return this.node.content;\n }\n\n set content(content: Content) {\n let from = this.from;\n let to = this.to;\n\n if (this.isBlock) {\n if (this.content.size === 0) {\n console.error(\n `You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`\n );\n return;\n }\n\n from = this.from + 1;\n to = this.to - 1;\n }\n\n this.editor.commands.insertContentAt({ from, to }, content);\n }\n\n get attributes(): { [key: string]: any } {\n return this.node.attrs;\n }\n\n get textContent(): string {\n return this.node.textContent;\n }\n\n get size(): number {\n return this.node.nodeSize;\n }\n\n get from(): number {\n if (this.isBlock) {\n return this.pos;\n }\n\n return this.resolvedPos.start(this.resolvedPos.depth);\n }\n\n get range(): Range {\n return {\n from: this.from,\n to: this.to,\n };\n }\n\n get to(): number {\n if (this.isBlock) {\n return this.pos + this.size;\n }\n\n return (\n this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1)\n );\n }\n\n get parent(): NodePos | null {\n if (this.depth === 0) {\n return null;\n }\n\n const parentPos = this.resolvedPos.start(this.resolvedPos.depth - 1);\n const $pos = this.resolvedPos.doc.resolve(parentPos);\n\n return new NodePos($pos, this.editor);\n }\n\n get before(): NodePos | null {\n let $pos = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));\n\n if ($pos.depth !== this.depth) {\n $pos = this.resolvedPos.doc.resolve(this.from - 3);\n }\n\n return new NodePos($pos, this.editor);\n }\n\n get after(): NodePos | null {\n let $pos = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));\n\n if ($pos.depth !== this.depth) {\n $pos = this.resolvedPos.doc.resolve(this.to + 3);\n }\n\n return new NodePos($pos, this.editor);\n }\n\n get children(): NodePos[] {\n const children: NodePos[] = [];\n\n this.node.content.forEach((node, offset) => {\n const isBlock = node.isBlock && !node.isTextblock;\n const isNonTextAtom = node.isAtom && !node.isText;\n\n const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);\n\n // Check if targetPos is within valid document range\n if (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) {\n return;\n }\n\n const $pos = this.resolvedPos.doc.resolve(targetPos);\n\n if (!isBlock && $pos.depth <= this.depth) {\n return;\n }\n\n const childNodePos = new NodePos(\n $pos,\n this.editor,\n isBlock,\n isBlock ? node : null\n );\n\n if (isBlock) {\n childNodePos.actualDepth = this.depth + 1;\n }\n\n children.push(\n new NodePos($pos, this.editor, isBlock, isBlock ? node : null)\n );\n });\n\n return children;\n }\n\n get firstChild(): NodePos | null {\n return this.children[0] || null;\n }\n\n get lastChild(): NodePos | null {\n const children = this.children;\n\n return children[children.length - 1] || null;\n }\n\n closest(\n selector: string,\n attributes: { [key: string]: any } = {}\n ): NodePos | null {\n let node: NodePos | null = null;\n let currentNode = this.parent;\n\n while (currentNode && !node) {\n if (currentNode.node.type.name === selector) {\n if (Object.keys(attributes).length > 0) {\n const nodeAttributes = currentNode.node.attrs;\n const attrKeys = Object.keys(attributes);\n\n for (let index = 0; index < attrKeys.length; index += 1) {\n const key = attrKeys[index];\n\n if (nodeAttributes[key] !== attributes[key]) {\n break;\n }\n }\n } else {\n node = currentNode;\n }\n }\n\n currentNode = currentNode.parent;\n }\n\n return node;\n }\n\n querySelector(\n selector: string,\n attributes: { [key: string]: any } = {}\n ): NodePos | null {\n return this.querySelectorAll(selector, attributes, true)[0] || null;\n }\n\n querySelectorAll(\n selector: string,\n attributes: { [key: string]: any } = {},\n firstItemOnly = false\n ): NodePos[] {\n let nodes: NodePos[] = [];\n\n if (!this.children || this.children.length === 0) {\n return nodes;\n }\n const attrKeys = Object.keys(attributes);\n\n /**\n * Finds all children recursively that match the selector and attributes\n * If firstItemOnly is true, it will return the first item found\n */\n this.children.forEach((childPos) => {\n // If we already found a node and we only want the first item, we dont need to keep going\n if (firstItemOnly && nodes.length > 0) {\n return;\n }\n\n if (childPos.node.type.name === selector) {\n const doesAllAttributesMatch = attrKeys.every(\n (key) => attributes[key] === childPos.node.attrs[key]\n );\n\n if (doesAllAttributesMatch) {\n nodes.push(childPos);\n }\n }\n\n // If we already found a node and we only want the first item, we can stop here and skip the recursion\n if (firstItemOnly && nodes.length > 0) {\n return;\n }\n\n nodes = nodes.concat(\n childPos.querySelectorAll(selector, attributes, firstItemOnly)\n );\n });\n\n return nodes;\n }\n\n setAttribute(attributes: { [key: string]: any }) {\n const { tr } = this.editor.state;\n\n tr.setNodeMarkup(this.from, undefined, {\n ...this.node.attrs,\n ...attributes,\n });\n\n this.editor.view.dispatch(tr);\n }\n}\n","export const style = `.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.blockslides-editor {\n background-color: var(--editor-bg, transparent);\n color: var(--editor-fg, #1a1a1a);\n}\n\n.blockslides-editor .ProseMirror ::selection {\n background-color: var(--editor-selection-bg, rgba(59, 130, 246, 0.1));\n}\n\n.blockslides-editor .ProseMirror-selectednode {\n outline: 2px solid var(--editor-selection, #3b82f6);\n}\n\n.blockslides-editor:focus-within {\n outline: none;\n}\n`;\n","import type { Theme } from \"./types.js\";\n\nexport const lightTheme: Theme = {\n name: \"light\",\n\n // Editor styling\n editor: {\n background: \"transparent\", // See-through canvas\n foreground: \"#1a1a1a\", // Text color\n border: \"#e5e5e5\", // Editor border (if any)\n },\n\n // Slide styling\n slide: {\n background: \"#ffffff\", // White cards\n border: \"#e5e5e5\", // Card border\n borderRadius: \"12px\", // Rounded corners\n shadow: \"0 4px 12px rgba(0, 0, 0, 0.08)\", // Drop shadow\n marginBottom: \"32px\", // Space between slides\n padding: \"48px\", // Inner padding\n },\n\n // Shared/general styling\n selection: \"#3b82f6\", // Blue highlight\n selectionBg: \"rgba(59, 130, 246, 0.1)\", // Light blue background\n hover: \"#f0f0f0\", // Hover state\n active: \"#e8e8e8\", // Active state\n focus: \"#3b82f6\", // Focus outline\n};\n","import type { Theme } from \"./types.js\";\n\nexport const darkTheme: Theme = {\n name: \"dark\",\n\n // Editor styling\n editor: {\n background: \"transparent\", // See-through canvas\n foreground: \"#ffffff\", // White text\n border: \"#3e3e3e\", // Dark border\n },\n\n // Slide styling\n slide: {\n background: \"#1e1e1e\", // Dark gray cards\n border: \"#3e3e3e\", // Subtle border\n borderRadius: \"12px\", // Rounded corners\n shadow: \"0 4px 12px rgba(0, 0, 0, 0.4)\", // Stronger shadow for dark\n marginBottom: \"32px\", // Space between slides\n padding: \"48px\", // Inner padding\n },\n\n // Shared/general styling\n selection: \"#3b82f6\", // Blue highlight\n selectionBg: \"rgba(59, 130, 246, 0.2)\", // Slightly more visible on dark\n hover: \"#2d2d2d\", // Hover state\n active: \"#3d3d3d\", // Active state\n focus: \"#3b82f6\", // Focus outline\n};\n","import { lightTheme } from \"./light.js\";\nimport { darkTheme } from \"./dark.js\";\nimport type { Theme, ThemeInput, ThemeConfig, ResolvedTheme } from \"./types.js\";\n\n/**\n * Built-in themes registry\n */\nconst BUILT_IN_THEMES: Record<string, Theme> = {\n light: lightTheme,\n dark: darkTheme,\n};\n\n/**\n * Deep merge two objects, preferring values from source\n */\nfunction deepMerge<T extends object>(target: T, source: Partial<T>): T {\n const result = { ...target };\n\n for (const key in source) {\n if (\n source[key] &&\n typeof source[key] === \"object\" &&\n !Array.isArray(source[key])\n ) {\n result[key] = deepMerge(result[key] as any, source[key] as any);\n } else if (source[key] !== undefined) {\n result[key] = source[key] as any;\n }\n }\n\n return result;\n}\n\n/**\n * Check if theme object is a partial theme (missing required properties)\n */\nfunction isPartialTheme(theme: any): boolean {\n // Check if editor properties are complete\n if (\n !theme.editor ||\n !theme.editor.background ||\n !theme.editor.foreground ||\n !theme.editor.border\n ) {\n return true;\n }\n\n // Check if slide properties are complete\n if (\n !theme.slide ||\n !theme.slide.background ||\n !theme.slide.border ||\n !theme.slide.borderRadius ||\n !theme.slide.shadow ||\n !theme.slide.marginBottom ||\n !theme.slide.padding\n ) {\n return true;\n }\n\n // Check if shared properties are complete\n if (\n !theme.selection ||\n !theme.selectionBg ||\n !theme.hover ||\n !theme.active ||\n !theme.focus\n ) {\n return true;\n }\n\n return false;\n}\n\n/**\n * Resolve theme from various input formats\n *\n * Handles:\n * - String references to built-in themes ('light', 'dark')\n * - Full custom theme objects\n * - Partial themes that extend built-in themes\n * - Undefined/invalid (returns null - no theme applied)\n *\n * @param themeInput - Theme configuration\n * @returns Resolved complete theme or null if no theme should be applied\n */\nexport function resolveTheme(themeInput: ThemeInput): ResolvedTheme {\n // No theme provided - don't apply any theme\n if (!themeInput) {\n return null;\n }\n\n // String reference to built-in theme\n if (typeof themeInput === \"string\") {\n const builtIn = BUILT_IN_THEMES[themeInput];\n if (!builtIn) {\n console.warn(\n `[BlockSlides] Theme \"${themeInput}\" not found. No theme will be applied.`\n );\n return null;\n }\n return builtIn;\n }\n\n // Full custom theme (has all required properties)\n if (\n \"editor\" in themeInput &&\n \"slide\" in themeInput &&\n !isPartialTheme(themeInput)\n ) {\n return themeInput as Theme;\n }\n\n // Partial theme - merge with base theme\n const config = themeInput as ThemeConfig;\n const baseThemeName = config.extends || \"light\";\n const baseTheme = BUILT_IN_THEMES[baseThemeName];\n\n if (!baseTheme) {\n console.warn(\n `[BlockSlides] Base theme \"${baseThemeName}\" not found. No theme will be applied.`\n );\n return null;\n }\n\n return deepMerge(baseTheme, themeInput as Partial<Theme>);\n}\n\n/**\n * Apply theme to DOM element using CSS custom properties\n *\n * Sets CSS variables on the element that can be used by stylesheets.\n * Also sets a data-theme attribute for additional CSS targeting.\n * If theme is null, removes all theme-related attributes and CSS variables.\n *\n * @param theme - Resolved theme to apply (or null to remove theme)\n * @param element - DOM element to apply theme to\n */\nexport function applyTheme(theme: ResolvedTheme, element: HTMLElement): void {\n // No theme - remove theme attributes and CSS variables\n if (!theme) {\n element.removeAttribute(\"data-theme\");\n element.style.removeProperty(\"--editor-bg\");\n element.style.removeProperty(\"--editor-fg\");\n element.style.removeProperty(\"--editor-border\");\n element.style.removeProperty(\"--editor-selection\");\n element.style.removeProperty(\"--editor-selection-bg\");\n element.style.removeProperty(\"--editor-hover\");\n element.style.removeProperty(\"--editor-active\");\n element.style.removeProperty(\"--editor-focus\");\n element.style.removeProperty(\"--slide-bg\");\n element.style.removeProperty(\"--slide-border\");\n element.style.removeProperty(\"--slide-border-radius\");\n element.style.removeProperty(\"--slide-shadow\");\n element.style.removeProperty(\"--slide-margin-bottom\");\n element.style.removeProperty(\"--slide-padding\");\n element.style.removeProperty(\"--slide-min-height\");\n return;\n }\n\n // Set data-theme attribute for CSS selectors\n element.setAttribute(\"data-theme\", theme.name);\n\n // Apply CSS variables\n const { editor, slide } = theme;\n\n // Editor properties\n element.style.setProperty(\"--editor-bg\", editor.background);\n element.style.setProperty(\"--editor-fg\", editor.foreground);\n element.style.setProperty(\"--editor-border\", editor.border);\n\n // Shared/general properties\n element.style.setProperty(\"--editor-selection\", theme.selection);\n element.style.setProperty(\"--editor-selection-bg\", theme.selectionBg);\n element.style.setProperty(\"--editor-hover\", theme.hover);\n element.style.setProperty(\"--editor-active\", theme.active);\n element.style.setProperty(\"--editor-focus\", theme.focus);\n\n // Slide properties\n element.style.setProperty(\"--slide-bg\", slide.background);\n element.style.setProperty(\"--slide-border\", slide.border);\n element.style.setProperty(\"--slide-border-radius\", slide.borderRadius);\n element.style.setProperty(\"--slide-shadow\", slide.shadow);\n element.style.setProperty(\"--slide-margin-bottom\", slide.marginBottom);\n element.style.setProperty(\"--slide-padding\", slide.padding);\n if (slide.minHeight) {\n element.style.setProperty(\"--slide-min-height\", slide.minHeight);\n }\n}\n\n/**\n * Register a custom theme globally\n *\n * Allows registering custom themes that can be referenced by string name\n *\n * @param theme - Theme to register\n */\nexport function registerTheme(theme: Theme): void {\n BUILT_IN_THEMES[theme.name] = theme;\n}\n\n/**\n * Get all registered theme names\n *\n * @returns Array of theme names\n */\nexport function getThemeNames(): string[] {\n return Object.keys(BUILT_IN_THEMES);\n}\n\n/**\n * Get a theme by name\n *\n * @param name - Theme name\n * @returns Theme if found, undefined otherwise\n */\nexport function getTheme(name: string): Theme | undefined {\n return BUILT_IN_THEMES[name];\n}\n","export function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement {\n const tiptapStyleTag = <HTMLStyleElement>(\n document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ''}]`)\n )\n\n if (tiptapStyleTag !== null) {\n return tiptapStyleTag\n }\n\n const styleNode = document.createElement('style')\n\n if (nonce) {\n styleNode.setAttribute('nonce', nonce)\n }\n\n styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ''}`, '')\n styleNode.innerHTML = style\n document.getElementsByTagName('head')[0].appendChild(styleNode)\n\n return styleNode\n}\n","import type { MarkType } from '@blockslides/pm/model'\n\nimport { getMarksBetween } from '../helpers/getMarksBetween.js'\nimport type { InputRuleFinder } from '../InputRule.js'\nimport { InputRule } from '../InputRule.js'\nimport type { ExtendedRegExpMatchArray } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\n\n/**\n * Build an input rule that adds a mark when the\n * matched text is typed into it.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n */\nexport function markInputRule(config: {\n find: InputRuleFinder\n type: MarkType\n undoable?: boolean\n getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null\n}) {\n return new InputRule({\n find: config.find,\n handler: ({ state, range, match }) => {\n const attributes = callOrReturn(config.getAttributes, undefined, match)\n\n if (attributes === false || attributes === null) {\n return null\n }\n\n const { tr } = state\n const captureGroup = match[match.length - 1]\n const fullMatch = match[0]\n\n if (captureGroup) {\n const startSpaces = fullMatch.search(/\\S/)\n const textStart = range.from + fullMatch.indexOf(captureGroup)\n const textEnd = textStart + captureGroup.length\n\n const excludedMarks = getMarksBetween(range.from, range.to, state.doc)\n .filter(item => {\n // @ts-ignore\n const excluded = item.mark.type.excluded as MarkType[]\n\n return excluded.find(type => type === config.type && type !== item.mark.type)\n })\n .filter(item => item.to > textStart)\n\n if (excludedMarks.length) {\n return null\n }\n\n if (textEnd < range.to) {\n tr.delete(textEnd, range.to)\n }\n\n if (textStart > range.from) {\n tr.delete(range.from + startSpaces, textStart)\n }\n\n const markEnd = range.from + startSpaces + captureGroup.length\n\n tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}))\n\n tr.removeStoredMark(config.type)\n }\n },\n undoable: config.undoable,\n })\n}\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport type { InputRuleFinder } from '../InputRule.js'\nimport { InputRule } from '../InputRule.js'\nimport type { ExtendedRegExpMatchArray } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\n\n/**\n * Build an input rule that adds a node when the\n * matched text is typed into it.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n */\nexport function nodeInputRule(config: {\n /**\n * The regex to match.\n */\n find: InputRuleFinder\n\n /**\n * The node type to add.\n */\n type: NodeType\n\n /**\n * Whether the input rule should be undoable\n * when the user presses backspace.\n */\n undoable?: boolean\n\n /**\n * A function that returns the attributes for the node\n * can also be an object of attributes\n */\n getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null\n}) {\n return new InputRule({\n find: config.find,\n handler: ({ state, range, match }) => {\n const attributes = callOrReturn(config.getAttributes, undefined, match) || {}\n const { tr } = state\n const start = range.from\n let end = range.to\n\n const newNode = config.type.create(attributes)\n\n if (match[1]) {\n const offset = match[0].lastIndexOf(match[1])\n let matchStart = start + offset\n\n if (matchStart > end) {\n matchStart = end\n } else {\n end = matchStart + match[1].length\n }\n\n // insert last typed character\n const lastChar = match[0][match[0].length - 1]\n\n tr.insertText(lastChar, start + match[0].length - 1)\n\n // insert node from input rule\n tr.replaceWith(matchStart, end, newNode)\n } else if (match[0]) {\n const insertionStart = config.type.isInline ? start : start - 1\n\n tr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end))\n }\n\n tr.scrollIntoView()\n },\n undoable: config.undoable,\n })\n}\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport type { InputRuleFinder } from '../InputRule.js'\nimport { InputRule } from '../InputRule.js'\nimport type { ExtendedRegExpMatchArray } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\n\n/**\n * Build an input rule that changes the type of a textblock when the\n * matched text is typed into it. When using a regular expresion you’ll\n * probably want the regexp to start with `^`, so that the pattern can\n * only occur at the start of a textblock.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n */\nexport function textblockTypeInputRule(config: {\n find: InputRuleFinder\n type: NodeType\n undoable?: boolean\n getAttributes?: Record<string, any> | ((match: ExtendedRegExpMatchArray) => Record<string, any>) | false | null\n}) {\n return new InputRule({\n find: config.find,\n handler: ({ state, range, match }) => {\n const $start = state.doc.resolve(range.from)\n const attributes = callOrReturn(config.getAttributes, undefined, match) || {}\n\n if (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) {\n return null\n }\n\n state.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes)\n },\n undoable: config.undoable,\n })\n}\n","import type { InputRuleFinder } from '../InputRule.js'\nimport { InputRule } from '../InputRule.js'\n\n/**\n * Build an input rule that replaces text when the\n * matched text is typed into it.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n */\nexport function textInputRule(config: { find: InputRuleFinder; replace: string; undoable?: boolean }) {\n return new InputRule({\n find: config.find,\n handler: ({ state, range, match }) => {\n let insert = config.replace\n let start = range.from\n const end = range.to\n\n if (match[1]) {\n const offset = match[0].lastIndexOf(match[1])\n\n insert += match[0].slice(offset + match[1].length)\n start += offset\n\n const cutOff = start - end\n\n if (cutOff > 0) {\n insert = match[0].slice(offset - cutOff, offset) + insert\n start = end\n }\n }\n\n state.tr.insertText(insert, start, end)\n },\n undoable: config.undoable,\n })\n}\n","import type {\n Node as ProseMirrorNode,\n NodeType,\n} from \"@blockslides/pm/model\";\nimport { canJoin, findWrapping } from \"@blockslides/pm/transform\";\n\nimport type { SlideEditor as Editor } from \"../SlideEditor.js\";\nimport type { InputRuleFinder } from \"../InputRule.js\";\nimport { InputRule } from \"../InputRule.js\";\nimport type { ExtendedRegExpMatchArray } from \"../types.js\";\nimport { callOrReturn } from \"../utilities/callOrReturn.js\";\n\n/**\n * Build an input rule for automatically wrapping a textblock when a\n * given string is typed. When using a regular expresion you’ll\n * probably want the regexp to start with `^`, so that the pattern can\n * only occur at the start of a textblock.\n *\n * `type` is the type of node to wrap in.\n *\n * By default, if there’s a node with the same type above the newly\n * wrapped node, the rule will try to join those\n * two nodes. You can pass a join predicate, which takes a regular\n * expression match and the node before the wrapped node, and can\n * return a boolean to indicate whether a join should happen.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n */\nexport function wrappingInputRule(config: {\n find: InputRuleFinder;\n type: NodeType;\n keepMarks?: boolean;\n keepAttributes?: boolean;\n editor?: Editor;\n undoable?: boolean;\n getAttributes?:\n | Record<string, any>\n | ((match: ExtendedRegExpMatchArray) => Record<string, any>)\n | false\n | null;\n joinPredicate?: (\n match: ExtendedRegExpMatchArray,\n node: ProseMirrorNode\n ) => boolean;\n}) {\n return new InputRule({\n find: config.find,\n handler: ({ state, range, match, chain }) => {\n const attributes =\n callOrReturn(config.getAttributes, undefined, match) || {};\n const tr = state.tr.delete(range.from, range.to);\n const $start = tr.doc.resolve(range.from);\n const blockRange = $start.blockRange();\n const wrapping =\n blockRange && findWrapping(blockRange, config.type, attributes);\n\n if (!wrapping) {\n return null;\n }\n\n tr.wrap(blockRange, wrapping);\n\n if (config.keepMarks && config.editor) {\n const { selection, storedMarks } = state;\n const { splittableMarks } = config.editor.extensionManager;\n const marks =\n storedMarks ||\n (selection.$to.parentOffset && selection.$from.marks());\n\n if (marks) {\n const filteredMarks = marks.filter((mark) =>\n splittableMarks.includes(mark.type.name)\n );\n\n tr.ensureMarks(filteredMarks);\n }\n }\n if (config.keepAttributes) {\n /** If the nodeType is `bulletList` or `orderedList` set the `nodeType` as `listItem` */\n const nodeType =\n config.type.name === \"bulletList\" ||\n config.type.name === \"orderedList\"\n ? \"listItem\"\n : \"taskList\";\n\n chain().updateAttributes(nodeType, attributes).run();\n }\n\n const before = tr.doc.resolve(range.from - 1).nodeBefore;\n\n if (\n before &&\n before.type === config.type &&\n canJoin(tr.doc, range.from - 1) &&\n (!config.joinPredicate || config.joinPredicate(match, before))\n ) {\n tr.join(range.from - 1);\n }\n },\n undoable: config.undoable,\n });\n}\n","export type Attributes = Record<string, any>\n\nexport type DOMOutputSpecElement = 0 | Attributes | DOMOutputSpecArray\n/**\n * Better describes the output of a `renderHTML` function in prosemirror\n * @see https://prosemirror.net/docs/ref/#model.DOMOutputSpec\n */\nexport type DOMOutputSpecArray =\n | [string]\n | [string, Attributes]\n | [string, 0]\n | [string, Attributes, 0]\n | [string, Attributes, DOMOutputSpecArray | 0]\n | [string, DOMOutputSpecArray]\n\n// JSX types for AA's JSX runtime\n// These types only apply when using @jsxImportSource @blockslides/core\n// eslint-disable-next-line @typescript-eslint/no-namespace\nexport namespace JSX {\n export type Element = DOMOutputSpecArray\n export interface IntrinsicElements {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: any\n }\n export interface ElementChildrenAttribute {\n children: unknown\n }\n}\n\nexport type JSXRenderer = (\n tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement),\n props?: Attributes,\n ...children: JSXRenderer[]\n) => DOMOutputSpecArray | DOMOutputSpecElement\n\nexport function Fragment(props: { children: JSXRenderer[] }) {\n return props.children\n}\n\nexport const h: JSXRenderer = (tag, attributes) => {\n // Treat the slot tag as the Prosemirror hole to render content into\n if (tag === 'slot') {\n return 0\n }\n\n // If the tag is a function, call it with the props\n if (tag instanceof Function) {\n return tag(attributes)\n }\n\n const { children, ...rest } = attributes ?? {}\n\n if (tag === 'svg') {\n throw new Error('SVG elements are not supported in the JSX syntax, use the array syntax instead')\n }\n\n // Otherwise, return the tag, attributes, and children\n return [tag, rest, children]\n}\n\n// See\n// https://esbuild.github.io/api/#jsx-import-source\n// https://www.typescriptlang.org/tsconfig/#jsxImportSource\n\nexport { h as createElement, h as jsx, h as jsxDEV, h as jsxs }\n","import type { NodeType } from '@blockslides/pm/model'\nimport { type EditorState, NodeSelection } from '@blockslides/pm/state'\n\nexport function canInsertNode(state: EditorState, nodeType: NodeType): boolean {\n const { selection } = state\n const { $from } = selection\n\n // Special handling for NodeSelection\n if (selection instanceof NodeSelection) {\n const index = $from.index()\n const parent = $from.parent\n\n // Can we replace the selected node with the horizontal rule?\n return parent.canReplaceWith(index, index + 1, nodeType)\n }\n\n // Default: check if we can insert at the current position\n let depth = $from.depth\n\n while (depth >= 0) {\n const index = $from.index(depth)\n const parent = $from.node(depth)\n const match = parent.contentMatchAt(index)\n if (match.matchType(nodeType)) {\n return true\n }\n depth -= 1\n }\n return false\n}\n","// source: https://stackoverflow.com/a/6969486\nexport function escapeForRegEx(string: string): string {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&')\n}\n","export function isString(value: any): value is string {\n return typeof value === 'string'\n}\n","/**\n * Layout Parser Utility\n *\n * Parses layout strings like '2-1' or '1-1-1' and applies flex ratios to columns.\n * Handles validation and provides graceful fallback to equal distribution.\n *\n * Examples:\n * - '1' → single column at 100%\n * - '1-1' → two equal columns (50/50)\n * - '2-1' → two columns (66.66% / 33.33%)\n * - '1-2-1' → three columns (25% / 50% / 25%)\n * - '5-3-2' → three columns (50% / 30% / 20%)\n */\n\n/**\n * Parses a layout string and returns flex ratios for each column\n *\n * @param layout - Layout string (e.g., '2-1', '1-1-1')\n * @param columnCount - Number of columns in the row\n * @returns Array of flex ratio numbers\n *\n * @example\n * parseLayout('2-1', 2) // Returns [2, 1]\n * parseLayout('1-1-1', 3) // Returns [1, 1, 1]\n * parseLayout('invalid', 2) // Returns [1, 1] with console warning\n */\nexport function parseLayout(layout: string, columnCount: number): number[] {\n // Empty or 'auto' layout = equal distribution\n if (!layout || layout === \"auto\") {\n return new Array(columnCount).fill(1);\n }\n\n // Validate format: must be numbers separated by dashes\n // Valid: '1-2', '1-1-1', '5-3-2'\n // Invalid: 'abc', '1--2', '1-2-', '-1-2'\n const layoutRegex = /^\\d+(-\\d+)*$/;\n if (!layoutRegex.test(layout)) {\n console.warn(\n `[BlockSlides] Invalid layout format '${layout}'. ` +\n `Expected format: numbers separated by dashes (e.g., '2-1', '1-1-1'). ` +\n `Using equal distribution.`\n );\n return new Array(columnCount).fill(1);\n }\n\n // Parse the layout string into numbers\n const ratios = layout.split(\"-\").map(Number);\n\n // Validate column count matches\n if (ratios.length !== columnCount) {\n console.warn(\n `[BlockSlides] Layout '${layout}' expects ${ratios.length} column(s) ` +\n `but found ${columnCount} column(s) in the row. ` +\n `Using equal distribution.`\n );\n return new Array(columnCount).fill(1);\n }\n\n return ratios;\n}\n\n/**\n * Applies layout ratios to a row's columns by setting flex values\n *\n * @param rowElement - The DOM element for the row\n * @param layout - Layout string (e.g., '2-1')\n *\n * @example\n * const row = document.querySelector('[data-node-type=\"row\"]');\n * applyLayoutToRow(row, '2-1');\n * // First column will have flex: 2 1 0%\n * // Second column will have flex: 1 1 0%\n */\nexport function applyLayoutToRow(\n rowElement: HTMLElement,\n layout: string\n): void {\n // Get all column children\n const columns = Array.from(rowElement.children).filter(\n (el) => el.getAttribute('data-node-type') === 'column'\n ) as HTMLElement[];\n\n if (columns.length === 0) {\n return; // No columns to apply layout to\n }\n\n // Parse the layout\n const ratios = parseLayout(layout, columns.length);\n\n // Apply flex values to each column as inline styles\n // Note: CSS also handles common layouts, but inline styles provide\n // a fallback for custom/dynamic layouts\n columns.forEach((column, index) => {\n const ratio = ratios[index];\n column.style.flex = `${ratio} 1 0%`;\n column.style.flexGrow = `${ratio}`;\n column.style.flexShrink = '1';\n column.style.flexBasis = '0%';\n });\n}\n\n/**\n * Applies layouts to all rows in the editor\n * Should be called after editor mount and after content updates\n *\n * @param editorElement - The root editor DOM element\n */\nexport function applyAllLayouts(editorElement: HTMLElement): void {\n // Find all row elements\n const rows = editorElement.querySelectorAll(\n '[data-node-type=\"row\"]'\n ) as NodeListOf<HTMLElement>;\n\n rows.forEach((row) => {\n const layout = row.getAttribute(\"data-layout\");\n\n // Only apply if layout is specified and not 'auto'\n // Note: CSS handles most common layouts, but this provides\n // support for custom/dynamic layouts\n if (layout && layout !== \"auto\") {\n applyLayoutToRow(row, layout);\n }\n // If no layout or 'auto', columns will use default flex: 1 from CSS\n });\n}\n","/**\n * @fileoverview Markdown utilities for creating standardized markdown specs.\n *\n * This module provides utilities for creating complete markdown specifications\n * for different types of nodes using unified syntax patterns.\n */\n\nexport * from './attributeUtils.js'\nexport * from './createAtomBlockMarkdownSpec.js'\nexport * from './createBlockMarkdownSpec.js'\nexport * from './createInlineMarkdownSpec.js'\nexport * from './parseIndentedBlocks.js'\nexport * from './renderNestedMarkdownContent.js'\n","/**\n * @fileoverview Utility functions for parsing and serializing markdown attributes.\n *\n * These utilities handle the common patterns for parsing attribute strings\n * in various markdown syntaxes like Pandoc attributes.\n */\n\n/**\n * Parses a Pandoc-style attribute string into an object.\n *\n * Supports the following patterns:\n * - Classes: `.className` → `{ class: 'className' }`\n * - IDs: `#myId` → `{ id: 'myId' }`\n * - Key-value pairs: `key=\"value\"` → `{ key: 'value' }`\n * - Boolean attributes: `disabled` → `{ disabled: true }`\n *\n * @param attrString - The attribute string to parse\n * @returns Parsed attributes object\n *\n * @example\n * ```ts\n * parseAttributes('.btn #submit disabled type=\"button\"')\n * // → { class: 'btn', id: 'submit', disabled: true, type: 'button' }\n * ```\n */\nexport function parseAttributes(attrString: string): Record<string, any> {\n if (!attrString?.trim()) {\n return {}\n }\n\n const attributes: Record<string, any> = {}\n\n // First, extract and remove quoted strings to avoid parsing content inside them\n const quotedStrings: string[] = []\n const tempString = attrString.replace(/[\"']([^\"']*)[\"']/g, match => {\n quotedStrings.push(match)\n return `__QUOTED_${quotedStrings.length - 1}__`\n })\n\n // Parse classes (.className) - only outside of quoted strings\n const classMatches = tempString.match(/(?:^|\\s)\\.([a-zA-Z][\\w-]*)/g)\n if (classMatches) {\n const classes = classMatches.map(match => match.trim().slice(1)) // Remove the dot\n attributes.class = classes.join(' ')\n }\n\n // Parse IDs (#myId) - only outside of quoted strings\n const idMatch = tempString.match(/(?:^|\\s)#([a-zA-Z][\\w-]*)/)\n if (idMatch) {\n attributes.id = idMatch[1]\n }\n\n // Parse key-value pairs (key=\"value\" or key='value') - restore quoted strings\n const kvRegex = /([a-zA-Z][\\w-]*)\\s*=\\s*(__QUOTED_\\d+__)/g\n const kvMatches = Array.from(tempString.matchAll(kvRegex))\n kvMatches.forEach(([, key, quotedRef]) => {\n const quotedIndex = parseInt(quotedRef.match(/__QUOTED_(\\d+)__/)?.[1] || '0', 10)\n const quotedValue = quotedStrings[quotedIndex]\n if (quotedValue) {\n // Remove the outer quotes\n attributes[key] = quotedValue.slice(1, -1)\n }\n })\n\n // Parse boolean attributes (standalone words that aren't classes/IDs)\n const cleanString = tempString\n .replace(/(?:^|\\s)\\.([a-zA-Z][\\w-]*)/g, '') // Remove classes\n .replace(/(?:^|\\s)#([a-zA-Z][\\w-]*)/g, '') // Remove IDs\n .replace(/([a-zA-Z][\\w-]*)\\s*=\\s*__QUOTED_\\d+__/g, '') // Remove key-value pairs\n .trim()\n\n if (cleanString) {\n const booleanAttrs = cleanString.split(/\\s+/).filter(Boolean)\n booleanAttrs.forEach(attr => {\n if (attr.match(/^[a-zA-Z][\\w-]*$/)) {\n attributes[attr] = true\n }\n })\n }\n\n return attributes\n}\n\n/**\n * Serializes an attributes object back to a Pandoc-style attribute string.\n *\n * @param attributes - The attributes object to serialize\n * @returns Serialized attribute string\n *\n * @example\n * ```ts\n * serializeAttributes({ class: 'btn primary', id: 'submit', disabled: true, type: 'button' })\n * // → '.btn.primary #submit disabled type=\"button\"'\n * ```\n */\nexport function serializeAttributes(attributes: Record<string, any>): string {\n if (!attributes || Object.keys(attributes).length === 0) {\n return ''\n }\n\n const parts: string[] = []\n\n // Handle classes\n if (attributes.class) {\n const classes = String(attributes.class).split(/\\s+/).filter(Boolean)\n classes.forEach(cls => parts.push(`.${cls}`))\n }\n\n // Handle ID\n if (attributes.id) {\n parts.push(`#${attributes.id}`)\n }\n\n // Handle other attributes\n Object.entries(attributes).forEach(([key, value]) => {\n if (key === 'class' || key === 'id') {\n return // Already handled\n }\n\n if (value === true) {\n // Boolean attribute\n parts.push(key)\n } else if (value !== false && value != null) {\n // Key-value attribute\n parts.push(`${key}=\"${String(value)}\"`)\n }\n })\n\n return parts.join(' ')\n}\n","import type {\n JSONContent,\n MarkdownParseHelpers,\n MarkdownParseResult,\n MarkdownToken,\n MarkdownTokenizer,\n} from '../../types.js'\nimport {\n parseAttributes as defaultParseAttributes,\n serializeAttributes as defaultSerializeAttributes,\n} from './attributeUtils.js'\n\nexport interface AtomBlockMarkdownSpecOptions {\n /** The Tiptap node name this spec is for */\n nodeName: string\n /** The markdown syntax name (defaults to nodeName if not provided) */\n name?: string\n /** Function to parse attributes from token attribute string */\n parseAttributes?: (attrString: string) => Record<string, any>\n /** Function to serialize attributes back to string for rendering */\n serializeAttributes?: (attrs: Record<string, any>) => string\n /** Default attributes to apply when parsing */\n defaultAttributes?: Record<string, any>\n /** Required attributes that must be present for successful parsing */\n requiredAttributes?: string[]\n /** Attributes that are allowed to be rendered back to markdown (whitelist) */\n allowedAttributes?: string[]\n}\n\n/**\n * Creates a complete markdown spec for atomic block nodes using Pandoc syntax.\n *\n * The generated spec handles:\n * - Parsing self-closing blocks with `:::blockName {attributes}`\n * - Extracting and parsing attributes\n * - Validating required attributes\n * - Rendering blocks back to markdown\n *\n * @param options - Configuration for the atomic block markdown spec\n * @returns Complete markdown specification object\n *\n * @example\n * ```ts\n * const youtubeSpec = createAtomBlockMarkdownSpec({\n * nodeName: 'youtube',\n * requiredAttributes: ['src'],\n * defaultAttributes: { start: 0 },\n * allowedAttributes: ['src', 'start', 'width', 'height'] // Only these get rendered to markdown\n * })\n *\n * // Usage in extension:\n * export const Youtube = Node.create({\n * // ... other config\n * markdown: youtubeSpec\n * })\n * ```\n */\nexport function createAtomBlockMarkdownSpec(options: AtomBlockMarkdownSpecOptions): {\n parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult\n markdownTokenizer: MarkdownTokenizer\n renderMarkdown: (node: JSONContent) => string\n} {\n const {\n nodeName,\n name: markdownName,\n parseAttributes = defaultParseAttributes,\n serializeAttributes = defaultSerializeAttributes,\n defaultAttributes = {},\n requiredAttributes = [],\n allowedAttributes,\n } = options\n\n // Use markdownName for syntax, fallback to nodeName\n const blockName = markdownName || nodeName\n\n // Helper function to filter attributes based on allowlist\n const filterAttributes = (attrs: Record<string, any>) => {\n if (!allowedAttributes) {\n return attrs\n }\n\n const filtered: Record<string, any> = {}\n allowedAttributes.forEach(key => {\n if (key in attrs) {\n filtered[key] = attrs[key]\n }\n })\n return filtered\n }\n\n return {\n parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => {\n const attrs = { ...defaultAttributes, ...token.attributes }\n return h.createNode(nodeName, attrs, [])\n },\n\n markdownTokenizer: {\n name: nodeName,\n level: 'block' as const,\n start(src: string) {\n const regex = new RegExp(`^:::${blockName}(?:\\\\s|$)`, 'm')\n const index = src.match(regex)?.index\n return index !== undefined ? index : -1\n },\n tokenize(src, _tokens, _lexer) {\n // Use non-global regex to match from the start of the string\n // Include optional newline to ensure we consume the entire line\n const regex = new RegExp(`^:::${blockName}(?:\\\\s+\\\\{([^}]*)\\\\})?\\\\s*:::(?:\\\\n|$)`)\n const match = src.match(regex)\n\n if (!match) {\n return undefined\n }\n\n // Parse attributes if present\n const attrString = match[1] || ''\n const attributes = parseAttributes(attrString)\n\n // Validate required attributes\n const missingRequired = requiredAttributes.find(required => !(required in attributes))\n if (missingRequired) {\n return undefined\n }\n\n return {\n type: nodeName,\n raw: match[0],\n attributes,\n }\n },\n },\n\n renderMarkdown: node => {\n const filteredAttrs = filterAttributes(node.attrs || {})\n const attrs = serializeAttributes(filteredAttrs)\n const attrString = attrs ? ` {${attrs}}` : ''\n\n return `:::${blockName}${attrString} :::`\n },\n }\n}\n","import type {\n JSONContent,\n MarkdownParseHelpers,\n MarkdownParseResult,\n MarkdownRendererHelpers,\n MarkdownToken,\n MarkdownTokenizer,\n} from '../../types.js'\nimport {\n parseAttributes as defaultParseAttributes,\n serializeAttributes as defaultSerializeAttributes,\n} from './attributeUtils.js'\n\nexport interface BlockMarkdownSpecOptions {\n /** The Tiptap node name this spec is for */\n nodeName: string\n /** The markdown syntax name (defaults to nodeName if not provided) */\n name?: string\n /** Function to extract content from the node for serialization */\n getContent?: (token: MarkdownToken) => string\n /** Function to parse attributes from the attribute string */\n parseAttributes?: (attrString: string) => Record<string, any>\n /** Function to serialize attributes to string */\n serializeAttributes?: (attrs: Record<string, any>) => string\n /** Default attributes to apply when parsing */\n defaultAttributes?: Record<string, any>\n /** Content type: 'block' allows paragraphs/lists/etc, 'inline' only allows bold/italic/links/etc */\n content?: 'block' | 'inline'\n /** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */\n allowedAttributes?: string[]\n}\n\n/**\n * Creates a complete markdown spec for block-level nodes using Pandoc syntax.\n *\n * The generated spec handles:\n * - Parsing blocks with `:::blockName {attributes}` syntax\n * - Extracting and parsing attributes\n * - Rendering blocks back to markdown with proper formatting\n * - Nested content support\n *\n * @param options - Configuration for the block markdown spec\n * @returns Complete markdown specification object\n *\n * @example\n * ```ts\n * const calloutSpec = createBlockMarkdownSpec({\n * nodeName: 'callout',\n * defaultAttributes: { type: 'info' },\n * allowedAttributes: ['type', 'title'] // Only these get rendered to markdown\n * })\n *\n * // Usage in extension:\n * export const Callout = Node.create({\n * // ... other config\n * markdown: calloutSpec\n * })\n * ```\n */\nexport function createBlockMarkdownSpec(options: BlockMarkdownSpecOptions): {\n parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult\n markdownTokenizer: MarkdownTokenizer\n renderMarkdown: (node: JSONContent, h: MarkdownRendererHelpers) => string\n} {\n const {\n nodeName,\n name: markdownName,\n getContent,\n parseAttributes = defaultParseAttributes,\n serializeAttributes = defaultSerializeAttributes,\n defaultAttributes = {},\n content = 'block',\n allowedAttributes,\n } = options\n\n // Use markdownName for syntax, fallback to nodeName\n const blockName = markdownName || nodeName\n\n // Helper function to filter attributes based on allowlist\n const filterAttributes = (attrs: Record<string, any>) => {\n if (!allowedAttributes) {\n return attrs\n }\n\n const filtered: Record<string, any> = {}\n allowedAttributes.forEach(key => {\n if (key in attrs) {\n filtered[key] = attrs[key]\n }\n })\n return filtered\n }\n\n return {\n parseMarkdown: (token, h) => {\n let nodeContent: JSONContent[]\n\n if (getContent) {\n const contentResult = getContent(token)\n // If getContent returns a string, wrap it in a text node\n nodeContent = typeof contentResult === 'string' ? [{ type: 'text', text: contentResult }] : contentResult\n } else if (content === 'block') {\n nodeContent = h.parseChildren(token.tokens || [])\n } else {\n nodeContent = h.parseInline(token.tokens || [])\n }\n\n const attrs = { ...defaultAttributes, ...token.attributes }\n\n return h.createNode(nodeName, attrs, nodeContent)\n },\n\n markdownTokenizer: {\n name: nodeName,\n level: 'block' as const,\n start(src) {\n const regex = new RegExp(`^:::${blockName}`, 'm')\n const index = src.match(regex)?.index\n return index !== undefined ? index : -1\n },\n tokenize(src, _tokens, lexer) {\n // Match the opening tag with optional attributes\n const openingRegex = new RegExp(`^:::${blockName}(?:\\\\s+\\\\{([^}]*)\\\\})?\\\\s*\\\\n`)\n const openingMatch = src.match(openingRegex)\n\n if (!openingMatch) {\n return undefined\n }\n\n const [openingTag, attrString = ''] = openingMatch\n const attributes = parseAttributes(attrString)\n\n // Find the matching closing tag by tracking nesting level\n let level = 1\n const position = openingTag.length\n let matchedContent = ''\n\n // Pattern to match any block opening (:::word) or closing (:::)\n const blockPattern = /^:::([\\w-]*)(\\s.*)?/gm\n const remaining = src.slice(position)\n\n blockPattern.lastIndex = 0\n\n // run until no more matches are found\n for (;;) {\n const match = blockPattern.exec(remaining)\n if (match === null) {\n break\n }\n const matchPos = match.index\n const blockType = match[1] // Empty string for closing tag, block name for opening\n\n if (match[2]?.endsWith(':::')) {\n // this is an atom ::: node, we skip it\n continue\n }\n\n if (blockType) {\n // Opening tag found - increase level\n level += 1\n } else {\n // Closing tag found - decrease level\n level -= 1\n\n if (level === 0) {\n // Found our matching closing tag\n // Don't trim yet - keep newlines for tokenizer regex matching\n const rawContent = remaining.slice(0, matchPos)\n matchedContent = rawContent.trim()\n const fullMatch = src.slice(0, position + matchPos + match[0].length)\n\n // Tokenize the content\n let contentTokens: MarkdownToken[] = []\n if (matchedContent) {\n if (content === 'block') {\n // Use rawContent for tokenization to preserve line boundaries for regex matching\n contentTokens = lexer.blockTokens(rawContent)\n\n // Parse inline tokens for any token that has text content but no tokens\n contentTokens.forEach(token => {\n if (token.text && (!token.tokens || token.tokens.length === 0)) {\n token.tokens = lexer.inlineTokens(token.text)\n }\n })\n\n // Clean up empty trailing paragraphs\n while (contentTokens.length > 0) {\n const lastToken = contentTokens[contentTokens.length - 1]\n if (lastToken.type === 'paragraph' && (!lastToken.text || lastToken.text.trim() === '')) {\n contentTokens.pop()\n } else {\n break\n }\n }\n } else {\n contentTokens = lexer.inlineTokens(matchedContent)\n }\n }\n\n return {\n type: nodeName,\n raw: fullMatch,\n attributes,\n content: matchedContent,\n tokens: contentTokens,\n }\n }\n }\n }\n\n // No matching closing tag found\n return undefined\n },\n },\n\n renderMarkdown: (node, h) => {\n const filteredAttrs = filterAttributes(node.attrs || {})\n const attrs = serializeAttributes(filteredAttrs)\n const attrString = attrs ? ` {${attrs}}` : ''\n const renderedContent = h.renderChildren(node.content || [], '\\n\\n')\n\n return `:::${blockName}${attrString}\\n\\n${renderedContent}\\n\\n:::`\n },\n }\n}\n","import type {\n JSONContent,\n MarkdownParseHelpers,\n MarkdownParseResult,\n MarkdownToken,\n MarkdownTokenizer,\n} from '../../types.js'\n\n/**\n * Parse shortcode attributes like 'id=\"madonna\" handle=\"john\" name=\"John Doe\"'\n * Requires all values to be quoted with either single or double quotes\n */\nfunction parseShortcodeAttributes(attrString: string): Record<string, any> {\n if (!attrString.trim()) {\n return {}\n }\n\n const attributes: Record<string, any> = {}\n // Match key=value pairs, only accepting quoted values\n const regex = /(\\w+)=(?:\"([^\"]*)\"|'([^']*)')/g\n let match = regex.exec(attrString)\n\n while (match !== null) {\n const [, key, doubleQuoted, singleQuoted] = match\n attributes[key] = doubleQuoted || singleQuoted\n match = regex.exec(attrString)\n }\n\n return attributes\n}\n\n/**\n * Serialize attributes back to shortcode format\n * Always quotes all values with double quotes\n */\nfunction serializeShortcodeAttributes(attrs: Record<string, any>): string {\n return Object.entries(attrs)\n .filter(([, value]) => value !== undefined && value !== null)\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ')\n}\n\nexport interface InlineMarkdownSpecOptions {\n /** The Tiptap node name this spec is for */\n nodeName: string\n /** The shortcode name (defaults to nodeName if not provided) */\n name?: string\n /** Function to extract content from the node for serialization */\n getContent?: (node: any) => string\n /** Function to parse attributes from the attribute string */\n parseAttributes?: (attrString: string) => Record<string, any>\n /** Function to serialize attributes to string */\n serializeAttributes?: (attrs: Record<string, any>) => string\n /** Default attributes to apply when parsing */\n defaultAttributes?: Record<string, any>\n /** Whether this is a self-closing shortcode (no content, like [emoji name=party]) */\n selfClosing?: boolean\n /** Allowlist of attributes to include in markdown (if not provided, all attributes are included) */\n allowedAttributes?: string[]\n}\n\n/**\n * Creates a complete markdown spec for inline nodes using attribute syntax.\n *\n * The generated spec handles:\n * - Parsing shortcode syntax with `[nodeName attributes]content[/nodeName]` format\n * - Self-closing shortcodes like `[emoji name=party_popper]`\n * - Extracting and parsing attributes from the opening tag\n * - Rendering inline elements back to shortcode markdown\n * - Supporting both content-based and self-closing inline elements\n *\n * @param options - Configuration for the inline markdown spec\n * @returns Complete markdown specification object\n *\n * @example\n * ```ts\n * // Self-closing mention: [mention id=\"madonna\" label=\"Madonna\"]\n * const mentionSpec = createInlineMarkdownSpec({\n * nodeName: 'mention',\n * selfClosing: true,\n * defaultAttributes: { type: 'user' },\n * allowedAttributes: ['id', 'label'] // Only these get rendered to markdown\n * })\n *\n * // Self-closing emoji: [emoji name=\"party_popper\"]\n * const emojiSpec = createInlineMarkdownSpec({\n * nodeName: 'emoji',\n * selfClosing: true,\n * allowedAttributes: ['name']\n * })\n *\n * // With content: [highlight color=\"yellow\"]text[/highlight]\n * const highlightSpec = createInlineMarkdownSpec({\n * nodeName: 'highlight',\n * selfClosing: false,\n * allowedAttributes: ['color', 'style']\n * })\n *\n * // Usage in extension:\n * export const Mention = Node.create({\n * name: 'mention', // Must match nodeName\n * // ... other config\n * markdown: mentionSpec\n * })\n * ```\n */\nexport function createInlineMarkdownSpec(options: InlineMarkdownSpecOptions): {\n parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => MarkdownParseResult\n markdownTokenizer: MarkdownTokenizer\n renderMarkdown: (node: JSONContent) => string\n} {\n const {\n nodeName,\n name: shortcodeName,\n getContent,\n parseAttributes = parseShortcodeAttributes,\n serializeAttributes = serializeShortcodeAttributes,\n defaultAttributes = {},\n selfClosing = false,\n allowedAttributes,\n } = options\n\n // Use shortcodeName for markdown syntax, fallback to nodeName\n const shortcode = shortcodeName || nodeName\n\n // Helper function to filter attributes based on allowlist\n const filterAttributes = (attrs: Record<string, any>) => {\n if (!allowedAttributes) {\n return attrs\n }\n\n const filtered: Record<string, any> = {}\n allowedAttributes.forEach(key => {\n if (key in attrs) {\n filtered[key] = attrs[key]\n }\n })\n return filtered\n }\n\n // Escape special regex characters in shortcode name\n const escapedShortcode = shortcode.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n return {\n parseMarkdown: (token: MarkdownToken, h: MarkdownParseHelpers) => {\n const attrs = { ...defaultAttributes, ...token.attributes }\n\n if (selfClosing) {\n // Self-closing nodes like mentions are atomic - no content\n return h.createNode(nodeName, attrs)\n }\n\n // Nodes with content\n const content = getContent ? getContent(token) : token.content || ''\n if (content) {\n // For inline content, create text nodes using the proper helper\n return h.createNode(nodeName, attrs, [h.createTextNode(content)])\n }\n return h.createNode(nodeName, attrs, [])\n },\n\n markdownTokenizer: {\n name: nodeName,\n level: 'inline' as const,\n start(src: string) {\n // Create a non-global version for finding the start position\n const startPattern = selfClosing\n ? new RegExp(`\\\\[${escapedShortcode}\\\\s*[^\\\\]]*\\\\]`)\n : new RegExp(`\\\\[${escapedShortcode}\\\\s*[^\\\\]]*\\\\][\\\\s\\\\S]*?\\\\[\\\\/${escapedShortcode}\\\\]`)\n\n const match = src.match(startPattern)\n const index = match?.index\n return index !== undefined ? index : -1\n },\n tokenize(src, _tokens, _lexer) {\n // Use non-global regex to match from the start of the string\n const tokenPattern = selfClosing\n ? new RegExp(`^\\\\[${escapedShortcode}\\\\s*([^\\\\]]*)\\\\]`)\n : new RegExp(`^\\\\[${escapedShortcode}\\\\s*([^\\\\]]*)\\\\]([\\\\s\\\\S]*?)\\\\[\\\\/${escapedShortcode}\\\\]`)\n\n const match = src.match(tokenPattern)\n\n if (!match) {\n return undefined\n }\n\n let content = ''\n let attrString = ''\n\n if (selfClosing) {\n // Self-closing: [shortcode attr=\"value\"]\n const [, attrs] = match\n attrString = attrs\n } else {\n // With content: [shortcode attr=\"value\"]content[/shortcode]\n const [, attrs, contentMatch] = match\n attrString = attrs\n content = contentMatch || ''\n }\n\n // Parse attributes from the attribute string\n const attributes = parseAttributes(attrString.trim())\n\n return {\n type: nodeName,\n raw: match[0],\n content: content.trim(),\n attributes,\n }\n },\n },\n\n renderMarkdown: (node: JSONContent) => {\n let content = ''\n if (getContent) {\n content = getContent(node)\n } else if (node.content && node.content.length > 0) {\n // Extract text from content array for inline nodes\n content = node.content\n .filter((child: any) => child.type === 'text')\n .map((child: any) => child.text)\n .join('')\n }\n\n const filteredAttrs = filterAttributes(node.attrs || {})\n const attrs = serializeAttributes(filteredAttrs)\n const attrString = attrs ? ` ${attrs}` : ''\n\n if (selfClosing) {\n return `[${shortcode}${attrString}]`\n }\n\n return `[${shortcode}${attrString}]${content}[/${shortcode}]`\n },\n }\n}\n","/**\n * @fileoverview Utility for parsing indented markdown blocks with hierarchical nesting.\n *\n * This utility handles the complex logic of parsing markdown blocks that can contain\n * nested content based on indentation levels, maintaining proper hierarchical structure\n * for lists, task lists, and other indented block types.\n */\n\nexport interface ParsedBlock {\n type: string\n raw: string\n mainContent: string\n indentLevel: number\n nestedContent?: string\n nestedTokens?: any[]\n [key: string]: any\n}\n\nexport interface BlockParserConfig {\n /** Regex pattern to match block items */\n itemPattern: RegExp\n /** Function to extract data from regex match */\n extractItemData: (match: RegExpMatchArray) => {\n mainContent: string\n indentLevel: number\n [key: string]: any\n }\n /** Function to create the final token */\n createToken: (data: any, nestedTokens?: any[]) => ParsedBlock\n /** Base indentation to remove from nested content (default: 2 spaces) */\n baseIndentSize?: number\n /**\n * Custom parser for nested content. If provided, this will be called instead\n * of the default lexer.blockTokens() for parsing nested content.\n * This allows recursive parsing of the same block type.\n */\n customNestedParser?: (dedentedContent: string) => any[] | undefined\n}\n\n/**\n * Parses markdown text into hierarchical indented blocks with proper nesting.\n *\n * This utility handles:\n * - Line-by-line parsing with pattern matching\n * - Hierarchical nesting based on indentation levels\n * - Nested content collection and parsing\n * - Empty line handling\n * - Content dedenting for nested blocks\n *\n * The key difference from flat parsing is that this maintains the hierarchical\n * structure where nested items become `nestedTokens` of their parent items,\n * rather than being flattened into a single array.\n *\n * @param src - The markdown source text to parse\n * @param config - Configuration object defining how to parse and create tokens\n * @param lexer - Markdown lexer for parsing nested content\n * @returns Parsed result with hierarchical items, or undefined if no matches\n *\n * @example\n * ```ts\n * const result = parseIndentedBlocks(src, {\n * itemPattern: /^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,\n * extractItemData: (match) => ({\n * indentLevel: match[1].length,\n * mainContent: match[4],\n * checked: match[3].toLowerCase() === 'x'\n * }),\n * createToken: (data, nestedTokens) => ({\n * type: 'taskItem',\n * checked: data.checked,\n * text: data.mainContent,\n * nestedTokens\n * })\n * }, lexer)\n * ```\n */\nexport function parseIndentedBlocks(\n src: string,\n config: BlockParserConfig,\n lexer: {\n inlineTokens: (src: string) => any[]\n blockTokens: (src: string) => any[]\n },\n):\n | {\n items: ParsedBlock[]\n raw: string\n }\n | undefined {\n const lines = src.split('\\n')\n const items: ParsedBlock[] = []\n let totalRaw = ''\n let i = 0\n const baseIndentSize = config.baseIndentSize || 2\n\n while (i < lines.length) {\n const currentLine = lines[i]\n const itemMatch = currentLine.match(config.itemPattern)\n\n if (!itemMatch) {\n // Not a matching item - stop if we have items, otherwise this isn't our block type\n if (items.length > 0) {\n break\n } else if (currentLine.trim() === '') {\n i += 1\n continue\n } else {\n return undefined\n }\n }\n\n const itemData = config.extractItemData(itemMatch)\n const { indentLevel, mainContent } = itemData\n totalRaw = `${totalRaw}${currentLine}\\n`\n\n // Collect content for this item (including nested items)\n const itemContent = [mainContent] // Start with the main text\n i += 1\n\n // Look ahead for nested content (indented more than current item)\n while (i < lines.length) {\n const nextLine = lines[i]\n\n if (nextLine.trim() === '') {\n // Empty line - might be end of nested content\n const nextNonEmptyIndex = lines.slice(i + 1).findIndex(l => l.trim() !== '')\n if (nextNonEmptyIndex === -1) {\n // No more content\n break\n }\n\n const nextNonEmpty = lines[i + 1 + nextNonEmptyIndex]\n const nextIndent = nextNonEmpty.match(/^(\\s*)/)?.[1]?.length || 0\n\n if (nextIndent > indentLevel) {\n // Nested content continues after empty line\n itemContent.push(nextLine)\n totalRaw = `${totalRaw}${nextLine}\\n`\n i += 1\n continue\n } else {\n // End of nested content\n break\n }\n }\n\n const nextIndent = nextLine.match(/^(\\s*)/)?.[1]?.length || 0\n\n if (nextIndent > indentLevel) {\n // This is nested content for the current item\n itemContent.push(nextLine)\n totalRaw = `${totalRaw}${nextLine}\\n`\n i += 1\n } else {\n // Same or less indentation - this belongs to parent level\n break\n }\n }\n\n // Parse nested content if present\n let nestedTokens: any[] | undefined\n const nestedContent = itemContent.slice(1)\n\n if (nestedContent.length > 0) {\n // Remove the base indentation from nested content\n const dedentedNested = nestedContent\n .map(nestedLine => nestedLine.slice(indentLevel + baseIndentSize)) // Remove base indent + 2 spaces\n .join('\\n')\n\n if (dedentedNested.trim()) {\n // Use custom nested parser if provided, otherwise fall back to default\n if (config.customNestedParser) {\n nestedTokens = config.customNestedParser(dedentedNested)\n } else {\n nestedTokens = lexer.blockTokens(dedentedNested)\n }\n }\n }\n\n // Create the token using the provided factory function\n const token = config.createToken(itemData, nestedTokens)\n items.push(token)\n }\n\n if (items.length === 0) {\n return undefined\n }\n\n return {\n items,\n raw: totalRaw.trim(),\n }\n}\n","import type { JSONContent } from '@blockslides/core'\n\n/**\n * @fileoverview Utility functions for rendering nested content in markdown.\n *\n * This module provides reusable utilities for extensions that need to render\n * content with a prefix on the main line and properly indented nested content.\n */\n\n/**\n * Utility function for rendering content with a main line prefix and nested indented content.\n *\n * This function handles the common pattern of rendering content with:\n * 1. A main line with a prefix (like \"- \" for lists, \"> \" for blockquotes, etc.)\n * 2. Nested content that gets indented properly\n *\n * @param node - The ProseMirror node representing the content\n * @param h - The markdown renderer helper\n * @param prefixOrGenerator - Either a string prefix or a function that generates the prefix from context\n * @param ctx - Optional context object (used when prefixOrGenerator is a function)\n * @returns The rendered markdown string\n *\n * @example\n * ```ts\n * // For a bullet list item with static prefix\n * return renderNestedMarkdownContent(node, h, '- ')\n *\n * // For a task item with static prefix\n * const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `\n * return renderNestedMarkdownContent(node, h, prefix)\n *\n * // For a blockquote with static prefix\n * return renderNestedMarkdownContent(node, h, '> ')\n *\n * // For content with dynamic prefix based on context\n * return renderNestedMarkdownContent(node, h, ctx => {\n * if (ctx.parentType === 'orderedList') {\n * return `${ctx.index + 1}. `\n * }\n * return '- '\n * }, ctx)\n *\n * // Custom extension example\n * const CustomContainer = Node.create({\n * name: 'customContainer',\n * // ... other config\n * markdown: {\n * render: (node, h) => {\n * const type = node.attrs?.type || 'info'\n * return renderNestedMarkdownContent(node, h, `[${type}] `)\n * }\n * }\n * })\n * ```\n */\nexport function renderNestedMarkdownContent(\n node: JSONContent,\n h: {\n renderChildren: (nodes: JSONContent[]) => string\n indent: (text: string) => string\n },\n prefixOrGenerator: string | ((ctx: any) => string),\n ctx?: any,\n): string {\n if (!node || !Array.isArray(node.content)) {\n return ''\n }\n\n // Determine the prefix based on the input\n const prefix = typeof prefixOrGenerator === 'function' ? prefixOrGenerator(ctx) : prefixOrGenerator\n\n const [content, ...children] = node.content\n\n // Render the main content (typically a paragraph)\n const mainContent = h.renderChildren([content])\n const output = [`${prefix}${mainContent}`]\n\n // Handle nested children with proper indentation\n if (children && children.length > 0) {\n children.forEach(child => {\n const childContent = h.renderChildren([child])\n if (childContent) {\n // Split the child content by lines and indent each line\n const indentedChild = childContent\n .split('\\n')\n .map(line => (line ? h.indent(line) : ''))\n .join('\\n')\n output.push(indentedChild)\n }\n })\n }\n\n return output.join('\\n')\n}\n","import type { Mark } from \"@blockslides/pm/model\";\nimport type { ViewMutationRecord } from \"@blockslides/pm/view\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport type { MarkViewProps, MarkViewRendererOptions } from \"./types.js\";\nimport { isAndroid, isiOS } from \"./utilities/index.js\";\n\nexport function updateMarkViewAttributes(\n checkMark: Mark,\n editor: Editor,\n attrs: Record<string, any> = {}\n): void {\n const { state } = editor;\n const { doc, tr } = state;\n const thisMark = checkMark;\n\n doc.descendants((node, pos) => {\n const from = tr.mapping.map(pos);\n const to = tr.mapping.map(pos) + node.nodeSize;\n let foundMark: Mark | null = null;\n\n // find the mark on the current node\n node.marks.forEach((mark) => {\n if (mark !== thisMark) {\n return false;\n }\n\n foundMark = mark;\n });\n\n if (!foundMark) {\n return;\n }\n\n // check if we need to update given the attributes\n let needsUpdate = false;\n Object.keys(attrs).forEach((k) => {\n if (attrs[k] !== foundMark!.attrs[k]) {\n needsUpdate = true;\n }\n });\n\n if (needsUpdate) {\n const updatedMark = checkMark.type.create({\n ...checkMark.attrs,\n ...attrs,\n });\n\n tr.removeMark(from, to, checkMark.type);\n tr.addMark(from, to, updatedMark);\n }\n });\n\n if (tr.docChanged) {\n editor.view.dispatch(tr);\n }\n}\n\nexport class MarkView<\n Component,\n Options extends MarkViewRendererOptions = MarkViewRendererOptions\n> {\n component: Component;\n editor: Editor;\n options: Options;\n mark: MarkViewProps[\"mark\"];\n HTMLAttributes: MarkViewProps[\"HTMLAttributes\"];\n\n constructor(\n component: Component,\n props: MarkViewProps,\n options?: Partial<Options>\n ) {\n this.component = component;\n this.editor = props.editor;\n this.options = { ...options } as Options;\n this.mark = props.mark;\n this.HTMLAttributes = props.HTMLAttributes;\n }\n\n get dom(): HTMLElement {\n return this.editor.view.dom;\n }\n\n get contentDOM(): HTMLElement | null {\n return null;\n }\n\n /**\n * Update the attributes of the mark in the document.\n * @param attrs The attributes to update.\n */\n updateAttributes(attrs: Record<string, any>, checkMark?: Mark): void {\n updateMarkViewAttributes(checkMark || this.mark, this.editor, attrs);\n }\n\n ignoreMutation(mutation: ViewMutationRecord): boolean {\n if (!this.dom || !this.contentDOM) {\n return true;\n }\n\n if (typeof this.options.ignoreMutation === \"function\") {\n return this.options.ignoreMutation({ mutation });\n }\n\n if (mutation.type === \"selection\") {\n return false;\n }\n\n if (\n this.dom.contains(mutation.target) &&\n mutation.type === \"childList\" &&\n (isiOS() || isAndroid()) &&\n this.editor.isFocused\n ) {\n const changedNodes = [\n ...Array.from(mutation.addedNodes),\n ...Array.from(mutation.removedNodes),\n ] as HTMLElement[];\n\n if (changedNodes.every((node) => node.isContentEditable)) {\n return false;\n }\n }\n\n if (this.contentDOM === mutation.target && mutation.type === \"attributes\") {\n return true;\n }\n\n if (this.contentDOM.contains(mutation.target)) {\n return false;\n }\n\n return true;\n }\n}\n","import type {\n DOMOutputSpec,\n Node as ProseMirrorNode,\n NodeSpec,\n NodeType,\n} from \"@blockslides/pm/model\";\n\nimport { SlideEditor as Editor } from \"./SlideEditor.js\";\nimport type { ExtendableConfig } from \"./Extendable.js\";\nimport { Extendable } from \"./Extendable.js\";\nimport type { Attributes, NodeViewRenderer, ParentConfig } from \"./types.js\";\n\nexport interface NodeConfig<Options = any, Storage = any>\n extends ExtendableConfig<\n Options,\n Storage,\n NodeConfig<Options, Storage>,\n NodeType\n > {\n /**\n * Node View\n */\n addNodeView?:\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n editor: Editor;\n type: NodeType;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"addNodeView\"];\n }) => NodeViewRenderer)\n | null;\n\n /**\n * Defines if this node should be a top level node (doc)\n * @default false\n * @example true\n */\n topNode?: boolean;\n\n /**\n * The content expression for this node, as described in the [schema\n * guide](/docs/guide/#schema.content_expressions). When not given,\n * the node does not allow any content.\n *\n * You can read more about it on the Prosemirror documentation here\n * @see https://prosemirror.net/docs/guide/#schema.content_expressions\n * @default undefined\n * @example content: 'block+'\n * @example content: 'headline paragraph block*'\n */\n content?:\n | NodeSpec[\"content\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"content\"];\n editor?: Editor;\n }) => NodeSpec[\"content\"]);\n\n /**\n * The marks that are allowed inside of this node. May be a\n * space-separated string referring to mark names or groups, `\"_\"`\n * to explicitly allow all marks, or `\"\"` to disallow marks. When\n * not given, nodes with inline content default to allowing all\n * marks, other nodes default to not allowing marks.\n *\n * @example marks: 'strong em'\n */\n marks?:\n | NodeSpec[\"marks\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"marks\"];\n editor?: Editor;\n }) => NodeSpec[\"marks\"]);\n\n /**\n * The group or space-separated groups to which this node belongs,\n * which can be referred to in the content expressions for the\n * schema.\n *\n * By default BlockSlides uses the groups 'block' and 'inline' for nodes. You\n * can also use custom groups if you want to group specific nodes together\n * and handle them in your schema.\n * @example group: 'block'\n * @example group: 'inline'\n * @example group: 'customBlock' // this uses a custom group\n */\n group?:\n | NodeSpec[\"group\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"group\"];\n editor?: Editor;\n }) => NodeSpec[\"group\"]);\n\n /**\n * Should be set to true for inline nodes. (Implied for text nodes.)\n */\n inline?:\n | NodeSpec[\"inline\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"inline\"];\n editor?: Editor;\n }) => NodeSpec[\"inline\"]);\n\n /**\n * Can be set to true to indicate that, though this isn't a [leaf\n * node](https://prosemirror.net/docs/ref/#model.NodeType.isLeaf), it doesn't have directly editable\n * content and should be treated as a single unit in the view.\n *\n * @example atom: true\n */\n atom?:\n | NodeSpec[\"atom\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"atom\"];\n editor?: Editor;\n }) => NodeSpec[\"atom\"]);\n\n /**\n * Controls whether nodes of this type can be selected as a [node\n * selection](https://prosemirror.net/docs/ref/#state.NodeSelection). Defaults to true for non-text\n * nodes.\n *\n * @default true\n * @example selectable: false\n */\n selectable?:\n | NodeSpec[\"selectable\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"selectable\"];\n editor?: Editor;\n }) => NodeSpec[\"selectable\"]);\n\n /**\n * Determines whether nodes of this type can be dragged without\n * being selected. Defaults to false.\n *\n * @default: false\n * @example: draggable: true\n */\n draggable?:\n | NodeSpec[\"draggable\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"draggable\"];\n editor?: Editor;\n }) => NodeSpec[\"draggable\"]);\n\n /**\n * Can be used to indicate that this node contains code, which\n * causes some commands to behave differently.\n */\n code?:\n | NodeSpec[\"code\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"code\"];\n editor?: Editor;\n }) => NodeSpec[\"code\"]);\n\n /**\n * Controls way whitespace in this a node is parsed. The default is\n * `\"normal\"`, which causes the [DOM parser](https://prosemirror.net/docs/ref/#model.DOMParser) to\n * collapse whitespace in normal mode, and normalize it (replacing\n * newlines and such with spaces) otherwise. `\"pre\"` causes the\n * parser to preserve spaces inside the node. When this option isn't\n * given, but [`code`](https://prosemirror.net/docs/ref/#model.NodeSpec.code) is true, `whitespace`\n * will default to `\"pre\"`. Note that this option doesn't influence\n * the way the node is rendered—that should be handled by `toDOM`\n * and/or styling.\n */\n whitespace?:\n | NodeSpec[\"whitespace\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"whitespace\"];\n editor?: Editor;\n }) => NodeSpec[\"whitespace\"]);\n\n /**\n * Allows a **single** node to be set as linebreak equivalent (e.g. hardBreak).\n * When converting between block types that have whitespace set to \"pre\"\n * and don't support the linebreak node (e.g. codeBlock) and other block types\n * that do support the linebreak node (e.g. paragraphs) - this node will be used\n * as the linebreak instead of stripping the newline.\n *\n * See [linebreakReplacement](https://prosemirror.net/docs/ref/#model.NodeSpec.linebreakReplacement).\n */\n linebreakReplacement?:\n | NodeSpec[\"linebreakReplacement\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<\n NodeConfig<Options, Storage>\n >[\"linebreakReplacement\"];\n editor?: Editor;\n }) => NodeSpec[\"linebreakReplacement\"]);\n\n /**\n * When enabled, enables both\n * [`definingAsContext`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingAsContext) and\n * [`definingForContent`](https://prosemirror.net/docs/ref/#model.NodeSpec.definingForContent).\n *\n * @default false\n * @example isolating: true\n */\n defining?:\n | NodeSpec[\"defining\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"defining\"];\n editor?: Editor;\n }) => NodeSpec[\"defining\"]);\n\n /**\n * When enabled (default is false), the sides of nodes of this type\n * count as boundaries that regular editing operations, like\n * backspacing or lifting, won't cross. An example of a node that\n * should probably have this enabled is a table cell.\n */\n isolating?:\n | NodeSpec[\"isolating\"]\n | ((this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"isolating\"];\n editor?: Editor;\n }) => NodeSpec[\"isolating\"]);\n\n /**\n * Associates DOM parser information with this node, which can be\n * used by [`DOMParser.fromSchema`](https://prosemirror.net/docs/ref/#model.DOMParser^fromSchema) to\n * automatically derive a parser. The `node` field in the rules is\n * implied (the name of this node will be filled in automatically).\n * If you supply your own parser, you do not need to also specify\n * parsing rules in your schema.\n *\n * @example parseHTML: [{ tag: 'div', attrs: { 'data-id': 'my-block' } }]\n */\n parseHTML?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"parseHTML\"];\n editor?: Editor;\n }) => NodeSpec[\"parseDOM\"];\n\n /**\n * A description of a DOM structure. Can be either a string, which is\n * interpreted as a text node, a DOM node, which is interpreted as\n * itself, a `{dom, contentDOM}` object, or an array.\n *\n * An array describes a DOM element. The first value in the array\n * should be a string—the name of the DOM element, optionally prefixed\n * by a namespace URL and a space. If the second element is plain\n * object, it is interpreted as a set of attributes for the element.\n * Any elements after that (including the 2nd if it's not an attribute\n * object) are interpreted as children of the DOM elements, and must\n * either be valid `DOMOutputSpec` values, or the number zero.\n *\n * The number zero (pronounced “hole”) is used to indicate the place\n * where a node's child nodes should be inserted. If it occurs in an\n * output spec, it should be the only child element in its parent\n * node.\n *\n * @example toDOM: ['div[data-id=\"my-block\"]', { class: 'my-block' }, 0]\n */\n renderHTML?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"renderHTML\"];\n editor?: Editor;\n },\n props: {\n node: ProseMirrorNode;\n HTMLAttributes: Record<string, any>;\n }\n ) => DOMOutputSpec)\n | null;\n\n /**\n * renders the node as text\n * @example renderText: () => 'foo\n */\n renderText?:\n | ((\n this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"renderText\"];\n editor?: Editor;\n },\n props: {\n node: ProseMirrorNode;\n pos: number;\n parent: ProseMirrorNode;\n index: number;\n }\n ) => string)\n | null;\n\n /**\n * Add attributes to the node\n * @example addAttributes: () => ({ class: 'foo' })\n */\n addAttributes?: (this: {\n name: string;\n options: Options;\n storage: Storage;\n parent: ParentConfig<NodeConfig<Options, Storage>>[\"addAttributes\"];\n editor?: Editor;\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n }) => Attributes | {};\n}\n\nexport class Node<Options = any, Storage = any> extends Extendable<\n Options,\n Storage,\n NodeConfig<Options, Storage>\n> {\n type = \"node\";\n\n /**\n * Create a new Node instance\n * @param config - Node configuration object or a function that returns a configuration object\n */\n static create<O = any, S = any>(\n config: Partial<NodeConfig<O, S>> | (() => Partial<NodeConfig<O, S>>) = {}\n ) {\n // If the config is a function, execute it to get the configuration object\n const resolvedConfig = typeof config === \"function\" ? config() : config;\n return new Node<O, S>(resolvedConfig);\n }\n\n configure(options?: Partial<Options>) {\n return super.configure(options) as Node<Options, Storage>;\n }\n\n extend<\n ExtendedOptions = Options,\n ExtendedStorage = Storage,\n ExtendedConfig = NodeConfig<ExtendedOptions, ExtendedStorage>\n >(\n extendedConfig?:\n | (() => Partial<ExtendedConfig>)\n | (Partial<ExtendedConfig> &\n ThisType<{\n name: string;\n options: ExtendedOptions;\n storage: ExtendedStorage;\n editor: Editor;\n type: NodeType;\n }>)\n ): Node<ExtendedOptions, ExtendedStorage> {\n // If the extended config is a function, execute it to get the configuration object\n const resolvedConfig =\n typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n return super.extend(resolvedConfig) as Node<\n ExtendedOptions,\n ExtendedStorage\n >;\n }\n}\n","import { NodeSelection } from \"@blockslides/pm/state\";\nimport type {\n NodeView as ProseMirrorNodeView,\n ViewMutationRecord,\n} from \"@blockslides/pm/view\";\n\nimport type { SlideEditor as CoreEditor } from \"./SlideEditor.js\";\nimport type {\n DecorationWithType,\n NodeViewRendererOptions,\n NodeViewRendererProps,\n} from \"./types.js\";\nimport { isAndroid } from \"./utilities/isAndroid.js\";\nimport { isiOS } from \"./utilities/isiOS.js\";\n\nexport class NodeView<\n Component,\n NodeEditor extends CoreEditor = CoreEditor,\n Options extends NodeViewRendererOptions = NodeViewRendererOptions\n> implements ProseMirrorNodeView\n{\n component: Component;\n\n editor: NodeEditor;\n\n options: Options;\n\n extension: NodeViewRendererProps[\"extension\"];\n\n node: NodeViewRendererProps[\"node\"];\n\n decorations: NodeViewRendererProps[\"decorations\"];\n\n innerDecorations: NodeViewRendererProps[\"innerDecorations\"];\n\n view: NodeViewRendererProps[\"view\"];\n\n getPos: NodeViewRendererProps[\"getPos\"];\n\n HTMLAttributes: NodeViewRendererProps[\"HTMLAttributes\"];\n\n isDragging = false;\n\n constructor(\n component: Component,\n props: NodeViewRendererProps,\n options?: Partial<Options>\n ) {\n this.component = component;\n this.editor = props.editor as NodeEditor;\n this.options = {\n stopEvent: null,\n ignoreMutation: null,\n ...options,\n } as Options;\n this.extension = props.extension;\n this.node = props.node;\n this.decorations = props.decorations as DecorationWithType[];\n this.innerDecorations = props.innerDecorations;\n this.view = props.view;\n this.HTMLAttributes = props.HTMLAttributes;\n this.getPos = props.getPos;\n this.mount();\n }\n\n mount() {\n // eslint-disable-next-line\n return;\n }\n\n get dom(): HTMLElement {\n return this.editor.view.dom as HTMLElement;\n }\n\n get contentDOM(): HTMLElement | null {\n return null;\n }\n\n onDragStart(event: DragEvent) {\n const { view } = this.editor;\n const target = event.target as HTMLElement;\n\n // get the drag handle element\n // `closest` is not available for text nodes so we may have to use its parent\n const dragHandle =\n target.nodeType === 3\n ? target.parentElement?.closest(\"[data-drag-handle]\")\n : target.closest(\"[data-drag-handle]\");\n\n if (!this.dom || this.contentDOM?.contains(target) || !dragHandle) {\n return;\n }\n\n let x = 0;\n let y = 0;\n\n // calculate offset for drag element if we use a different drag handle element\n if (this.dom !== dragHandle) {\n const domBox = this.dom.getBoundingClientRect();\n const handleBox = dragHandle.getBoundingClientRect();\n\n // In React, we have to go through nativeEvent to reach offsetX/offsetY.\n const offsetX = event.offsetX ?? (event as any).nativeEvent?.offsetX;\n const offsetY = event.offsetY ?? (event as any).nativeEvent?.offsetY;\n\n x = handleBox.x - domBox.x + offsetX;\n y = handleBox.y - domBox.y + offsetY;\n }\n\n const clonedNode = this.dom.cloneNode(true) as HTMLElement;\n\n // Preserve the visual size of the original when using the clone as\n // the drag image.\n try {\n const domBox = this.dom.getBoundingClientRect();\n clonedNode.style.width = `${Math.round(domBox.width)}px`;\n clonedNode.style.height = `${Math.round(domBox.height)}px`;\n clonedNode.style.boxSizing = \"border-box\";\n // Ensure the clone doesn't capture pointer events while offscreen\n clonedNode.style.pointerEvents = \"none\";\n } catch {\n // ignore measurement errors (e.g. if element not in DOM)\n }\n\n // Some browsers (notably Safari) require the element passed to\n // setDragImage to be present in the DOM. Using a detached node can\n // cause the drag to immediately end.\n let dragImageWrapper: HTMLElement | null = null;\n\n try {\n dragImageWrapper = document.createElement(\"div\");\n dragImageWrapper.style.position = \"absolute\";\n dragImageWrapper.style.top = \"-9999px\";\n dragImageWrapper.style.left = \"-9999px\";\n dragImageWrapper.style.pointerEvents = \"none\";\n dragImageWrapper.appendChild(clonedNode);\n document.body.appendChild(dragImageWrapper);\n\n event.dataTransfer?.setDragImage(clonedNode, x, y);\n } finally {\n // Remove the wrapper on the next tick so the browser can use the\n // element as the drag image. A 0ms timeout is enough in practice.\n if (dragImageWrapper) {\n setTimeout(() => {\n try {\n dragImageWrapper?.remove();\n } catch {\n // ignore removal errors\n }\n }, 0);\n }\n }\n\n const pos = this.getPos();\n\n if (typeof pos !== \"number\") {\n return;\n }\n // we need to tell ProseMirror that we want to move the whole node\n // so we create a NodeSelection\n const selection = NodeSelection.create(view.state.doc, pos);\n const transaction = view.state.tr.setSelection(selection);\n\n view.dispatch(transaction);\n }\n\n stopEvent(event: Event) {\n if (!this.dom) {\n return false;\n }\n\n if (typeof this.options.stopEvent === \"function\") {\n return this.options.stopEvent({ event });\n }\n\n const target = event.target as HTMLElement;\n const isInElement =\n this.dom.contains(target) && !this.contentDOM?.contains(target);\n\n // any event from child nodes should be handled by ProseMirror\n if (!isInElement) {\n return false;\n }\n\n const isDragEvent = event.type.startsWith(\"drag\");\n const isDropEvent = event.type === \"drop\";\n const isInput =\n [\"INPUT\", \"BUTTON\", \"SELECT\", \"TEXTAREA\"].includes(target.tagName) ||\n target.isContentEditable;\n\n // any input event within node views should be ignored by ProseMirror\n if (isInput && !isDropEvent && !isDragEvent) {\n return true;\n }\n\n const { isEditable } = this.editor;\n const { isDragging } = this;\n const isDraggable = !!this.node.type.spec.draggable;\n const isSelectable = NodeSelection.isSelectable(this.node);\n const isCopyEvent = event.type === \"copy\";\n const isPasteEvent = event.type === \"paste\";\n const isCutEvent = event.type === \"cut\";\n const isClickEvent = event.type === \"mousedown\";\n\n // ProseMirror tries to drag selectable nodes\n // even if `draggable` is set to `false`\n // this fix prevents that\n if (\n !isDraggable &&\n isSelectable &&\n isDragEvent &&\n event.target === this.dom\n ) {\n event.preventDefault();\n }\n\n if (\n isDraggable &&\n isDragEvent &&\n !isDragging &&\n event.target === this.dom\n ) {\n event.preventDefault();\n return false;\n }\n\n // we have to store that dragging started\n if (isDraggable && isEditable && !isDragging && isClickEvent) {\n const dragHandle = target.closest(\"[data-drag-handle]\");\n const isValidDragHandle =\n dragHandle &&\n (this.dom === dragHandle || this.dom.contains(dragHandle));\n\n if (isValidDragHandle) {\n this.isDragging = true;\n\n document.addEventListener(\n \"dragend\",\n () => {\n this.isDragging = false;\n },\n { once: true }\n );\n\n document.addEventListener(\n \"drop\",\n () => {\n this.isDragging = false;\n },\n { once: true }\n );\n\n document.addEventListener(\n \"mouseup\",\n () => {\n this.isDragging = false;\n },\n { once: true }\n );\n }\n }\n\n // these events are handled by prosemirror\n if (\n isDragging ||\n isDropEvent ||\n isCopyEvent ||\n isPasteEvent ||\n isCutEvent ||\n (isClickEvent && isSelectable)\n ) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Called when a DOM [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or a selection change happens within the view.\n * @return `false` if the editor should re-read the selection or re-parse the range around the mutation\n * @return `true` if it can safely be ignored.\n */\n ignoreMutation(mutation: ViewMutationRecord) {\n if (!this.dom || !this.contentDOM) {\n return true;\n }\n\n if (typeof this.options.ignoreMutation === \"function\") {\n return this.options.ignoreMutation({ mutation });\n }\n\n // a leaf/atom node is like a black box for ProseMirror\n // and should be fully handled by the node view\n if (this.node.isLeaf || this.node.isAtom) {\n return true;\n }\n\n // ProseMirror should handle any selections\n if (mutation.type === \"selection\") {\n return false;\n }\n\n if (\n this.dom.contains(mutation.target) &&\n mutation.type === \"childList\" &&\n (isiOS() || isAndroid()) &&\n this.editor.isFocused\n ) {\n const changedNodes = [\n ...Array.from(mutation.addedNodes),\n ...Array.from(mutation.removedNodes),\n ] as HTMLElement[];\n\n // we’ll check if every changed node is contentEditable\n // to make sure it’s probably mutated by ProseMirror\n if (changedNodes.every((node) => node.isContentEditable)) {\n return false;\n }\n }\n\n // we will allow mutation contentDOM with attributes\n // so we can for example adding classes within our node view\n if (this.contentDOM === mutation.target && mutation.type === \"attributes\") {\n return true;\n }\n\n // ProseMirror should handle any changes within contentDOM\n if (this.contentDOM.contains(mutation.target)) {\n return false;\n }\n\n return true;\n }\n\n /**\n * Update the attributes of the prosemirror node.\n */\n updateAttributes(attributes: Record<string, any>): void {\n this.editor.commands.command(({ tr }) => {\n const pos = this.getPos();\n\n if (typeof pos !== \"number\") {\n return false;\n }\n\n tr.setNodeMarkup(pos, undefined, {\n ...this.node.attrs,\n ...attributes,\n });\n\n return true;\n });\n }\n\n /**\n * Delete the node.\n */\n deleteNode(): void {\n const from = this.getPos();\n\n if (typeof from !== \"number\") {\n return;\n }\n const to = from + this.node.nodeSize;\n\n this.editor.commands.deleteRange({ from, to });\n }\n}\n","import type { MarkType } from '@blockslides/pm/model'\n\nimport { getMarksBetween } from '../helpers/getMarksBetween.js'\nimport type { PasteRuleFinder } from '../PasteRule.js'\nimport { PasteRule } from '../PasteRule.js'\nimport type { ExtendedRegExpMatchArray } from '../types.js'\nimport { callOrReturn } from '../utilities/callOrReturn.js'\n\n/**\n * Build an paste rule that adds a mark when the\n * matched text is pasted into it.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\n */\nexport function markPasteRule(config: {\n find: PasteRuleFinder\n type: MarkType\n getAttributes?:\n | Record<string, any>\n | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>)\n | false\n | null\n}) {\n return new PasteRule({\n find: config.find,\n handler: ({ state, range, match, pasteEvent }) => {\n const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent)\n\n if (attributes === false || attributes === null) {\n return null\n }\n\n const { tr } = state\n const captureGroup = match[match.length - 1]\n const fullMatch = match[0]\n let markEnd = range.to\n\n if (captureGroup) {\n const startSpaces = fullMatch.search(/\\S/)\n const textStart = range.from + fullMatch.indexOf(captureGroup)\n const textEnd = textStart + captureGroup.length\n\n const excludedMarks = getMarksBetween(range.from, range.to, state.doc)\n .filter(item => {\n // @ts-ignore\n const excluded = item.mark.type.excluded as MarkType[]\n\n return excluded.find(type => type === config.type && type !== item.mark.type)\n })\n .filter(item => item.to > textStart)\n\n if (excludedMarks.length) {\n return null\n }\n\n if (textEnd < range.to) {\n tr.delete(textEnd, range.to)\n }\n\n if (textStart > range.from) {\n tr.delete(range.from + startSpaces, textStart)\n }\n\n markEnd = range.from + startSpaces + captureGroup.length\n\n tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}))\n\n tr.removeStoredMark(config.type)\n }\n },\n })\n}\n","import type { NodeType } from '@blockslides/pm/model'\n\nimport type { PasteRuleFinder } from '../PasteRule.js'\nimport { PasteRule } from '../PasteRule.js'\nimport type { ExtendedRegExpMatchArray, JSONContent } from '../types.js'\nimport { callOrReturn } from '../utilities/index.js'\n\n/**\n * Build an paste rule that adds a node when the\n * matched text is pasted into it.\n * @see https://tiptap.dev/docs/editor/api/paste-rules\n */\nexport function nodePasteRule(config: {\n find: PasteRuleFinder\n type: NodeType\n getAttributes?:\n | Record<string, any>\n | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record<string, any>)\n | false\n | null\n getContent?: JSONContent[] | ((attrs: Record<string, any>) => JSONContent[]) | false | null\n}) {\n return new PasteRule({\n find: config.find,\n handler({ match, chain, range, pasteEvent }) {\n const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent)\n const content = callOrReturn(config.getContent, undefined, attributes)\n\n if (attributes === false || attributes === null) {\n return null\n }\n\n const node = { type: config.type.name, attrs: attributes } as JSONContent\n\n if (content) {\n node.content = content\n }\n\n if (match.input) {\n chain().deleteRange(range).insertContentAt(range.from, node)\n }\n },\n })\n}\n","import type { PasteRuleFinder } from '../PasteRule.js'\nimport { PasteRule } from '../PasteRule.js'\n\n/**\n * Build an paste rule that replaces text when the\n * matched text is pasted into it.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\n */\nexport function textPasteRule(config: { find: PasteRuleFinder; replace: string }) {\n return new PasteRule({\n find: config.find,\n handler: ({ state, range, match }) => {\n let insert = config.replace\n let start = range.from\n const end = range.to\n\n if (match[1]) {\n const offset = match[0].lastIndexOf(match[1])\n\n insert += match[0].slice(offset + match[1].length)\n start += offset\n\n const cutOff = start - end\n\n if (cutOff > 0) {\n insert = match[0].slice(offset - cutOff, offset) + insert\n start = end\n }\n }\n\n state.tr.insertText(insert, start, end)\n },\n })\n}\n","import type { Transaction } from '@blockslides/pm/state'\n\nexport interface TrackerResult {\n position: number\n deleted: boolean\n}\n\nexport class Tracker {\n transaction: Transaction\n\n currentStep: number\n\n constructor(transaction: Transaction) {\n this.transaction = transaction\n this.currentStep = this.transaction.steps.length\n }\n\n map(position: number): TrackerResult {\n let deleted = false\n\n const mappedPosition = this.transaction.steps.slice(this.currentStep).reduce((newPosition, step) => {\n const mapResult = step.getMap().mapResult(newPosition)\n\n if (mapResult.deleted) {\n deleted = true\n }\n\n return mapResult.pos\n }, position)\n\n return {\n position: mappedPosition,\n deleted,\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAAA;AAAA,EAAA;AAAA;AAAA;AAAA,cAAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AO,IAAI,UAAU;AAAA,IACnB,MAAM,OAAO;AAAA,IACb,SAAS,CAAC,EAAE,OAAO,OAAO,MAAM,MAAM;AACpC,UAAI,SAAS,OAAO;AACpB,UAAI,QAAQ,MAAM;AAClB,YAAM,MAAM,MAAM;AAElB,UAAI,MAAM,CAAC,GAAG;AACZ,cAAM,SAAS,MAAM,CAAC,EAAE,YAAY,MAAM,CAAC,CAAC;AAE5C,kBAAU,MAAM,CAAC,EAAE,MAAM,SAAS,MAAM,CAAC,EAAE,MAAM;AACjD,iBAAS;AAET,cAAM,SAAS,QAAQ;AAEvB,YAAI,SAAS,GAAG;AACd,mBAAS,MAAM,CAAC,EAAE,MAAM,SAAS,QAAQ,MAAM,IAAI;AACnD,kBAAQ;AAAA,QACV;AAAA,MACF;AAEA,YAAM,GAAG,WAAW,QAAQ,OAAO,GAAG;AAAA,IACxC;AAAA,EACF,CAAC;AACH;;;AC1BO,IAAM,UAAN,MAAc;AAAA,EAKnB,YAAY,aAA0B;AACpC,SAAK,cAAc;AACnB,SAAK,cAAc,KAAK,YAAY,MAAM;AAAA,EAC5C;AAAA,EAEA,IAAI,UAAiC;AACnC,QAAI,UAAU;AAEd,UAAM,iBAAiB,KAAK,YAAY,MAAM,MAAM,KAAK,WAAW,EAAE,OAAO,CAAC,aAAa,SAAS;AAClG,YAAM,YAAY,KAAK,OAAO,EAAE,UAAU,WAAW;AAErD,UAAI,UAAU,SAAS;AACrB,kBAAU;AAAA,MACZ;AAEA,aAAO,UAAU;AAAA,IACnB,GAAG,QAAQ;AAEX,WAAO;AAAA,MACL,UAAU;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":["Fragment","Node","command","run","originalCreateParagraphNear","import_commands","originalDeleteSelection","import_commands","originalExitCode","import_state","mark","import_state","import_state","import_model","ProseMirrorNode","import_state","import_transform","isTextSelection","import_commands","originalJoinUp","originalJoinDown","originalJoinBackward","originalJoinForward","import_transform","import_transform","import_commands","originalCommand","import_commands","originalCommand","import_commands","isActive","originalLift","import_commands","originalLiftEmptyBlock","originalLiftListItem","import_commands","originalNewlineInCode","import_state","import_commands","originalSelectNodeBackward","import_commands","originalSelectNodeForward","import_commands","originalSelectParentNode","import_commands","originalSelectTextblockEnd","import_commands","originalSelectTextblockStart","document","import_transform","import_model","import_model","import_model","style","_a","import_model","import_model","node","output","range","import_state","import_commands","import_state","import_state","import_schema_list","originalSinkListItem","import_state","import_transform","first","import_model","import_state","import_transform","newNextTypeAttributes","nextType","import_transform","isActive","isActive","isActive","import_commands","originalWrapIn","import_schema_list","originalWrapInList","import_state","import_model","import_state","import_model","import_state","run","from","to","import_state","range","import_transform","_a","_b","_c","import_state","import_state","import_state","import_state","tr","import_state","import_state","style","focus","blur","import_transform","Fragment","import_state","parseAttributes","serializeAttributes","h","parseAttributes","serializeAttributes","h","parseAttributes","serializeAttributes","h","nextIndent","h","Node","import_state"]}