{"version":3,"file":"index.cjs","names":["liftTarget","originalCreateParagraphNear","TextSelection","TextSelection","originalExitCode","TextSelection","TextSelection","Selection","TextSelection","Fragment","Schema","DOMParser","ReplaceStep","ReplaceAroundStep","Selection","Fragment","originalJoinUp","originalJoinDown","originalJoinBackward","originalJoinForward","joinPoint","joinPoint","originalCommand","originalCommand","originalLift","originalLiftEmptyBlock","originalLiftListItem","originalNewlineInCode","AllSelection","originalSelectNodeBackward","originalSelectNodeForward","originalSelectParentNode","originalSelectTextblockEnd","originalSelectTextblockStart","Transform","DOMSerializer","Schema","Node","DOMParser","Node","NodeSelection","fragment","setBlockType","NodeSelection","TextSelection","originalSinkListItem","NodeSelection","canSplit","TextSelection","Fragment","Slice","TextSelection","canSplit","canJoin","TextSelection","PluginKey","originalWrapIn","originalWrapInList","DecorationSet","DecorationSet","DecorationSet","Plugin","DecorationSet","NodeSelection","defaultParseAttributes","defaultSerializeAttributes","parseAttributes","serializeAttributes","defaultParseAttributes","defaultSerializeAttributes","parseAttributes","serializeAttributes","run","Plugin","Fragment","Plugin","Fragment","keymap","Plugin","PluginKey","commands","RemoveMarkStep","Plugin","PluginKey","Plugin","PluginKey","PluginKey","Plugin","Selection","Plugin","PluginKey","Plugin","PluginKey","Plugin","PluginKey","Plugin","PluginKey","ReplaceStep","Fragment","EditorState","EditorView","PMDecoration","findWrapping","canJoin","NodeSelection"],"sources":["../src/helpers/createChainableState.ts","../src/CommandManager.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/utilities/isRegExp.ts","../src/utilities/objectIncludes.ts","../src/helpers/getMarkRange.ts","../src/helpers/getMarkType.ts","../src/commands/extendMarkRange.ts","../src/commands/first.ts","../src/helpers/isTextSelection.ts","../src/utilities/minMax.ts","../src/helpers/resolveFocusPosition.ts","../src/utilities/isAndroid.ts","../src/utilities/isiOS.ts","../src/utilities/isSafari.ts","../src/commands/focus.ts","../src/commands/forEach.ts","../src/commands/insertContent.ts","../src/utilities/elementFromString.ts","../src/helpers/isProseMirrorContent.ts","../src/helpers/createNodeFromContent.ts","../src/helpers/isFragment.ts","../src/helpers/selectionToInsertionEnd.ts","../src/commands/insertContentAt.ts","../src/helpers/defaultBlockAt.ts","../src/commands/insertDefaultBlock.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/helpers/isNodeActive.ts","../src/commands/lift.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/findChildren.ts","../src/helpers/findChildrenInRange.ts","../src/helpers/findParentNodeClosestToPos.ts","../src/helpers/findParentNode.ts","../src/helpers/getExtensionField.ts","../src/helpers/flattenExtensions.ts","../src/helpers/getHTMLFromFragment.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/helpers/getSchemaByResolvedExtensions.ts","../src/utilities/findDuplicates.ts","../src/helpers/sortExtensions.ts","../src/helpers/resolveExtensions.ts","../src/helpers/getSchema.ts","../src/helpers/generateHTML.ts","../src/helpers/generateJSON.ts","../src/helpers/getTextBetween.ts","../src/helpers/getText.ts","../src/helpers/getTextSerializersFromSchema.ts","../src/helpers/generateText.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/getPreviousBlockSibling.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/isNodeViewSelected.ts","../src/helpers/isProseMirrorStep.ts","../src/helpers/isProseMirrorAddMarkStep.ts","../src/helpers/isProseMirrorAddNodeMarkStep.ts","../src/helpers/isProseMirrorAttrStep.ts","../src/helpers/isProseMirrorCellSelection.ts","../src/helpers/isProseMirrorDocAttrStep.ts","../src/helpers/isProseMirrorFragment.ts","../src/helpers/isProseMirrorNodeSelection.ts","../src/helpers/isProseMirrorRemoveMarkStep.ts","../src/helpers/isProseMirrorRemoveNodeMarkStep.ts","../src/helpers/isProseMirrorReplaceAroundStep.ts","../src/helpers/isProseMirrorReplaceStep.ts","../src/helpers/isProseMirrorSlice.ts","../src/helpers/isProseMirrorStepResult.ts","../src/helpers/MappablePosition.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/setTextDirection.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/unsetTextDirection.ts","../src/commands/updateAttributes.ts","../src/decorations/constants.ts","../src/commands/updateDecorations.ts","../src/commands/wrapIn.ts","../src/commands/wrapInList.ts","../src/commands/index.ts","../src/decorations/decorationApplyScope.ts","../src/EventEmitter.ts","../src/utilities/isDev.ts","../src/decorations/helpers/decorationsToPMDecorations.ts","../src/decorations/helpers/buildDecorationSet.ts","../src/decorations/helpers/rangeOwnsPosition.ts","../src/decorations/helpers/filterOutOfRangeDecorations.ts","../src/decorations/helpers/widgetKeyOf.ts","../src/decorations/helpers/findDuplicateWidgetKeys.ts","../src/decorations/helpers/isAttrStep.ts","../src/decorations/helpers/hasResolvableChangedRange.ts","../src/decorations/helpers/getRebuildRanges.ts","../src/decorations/helpers/mapDecorationSet.ts","../src/decorations/helpers/mapDecorations.ts","../src/decorations/helpers/mergeDecorationSets.ts","../src/decorations/helpers/unionWidgetKeys.ts","../src/decorations/helpers/validateDecorationSpec.ts","../src/decorations/helpers/shouldRecomputeDecoration.ts","../src/decorations/DecorationManager.ts","../src/utilities/attrsEqual.ts","../src/utilities/canInsertNode.ts","../src/utilities/createStyleTag.ts","../src/utilities/escapeForRegEx.ts","../src/utilities/getStyleProperty.ts","../src/utilities/htmlEntities.ts","../src/utilities/isFirefox.ts","../src/utilities/isNumber.ts","../src/utilities/isPlainObject.ts","../src/utilities/isString.ts","../src/utilities/markdown/tokenizeAttributes.ts","../src/utilities/markdown/parseAttributes.ts","../src/utilities/markdown/serializeAttributes.ts","../src/utilities/markdown/createAtomBlockMarkdownSpec.ts","../src/utilities/markdown/createBlockMarkdownSpec.ts","../src/utilities/markdown/parseShortcodeAttributes.ts","../src/utilities/markdown/createInlineMarkdownSpec.ts","../src/utilities/markdown/parseIndentedBlocks.ts","../src/utilities/markdown/renderNestedMarkdownContent.ts","../src/utilities/markdown/index.ts","../src/utilities/marksEqual.ts","../src/utilities/mergeDeep.ts","../src/MarkView.ts","../src/InputRule.ts","../src/Extendable.ts","../src/Mark.ts","../src/PasteRule.ts","../src/ExtensionManager.ts","../src/Extension.ts","../src/extensions/clipboardTextSerializer.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/extensions/textDirection.ts","../src/extensions/index.ts","../src/helpers/warnOnDuplicatedProseMirrorModel.ts","../src/NodePos.ts","../src/style.ts","../src/Editor.ts","../src/decorations/Decoration.ts","../src/decorations/createWidgetDecoration.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/lib/ResizableNodeView.ts","../src/Node.ts","../src/NodeView.ts","../src/pasteRules/markPasteRule.ts","../src/pasteRules/nodePasteRule.ts","../src/pasteRules/textPasteRule.ts","../src/Tracker.ts"],"sourcesContent":["import type { EditorState, Transaction } from '@tiptap/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: {\n  transaction: Transaction\n  state: EditorState\n}): 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 '@tiptap/pm/state'\n\nimport type { Editor } from './Editor.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(startTr?: Transaction, shouldDispatch = true): 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  /**\n   * Creates a chain that safely returns `false` when run.\n   * @returns A non-dispatching command chain.\n   * @example\n   * const chain = CommandManager.createFakeChain()\n   * chain.focus().run() // false\n   */\n  public static createFakeChain(): ChainedCommands {\n    const chain = new Proxy(\n      {},\n      {\n        get: (_target, property) => {\n          if (property === 'then') {\n            return undefined\n          }\n\n          if (property === 'run') {\n            return () => false\n          }\n\n          return () => chain\n        },\n      },\n    ) 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 [name, (...args: never[]) => command(...args)({ ...props, dispatch: undefined })]\n      }),\n    ) as unknown as SingleCommands\n\n    return {\n      ...formattedCommands,\n      chain: () => this.createChain(tr, dispatch),\n    } as CanCommands\n  }\n\n  /**\n   * Creates capability checks that safely return `false`.\n   * @returns A non-dispatching capability checker.\n   * @example\n   * const can = CommandManager.createFallbackCan()\n   * can.focus() // false\n   */\n  public static createFallbackCan(): CanCommands {\n    const chain = CommandManager.createFakeChain()\n    const can = new Proxy(\n      {\n        chain: () => chain,\n      },\n      {\n        get: (target, property) => {\n          if (property === 'then') {\n            return undefined\n          }\n\n          if (property === 'chain') {\n            return target.chain\n          }\n\n          return () => false\n        },\n      },\n    ) as CanCommands\n\n    return can\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","import type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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        // Browsers should remove the caret on blur but safari does not.\n        // See: https://github.com/ueberdosis/tiptap/issues/2405\n        window?.getSelection()?.removeAllRanges()\n      }\n    })\n\n    return true\n  }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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 '@tiptap/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(\n        `There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`,\n      )\n    }\n\n    return schema.nodes[nameOrType]\n  }\n\n  return nameOrType\n}\n","import type { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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 type { ResolvedPos, Schema } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\n/**\n * Check if a node has text content based on its content specification.\n * Returns true if the node's content spec matches text* or text+ patterns.\n */\nconst hasTextContent = (nodeSpec: { content?: string }): boolean => {\n  if (!nodeSpec.content) {\n    return false\n  }\n  const textRegex = /^text(\\*|\\+)/\n  return textRegex.test(nodeSpec.content)\n}\n\n/**\n * Expand selection position for a specific side (left or right) to handle inline text nodes.\n * This function checks if the position is within an inline node with text content and\n * expands it to include the entire node boundaries for proper deletion.\n * @param $pos - The resolved position to expand\n * @param schema - The ProseMirror schema\n * @param side - Which side to expand ('left' or 'right')\n * @returns The expanded position for deletion\n */\nconst expandSelectionForSide = (\n  $pos: ResolvedPos,\n  schema: Schema,\n  side: 'left' | 'right',\n): number => {\n  if (!$pos.parent.isInline) {\n    return $pos.pos\n  }\n\n  if ((side === 'left' && $pos.pos > $pos.start()) || (side === 'right' && $pos.pos < $pos.end())) {\n    return $pos.pos\n  }\n\n  const parentContent = schema.nodes[$pos.parent.type.name].spec\n  if (!hasTextContent(parentContent)) {\n    return $pos.pos\n  }\n\n  return side === 'left' ? $pos.start() - 1 : $pos.end() + 1\n}\n\n/**\n * Expand selection range to properly handle deletion of inline text nodes.\n * Inline text nodes don't collapse correctly when text inside is deleted,\n * so we need to expand the selection to include the entire node.\n * See: https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1365\n */\nconst expandSelectionForInlineText = (\n  $from: ResolvedPos,\n  $to: ResolvedPos,\n  schema: Schema,\n): { from: number; to: number } => {\n  const from = expandSelectionForSide($from, schema, 'left')\n  const to = expandSelectionForSide($to, schema, 'right')\n\n  return { from, to }\n}\n\ndeclare module '@tiptap/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    if (state.selection.empty) {\n      return false\n    }\n\n    if (dispatch) {\n      const tr = state.tr\n      const { ranges } = state.selection\n      const mapFrom = tr.steps.length\n\n      ranges.forEach(range => {\n        const mapping = tr.mapping.slice(mapFrom)\n        const $from = tr.doc.resolve(mapping.map(range.$from.pos))\n        const $to = tr.doc.resolve(mapping.map(range.$to.pos))\n        const { from, to } = expandSelectionForInlineText($from, $to, state.schema)\n        tr.deleteRange(from, to)\n      })\n\n      // after deleting the selection we restore a text selection\n      // near the from position to avoid having confusing selections\n      // after the deletion (for example after deleting via Ctrl/Cmd+A)\n      if (!tr.selection.empty) {\n        tr.setSelection(TextSelection.near(tr.doc.resolve(tr.selection.from)))\n      }\n\n      tr.scrollIntoView()\n      dispatch(tr)\n    }\n\n    return true\n  }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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","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 '@tiptap/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(\n  marks: ProseMirrorMark[],\n  type: MarkType,\n  attributes: Record<string, any> = {},\n): 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 attributes of the first mark with the given type\n  if (!attributes) {\n    const firstMark = start.node.marks.find(mark => mark.type === type)\n    if (firstMark) {\n      attributes = firstMark.attrs\n    }\n  }\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 (\n    startIndex > 0 &&\n    isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)\n  ) {\n    startIndex -= 1\n    startPos -= $pos.parent.child(startIndex).nodeSize\n  }\n\n  while (\n    endIndex < $pos.parent.childCount &&\n    isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)\n  ) {\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 '@tiptap/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(\n        `There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`,\n      )\n    }\n\n    return schema.marks[nameOrType]\n  }\n\n  return nameOrType\n}\n","import type { MarkType } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\n\nimport { getMarkRange } from '../helpers/getMarkRange.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 to match against.\n       * If not provided, only the first mark at the position will be matched.\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","import type { Command, CommandProps, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/state'\n\nexport function isTextSelection(value: unknown): value is TextSelection {\n  return value instanceof TextSelection\n}\n","export function minMax(value = 0, min = 0, max = 0): number {\n  return Math.min(Math.max(value, min), max)\n}\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Selection, TextSelection } from '@tiptap/pm/state'\n\nimport type { FocusPosition } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\nexport function resolveFocusPosition(\n  doc: ProseMirrorNode,\n  position: FocusPosition = null,\n): 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(\n      doc,\n      minMax(0, minPos, maxPos),\n      minMax(doc.content.size, minPos, maxPos),\n    )\n  }\n\n  return TextSelection.create(\n    doc,\n    minMax(position, minPos, maxPos),\n    minMax(position, minPos, maxPos),\n  )\n}\n","export function isAndroid(): boolean {\n  return ['Android'].includes(navigator.platform) || /android/i.test(navigator.userAgent)\n}\n","export function isiOS(): boolean {\n  return (\n    ['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(\n      navigator.platform,\n    ) ||\n    // iPad on iOS 13 detection\n    (navigator.userAgent.includes('Mac') && 'ontouchend' in document)\n  )\n}\n","/**\n * Detects if the current browser is Safari (but not iOS Safari or Chrome).\n * @returns `true` if the browser is Safari, `false` otherwise.\n * @example\n * if (isSafari()) {\n *   // Safari-specific handling\n * }\n */\nexport function isSafari(): boolean {\n  return typeof navigator !== 'undefined'\n    ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent)\n    : false\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'\nimport { isSafari } from '../utilities/isSafari.js'\n\ndeclare module '@tiptap/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      // Safari requires preventScroll to avoid the browser scrolling to the\n      // top of the editor when focus is called before the selection is set.\n      // We exclude iOS and Android since they are already handled above.\n      // see: https://github.com/ueberdosis/tiptap/issues/7318\n      if (isSafari() && !isiOS() && !isAndroid()) {\n        ;(view.dom as HTMLElement).focus({ preventScroll: true })\n      }\n\n      // For React we have to focus asynchronously. Otherwise wild things happen.\n      // see: https://github.com/ueberdosis/tiptap/issues/1520\n      requestAnimationFrame(() => {\n        if (!editor.isDestroyed) {\n          view.focus()\n\n          if (options?.scrollIntoView) {\n            editor.commands.scrollIntoView()\n          }\n        }\n      })\n    }\n\n    try {\n      if ((view.hasFocus() && position === null) || position === false) {\n        return true\n      }\n    } catch {\n      // if view.hasFocus fails (view not mounted yet)\n      // we will return false because there's nothing to focus\n      return false\n    }\n\n    // we don’t try to resolve a NodeSelection or CellSelection\n    if (dispatch && position === null && !isTextSelection(editor.state.selection)) {\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 = 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 '@tiptap/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 '@tiptap/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 '@tiptap/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(\n      { from: tr.selection.from, to: tr.selection.to },\n      value,\n      options,\n    )\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(\n      '[tiptap error]: there is no window object available, so this function cannot be used',\n    )\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 { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model'\n\n/**\n * Checks whether a value is already a ProseMirror node or fragment. Looks for the\n * `nodesBetween` method, because `instanceof` fails when prosemirror-model is loaded twice.\n * @param value Any value that could be passed as content\n * @returns True for a node or a fragment, false for JSON, HTML and everything else\n * @example ```js\n * isProseMirrorContent(editor.state.doc)\n * ```\n */\nexport function isProseMirrorContent(value: unknown): value is ProseMirrorNode | Fragment {\n  return typeof (value as ProseMirrorNode | Fragment | undefined)?.nodesBetween === 'function'\n}\n","import type { Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'\nimport { DOMParser, Fragment, Schema } from '@tiptap/pm/model'\n\nimport type { Content } from '../types.js'\nimport { elementFromString } from '../utilities/elementFromString.js'\nimport { isProseMirrorContent } from './isProseMirrorContent.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 (isProseMirrorContent(content)) {\n    return content\n  }\n\n  const isJSONContent = typeof content === 'object' && content !== null\n\n  options = {\n    slice: true,\n    parseOptions: {},\n    ...options,\n  }\n\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('[tiptap error]: Invalid JSON content', { cause: error as Error })\n      }\n\n      console.warn('[tiptap 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(\n          elementFromString(content),\n          options.parseOptions,\n        )\n      } else {\n        DOMParser.fromSchema(contentCheckSchema).parse(\n          elementFromString(content),\n          options.parseOptions,\n        )\n      }\n\n      if (options.errorOnInvalidContent && hasInvalidContent) {\n        throw new Error('[tiptap 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","import type { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model'\n\n/**\n * Checks whether a node or fragment is a fragment. Looks for a missing `type` field,\n * because `instanceof` fails when prosemirror-model is loaded twice.\n * @param nodeOrFragment A ProseMirror node or fragment\n * @returns True for a fragment, false for a node\n * @example ```js\n * isFragment(editor.state.doc.content)\n * ```\n */\nexport function isFragment(nodeOrFragment: ProseMirrorNode | Fragment): nodeOrFragment is Fragment {\n  return !('type' in nodeOrFragment)\n}\n","import type { Transaction } from '@tiptap/pm/state'\nimport { Selection } from '@tiptap/pm/state'\nimport { ReplaceAroundStep, ReplaceStep } from '@tiptap/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 type { Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'\nimport { Fragment } from '@tiptap/pm/model'\n\nimport { createNodeFromContent } from '../helpers/createNodeFromContent.js'\nimport { isFragment } from '../helpers/isFragment.js'\nimport { isProseMirrorContent } from '../helpers/isProseMirrorContent.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 '@tiptap/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\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 (\n        !options.errorOnInvalidContent &&\n        !editor.options.enableContentCheck &&\n        editor.options.emitContentError\n      ) {\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'\n          ? { from: position, to: position }\n          : { from: position.from, to: position.to }\n\n      let isOnlyTextContent = true\n      let isOnlyBlockContent = true\n      const nodes: readonly ProseMirrorNode[] = isFragment(content) ? 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(item => item.text || '').join('')\n        } else if (isProseMirrorContent(value)) {\n          newContent = nodes.map(node => node.text ?? '').join('')\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 = Fragment.from(nodes)\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 && isOnlyBlockContent) {\n          from = Math.max(0, from - 1)\n        }\n\n        tr.replaceWith(from, to, nodes)\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 { ContentMatch, NodeType } from '@tiptap/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, Fragment, ResolvedPos } from '@tiptap/pm/model'\n\nimport { createNodeFromContent } from '../helpers/createNodeFromContent.js'\nimport { defaultBlockAt } from '../helpers/defaultBlockAt.js'\nimport { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd.js'\nimport type { Content, RawCommands } from '../types.js'\n\nexport interface InsertDefaultBlockOptions {\n  /**\n   * The position to insert the block at.\n   * Accepts a number or a resolved ProseMirror position.\n   * Defaults to the current caret position.\n   */\n  pos?: number | ResolvedPos\n\n  /**\n   * Attributes to apply to the inserted node.\n   * Only attributes that match the node's schema will be applied.\n   */\n  attrs?: Record<string, any>\n\n  /**\n   * Content to insert into the block.\n   * Accepts string (plain text or HTML), ProseMirror node, or Fragment.\n   */\n  content?: Content | ProseMirrorNode | Fragment\n\n  /**\n   * Whether to update the selection after inserting the content.\n   * @default true\n   */\n  updateSelection?: boolean\n}\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    insertDefaultBlock: {\n      /**\n       * Insert a default content block at the given position.\n       * Returns false when the default block can't be inserted at that position.\n       * @example editor.commands.insertDefaultBlock()\n       * @example editor.commands.insertDefaultBlock({ pos: 5, content: 'Hello' })\n       */\n      insertDefaultBlock: (options?: InsertDefaultBlockOptions) => ReturnType\n    }\n  }\n}\n\nexport const insertDefaultBlock: RawCommands['insertDefaultBlock'] =\n  (options = {}) =>\n  ({ tr, dispatch, editor }) => {\n    const { pos, attrs, content, updateSelection = true } = options\n\n    let $pos: ResolvedPos\n\n    if (typeof pos === 'number') {\n      $pos = tr.doc.resolve(pos)\n    } else if (pos) {\n      $pos = pos\n    } else {\n      $pos = tr.selection.$from\n    }\n\n    const defaultType = defaultBlockAt($pos.parent.contentMatchAt($pos.index()))\n\n    if (!defaultType) {\n      return false\n    }\n\n    const validAttrKeys = Object.keys(defaultType.spec.attrs || {})\n    const filteredAttrs = attrs\n      ? Object.fromEntries(Object.entries(attrs).filter(([key]) => validAttrKeys.includes(key)))\n      : {}\n\n    let node: ProseMirrorNode | null | undefined\n\n    if (content) {\n      const parsed = createNodeFromContent(content, editor.schema)\n      node = defaultType.createAndFill(filteredAttrs, parsed)\n    } else {\n      node = defaultType.createAndFill(filteredAttrs)\n    }\n\n    if (!node) {\n      return false\n    }\n\n    if (dispatch) {\n      tr.insert($pos.pos, node)\n\n      if (updateSelection) {\n        selectionToInsertionEnd(tr, tr.steps.length - 1, -1)\n      }\n    }\n\n    return true\n  }\n","import {\n  joinBackward as originalJoinBackward,\n  joinDown as originalJoinDown,\n  joinForward as originalJoinForward,\n  joinUp as originalJoinUp,\n} from '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/transform'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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 type { NodeType } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/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 { lift as originalLift } from '@tiptap/pm/commands'\nimport type { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 { liftEmptyBlock as originalLiftEmptyBlock } from '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/model'\nimport { liftListItem as originalLiftListItem } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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(\n  obj: Record<string, any>,\n  propOrProps: string | string[],\n): 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 '@tiptap/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 '@tiptap/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: (\n        typeOrName: string | NodeType | MarkType,\n        attributes: string | string[],\n      ) => 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    let canReset = false\n\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          canReset = true\n\n          if (dispatch) {\n            tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes))\n          }\n        }\n\n        if (markType && node.marks.length) {\n          node.marks.forEach(mark => {\n            if (markType === mark.type) {\n              canReset = true\n\n              if (dispatch) {\n                tr.addMark(\n                  pos,\n                  pos + node.nodeSize,\n                  markType.create(deleteProps(mark.attrs, attributes)),\n                )\n              }\n            }\n          })\n        }\n      })\n    })\n\n    return canReset\n  }\n","import type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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 '@tiptap/pm/model'\n\nimport { createDocument } from '../helpers/createDocument.js'\nimport { isFragment } from '../helpers/isFragment.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 '@tiptap/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        const nodes = isFragment(document) ? document.content : [document]\n\n        tr.replaceWith(0, doc.content.size, nodes).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 '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/pm/state'\n\nimport { getMarkType } from './getMarkType.js'\n\nexport function getMarkAttributes(\n  state: EditorState,\n  typeOrName: string | MarkType,\n): 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 '@tiptap/pm/model'\nimport type { Transaction } from '@tiptap/pm/state'\nimport { Transform } from '@tiptap/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(\n  oldDoc: ProseMirrorNode,\n  transactions: Transaction[],\n): 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 { Node as ProseMirrorNode } from '@tiptap/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 '@tiptap/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(\n  node: ProseMirrorNode,\n  range: Range,\n  predicate: Predicate,\n): 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 '@tiptap/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 '@tiptap/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 Tiptap 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']>(\n          extension,\n          'addExtensions',\n          context,\n        )\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 type { Fragment, Schema } from '@tiptap/pm/model'\nimport { DOMSerializer } from '@tiptap/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","// oxlint-disable-next-lineno-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>(\n  value: T,\n  context: any = undefined,\n  ...props: any[]\n): 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(\n    extension => extension.type === 'extension',\n  ) 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  // Precompute lists of extension types for global attribute resolution\n  const nodeExtensionTypes = nodeExtensions.filter(ext => ext.name !== 'text').map(ext => ext.name)\n  const markExtensionTypes = markExtensions.map(ext => ext.name)\n  const allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes]\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      // Resolve the types based on the string shorthand or explicit array\n      let resolvedTypes: string[]\n      if (Array.isArray(globalAttribute.types)) {\n        resolvedTypes = globalAttribute.types\n      } else if (globalAttribute.types === '*') {\n        resolvedTypes = allExtensionTypes\n      } else if (globalAttribute.types === 'nodes') {\n        resolvedTypes = nodeExtensionTypes\n      } else if (globalAttribute.types === 'marks') {\n        resolvedTypes = markExtensionTypes\n      } else {\n        resolvedTypes = []\n      }\n\n      resolvedTypes.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<\n      NodeConfig['addAttributes'] | MarkConfig['addAttributes']\n    >(extension, 'addAttributes', context)\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","/** Splits a CSS style string into declarations, ignoring semicolons inside quotes/parentheses. */\nfunction splitStyleDeclarations(styles: string): string[] {\n  const result: string[] = []\n\n  let current = ''\n  let inSingleQuote = false\n  let inDoubleQuote = false\n  let parenDepth = 0\n\n  const length = styles.length\n  for (let i = 0; i < length; i += 1) {\n    const char = styles[i]\n    if (char === \"'\" && !inDoubleQuote) {\n      inSingleQuote = !inSingleQuote\n      current += char\n      continue\n    }\n    if (char === '\"' && !inSingleQuote) {\n      inDoubleQuote = !inDoubleQuote\n      current += char\n      continue\n    }\n    if (!inSingleQuote && !inDoubleQuote) {\n      if (char === '(') {\n        parenDepth += 1\n        current += char\n        continue\n      }\n      if (char === ')' && parenDepth > 0) {\n        parenDepth -= 1\n        current += char\n        continue\n      }\n      if (char === ';' && parenDepth === 0) {\n        result.push(current)\n        current = ''\n        continue\n      }\n    }\n    current += char\n  }\n  if (current) {\n    result.push(current)\n  }\n\n  return result\n}\n\n/** Yields property/value pairs from a style string. */\nfunction parseStyleEntries(styles: string | undefined): [property: string, value: string][] {\n  const pairs: [string, string][] = []\n\n  const declarations = splitStyleDeclarations(styles || '')\n  const numDeclarations = declarations.length\n\n  for (let i = 0; i < numDeclarations; i += 1) {\n    const declaration = declarations[i]\n\n    const firstColonIndex = declaration.indexOf(':')\n    if (firstColonIndex === -1) {\n      continue\n    }\n\n    const property = declaration.slice(0, firstColonIndex).trim()\n    const value = declaration.slice(firstColonIndex + 1).trim()\n    if (property && value) {\n      pairs.push([property, value])\n    }\n  }\n\n  return pairs\n}\n\nexport 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        // Define a data property so untrusted input cannot change the merged object's prototype.\n        if (key === '__proto__') {\n          Object.defineProperty(mergedAttributes, key, {\n            configurable: true,\n            enumerable: true,\n            value,\n            writable: true,\n          })\n\n          return\n        }\n\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]\n            ? mergedAttributes[key].split(' ')\n            : []\n\n          const insertClasses = valueClasses.filter(\n            valueClass => !existingClasses.includes(valueClass),\n          )\n\n          mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ')\n        } else if (key === 'style') {\n          const styleMap = new Map([\n            ...parseStyleEntries(mergedAttributes[key]),\n            ...parseStyleEntries(value),\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 '@tiptap/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 '@tiptap/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","import type { MarkSpec, NodeSpec, TagParseRule } from '@tiptap/pm/model'\nimport { Schema } from '@tiptap/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 * Builds an attribute spec tuple for ProseMirror schema from an extension attribute.\n * @param extensionAttribute The extension attribute to build the spec for\n * @returns A tuple of [attributeName, spec]\n */\nfunction buildAttributeSpec(\n  extensionAttribute: ReturnType<typeof getAttributesFromExtensions>[number],\n): [string, Record<string, any>] {\n  const spec: Record<string, any> = {}\n\n  // Only include 'default' if the attribute is not required and default is set on the attribute\n  if (\n    !extensionAttribute?.attribute?.isRequired &&\n    'default' in (extensionAttribute?.attribute || {})\n  ) {\n    spec.default = extensionAttribute.attribute.default\n  }\n\n  // Only include 'validate' if it's defined\n  if (extensionAttribute?.attribute?.validate !== undefined) {\n    spec.validate = extensionAttribute.attribute.validate\n  }\n\n  return [extensionAttribute.name, spec]\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(\n        attribute => attribute.type === extension.name,\n      )\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']>(\n          e,\n          'extendNodeSchema',\n          context,\n        )\n\n        return {\n          ...fields,\n          ...(extendNodeSchema ? extendNodeSchema(extension) : {}),\n        }\n      }, {})\n\n      const schema: NodeSpec = cleanUpSchemaItem({\n        ...extraNodeFields,\n        content: callOrReturn(\n          getExtensionField<NodeConfig['content']>(extension, 'content', context),\n        ),\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(\n          getExtensionField<NodeConfig['selectable']>(extension, 'selectable', context),\n        ),\n        draggable: callOrReturn(\n          getExtensionField<NodeConfig['draggable']>(extension, 'draggable', context),\n        ),\n        code: callOrReturn(getExtensionField<NodeConfig['code']>(extension, 'code', context)),\n        whitespace: callOrReturn(\n          getExtensionField<NodeConfig['whitespace']>(extension, 'whitespace', context),\n        ),\n        linebreakReplacement: callOrReturn(\n          getExtensionField<NodeConfig['linebreakReplacement']>(\n            extension,\n            'linebreakReplacement',\n            context,\n          ),\n        ),\n        defining: callOrReturn(\n          getExtensionField<NodeConfig['defining']>(extension, 'defining', context),\n        ),\n        isolating: callOrReturn(\n          getExtensionField<NodeConfig['isolating']>(extension, 'isolating', context),\n        ),\n        attrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec)),\n      })\n\n      const parseHTML = callOrReturn(\n        getExtensionField<NodeConfig['parseHTML']>(extension, 'parseHTML', context),\n      )\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']>(\n        extension,\n        'renderHTML',\n        context,\n      )\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']>(\n        extension,\n        'renderText',\n        context,\n      )\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(\n        attribute => attribute.type === extension.name,\n      )\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']>(\n          e,\n          'extendMarkSchema',\n          context,\n        )\n\n        return {\n          ...fields,\n          ...(extendMarkSchema ? extendMarkSchema(extension as any) : {}),\n        }\n      }, {})\n\n      const schema: MarkSpec = cleanUpSchemaItem({\n        ...extraMarkFields,\n        inclusive: callOrReturn(\n          getExtensionField<MarkConfig['inclusive']>(extension, 'inclusive', context),\n        ),\n        excludes: callOrReturn(\n          getExtensionField<MarkConfig['excludes']>(extension, 'excludes', context),\n        ),\n        group: callOrReturn(getExtensionField<MarkConfig['group']>(extension, 'group', context)),\n        spanning: callOrReturn(\n          getExtensionField<MarkConfig['spanning']>(extension, 'spanning', context),\n        ),\n        code: callOrReturn(getExtensionField<MarkConfig['code']>(extension, 'code', context)),\n        attrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec)),\n      })\n\n      const parseHTML = callOrReturn(\n        getExtensionField<MarkConfig['parseHTML']>(extension, 'parseHTML', context),\n      )\n\n      if (parseHTML) {\n        schema.parseDOM = parseHTML.map(parseRule =>\n          injectExtensionAttributesToParseRule(parseRule, extensionAttributes),\n        )\n      }\n\n      const renderHTML = getExtensionField<MarkConfig['renderHTML']>(\n        extension,\n        'renderHTML',\n        context,\n      )\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","/**\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 Tiptap extensions\n * @returns An flattened and sorted array of Tiptap 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      `[tiptap 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 '@tiptap/pm/model'\n\nimport type { Editor } from '../Editor.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 { Node } from '@tiptap/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 { DOMParser } from '@tiptap/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 type { Node as ProseMirrorNode } from '@tiptap/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) // oxlint-disable-line\n    }\n  })\n\n  return text\n}\n","import type { Node as ProseMirrorNode } from '@tiptap/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 '@tiptap/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 { Node } from '@tiptap/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, NodeType } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/pm/state'\n\nimport { getNodeType } from './getNodeType.js'\n\nexport function getNodeAttributes(\n  state: EditorState,\n  typeOrName: string | NodeType,\n): 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 '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/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(\n  state: EditorState,\n  typeOrName: string | NodeType | MarkType,\n): 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 '@tiptap/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 '@tiptap/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 '@tiptap/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 '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/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 = (\n  state: EditorState,\n  typeOrName: string | NodeType,\n  pos: number,\n  maxDepth = 20,\n) => {\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 { Node, ResolvedPos } from '@tiptap/pm/model'\n\n/**\n * Returns the block-level sibling immediately before the cursor's textblock\n * (or null when the cursor is at the first child of its block parent).\n *\n * The position does not have to sit inside a textblock: for any resolved\n * position, the result is the sibling immediately before `$pos.parent`. At a\n * GapCursor position this is the sibling before the whole container, not the\n * node before the gap.\n *\n * @param $pos The resolved position to look around\n * @returns The previous block-level sibling, or null\n * @example ```js\n * // Cursor in a top-level paragraph after a list:\n * // <ul><li>A</li></ul><p>|B</p>\n * getPreviousBlockSibling($from) // <ul>\n *\n * // Cursor in the second paragraph of a list item:\n * // <ul><li><p>A</p><p>|B</p></li></ul>\n * getPreviousBlockSibling($from) // <p>A</p>\n *\n * // Cursor in the first child of its block parent:\n * // <doc><p>|A</p></doc>\n * getPreviousBlockSibling($from) // null\n * ```\n */\nexport const getPreviousBlockSibling = ($pos: ResolvedPos): Node | null => {\n  const parentDepth = $pos.depth - 1\n  if (parentDepth < 0) return null\n\n  const index = $pos.index(parentDepth)\n  if (index === 0) return null\n\n  return $pos.node(parentDepth).child(index - 1)\n}\n","import type { MarkType, NodeType, Schema } from '@tiptap/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 '@tiptap/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(\n    Math.max(0, sliceEndPos - maxMatch),\n    sliceEndPos,\n    (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 +=\n        node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos))\n    },\n  )\n\n  return textBefore\n}\n","import type { MarkType } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/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      // ignore selected text inside nodes whose schema disallows this mark type\n      if (type && node.inlineContent && !node.type.allowsMarkType(type)) {\n        return false\n      }\n\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 '@tiptap/pm/state'\n\nimport { getSchemaTypeNameByName } from './getSchemaTypeNameByName.js'\nimport { isMarkActive } from './isMarkActive.js'\nimport { isNodeActive } from './isNodeActive.js'\n\nexport function isActive(\n  state: EditorState,\n  name: string | null,\n  attributes: Record<string, any> = {},\n): 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 '@tiptap/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 '@tiptap/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 '@tiptap/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/.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 '@tiptap/pm/state'\n\nexport function isNodeSelection(value: unknown): value is NodeSelection {\n  return value instanceof NodeSelection\n}\n","import type { Selection } from '@tiptap/pm/state'\n\nimport { isTextSelection } from './isTextSelection.js'\n\n/**\n * Determines whether a node view should be considered selected for the given\n * editor selection.\n *\n * A node is considered selected when the current selection fully covers it\n * (e.g. a `NodeSelection`). When `selectedOnTextSelection` is enabled, the\n * node is additionally considered selected if a `TextSelection` is fully\n * contained within the node's range.\n *\n * @param selection The current editor selection.\n * @param pos The start position of the node in the document.\n * @param nodeSize The size of the node.\n * @param selectedOnTextSelection When `true`, also treat selections inside the node as selected.\n * @returns `true` if the node view should render as selected.\n */\nexport function isNodeViewSelected({\n  selection,\n  pos,\n  nodeSize,\n  selectedOnTextSelection = false,\n}: {\n  selection: Selection\n  pos: number\n  nodeSize: number\n  selectedOnTextSelection?: boolean\n}): boolean {\n  const { from, to } = selection\n\n  if (from <= pos && to >= pos + nodeSize) {\n    return true\n  }\n\n  if (selectedOnTextSelection && isTextSelection(selection) && from > pos && to < pos + nodeSize) {\n    return true\n  }\n\n  return false\n}\n","import { type Step } from '@tiptap/pm/transform'\n\n/**\n * Checks if a value is a ProseMirror step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror Step\n * @example ```js\n * isProseMirrorStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorStep(value: unknown): value is Step {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (\n    typeof step.apply !== 'function' ||\n    typeof step.getMap !== 'function' ||\n    typeof step.invert !== 'function' ||\n    typeof step.map !== 'function' ||\n    typeof step.merge !== 'function' ||\n    typeof step.toJSON !== 'function'\n  ) {\n    return false\n  }\n\n  return true\n}\n","import { type AddMarkStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror add mark step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror AddMarkStep\n * @example ```js\n * isProseMirrorAddMarkStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorAddMarkStep(value: unknown): value is AddMarkStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is an add mark step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'addMark') {\n    return false\n  }\n\n  return true\n}\n","import { type AddNodeMarkStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror add node mark step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror AddNodeMarkStep\n * @example ```js\n * isProseMirrorAddNodeMarkStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorAddNodeMarkStep(value: unknown): value is AddNodeMarkStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is an add node mark step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'addNodeMark') {\n    return false\n  }\n\n  return true\n}\n","import { type AttrStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror attribute step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror AttrStep\n * @example ```js\n * isProseMirrorAttrStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorAttrStep(value: unknown): value is AttrStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is an attribute step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'attr') {\n    return false\n  }\n\n  return true\n}\n","import type { CellSelection } from '@tiptap/pm/tables'\n\n/**\n * Check whether a selection provides the cell-iteration API.\n *\n * @param selection - Selection to inspect.\n * @returns Whether the selection is a table cell selection.\n * @example ```js\n * isProseMirrorCellSelection(editor.state.selection)\n * ```\n */\nexport function isProseMirrorCellSelection(selection: unknown): selection is CellSelection {\n  if (selection === null || typeof selection !== 'object') {\n    return false\n  }\n\n  return 'forEachCell' in selection && typeof selection.forEachCell === 'function'\n}\n","import { type DocAttrStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror document attribute step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror DocAttrStep\n * @example ```js\n * isProseMirrorDocAttrStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorDocAttrStep(value: unknown): value is DocAttrStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is a document attribute step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'docAttr') {\n    return false\n  }\n\n  return true\n}\n","import { type Fragment } from '@tiptap/pm/model'\n\n/**\n * Checks if a value is a ProseMirror fragment by inspecting it\n * @param value The value to check\n * @returns - A boolean, if true the value is a ProseMirror fragment\n * @example ```js\n * isProseMirrorFragment(editor.state.doc.content)\n * ```\n */\nexport function isProseMirrorFragment(value: unknown): value is Fragment {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const fragment = value as Record<string, unknown>\n\n  if (\n    !Array.isArray(fragment.content) ||\n    typeof fragment.size !== 'number' ||\n    typeof fragment.nodesBetween !== 'function' ||\n    typeof fragment.descendants !== 'function' ||\n    typeof fragment.textBetween !== 'function' ||\n    typeof fragment.append !== 'function' ||\n    typeof fragment.cut !== 'function' ||\n    typeof fragment.eq !== 'function' ||\n    typeof fragment.child !== 'function' ||\n    typeof fragment.forEach !== 'function'\n  ) {\n    return false\n  }\n\n  return true\n}\n","import type { NodeSelection } from '@tiptap/pm/state'\n\n/**\n * Check whether a selection exposes a selected node.\n *\n * @param selection - Selection to inspect.\n * @returns Whether the selection is a node selection.\n * @example ```js\n * isProseMirrorNodeSelection(editor.state.selection)\n * ```\n */\nexport function isProseMirrorNodeSelection(selection: unknown): selection is NodeSelection {\n  if (selection === null || typeof selection !== 'object') {\n    return false\n  }\n\n  return 'node' in selection && selection.node != null\n}\n","import { type RemoveMarkStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror remove mark step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror RemoveMarkStep\n * @example ```js\n * isProseMirrorRemoveMarkStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorRemoveMarkStep(value: unknown): value is RemoveMarkStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is a remove mark step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'removeMark') {\n    return false\n  }\n\n  return true\n}\n","import { type RemoveNodeMarkStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror remove node mark step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror RemoveNodeMarkStep\n * @example ```js\n * isProseMirrorRemoveNodeMarkStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorRemoveNodeMarkStep(value: unknown): value is RemoveNodeMarkStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is a remove node mark step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'removeNodeMark') {\n    return false\n  }\n\n  return true\n}\n","import { type ReplaceAroundStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror replace around step\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror ReplaceAroundStep\n * @example ```js\n * isProseMirrorReplaceAroundStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorReplaceAroundStep(value: unknown): value is ReplaceAroundStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is a replace around step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'replaceAround') {\n    return false\n  }\n\n  return true\n}\n","import { type ReplaceStep } from '@tiptap/pm/transform'\nimport { isProseMirrorStep } from './isProseMirrorStep.js'\n\n/**\n * Checks if a value is a ProseMirror replace step result\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror ReplaceStep\n * @example ```js\n * isProseMirrorReplaceStep(transaction.steps[0])\n * ```\n */\nexport function isProseMirrorReplaceStep(value: unknown): value is ReplaceStep {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const step = value as Record<string, unknown>\n\n  if (!isProseMirrorStep(step)) {\n    return false\n  }\n\n  const json = step.toJSON()\n\n  // we use the steps jsonID to check if the step is a replace step\n  if (json === null || typeof json !== 'object' || json.stepType !== 'replace') {\n    return false\n  }\n\n  return true\n}\n","import { type Slice } from '@tiptap/pm/model'\nimport { isProseMirrorFragment } from './isProseMirrorFragment.js'\n\n/**\n * Checks if a value is a ProseMirror slice by inspecting it\n * @param value The value to check\n * @returns - A boolean, if true the value is a ProseMirror slice\n * @example ```js\n * isProseMirrorSlice(editor.state.doc.content.slice(0, 10))\n * ```\n */\nexport function isProseMirrorSlice(value: unknown): value is Slice {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const slice = value as Record<string, unknown>\n\n  const openStartIsNumber = Number.isInteger(slice.openStart) && (slice.openStart as number) >= 0\n  const openEndIsNumber = Number.isInteger(slice.openEnd) && (slice.openEnd as number) >= 0\n  const sliceHasRequiredProperties =\n    typeof slice.size === 'number' &&\n    typeof slice.eq === 'function' &&\n    typeof slice.toJSON === 'function'\n\n  if (!openStartIsNumber || !openEndIsNumber || !sliceHasRequiredProperties) {\n    return false\n  }\n\n  const content = slice.content\n\n  if (content === null || typeof content !== 'object') {\n    return false\n  }\n\n  const fragment = content as Record<string, unknown>\n\n  if (!isProseMirrorFragment(fragment)) {\n    return false\n  }\n\n  return true\n}\n","import { type StepResult } from '@tiptap/pm/transform'\n\n/**\n * Checks if a value is a ProseMirror step result\n * @param value The value to check\n * @returns - A boolean, if the boolean is true the value is a ProseMirror StepResult\n * @example ```js\n * isProseMirrorStepResult(step.apply(editor.state.doc))\n * ```\n */\nexport function isProseMirrorStepResult(value: unknown): value is StepResult {\n  if (value === null || typeof value !== 'object') {\n    return false\n  }\n\n  const result = value as Record<string, unknown>\n\n  const isValidDoc = result.doc !== null && typeof result.doc === 'object' && result.failed === null\n  const isValidFailed = typeof result.failed === 'string' && result.doc === null\n\n  if (!isValidDoc && !isValidFailed) {\n    return false\n  }\n\n  return true\n}\n","import type { Transaction } from '@tiptap/pm/state'\nimport type { MapResult } from '@tiptap/pm/transform'\n\n/**\n * A class that represents a mappable position in the editor. It can be extended\n * by other extensions to add additional position mapping capabilities.\n */\nexport class MappablePosition {\n  /**\n   * The absolute position in the editor.\n   */\n  public position: number\n\n  constructor(position: number) {\n    this.position = position\n  }\n\n  /**\n   * Creates a MappablePosition from a JSON object.\n   */\n  static fromJSON(json: any): MappablePosition {\n    return new MappablePosition(json.position)\n  }\n\n  /**\n   * Converts the MappablePosition to a JSON object.\n   */\n  toJSON(): any {\n    return {\n      position: this.position,\n    }\n  }\n}\n\n/**\n * The result of the getUpdatedPosition function.\n */\nexport interface GetUpdatedPositionResult {\n  position: MappablePosition\n  mapResult: MapResult | null\n}\n\n/**\n * Calculates the new position after applying a transaction.\n *\n * @returns The new mappable position and the map result.\n */\nexport function getUpdatedPosition(\n  position: MappablePosition,\n  transaction: Transaction,\n): GetUpdatedPositionResult {\n  const mapResult = transaction.mapping.mapResult(position.position)\n  return {\n    position: new MappablePosition(mapResult.pos),\n    mapResult,\n  }\n}\n\n/**\n * Creates a MappablePosition from a position number. This is the default\n * implementation for Tiptap core. It can be overridden by other Tiptap\n * extensions.\n *\n * @param position The position (as a number) where the MappablePosition will be created.\n * @returns A new MappablePosition instance at the given position.\n */\nexport function createMappablePosition(position: number): MappablePosition {\n  return new MappablePosition(position)\n}\n","import type { EditorView } from '@tiptap/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 '@tiptap/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      if (mark === null || mark === undefined) {\n        // Drop malformed (nullish) mark entries instead of crashing\n        return false\n      }\n\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(value => {\n        if (value === null || value === undefined) {\n          // Drop malformed (nullish) content entries instead of crashing\n          return null\n        }\n\n        return 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 '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/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 '@tiptap/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) ||\n        !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\n        ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType)\n        : 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) ||\n          !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 '@tiptap/pm/state'\n\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/commands'\nimport type { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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('[tiptap 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 '@tiptap/pm/state'\n\nimport type { RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@tiptap/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 type { Range, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    setTextDirection: {\n      /**\n       * Set the text direction for nodes.\n       * If no position is provided, it will use the current selection.\n       * @param direction The text direction to set ('ltr', 'rtl', or 'auto')\n       * @param position Optional position or range to apply the direction to\n       * @example editor.commands.setTextDirection('rtl')\n       * @example editor.commands.setTextDirection('ltr', { from: 0, to: 10 })\n       */\n      setTextDirection: (direction: 'ltr' | 'rtl' | 'auto', position?: number | Range) => ReturnType\n    }\n  }\n}\n\nexport const setTextDirection: RawCommands['setTextDirection'] =\n  (direction, position) =>\n  ({ tr, state, dispatch }) => {\n    const { selection } = state\n    let from: number\n    let to: number\n\n    if (typeof position === 'number') {\n      from = position\n      to = position\n    } else if (position && 'from' in position && 'to' in position) {\n      from = position.from\n      to = position.to\n    } else {\n      from = selection.from\n      to = selection.to\n    }\n\n    if (dispatch) {\n      tr.doc.nodesBetween(from, to, (node, pos) => {\n        if (node.isText) {\n          return\n        }\n\n        tr.setNodeMarkup(pos, undefined, {\n          ...node.attrs,\n          dir: direction,\n        })\n      })\n    }\n\n    return true\n  }\n","import { TextSelection } from '@tiptap/pm/state'\n\nimport type { Range, RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@tiptap/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 } =\n        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 '@tiptap/pm/model'\nimport { sinkListItem as originalSinkListItem } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/state'\nimport { NodeSelection, TextSelection } from '@tiptap/pm/state'\nimport { canSplit } from '@tiptap/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 =\n    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 '@tiptap/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(\n      extensionAttributes,\n      $from.node().type.name,\n      $from.node().attrs,\n    )\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 =\n      $from.depth === 0\n        ? undefined\n        : 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 (\n      !types &&\n      !can &&\n      canSplit(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : undefined)\n    ) {\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 '@tiptap/pm/model'\nimport { Fragment, Slice } from '@tiptap/pm/model'\nimport { TextSelection } from '@tiptap/pm/state'\nimport { canSplit } from '@tiptap/pm/transform'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { getSplittedAttributes } from '../helpers/getSplittedAttributes.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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: (\n        typeOrName: string | NodeType,\n        overrideAttrs?: Record<string, any>,\n      ) => 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    // oxlint-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 (\n        $from.depth === 2 ||\n        $from.node(-3).type !== type ||\n        $from.index(-2) !== $from.node(-2).childCount - 1\n      ) {\n        return false\n      }\n\n      if (dispatch) {\n        let wrap = Fragment.empty\n        // oxlint-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          // oxlint-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 =\n          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 '@tiptap/pm/model'\nimport type { Transaction } from '@tiptap/pm/state'\nimport { TextSelection } from '@tiptap/pm/state'\nimport { canJoin } from '@tiptap/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\n/**\n * Normalise a list type attribute for comparison.\n * Treats null, undefined, and \"1\" as equivalent (the default numeric type).\n */\nfunction normalizeListType(type: string | null | undefined): string | null {\n  return !type || type === '1' ? null : type\n}\n\n/**\n * Check if two list type attributes are compatible for joining.\n * Lists can only join when they have the same type (both default, or both the same non-default type).\n */\nfunction areListTypesCompatible(\n  typeA: string | null | undefined,\n  typeB: string | null | undefined,\n): boolean {\n  return normalizeListType(typeA) === normalizeListType(typeB)\n}\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  // Don't join if the type attributes are incompatible\n  // (e.g. a default-type list should not merge with a type=\"a\" list)\n  if (!areListTypesCompatible(list.node.attrs.type, nodeBefore?.attrs.type)) {\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  // Don't join if the type attributes are incompatible\n  if (!areListTypesCompatible(list.node.attrs.type, nodeAfter?.attrs.type)) {\n    return true\n  }\n\n  tr.join(after)\n\n  return true\n}\n\ndeclare module '@tiptap/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\nfunction createInnerSelectionForWholeDocList(tr: Transaction) {\n  const doc = tr.doc\n  const list = doc.firstChild\n\n  if (!list) {\n    return null\n  }\n\n  // Place the selection inside the list node so that ProseMirror's\n  // liftListItem command can operate. AllSelection sits at the doc root.\n  // Use TextSelection.between to resolve positions into valid inline\n  // content positions, so the selection survives position mapping after\n  // liftListItem removes list/item wrappers.\n  const $start = doc.resolve(1)\n  const $end = doc.resolve(list.nodeSize - 1)\n\n  return TextSelection.between($start, $end)\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    // When the user presses Ctrl/Cmd+A, ProseMirror creates an `AllSelection`\n    // covering the entire document (0..doc.content.size). In that case\n    // `findParentNode` cannot detect the surrounding list because the\n    // selection sits at the document root. If the document consists of a\n    // single top-level list node, treat that list as the active list so the\n    // toggle logic can correctly lift or change it.\n    const isAllSelection = selection.from === 0 && selection.to === state.doc.content.size\n    const topLevelNodes = state.doc.content.content\n    const soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null\n    const allSelectionList =\n      isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions)\n        ? {\n            node: soleTopLevelNode,\n            pos: 0,\n            depth: 0,\n          }\n        : null\n\n    const currentList = parentList ?? allSelectionList\n\n    const isInsideExistingList =\n      !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1\n\n    const hasWholeDocSelectedList = !!allSelectionList\n    if ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {\n      // remove list\n      if (currentList.node.type === listType) {\n        if (isAllSelection && hasWholeDocSelectedList) {\n          return chain()\n            .command(({ tr: trx, dispatch: disp }) => {\n              // Ctrl/Cmd+A creates an AllSelection at the document root.\n              // When the whole document is a single top-level list, normalize the\n              // selection into that list before lifting, since liftListItem expects\n              // a selection inside a list item.\n              const nextSelection = createInnerSelectionForWholeDocList(trx)\n\n              if (!nextSelection) {\n                return false\n              }\n\n              trx.setSelection(nextSelection)\n\n              if (disp) {\n                disp(trx)\n              }\n\n              return true\n            })\n            .liftListItem(itemType)\n            .run()\n        }\n\n        return commands.liftListItem(itemType)\n      }\n\n      // change list type\n      if (\n        isList(currentList.node.type.name, extensions) &&\n        listType.validContent(currentList.node.content)\n      ) {\n        return chain()\n          .command(() => {\n            tr.setNodeMarkup(currentList.pos, listType)\n\n            return true\n          })\n          .command(() => joinListBackwards(tr, listType))\n          .command(() => joinListForwards(tr, listType))\n          .run()\n      }\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            if (canWrapInList) {\n              return true\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          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 '@tiptap/pm/model'\n\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { isMarkActive } from '../helpers/isMarkActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/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      // oxlint-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 '@tiptap/core' {\n  interface Commands<ReturnType> {\n    unsetAllMarks: {\n      /**\n       * Remove all clearable marks in the current selection.\n       * Marks with `clearable: false` are preserved\n       * @param options.ignoreClearable If true, removes all marks regardless of `clearable` setting. Defaults to `false`.\n       * @example editor.commands.unsetAllMarks()\n       * @example editor.commands.unsetAllMarks({ ignoreClearable: true })\n       */\n      unsetAllMarks: (options?: { ignoreClearable?: boolean }) => ReturnType\n    }\n  }\n}\n\nexport const unsetAllMarks: RawCommands['unsetAllMarks'] =\n  (options = {}) =>\n  ({ tr, dispatch, editor }) => {\n    const { ignoreClearable = false } = options\n    const { selection } = tr\n    const { empty, ranges } = selection\n\n    if (empty) {\n      return true\n    }\n\n    const { nonClearableMarks } = editor.extensionManager\n\n    if (dispatch) {\n      const clearableMarkTypes = Object.values(editor.schema.marks).filter(\n        markType => ignoreClearable || !nonClearableMarks.includes(markType.name),\n      )\n\n      ranges.forEach(range => {\n        for (const markType of clearableMarkTypes) {\n          tr.removeMark(range.$from.pos, range.$to.pos, markType)\n        }\n      })\n    }\n\n    return true\n  }\n","import type { MarkType } from '@tiptap/pm/model'\n\nimport { getMarkRange } from '../helpers/getMarkRange.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 { Range, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    unsetTextDirection: {\n      /**\n       * Remove the text direction attribute from nodes.\n       * If no position is provided, it will use the current selection.\n       * @param position Optional position or range to remove the direction from\n       * @example editor.commands.unsetTextDirection()\n       * @example editor.commands.unsetTextDirection({ from: 0, to: 10 })\n       */\n      unsetTextDirection: (position?: number | Range) => ReturnType\n    }\n  }\n}\n\nexport const unsetTextDirection: RawCommands['unsetTextDirection'] =\n  position =>\n  ({ tr, state, dispatch }) => {\n    const { selection } = state\n    let from: number\n    let to: number\n\n    if (typeof position === 'number') {\n      from = position\n      to = position\n    } else if (position && 'from' in position && 'to' in position) {\n      from = position.from\n      to = position.to\n    } else {\n      from = selection.from\n      to = selection.to\n    }\n\n    if (dispatch) {\n      tr.doc.nodesBetween(from, to, (node, pos) => {\n        if (node.isText) {\n          return\n        }\n\n        const newAttrs = { ...node.attrs }\n\n        delete newAttrs.dir\n\n        tr.setNodeMarkup(pos, undefined, newAttrs)\n      })\n    }\n\n    return true\n  }\n","import type { Mark, MarkType, Node, NodeType } from '@tiptap/pm/model'\nimport type { SelectionRange } from '@tiptap/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 '@tiptap/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    let canUpdate = false\n\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            canUpdate = true\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            canUpdate = true\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              canUpdate = true\n\n              if (dispatch) {\n                tr.setNodeMarkup(pos, undefined, {\n                  ...node.attrs,\n                  ...attributes,\n                })\n              }\n            }\n\n            if (markType && node.marks.length) {\n              node.marks.forEach((mark: Mark) => {\n                if (markType === mark.type) {\n                  canUpdate = true\n\n                  if (dispatch) {\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\n      if (lastNode) {\n        if (lastPos !== undefined && dispatch) {\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 && dispatch) {\n              tr.addMark(\n                trimmedFrom,\n                trimmedTo,\n                markType.create({\n                  ...mark.attrs,\n                  ...attributes,\n                }),\n              )\n            }\n          })\n        }\n      }\n    })\n\n    return canUpdate\n  }\n","import { PluginKey } from '@tiptap/pm/state'\nimport { DecorationManagerState } from './types.js'\n\nexport const DECORATION_MANAGER_PLUGIN_KEY_NAME = '__tiptap_decorations__'\nexport const DECORATION_MANAGER_PLUGIN_KEY = new PluginKey<DecorationManagerState>(\n  DECORATION_MANAGER_PLUGIN_KEY_NAME,\n)\n","import { DECORATION_MANAGER_PLUGIN_KEY } from '../decorations/constants.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    updateDecorations: {\n      /**\n       * Force declarative decorations to recompute, bypassing each extension's\n       * `shouldUpdate` gate. Pass an extension name to recompute only that\n       * extension's decorations, or omit it to recompute all of them.\n       * @param extensionName The name of the extension to recompute (optional).\n       * @example editor.commands.updateDecorations()\n       * @example editor.commands.updateDecorations('myExtension')\n       */\n      updateDecorations: (extensionName?: string) => ReturnType\n    }\n  }\n}\n\nexport const updateDecorations: RawCommands['updateDecorations'] =\n  extensionName =>\n  ({ tr, dispatch }) => {\n    if (dispatch) {\n      tr.setMeta(DECORATION_MANAGER_PLUGIN_KEY, { type: 'force', name: extensionName })\n    }\n\n    return true\n  }\n","import { wrapIn as originalWrapIn } from '@tiptap/pm/commands'\nimport type { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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 '@tiptap/pm/model'\nimport { wrapInList as originalWrapInList } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport type { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/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","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 './insertDefaultBlock.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 './setTextDirection.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 './unsetTextDirection.js'\nexport * from './updateAttributes.js'\nexport * from './updateDecorations.js'\nexport * from './wrapIn.js'\nexport * from './wrapInList.js'\n","/**\n * Tracks which editors are running decoration create() callbacks inside state.apply,\n * using a private WeakMap to keep this off the public Editor surface.\n */\nconst depthByEditor = new WeakMap<object, number>()\n\n/**\n * Marks callback as decoration-apply work for editor, so editor.state can warn\n * about stale reads. Counts depth to handle nested applies.\n *\n * @param editor The editor the decorations belong to\n * @param callback The work to run inside the scope\n * @returns Whatever `callback` returns\n * @example\n * runInDecorationApplyScope(editor, () => spec.create({ editor, state, view }))\n */\nexport function runInDecorationApplyScope<T>(editor: object, callback: () => T): T {\n  depthByEditor.set(editor, (depthByEditor.get(editor) ?? 0) + 1)\n\n  try {\n    return callback()\n  } finally {\n    const remaining = (depthByEditor.get(editor) ?? 1) - 1\n\n    if (remaining > 0) {\n      depthByEditor.set(editor, remaining)\n    } else {\n      depthByEditor.delete(editor)\n    }\n  }\n}\n\n/**\n * Whether the editor is currently inside a decoration apply scope.\n *\n * @param editor The editor to check\n * @returns `true` while decoration create() callbacks run\n * @example\n * if (isInDecorationApplyScope(editor)) {\n *   // reads of editor.state are stale here\n * }\n */\nexport function isInDecorationApplyScope(editor: object): boolean {\n  return depthByEditor.has(editor)\n}\n","type StringKeyOf<T> = Extract<keyof T, string>\ntype CallbackType<\n  T extends Record<string, any>,\n  EventName extends StringKeyOf<T>,\n> = T[EventName] extends any[] ? T[EventName] : [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>>(\n    event: EventName,\n    fn: CallbackFunction<T, EventName>,\n  ): 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>>(\n    event: EventName,\n    ...args: CallbackType<T, EventName>\n  ): 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>>(\n    event: EventName,\n    fn?: CallbackFunction<T, EventName>,\n  ): 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>>(\n    event: EventName,\n    fn: CallbackFunction<T, EventName>,\n  ): 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","// Core has no node types and can run unbundled in the browser, where `process`\n// is missing. The `typeof` check keeps that case from throwing, and the inline\n// `process.env.NODE_ENV` lets bundlers fold this to `false` and strip dev-only\n// warnings from production builds.\ndeclare const process: { env: { NODE_ENV?: string } } | undefined\n\n/**\n * Whether the editor runs in a development build. Use it to guard warnings so\n * bundlers can drop them from production output.\n */\nexport const isDev: boolean =\n  typeof process !== 'undefined' && process.env.NODE_ENV !== 'production'\n","import { Decoration as PMDecoration } from '@tiptap/pm/view'\n\nimport type { Decoration, WidgetDecoration } from '../Decoration.js'\n\nfunction isWidgetDecoration(decoration: Decoration): decoration is WidgetDecoration {\n  return decoration.kind === 'widget'\n}\n\n/**\n * Converts a list of decorations to ProseMirror decorations.\n * @param decorations The decorations to convert.\n * @param extensionName The name of the extension that created the decorations.\n * @returns The converted decorations and the widget keys.\n */\nexport function decorationsToPMDecorations(\n  decorations: Decoration[],\n  extensionName?: string,\n): {\n  decorations: PMDecoration[]\n  widgetKeys: Set<string>\n} {\n  const pmDecorations: PMDecoration[] = []\n  const widgetKeys = new Set<string>()\n\n  for (const decoration of decorations) {\n    if (decoration.kind === 'widget') {\n      if (isWidgetDecoration(decoration)) {\n        widgetKeys.add(decoration.key)\n      }\n    }\n\n    pmDecorations.push(decoration.toPMDecoration(extensionName))\n  }\n\n  return { decorations: pmDecorations, widgetKeys }\n}\n","import type { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport type { Decoration } from '../Decoration.js'\nimport { decorationsToPMDecorations } from './decorationsToPMDecorations.js'\n\n/**\n * Builds a DecorationSet from a list of decorations.\n * @param doc The document to build the decoration set for.\n * @param decorations The decorations to build the set from.\n * @param extensionName The name of the extension that created the decorations.\n * @returns The built decoration set and the widget keys.\n */\nexport function buildDecorationSet(\n  doc: Node,\n  decorations: Decoration[],\n  extensionName?: string,\n): { set: DecorationSet; widgetKeys: Set<string> } {\n  const { decorations: pmDecorations, widgetKeys } = decorationsToPMDecorations(\n    decorations,\n    extensionName,\n  )\n\n  return { set: DecorationSet.create(doc, pmDecorations), widgetKeys }\n}\n","export interface RangeOwnsPositionOptions {\n  position: number\n  from: number\n  to: number\n  /** `doc.content.size` of the document the range was computed against. */\n  docSize: number\n}\n\n/**\n * Whether the block range `[from, to)` owns a decoration at `position`.\n *\n * `to` is the next block's start, so that block owns it. The last block is the\n * exception: nothing follows it, so it owns the end of the document.\n *\n * @param options The position, the range, and the document size.\n * @returns True when the range owns the position.\n * @example\n * // <p>foo</p><p>bar</p>, blocks [0, 5] and [5, 10]\n * rangeOwnsPosition({ position: 5, from: 0, to: 5, docSize: 10 }) // false, block 2 owns it\n * rangeOwnsPosition({ position: 5, from: 5, to: 10, docSize: 10 }) // true\n * rangeOwnsPosition({ position: 10, from: 5, to: 10, docSize: 10 }) // true, end of document\n */\nexport function rangeOwnsPosition({\n  position,\n  from,\n  to,\n  docSize,\n}: RangeOwnsPositionOptions): boolean {\n  if (position < from) {\n    return false\n  }\n\n  if (position < to) {\n    return true\n  }\n\n  return position === to && to === docSize\n}\n","import type { Decoration } from '../Decoration.js'\nimport { rangeOwnsPosition } from './rangeOwnsPosition.js'\n\nexport interface FilterOutOfRangeDecorationsOptions {\n  decorations: Decoration[]\n  from: number\n  to: number\n  /** `doc.content.size` of the document the range was computed against. */\n  docSize: number\n  /** The extension that created the decorations, used in the warning. */\n  extensionName: string\n  /** Extensions already warned about, so a buggy one warns once per editor. */\n  warnedExtensions: Set<string>\n}\n\n/**\n * Filter decorations the block range `[from, to)` does not own.\n * Must match the stale sweep in `DecorationManager.rebuildRanges`.\n *\n * @param options The decorations, the range, and the warning bookkeeping.\n * @returns The filtered decorations.\n */\nexport function filterOutOfRangeDecorations({\n  decorations,\n  from,\n  to,\n  docSize,\n  extensionName,\n  warnedExtensions,\n}: FilterOutOfRangeDecorationsOptions): Decoration[] {\n  return decorations.filter(decoration => {\n    if (rangeOwnsPosition({ position: decoration.anchor, from, to, docSize })) {\n      return true\n    }\n\n    // The next block owns `to` and rebuilds it there, so this is a normal\n    // overlap from scanning the boundary, not an authoring mistake.\n    if (decoration.anchor === to) {\n      return false\n    }\n\n    if (!warnedExtensions.has(extensionName)) {\n      warnedExtensions.add(extensionName)\n      console.warn(\n        `[tiptap warn]: Extension \"${extensionName}\" returned a decoration outside the ` +\n          `requested range [${from}, ${to}). It was ignored.`,\n      )\n    }\n\n    return false\n  })\n}\n","import type { Decoration } from '@tiptap/pm/view'\n\n/**\n * Extracts the widget key from a decoration spec.\n * @param decoration The decoration to extract the key from.\n * @returns The widget key, or undefined if the decoration has no key.\n */\nexport function widgetKeyOf(decoration: Decoration): string | undefined {\n  const key = (decoration.spec as { key?: unknown } | undefined)?.key\n  return typeof key === 'string' ? key : undefined\n}\n","import type { DecorationSet } from '@tiptap/pm/view'\n\nimport { widgetKeyOf } from './widgetKeyOf.js'\n\nexport interface DuplicateWidgetKey {\n  key: string\n  extensions: Set<string>\n}\n\n/**\n * Finds widget keys which are still duplicated in the final decoration set.\n * @param decorationSet The merged decoration set to inspect.\n * @returns The duplicate keys and their producing extensions.\n */\nexport function findDuplicateWidgetKeys(decorationSet: DecorationSet): DuplicateWidgetKey[] {\n  const extensionsByKey = new Map<string, Set<string>>()\n  const counts = new Map<string, number>()\n\n  for (const decoration of decorationSet.find()) {\n    const key = widgetKeyOf(decoration)\n\n    if (!key) {\n      continue\n    }\n\n    const extension = (decoration.spec as { extensionName?: string }).extensionName ?? 'unknown'\n    const extensions = extensionsByKey.get(key) ?? new Set<string>()\n\n    extensions.add(extension)\n    extensionsByKey.set(key, extensions)\n    counts.set(key, (counts.get(key) ?? 0) + 1)\n  }\n\n  return Array.from(extensionsByKey, ([key, extensions]) => ({ key, extensions })).filter(\n    ({ key }) => (counts.get(key) ?? 0) > 1,\n  )\n}\n","import type { Step } from '@tiptap/pm/transform'\n\n/** `jsonID` is set on each step's prototype by `Step.jsonID`; not in the type defs. */\ntype StepWithId = Step & { jsonID?: string }\n\n/**\n * Whether a step only sets a node attribute.\n *\n * Matched by `jsonID` rather than `instanceof`, which fails when two copies of\n * prosemirror-transform are loaded.\n *\n * @param step The step to check.\n * @returns `true` for an `AttrStep`, which carries the target node's position.\n * @example\n * if (isAttrStep(step)) {\n *   rebuildBlockAt(step.pos)\n * }\n */\nexport function isAttrStep(step: Step): step is Step & { pos: number } {\n  return (step as StepWithId).jsonID === 'attr'\n}\n","import type { Step } from '@tiptap/pm/transform'\n\nimport { isAttrStep } from './isAttrStep.js'\n\n/**\n * Check if a step has a resolvable changed range.\n * @param step The step to check.\n * @returns True if the step has a resolvable changed range, false otherwise.\n */\nexport function hasResolvableChangedRange(step: Step): boolean {\n  let hasMappedRange = false\n\n  step.getMap().forEach(() => {\n    hasMappedRange = true\n  })\n\n  if (hasMappedRange || isAttrStep(step)) {\n    return true\n  }\n\n  const positionalStep = step as Step & { from?: unknown; to?: unknown }\n\n  return typeof positionalStep.from === 'number' && typeof positionalStep.to === 'number'\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { Transaction } from '@tiptap/pm/state'\n\nimport { getChangedRanges } from '../../helpers/getChangedRanges.js'\nimport type { Range } from '../../types.js'\nimport { hasResolvableChangedRange } from './hasResolvableChangedRange.js'\nimport { isAttrStep } from './isAttrStep.js'\n\nexport type RebuildRangeResolution = { type: 'ranges'; ranges: Range[] } | { type: 'full' }\n\n/**\n * Expands a changed range to the top-level blocks it touches. Blocks are\n * ordered, so the walk stops as soon as it passes the range.\n */\nfunction blockRangeFor(doc: Node, changed: Range): Range | null {\n  let from: number | null = null\n  let to = 0\n  let nodeStart = 0\n\n  for (let index = 0; index < doc.childCount; index += 1) {\n    if (nodeStart > changed.to) {\n      break\n    }\n\n    const nodeEnd = nodeStart + doc.child(index).nodeSize\n\n    // A block ending exactly at `changed.from` still owns decorations that\n    // span the boundary, so it counts as overlapping.\n    if (nodeEnd >= changed.from) {\n      if (from === null) {\n        from = nodeStart\n      }\n\n      to = nodeEnd\n    }\n\n    nodeStart = nodeEnd\n  }\n\n  return from === null ? null : { from, to }\n}\n\n/**\n * Returns the top-level block ranges to recompute after a transaction,\n * or `{ type: 'full' }` when the whole document must be rebuilt.\n * @param tr The transaction to inspect.\n * @param doc The new document after the transaction.\n * @returns The block ranges to recompute, or a full-recompute signal.\n */\nexport function getRebuildRanges(tr: Transaction, doc: Node): RebuildRangeResolution {\n  // If any step cannot be resolved, fall back to full recompute.\n  if (tr.steps.some(step => !hasResolvableChangedRange(step))) {\n    return { type: 'full' }\n  }\n\n  const newRanges: Range[] = getChangedRanges(tr).map(({ newRange }) => newRange)\n\n  // An AttrStep maps no position, so getChangedRanges misses it.\n  tr.steps.forEach((step, index) => {\n    if (!isAttrStep(step)) {\n      return\n    }\n\n    const mapping = tr.mapping.slice(index)\n\n    newRanges.push({ from: mapping.map(step.pos, -1), to: mapping.map(step.pos + 1) })\n  })\n\n  const ranges: Range[] = []\n\n  for (const newRange of newRanges) {\n    const blockRange = blockRangeFor(doc, newRange)\n\n    if (blockRange) {\n      ranges.push(blockRange)\n    }\n  }\n\n  ranges.sort((a, b) => a.from - b.from)\n\n  const merged: Range[] = []\n\n  // for each range, merge it with the previous range if it overlaps\n  for (const range of ranges) {\n    const last = merged[merged.length - 1]\n\n    // if the current range overlaps with the previous range, merge it\n    if (last && range.from <= last.to) {\n      last.to = Math.max(last.to, range.to)\n    } else {\n      merged.push({ ...range })\n    }\n  }\n\n  return { type: 'ranges', ranges: merged }\n}\n","import type { Mapping } from '@tiptap/pm/transform'\nimport type { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\ntype RemovedDecorationSpec = { key?: unknown } | undefined\n\n/**\n * Maps a decoration set through a mapping and prunes the keys of any widget\n * dropped because its position was deleted.\n * @param set The decoration set to map.\n * @param mapping The mapping to use.\n * @param doc The document to map the set through.\n * @param widgetKeys The set of widget keys to prune.\n * @returns The mapped decoration set.\n */\nexport function mapDecorationSet(\n  set: DecorationSet,\n  mapping: Mapping,\n  doc: Node,\n  widgetKeys: Set<string>,\n): DecorationSet {\n  return set.map(mapping, doc, {\n    onRemove: (removedSpec: RemovedDecorationSpec) => {\n      const key = removedSpec?.key\n\n      if (typeof key === 'string') {\n        widgetKeys.delete(key)\n      }\n    },\n  })\n}\n","import { DecorationSet } from '@tiptap/pm/view'\nimport type { Transaction } from '@tiptap/pm/state'\n\nimport type { DecorationManagerState } from '../types.js'\nimport { mapDecorationSet } from './mapDecorationSet.js'\n\n/**\n * Moves an extension's existing decorations to their new positions after a\n * transaction, and prunes widget keys for any widget whose position was deleted.\n * @param name The name of the decoration extension.\n * @param previous The previous decoration manager state.\n * @param tr The transaction to map through.\n * @returns The updated decoration set and widget keys.\n */\nexport function mapDecorations(\n  name: string,\n  previous: DecorationManagerState,\n  tr: Transaction,\n): { set: DecorationSet; widgetKeys: Set<string> } {\n  const previousSet = previous.decorationSetsByExtension[name] ?? DecorationSet.empty\n  const widgetKeys = new Set<string>(previous.widgetKeysByExtension[name] ?? [])\n\n  const set = mapDecorationSet(previousSet, tr.mapping, tr.doc, widgetKeys)\n\n  return { set, widgetKeys }\n}\n","import type { Node } from '@tiptap/pm/model'\nimport { DecorationSet } from '@tiptap/pm/view'\n\n/**\n * Merges multiple decoration sets into a single decoration set.\n * @param doc The document to merge the decoration sets for.\n * @param decorationSetsByExtension The decoration sets to merge.\n * @returns The merged decoration set.\n */\nexport function mergeDecorationSets(\n  doc: Node,\n  decorationSetsByExtension: Record<string, DecorationSet>,\n): DecorationSet {\n  const allDecorations = Object.values(decorationSetsByExtension).flatMap(set => set.find())\n  return DecorationSet.create(doc, allDecorations)\n}\n","/**\n * Unions all widget keys from multiple extensions into a single set.\n * @param widgetKeysByExtension The widget keys to union.\n * @returns The unioned widget keys.\n */\nexport function unionWidgetKeys(widgetKeysByExtension: Record<string, Set<string>>): Set<string> {\n  const merged = new Set<string>()\n  for (const keys of Object.values(widgetKeysByExtension)) {\n    for (const key of keys) {\n      merged.add(key)\n    }\n  }\n\n  return merged\n}\n","import type { DecorationSpec } from '../types.js'\n\n/**\n * Validates a decoration spec to ensure it follows the correct pattern for its update strategy.\n * @param name The name of the extension.\n * @param spec The decoration spec to validate\n */\nexport function validateDecorationSpec(name: string, spec: DecorationSpec): void {\n  const strategy = (spec as DecorationSpec & { update?: unknown }).update ?? 'document'\n\n  switch (strategy) {\n    case 'document':\n      if (spec.createInRange) {\n        throw new Error(\n          `[tiptap error]: Extension \"${name}\" provides createInRange() but does not use the ` +\n            '\"changedRanges\" decoration update strategy.',\n        )\n      }\n      return\n    case 'changedRanges':\n      if (!spec.createInRange) {\n        throw new Error(\n          `[tiptap error]: Extension \"${name}\" uses the \"changedRanges\" decoration update ` +\n            'strategy but does not provide createInRange().',\n        )\n      }\n      return\n    case 'manual':\n      if (spec.createInRange) {\n        throw new Error(\n          `[tiptap error]: Extension \"${name}\" uses the \"manual\" decoration update strategy, ` +\n            'which is not compatible with createInRange(). createInRange() requires the ' +\n            '\"changedRanges\" strategy.',\n        )\n      }\n      if (spec.shouldUpdate) {\n        throw new Error(\n          `[tiptap error]: Extension \"${name}\" cannot combine the \"manual\" decoration update ` +\n            'strategy with shouldUpdate().',\n        )\n      }\n      return\n    default:\n      throw new Error(\n        `[tiptap error]: Extension \"${name}\" uses an unknown decoration update strategy. ` +\n          'Expected \"document\", \"changedRanges\", or \"manual\".',\n      )\n  }\n}\n","import type { DecorationShouldUpdateProps, DecorationSpec } from '../types.js'\n\n/**\n * Decides whether a decoration spec should be recomputed for a transaction.\n * @param spec The decoration spec to check.\n * @param props Properties containing editor, transaction, and state.\n * @param forced Whether recomputation was forced.\n * @returns `true` if the decoration should be recomputed.\n */\nexport function shouldRecomputeDecoration(\n  spec: DecorationSpec,\n  props: DecorationShouldUpdateProps,\n  forced: boolean,\n): boolean {\n  if (forced) {\n    return true\n  }\n\n  if (spec.update === 'manual') {\n    return false\n  }\n\n  return spec.shouldUpdate ? spec.shouldUpdate(props) : props.tr.docChanged\n}\n","import type { Node } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport { Plugin } from '@tiptap/pm/state'\nimport type { EditorView } from '@tiptap/pm/view'\nimport { DecorationSet } from '@tiptap/pm/view'\n\nimport type { Editor } from '../Editor.js'\nimport type { Range } from '../types.js'\nimport { isDev } from '../utilities/isDev.js'\nimport { DECORATION_MANAGER_PLUGIN_KEY } from './constants.js'\nimport type { Decoration } from './Decoration.js'\nimport { runInDecorationApplyScope } from './decorationApplyScope.js'\nimport { buildDecorationSet } from './helpers/buildDecorationSet.js'\nimport { decorationsToPMDecorations } from './helpers/decorationsToPMDecorations.js'\nimport { filterOutOfRangeDecorations } from './helpers/filterOutOfRangeDecorations.js'\nimport { findDuplicateWidgetKeys } from './helpers/findDuplicateWidgetKeys.js'\nimport { getRebuildRanges } from './helpers/getRebuildRanges.js'\nimport { mapDecorations } from './helpers/mapDecorations.js'\nimport { mapDecorationSet } from './helpers/mapDecorationSet.js'\nimport { mergeDecorationSets } from './helpers/mergeDecorationSets.js'\nimport { rangeOwnsPosition } from './helpers/rangeOwnsPosition.js'\nimport { unionWidgetKeys } from './helpers/unionWidgetKeys.js'\nimport { validateDecorationSpec } from './helpers/validateDecorationSpec.js'\nimport { shouldRecomputeDecoration } from './helpers/shouldRecomputeDecoration.js'\nimport { widgetKeyOf } from './helpers/widgetKeyOf.js'\nimport type {\n  DecorationCreateProps,\n  DecorationManagerEntry,\n  DecorationManagerState,\n  DecorationMeta,\n  DecorationRangeProps,\n  DecorationSpec,\n  ResolvedDecorationEntry,\n} from './types.js'\nexport type { DecorationManagerEntry } from './types.js'\n\nconst EMPTY_KEYS: ReadonlySet<string> = new Set()\n\nexport function liveWidgetKeys(editor: Editor): ReadonlySet<string> {\n  return editor.extensionManager?.decorationManager?.liveWidgetKeys() ?? EMPTY_KEYS\n}\n\nexport class DecorationManager {\n  editor: Editor\n  entries: ResolvedDecorationEntry[]\n  plugin: Plugin<DecorationManagerState> | null\n  private warnedWidgetKeys = new Set<string>()\n  private warnedOutOfRangeExtensions = new Set<string>()\n  private readonly handleBeforeTransaction = ({ nextState }: { nextState: EditorState }) => {\n    const state = DECORATION_MANAGER_PLUGIN_KEY.getState(nextState)\n\n    if (state) {\n      this.warnDuplicateWidgetKeys(state)\n    }\n  }\n\n  constructor(options: { editor: Editor; entries: DecorationManagerEntry[] }) {\n    this.editor = options.editor\n    this.entries = this.resolveEntries(options.entries)\n    this.entries.forEach(({ name, spec }) => validateDecorationSpec(name, spec))\n    this.plugin = this.entries.length > 0 ? this.createPlugin() : null\n\n    this.editor.on('beforeTransaction', this.handleBeforeTransaction)\n  }\n\n  destroy(): void {\n    this.editor.off('beforeTransaction', this.handleBeforeTransaction)\n  }\n\n  /**\n   * Returns the set of live widget keys from all decoration extensions.\n   * @returns A readonly set of widget keys\n   */\n  liveWidgetKeys(): ReadonlySet<string> {\n    return DECORATION_MANAGER_PLUGIN_KEY.getState(this.editor.state)?.widgetKeys ?? EMPTY_KEYS\n  }\n\n  /**\n   * The mounted editor view, or `null` when destroyed. Decoration callbacks\n   * must never receive the placeholder view `editor.view` falls back to.\n   * @returns The mounted editor view, or `null`\n   */\n  private get mountedView(): EditorView | null {\n    return this.editor.isDestroyed ? null : this.editor.view\n  }\n\n  /**\n   * Resolves decoration entries by calling the addDecorations function for each extension entry.\n   * @param entries The decoration manager entries to resolve\n   * @returns An array of resolved decoration entries\n   */\n  private resolveEntries(entries: DecorationManagerEntry[]): ResolvedDecorationEntry[] {\n    const resolved: ResolvedDecorationEntry[] = []\n\n    for (const { name, addDecorations } of entries) {\n      const spec = addDecorations()\n\n      if (spec) {\n        resolved.push({ name, spec })\n      }\n    }\n\n    return resolved\n  }\n\n  /**\n   * Creates the ProseMirror plugin for managing decorations.\n   * @returns A ProseMirror plugin with state management\n   */\n  private createPlugin(): Plugin<DecorationManagerState> {\n    const { editor, entries } = this\n\n    return new Plugin<DecorationManagerState>({\n      key: DECORATION_MANAGER_PLUGIN_KEY,\n      state: {\n        init: (_config, state) => {\n          const decorationSetsByExtension: Record<string, DecorationSet> = {}\n          const widgetKeysByExtension: Record<string, Set<string>> = {}\n\n          for (const { name, spec } of entries) {\n            const { set, widgetKeys } = this.buildFullSet(name, spec, state)\n\n            decorationSetsByExtension[name] = set\n            widgetKeysByExtension[name] = widgetKeys\n          }\n\n          const managerState = {\n            decorationSetsByExtension,\n            widgetKeysByExtension,\n            mergedDecorationSet: this.buildMergedSet(state.doc, decorationSetsByExtension),\n            widgetKeys: unionWidgetKeys(widgetKeysByExtension),\n          }\n\n          this.warnDuplicateWidgetKeys(managerState)\n\n          return managerState\n        },\n        apply: (tr, previous, oldState, newState) => {\n          const meta = tr.getMeta(DECORATION_MANAGER_PLUGIN_KEY) as DecorationMeta | undefined\n          const forceAll = meta?.type === 'force' && !meta.name\n          const forceName = meta?.type === 'force' ? meta.name : undefined\n\n          const decorationSetsByExtension: Record<string, DecorationSet> = {}\n          const widgetKeysByExtension: Record<string, Set<string>> = {}\n          const recomputedNames = new Set<string>()\n\n          runInDecorationApplyScope(editor, () => {\n            for (const { name, spec } of entries) {\n              const forced = forceAll || forceName === name\n              const shouldRecompute = shouldRecomputeDecoration(\n                spec,\n                { editor, tr, oldState, newState },\n                forced,\n              )\n\n              if (!shouldRecompute) {\n                const result = mapDecorations(name, previous, tr)\n                decorationSetsByExtension[name] = result.set\n                widgetKeysByExtension[name] = result.widgetKeys\n              } else if (spec.update === 'changedRanges' && tr.docChanged && !forced) {\n                const result = this.applyChangedRangesRecompute(name, spec, previous, tr, newState)\n\n                decorationSetsByExtension[name] = result.set\n                widgetKeysByExtension[name] = result.widgetKeys\n                recomputedNames.add(name)\n              } else {\n                const { set, widgetKeys } = this.buildFullSet(name, spec, newState)\n\n                decorationSetsByExtension[name] = set\n                widgetKeysByExtension[name] = widgetKeys\n                recomputedNames.add(name)\n              }\n            }\n          })\n\n          if (recomputedNames.size === 0 && !tr.docChanged) {\n            return previous\n          }\n\n          const mergedDecorationSet = this.mergeAfterApply({\n            entries,\n            previous,\n            tr,\n            decorationSetsByExtension,\n            recomputedNames,\n          })\n\n          return {\n            decorationSetsByExtension,\n            widgetKeysByExtension,\n            mergedDecorationSet,\n            widgetKeys: unionWidgetKeys(widgetKeysByExtension),\n          }\n        },\n      },\n      props: {\n        decorations(state) {\n          return (\n            DECORATION_MANAGER_PLUGIN_KEY.getState(state)?.mergedDecorationSet ??\n            DecorationSet.empty\n          )\n        },\n      },\n    })\n  }\n\n  /**\n   * Applies changed ranges recomputation to a decoration set, dropping stale decorations and rebuilding only the touched blocks.\n   * @param name The name of the decoration extension\n   * @param spec The decoration spec\n   * @param previous The previous decoration manager state\n   * @param tr The transaction to apply\n   * @param newState The new editor state\n   * @returns The updated decoration set and widget keys\n   */\n  private applyChangedRangesRecompute(\n    name: string,\n    spec: DecorationSpec,\n    previous: DecorationManagerState,\n    tr: Transaction,\n    newState: EditorState,\n  ): { set: DecorationSet; widgetKeys: Set<string> } {\n    const resolution = getRebuildRanges(tr, newState.doc)\n\n    if (resolution.type === 'full') {\n      return this.buildFullSet(name, spec, newState)\n    }\n\n    return this.rebuildRanges(name, spec, previous, tr, newState, resolution.ranges)\n  }\n\n  /**\n   * Rebuilds decorations for the changed block ranges: maps the previous set\n   * forward, then for each range removes stale decorations, calls\n   * `createInRange`, and adds the new ones while syncing widget keys.\n   * @param name The extension name.\n   * @param spec The decoration spec.\n   * @param previous The previous decoration manager state.\n   * @param tr The transaction to apply.\n   * @param newState The new editor state.\n   * @param ranges The block ranges to rebuild.\n   * @returns The updated decoration set and widget keys.\n   */\n  private rebuildRanges(\n    name: string,\n    spec: DecorationSpec,\n    previous: DecorationManagerState,\n    tr: Transaction,\n    newState: EditorState,\n    ranges: Range[],\n  ): { set: DecorationSet; widgetKeys: Set<string> } {\n    const previousSet = previous.decorationSetsByExtension[name] ?? DecorationSet.empty\n    const widgetKeys = new Set<string>(previous.widgetKeysByExtension[name] ?? [])\n    let set = mapDecorationSet(previousSet, tr.mapping, tr.doc, widgetKeys)\n\n    const docSize = newState.doc.content.size\n\n    for (const { from, to } of ranges) {\n      const stale = set\n        .find(from, to)\n        .filter(decoration => rangeOwnsPosition({ position: decoration.from, from, to, docSize }))\n\n      for (const decoration of stale) {\n        const key = widgetKeyOf(decoration)\n\n        if (key) {\n          widgetKeys.delete(key)\n        }\n      }\n\n      set = set.remove(stale)\n\n      const rangeDecorations = filterOutOfRangeDecorations({\n        decorations: this.runCreate(name, 'createInRange', () =>\n          spec.createInRange!({\n            editor: this.editor,\n            state: newState,\n            view: this.mountedView,\n            from,\n            to,\n          } satisfies DecorationRangeProps),\n        ),\n        from,\n        to,\n        docSize,\n        extensionName: name,\n        warnedExtensions: this.warnedOutOfRangeExtensions,\n      })\n      const { decorations: pmDecorations, widgetKeys: addedKeys } = decorationsToPMDecorations(\n        rangeDecorations,\n        name,\n      )\n\n      set = set.add(newState.doc, pmDecorations)\n\n      for (const key of addedKeys) {\n        widgetKeys.add(key)\n      }\n    }\n\n    return { set, widgetKeys }\n  }\n\n  /**\n   * Builds a full decoration set for the entire document.\n   * @param name The name of the decoration extension\n   * @param spec The decoration spec\n   * @param state The editor state\n   * @returns The decoration set and widget keys\n   */\n  private buildFullSet(\n    name: string,\n    spec: DecorationSpec,\n    state: EditorState,\n  ): { set: DecorationSet; widgetKeys: Set<string> } {\n    const decorations = this.runCreate(name, 'create', () =>\n      spec.create({\n        editor: this.editor,\n        state,\n        view: this.mountedView,\n      } satisfies DecorationCreateProps),\n    )\n\n    return buildDecorationSet(state.doc, decorations, name)\n  }\n\n  /**\n   * Runs a decoration callback and swallows anything it throws. These run inside\n   * `state.apply`, where an uncaught error would abort the whole transaction.\n   * @param name The extension name.\n   * @param method The callback name, used in the error message.\n   * @param create The callback to run.\n   * @returns The decorations, or an empty array if the callback threw.\n   */\n  private runCreate(\n    name: string,\n    method: 'create' | 'createInRange',\n    create: () => Decoration[],\n  ): Decoration[] {\n    try {\n      return create()\n    } catch (error) {\n      console.error(\n        `[tiptap error]: Extension \"${name}\" threw in \\`addDecorations().${method}()\\`. ` +\n          'Its decorations were dropped for this update.',\n        error,\n      )\n\n      return []\n    }\n  }\n\n  private warnDuplicateWidgetKeys(state: DecorationManagerState): void {\n    if (!isDev) {\n      return\n    }\n\n    // No widget keys means no duplicates, so the scan over the merged set is\n    // pointless. Most documents carry only node and inline decorations.\n    if (state.widgetKeys.size === 0) {\n      this.warnedWidgetKeys.clear()\n\n      return\n    }\n\n    const duplicateKeys = findDuplicateWidgetKeys(state.mergedDecorationSet)\n    const nextWarningKeys = new Set(duplicateKeys.map(({ key }) => key))\n\n    for (const { key, extensions } of duplicateKeys) {\n      if (this.warnedWidgetKeys.has(key)) {\n        continue\n      }\n\n      const names = Array.from(extensions)\n        .map(name => `\"${name}\"`)\n        .join(', ')\n\n      console.warn(\n        `[tiptap warn]: Duplicate widget decoration key \"${key}\" in extension${\n          extensions.size === 1 ? '' : 's'\n        } ${names}. Widget decoration keys must be globally unique, otherwise ProseMirror ` +\n          'misplaces the widget DOM. Use a stable, unique key (e.g. `comment-${id}`).',\n      )\n    }\n\n    this.warnedWidgetKeys = nextWarningKeys\n  }\n\n  /**\n   * Builds the merged DecorationSet during init. Skips the merge for a\n   * single extension since its per-extension set is already correct.\n   * @param doc The document to build the merged set for.\n   * @param decorationSetsByExtension The per-extension decoration sets.\n   * @returns The merged decoration set.\n   */\n  private buildMergedSet(\n    doc: Node,\n    decorationSetsByExtension: Record<string, DecorationSet>,\n  ): DecorationSet {\n    const names = Object.keys(decorationSetsByExtension)\n\n    if (names.length === 1) {\n      return decorationSetsByExtension[names[0]]\n    }\n\n    return mergeDecorationSets(doc, decorationSetsByExtension)\n  }\n\n  /**\n   * Computes the merged DecorationSet after apply. Single extension skips the\n   * merge; nothing recomputed maps the previous merged set forward; otherwise\n   * the merge is rebuilt from the per-extension sets.\n   */\n  private mergeAfterApply({\n    entries,\n    previous,\n    tr,\n    decorationSetsByExtension,\n    recomputedNames,\n  }: {\n    entries: ResolvedDecorationEntry[]\n    previous: DecorationManagerState\n    tr: Transaction\n    decorationSetsByExtension: Record<string, DecorationSet>\n    recomputedNames: Set<string>\n  }): DecorationSet {\n    if (entries.length === 1) {\n      return decorationSetsByExtension[entries[0].name]\n    }\n\n    if (recomputedNames.size === 0) {\n      return previous.mergedDecorationSet.map(tr.mapping, tr.doc)\n    }\n\n    // Patching the previous merged set is far slower than rebuilding it:\n    // `DecorationSet.remove` scans every decoration once per block, so it goes\n    // quadratic on large documents. Every set here already matches `tr.doc`.\n    return mergeDecorationSets(tr.doc, decorationSetsByExtension)\n  }\n}\n","/**\n * Compare two attribute objects for equality.\n * Handles null/undefined and asserts key presence in both objects so that\n * `{ foo: undefined }` and `{ bar: undefined }` are not treated as equal.\n */\nexport function attrsEqual(\n  a: Record<string, any> | null | undefined,\n  b: Record<string, any> | null | undefined,\n): boolean {\n  if (a === b) {\n    return true\n  }\n  if (!a || !b) {\n    return false\n  }\n\n  const keysA = Object.keys(a)\n  const keysB = Object.keys(b)\n\n  if (keysA.length !== keysB.length) {\n    return false\n  }\n\n  return keysA.every(\n    key => Object.prototype.hasOwnProperty.call(b, key) && Object.is(a[key], b[key]),\n  )\n}\n","import type { NodeType } from '@tiptap/pm/model'\nimport { type EditorState, NodeSelection } from '@tiptap/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","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","// source: https://stackoverflow.com/a/6969486\nexport function escapeForRegEx(string: string): string {\n  return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&')\n}\n","/**\n * Read a CSS property value directly from an element's raw inline `style`\n * attribute, bypassing the CSSOM (e.g. `element.style.fontFamily`) which\n * canonicalizes values and can change formatting. The original format is\n * preserved (quotes, hex vs rgb, etc.).\n *\n * When a property is declared more than once, the last declaration wins —\n * this matches CSS cascade order and is useful when nested spans are merged\n * and the child's value should take priority.\n *\n * Property name comparison is case-insensitive.\n *\n * @param element - The element whose `style` attribute should be read.\n * @param propertyName - The CSS property name (e.g. `font-family`).\n * @returns The raw value string, or `null` if the property is not present.\n *\n * @example\n * ```ts\n * parseHTML: element => getStyleProperty(element, 'font-family')\n * ```\n */\nexport function getStyleProperty(element: HTMLElement, propertyName: string): string | null {\n  const styleAttr = element.getAttribute('style')\n\n  if (!styleAttr) {\n    return null\n  }\n\n  const decls = styleAttr\n    .split(';')\n    .map(decl => decl.trim())\n    .filter(Boolean)\n\n  const target = propertyName.toLowerCase()\n\n  for (let i = decls.length - 1; i >= 0; i -= 1) {\n    const decl = decls[i]\n    const colonIndex = decl.indexOf(':')\n\n    if (colonIndex === -1) {\n      continue\n    }\n\n    const prop = decl.slice(0, colonIndex).trim().toLowerCase()\n\n    if (prop === target) {\n      return decl.slice(colonIndex + 1).trim()\n    }\n  }\n\n  return null\n}\n","/**\n * Decode common HTML entities in text content so they display as literal\n * characters inside the editor.  The decode order matters: `&amp;` must be\n * decoded **last** so that doubly-encoded sequences like `&amp;lt;` first\n * survive the `&lt;` pass and then correctly become `&lt;` (not `<`).\n */\nexport function decodeHtmlEntities(text: string): string {\n  return text\n    .replace(/&lt;/g, '<')\n    .replace(/&gt;/g, '>')\n    .replace(/&quot;/g, '\"')\n    .replace(/&amp;/g, '&')\n}\n\n/**\n * Encode HTML special characters so they roundtrip safely through markdown.\n * `&` is encoded **first** to avoid double-encoding the ampersand in other\n * entities (e.g. `<` → `&lt;`, not `&amp;lt;`).\n *\n * Note: `\"` is intentionally NOT encoded here because double quotes are\n * ordinary characters in markdown and do not need escaping.  The decode\n * function still handles `&quot;` because the markdown tokenizer may emit it.\n */\nexport function encodeHtmlEntities(text: string): string {\n  return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')\n}\n","/**\n * Detects if the current browser is Firefox.\n * @returns `true` if the browser is Firefox, `false` otherwise.\n * @example\n * if (isFirefox()) {\n *   // Firefox-specific handling\n * }\n */\nexport function isFirefox(): boolean {\n  return typeof navigator !== 'undefined' ? /Firefox/.test(navigator.userAgent) : false\n}\n","export function isNumber(value: any): value is number {\n  return typeof value === 'number'\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","export function isString(value: any): value is string {\n  return typeof value === 'string'\n}\n","export type AttributeToken =\n  | { type: 'class'; name: string }\n  | { type: 'id'; name: string }\n  | { type: 'keyValue'; name: string; value: string }\n  | { type: 'boolean'; name: string }\n\ntype AttributeSyntax = 'pandoc' | 'shortcode'\n\ntype TokenResult = {\n  token?: AttributeToken\n  nextIndex: number\n}\n\nfunction isWhitespace(character: string): boolean {\n  return /\\s/.test(character)\n}\n\nfunction isAsciiLetter(character: string): boolean {\n  return /^[a-zA-Z]$/.test(character)\n}\n\nfunction isWordCharacter(character: string): boolean {\n  return /^\\w$/.test(character)\n}\n\nfunction skipWhitespace(input: string, index: number): number {\n  while (index < input.length && isWhitespace(input[index])) {\n    index += 1\n  }\n\n  return index\n}\n\nfunction skipToWhitespace(input: string, index: number): number {\n  while (index < input.length && !isWhitespace(input[index])) {\n    index += 1\n  }\n\n  return index\n}\n\nfunction readName(input: string, index: number, allowHyphen: boolean): number {\n  while (\n    index < input.length &&\n    (isWordCharacter(input[index]) || (allowHyphen && input[index] === '-'))\n  ) {\n    index += 1\n  }\n\n  return index\n}\n\nfunction readShorthand(input: string, index: number): TokenResult {\n  const prefix = input[index]\n  const nameStart = index + 1\n  const nameEnd = readName(input, nameStart, true)\n\n  if (nameEnd === nameStart) {\n    return { nextIndex: skipToWhitespace(input, nameEnd) }\n  }\n\n  return {\n    token: {\n      type: prefix === '.' ? 'class' : 'id',\n      name: input.slice(nameStart, nameEnd),\n    },\n    nextIndex: skipToWhitespace(input, nameEnd),\n  }\n}\n\nfunction readQuotedSegment(input: string, index: number): TokenResult {\n  const closingQuote = input.indexOf(input[index], index + 1)\n  const segmentEnd = closingQuote === -1 ? index : closingQuote + 1\n\n  return { nextIndex: skipToWhitespace(input, segmentEnd) }\n}\n\nfunction readKeyValue(\n  input: string,\n  name: string,\n  index: number,\n  allowWhitespace: boolean,\n): TokenResult | undefined {\n  let valueStart = allowWhitespace ? skipWhitespace(input, index) : index\n  if (input[valueStart] !== '=') {\n    return undefined\n  }\n\n  valueStart = allowWhitespace ? skipWhitespace(input, valueStart + 1) : valueStart + 1\n  const quote = input[valueStart]\n  if (quote !== '\"' && quote !== \"'\") {\n    return undefined\n  }\n\n  const valueEnd = input.indexOf(quote, valueStart + 1)\n  if (valueEnd === -1) {\n    return undefined\n  }\n\n  return {\n    token: {\n      type: 'keyValue',\n      name,\n      value: input.slice(valueStart + 1, valueEnd),\n    },\n    nextIndex: skipToWhitespace(input, valueEnd + 1),\n  }\n}\n\nfunction readNamedAttribute(input: string, index: number, syntax: AttributeSyntax): TokenResult {\n  const isPandoc = syntax === 'pandoc'\n  const nameEnd = readName(input, index + 1, isPandoc)\n  const name = input.slice(index, nameEnd)\n  const keyValue = readKeyValue(input, name, nameEnd, isPandoc)\n\n  if (keyValue) {\n    return keyValue\n  }\n\n  const isStandalone = nameEnd === input.length || isWhitespace(input[nameEnd])\n  return {\n    token: isPandoc && isStandalone ? { type: 'boolean', name } : undefined,\n    nextIndex: syntax === 'shortcode' ? skipToWhitespace(input, nameEnd) : nameEnd,\n  }\n}\n\nfunction readAttribute(input: string, index: number, syntax: AttributeSyntax): TokenResult {\n  const prefix = input[index]\n\n  if (syntax === 'pandoc' && (prefix === '.' || prefix === '#')) {\n    return readShorthand(input, index)\n  }\n  if (prefix === '\"' || prefix === \"'\") {\n    return readQuotedSegment(input, index)\n  }\n\n  const hasValidStart = syntax === 'pandoc' ? isAsciiLetter(prefix) : isWordCharacter(prefix)\n  if (hasValidStart) {\n    return readNamedAttribute(input, index, syntax)\n  }\n\n  return { nextIndex: skipToWhitespace(input, index) }\n}\n\nexport function tokenizeAttributes(input: string, syntax: AttributeSyntax): AttributeToken[] {\n  const tokens: AttributeToken[] = []\n  let index = 0\n\n  while (index < input.length) {\n    index = skipWhitespace(input, index)\n    if (index >= input.length) {\n      break\n    }\n\n    const result = readAttribute(input, index, syntax)\n    if (result.token) {\n      tokens.push(result.token)\n    }\n    index = result.nextIndex\n  }\n\n  return tokens\n}\n","import type { AttributeToken } from './tokenizeAttributes.js'\nimport { tokenizeAttributes } from './tokenizeAttributes.js'\n\nfunction applyTokens(tokens: AttributeToken[]): Record<string, any> {\n  const attributes: Record<string, any> = {}\n  const classes = tokens.filter(token => token.type === 'class').map(token => token.name)\n  const id = tokens.find(token => token.type === 'id')\n\n  if (classes.length > 0) {\n    attributes.class = classes.join(' ')\n  }\n  if (id) {\n    attributes.id = id.name\n  }\n\n  tokens.forEach(token => {\n    if (token.type === 'keyValue') {\n      attributes[token.name] = token.value\n    }\n  })\n  tokens.forEach(token => {\n    if (token.type === 'boolean') {\n      attributes[token.name] = true\n    }\n  })\n\n  return attributes\n}\n\n/**\n * Parses a Pandoc-style attribute string into an object.\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  return applyTokens(tokenizeAttributes(attrString, 'pandoc'))\n}\n","/**\n * Serializes an attributes object 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  if (attributes.class) {\n    const classes = String(attributes.class).split(/\\s+/).filter(Boolean)\n    classes.forEach(className => parts.push(`.${className}`))\n  }\n\n  if (attributes.id) {\n    parts.push(`#${attributes.id}`)\n  }\n\n  Object.entries(attributes).forEach(([key, value]) => {\n    if (key === 'class' || key === 'id') {\n      return\n    }\n\n    if (value === true) {\n      parts.push(key)\n    } else if (value !== false && value != null) {\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 { parseAttributes as defaultParseAttributes } from './parseAttributes.js'\nimport { serializeAttributes as defaultSerializeAttributes } from './serializeAttributes.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 { parseAttributes as defaultParseAttributes } from './parseAttributes.js'\nimport { serializeAttributes as defaultSerializeAttributes } from './serializeAttributes.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 =\n          typeof contentResult === 'string'\n            ? [{ type: 'text', text: contentResult }]\n            : 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 (\n                      lastToken.type === 'paragraph' &&\n                      (!lastToken.text || lastToken.text.trim() === '')\n                    ) {\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 { tokenizeAttributes } from './tokenizeAttributes.js'\n\nexport function parseShortcodeAttributes(attrString: string): Record<string, any> {\n  const attributes: Record<string, any> = {}\n\n  tokenizeAttributes(attrString, 'shortcode').forEach(token => {\n    if (token.type === 'keyValue') {\n      attributes[token.name] = token.value\n    }\n  })\n\n  return attributes\n}\n","import type {\n  JSONContent,\n  MarkdownParseHelpers,\n  MarkdownParseResult,\n  MarkdownToken,\n  MarkdownTokenizer,\n} from '../../types.js'\nimport { parseShortcodeAttributes } from './parseShortcodeAttributes.js'\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\n/**\n * Configuration for an allowed attribute in markdown serialization.\n * Can be a simple string (attribute name) or an object with additional options.\n */\nexport type AllowedAttribute =\n  | string\n  | {\n      /** The attribute name */\n      name: string\n      /**\n       * If provided, the attribute will be skipped during serialization when its value\n       * equals this default value. This keeps markdown output clean by omitting\n       * attributes that have their default values.\n       */\n      skipIfDefault?: any\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  /**\n   * Allowlist of attributes to include in markdown serialization.\n   * If not provided, all attributes are included.\n   *\n   * Each item can be either:\n   * - A string: the attribute name (always included if present)\n   * - An object: `{ name: string, skipIfDefault?: any }` for conditional inclusion\n   *\n   * @example\n   * // Simple string attributes (backward compatible)\n   * allowedAttributes: ['id', 'label']\n   *\n   * // Mixed with conditional attributes\n   * allowedAttributes: [\n   *   'id',\n   *   'label',\n   *   { name: 'mentionSuggestionChar', skipIfDefault: '@' }\n   * ]\n   */\n  allowedAttributes?: AllowedAttribute[]\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(attr => {\n      // Handle both string and object formats for backward compatibility\n      const attrName = typeof attr === 'string' ? attr : attr.name\n      const skipIfDefault = typeof attr === 'string' ? undefined : attr.skipIfDefault\n\n      if (attrName in attrs) {\n        const value = attrs[attrName]\n\n        // Skip if value equals the default (when skipIfDefault is specified)\n        if (skipIfDefault !== undefined && value === skipIfDefault) {\n          return\n        }\n\n        filtered[attrName] = value\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(\n              `^\\\\[${escapedShortcode}\\\\s*([^\\\\]]*)\\\\]([\\\\s\\\\S]*?)\\\\[\\\\/${escapedShortcode}\\\\]`,\n            )\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        totalRaw = `${totalRaw}${currentLine}\\n`\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,\n  }\n}\n","import type { JSONContent } from '@tiptap/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 * @param options - Optional rendering options\n * @param options.alignNestedToPrefix - Indent nested content to the width of the prefix\n * instead of the configured indent size, when the configured one is narrower\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 an ordered list item, where the nested block has to line up with the marker\n * return renderNestedMarkdownContent(node, h, '10. ', ctx, { alignNestedToPrefix: true })\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 */\nconst TAB_STOP = 4\n\n/** Width of indentation in Markdown columns, where a tab runs to the next tab stop. */\nfunction columnWidth(text: string): number {\n  let width = 0\n\n  for (const character of text) {\n    width = character === '\\t' ? width + TAB_STOP - (width % TAB_STOP) : width + 1\n  }\n\n  return width\n}\n\nexport function renderNestedMarkdownContent(\n  node: JSONContent,\n  h: {\n    renderChildren: (nodes: JSONContent[]) => string\n    renderChild?: (node: JSONContent, index: number) => string\n    indent: (text: string) => string\n  },\n  prefixOrGenerator: string | ((ctx: any) => string),\n  ctx?: any,\n  options?: {\n    /** See the `@param` note above. */\n    alignNestedToPrefix?: boolean\n  },\n): string {\n  if (!node || !Array.isArray(node.content)) {\n    return ''\n  }\n\n  // Determine the prefix based on the input\n  const prefix =\n    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  let output = `${prefix}${mainContent}`\n\n  // Handle nested children with proper indentation\n  if (children && children.length > 0) {\n    children.forEach((child, index) => {\n      const childContent = h.renderChild?.(child, index + 1) ?? h.renderChildren([child])\n      if (childContent !== undefined && childContent !== null) {\n        // Split the child content by lines and indent each line\n        const indentLine = (line: string) => {\n          if (!options?.alignNestedToPrefix) {\n            return h.indent(line)\n          }\n\n          // Keep the configured indentation when it already reaches the\n          // content column, so `Markdown.indentation` still applies. A tab\n          // runs to the next tab stop, so it is wider than its one character.\n          const configured = h.indent('')\n          const prefixWidth = columnWidth(prefix)\n\n          return (\n            (columnWidth(configured) >= prefixWidth ? configured : ' '.repeat(prefixWidth)) + line\n          )\n        }\n\n        const indentedChild = childContent\n          .split('\\n')\n          .map(line => (line ? indentLine(line) : indentLine('')))\n          .join('\\n')\n\n        output += child.type === 'paragraph' ? `\\n\\n${indentedChild}` : `\\n${indentedChild}`\n      }\n    })\n  }\n\n  return output\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 './createAtomBlockMarkdownSpec.js'\nexport * from './createBlockMarkdownSpec.js'\nexport * from './createInlineMarkdownSpec.js'\nexport * from './parseAttributes.js'\nexport * from './parseIndentedBlocks.js'\nexport * from './renderNestedMarkdownContent.js'\nexport * from './serializeAttributes.js'\n","import { attrsEqual } from './attrsEqual.js'\n\n/**\n * Shape accepted by marksEqual, works with both JSONContent marks\n * (`{ type: 'bold' }`) and ProseMirror Mark objects (`{ type: MarkType }`).\n */\nexport type MarkLike = {\n  type: string | { name: string }\n  attrs?: Record<string, any> | null\n}\n\nfunction markTypeName(mark: MarkLike): string {\n  return typeof mark.type === 'string' ? mark.type : mark.type.name\n}\n\n/**\n * Compare two arrays of mark objects for equality (order-insensitive).\n * Marks are matched by type name and attributes (via attrsEqual),\n * so key ordering in attrs does not matter, nor does mark array order.\n */\nexport function marksEqual(a: readonly MarkLike[], b: readonly MarkLike[]): boolean {\n  if (a.length !== b.length) {\n    return false\n  }\n\n  // Marks are matched by (type, attrs) identity, so greedy first-match works.\n  const consumed = Array.from({ length: b.length }, () => false)\n\n  return a.every(markA => {\n    const nameA = markTypeName(markA)\n\n    const idx = b.findIndex(\n      (markB, i) =>\n        !consumed[i] && nameA === markTypeName(markB) && attrsEqual(markA.attrs, markB.attrs),\n    )\n\n    if (idx === -1) {\n      return false\n    }\n\n    consumed[idx] = true\n    return true\n  })\n}\n","import { isPlainObject } from './isPlainObject.js'\n\nexport function mergeDeep(\n  target: Record<string, any>,\n  source: Record<string, any>,\n): 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 { Mark } from '@tiptap/pm/model'\nimport type { ViewMutationRecord } from '@tiptap/pm/view'\n\nimport type { Editor } from './Editor.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(component: Component, props: MarkViewProps, options?: Partial<Options>) {\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.contentDOM.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 { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Fragment } from '@tiptap/pm/model'\nimport type { EditorState, TextSelection } from '@tiptap/pm/state'\nimport { Plugin } from '@tiptap/pm/state'\n\nimport { CommandManager } from './CommandManager.js'\nimport type { Editor } from './Editor.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 = RegExp | ((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        '[tiptap 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(mark => mark.type.spec.code)\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    // Leaf nodes have a different length in text and the document.\n    // Skip matches across them to avoid wrong document positions.\n    const matchedDocLength = match[0].length - text.length\n\n    if (matchedDocLength > 0) {\n      const matchStartOffset = $from.parentOffset - matchedDocLength\n\n      if (\n        matchStartOffset < 0 ||\n        $from.parent.textBetween(matchStartOffset, $from.parentOffset) !==\n          match[0].slice(0, matchedDocLength)\n      ) {\n        return\n      }\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: { editor: Editor; rules: InputRule[] }): 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","import type { Plugin } from '@tiptap/pm/state'\n\nimport type { Editor } from './Editor.js'\nimport type { DecorationSpec } from './decorations/index.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  DispatchTransactionProps,\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<Options, Storage, any, any>,\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  /**\n   * This method will add options to this extension\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#settings\n   * @example\n   * addOptions() {\n   *  return {\n   *    myOption: 'foo',\n   *    myOtherOption: 10,\n   * }\n   */\n  addOptions?: (this: { name: string; parent: ParentConfig<Config>['addOptions'] }) => Options\n\n  /**\n   * The default storage this extension can save data to.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#storage\n   * @example\n   * defaultStorage: {\n   *   prefetchedUsers: [],\n   *   loading: false,\n   * }\n   */\n  addStorage?: (this: {\n    name: string\n    options: Options\n    parent: ParentConfig<Config>['addStorage']\n  }) => Storage\n\n  /**\n   * This function adds globalAttributes to specific nodes.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#global-attributes\n   * @example\n   * addGlobalAttributes() {\n   *   return [\n   *     {\n           // Extend the following extensions\n   *       types: [\n   *         'heading',\n   *         'paragraph',\n   *       ],\n   *       // … with those attributes\n   *       attributes: {\n   *         textAlign: {\n   *           default: 'left',\n   *           renderHTML: attributes => ({\n   *             style: `text-align: ${attributes.textAlign}`,\n   *           }),\n   *           parseHTML: element => element.style.textAlign || 'left',\n   *         },\n   *       },\n   *     },\n   *   ]\n   * }\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  /**\n   * This function adds commands to the editor\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#commands\n   * @example\n   * addCommands() {\n   *   return {\n   *     myCommand: () => ({ chain }) => chain().setMark('type', 'foo').run(),\n   *   }\n   * }\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  /**\n   * This function registers keyboard shortcuts.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#keyboard-shortcuts\n   * @example\n   * addKeyboardShortcuts() {\n   *   return {\n   *     'Mod-l': () => this.editor.commands.toggleBulletList(),\n   *   }\n   * },\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  /**\n   * This function adds input rules to the editor.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#input-rules\n   * @example\n   * addInputRules() {\n   *   return [\n   *     markInputRule({\n   *       find: inputRegex,\n   *       type: this.type,\n   *     }),\n   *   ]\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  /**\n   * This function adds paste rules to the editor.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#paste-rules\n   * @example\n   * addPasteRules() {\n   *   return [\n   *     markPasteRule({\n   *       find: pasteRegex,\n   *       type: this.type,\n   *     }),\n   *   ]\n   * },\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  /**\n   * This function adds Prosemirror plugins to the editor\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#prosemirror-plugins\n   * @example\n   * addProseMirrorPlugins() {\n   *   return [\n   *     customPlugin(),\n   *   ]\n   * }\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  /**\n   * Adds editor decorations (node, inline, widget). Return a spec with a `create`\n   * function that builds instances via `Decoration.Node`/`Inline`/`Widget`. Use\n   * `shouldUpdate`, `update: 'changedRanges'` + `createInRange`, or `update: 'manual'` to control recomputation.\n   * @see https://tiptap.dev/docs/editor/core-concepts/decorations\n   * @example\n   * addDecorations() {\n   *   return {\n   *     create: ({ state }) =>\n   *       findChildren(state.doc, node => node.type.name === 'heading').map(\n   *         ({ pos, node }) =>\n   *           Decoration.Node(pos, pos + node.nodeSize, { class: 'is-heading' }),\n   *       ),\n   *   }\n   * }\n   *\n   * For framework widgets, use `ReactWidgetRenderer` or `VueWidgetRenderer`\n   * from the matching framework package. Give stateful widgets a stable key.\n   *\n   * `create` and `createInRange` must not throw. An exception escapes through\n   * `editor.commands.*` and stops the document from updating until it stops.\n   */\n  addDecorations?: (this: {\n    name: string\n    options: Options\n    storage: Storage\n    editor: Editor\n    type: PMType\n    parent: ParentConfig<Config>['addDecorations']\n  }) => DecorationSpec | null\n\n  /**\n   * This function transforms pasted HTML content before it's parsed.\n   * Extensions can use this to modify or clean up pasted HTML.\n   * The transformations are chained - each extension's transform receives\n   * the output from the previous extension's transform.\n   * @see https://tiptap.dev/docs/editor/guide/custom-extensions#transform-pasted-html\n   * @example\n   * transformPastedHTML(html) {\n   *   // Remove all style attributes\n   *   return html.replace(/style=\"[^\"]*\"/g, '')\n   * }\n   */\n  transformPastedHTML?: (\n    this: {\n      name: string\n      options: Options\n      storage: Storage\n      editor: Editor\n      type: PMType\n      parent: ParentConfig<Config>['transformPastedHTML']\n    },\n    html: string,\n  ) => string\n\n  /**\n   * This function adds additional extensions to the editor. This is useful for\n   * building extension kits.\n   * @example\n   * addExtensions() {\n   *   return [\n   *     BulletList,\n   *     OrderedList,\n   *     ListItem\n   *   ]\n   * }\n   */\n  addExtensions?: (this: {\n    name: string\n    options: Options\n    storage: Storage\n    parent: ParentConfig<Config>['addExtensions']\n  }) => Extensions\n\n  /**\n   * The markdown token name\n   *\n   * This is the name of the token that this extension uses to parse and render markdown and comes from the Marked Lexer.\n   *\n   * @see https://github.com/markedjs/marked/blob/master/src/Tokens.ts\n   *\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?: (token: MarkdownToken, helpers: MarkdownParseHelpers) => 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     * Lets a mark tell the Markdown serializer which inline HTML tags it can\n     * safely use when plain markdown delimiters would become ambiguous.\n     *\n     * This is mainly useful for overlapping marks. For example, bold followed\n     * by bold+italic followed by italic cannot always be written back with only\n     * `*` and `**` in a way that still parses correctly. In that case, the\n     * serializer can close the overlapping section with markdown and reopen the\n     * remaining tail with HTML instead.\n     *\n     * Example:\n     * - desired formatting: `**123` + `*456*` + `789 italic`\n     * - serialized result: `**123*456***<em>789</em>`\n     *\n     * If your extension defines custom mark names, set `htmlReopen` on that\n     * extension so the serializer can reuse its HTML form for overlap cases.\n     */\n    htmlReopen?: {\n      open: string\n      close: string\n    }\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  /**\n   * This hook allows you to intercept and modify transactions before they are dispatched.\n   *\n   * Example\n   * ```ts\n   * dispatchTransaction({ transaction, next }) {\n   *   console.log('Dispatching transaction:', transaction)\n   *   next(transaction)\n   * }\n   * ```\n   *\n   * @param props - The dispatch transaction props\n   */\n  dispatchTransaction?:\n    | ((\n        this: {\n          name: string\n          options: Options\n          storage: Storage\n          editor: Editor\n          type: PMType\n          parent: ParentConfig<Config>['dispatchTransaction']\n        },\n        props: DispatchTransactionProps,\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(this.options as Record<string, any>, options) as Options\n      },\n    })\n\n    extension.name = this.name\n    extension.parent = this.parent\n\n    this.child = null\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  >(extendedConfig: Partial<ExtendedConfig> = {}): Extendable<ExtendedOptions, ExtendedStorage> {\n    const extension = new (this.constructor as any)({ ...this.config, ...extendedConfig })\n\n    extension.parent = this\n    this.child = extension\n    extension.name = 'name' in extendedConfig ? extendedConfig.name : extension.parent.name\n\n    return extension\n  }\n}\n","import type { DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType } from '@tiptap/pm/model'\n\nimport type { Editor } from './Editor.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> 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   * Whether this mark is removed by `unsetAllMarks`.\n   * Set to `false` for semantic marks (comments, suggestions) that should survive \"clear formatting\".\n   * @default true\n   */\n  clearable?: 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    // oxlint-disable-next-lineno-empty-object-type\n  }) => Attributes | {}\n}\n\n/**\n * The Mark class is used to create custom mark extensions.\n * @see https://tiptap.dev/api/extensions#create-a-new-extension\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 extends MarkConfig<ExtendedOptions, ExtendedStorage> = MarkConfig<\n      ExtendedOptions,\n      ExtendedStorage\n    >,\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 = typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig\n    return super.extend(resolvedConfig) as Mark<ExtendedOptions, ExtendedStorage>\n  }\n}\n","import type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Fragment } from '@tiptap/pm/model'\nimport type { EditorState } from '@tiptap/pm/state'\nimport { Plugin } from '@tiptap/pm/state'\n\nimport { CommandManager } from './CommandManager.js'\nimport type { Editor } from './Editor.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  | ((text: string, event?: ClipboardEvent | null) => PasteRuleMatch[] | null | undefined)\n\n/**\n * Paste rules are used to react to pasted content.\n * @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\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          '[tiptap 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 (node.type?.spec?.code || !(node.isText || node.isTextblock || node.isInline)) {\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(resolvedFrom - pos, resolvedTo - pos, undefined, '\\ufffc')\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: { editor: Editor; rules: PasteRule[] }): Plugin[] {\n  const { editor, rules } = props\n  let dragSourceElement: Element | null = null\n  let isPastedFromProseMirror = false\n  let isDroppedFromProseMirror = false\n  let pasteEvent = 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 = typeof DragEvent !== 'undefined' ? new DragEvent('drop') : null\n    } catch {\n      dropEvent = null\n    }\n    pasteEvent = typeof ClipboardEvent !== 'undefined' ? new ClipboardEvent('paste') : 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(event.target as Element)\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 = 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('text/html')\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 = transaction.getMeta('uiEvent') === 'paste' && !isPastedFromProseMirror\n        const isDrop = transaction.getMeta('uiEvent') === 'drop' && !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","import { keymap } from '@tiptap/pm/keymap'\nimport type { Schema } from '@tiptap/pm/model'\nimport type { Plugin, Transaction } from '@tiptap/pm/state'\nimport type { EditorView, MarkViewConstructor, NodeViewConstructor } from '@tiptap/pm/view'\n\nimport type { Editor } from './Editor.js'\nimport { DecorationManager, type DecorationManagerEntry } from './decorations/DecorationManager.js'\nimport {\n  flattenExtensions,\n  getAttributesFromExtensions,\n  getExtensionField,\n  getMarkType,\n  getNodeType,\n  getRenderedAttributes,\n  getSchemaByResolvedExtensions,\n  getSchemaTypeByName,\n  isExtensionRulesEnabled,\n  resolveExtensions,\n  sortExtensions,\n  splitExtensions,\n} from './helpers/index.js'\nimport { updateMarkViewAttributes } from './MarkView.js'\nimport { inputRulesPlugin } from './InputRule.js'\nimport { Mark, type MarkConfig } from './Mark.js'\nimport { pasteRulesPlugin } from './PasteRule.js'\nimport type { AnyConfig, Extensions, RawCommands, Storage } from './types.js'\nimport { callOrReturn } from './utilities/callOrReturn.js'\nimport { type NodeConfig } from './Node.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  nonClearableMarks: string[] = []\n\n  decorationManager: DecorationManager | null = null\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    // With ProseMirror, first plugins within an array are executed first.\n    // In Tiptap, we provide the ability to override plugins,\n    // so it feels more natural to run plugins at the end of an array first.\n    // That’s why we have to reverse the `extensions` array and sort again\n    // based on the `priority` option.\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<AnyConfig['addKeyboardShortcuts']>(\n        extension,\n        'addKeyboardShortcuts',\n        context,\n      )\n\n      let defaultBindings: Record<string, () => boolean> = {}\n\n      // bind exit handling\n      if (\n        extension.type === 'mark' &&\n        getExtensionField<MarkConfig['exitable']>(extension, 'exitable', context)\n      ) {\n        defaultBindings.ArrowRight = () => 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 (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {\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) ? inputResult : [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 (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {\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<AnyConfig['addProseMirrorPlugins']>(\n        extension,\n        'addProseMirrorPlugins',\n        context,\n      )\n\n      if (addProseMirrorPlugins) {\n        const proseMirrorPlugins = addProseMirrorPlugins()\n\n        plugins.push(...proseMirrorPlugins)\n      }\n\n      return plugins\n    })\n\n    const decorationPlugin = this.createDecorationPlugin()\n\n    if (decorationPlugin) {\n      allPlugins.push(decorationPlugin)\n    }\n\n    return allPlugins\n  }\n\n  /**\n   * Aggregates decorations from extensions into a single plugin, or returns null\n   * if none exist. Destroys the previous manager to avoid orphaned listeners.\n   * @returns A ProseMirror plugin or `null`\n   * @example\n   * const plugin = editor.extensionManager.createDecorationPlugin()\n   */\n  createDecorationPlugin(): Plugin | null {\n    const { editor } = this\n\n    this.decorationManager?.destroy()\n\n    const entries: DecorationManagerEntry[] = []\n\n    this.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,\n        type: getSchemaTypeByName(extension.name, this.schema),\n      }\n\n      const addDecorations = getExtensionField<AnyConfig['addDecorations']>(\n        extension,\n        'addDecorations',\n        context,\n      )\n\n      if (!addDecorations) {\n        return\n      }\n\n      entries.push({ name: extension.name, addDecorations })\n    })\n\n    this.decorationManager = new DecorationManager({ editor, entries })\n\n    return this.decorationManager.plugin\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: 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 nodeViewResult = addNodeView()\n\n          if (!nodeViewResult) {\n            return []\n          }\n\n          const nodeview: NodeViewConstructor = (\n            node,\n            view,\n            getPos,\n            decorations,\n            innerDecorations,\n          ) => {\n            const HTMLAttributes = getRenderedAttributes(node, extensionAttributes)\n\n            return nodeViewResult({\n              // pass-through\n              node,\n              view,\n              getPos: getPos as () => number,\n              decorations,\n              innerDecorations,\n              // tiptap-specific\n              editor,\n              extension,\n              HTMLAttributes,\n            })\n          }\n\n          return [extension.name, nodeview]\n        }),\n    )\n  }\n\n  /**\n   * Get the composed dispatchTransaction function from all extensions.\n   * @param baseDispatch The base dispatch function (e.g. from the editor or user props)\n   * @returns A composed dispatch function\n   */\n  dispatchTransaction(baseDispatch: (tr: Transaction) => void): (tr: Transaction) => void {\n    const { editor } = this\n    const extensions = sortExtensions([...this.extensions].reverse())\n\n    return extensions.reduceRight((next, 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 dispatchTransaction = getExtensionField<AnyConfig['dispatchTransaction']>(\n        extension,\n        'dispatchTransaction',\n        context,\n      )\n\n      if (!dispatchTransaction) {\n        return next\n      }\n\n      return (transaction: Transaction) => {\n        dispatchTransaction.call(context, { transaction, next })\n      }\n    }, baseDispatch)\n  }\n\n  /**\n   * Get the composed transformPastedHTML function from all extensions.\n   * @param baseTransform The base transform function (e.g. from the editor props)\n   * @returns A composed transform function that chains all extension transforms\n   */\n  transformPastedHTML(\n    baseTransform?: (html: string, view?: any) => string,\n  ): (html: string, view?: EditorView) => string {\n    const { editor } = this\n    const extensions = sortExtensions([...this.extensions])\n\n    return extensions.reduce(\n      (transform, 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 extensionTransform = getExtensionField<AnyConfig['transformPastedHTML']>(\n          extension,\n          'transformPastedHTML',\n          context,\n        )\n\n        if (!extensionTransform) {\n          return transform\n        }\n\n        return (html: string, view?: any) => {\n          // Chain the transforms: pass the result of the previous transform to the next\n          const transformedHtml = transform(html, view)\n          return extensionTransform.call(context, transformedHtml)\n        }\n      },\n      baseTransform || ((html: string) => html),\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: 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(mark, extensionAttributes)\n\n            return addMarkView()({\n              // pass-through\n              mark,\n              view,\n              inline,\n              // tiptap-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   * Destroy the extension manager and clean up all extension references\n   * to prevent memory leaks through parent/child extension chains.\n   *\n   * Walks each extension's full parent chain and nulls every forward\n   * `parent.child → current` link where the parent still points to the\n   * current node. This breaks the retention path from module-scope\n   * singleton roots through deep extend() chains.\n   *\n   * Only ancestor `.child` links matching the current chain are cleared.\n   * The `.parent` pointer on ancestors is never touched — extensions\n   * may be shared across live editors, so their own backward references\n   * and non-matching forward links must remain intact.\n   */\n  destroy() {\n    this.decorationManager?.destroy()\n\n    this.extensions.forEach(extension => {\n      let current: any = extension\n\n      while (current.parent) {\n        const parent = current.parent\n\n        if (parent.child === current) {\n          parent.child = null\n        }\n\n        current = parent\n      }\n    })\n\n    this.extensions = []\n    this.baseExtensions = []\n    this.decorationManager = null\n    this.schema = null as any\n    this.editor = null as any\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)) ?? true\n\n        if (keepOnSplit) {\n          this.splittableMarks.push(extension.name)\n        }\n\n        const clearable =\n          callOrReturn(\n            getExtensionField<MarkConfig['clearable']>(extension, 'clearable', context),\n          ) ?? true\n\n        if (!clearable) {\n          this.nonClearableMarks.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']>(extension, 'onCreate', context)\n      const onUpdate = getExtensionField<AnyConfig['onUpdate']>(extension, 'onUpdate', context)\n      const onSelectionUpdate = getExtensionField<AnyConfig['onSelectionUpdate']>(\n        extension,\n        'onSelectionUpdate',\n        context,\n      )\n      const onTransaction = getExtensionField<AnyConfig['onTransaction']>(\n        extension,\n        'onTransaction',\n        context,\n      )\n      const onFocus = getExtensionField<AnyConfig['onFocus']>(extension, 'onFocus', context)\n      const onBlur = getExtensionField<AnyConfig['onBlur']>(extension, 'onBlur', context)\n      const onDestroy = getExtensionField<AnyConfig['onDestroy']>(extension, 'onDestroy', context)\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 { Editor } from './Editor.js'\nimport { type ExtendableConfig, Extendable } from './Extendable.js'\n\n// oxlint-disable-next-lineno-empty-object-type\nexport interface ExtensionConfig<Options = any, Storage = any> extends ExtendableConfig<\n  Options,\n  Storage,\n  ExtensionConfig<Options, Storage>,\n  null\n> {}\n\n/**\n * The Extension class is the base class for all extensions.\n * @see https://tiptap.dev/api/extensions#create-a-new-extension\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: Partial<ExtensionConfig<O, S>> | (() => 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 = typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig\n    return super.extend(resolvedConfig) as Extension<ExtendedOptions, ExtendedStorage>\n  }\n}\n","import { Plugin, PluginKey } from '@tiptap/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 textSerializers = getTextSerializersFromSchema(schema)\n            const { blockSeparator } = this.options\n            const options = {\n              ...(blockSeparator !== undefined ? { blockSeparator } : {}),\n              textSerializers,\n            }\n\n            // Serialize each selection range independently and join the results.\n            // CellSelection exposes one range per selected cell; flattening to\n            // min(from)/max(to) would pull in unselected cells between them.\n            // Sort by document position so reverse selections (e.g. dragging\n            // upward) still emit text in document order.\n            const sortedRanges = [...selection.ranges].sort((a, b) => a.$from.pos - b.$from.pos)\n\n            return sortedRanges\n              .map(({ $from, $to }) =>\n                getTextBetween(doc, { from: $from.pos, to: $to.pos }, options),\n              )\n              .join(blockSeparator ?? '\\n\\n')\n          },\n        },\n      }),\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 '@tiptap/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, [\n        transaction,\n        ...appendedTransactions,\n      ])\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(\n            change.oldRange.from,\n            change.oldRange.to,\n            (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\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 =\n            newStart > 0\n              ? nextTransaction.doc.nodeAt(newStart - 1)?.marks.some(mark => mark.eq(step.mark))\n              : false\n          const foundAfterMark = nextTransaction.doc\n            .nodeAt(newEnd)\n            ?.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 '@tiptap/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('tiptapDrop'),\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 '@tiptap/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 '@tiptap/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\n                .setMeta('focus', { event })\n                .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\n                .setMeta('blur', { event })\n                .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 '@tiptap/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 =\n              $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 =\n            transactions.some(transaction => transaction.docChanged) &&\n            !oldState.doc.eq(newState.doc)\n\n          const ignoreTr = transactions.some(transaction =>\n            transaction.getMeta('preventClearDocument'),\n          )\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 '@tiptap/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('tiptapPaste'),\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 '@tiptap/pm/state'\n\nimport { Extension } from '../Extension.js'\n\n/**\n * Options for the Tabindex extension.\n */\nexport type TabindexOptions = {\n  /**\n   * The value for the `tabindex` attribute on the editor element.\n   * When undefined, editable editors default to `0` and non-editable editors get no tabindex.\n   */\n  value?: string\n}\n\n/**\n * The Tabindex extension adds a configurable tabindex attribute to the editor.\n *\n * By default, the editor gets tabindex=\"0\" when editable. This can be customized\n * via coreExtensionOptions to support specific focus ordering requirements in forms\n * or to enable focusing on non-editable editors.\n *\n * @example\n * ```ts\n * new Editor({\n *   coreExtensionOptions: {\n *     tabindex: {\n *       value: '-1',\n *     },\n *   },\n * })\n * ```\n */\nexport const Tabindex = Extension.create<TabindexOptions>({\n  name: 'tabindex',\n\n  addOptions() {\n    return {\n      value: undefined,\n    }\n  },\n\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey('tabindex'),\n        props: {\n          attributes: (): { [name: string]: string } => {\n            if (!this.editor.isEditable && this.options.value === undefined) {\n              return {}\n            }\n            return { tabindex: this.options.value ?? '0' }\n          },\n        },\n      }),\n    ]\n  },\n})\n","import { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { Extension } from '../Extension.js'\nimport { splitExtensions } from '../helpers/splitExtensions.js'\n\nexport interface TextDirectionOptions {\n  direction: 'ltr' | 'rtl' | 'auto' | undefined\n}\n\n/**\n * The TextDirection extension adds support for setting text direction (LTR/RTL/auto)\n * on all nodes in the editor.\n *\n * This extension adds a global `dir` attribute to all node types, which can be used\n * to control bidirectional text rendering. The direction can be set globally via\n * editor options or per-node using commands.\n */\nexport const TextDirection = Extension.create<TextDirectionOptions>({\n  name: 'textDirection',\n\n  addOptions() {\n    return {\n      direction: undefined,\n    }\n  },\n\n  addGlobalAttributes() {\n    // Only add the dir attribute to nodes if text direction is configured\n    // This prevents null/undefined values from appearing in JSON exports\n    if (!this.options.direction) {\n      return []\n    }\n\n    const { nodeExtensions } = splitExtensions(this.extensions)\n\n    return [\n      {\n        types: nodeExtensions\n          .filter(extension => extension.name !== 'text')\n          .map(extension => extension.name),\n        attributes: {\n          dir: {\n            default: this.options.direction,\n            parseHTML: element => {\n              const dir = element.getAttribute('dir')\n\n              if (dir && (dir === 'ltr' || dir === 'rtl' || dir === 'auto')) {\n                return dir\n              }\n\n              return this.options.direction\n            },\n            renderHTML: attributes => {\n              if (!attributes.dir) {\n                return {}\n              }\n\n              return {\n                dir: attributes.dir,\n              }\n            },\n          },\n        },\n      },\n    ]\n  },\n\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey('textDirection'),\n        props: {\n          attributes: (): { [name: string]: string } => {\n            const direction = this.options.direction\n\n            if (!direction) {\n              return {}\n            }\n\n            return {\n              dir: direction,\n            }\n          },\n        },\n      }),\n    ]\n  },\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'\nexport { TextDirection } from './textDirection.js'\n","import type { Schema } from '@tiptap/pm/model'\nimport { Fragment } from '@tiptap/pm/model'\nimport { ReplaceStep } from '@tiptap/pm/transform'\n\nlet hasChecked = false\n\n/**\n * Warns once when prosemirror-model is loaded twice\n * @param schema The editor schema\n * @returns void\n * @example ```js\n * warnOnDuplicatedProseMirrorModel(editor.schema)\n * ```\n */\nexport function warnOnDuplicatedProseMirrorModel(schema: Schema): void {\n  if (hasChecked) {\n    return\n  }\n\n  hasChecked = true\n\n  let content\n\n  try {\n    // prosemirror-transform fills this step with the prosemirror-model it resolved\n    // itself, so a foreign fragment means a second copy is loaded.\n    content = ReplaceStep.fromJSON(schema, { from: 0, to: 0 }).slice.content\n  } catch {\n    // A warning we cannot stand behind is worse than no warning.\n    return\n  }\n\n  if (content instanceof Fragment) {\n    return\n  }\n\n  console.warn(\n    '[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.',\n  )\n}\n","import type { Fragment, Node, ResolvedPos } from '@tiptap/pm/model'\n\nimport type { Editor } from './Editor.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(pos: ResolvedPos, editor: Editor, isBlock = false, node: Node | null = null) {\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 this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1)\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      const isInline = node.isInline\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      // Only apply depth check for non-block, non-inline nodes (i.e., textblocks)\n      // Inline nodes should always be included as children since we're iterating\n      // over direct children via this.node.content\n      if (!isBlock && !isInline && $pos.depth <= this.depth) {\n        return\n      }\n\n      // Pass the node for both block and inline nodes to ensure correct node reference\n      const childNodePos = new NodePos(\n        $pos,\n        this.editor,\n        isBlock,\n        isBlock || isInline ? node : null,\n      )\n\n      if (isBlock) {\n        childNodePos.actualDepth = this.depth + 1\n      }\n\n      children.push(childNodePos)\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(selector: string, attributes: { [key: string]: any } = {}): 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(selector: string, attributes: { [key: string]: any } = {}): 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(childPos.querySelectorAll(selector, attributes, firstItemOnly))\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","/* oslint-disableno-empty-object-type */\nimport type { MarkType, Node as ProseMirrorNode, NodeType, Schema } from '@tiptap/pm/model'\nimport type { Plugin, PluginKey, Transaction } from '@tiptap/pm/state'\nimport { EditorState } from '@tiptap/pm/state'\nimport { type DirectEditorProps, EditorView } from '@tiptap/pm/view'\n\nimport { CommandManager } from './CommandManager.js'\nimport { isInDecorationApplyScope } from './decorations/decorationApplyScope.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  TextDirection,\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 { createMappablePosition, getUpdatedPosition } from './helpers/MappablePosition.js'\nimport { resolveFocusPosition } from './helpers/resolveFocusPosition.js'\nimport { warnOnDuplicatedProseMirrorModel } from './helpers/warnOnDuplicatedProseMirrorModel.js'\nimport type { Storage } from './index.js'\nimport { NodePos } from './NodePos.js'\nimport { style } from './style.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  Utils,\n} from './types.js'\nimport { createStyleTag } from './utilities/createStyleTag.js'\nimport { isDev } from './utilities/isDev.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?: Editor\n}\n\nexport class Editor extends EventEmitter<EditorEvents> {\n  private commandManager!: CommandManager\n\n  public extensionManager!: ExtensionManager\n\n  private css: HTMLStyleElement | null = null\n\n  private className = 'tiptap'\n\n  public schema!: Schema\n\n  private editorView: EditorView | null = null\n\n  public isFocused = false\n\n  private destroyed = 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   * A unique ID for this editor instance.\n   */\n  public instanceId = Math.random().toString(36).slice(2, 9)\n\n  private hasWarnedStaleDecorationRead = false\n\n  public options: EditorOptions = {\n    element: typeof document !== 'undefined' ? document.createElement('div') : null,\n    content: '',\n    injectCSS: true,\n    injectNonce: undefined,\n    extensions: [],\n    autofocus: false,\n    editable: true,\n    textDirection: undefined,\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    enableExtensionDispatchTransaction: true,\n  }\n\n  constructor(options: Partial<EditorOptions> = {}) {\n    super()\n    this.setOptions(options)\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 }) => this.options.onDrop(event, slice, moved))\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\n    // createDoc() already seeds editorState from the fallback doc on a content error\n    if (!this.editorState) {\n      const selection = resolveFocusPosition(initialDoc, this.options.autofocus)\n\n      this.editorState = EditorState.create({\n        doc: initialDoc,\n        schema: this.schema,\n        selection: selection || undefined,\n      })\n    }\n\n    warnOnDuplicatedProseMirrorModel(this.schema)\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        `[tiptap 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      if (this.options.autofocus !== false && this.options.autofocus !== null) {\n        this.commands.focus(this.options.autofocus)\n      }\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      // Keep the cached state in sync so plugin state stays available after unmount.\n      this.editorState = this.editorView.state\n\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    // Only remove CSS if no other editors exist in the document after unmount\n    if (this.css && !document.querySelectorAll(`.${this.className}`).length) {\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    if (!this.commandManager) {\n      return CommandManager.createFakeChain()\n    }\n\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    if (!this.commandManager) {\n      return CommandManager.createFallbackCan()\n    }\n\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', { editor: this, transaction: this.state.tr, appendedTransactions: [] })\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 view.\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: (state: EditorState): 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            `[tiptap error]: The editor view is not available. Cannot access view['${key as string}']. 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 (isDev && !this.hasWarnedStaleDecorationRead && isInDecorationApplyScope(this)) {\n      // Warn once per editor. The same read repeats on every transaction, and\n      // a decoration that dispatches from `create()` would flood the console.\n      this.hasWarnedStaleDecorationRead = true\n\n      console.warn(\n        '[tiptap warn]: `editor.state` was read while decoration `create()` was running. ' +\n          'It returns the pre-transaction document. Use the `state` argument passed to ' +\n          '`create()` instead. Helpers like `editor.isActive()` read `editor.state` too, ' +\n          'so pass `state` to their standalone versions instead of calling them on the editor.',\n      )\n    }\n\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)[]).concat(nameOrPluginKeyToRemove).forEach(nameOrPluginKey => {\n      // @ts-ignore\n      const name = typeof nameOrPluginKey === 'string' ? `${nameOrPluginKey}$` : 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?.blockSeparator,\n          }),\n          Commands,\n          FocusEvents,\n          Keymap,\n          Tabindex.configure({\n            value: this.options.coreExtensionOptions?.tabindex?.value,\n          }),\n          Drop,\n          Paste,\n          Delete,\n          TextDirection.configure({\n            direction: this.options.textDirection,\n          }),\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 = [...coreExtensions, ...this.options.extensions].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(this.options.content, this.schema, this.options.parseOptions, {\n        errorOnInvalidContent: this.options.enableContentCheck,\n      })\n    } catch (e) {\n      if (\n        !(e instanceof Error) ||\n        !['[tiptap error]: Invalid JSON content', '[tiptap error]: Invalid HTML content'].includes(\n          e.message,\n        )\n      ) {\n        // Not the content error we were expecting\n        throw e\n      }\n\n      // Content is invalid, but attempt to create it anyway, stripping out the invalid parts\n      const fallbackDoc = createDocument(\n        this.options.content,\n        this.schema,\n        this.options.parseOptions,\n        {\n          errorOnInvalidContent: false,\n        },\n      )\n\n      // Seed editorState with the fallback doc so a handler can safely use `editor.commands`\n      this.editorState = EditorState.create({\n        doc: fallbackDoc,\n        schema: this.schema,\n        selection: resolveFocusPosition(fallbackDoc, this.options.autofocus) || undefined,\n      })\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      return this.editorState.doc\n    }\n    return doc\n  }\n\n  /**\n   * Creates a ProseMirror view.\n   */\n  private createView(element: NonNullable<EditorOptions['element']>): void {\n    const { editorProps, enableExtensionDispatchTransaction } = this.options\n    // If a user provided a custom `dispatchTransaction` through `editorProps`,\n    // we use that as the base dispatch function.\n    // Otherwise, we use Tiptap's internal `dispatchTransaction` method.\n    const baseDispatch =\n      (editorProps as DirectEditorProps).dispatchTransaction || this.dispatchTransaction.bind(this)\n    const dispatch = enableExtensionDispatchTransaction\n      ? this.extensionManager.dispatchTransaction(baseDispatch)\n      : baseDispatch\n\n    // Compose transformPastedHTML from extensions and user-provided editorProps\n    const baseTransformPastedHTML = (editorProps as DirectEditorProps).transformPastedHTML\n    const transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML)\n\n    this.editorView = new EditorView(element, {\n      ...editorProps,\n      attributes: {\n        // add `role=\"textbox\"` to the editor element\n        role: 'textbox',\n        ...editorProps?.attributes,\n      },\n      dispatchTransaction: dispatch,\n      transformPastedHTML,\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    // 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 = `${this.className} ${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 => 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    const mostRecentFocusTr = transactions.findLast(tr => tr.getMeta('focus') || tr.getMeta('blur'))\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        // oxlint-disable-next-lineno-non-null-assertion\n        transaction: mostRecentFocusTr!,\n      })\n    }\n\n    if (blur) {\n      this.emit('blur', {\n        editor: this,\n        event: blur.event,\n        // oxlint-disable-next-lineno-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 => 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(nameOrType: string | NodeType | MarkType): 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(nameOrAttributes: string, attributesOrUndefined?: {}): boolean {\n    const name = typeof nameOrAttributes === 'string' ? nameOrAttributes : null\n\n    const attributes =\n      typeof nameOrAttributes === 'string' ? attributesOrUndefined : 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<string, undefined | Record<string, any>, any, (TNodeType | TTextType)[]>[]\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   * Destroy the editor.\n   */\n  public destroy(): void {\n    if (this.destroyed) {\n      return\n    }\n\n    this.destroyed = true\n\n    this.emit('destroy')\n    this.unmount()\n    this.removeAllListeners()\n\n    this.extensionManager.destroy()\n    this.extensionManager = null as any\n    this.schema = null as any\n    this.commandManager = null as unknown as CommandManager\n    this.extensionStorage = {} as Storage\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(selector: string, attributes?: { [key: string]: any }): NodePos | null {\n    return this.$doc?.querySelector(selector, attributes) || null\n  }\n\n  public $nodes(selector: string, attributes?: { [key: string]: any }): 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    // For positions directly before a non-text atom, resolvedPos.node() returns\n    // the parent, so pass the atom explicitly. Container nodes and $pos(0) keep\n    // resolving to the parent.\n    const node =\n      pos > 0 && $pos.nodeAfter && !$pos.nodeAfter.isText && $pos.nodeAfter.isAtom\n        ? $pos.nodeAfter\n        : null\n\n    return new NodePos($pos, this, false, node)\n  }\n\n  get $doc() {\n    return this.$pos(0)\n  }\n\n  /**\n   * Returns a set of utilities for working with positions and ranges.\n   */\n  public utils: Utils = {\n    getUpdatedPosition,\n    createMappablePosition,\n  }\n}\n","import type { Mark } from '@tiptap/pm/model'\nimport { DecorationAttrs, Decoration as PMDecoration, type EditorView } from '@tiptap/pm/view'\n\nexport interface WidgetDecorationOptions {\n  side?: number\n  relaxedSide?: boolean\n  marks?: readonly Mark[]\n  stopEvent?: (event: Event) => boolean\n  ignoreSelection?: boolean\n  /**\n   * runs when ProseMirror drops the widget, also on editor destroy and unmount.\n   * skipped on teardown for widgets made with the React or Vue widget renderer.\n   * receives the DOM node, not a ProseMirror node.\n   */\n  destroy?: (node: globalThis.Node) => void\n}\n\nexport type DecorationKind = 'inline' | 'node' | 'widget'\n\n/**\n * Base class for decorations built in `addDecorations()`. Shadows `Decoration`\n * from `@tiptap/pm/view`, like core's `Node` and `Mark` do, so alias one of them\n * in files that need both.\n *\n * @example\n * import { Decoration } from '@tiptap/core'\n * import { Decoration as PMDecoration } from '@tiptap/pm/view'\n *\n * const highlight = Decoration.Inline(1, 5, { class: 'highlight' })\n */\nexport abstract class Decoration {\n  abstract kind: DecorationKind\n  abstract get anchor(): number\n\n  /**\n   * Builds the ProseMirror decoration. When `extensionName` is provided,\n   * it is embedded into the decoration spec for incremental merge tracking.\n   * @param extensionName The name of the extension that produced this decoration.\n   * @returns The ProseMirror decoration.\n   */\n  abstract toPMDecoration(extensionName?: string): PMDecoration\n\n  static Inline(\n    from: number,\n    to: number,\n    attrs: DecorationAttrs = {},\n    spec?: Record<string, any>,\n  ): InlineDecoration {\n    return new InlineDecoration(from, to, attrs, spec)\n  }\n\n  static Node(\n    pos: number,\n    to: number,\n    attrs: DecorationAttrs = {},\n    spec?: Record<string, any>,\n  ): NodeDecoration {\n    return new NodeDecoration(pos, to, attrs, spec)\n  }\n\n  /**\n   * Creates a widget decoration: a DOM node drawn at a document position.\n   *\n   * The `key` is the widget's identity. While it stays the same, ProseMirror\n   * keeps the widget mounted and only its position tracks the document.\n   * `render`, `side`, `destroy` and other options are fixed on first mount.\n   * Change the key to remount with new options.\n   *\n   * @param pos The document position where the widget is drawn.\n   * @param render Called once on first mount. Returns the DOM node.\n   * @param options Must include a unique `key`. See `WidgetDecorationOptions`.\n   * @returns The widget decoration.\n   */\n  static Widget(\n    pos: number,\n    render: (view: EditorView, getPos: () => number | undefined) => HTMLElement,\n    options: { key: string } & WidgetDecorationOptions & Record<string, any>,\n  ): WidgetDecoration {\n    const { key, ...spec } = options\n\n    return new WidgetDecoration(pos, render, key, spec)\n  }\n}\n\n/**\n * Represents an inline decoration (text-level highlighting, etc.).\n */\nexport class InlineDecoration extends Decoration {\n  kind = 'inline' as const\n  from: number\n  to: number\n  attrs: DecorationAttrs\n  spec?: Record<string, any>\n\n  constructor(from: number, to: number, attrs: DecorationAttrs = {}, spec?: Record<string, any>) {\n    super()\n    this.from = from\n    this.to = to\n    this.attrs = attrs\n    this.spec = spec\n  }\n\n  get anchor(): number {\n    return this.from\n  }\n\n  toPMDecoration(extensionName?: string): PMDecoration {\n    const spec = extensionName ? { ...this.spec, extensionName } : this.spec\n\n    return PMDecoration.inline(this.from, this.to, this.attrs, spec)\n  }\n}\n\n/**\n * Represents a node-level decoration (block-level highlights, etc.).\n */\nexport class NodeDecoration extends Decoration {\n  kind = 'node' as const\n  from: number\n  to: number\n  attrs: DecorationAttrs\n  spec?: Record<string, any>\n\n  constructor(pos: number, to: number, attrs: DecorationAttrs = {}, spec?: Record<string, any>) {\n    super()\n    this.from = pos\n    this.to = to\n    this.attrs = attrs\n    this.spec = spec\n  }\n\n  get anchor(): number {\n    return this.from\n  }\n\n  toPMDecoration(extensionName?: string): PMDecoration {\n    const spec = extensionName ? { ...this.spec, extensionName } : this.spec\n\n    return PMDecoration.node(this.from, this.to, this.attrs, spec)\n  }\n}\n\n/**\n * Represents a widget decoration (inline widgets, etc.).\n */\nexport class WidgetDecoration extends Decoration {\n  kind = 'widget' as const\n  pos: number\n  key: string\n  render: (view: EditorView, getPos: () => number | undefined) => HTMLElement\n  spec?: WidgetDecorationOptions & Record<string, any>\n\n  constructor(\n    pos: number,\n    render: (view: EditorView, getPos: () => number | undefined) => HTMLElement,\n    key: string,\n    spec?: WidgetDecorationOptions & Record<string, any>,\n  ) {\n    super()\n    this.pos = pos\n    this.render = render\n    this.key = key\n    this.spec = spec\n  }\n\n  get anchor(): number {\n    return this.pos\n  }\n\n  toPMDecoration(extensionName?: string): PMDecoration {\n    const spec = extensionName\n      ? { ...this.spec, key: this.key, extensionName }\n      : { ...this.spec, key: this.key }\n\n    return PMDecoration.widget(this.pos, this.render, spec)\n  }\n}\n","import type { EditorView } from '@tiptap/pm/view'\n\nimport type { Editor } from '../Editor.js'\nimport { attrsEqual } from '../utilities/attrsEqual.js'\nimport { Decoration } from './Decoration.js'\nimport type { WidgetDecoration, WidgetDecorationOptions } from './Decoration.js'\nimport { liveWidgetKeys } from './DecorationManager.js'\n\n/**\n * The minimum a framework renderer must provide to be driven by\n * {@link createWidgetDecoration}. Both `ReactRenderer` and `VueRenderer` match it.\n */\nexport interface WidgetRenderer {\n  updateProps: (props: Record<string, any>) => void\n  destroy: () => void\n}\n\ninterface WidgetCache<TRenderer extends WidgetRenderer> {\n  /**\n   * The live renderer for each widget key, reused across recomputes so the\n   * component and its state are preserved instead of remounted.\n   */\n  renderers: Map<string, TRenderer>\n  /**\n   * Last props pushed to each widget. Skips updates when nothing changed.\n   */\n  props: Map<string, Record<string, any>>\n  /**\n   * Props queued during `create()` and pushed on the next microtask.\n   * Last write wins per key.\n   */\n  pendingProps: Map<string, Record<string, any>>\n  flushScheduled: boolean\n}\n\nexport interface CreateWidgetDecorationOptions<\n  TRenderer extends WidgetRenderer,\n> extends WidgetDecorationOptions {\n  /**\n   * The editor instance. The renderer cache is stored on it, so widgets are\n   * swept when the editor is destroyed.\n   */\n  editor: Editor\n  /**\n   * The document position the widget is rendered at.\n   */\n  pos: number\n  /**\n   * A stable, position-independent identifier for the widget. Reusing the same\n   * key keeps the component mounted across recomputes.\n   */\n  key: string\n  /**\n   * Props passed to the component, merged with {@link context} on every render.\n   */\n  props: Record<string, any>\n  /**\n   * The symbol the renderer cache is stored under on the editor. Use one\n   * dedicated symbol per framework package so caches never mix.\n   */\n  cacheKey: symbol\n  /**\n   * Extra props merged into every render, for example `editor` and `getPos`.\n   * Called on each materialization because `getPos` is view-bound.\n   */\n  context: (getPos: () => number | undefined) => Record<string, any>\n  /**\n   * Creates the renderer on first mount. Receives `props` and `context`\n   * already merged.\n   */\n  create: (props: Record<string, any>) => TRenderer\n  /**\n   * Returns the element ProseMirror inserts, plus any work that has to happen\n   * on every materialization (React re-registers its portal here).\n   */\n  materialize: (renderer: TRenderer) => HTMLElement\n}\n\nfunction getCache<TRenderer extends WidgetRenderer>(\n  editor: Editor,\n  cacheKey: symbol,\n): WidgetCache<TRenderer> {\n  const host = editor as Editor & Record<symbol, WidgetCache<TRenderer> | undefined>\n\n  let cache = host[cacheKey]\n\n  if (!cache) {\n    cache = {\n      renderers: new Map(),\n      props: new Map(),\n      pendingProps: new Map(),\n      flushScheduled: false,\n    }\n\n    host[cacheKey] = cache\n\n    const sweep = cache\n\n    // Sweep any widgets still mounted when the editor goes away.\n    editor.on('destroy', () => {\n      sweep.pendingProps.clear()\n      sweep.renderers.forEach(renderer => renderer.destroy())\n      sweep.renderers.clear()\n      sweep.props.clear()\n    })\n  }\n\n  return cache\n}\n\nfunction flushPendingProps<TRenderer extends WidgetRenderer>(cache: WidgetCache<TRenderer>): void {\n  cache.flushScheduled = false\n\n  for (const [key, props] of cache.pendingProps) {\n    const renderer = cache.renderers.get(key)\n\n    if (renderer) {\n      renderer.updateProps(props)\n      cache.props.set(key, { ...props })\n    }\n  }\n\n  cache.pendingProps.clear()\n}\n\n/**\n * Builds a widget decoration backed by a framework component renderer.\n *\n * Owns everything that is not framework specific: the per-editor renderer\n * cache, prop diffing, the deferred prop flush, the key reassignment guard and\n * the ProseMirror option pass-through. Framework packages supply only `create`,\n * `context` and `materialize`.\n *\n * @param options The widget options plus the three framework hooks.\n * @returns The widget decoration to return from `addDecorations`.\n * @example\n * createWidgetDecoration<ReactRenderer>({\n *   editor, pos, key, props, cacheKey: WIDGET_CACHE,\n *   context: getPos => ({ editor, getPos }),\n *   create: renderProps => new ReactRenderer(component, { editor, props: renderProps }),\n *   materialize: renderer => renderer.element,\n * })\n */\nexport function createWidgetDecoration<TRenderer extends WidgetRenderer>(\n  options: CreateWidgetDecorationOptions<TRenderer>,\n): WidgetDecoration {\n  const {\n    editor,\n    pos,\n    key,\n    props,\n    cacheKey,\n    context,\n    create,\n    materialize,\n    side,\n    relaxedSide,\n    marks,\n    stopEvent,\n    ignoreSelection,\n    destroy,\n  } = options\n  const cache = getCache<TRenderer>(editor, cacheKey)\n\n  // Queue prop updates for already-mounted widgets. This code runs inside\n  // ProseMirror's `state.apply`, which must stay pure, so the renderer is only\n  // touched on the next microtask. ProseMirror skips `render` when it reuses\n  // DOM, so the flush is the only update path for a mounted widget.\n  if (cache.renderers.has(key)) {\n    const previous = cache.pendingProps.get(key) ?? cache.props.get(key)\n\n    if (!previous || !attrsEqual(previous, props)) {\n      cache.pendingProps.set(key, props)\n\n      if (!cache.flushScheduled) {\n        cache.flushScheduled = true\n        queueMicrotask(() => flushPendingProps(cache))\n      }\n    }\n  }\n\n  const render = (_view: EditorView, getPos: () => number | undefined): HTMLElement => {\n    const renderProps = { ...props, ...context(getPos) }\n    let renderer = cache.renderers.get(key)\n\n    if (renderer) {\n      renderer.updateProps(renderProps)\n    } else {\n      renderer = create(renderProps)\n      cache.renderers.set(key, renderer)\n      cache.props.set(key, { ...props })\n    }\n\n    return materialize(renderer)\n  }\n\n  return Decoration.Widget(pos, render, {\n    key,\n    side,\n    relaxedSide,\n    marks,\n    stopEvent,\n    ignoreSelection,\n    destroy: (rendererElement: globalThis.Node) => {\n      // Keep the renderer if the widget is still live (being reassigned, not removed).\n      // Only correct because ProseMirror sets `view.state` before dropping widget descs.\n      if (liveWidgetKeys(editor).has(key)) {\n        return\n      }\n\n      try {\n        cache.renderers.get(key)?.destroy()\n        cache.renderers.delete(key)\n        cache.props.delete(key)\n        cache.pendingProps.delete(key)\n      } finally {\n        destroy?.(rendererElement)\n      }\n    },\n  })\n}\n","import type { MarkType } from '@tiptap/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?:\n    | Record<string, any>\n    | ((match: ExtendedRegExpMatchArray) => Record<string, any>)\n    | false\n    | 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 '@tiptap/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?:\n    | Record<string, any>\n    | ((match: ExtendedRegExpMatchArray) => Record<string, any>)\n    | false\n    | 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(\n          tr.mapping.map(start),\n          tr.mapping.map(end),\n        )\n      }\n\n      tr.scrollIntoView()\n    },\n    undoable: config.undoable,\n  })\n}\n","import type { NodeType } from '@tiptap/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?:\n    | Record<string, any>\n    | ((match: ExtendedRegExpMatchArray) => Record<string, any>)\n    | false\n    | 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\n        .delete(range.from, range.to)\n        .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: {\n  find: InputRuleFinder\n  replace: string\n  undoable?: boolean\n}) {\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 { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model'\nimport { canJoin, findWrapping } from '@tiptap/pm/transform'\n\nimport type { Editor } from '../Editor.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?: (match: ExtendedRegExpMatchArray, node: ProseMirrorNode) => boolean\n}) {\n  return new InputRule({\n    find: config.find,\n    handler: ({ state, range, match, chain }) => {\n      const attributes = 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 = 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 = storedMarks || (selection.$to.parentOffset && selection.$from.marks())\n\n        if (marks) {\n          const filteredMarks = marks.filter(mark => splittableMarks.includes(mark.type.name))\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' || 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// Child lists and DOM output specs are both arrays, so track JSX boundaries by identity.\nconst jsxElements = new WeakSet<DOMOutputSpecArray>()\nconst jsxFragments = new WeakSet<unknown[]>()\n\n/** Create a new JSX element from the given spec */\nfunction createJSXElement(spec: unknown[]): DOMOutputSpecArray {\n  const element = spec as DOMOutputSpecArray\n\n  jsxElements.add(element)\n\n  return element\n}\n\n/** Check if a spec is a JSX element */\nfunction isJSXElement(value: unknown): value is DOMOutputSpecArray {\n  return Array.isArray(value) && jsxElements.has(value as DOMOutputSpecArray)\n}\n\nfunction flattenFragmentChildren(children: unknown[]): unknown[] {\n  return children.flatMap(child => {\n    if (child == null) {\n      return []\n    }\n\n    if (Array.isArray(child) && jsxFragments.has(child) && !isJSXElement(child)) {\n      return flattenFragmentChildren(child)\n    }\n\n    return [child]\n  })\n}\n\n// JSX types for Tiptap's JSX runtime\n// These types only apply when using @jsxImportSource @tiptap/core\nexport declare namespace JSX {\n  export type Element = DOMOutputSpecArray\n  export interface IntrinsicElements {\n    [key: string]: any\n  }\n  export interface ElementChildrenAttribute {\n    children: unknown\n  }\n}\n\ntype JSXChild = DOMOutputSpecElement | string | null | undefined | JSXChild[]\n\nexport type JSXRenderer = (\n  tag: 'slot' | string | ((props?: Attributes) => DOMOutputSpecArray | DOMOutputSpecElement),\n  props?: Attributes,\n  ...children: JSXChild[]\n) => DOMOutputSpecArray | DOMOutputSpecElement\n\nexport function Fragment(props: { children: JSXChild[] }) {\n  jsxFragments.add(props.children)\n\n  return props.children\n}\n\nfunction render(tag: Parameters<JSXRenderer>[0], attributes: Attributes | undefined) {\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    const result = tag(attributes)\n\n    if (Array.isArray(result) && !isJSXElement(result) && !jsxFragments.has(result)) {\n      return createJSXElement(result)\n    }\n\n    return result\n  }\n\n  const { children, ...rest } = attributes ?? {}\n\n  if (tag === 'svg') {\n    throw new Error(\n      'SVG elements are not supported in the JSX syntax, use the array syntax instead',\n    )\n  }\n\n  // Handle children array by spreading elements\n  if (Array.isArray(children)) {\n    if (isJSXElement(children)) {\n      return createJSXElement([tag, rest, children])\n    }\n\n    if (children.length === 0) {\n      // Empty array means no children\n      return createJSXElement([tag, rest])\n    }\n\n    const flattenedChildren = flattenFragmentChildren(children)\n\n    if (flattenedChildren.length === 0) {\n      return createJSXElement([tag, rest])\n    }\n\n    // Spread children into the result array\n    return createJSXElement([tag, rest, ...flattenedChildren])\n  }\n\n  // Single child or no children\n  if (children !== undefined && children !== null) {\n    return createJSXElement([tag, rest, children])\n  }\n\n  return createJSXElement([tag, rest])\n}\n\nexport const h: JSXRenderer = (tag, attributes) => render(tag, attributes)\n\nexport const jsxs: JSXRenderer = (tag, attributes) => render(tag, attributes)\n\nexport const jsxDEV = (\n  tag: Parameters<JSXRenderer>[0],\n  attributes?: Attributes,\n  _key?: unknown,\n  _isStaticChildren?: boolean,\n) => {\n  return render(tag, attributes)\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 }\n","import type { Node as PMNode } from '@tiptap/pm/model'\nimport type { Decoration, DecorationSource, NodeView } from '@tiptap/pm/view'\n\nimport type { Editor } from '../Editor.js'\n\nconst isTouchEvent = (e: MouseEvent | TouchEvent): e is TouchEvent => {\n  return 'touches' in e\n}\n\n/**\n * Directions where resize handles can be placed\n *\n * @example\n * - `'top'` - Top edge handle\n * - `'bottom-right'` - Bottom-right corner handle\n */\nexport type ResizableNodeViewDirection =\n  | 'top'\n  | 'right'\n  | 'bottom'\n  | 'left'\n  | 'top-right'\n  | 'top-left'\n  | 'bottom-right'\n  | 'bottom-left'\n\n/**\n * Dimensions for the resizable node in pixels\n */\nexport type ResizableNodeDimensions = {\n  /** Width in pixels */\n  width: number\n  /** Height in pixels */\n  height: number\n}\n\n/**\n * Configuration options for creating a ResizableNodeView\n *\n * @example\n * ```ts\n * new ResizableNodeView({\n *   element: imgElement,\n *   node,\n *   getPos,\n *   onResize: (width, height) => {\n *     imgElement.style.width = `${width}px`\n *     imgElement.style.height = `${height}px`\n *   },\n *   onCommit: (width, height) => {\n *     editor.commands.updateAttributes('image', { width, height })\n *   },\n *   onUpdate: (node) => true,\n *   options: {\n *     directions: ['bottom-right', 'bottom-left'],\n *     min: { width: 100, height: 100 },\n *     preserveAspectRatio: true\n *   }\n * })\n * ```\n */\nexport type ResizableNodeViewOptions = {\n  /**\n   * The DOM element to make resizable (e.g., an img, video, or iframe element)\n   */\n  element: HTMLElement\n\n  /**\n   * The DOM element that will hold the editable content element\n   */\n  contentElement?: HTMLElement\n\n  /**\n   * The ProseMirror node instance\n   */\n  node: PMNode\n\n  /**\n   * The Tiptap editor instance\n   */\n  editor: Editor\n\n  /**\n   * Function that returns the current position of the node in the document\n   */\n  getPos: () => number | undefined\n\n  /**\n   * Callback fired continuously during resize with current dimensions.\n   * Use this to update the element's visual size in real-time.\n   *\n   * @param width - Current width in pixels\n   * @param height - Current height in pixels\n   *\n   * @example\n   * ```ts\n   * onResize: (width, height) => {\n   *   element.style.width = `${width}px`\n   *   element.style.height = `${height}px`\n   * }\n   * ```\n   */\n  onResize?: (width: number, height: number) => void\n\n  /**\n   * Callback fired once when resize completes with final dimensions.\n   * Use this to persist the new size to the node's attributes.\n   *\n   * @param width - Final width in pixels\n   * @param height - Final height in pixels\n   *\n   * @example\n   * ```ts\n   * onCommit: (width, height) => {\n   *   const pos = getPos()\n   *   if (pos !== undefined) {\n   *     editor.commands.updateAttributes('image', { width, height })\n   *   }\n   * }\n   * ```\n   */\n  onCommit: (width: number, height: number) => void\n\n  /**\n   * Callback for handling node updates.\n   * Return `true` to accept the update, `false` to reject it.\n   *\n   * @example\n   * ```ts\n   * onUpdate: (node, decorations, innerDecorations) => {\n   *   if (node.type !== this.node.type) return false\n   *   return true\n   * }\n   * ```\n   */\n  onUpdate: NodeView['update']\n\n  /**\n   * Optional configuration for resize behavior and styling\n   */\n  options?: {\n    /**\n     * Which resize handles to display.\n     * @default ['bottom-left', 'bottom-right', 'top-left', 'top-right']\n     *\n     * @example\n     * ```ts\n     * // Only show corner handles\n     * directions: ['top-left', 'top-right', 'bottom-left', 'bottom-right']\n     *\n     * // Only show right edge handle\n     * directions: ['right']\n     * ```\n     */\n    directions?: ResizableNodeViewDirection[]\n\n    /**\n     * Minimum dimensions in pixels\n     * @default { width: 8, height: 8 }\n     *\n     * @example\n     * ```ts\n     * min: { width: 100, height: 50 }\n     * ```\n     */\n    min?: Partial<ResizableNodeDimensions>\n\n    /**\n     * Maximum dimensions in pixels\n     * @default undefined (no maximum)\n     *\n     * @example\n     * ```ts\n     * max: { width: 1000, height: 800 }\n     * ```\n     */\n    max?: Partial<ResizableNodeDimensions>\n\n    /**\n     * Always preserve aspect ratio when resizing.\n     * When `false`, aspect ratio is preserved only when Shift key is pressed.\n     * @default false\n     *\n     * @example\n     * ```ts\n     * preserveAspectRatio: true // Always lock aspect ratio\n     * ```\n     */\n    preserveAspectRatio?: boolean\n\n    /**\n     * Custom CSS class names for styling\n     *\n     * @example\n     * ```ts\n     * className: {\n     *   container: 'resize-container',\n     *   wrapper: 'resize-wrapper',\n     *   handle: 'resize-handle',\n     *   resizing: 'is-resizing'\n     * }\n     * ```\n     */\n    className?: {\n      /** Class for the outer container element */\n      container?: string\n      /** Class for the wrapper element that contains the resizable element */\n      wrapper?: string\n      /** Class applied to all resize handles */\n      handle?: string\n      /** Class added to container while actively resizing */\n      resizing?: string\n    }\n\n    /**\n     * Optional callback for creating custom resize handle elements.\n     *\n     * This function allows developers to define their own handle element\n     * (e.g., custom icons, classes, or styles) for a given resize direction.\n     * It is called internally for each handle direction.\n     *\n     * @param direction - The direction of the handle being created (e.g., 'top', 'bottom-right').\n     * @returns The custom handle HTMLElement.\n     *\n     * @example\n     * ```ts\n     * createCustomHandle: (direction) => {\n     *   const handle = document.createElement('div')\n     *   handle.dataset.resizeHandle = direction\n     *   handle.style.position = 'absolute'\n     *   handle.className = 'tiptap-custom-handle'\n     *\n     *   const isTop = direction.includes('top')\n     *   const isBottom = direction.includes('bottom')\n     *   const isLeft = direction.includes('left')\n     *   const isRight = direction.includes('right')\n     *\n     *   if (isTop) handle.style.top = '0'\n     *   if (isBottom) handle.style.bottom = '0'\n     *   if (isLeft) handle.style.left = '0'\n     *   if (isRight) handle.style.right = '0'\n     *\n     *   // Edge handles span the full width or height\n     *   if (direction === 'top' || direction === 'bottom') {\n     *     handle.style.left = '0'\n     *     handle.style.right = '0'\n     *   }\n     *\n     *   if (direction === 'left' || direction === 'right') {\n     *     handle.style.top = '0'\n     *     handle.style.bottom = '0'\n     *   }\n     *\n     *   return handle\n     * }\n     * ```\n     */\n    createCustomHandle?: (direction: ResizableNodeViewDirection) => HTMLElement\n  }\n}\n\n/**\n * A NodeView implementation that adds resize handles to any DOM element.\n *\n * This class creates a resizable node view for Tiptap/ProseMirror editors.\n * It wraps your element with resize handles and manages the resize interaction,\n * including aspect ratio preservation, min/max constraints, and keyboard modifiers.\n *\n * @example\n * ```ts\n * // Basic usage in a Tiptap extension\n * addNodeView() {\n *   return ({ node, getPos }) => {\n *     const img = document.createElement('img')\n *     img.src = node.attrs.src\n *\n *     return new ResizableNodeView({\n *       element: img,\n *       node,\n *       getPos,\n *       onResize: (width, height) => {\n *         img.style.width = `${width}px`\n *         img.style.height = `${height}px`\n *       },\n *       onCommit: (width, height) => {\n *         this.editor.commands.updateAttributes('image', { width, height })\n *       },\n *       onUpdate: () => true,\n *       options: {\n *         min: { width: 100, height: 100 },\n *         preserveAspectRatio: true\n *       }\n *     })\n *   }\n * }\n * ```\n */\nexport class ResizableNodeView {\n  /** The ProseMirror node instance */\n  node: PMNode\n\n  /** The Tiptap editor instance */\n  editor: Editor\n\n  /** The DOM element being made resizable */\n  element: HTMLElement\n\n  /** The editable DOM element inside the DOM */\n  contentElement?: HTMLElement\n\n  /** The outer container element (returned as NodeView.dom) */\n  container: HTMLElement\n\n  /** The wrapper element that contains the element and handles */\n  wrapper: HTMLElement\n\n  /** Function to get the current node position */\n  getPos: () => number | undefined\n\n  /** Callback fired during resize */\n  onResize?: (width: number, height: number) => void\n\n  /** Callback fired when resize completes */\n  onCommit: (width: number, height: number) => void\n\n  /** Callback for node updates */\n  onUpdate?: NodeView['update']\n\n  /** Active resize handle directions */\n  directions: ResizableNodeViewDirection[] = [\n    'bottom-left',\n    'bottom-right',\n    'top-left',\n    'top-right',\n  ]\n\n  /** Minimum allowed dimensions */\n  minSize: ResizableNodeDimensions = {\n    height: 8,\n    width: 8,\n  }\n\n  /** Maximum allowed dimensions (optional) */\n  maxSize?: Partial<ResizableNodeDimensions>\n\n  /** Whether to always preserve aspect ratio */\n  preserveAspectRatio: boolean = false\n\n  /** CSS class names for elements */\n  classNames = {\n    container: '',\n    wrapper: '',\n    handle: '',\n    resizing: '',\n  }\n\n  /** Optional callback for creating custom resize handles */\n  createCustomHandle?: (direction: ResizableNodeViewDirection) => HTMLElement\n\n  /** Initial width of the element (for aspect ratio calculation) */\n  private initialWidth: number = 0\n\n  /** Initial height of the element (for aspect ratio calculation) */\n  private initialHeight: number = 0\n\n  /** Calculated aspect ratio (width / height) */\n  private aspectRatio: number = 1\n\n  /** Whether a resize operation is currently active */\n  private isResizing: boolean = false\n\n  /** The handle currently being dragged */\n  private activeHandle: ResizableNodeViewDirection | null = null\n\n  /** Starting mouse X position when resize began */\n  private startX: number = 0\n\n  /** Starting mouse Y position when resize began */\n  private startY: number = 0\n\n  /** Element width when resize began */\n  private startWidth: number = 0\n\n  /** Element height when resize began */\n  private startHeight: number = 0\n\n  /** Whether Shift key is currently pressed (for temporary aspect ratio lock) */\n  private isShiftKeyPressed: boolean = false\n\n  /** Last known editable state of the editor */\n  private lastEditableState: boolean | undefined = undefined\n\n  /** Map of handle elements by direction */\n  private handleMap = new Map<ResizableNodeViewDirection, HTMLElement>()\n\n  /**\n   * Creates a new ResizableNodeView instance.\n   *\n   * The constructor sets up the resize handles, applies initial sizing from\n   * node attributes, and configures all resize behavior options.\n   *\n   * @param options - Configuration options for the resizable node view\n   */\n  constructor(options: ResizableNodeViewOptions) {\n    this.node = options.node\n    this.editor = options.editor\n    this.element = options.element\n    this.element.draggable = false\n    this.contentElement = options.contentElement\n\n    this.getPos = options.getPos\n\n    this.onResize = options.onResize\n    this.onCommit = options.onCommit\n    this.onUpdate = options.onUpdate\n\n    if (options.options?.min) {\n      this.minSize = {\n        ...this.minSize,\n        ...options.options.min,\n      }\n    }\n\n    if (options.options?.max) {\n      this.maxSize = options.options.max\n    }\n\n    if (options?.options?.directions) {\n      this.directions = options.options.directions\n    }\n\n    if (options.options?.preserveAspectRatio) {\n      this.preserveAspectRatio = options.options.preserveAspectRatio\n    }\n\n    if (options.options?.className) {\n      this.classNames = {\n        container: options.options.className.container || '',\n        wrapper: options.options.className.wrapper || '',\n        handle: options.options.className.handle || '',\n        resizing: options.options.className.resizing || '',\n      }\n    }\n\n    if (options.options?.createCustomHandle) {\n      this.createCustomHandle = options.options.createCustomHandle\n    }\n\n    this.wrapper = this.createWrapper()\n    this.container = this.createContainer()\n\n    this.applyInitialSize()\n    this.attachHandles()\n\n    this.editor.on('update', this.handleEditorUpdate.bind(this))\n  }\n\n  /**\n   * Returns the top-level DOM node that should be placed in the editor.\n   *\n   * This is required by the ProseMirror NodeView interface. The container\n   * includes the wrapper, handles, and the actual content element.\n   *\n   * @returns The container element to be inserted into the editor\n   */\n  get dom() {\n    return this.container\n  }\n\n  get contentDOM(): HTMLElement | null {\n    return this.contentElement ?? null\n  }\n\n  private handleEditorUpdate() {\n    const isEditable = this.editor.isEditable\n\n    // Only if state actually changed\n    if (isEditable === this.lastEditableState) {\n      return\n    }\n\n    this.lastEditableState = isEditable\n\n    if (!isEditable) {\n      this.removeHandles()\n    } else if (isEditable && this.handleMap.size === 0) {\n      this.attachHandles()\n    }\n  }\n\n  /**\n   * Called when the node's content or attributes change.\n   *\n   * Updates the internal node reference. If a custom `onUpdate` callback\n   * was provided, it will be called to handle additional update logic.\n   *\n   * @param node - The new/updated node\n   * @param decorations - Node decorations\n   * @param innerDecorations - Inner decorations\n   * @returns `false` if the node type has changed (requires full rebuild), otherwise the result of `onUpdate` or `true`\n   */\n  update(\n    node: PMNode,\n    decorations: readonly Decoration[],\n    innerDecorations: DecorationSource,\n  ): boolean {\n    if (node.type !== this.node.type) {\n      return false\n    }\n\n    this.node = node\n\n    if (this.onUpdate) {\n      return this.onUpdate(node, decorations, innerDecorations)\n    }\n\n    return true\n  }\n\n  /**\n   * Cleanup method called when the node view is being removed.\n   *\n   * Removes all event listeners to prevent memory leaks. This is required\n   * by the ProseMirror NodeView interface. If a resize is active when\n   * destroy is called, it will be properly cancelled.\n   */\n  destroy() {\n    if (this.isResizing) {\n      this.container.dataset.resizeState = 'false'\n\n      if (this.classNames.resizing) {\n        this.container.classList.remove(this.classNames.resizing)\n      }\n\n      document.removeEventListener('mousemove', this.handleMouseMove)\n      document.removeEventListener('mouseup', this.handleMouseUp)\n      document.removeEventListener('keydown', this.handleKeyDown)\n      document.removeEventListener('keyup', this.handleKeyUp)\n      this.isResizing = false\n      this.activeHandle = null\n    }\n\n    this.editor.off('update', this.handleEditorUpdate.bind(this))\n\n    this.container.remove()\n  }\n\n  /**\n   * Creates the outer container element.\n   *\n   * The container is the top-level element returned by the NodeView and\n   * wraps the entire resizable node. It's set up with flexbox to handle\n   * alignment and includes data attributes for styling and identification.\n   *\n   * @returns The container element\n   */\n  createContainer() {\n    const element = document.createElement('div')\n    element.dataset.resizeContainer = ''\n    element.dataset.node = this.node.type.name\n    element.style.display = this.node.type.isInline ? 'inline-flex' : 'flex'\n\n    if (this.classNames.container) {\n      element.className = this.classNames.container\n    }\n\n    element.appendChild(this.wrapper)\n\n    return element\n  }\n\n  /**\n   * Creates the wrapper element that contains the content and handles.\n   *\n   * The wrapper uses relative positioning so that resize handles can be\n   * positioned absolutely within it. This is the direct parent of the\n   * content element being made resizable.\n   *\n   * @returns The wrapper element\n   */\n  createWrapper() {\n    const element = document.createElement('div')\n    element.style.position = 'relative'\n    element.style.display = 'block'\n    element.dataset.resizeWrapper = ''\n\n    if (this.classNames.wrapper) {\n      element.className = this.classNames.wrapper\n    }\n\n    element.appendChild(this.element)\n\n    return element\n  }\n\n  /**\n   * Creates a resize handle element for a specific direction.\n   *\n   * Each handle is absolutely positioned and includes a data attribute\n   * identifying its direction for styling purposes.\n   *\n   * @param direction - The resize direction for this handle\n   * @returns The handle element\n   */\n  private createHandle(direction: ResizableNodeViewDirection): HTMLElement {\n    const handle = document.createElement('div')\n    handle.dataset.resizeHandle = direction\n    handle.style.position = 'absolute'\n\n    if (this.classNames.handle) {\n      handle.className = this.classNames.handle\n    }\n\n    return handle\n  }\n\n  /**\n   * Positions a handle element according to its direction.\n   *\n   * Corner handles (e.g., 'top-left') are positioned at the intersection\n   * of two edges. Edge handles (e.g., 'top') span the full width or height.\n   *\n   * @param handle - The handle element to position\n   * @param direction - The direction determining the position\n   */\n  private positionHandle(handle: HTMLElement, direction: ResizableNodeViewDirection): void {\n    const isTop = direction.includes('top')\n    const isBottom = direction.includes('bottom')\n    const isLeft = direction.includes('left')\n    const isRight = direction.includes('right')\n\n    if (isTop) {\n      handle.style.top = '0'\n    }\n\n    if (isBottom) {\n      handle.style.bottom = '0'\n    }\n\n    if (isLeft) {\n      handle.style.left = '0'\n    }\n\n    if (isRight) {\n      handle.style.right = '0'\n    }\n\n    // Edge handles span the full width or height\n    if (direction === 'top' || direction === 'bottom') {\n      handle.style.left = '0'\n      handle.style.right = '0'\n    }\n\n    if (direction === 'left' || direction === 'right') {\n      handle.style.top = '0'\n      handle.style.bottom = '0'\n    }\n  }\n\n  /**\n   * Creates and attaches all resize handles to the wrapper.\n   *\n   * Iterates through the configured directions, creates a handle for each,\n   * positions it, attaches the mousedown listener, and appends it to the DOM.\n   */\n  private attachHandles(): void {\n    this.directions.forEach(direction => {\n      let handle: HTMLElement\n\n      if (this.createCustomHandle) {\n        handle = this.createCustomHandle(direction)\n      } else {\n        handle = this.createHandle(direction)\n      }\n\n      if (!(handle instanceof HTMLElement)) {\n        console.warn(\n          `[ResizableNodeView] createCustomHandle(\"${direction}\") did not return an HTMLElement. Falling back to default handle.`,\n        )\n        handle = this.createHandle(direction)\n      }\n\n      if (!this.createCustomHandle) {\n        this.positionHandle(handle, direction)\n      }\n\n      handle.addEventListener('mousedown', event => this.handleResizeStart(event, direction))\n      handle.addEventListener('touchstart', event =>\n        this.handleResizeStart(event as unknown as MouseEvent, direction),\n      )\n\n      this.handleMap.set(direction, handle)\n\n      this.wrapper.appendChild(handle)\n    })\n  }\n\n  /**\n   * Removes all resize handles from the wrapper.\n   *\n   * Cleans up the handle map and removes each handle element from the DOM.\n   */\n  private removeHandles(): void {\n    this.handleMap.forEach(el => el.remove())\n    this.handleMap.clear()\n  }\n\n  /**\n   * Applies initial sizing from node attributes to the element.\n   *\n   * If width/height attributes exist on the node, they're applied to the element.\n   * Otherwise, the element's natural/current dimensions are measured. The aspect\n   * ratio is calculated for later use in aspect-ratio-preserving resizes.\n   */\n  private applyInitialSize(): void {\n    const width = this.node.attrs.width as number | undefined\n    const height = this.node.attrs.height as number | undefined\n\n    if (width) {\n      this.element.style.width = `${width}px`\n      this.initialWidth = width\n    } else {\n      this.initialWidth = this.element.offsetWidth\n    }\n\n    if (height) {\n      this.element.style.height = `${height}px`\n      this.initialHeight = height\n    } else {\n      this.initialHeight = this.element.offsetHeight\n    }\n\n    // Calculate aspect ratio for use during resizing\n    if (this.initialWidth > 0 && this.initialHeight > 0) {\n      this.aspectRatio = this.initialWidth / this.initialHeight\n    }\n  }\n\n  /**\n   * Initiates a resize operation when a handle is clicked.\n   *\n   * Captures the starting mouse position and element dimensions, sets up\n   * the resize state, adds the resizing class and state attribute, and\n   * attaches document-level listeners for mouse movement and keyboard input.\n   *\n   * @param event - The mouse down event\n   * @param direction - The direction of the handle being dragged\n   */\n  private handleResizeStart(\n    event: MouseEvent | TouchEvent,\n    direction: ResizableNodeViewDirection,\n  ): void {\n    event.preventDefault()\n    event.stopPropagation()\n\n    // Capture initial state\n    this.isResizing = true\n    this.activeHandle = direction\n\n    if (isTouchEvent(event)) {\n      this.startX = event.touches[0].clientX\n      this.startY = event.touches[0].clientY\n    } else {\n      this.startX = event.clientX\n      this.startY = event.clientY\n    }\n\n    this.startWidth = this.element.offsetWidth\n    this.startHeight = this.element.offsetHeight\n\n    // Recalculate aspect ratio at resize start for accuracy\n    if (this.startWidth > 0 && this.startHeight > 0) {\n      this.aspectRatio = this.startWidth / this.startHeight\n    }\n\n    const pos = this.getPos()\n    if (pos !== undefined) {\n      // TODO: Select the node in the editor\n    }\n\n    // Update UI state\n    this.container.dataset.resizeState = 'true'\n\n    if (this.classNames.resizing) {\n      this.container.classList.add(this.classNames.resizing)\n    }\n\n    // Attach document-level listeners for resize\n    document.addEventListener('mousemove', this.handleMouseMove)\n    document.addEventListener('touchmove', this.handleTouchMove)\n    document.addEventListener('mouseup', this.handleMouseUp)\n    document.addEventListener('keydown', this.handleKeyDown)\n    document.addEventListener('keyup', this.handleKeyUp)\n  }\n\n  /**\n   * Handles mouse movement during an active resize.\n   *\n   * Calculates the delta from the starting position, computes new dimensions\n   * based on the active handle direction, applies constraints and aspect ratio,\n   * then updates the element's style and calls the onResize callback.\n   *\n   * @param event - The mouse move event\n   */\n  private handleMouseMove = (event: MouseEvent): void => {\n    if (!this.isResizing || !this.activeHandle) {\n      return\n    }\n\n    const deltaX = event.clientX - this.startX\n    const deltaY = event.clientY - this.startY\n\n    this.handleResize(deltaX, deltaY)\n  }\n\n  private handleTouchMove = (event: TouchEvent): void => {\n    if (!this.isResizing || !this.activeHandle) {\n      return\n    }\n\n    const touch = event.touches[0]\n    if (!touch) {\n      return\n    }\n\n    const deltaX = touch.clientX - this.startX\n    const deltaY = touch.clientY - this.startY\n\n    this.handleResize(deltaX, deltaY)\n  }\n\n  private handleResize(deltaX: number, deltaY: number) {\n    if (!this.activeHandle) {\n      return\n    }\n\n    const shouldPreserveAspectRatio = this.preserveAspectRatio || this.isShiftKeyPressed\n    const { width, height } = this.calculateNewDimensions(this.activeHandle, deltaX, deltaY)\n    const constrained = this.applyConstraints(width, height, shouldPreserveAspectRatio)\n\n    this.element.style.width = `${constrained.width}px`\n    this.element.style.height = `${constrained.height}px`\n\n    if (this.onResize) {\n      this.onResize(constrained.width, constrained.height)\n    }\n  }\n\n  /**\n   * Completes the resize operation when the mouse button is released.\n   *\n   * Captures final dimensions, calls the onCommit callback to persist changes,\n   * removes the resizing state and class, and cleans up document-level listeners.\n   */\n  private handleMouseUp = (): void => {\n    if (!this.isResizing) {\n      return\n    }\n\n    const finalWidth = this.element.offsetWidth\n    const finalHeight = this.element.offsetHeight\n\n    this.onCommit(finalWidth, finalHeight)\n\n    this.isResizing = false\n    this.activeHandle = null\n\n    // Remove UI state\n    this.container.dataset.resizeState = 'false'\n\n    if (this.classNames.resizing) {\n      this.container.classList.remove(this.classNames.resizing)\n    }\n\n    // Clean up document-level listeners\n    document.removeEventListener('mousemove', this.handleMouseMove)\n    document.removeEventListener('mouseup', this.handleMouseUp)\n    document.removeEventListener('keydown', this.handleKeyDown)\n    document.removeEventListener('keyup', this.handleKeyUp)\n  }\n\n  /**\n   * Tracks Shift key state to enable temporary aspect ratio locking.\n   *\n   * When Shift is pressed during resize, aspect ratio is preserved even if\n   * preserveAspectRatio is false.\n   *\n   * @param event - The keyboard event\n   */\n  private handleKeyDown = (event: KeyboardEvent): void => {\n    if (event.key === 'Shift') {\n      this.isShiftKeyPressed = true\n    }\n  }\n\n  /**\n   * Tracks Shift key release to disable temporary aspect ratio locking.\n   *\n   * @param event - The keyboard event\n   */\n  private handleKeyUp = (event: KeyboardEvent): void => {\n    if (event.key === 'Shift') {\n      this.isShiftKeyPressed = false\n    }\n  }\n\n  /**\n   * Calculates new dimensions based on mouse delta and resize direction.\n   *\n   * Takes the starting dimensions and applies the mouse movement delta\n   * according to the handle direction. For corner handles, both dimensions\n   * are affected. For edge handles, only one dimension changes. If aspect\n   * ratio should be preserved, delegates to applyAspectRatio.\n   *\n   * @param direction - The active resize handle direction\n   * @param deltaX - Horizontal mouse movement since resize start\n   * @param deltaY - Vertical mouse movement since resize start\n   * @returns The calculated width and height\n   */\n  private calculateNewDimensions(\n    direction: ResizableNodeViewDirection,\n    deltaX: number,\n    deltaY: number,\n  ): ResizableNodeDimensions {\n    let newWidth = this.startWidth\n    let newHeight = this.startHeight\n\n    const isRight = direction.includes('right')\n    const isLeft = direction.includes('left')\n    const isBottom = direction.includes('bottom')\n    const isTop = direction.includes('top')\n\n    // Apply horizontal delta\n    if (isRight) {\n      newWidth = this.startWidth + deltaX\n    } else if (isLeft) {\n      newWidth = this.startWidth - deltaX\n    }\n\n    // Apply vertical delta\n    if (isBottom) {\n      newHeight = this.startHeight + deltaY\n    } else if (isTop) {\n      newHeight = this.startHeight - deltaY\n    }\n\n    // For pure horizontal/vertical handles, only one dimension changes\n    if (direction === 'right' || direction === 'left') {\n      newWidth = this.startWidth + (isRight ? deltaX : -deltaX)\n    }\n\n    if (direction === 'top' || direction === 'bottom') {\n      newHeight = this.startHeight + (isBottom ? deltaY : -deltaY)\n    }\n\n    const shouldPreserveAspectRatio = this.preserveAspectRatio || this.isShiftKeyPressed\n\n    if (shouldPreserveAspectRatio) {\n      return this.applyAspectRatio(newWidth, newHeight, direction)\n    }\n\n    return { width: newWidth, height: newHeight }\n  }\n\n  /**\n   * Applies min/max constraints to dimensions.\n   *\n   * When aspect ratio is NOT preserved, constraints are applied independently\n   * to width and height. When aspect ratio IS preserved, constraints are\n   * applied while maintaining the aspect ratio—if one dimension hits a limit,\n   * the other is recalculated proportionally.\n   *\n   * This ensures that aspect ratio is never broken when constrained.\n   *\n   * @param width - The unconstrained width\n   * @param height - The unconstrained height\n   * @param preserveAspectRatio - Whether to maintain aspect ratio while constraining\n   * @returns The constrained dimensions\n   */\n  private applyConstraints(\n    width: number,\n    height: number,\n    preserveAspectRatio: boolean,\n  ): ResizableNodeDimensions {\n    if (!preserveAspectRatio) {\n      // Independent constraints for each dimension\n      let constrainedWidth = Math.max(this.minSize.width, width)\n      let constrainedHeight = Math.max(this.minSize.height, height)\n\n      if (this.maxSize?.width) {\n        constrainedWidth = Math.min(this.maxSize.width, constrainedWidth)\n      }\n\n      if (this.maxSize?.height) {\n        constrainedHeight = Math.min(this.maxSize.height, constrainedHeight)\n      }\n\n      return { width: constrainedWidth, height: constrainedHeight }\n    }\n\n    // Aspect-ratio-aware constraints: adjust both dimensions proportionally\n    let constrainedWidth = width\n    let constrainedHeight = height\n\n    // Check minimum constraints\n    if (constrainedWidth < this.minSize.width) {\n      constrainedWidth = this.minSize.width\n      constrainedHeight = constrainedWidth / this.aspectRatio\n    }\n\n    if (constrainedHeight < this.minSize.height) {\n      constrainedHeight = this.minSize.height\n      constrainedWidth = constrainedHeight * this.aspectRatio\n    }\n\n    // Check maximum constraints\n    if (this.maxSize?.width && constrainedWidth > this.maxSize.width) {\n      constrainedWidth = this.maxSize.width\n      constrainedHeight = constrainedWidth / this.aspectRatio\n    }\n\n    if (this.maxSize?.height && constrainedHeight > this.maxSize.height) {\n      constrainedHeight = this.maxSize.height\n      constrainedWidth = constrainedHeight * this.aspectRatio\n    }\n\n    return { width: constrainedWidth, height: constrainedHeight }\n  }\n\n  /**\n   * Adjusts dimensions to maintain the original aspect ratio.\n   *\n   * For horizontal handles (left/right), uses width as the primary dimension\n   * and calculates height from it. For vertical handles (top/bottom), uses\n   * height as primary and calculates width. For corner handles, uses width\n   * as the primary dimension.\n   *\n   * @param width - The new width\n   * @param height - The new height\n   * @param direction - The active resize direction\n   * @returns Dimensions adjusted to preserve aspect ratio\n   */\n  private applyAspectRatio(\n    width: number,\n    height: number,\n    direction: ResizableNodeViewDirection,\n  ): ResizableNodeDimensions {\n    const isHorizontal = direction === 'left' || direction === 'right'\n    const isVertical = direction === 'top' || direction === 'bottom'\n\n    if (isHorizontal) {\n      // For horizontal resize, width is primary\n      return {\n        width,\n        height: width / this.aspectRatio,\n      }\n    }\n\n    if (isVertical) {\n      // For vertical resize, height is primary\n      return {\n        width: height * this.aspectRatio,\n        height,\n      }\n    }\n\n    // For corner resize, width is primary\n    return {\n      width,\n      height: width / this.aspectRatio,\n    }\n  }\n}\n\n/**\n * Alias for ResizableNodeView to maintain consistent naming.\n * @deprecated Use ResizableNodeView instead - will be removed in future versions.\n */\nexport const ResizableNodeview = ResizableNodeView\n","import type { DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType } from '@tiptap/pm/model'\n\nimport type { Editor } from './Editor.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> 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 | null)\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 Tiptap 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<NodeConfig<Options, Storage>>['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    // oxlint-disable-next-lineno-empty-object-type\n  }) => Attributes | {}\n}\n\n/**\n * The Node class is used to create custom node extensions.\n * @see https://tiptap.dev/api/extensions#create-a-new-extension\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 extends NodeConfig<ExtendedOptions, ExtendedStorage> = NodeConfig<\n      ExtendedOptions,\n      ExtendedStorage\n    >,\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 = typeof extendedConfig === 'function' ? extendedConfig() : extendedConfig\n    return super.extend(resolvedConfig) as Node<ExtendedOptions, ExtendedStorage>\n  }\n}\n","import { NodeSelection } from '@tiptap/pm/state'\nimport type { NodeView as ProseMirrorNodeView, ViewMutationRecord } from '@tiptap/pm/view'\n\nimport type { Editor as CoreEditor } from './Editor.js'\nimport type { DecorationWithType, NodeViewRendererOptions, NodeViewRendererProps } from './types.js'\nimport { isAndroid } from './utilities/isAndroid.js'\nimport { isiOS } from './utilities/isiOS.js'\n\n/**\n * Node views are used to customize the rendered DOM structure of a node.\n * @see https://tiptap.dev/guide/node-views\n */\nexport class NodeView<\n  Component,\n  NodeEditor extends CoreEditor = CoreEditor,\n  Options extends NodeViewRendererOptions = NodeViewRendererOptions,\n> implements ProseMirrorNodeView {\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(component: Component, props: NodeViewRendererProps, options?: Partial<Options>) {\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 = () => {\n      // ProseMirror throws while this node view is not attached to its parent yet.\n      try {\n        return props.getPos()\n      } catch {\n        return undefined\n      }\n    }\n    this.mount()\n  }\n\n  mount() {\n    // oxlint-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 = 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 isDragOverEnterEvent = event.type === 'dragover' || event.type === 'dragenter'\n    const isDropEvent = event.type === 'drop'\n    const isInput =\n      ['INPUT', 'BUTTON', 'SELECT', 'TEXTAREA'].includes(target.tagName) || 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 (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) {\n      event.preventDefault()\n    }\n\n    if (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {\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 && (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      isDragOverEnterEvent ||\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    // try to prevent a bug on iOS and Android that will break node views on enter\n    // this is because ProseMirror can’t preventDispatch on enter\n    // this will lead to a re-render of the node view on enter\n    // see: https://github.com/ueberdosis/tiptap/issues/1214\n    // see: https://github.com/ueberdosis/tiptap/issues/2534\n    if (\n      this.contentDOM.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 '@tiptap/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        // Only remove the stored mark if the match is not at the end of the\n        // pasted text. When a mark extends to the end of the content, removing\n        // it overrides the mark's `inclusive` behavior and incorrectly places\n        // the cursor outside the mark.\n        const isMatchAtEndOfText =\n          match.index !== undefined &&\n          match.input !== undefined &&\n          match.index + match[0].length >= match.input.length\n\n        if (!isMatchAtEndOfText) {\n          tr.removeStoredMark(config.type)\n        }\n      }\n    },\n  })\n}\n","import type { NodeType } from '@tiptap/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 '@tiptap/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\n      .slice(this.currentStep)\n      .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":";;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,SAAgB,qBAAqB,QAGrB;CACd,MAAM,EAAE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