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AEhFvF,EAAGkS,iBAAiBhT,EAAOmF,K,IAInC,CCtEM,SAAUm6B,GAAeC,GAC7B,OAAOA,EAAOnM,QAAQ,wBAAyB,OACjD,C","sources":["../node_modules/@tiptap/core/src/helpers/createChainableState.ts","../node_modules/@tiptap/core/src/CommandManager.ts","../node_modules/@tiptap/core/src/EventEmitter.ts","../node_modules/@tiptap/core/src/helpers/getExtensionField.ts","../node_modules/@tiptap/core/src/helpers/splitExtensions.ts","../node_modules/@tiptap/core/src/helpers/getAttributesFromExtensions.ts","../node_modules/@tiptap/core/src/helpers/getNodeType.ts","../node_modules/@tiptap/core/src/utilities/mergeAttributes.ts","../node_modules/@tiptap/core/src/helpers/getRenderedAttributes.ts","../node_modules/@tiptap/core/src/utilities/isFunction.ts","../node_modules/@tiptap/core/src/utilities/callOrReturn.ts","../node_modules/@tiptap/core/src/helpers/injectExtensionAttributesToParseRule.ts","../node_modules/@tiptap/core/src/utilities/fromString.ts","../node_modules/@tiptap/core/src/helpers/getSchemaByResolvedExtensions.ts","../node_modules/@tiptap/core/src/utilities/isEmptyObject.ts","../node_modules/@tiptap/core/src/helpers/getSchemaTypeByName.ts","../node_modules/@tiptap/core/src/helpers/isExtensionRulesEnabled.ts","../node_modules/@tiptap/core/src/helpers/getHTMLFromFragment.ts","../node_modules/@tiptap/core/src/utilities/isRegExp.ts","../node_modules/@tiptap/core/src/InputRule.ts","../node_modules/@tiptap/core/src/helpers/getTextContentFromNodes.ts","../node_modules/@tiptap/core/src/utilities/isPlainObject.ts","../node_modules/@tiptap/core/src/utilities/mergeDeep.ts","../node_modules/@tiptap/core/src/Mark.ts","../node_modules/@tiptap/core/src/PasteRule.ts","../node_modules/@tiptap/core/src/utilities/isNumber.ts","../node_modules/@tiptap/core/src/ExtensionManager.ts","../node_modules/@tiptap/core/src/utilities/findDuplicates.ts","../node_modules/@tiptap/core/src/Extension.ts","../node_modules/@tiptap/core/src/helpers/getTextBetween.ts","../node_modules/@tiptap/core/src/helpers/getTextSerializersFromSchema.ts","../node_modules/@tiptap/core/src/extensions/clipboardTextSerializer.ts","../node_modules/@tiptap/core/src/utilities/objectIncludes.ts","../node_modules/@tiptap/core/src/helpers/getMarkRange.ts","../node_modules/@tiptap/core/src/helpers/getMarkType.ts","../node_modules/@tiptap/core/src/helpers/isTextSelection.ts","../node_modules/@tiptap/core/src/utilities/minMax.ts","../node_modules/@tiptap/core/src/helpers/resolveFocusPosition.ts","../node_modules/@tiptap/core/src/utilities/isAndroid.ts","../node_modules/@tiptap/core/src/utilities/isiOS.ts","../node_modules/@tiptap/core/src/commands/focus.ts","../node_modules/@tiptap/core/src/utilities/elementFromString.ts","../node_modules/@tiptap/core/src/helpers/createNodeFromContent.ts","../node_modules/@tiptap/core/src/utilities/isMacOS.ts","../node_modules/@tiptap/core/src/helpers/isNodeActive.ts","../node_modules/@tiptap/core/src/helpers/getSchemaTypeNameByName.ts","../node_modules/@tiptap/core/src/utilities/deleteProps.ts","../node_modules/@tiptap/core/src/helpers/createDocument.ts","../node_modules/@tiptap/core/src/helpers/getMarkAttributes.ts","../node_modules/@tiptap/core/src/helpers/combineTransactionSteps.ts","../node_modules/@tiptap/core/src/helpers/findChildrenInRange.ts","../node_modules/@tiptap/core/src/helpers/findParentNode.ts","../node_modules/@tiptap/core/src/helpers/findParentNodeClosestToPos.ts","../node_modules/@tiptap/core/src/helpers/getText.ts","../node_modules/@tiptap/core/src/helpers/getAttributes.ts","../node_modules/@tiptap/core/src/helpers/getNodeAttributes.ts","../node_modules/@tiptap/core/src/helpers/getChangedRanges.ts","../node_modules/@tiptap/core/src/utilities/removeDuplicates.ts","../node_modules/@tiptap/core/src/helpers/getMarksBetween.ts","../node_modules/@tiptap/core/src/helpers/getSplittedAttributes.ts","../node_modules/@tiptap/core/src/helpers/isMarkActive.ts","../node_modules/@tiptap/core/src/helpers/isList.ts","../node_modules/@tiptap/core/src/helpers/isNodeEmpty.ts","../node_modules/@tiptap/core/src/helpers/isNodeSelection.ts","../node_modules/@tiptap/core/src/helpers/posToDOMRect.ts","../node_modules/@tiptap/core/src/commands/splitBlock.ts","../node_modules/@tiptap/core/src/commands/toggleList.ts","../node_modules/@tiptap/core/src/commands/blur.ts","../node_modules/@tiptap/core/src/commands/clearContent.ts","../node_modules/@tiptap/core/src/commands/clearNodes.ts","../node_modules/@tiptap/core/src/commands/command.ts","../node_modules/@tiptap/core/src/commands/createParagraphNear.ts","../node_modules/@tiptap/core/src/commands/cut.ts","../node_modules/@tiptap/core/src/commands/deleteCurrentNode.ts","../node_modules/@tiptap/core/src/commands/deleteNode.ts","../node_modules/@tiptap/core/src/commands/deleteRange.ts","../node_modules/@tiptap/core/src/commands/deleteSelection.ts","../node_modules/@tiptap/core/src/commands/enter.ts","../node_modules/@tiptap/core/src/commands/exitCode.ts","../node_modules/@tiptap/core/src/commands/extendMarkRange.ts","../node_modules/@tiptap/core/src/commands/first.ts","../node_modules/@tiptap/core/src/commands/forEach.ts","../node_modules/@tiptap/core/src/commands/insertContent.ts","../node_modules/@tiptap/core/src/commands/insertContentAt.ts","../node_modules/@tiptap/core/src/helpers/selectionToInsertionEnd.ts","../node_modules/@tiptap/core/src/commands/join.ts","../node_modules/@tiptap/core/src/commands/joinItemBackward.ts","../node_modules/@tiptap/core/src/commands/joinItemForward.ts","../node_modules/@tiptap/core/src/commands/joinTextblockBackward.ts","../node_modules/@tiptap/core/src/commands/joinTextblockForward.ts","../node_modules/@tiptap/core/src/commands/keyboardShortcut.ts","../node_modules/@tiptap/core/src/commands/lift.ts","../node_modules/@tiptap/core/src/commands/liftEmptyBlock.ts","../node_modules/@tiptap/core/src/commands/liftListItem.ts","../node_modules/@tiptap/core/src/commands/newlineInCode.ts","../node_modules/@tiptap/core/src/commands/resetAttributes.ts","../node_modules/@tiptap/core/src/commands/scrollIntoView.ts","../node_modules/@tiptap/core/src/commands/selectAll.ts","../node_modules/@tiptap/core/src/commands/selectNodeBackward.ts","../node_modules/@tiptap/core/src/commands/selectNodeForward.ts","../node_modules/@tiptap/core/src/commands/selectParentNode.ts","../node_modules/@tiptap/core/src/commands/selectTextblockEnd.ts","../node_modules/@tiptap/core/src/commands/selectTextblockStart.ts","../node_modules/@tiptap/core/src/commands/setContent.ts","../node_modules/@tiptap/core/src/commands/setMark.ts","../node_modules/@tiptap/core/src/commands/setMeta.ts","../node_modules/@tiptap/core/src/commands/setNode.ts","../node_modules/@tiptap/core/src/commands/setNodeSelection.ts","../node_modules/@tiptap/core/src/commands/setTextSelection.ts","../node_modules/@tiptap/core/src/commands/sinkListItem.ts","../node_modules/@tiptap/core/src/helpers/defaultBlockAt.ts","../node_modules/@tiptap/core/src/commands/splitListItem.ts","../node_modules/@tiptap/core/src/commands/toggleMark.ts","../node_modules/@tiptap/core/src/commands/toggleNode.ts","../node_modules/@tiptap/core/src/commands/toggleWrap.ts","../node_modules/@tiptap/core/src/commands/undoInputRule.ts","../node_modules/@tiptap/core/src/commands/unsetAllMarks.ts","../node_modules/@tiptap/core/src/commands/unsetMark.ts","../node_modules/@tiptap/core/src/commands/updateAttributes.ts","../node_modules/@tiptap/core/src/commands/wrapIn.ts","../node_modules/@tiptap/core/src/commands/wrapInList.ts","../node_modules/@tiptap/core/src/extensions/commands.ts","../node_modules/@tiptap/core/src/extensions/drop.ts","../node_modules/@tiptap/core/src/extensions/editable.ts","../node_modules/@tiptap/core/src/extensions/focusEvents.ts","../node_modules/@tiptap/core/src/extensions/keymap.ts","../node_modules/@tiptap/core/src/extensions/paste.ts","../node_modules/@tiptap/core/src/extensions/tabindex.ts","../node_modules/@tiptap/core/src/NodePos.ts","../node_modules/@tiptap/core/src/Editor.ts","../node_modules/@tiptap/core/src/utilities/createStyleTag.ts","../node_modules/@tiptap/core/src/style.ts","../node_modules/@tiptap/core/src/helpers/isActive.ts","../node_modules/@tiptap/core/src/inputRules/markInputRule.ts","../node_modules/@tiptap/core/src/inputRules/nodeInputRule.ts","../node_modules/@tiptap/core/src/inputRules/textblockTypeInputRule.ts","../node_modules/@tiptap/core/src/inputRules/wrappingInputRule.ts","../node_modules/@tiptap/core/src/Node.ts","../node_modules/@tiptap/core/src/pasteRules/markPasteRule.ts","../node_modules/@tiptap/core/src/utilities/escapeForRegEx.ts"],"sourcesContent":["import { 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 { EditorState, Transaction } from '@tiptap/pm/state'\n\nimport { Editor } from './Editor.js'\nimport { createChainableState } from './helpers/createChainableState.js'\nimport {\n AnyCommands, CanCommands, ChainedCommands, CommandProps, 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 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 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","type StringKeyOf = Extract\ntype CallbackType<\n T extends Record,\n EventName extends StringKeyOf,\n> = T[EventName] extends any[] ? T[EventName] : [T[EventName]]\ntype CallbackFunction<\n T extends Record,\n EventName extends StringKeyOf,\n> = (...props: CallbackType) => any\n\nexport class EventEmitter> {\n\n private callbacks: { [key: string]: Array<(...args: any[])=>void> } = {}\n\n public on>(event: EventName, fn: CallbackFunction): 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>(event: EventName, ...args: CallbackType): 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>(event: EventName, fn?: CallbackFunction): 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>(event: EventName, fn: CallbackFunction): this {\n const onceFn = (...args: CallbackType) => {\n this.off(event, onceFn)\n fn.apply(this, args)\n }\n\n return this.on(event, onceFn)\n }\n\n public removeAllListeners(): void {\n this.callbacks = {}\n }\n}\n","import { 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(\n extension: AnyExtension,\n field: string,\n context?: Omit, 'parent'>,\n): RemoveThis {\n\n if (extension.config[field] === undefined && extension.parent) {\n return getExtensionField(extension.parent, field, context)\n }\n\n if (typeof extension.config[field] === 'function') {\n const value = extension.config[field].bind({\n ...context,\n parent: extension.parent\n ? getExtensionField(extension.parent, field, context)\n : null,\n })\n\n return value\n }\n\n return extension.config[field]\n}\n","import { Extension } from '../Extension.js'\nimport { Mark } from '../Mark.js'\nimport { Node } from '../Node.js'\nimport { Extensions } from '../types.js'\n\nexport function splitExtensions(extensions: Extensions) {\n const baseExtensions = extensions.filter(extension => extension.type === 'extension') as Extension[]\n const nodeExtensions = extensions.filter(extension => extension.type === 'node') as Node[]\n const markExtensions = extensions.filter(extension => extension.type === 'mark') as Mark[]\n\n return {\n baseExtensions,\n nodeExtensions,\n markExtensions,\n }\n}\n","import { MarkConfig, NodeConfig } from '../index.js'\nimport {\n AnyConfig,\n Attribute,\n Attributes,\n ExtensionAttribute,\n Extensions,\n} 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 = {\n default: null,\n rendered: true,\n renderHTML: null,\n parseHTML: null,\n keepOnSplit: true,\n isRequired: false,\n }\n\n extensions.forEach(extension => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n extensions: nodeAndMarkExtensions,\n }\n\n const addGlobalAttributes = getExtensionField(\n extension,\n 'addGlobalAttributes',\n context,\n )\n\n if (!addGlobalAttributes) {\n return\n }\n\n const globalAttributes = addGlobalAttributes()\n\n globalAttributes.forEach(globalAttribute => {\n globalAttribute.types.forEach(type => {\n Object\n .entries(globalAttribute.attributes)\n .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 extension,\n 'addAttributes',\n context,\n )\n\n if (!addAttributes) {\n return\n }\n\n // TODO: remove `as Attributes`\n const attributes = addAttributes() as Attributes\n\n Object\n .entries(attributes)\n .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","import { 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","export function mergeAttributes(...objects: Record[]): Record {\n return objects\n .filter(item => !!item)\n .reduce((items, item) => {\n const mergedAttributes = { ...items }\n\n Object.entries(item).forEach(([key, value]) => {\n const exists = mergedAttributes[key]\n\n if (!exists) {\n mergedAttributes[key] = value\n\n return\n }\n\n if (key === 'class') {\n const valueClasses: string[] = value ? String(value).split(' ') : []\n const existingClasses: string[] = mergedAttributes[key] ? mergedAttributes[key].split(' ') : []\n\n const insertClasses = valueClasses.filter(\n valueClass => !existingClasses.includes(valueClass),\n )\n\n mergedAttributes[key] = [...existingClasses, ...insertClasses].join(' ')\n } else if (key === 'style') {\n const newStyles: string[] = value ? value.split(';').map((style: string) => style.trim()).filter(Boolean) : []\n const existingStyles: string[] = mergedAttributes[key] ? mergedAttributes[key].split(';').map((style: string) => style.trim()).filter(Boolean) : []\n\n const styleMap = new Map()\n\n existingStyles.forEach(style => {\n const [property, val] = style.split(':').map(part => part.trim())\n\n styleMap.set(property, val)\n })\n\n newStyles.forEach(style => {\n const [property, val] = style.split(':').map(part => part.trim())\n\n styleMap.set(property, val)\n })\n\n mergedAttributes[key] = Array.from(styleMap.entries()).map(([property, val]) => `${property}: ${val}`).join('; ')\n } else {\n mergedAttributes[key] = value\n }\n })\n\n return mergedAttributes\n }, {})\n}\n","import { Mark, Node } from '@tiptap/pm/model'\n\nimport { ExtensionAttribute } from '../types.js'\nimport { mergeAttributes } from '../utilities/mergeAttributes.js'\n\nexport function getRenderedAttributes(\n nodeOrMark: Node | Mark,\n extensionAttributes: ExtensionAttribute[],\n): Record {\n return extensionAttributes\n .filter(\n attribute => attribute.type === nodeOrMark.type.name,\n )\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","// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport function isFunction(value: any): value is Function {\n return typeof value === 'function'\n}\n","import { 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(value: T, context: any = undefined, ...props: any[]): MaybeReturnType {\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\n}\n","import { ParseRule } from '@tiptap/pm/model'\n\nimport { 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","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 {\n MarkSpec, NodeSpec, Schema, TagParseRule,\n} from '@tiptap/pm/model'\n\nimport { Editor, MarkConfig, NodeConfig } from '../index.js'\nimport { 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(data: T) {\n return Object.fromEntries(\n // @ts-ignore\n Object.entries(data).filter(([key, value]) => {\n if (key === 'attrs' && isEmptyObject(value as object | undefined)) {\n return false\n }\n\n return value !== null && value !== undefined\n }),\n ) as T\n}\n\n/**\n * Creates a new Prosemirror schema based on the given extensions.\n * @param extensions An array of Tiptap extensions\n * @param editor The editor instance\n * @returns A Prosemirror schema\n */\nexport function getSchemaByResolvedExtensions(extensions: Extensions, editor?: Editor): Schema {\n const allAttributes = getAttributesFromExtensions(extensions)\n const { nodeExtensions, markExtensions } = splitExtensions(extensions)\n const topNode = nodeExtensions.find(extension => getExtensionField(extension, 'topNode'))?.name\n\n const nodes = Object.fromEntries(\n nodeExtensions.map(extension => {\n const extensionAttributes = allAttributes.filter(\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(\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(extension, 'content', context),\n ),\n marks: callOrReturn(getExtensionField(extension, 'marks', context)),\n group: callOrReturn(getExtensionField(extension, 'group', context)),\n inline: callOrReturn(getExtensionField(extension, 'inline', context)),\n atom: callOrReturn(getExtensionField(extension, 'atom', context)),\n selectable: callOrReturn(\n getExtensionField(extension, 'selectable', context),\n ),\n draggable: callOrReturn(\n getExtensionField(extension, 'draggable', context),\n ),\n code: callOrReturn(getExtensionField(extension, 'code', context)),\n whitespace: callOrReturn(getExtensionField(extension, 'whitespace', context)),\n linebreakReplacement: callOrReturn(getExtensionField(extension, 'linebreakReplacement', context)),\n defining: callOrReturn(\n getExtensionField(extension, 'defining', context),\n ),\n isolating: callOrReturn(\n getExtensionField(extension, 'isolating', context),\n ),\n attrs: Object.fromEntries(\n extensionAttributes.map(extensionAttribute => {\n return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]\n }),\n ),\n })\n\n const parseHTML = callOrReturn(\n getExtensionField(extension, 'parseHTML', context),\n )\n\n if (parseHTML) {\n schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes)) as TagParseRule[]\n }\n\n const renderHTML = getExtensionField(\n extension,\n 'renderHTML',\n context,\n )\n\n if (renderHTML) {\n schema.toDOM = node => renderHTML({\n node,\n HTMLAttributes: getRenderedAttributes(node, extensionAttributes),\n })\n }\n\n const renderText = getExtensionField(\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(\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(extension, 'inclusive', context),\n ),\n excludes: callOrReturn(\n getExtensionField(extension, 'excludes', context),\n ),\n group: callOrReturn(getExtensionField(extension, 'group', context)),\n spanning: callOrReturn(\n getExtensionField(extension, 'spanning', context),\n ),\n code: callOrReturn(getExtensionField(extension, 'code', context)),\n attrs: Object.fromEntries(\n extensionAttributes.map(extensionAttribute => {\n return [extensionAttribute.name, { default: extensionAttribute?.attribute?.default }]\n }),\n ),\n })\n\n const parseHTML = callOrReturn(\n getExtensionField(extension, 'parseHTML', context),\n )\n\n if (parseHTML) {\n schema.parseDOM = parseHTML.map(parseRule => injectExtensionAttributesToParseRule(parseRule, extensionAttributes))\n }\n\n const renderHTML = getExtensionField(\n extension,\n 'renderHTML',\n context,\n )\n\n if (renderHTML) {\n schema.toDOM = mark => 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","export function isEmptyObject(value = {}): boolean {\n return Object.keys(value).length === 0 && value.constructor === Object\n}\n","import { 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 { 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'\n ? enabledExtension\n : enabledExtension.name\n\n return name === extension.name\n })\n }\n\n return enabled\n}\n","import { DOMSerializer, Fragment, Schema } 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","export function isRegExp(value: any): value is RegExp {\n return Object.prototype.toString.call(value) === '[object RegExp]'\n}\n","import { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { EditorState, Plugin, TextSelection } from '@tiptap/pm/state'\n\nimport { CommandManager } from './CommandManager.js'\nimport { Editor } from './Editor.js'\nimport { createChainableState } from './helpers/createChainableState.js'\nimport { getHTMLFromFragment } from './helpers/getHTMLFromFragment.js'\nimport { getTextContentFromNodes } from './helpers/getTextContentFromNodes.js'\nimport {\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;\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 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 }) {\n this.find = config.find\n this.handler = config.handler\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 {\n editor, from, to, text, rules, plugin,\n } = 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 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 tr.setMeta(plugin, {\n transform: tr,\n from,\n to,\n text,\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 { 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 = node.type.spec.toText?.({\n node,\n pos,\n parent,\n index,\n })\n || node.textContent\n || '%leaf%'\n\n textBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos))\n },\n )\n\n return textBefore\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 {\n if (getType(value) !== 'Object') {\n return false\n }\n\n return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype\n}\n","import { isPlainObject } from './isPlainObject.js'\n\nexport function mergeDeep(target: Record, source: Record): Record {\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 {\n DOMOutputSpec, Mark as ProseMirrorMark, MarkSpec, MarkType,\n} from '@tiptap/pm/model'\nimport { Plugin, Transaction } from '@tiptap/pm/state'\n\nimport { Editor } from './Editor.js'\nimport { getExtensionField } from './helpers/getExtensionField.js'\nimport { MarkConfig } from './index.js'\nimport { InputRule } from './InputRule.js'\nimport { Node } from './Node.js'\nimport { PasteRule } from './PasteRule.js'\nimport {\n AnyConfig,\n Attributes,\n Extensions,\n GlobalAttributes,\n KeyboardShortcutCommand,\n ParentConfig,\n RawCommands,\n} from './types.js'\nimport { callOrReturn } from './utilities/callOrReturn.js'\nimport { mergeDeep } from './utilities/mergeDeep.js'\n\ndeclare module '@tiptap/core' {\n export interface MarkConfig {\n // @ts-ignore - this is a dynamic key\n [key: string]: 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 * The default options for this extension.\n * @example\n * defaultOptions: {\n * myOption: 'foo',\n * myOtherOption: 10,\n * }\n */\n defaultOptions?: Options\n\n /**\n * This method will add options to this extension\n * @see https://tiptap.dev/guide/custom-extensions#settings\n * @example\n * addOptions() {\n * return {\n * myOption: 'foo',\n * myOtherOption: 10,\n * }\n */\n addOptions?: (this: {\n name: string\n parent: Exclude>['addOptions'], undefined>\n }) => Options\n\n /**\n * The default storage this extension can save data to.\n * @see https://tiptap.dev/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: Exclude>['addStorage'], undefined>\n }) => Storage\n\n /**\n * This function adds globalAttributes to specific nodes.\n * @see https://tiptap.dev/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>['addGlobalAttributes']\n }) => GlobalAttributes\n\n /**\n * This function adds commands to the editor\n * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts\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: MarkType\n parent: ParentConfig>['addCommands']\n }) => Partial\n\n /**\n * This function registers keyboard shortcuts.\n * @see https://tiptap.dev/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: MarkType\n parent: ParentConfig>['addKeyboardShortcuts']\n }) => {\n [key: string]: KeyboardShortcutCommand\n }\n\n /**\n * This function adds input rules to the editor.\n * @see https://tiptap.dev/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: MarkType\n parent: ParentConfig>['addInputRules']\n }) => InputRule[]\n\n /**\n * This function adds paste rules to the editor.\n * @see https://tiptap.dev/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: MarkType\n parent: ParentConfig>['addPasteRules']\n }) => PasteRule[]\n\n /**\n * This function adds Prosemirror plugins to the editor\n * @see https://tiptap.dev/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: MarkType\n parent: ParentConfig>['addProseMirrorPlugins']\n }) => Plugin[]\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>['addExtensions']\n }) => Extensions\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>['extendNodeSchema']\n },\n extension: Node,\n ) => Record)\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>['extendMarkSchema']\n },\n extension: Mark,\n ) => Record)\n | null\n\n /**\n * The editor is not ready yet.\n */\n onBeforeCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: MarkType\n parent: ParentConfig>['onBeforeCreate']\n }) => void)\n | null\n\n /**\n * The editor is ready.\n */\n onCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: MarkType\n parent: ParentConfig>['onCreate']\n }) => void)\n | null\n\n /**\n * The content has changed.\n */\n onUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: MarkType\n parent: ParentConfig>['onUpdate']\n }) => void)\n | null\n\n /**\n * The selection has changed.\n */\n onSelectionUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: MarkType\n parent: ParentConfig>['onSelectionUpdate']\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: MarkType\n parent: ParentConfig>['onTransaction']\n },\n props: {\n editor: Editor\n transaction: Transaction\n },\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: MarkType\n parent: ParentConfig>['onFocus']\n },\n props: {\n event: FocusEvent\n },\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: MarkType\n parent: ParentConfig>['onBlur']\n },\n props: {\n event: FocusEvent\n },\n ) => void)\n | null\n\n /**\n * The editor is destroyed.\n */\n onDestroy?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: MarkType\n parent: ParentConfig>['onDestroy']\n }) => void)\n | null\n\n /**\n * Keep mark after split node\n */\n keepOnSplit?: boolean | (() => boolean)\n\n /**\n * Inclusive\n */\n inclusive?:\n | MarkSpec['inclusive']\n | ((this: {\n name: string\n options: Options\n storage: Storage\n parent: ParentConfig>['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>['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>['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>['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>['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>['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>['renderHTML']\n editor?: Editor\n },\n props: {\n mark: ProseMirrorMark\n HTMLAttributes: Record\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>['addAttributes']\n editor?: Editor\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n }) => Attributes | {}\n }\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 {\n type = 'mark'\n\n name = 'mark'\n\n parent: Mark | null = null\n\n child: Mark | null = null\n\n options: Options\n\n storage: Storage\n\n config: MarkConfig = {\n name: this.name,\n defaultOptions: {},\n }\n\n constructor(config: Partial> = {}) {\n this.config = {\n ...this.config,\n ...config,\n }\n\n this.name = this.config.name\n\n if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`,\n )\n }\n\n // TODO: remove `addOptions` fallback\n this.options = this.config.defaultOptions\n\n if (this.config.addOptions) {\n this.options = callOrReturn(\n getExtensionField(this, 'addOptions', {\n name: this.name,\n }),\n )\n }\n\n this.storage = callOrReturn(\n getExtensionField(this, 'addStorage', {\n name: this.name,\n options: this.options,\n }),\n ) || {}\n }\n\n static create(config: Partial> = {}) {\n return new Mark(config)\n }\n\n configure(options: Partial = {}) {\n // return a new instance so we can use the same extension\n // with different calls of `configure`\n const extension = this.extend({\n ...this.config,\n addOptions: () => {\n return mergeDeep(this.options as Record, options) as Options\n },\n })\n\n // Always preserve the current name\n extension.name = this.name\n // Set the parent to be our parent\n extension.parent = this.parent\n\n return extension\n }\n\n extend(\n extendedConfig: Partial> = {},\n ) {\n const extension = new Mark(extendedConfig)\n\n extension.parent = this\n\n this.child = extension\n\n extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name\n\n if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`,\n )\n }\n\n extension.options = callOrReturn(\n getExtensionField(extension, 'addOptions', {\n name: extension.name,\n }),\n )\n\n extension.storage = callOrReturn(\n getExtensionField(extension, 'addStorage', {\n name: extension.name,\n options: extension.options,\n }),\n )\n\n return extension\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","import { Fragment, Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { EditorState, Plugin } from '@tiptap/pm/state'\n\nimport { CommandManager } from './CommandManager.js'\nimport { Editor } from './Editor.js'\nimport { createChainableState } from './helpers/createChainableState.js'\nimport { getHTMLFromFragment } from './helpers/getHTMLFromFragment.js'\nimport {\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;\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 {\n editor, state, from, to, rule, pasteEvent, dropEvent,\n } = 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 if (!node.isTextblock || node.type.spec.code) {\n return\n }\n\n const resolvedFrom = Math.max(from, pos)\n const resolvedTo = Math.min(to, pos + node.content.size)\n const textToMatch = 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) {\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({ from: selection.from, to: selection.to })\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","export function isNumber(value: any): value is number {\n return typeof value === 'number'\n}\n","import { keymap } from '@tiptap/pm/keymap'\nimport { Schema } from '@tiptap/pm/model'\nimport { Plugin } from '@tiptap/pm/state'\nimport { NodeViewConstructor } from '@tiptap/pm/view'\n\nimport type { Editor } from './Editor.js'\nimport { getAttributesFromExtensions } from './helpers/getAttributesFromExtensions.js'\nimport { getExtensionField } from './helpers/getExtensionField.js'\nimport { getNodeType } from './helpers/getNodeType.js'\nimport { getRenderedAttributes } from './helpers/getRenderedAttributes.js'\nimport { getSchemaByResolvedExtensions } from './helpers/getSchemaByResolvedExtensions.js'\nimport { getSchemaTypeByName } from './helpers/getSchemaTypeByName.js'\nimport { isExtensionRulesEnabled } from './helpers/isExtensionRulesEnabled.js'\nimport { splitExtensions } from './helpers/splitExtensions.js'\nimport type { NodeConfig } from './index.js'\nimport { InputRule, inputRulesPlugin } from './InputRule.js'\nimport { Mark } from './Mark.js'\nimport { PasteRule, pasteRulesPlugin } from './PasteRule.js'\nimport { AnyConfig, Extensions, RawCommands } from './types.js'\nimport { callOrReturn } from './utilities/callOrReturn.js'\nimport { findDuplicates } from './utilities/findDuplicates.js'\n\nexport class ExtensionManager {\n editor: Editor\n\n schema: Schema\n\n extensions: Extensions\n\n splittableMarks: string[] = []\n\n constructor(extensions: Extensions, editor: Editor) {\n this.editor = editor\n this.extensions = ExtensionManager.resolve(extensions)\n this.schema = getSchemaByResolvedExtensions(this.extensions, editor)\n this.setupExtensions()\n }\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 */\n static resolve(extensions: Extensions): Extensions {\n const resolvedExtensions = ExtensionManager.sort(ExtensionManager.flatten(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\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 */\n static flatten(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(\n extension,\n 'addExtensions',\n context,\n )\n\n if (addExtensions) {\n return [extension, ...this.flatten(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\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 */\n static sort(extensions: Extensions): Extensions {\n const defaultPriority = 100\n\n return extensions.sort((a, b) => {\n const priorityA = getExtensionField(a, 'priority') || defaultPriority\n const priorityB = getExtensionField(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\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: extension.storage,\n editor: this.editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n }\n\n const addCommands = getExtensionField(\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 = ExtensionManager.sort([...this.extensions].reverse())\n\n const inputRules: InputRule[] = []\n const pasteRules: PasteRule[] = []\n\n const allPlugins = extensions\n .map(extension => {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n }\n\n const plugins: Plugin[] = []\n\n const addKeyboardShortcuts = getExtensionField(\n extension,\n 'addKeyboardShortcuts',\n context,\n )\n\n let defaultBindings: Record boolean> = {}\n\n // bind exit handling\n if (extension.type === 'mark' && getExtensionField(extension, 'exitable', context)) {\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(\n extension,\n 'addInputRules',\n context,\n )\n\n if (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {\n inputRules.push(...addInputRules())\n }\n\n const addPasteRules = getExtensionField(\n extension,\n 'addPasteRules',\n context,\n )\n\n if (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {\n pasteRules.push(...addPasteRules())\n }\n\n const addProseMirrorPlugins = getExtensionField(\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 .flat()\n\n return [\n inputRulesPlugin({\n editor,\n rules: inputRules,\n }),\n ...pasteRulesPlugin({\n editor,\n rules: pasteRules,\n }),\n ...allPlugins,\n ]\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 {\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: extension.storage,\n editor,\n type: getNodeType(extension.name, this.schema),\n }\n const addNodeView = getExtensionField(\n extension,\n 'addNodeView',\n context,\n )\n\n if (!addNodeView) {\n return []\n }\n\n const nodeview: NodeViewConstructor = (\n node,\n view,\n getPos,\n decorations,\n innerDecorations,\n ) => {\n const HTMLAttributes = getRenderedAttributes(node, extensionAttributes)\n\n return addNodeView()({\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 * Go through all extensions, create extension storages & setup marks\n * & bind editor event listener.\n */\n private setupExtensions() {\n this.extensions.forEach(extension => {\n // store extension storage in editor\n this.editor.extensionStorage[extension.name] = extension.storage\n\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n editor: this.editor,\n type: getSchemaTypeByName(extension.name, this.schema),\n }\n\n if (extension.type === 'mark') {\n const keepOnSplit = callOrReturn(getExtensionField(extension, 'keepOnSplit', context)) ?? true\n\n if (keepOnSplit) {\n this.splittableMarks.push(extension.name)\n }\n }\n\n const onBeforeCreate = getExtensionField(\n extension,\n 'onBeforeCreate',\n context,\n )\n const onCreate = getExtensionField(extension, 'onCreate', context)\n const onUpdate = getExtensionField(extension, 'onUpdate', context)\n const onSelectionUpdate = getExtensionField(\n extension,\n 'onSelectionUpdate',\n context,\n )\n const onTransaction = getExtensionField(\n extension,\n 'onTransaction',\n context,\n )\n const onFocus = getExtensionField(extension, 'onFocus', context)\n const onBlur = getExtensionField(extension, 'onBlur', context)\n const onDestroy = getExtensionField(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","export function findDuplicates(items: any[]): any[] {\n const filtered = items.filter((el, index) => items.indexOf(el) !== index)\n\n return Array.from(new Set(filtered))\n}\n","import { Plugin, Transaction } from '@tiptap/pm/state'\n\nimport { Editor } from './Editor.js'\nimport { getExtensionField } from './helpers/getExtensionField.js'\nimport { ExtensionConfig } from './index.js'\nimport { InputRule } from './InputRule.js'\nimport { Mark } from './Mark.js'\nimport { Node } from './Node.js'\nimport { PasteRule } from './PasteRule.js'\nimport {\n AnyConfig,\n Extensions,\n GlobalAttributes,\n KeyboardShortcutCommand,\n ParentConfig,\n RawCommands,\n} from './types.js'\nimport { callOrReturn } from './utilities/callOrReturn.js'\nimport { mergeDeep } from './utilities/mergeDeep.js'\n\ndeclare module '@tiptap/core' {\n interface ExtensionConfig {\n // @ts-ignore - this is a dynamic key\n [key: string]: 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 * The default options for this extension.\n * @example\n * defaultOptions: {\n * myOption: 'foo',\n * myOtherOption: 10,\n * }\n */\n defaultOptions?: Options\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: {\n name: string\n parent: Exclude>['addOptions'], undefined>\n }) => 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: Exclude>['addStorage'], undefined>\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>['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 parent: ParentConfig>['addCommands']\n }) => Partial\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 parent: ParentConfig>['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 parent: ParentConfig>['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 parent: ParentConfig>['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 parent: ParentConfig>['addProseMirrorPlugins']\n }) => Plugin[]\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>['addExtensions']\n }) => Extensions\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>['extendNodeSchema']\n },\n extension: Node,\n ) => Record)\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>['extendMarkSchema']\n },\n extension: Mark,\n ) => Record)\n | null\n\n /**\n * The editor is not ready yet.\n */\n onBeforeCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n parent: ParentConfig>['onBeforeCreate']\n }) => void)\n | null\n\n /**\n * The editor is ready.\n */\n onCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n parent: ParentConfig>['onCreate']\n }) => void)\n | null\n\n /**\n * The content has changed.\n */\n onUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n parent: ParentConfig>['onUpdate']\n }) => void)\n | null\n\n /**\n * The selection has changed.\n */\n onSelectionUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n parent: ParentConfig>['onSelectionUpdate']\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 parent: ParentConfig>['onTransaction']\n },\n props: {\n editor: Editor\n transaction: Transaction\n },\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 parent: ParentConfig>['onFocus']\n },\n props: {\n event: FocusEvent\n },\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 parent: ParentConfig>['onBlur']\n },\n props: {\n event: FocusEvent\n },\n ) => void)\n | null\n\n /**\n * The editor is destroyed.\n */\n onDestroy?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n parent: ParentConfig>['onDestroy']\n }) => void)\n | null\n }\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 {\n type = 'extension'\n\n name = 'extension'\n\n parent: Extension | null = null\n\n child: Extension | null = null\n\n options: Options\n\n storage: Storage\n\n config: ExtensionConfig = {\n name: this.name,\n defaultOptions: {},\n }\n\n constructor(config: Partial> = {}) {\n this.config = {\n ...this.config,\n ...config,\n }\n\n this.name = this.config.name\n\n if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`,\n )\n }\n\n // TODO: remove `addOptions` fallback\n this.options = this.config.defaultOptions\n\n if (this.config.addOptions) {\n this.options = callOrReturn(\n getExtensionField(this, 'addOptions', {\n name: this.name,\n }),\n )\n }\n\n this.storage = callOrReturn(\n getExtensionField(this, 'addStorage', {\n name: this.name,\n options: this.options,\n }),\n ) || {}\n }\n\n static create(config: Partial> = {}) {\n return new Extension(config)\n }\n\n configure(options: Partial = {}) {\n // return a new instance so we can use the same extension\n // with different calls of `configure`\n const extension = this.extend({\n ...this.config,\n addOptions: () => {\n return mergeDeep(this.options as Record, options) as Options\n },\n })\n\n // Always preserve the current name\n extension.name = this.name\n // Set the parent to be our parent\n extension.parent = this.parent\n\n return extension\n }\n\n extend(\n extendedConfig: Partial> = {},\n ) {\n const extension = new Extension({ ...this.config, ...extendedConfig })\n\n extension.parent = this\n\n this.child = extension\n\n extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name\n\n if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`,\n )\n }\n\n extension.options = callOrReturn(\n getExtensionField(extension, 'addOptions', {\n name: extension.name,\n }),\n )\n\n extension.storage = callOrReturn(\n getExtensionField(extension, 'addStorage', {\n name: extension.name,\n options: extension.options,\n }),\n )\n\n return extension\n }\n}\n","import { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { 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\n },\n): string {\n const { from, to } = range\n const { blockSeparator = '\\n\\n', textSerializers = {} } = options || {}\n let text = ''\n\n startNode.nodesBetween(from, to, (node, pos, parent, index) => {\n if (node.isBlock && pos > from) {\n text += blockSeparator\n }\n\n const textSerializer = textSerializers?.[node.type.name]\n\n if (textSerializer) {\n if (parent) {\n text += textSerializer({\n node,\n pos,\n parent,\n index,\n range,\n })\n }\n // do not descend into child nodes when there exists a serializer\n return false\n }\n\n if (node.isText) {\n text += node?.text?.slice(Math.max(from, pos) - pos, to - pos) // eslint-disable-line\n }\n })\n\n return text\n}\n","import { Schema } from '@tiptap/pm/model'\n\nimport { 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 {\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 { 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({\n name: 'clipboardTextSerializer',\n\n addOptions() {\n return {\n blockSeparator: undefined,\n }\n },\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('clipboardTextSerializer'),\n props: {\n clipboardTextSerializer: () => {\n const { editor } = this\n const { state, schema } = editor\n const { doc, selection } = state\n const { ranges } = selection\n const from = Math.min(...ranges.map(range => range.$from.pos))\n const to = Math.max(...ranges.map(range => range.$to.pos))\n const textSerializers = getTextSerializersFromSchema(schema)\n const range = { from, to }\n\n return getTextBetween(doc, range, {\n ...(this.options.blockSeparator !== undefined\n ? { blockSeparator: this.options.blockSeparator }\n : {}),\n textSerializers,\n })\n },\n },\n }),\n ]\n },\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,\n object2: Record,\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 { Mark as ProseMirrorMark, MarkType, ResolvedPos } from '@tiptap/pm/model'\n\nimport { Range } from '../types.js'\nimport { objectIncludes } from '../utilities/objectIncludes.js'\n\nfunction findMarkInSet(\n marks: ProseMirrorMark[],\n type: MarkType,\n attributes: Record = {},\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 = {},\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,\n): Range | void {\n if (!$pos || !type) {\n return\n }\n let start = $pos.parent.childAfter($pos.parentOffset)\n\n // If the cursor is at the start of a text node that does not have the mark, look backward\n if (!start.node || !start.node.marks.some(mark => mark.type === type)) {\n start = $pos.parent.childBefore($pos.parentOffset)\n }\n\n // If there is no text node with the mark even backward, return undefined\n if (!start.node || !start.node.marks.some(mark => mark.type === type)) {\n return\n }\n\n // Default to only matching against the first mark's attributes\n attributes = attributes || start.node.marks[0]?.attrs\n\n // We now know that the cursor is either at the start, middle or end of a text node with the specified mark\n // so we can look it up on the targeted mark\n const mark = findMarkInSet([...start.node.marks], type, attributes)\n\n if (!mark) {\n return\n }\n\n let startIndex = start.index\n let startPos = $pos.start() + start.offset\n let endIndex = startIndex + 1\n let endPos = startPos + start.node.nodeSize\n\n while (\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 { 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 { 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 { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Selection, TextSelection } from '@tiptap/pm/state'\n\nimport { 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 navigator.platform === 'Android' || /android/i.test(navigator.userAgent)\n}\n","export function isiOS(): boolean {\n return [\n 'iPad Simulator',\n 'iPhone Simulator',\n 'iPod Simulator',\n 'iPad',\n 'iPhone',\n 'iPod',\n ].includes(navigator.platform)\n // iPad on iOS 13 detection\n || (navigator.userAgent.includes('Mac') && 'ontouchend' in document)\n}\n","import { isTextSelection } from '../helpers/isTextSelection.js'\nimport { resolveFocusPosition } from '../helpers/resolveFocusPosition.js'\nimport { FocusPosition, RawCommands } from '../types.js'\nimport { isAndroid } from '../utilities/isAndroid.js'\nimport { isiOS } from '../utilities/isiOS.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = (position = null, options = {}) => ({\n editor,\n view,\n tr,\n dispatch,\n}) => {\n options = {\n scrollIntoView: true,\n ...options,\n }\n\n const delayedFocus = () => {\n // focus within `requestAnimationFrame` breaks focus on iOS and Android\n // so we have to call this\n if (isiOS() || isAndroid()) {\n (view.dom as HTMLElement).focus()\n }\n\n // For React we have to focus asynchronously. Otherwise wild things happen.\n // 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 if ((view.hasFocus() && position === null) || position === false) {\n return true\n }\n\n // we don’t try to resolve a NodeSelection or CellSelection\n if (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","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 // add a wrapper to preserve leading and trailing whitespace\n const wrappedValue = `${value}`\n\n const html = new window.DOMParser().parseFromString(wrappedValue, 'text/html').body\n\n return removeWhitespaces(html)\n}\n","import {\n DOMParser,\n Fragment,\n Node as ProseMirrorNode,\n ParseOptions,\n Schema,\n} from '@tiptap/pm/model'\n\nimport { Content } from '../types.js'\nimport { elementFromString } from '../utilities/elementFromString.js'\n\nexport type CreateNodeFromContentOptions = {\n slice?: boolean\n parseOptions?: ParseOptions\n errorOnInvalidContent?: boolean\n}\n\n/**\n * Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.\n * @param content The JSON or HTML content to create the node from\n * @param schema The Prosemirror schema to use for the node\n * @param options Options for the parser\n * @returns The created Prosemirror node or fragment\n */\nexport function createNodeFromContent(\n content: Content | ProseMirrorNode | Fragment,\n schema: Schema,\n options?: CreateNodeFromContentOptions,\n): ProseMirrorNode | Fragment {\n if (content instanceof ProseMirrorNode || content instanceof Fragment) {\n return content\n }\n options = {\n slice: true,\n parseOptions: {},\n ...options,\n }\n\n const isJSONContent = typeof content === 'object' && content !== null\n const isTextContent = typeof content === 'string'\n\n if (isJSONContent) {\n try {\n const isArrayContent = Array.isArray(content) && content.length > 0\n\n // if the JSON Content is an array of nodes, create a fragment for each node\n if (isArrayContent) {\n return Fragment.fromArray(content.map(item => schema.nodeFromJSON(item)))\n }\n\n const node = schema.nodeFromJSON(content)\n\n if (options.errorOnInvalidContent) {\n node.check()\n }\n\n return node\n } catch (error) {\n if (options.errorOnInvalidContent) {\n throw new Error('[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\n // Check for invalid content\n if (options.errorOnInvalidContent) {\n let hasInvalidContent = false\n let invalidContent = ''\n\n // A copy of the current schema with a catch-all node at the end\n const contentCheckSchema = new Schema({\n topNode: schema.spec.topNode,\n marks: schema.spec.marks,\n // Prosemirror's schemas are executed such that: the last to execute, matches last\n // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle\n nodes: schema.spec.nodes.append({\n __tiptap__private__unknown__catch__all__node: {\n content: 'inline*',\n group: 'block',\n parseDOM: [\n {\n tag: '*',\n getAttrs: e => {\n // If this is ever called, we know that the content has something that we don't know how to handle in the schema\n hasInvalidContent = true\n // Try to stringify the element for a more helpful error message\n invalidContent = typeof e === 'string' ? e : e.outerHTML\n return null\n },\n },\n ],\n },\n }),\n })\n\n if (options.slice) {\n DOMParser.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options.parseOptions)\n } else {\n DOMParser.fromSchema(contentCheckSchema).parse(elementFromString(content), options.parseOptions)\n }\n\n if (options.errorOnInvalidContent && hasInvalidContent) {\n throw new Error('[tiptap error]: Invalid HTML content', { cause: new Error(`Invalid element found: ${invalidContent}`) })\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\n return createNodeFromContent('', schema, options)\n}\n","export function isMacOS(): boolean {\n return typeof navigator !== 'undefined'\n ? /Mac/.test(navigator.platform)\n : false\n}\n","import { NodeType } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { 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 = {},\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 { 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(obj: Record, propOrProps: string | string[]): Record {\n const props = typeof propOrProps === 'string'\n ? [propOrProps]\n : propOrProps\n\n return Object\n .keys(obj)\n .reduce((newObj: Record, prop) => {\n if (!props.includes(prop)) {\n newObj[prop] = obj[prop]\n }\n\n return newObj\n }, {})\n}\n","import {\n Fragment, Node as ProseMirrorNode, ParseOptions, Schema,\n} from '@tiptap/pm/model'\n\nimport { 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 { Mark, MarkType } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { getMarkType } from './getMarkType.js'\n\nexport function getMarkAttributes(\n state: EditorState,\n typeOrName: string | MarkType,\n): Record {\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 { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { 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 { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { 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 { Selection } from '@tiptap/pm/state'\n\nimport { 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(predicate: Predicate) {\n return (selection: Selection) => findParentNodeClosestToPos(selection.$from, predicate)\n}\n","import { Node as ProseMirrorNode, ResolvedPos } from '@tiptap/pm/model'\n\nimport { 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 { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { 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\n },\n) {\n const range = {\n from: 0,\n to: node.content.size,\n }\n\n return getTextBetween(node, range, options)\n}\n","import { MarkType, NodeType } from '@tiptap/pm/model'\nimport { 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 {\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","import { Node, NodeType } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { getNodeType } from './getNodeType.js'\n\nexport function getNodeAttributes(\n state: EditorState,\n typeOrName: string | NodeType,\n): Record {\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 { Step, Transform } from '@tiptap/pm/transform'\n\nimport { 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 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 * 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","/**\n * Removes duplicated values within an array.\n * Supports numbers, strings and objects.\n */\nexport function removeDuplicates(array: T[], by = JSON.stringify): T[] {\n const seen: Record = {}\n\n return array.filter(item => {\n const key = by(item)\n\n return Object.prototype.hasOwnProperty.call(seen, key)\n ? false\n : (seen[key] = true)\n })\n}\n","import { Node as ProseMirrorNode } from '@tiptap/pm/model'\n\nimport { 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 { 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,\n): Record {\n return Object.fromEntries(Object\n .entries(attributes)\n .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","import { MarkType } from '@tiptap/pm/model'\nimport { EditorState } from '@tiptap/pm/state'\n\nimport { 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 = {},\n): boolean {\n const { empty, ranges } = state.selection\n const type = typeOrName ? getMarkType(typeOrName, state.schema) : null\n\n if (empty) {\n return !!(state.storedMarks || state.selection.$from.marks())\n .filter(mark => {\n if (!type) {\n return true\n }\n\n return type.name === mark.type.name\n })\n .find(mark => objectIncludes(mark.attrs, attributes, { strict: false }))\n }\n\n let selectionRange = 0\n const markRanges: MarkRange[] = []\n\n ranges.forEach(({ $from, $to }) => {\n const from = $from.pos\n const to = $to.pos\n\n state.doc.nodesBetween(from, to, (node, pos) => {\n if (!node.isText && !node.marks.length) {\n return\n }\n\n const relativeFrom = Math.max(from, pos)\n const relativeTo = Math.min(to, pos + node.nodeSize)\n const range = relativeTo - relativeFrom\n\n selectionRange += range\n\n markRanges.push(\n ...node.marks.map(mark => ({\n mark,\n from: relativeFrom,\n to: relativeTo,\n })),\n )\n })\n })\n\n if (selectionRange === 0) {\n return false\n }\n\n // calculate range of matched mark\n const matchedRange = markRanges\n .filter(markRange => {\n if (!type) {\n return true\n }\n\n return type.name === markRange.mark.type.name\n })\n .filter(markRange => objectIncludes(markRange.mark.attrs, attributes, { strict: false }))\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0)\n\n // calculate range of marks that excludes the searched mark\n // for example `code` doesn’t allow any other marks\n const excludedRange = markRanges\n .filter(markRange => {\n if (!type) {\n return true\n }\n\n return markRange.mark.type !== type && markRange.mark.type.excludes(type)\n })\n .reduce((sum, markRange) => sum + markRange.to - markRange.from, 0)\n\n // we only include the result of `excludedRange`\n // if there is a match at all\n const range = matchedRange > 0 ? matchedRange + excludedRange : matchedRange\n\n return range >= selectionRange\n}\n","import { getExtensionField } from '../helpers/getExtensionField.js'\nimport { NodeConfig } from '../index.js'\nimport { 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(extension, 'group', context))\n\n if (typeof group !== 'string') {\n return false\n }\n\n return group.split(' ').includes('list')\n}\n","import { 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*$/m.test(node.text ?? '')\n }\n }\n\n if (node.isText) {\n return !node.text\n }\n\n if (node.isAtom || node.isLeaf) {\n return false\n }\n\n if (node.content.childCount === 0) {\n return true\n }\n\n if (checkChildren) {\n let isContentEmpty = true\n\n node.content.forEach(childNode => {\n if (isContentEmpty === false) {\n // Exit early for perf\n return\n }\n\n if (!isNodeEmpty(childNode, { ignoreWhitespace, checkChildren })) {\n isContentEmpty = false\n }\n })\n\n return isContentEmpty\n }\n\n return false\n}\n","import { NodeSelection } from '@tiptap/pm/state'\n\nexport function isNodeSelection(value: unknown): value is NodeSelection {\n return value instanceof NodeSelection\n}\n","import { 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 { EditorState, 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 { RawCommands } from '../types.js'\n\nfunction ensureMarks(state: EditorState, splittableMarks?: string[]) {\n const marks = state.storedMarks || (state.selection.$to.parentOffset && state.selection.$from.marks())\n\n if (marks) {\n const filteredMarks = marks.filter(mark => splittableMarks?.includes(mark.type.name))\n\n state.tr.ensureMarks(filteredMarks)\n }\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = ({ keepMarks = true } = {}) => ({\n tr, state, dispatch, editor,\n}) => {\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 = $from.depth === 0\n ? undefined\n : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)))\n\n let types = 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 { NodeType } from '@tiptap/pm/model'\nimport { Transaction } 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 { RawCommands } from '../types.js'\n\nconst joinListBackwards = (tr: Transaction, listType: NodeType): boolean => {\n const list = findParentNode(node => node.type === listType)(tr.selection)\n\n if (!list) {\n return true\n }\n\n const before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth)\n\n if (before === undefined) {\n return true\n }\n\n const nodeBefore = tr.doc.nodeAt(before)\n const canJoinBackwards = list.node.type === nodeBefore?.type && canJoin(tr.doc, list.pos)\n\n if (!canJoinBackwards) {\n return true\n }\n\n tr.join(list.pos)\n\n return true\n}\n\nconst joinListForwards = (tr: Transaction, listType: NodeType): boolean => {\n const list = findParentNode(node => node.type === listType)(tr.selection)\n\n if (!list) {\n return true\n }\n\n const after = tr.doc.resolve(list.start).after(list.depth)\n\n if (after === undefined) {\n return true\n }\n\n const nodeAfter = tr.doc.nodeAt(after)\n const canJoinForwards = list.node.type === nodeAfter?.type && canJoin(tr.doc, after)\n\n if (!canJoinForwards) {\n return true\n }\n\n tr.join(after)\n\n return true\n}\n\ndeclare module '@tiptap/core' {\n interface Commands {\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: (listTypeOrName: string | NodeType, itemTypeOrName: string | NodeType, keepMarks?: boolean, attributes?: Record) => ReturnType;\n }\n }\n}\n\nexport const toggleList: RawCommands['toggleList'] = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({\n editor, tr, state, dispatch, chain, commands, can,\n}) => {\n const { extensions, splittableMarks } = editor.extensionManager\n const listType = getNodeType(listTypeOrName, state.schema)\n const itemType = getNodeType(itemTypeOrName, state.schema)\n const { selection, storedMarks } = state\n const { $from, $to } = selection\n const range = $from.blockRange($to)\n\n const marks = storedMarks || (selection.$to.parentOffset && selection.$from.marks())\n\n if (!range) {\n return false\n }\n\n const parentList = findParentNode(node => isList(node.type.name, extensions))(selection)\n\n if (range.depth >= 1 && parentList && range.depth - parentList.depth <= 1) {\n // remove list\n if (parentList.node.type === listType) {\n return commands.liftListItem(itemType)\n }\n\n // change list type\n if (\n isList(parentList.node.type.name, extensions)\n && listType.validContent(parentList.node.content)\n && dispatch\n ) {\n return chain()\n .command(() => {\n tr.setNodeMarkup(parentList.pos, listType)\n\n return true\n })\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n }\n }\n if (!keepMarks || !marks || !dispatch) {\n\n return chain()\n // try to convert node to default node if needed\n .command(() => {\n const canWrapInList = can().wrapInList(listType, attributes)\n\n if (canWrapInList) {\n return true\n }\n\n return commands.clearNodes()\n })\n .wrapInList(listType, attributes)\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n }\n\n return (\n chain()\n // try to convert node to default node if needed\n .command(() => {\n const canWrapInList = can().wrapInList(listType, attributes)\n\n const filteredMarks = marks.filter(mark => splittableMarks.includes(mark.type.name))\n\n tr.ensureMarks(filteredMarks)\n\n if (canWrapInList) {\n return true\n }\n\n return commands.clearNodes()\n })\n .wrapInList(listType, attributes)\n .command(() => joinListBackwards(tr, listType))\n .command(() => joinListForwards(tr, listType))\n .run()\n )\n}\n","import { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n clearContent: {\n /**\n * Clear the whole document.\n * @param emitUpdate Whether to emit an update event.\n * @example editor.commands.clearContent()\n */\n clearContent: (emitUpdate?: boolean) => ReturnType,\n }\n }\n}\n\nexport const clearContent: RawCommands['clearContent'] = (emitUpdate = false) => ({ commands }) => {\n return commands.setContent('', emitUpdate)\n}\n","import { liftTarget } from '@tiptap/pm/transform'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { Command, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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[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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalCreateParagraphNear(state, dispatch)\n}\n","import { TextSelection } from '@tiptap/pm/state'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = (originRange, targetPos) => ({ 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(newPos - 1)))\n\n return true\n}\n","import { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = typeOrName => ({ 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 { Range, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = range => ({ tr, dispatch }) => {\n const { from, to } = range\n\n if (dispatch) {\n tr.delete(from, to)\n }\n\n return true\n}\n","import { deleteSelection as originalDeleteSelection } from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalDeleteSelection(state, dispatch)\n}\n","import { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n enter: {\n /**\n * Trigger enter.\n * @example editor.commands.enter()\n */\n enter: () => ReturnType,\n }\n }\n}\n\nexport const enter: RawCommands['enter'] = () => ({ commands }) => {\n return commands.keyboardShortcut('Enter')\n}\n","import { exitCode as originalExitCode } from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalExitCode(state, dispatch)\n}\n","import { 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n extendMarkRange: {\n /**\n * Extends the text selection to the current mark by type or name.\n * @param typeOrName The type or name of the mark.\n * @param attributes The attributes of the mark.\n * @example editor.commands.extendMarkRange('bold')\n * @example editor.commands.extendMarkRange('mention', { userId: \"1\" })\n */\n extendMarkRange: (\n /**\n * The type or name of the mark.\n */\n typeOrName: string | MarkType,\n\n /**\n * The attributes of the mark.\n */\n attributes?: Record,\n ) => ReturnType\n }\n }\n}\n\nexport const extendMarkRange: RawCommands['extendMarkRange'] = (typeOrName, attributes = {}) => ({ 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 { Command, CommandProps, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'\n ? commands(props)\n : 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 { CommandProps, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n forEach: {\n /**\n * Loop through an array of items.\n */\n forEach: (\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 { Fragment, Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'\n\nimport { Content, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n insertContent: {\n /**\n * Insert a node or string of HTML at the current position.\n * @example editor.commands.insertContent('

Example

')\n * @example editor.commands.insertContent('

Example

', { 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?: {\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 ) => ReturnType;\n };\n }\n}\n\nexport const insertContent: RawCommands['insertContent'] = (value, options) => ({ tr, commands }) => {\n return commands.insertContentAt(\n { from: tr.selection.from, to: tr.selection.to },\n value,\n options,\n )\n}\n","import { Fragment, Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'\n\nimport { createNodeFromContent } from '../helpers/createNodeFromContent.js'\nimport { selectionToInsertionEnd } from '../helpers/selectionToInsertionEnd.js'\nimport { Content, Range, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n insertContentAt: {\n /**\n * Insert a node or string of HTML at a specific position.\n * @example editor.commands.insertContentAt(0, '

Example

')\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?: {\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 ) => ReturnType\n }\n }\n}\n\nconst isFragment = (nodeOrFragment: ProseMirrorNode | Fragment): nodeOrFragment is Fragment => {\n return !('type' in nodeOrFragment)\n}\n\nexport const insertContentAt: RawCommands['insertContentAt'] = (position, value, options) => ({ 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 try {\n content = createNodeFromContent(value, editor.schema, {\n parseOptions: {\n preserveWhitespace: 'full',\n ...options.parseOptions,\n },\n errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n } catch (e) {\n editor.emit('contentError', {\n editor,\n error: e as Error,\n disableCollaboration: () => {\n if (editor.storage.collaboration) {\n editor.storage.collaboration.isDisabled = true\n }\n },\n })\n return false\n }\n\n let { from, to } = typeof position === 'number' ? { from: position, to: position } : { from: position.from, to: position.to }\n\n let isOnlyTextContent = true\n let isOnlyBlockContent = true\n const nodes = isFragment(content) ? content : [content]\n\n nodes.forEach(node => {\n // check if added node is valid\n node.check()\n\n isOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false\n\n isOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false\n })\n\n // check if we can replace the wrapping node by\n // the newly inserted content\n // example:\n // replace an empty paragraph by an inserted image\n // instead of inserting the image below the paragraph\n if (from === to && isOnlyBlockContent) {\n const { parent } = tr.doc.resolve(from)\n const isEmptyTextBlock = parent.isTextblock && !parent.type.spec.code && !parent.childCount\n\n if (isEmptyTextBlock) {\n from -= 1\n to += 1\n }\n }\n\n let newContent\n\n // if there is only plain text we have to use `insertText`\n // because this will keep the current marks\n if (isOnlyTextContent) {\n // if value is string, we can use it directly\n // otherwise if it is an array, we have to join it\n if (Array.isArray(value)) {\n newContent = value.map(v => v.text || '').join('')\n } else if (value instanceof Fragment) {\n let text = ''\n\n value.forEach(node => {\n if (node.text) {\n text += node.text\n }\n })\n\n newContent = text\n } else if (typeof value === 'object' && !!value && !!value.text) {\n newContent = value.text\n } else {\n newContent = value as string\n }\n\n tr.insertText(newContent, from, to)\n } else {\n newContent = content\n\n tr.replaceWith(from, to, newContent)\n }\n\n // set cursor at end of inserted content\n if (options.updateSelection) {\n selectionToInsertionEnd(tr, tr.steps.length - 1, -1)\n }\n\n if (options.applyInputRules) {\n tr.setMeta('applyInputRules', { from, text: newContent })\n }\n\n if (options.applyPasteRules) {\n tr.setMeta('applyPasteRules', { from, text: newContent })\n }\n }\n\n return true\n}\n","import { Selection, Transaction } 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 {\n joinBackward as originalJoinBackward,\n joinDown as originalJoinDown,\n joinForward as originalJoinForward,\n joinUp as originalJoinUp,\n} from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalJoinUp(state, dispatch)\n}\n\nexport const joinDown: RawCommands['joinDown'] = () => ({ state, dispatch }) => {\n return originalJoinDown(state, dispatch)\n}\n\nexport const joinBackward: RawCommands['joinBackward'] = () => ({ state, dispatch }) => {\n return originalJoinBackward(state, dispatch)\n}\n\nexport const joinForward: RawCommands['joinForward'] = () => ({ state, dispatch }) => {\n return originalJoinForward(state, dispatch)\n}\n","import { joinPoint } from '@tiptap/pm/transform'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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 state,\n dispatch,\n tr,\n}) => {\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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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 state,\n dispatch,\n tr,\n}) => {\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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalCommand(state, dispatch)\n}\n","import { joinTextblockForward as originalCommand } from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalCommand(state, dispatch)\n}\n","import { 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 {\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'] = name => ({\n editor,\n view,\n tr,\n dispatch,\n}) => {\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'\n ? ' '\n : key,\n altKey: keys.includes('Alt'),\n ctrlKey: keys.includes('Ctrl'),\n metaKey: keys.includes('Meta'),\n shiftKey: keys.includes('Shift'),\n bubbles: true,\n cancelable: true,\n })\n\n const capturedTransaction = editor.captureTransaction(() => {\n view.someProp('handleKeyDown', f => f(view, event))\n })\n\n capturedTransaction?.steps.forEach(step => {\n const newStep = step.map(tr.mapping)\n\n if (newStep && dispatch) {\n tr.maybeStep(newStep)\n }\n })\n\n return true\n}\n","import { lift as originalLift } from '@tiptap/pm/commands'\nimport { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => ReturnType\n }\n }\n}\n\nexport const lift: RawCommands['lift'] = (typeOrName, attributes = {}) => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalLiftEmptyBlock(state, dispatch)\n}\n","import { NodeType } from '@tiptap/pm/model'\nimport { liftListItem as originalLiftListItem } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = typeOrName => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalNewlineInCode(state, dispatch)\n}\n","import { 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 { RawCommands } from '../types.js'\nimport { deleteProps } from '../utilities/deleteProps.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = (typeOrName, attributes) => ({ tr, state, dispatch }) => {\n let nodeType: NodeType | null = null\n let markType: MarkType | null = null\n\n const schemaType = getSchemaTypeNameByName(\n typeof typeOrName === 'string' ? typeOrName : typeOrName.name,\n state.schema,\n )\n\n if (!schemaType) {\n return false\n }\n\n if (schemaType === 'node') {\n nodeType = getNodeType(typeOrName as NodeType, state.schema)\n }\n\n if (schemaType === 'mark') {\n markType = getMarkType(typeOrName as MarkType, state.schema)\n }\n\n if (dispatch) {\n tr.selection.ranges.forEach(range => {\n state.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {\n if (nodeType && nodeType === node.type) {\n tr.setNodeMarkup(pos, undefined, deleteProps(node.attrs, attributes))\n }\n\n if (markType && node.marks.length) {\n node.marks.forEach(mark => {\n if (markType === mark.type) {\n tr.addMark(\n pos,\n pos + node.nodeSize,\n markType.create(deleteProps(mark.attrs, attributes)),\n )\n }\n })\n }\n })\n })\n }\n\n return true\n}\n","import { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ tr, dispatch }) => {\n if (dispatch) {\n tr.scrollIntoView()\n }\n\n return true\n}\n","import { AllSelection } from '@tiptap/pm/state'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalSelectNodeBackward(state, dispatch)\n}\n","import { selectNodeForward as originalSelectNodeForward } from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalSelectNodeForward(state, dispatch)\n}\n","import { selectParentNode as originalSelectParentNode } from '@tiptap/pm/commands'\n\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n return originalSelectTextblockStart(state, dispatch)\n}\n","import { Fragment, Node as ProseMirrorNode, ParseOptions } from '@tiptap/pm/model'\n\nimport { createDocument } from '../helpers/createDocument.js'\nimport { Content, RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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('

Example text

')\n */\n setContent: (\n /**\n * The new content.\n */\n content: Content | Fragment | ProseMirrorNode,\n\n /**\n * Whether to emit an update event.\n * @default false\n */\n emitUpdate?: boolean,\n\n /**\n * Options for parsing the content.\n * @default {}\n */\n parseOptions?: ParseOptions,\n /**\n * Options for `setContent`.\n */\n options?: {\n /**\n * Whether to throw an error if the content is invalid.\n */\n errorOnInvalidContent?: boolean;\n }\n ) => ReturnType;\n };\n }\n}\n\nexport const setContent: RawCommands['setContent'] = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({\n editor, tr, dispatch, commands,\n}) => {\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: options.errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n\n if (dispatch) {\n tr.replaceWith(0, doc.content.size, document).setMeta('preventUpdate', !emitUpdate)\n }\n return true\n }\n\n if (dispatch) {\n tr.setMeta('preventUpdate', !emitUpdate)\n }\n\n return commands.insertContentAt({ from: 0, to: doc.content.size }, content, {\n parseOptions,\n errorOnInvalidContent: options.errorOnInvalidContent ?? editor.options.enableContentCheck,\n })\n}\n","import { MarkType, ResolvedPos } from '@tiptap/pm/model'\nimport { 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => 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\n // There can be no current marks that exclude the new mark\n return (\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 = $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 = !!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'] = (typeOrName, attributes = {}) => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = (key, value) => ({ tr }) => {\n tr.setMeta(key, value)\n\n return true\n}\n","import { setBlockType } from '@tiptap/pm/commands'\nimport { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => ReturnType\n }\n }\n}\n\nexport const setNode: RawCommands['setNode'] = (typeOrName, attributes = {}) => ({ state, dispatch, chain }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n let attributesToCopy: Record | 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 { RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = position => ({ tr, dispatch }) => {\n if (dispatch) {\n const { doc } = tr\n const from = minMax(position, 0, doc.content.size)\n const selection = NodeSelection.create(doc, from)\n\n tr.setSelection(selection)\n }\n\n return true\n}\n","import { TextSelection } from '@tiptap/pm/state'\n\nimport { Range, RawCommands } from '../types.js'\nimport { minMax } from '../utilities/minMax.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = position => ({ tr, dispatch }) => {\n if (dispatch) {\n const { doc } = tr\n const { from, to } = typeof position === 'number' ? { from: position, to: position } : position\n const minPos = TextSelection.atStart(doc).from\n const maxPos = TextSelection.atEnd(doc).to\n const resolvedFrom = minMax(from, minPos, maxPos)\n const resolvedEnd = minMax(to, minPos, maxPos)\n const selection = TextSelection.create(doc, resolvedFrom, resolvedEnd)\n\n tr.setSelection(selection)\n }\n\n return true\n}\n","import { NodeType } from '@tiptap/pm/model'\nimport { sinkListItem as originalSinkListItem } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = typeOrName => ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalSinkListItem(type)(state, dispatch)\n}\n","import { 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 {\n Fragment, Node as ProseMirrorNode, NodeType, Slice,\n} 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n splitListItem: {\n /**\n * Splits one list item into two list items.\n * @param typeOrName The type or name of the node.\n * @param overrideAttrs The attributes to ensure on the new node.\n * @example editor.commands.splitListItem('listItem')\n */\n splitListItem: (typeOrName: string | NodeType, overrideAttrs?: Record) => ReturnType\n }\n }\n}\n\nexport const splitListItem: RawCommands['splitListItem'] = (typeOrName, overrideAttrs = {}) => ({\n tr, state, dispatch, editor,\n}) => {\n const type = getNodeType(typeOrName, state.schema)\n const { $from, $to } = state.selection\n\n // @ts-ignore\n // eslint-disable-next-line\n const node: ProseMirrorNode = state.selection.node\n\n if ((node && node.isBlock) || $from.depth < 2 || !$from.sameParent($to)) {\n return false\n }\n\n const grandParent = $from.node(-1)\n\n if (grandParent.type !== type) {\n return false\n }\n\n const extensionAttributes = editor.extensionManager.attributes\n\n if ($from.parent.content.size === 0 && $from.node(-1).childCount === $from.indexAfter(-1)) {\n // In an empty block. If this is a nested list, the wrapping\n // list item should be split. Otherwise, bail out and let next\n // command handle lifting.\n if (\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 // eslint-disable-next-line\n const depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3\n\n // Build a fragment containing empty versions of the structure\n // from the outer list item to the parent node of the cursor\n for (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) {\n wrap = Fragment.from($from.node(d).copy(wrap))\n }\n\n // eslint-disable-next-line\n const depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3\n\n // Add a second list item with an empty default start node\n const newNextTypeAttributes = {\n ...getSplittedAttributes(\n extensionAttributes,\n $from.node().type.name,\n $from.node().attrs,\n ),\n ...overrideAttrs,\n }\n const nextType = type.contentMatch.defaultType?.createAndFill(newNextTypeAttributes) || undefined\n\n wrap = wrap.append(Fragment.from(type.createAndFill(null, nextType) || undefined))\n\n const start = $from.before($from.depth - (depthBefore - 1))\n\n tr.replace(start, $from.after(-depthAfter), new Slice(wrap, 4 - depthBefore, 0))\n\n let sel = -1\n\n tr.doc.nodesBetween(start, tr.doc.content.size, (n, pos) => {\n if (sel > -1) {\n return false\n }\n\n if (n.isTextblock && n.content.size === 0) {\n sel = pos + 1\n }\n })\n\n if (sel > -1) {\n tr.setSelection(TextSelection.near(tr.doc.resolve(sel)))\n }\n\n tr.scrollIntoView()\n }\n\n return true\n }\n\n const nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null\n\n const newTypeAttributes = {\n ...getSplittedAttributes(\n extensionAttributes,\n grandParent.type.name,\n grandParent.attrs,\n ),\n ...overrideAttrs,\n }\n const newNextTypeAttributes = {\n ...getSplittedAttributes(\n extensionAttributes,\n $from.node().type.name,\n $from.node().attrs,\n ),\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 { MarkType } from '@tiptap/pm/model'\n\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { isMarkActive } from '../helpers/isMarkActive.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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,\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'] = (typeOrName, attributes = {}, options = {}) => ({ 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 { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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,\n ) => ReturnType\n }\n }\n}\n\nexport const toggleNode: RawCommands['toggleNode'] = (typeOrName, toggleTypeOrName, attributes = {}) => ({ 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 | 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 { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { isNodeActive } from '../helpers/isNodeActive.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => ReturnType\n }\n }\n}\n\nexport const toggleWrap: RawCommands['toggleWrap'] = (typeOrName, attributes = {}) => ({ 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = () => ({ state, dispatch }) => {\n const plugins = state.plugins\n\n for (let i = 0; i < plugins.length; i += 1) {\n const plugin = plugins[i]\n let undoable\n\n // @ts-ignore\n // eslint-disable-next-line\n if (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {\n if (dispatch) {\n const tr = state.tr\n const toUndo = undoable.transform\n\n for (let j = toUndo.steps.length - 1; j >= 0; j -= 1) {\n tr.step(toUndo.steps[j].invert(toUndo.docs[j]))\n }\n\n if (undoable.text) {\n const marks = tr.doc.resolve(undoable.from).marks()\n\n tr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks))\n } else {\n tr.delete(undoable.from, undoable.to)\n }\n }\n\n return true\n }\n }\n\n return false\n}\n","import { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\n unsetAllMarks: {\n /**\n * Remove all marks in the current selection.\n * @example editor.commands.unsetAllMarks()\n */\n unsetAllMarks: () => ReturnType,\n }\n }\n}\n\nexport const unsetAllMarks: RawCommands['unsetAllMarks'] = () => ({ tr, dispatch }) => {\n const { selection } = tr\n const { empty, ranges } = selection\n\n if (empty) {\n return true\n }\n\n if (dispatch) {\n ranges.forEach(range => {\n tr.removeMark(range.$from.pos, range.$to.pos)\n })\n }\n\n return true\n}\n","import { MarkType } from '@tiptap/pm/model'\n\nimport { getMarkRange } from '../helpers/getMarkRange.js'\nimport { getMarkType } from '../helpers/getMarkType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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'] = (typeOrName, options = {}) => ({ 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 {\n Mark, MarkType, Node, NodeType,\n} from '@tiptap/pm/model'\nimport { 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 { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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,\n ) => ReturnType\n }\n }\n}\n\nexport const updateAttributes: RawCommands['updateAttributes'] = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\n\n let nodeType: NodeType | null = null\n let markType: MarkType | null = null\n\n const schemaType = getSchemaTypeNameByName(\n typeof typeOrName === 'string' ? typeOrName : typeOrName.name,\n state.schema,\n )\n\n if (!schemaType) {\n return false\n }\n\n if (schemaType === 'node') {\n nodeType = getNodeType(typeOrName as NodeType, state.schema)\n }\n\n if (schemaType === 'mark') {\n markType = getMarkType(typeOrName as MarkType, state.schema)\n }\n\n if (dispatch) {\n tr.selection.ranges.forEach((range: SelectionRange) => {\n\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\n if (nodeType && nodeType === node.type) {\n trimmedFrom = Math.max(pos, from)\n trimmedTo = Math.min(pos + node.nodeSize, to)\n lastPos = pos\n lastNode = node\n }\n })\n } else {\n state.doc.nodesBetween(from, to, (node: Node, pos: number) => {\n\n if (pos < from && nodeType && nodeType === node.type) {\n trimmedFrom = Math.max(pos, from)\n trimmedTo = Math.min(pos + node.nodeSize, to)\n lastPos = pos\n lastNode = node\n }\n\n if (pos >= from && pos <= to) {\n\n if (nodeType && nodeType === node.type) {\n tr.setNodeMarkup(pos, undefined, {\n ...node.attrs,\n ...attributes,\n })\n }\n\n if (markType && node.marks.length) {\n node.marks.forEach((mark: Mark) => {\n\n if (markType === mark.type) {\n const trimmedFrom2 = Math.max(pos, from)\n const trimmedTo2 = Math.min(pos + node.nodeSize, to)\n\n tr.addMark(\n trimmedFrom2,\n trimmedTo2,\n markType.create({\n ...mark.attrs,\n ...attributes,\n }),\n )\n }\n })\n }\n }\n })\n }\n\n if (lastNode) {\n\n if (lastPos !== undefined) {\n tr.setNodeMarkup(lastPos, undefined, {\n ...lastNode.attrs,\n ...attributes,\n })\n }\n\n if (markType && lastNode.marks.length) {\n lastNode.marks.forEach((mark: Mark) => {\n\n if (markType === mark.type) {\n tr.addMark(\n trimmedFrom,\n trimmedTo,\n markType.create({\n ...mark.attrs,\n ...attributes,\n }),\n )\n }\n })\n }\n }\n })\n }\n\n return true\n}\n","import { wrapIn as originalWrapIn } from '@tiptap/pm/commands'\nimport { NodeType } from '@tiptap/pm/model'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => ReturnType\n }\n }\n}\n\nexport const wrapIn: RawCommands['wrapIn'] = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalWrapIn(type, attributes)(state, dispatch)\n}\n","import { NodeType } from '@tiptap/pm/model'\nimport { wrapInList as originalWrapInList } from '@tiptap/pm/schema-list'\n\nimport { getNodeType } from '../helpers/getNodeType.js'\nimport { RawCommands } from '../types.js'\n\ndeclare module '@tiptap/core' {\n interface Commands {\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) => ReturnType\n }\n }\n}\n\nexport const wrapInList: RawCommands['wrapInList'] = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\n const type = getNodeType(typeOrName, state.schema)\n\n return originalWrapInList(type, attributes)(state, dispatch)\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 { 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 FocusEvents = Extension.create({\n name: 'focusEvents',\n\n addProseMirrorPlugins() {\n const { editor } = this\n\n return [\n new Plugin({\n key: new PluginKey('focusEvents'),\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 = () => this.editor.commands.first(({ commands }) => [\n () => commands.undoInputRule(),\n\n // maybe convert first text block node to default node\n () => commands.command(({ tr }) => {\n const { selection, doc } = tr\n const { empty, $anchor } = selection\n const { pos, parent } = $anchor\n const $parentPos = $anchor.parent.isTextblock && pos > 0 ? tr.doc.resolve(pos - 1) : $anchor\n const parentIsIsolating = $parentPos.parent.type.spec.isolating\n\n const parentPos = $anchor.pos - $anchor.parentOffset\n\n const isAtStart = (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 = () => this.editor.commands.first(({ commands }) => [\n () => commands.deleteSelection(),\n () => commands.deleteCurrentNode(),\n () => commands.joinForward(),\n () => commands.selectNodeForward(),\n ])\n\n const handleEnter = () => this.editor.commands.first(({ commands }) => [\n () => commands.newlineInCode(),\n () => commands.createParagraphNear(),\n () => commands.liftEmptyBlock(),\n () => commands.splitBlock(),\n ])\n\n const baseKeymap = {\n Enter: handleEnter,\n 'Mod-Enter': () => this.editor.commands.exitCode(),\n Backspace: handleBackspace,\n 'Mod-Backspace': handleBackspace,\n 'Shift-Backspace': handleBackspace,\n Delete: handleDelete,\n 'Mod-Delete': handleDelete,\n 'Mod-a': () => this.editor.commands.selectAll(),\n }\n\n const pcKeymap = {\n ...baseKeymap,\n }\n\n const macKeymap = {\n ...baseKeymap,\n 'Ctrl-h': handleBackspace,\n 'Alt-Backspace': handleBackspace,\n 'Ctrl-d': handleDelete,\n 'Ctrl-Alt-Backspace': handleDelete,\n 'Alt-Delete': handleDelete,\n 'Alt-d': handleDelete,\n 'Ctrl-a': () => this.editor.commands.selectTextblockStart(),\n 'Ctrl-e': () => this.editor.commands.selectTextblockEnd(),\n }\n\n if (isiOS() || isMacOS()) {\n return macKeymap\n }\n\n return pcKeymap\n },\n\n addProseMirrorPlugins() {\n return [\n // With this plugin we check if the whole document was selected and deleted.\n // In this case we will additionally call `clearNodes()` to convert e.g. a heading\n // to a paragraph if necessary.\n // This is an alternative to ProseMirror's `AllSelection`, which doesn’t work well\n // with many other commands.\n new Plugin({\n key: new PluginKey('clearDocument'),\n appendTransaction: (transactions, oldState, newState) => {\n if (transactions.some(tr => tr.getMeta('composition'))) {\n return\n }\n\n const docChanges = transactions.some(transaction => transaction.docChanged)\n && !oldState.doc.eq(newState.doc)\n\n const ignoreTr = transactions.some(transaction => transaction.getMeta('preventClearDocument'))\n\n if (!docChanges || ignoreTr) {\n return\n }\n\n const { empty, from, to } = oldState.selection\n const allFrom = Selection.atStart(oldState.doc).from\n const allEnd = Selection.atEnd(oldState.doc).to\n const allWasSelected = from === allFrom && to === allEnd\n\n if (empty || !allWasSelected) {\n return\n }\n\n const isEmpty = isNodeEmpty(newState.doc)\n\n if (!isEmpty) {\n return\n }\n\n const tr = newState.tr\n const state = createChainableState({\n state: newState,\n transaction: tr,\n })\n const { commands } = new CommandManager({\n editor: this.editor,\n state,\n })\n\n commands.clearNodes()\n\n if (!tr.steps.length) {\n return\n }\n\n return tr\n },\n }),\n ]\n },\n})\n","import { Plugin, PluginKey } from '@tiptap/pm/state'\n\nimport { Extension } from '../Extension.js'\n\nexport const Paste = Extension.create({\n name: 'paste',\n\n addProseMirrorPlugins() {\n\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\nexport const Tabindex = Extension.create({\n name: 'tabindex',\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('tabindex'),\n props: {\n attributes: (): { [name: string]: string; } => (this.editor.isEditable ? { tabindex: '0' } : {}),\n },\n }),\n ]\n },\n})\n","import {\n Fragment, Node, ResolvedPos,\n} from '@tiptap/pm/model'\n\nimport { Editor } from './Editor.js'\nimport { 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(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`)\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\n const targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1)\n const $pos = this.resolvedPos.doc.resolve(targetPos)\n\n if (!isBlock && $pos.depth <= this.depth) {\n return\n }\n\n const childNodePos = new NodePos($pos, this.editor, isBlock, isBlock ? node : null)\n\n if (isBlock) {\n childNodePos.actualDepth = this.depth + 1\n }\n\n children.push(new NodePos($pos, this.editor, isBlock, isBlock ? node : null))\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(selector: string, attributes: { [key: string]: any } = {}, firstItemOnly = false): 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(key => attributes[key] === childPos.node.attrs[key])\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","/* eslint-disable @typescript-eslint/no-empty-object-type */\nimport {\n MarkType,\n Node as ProseMirrorNode,\n NodeType,\n Schema,\n} from '@tiptap/pm/model'\nimport {\n EditorState, Plugin, PluginKey, Transaction,\n} from '@tiptap/pm/state'\nimport { EditorView } from '@tiptap/pm/view'\n\nimport { CommandManager } from './CommandManager.js'\nimport { EventEmitter } from './EventEmitter.js'\nimport { ExtensionManager } from './ExtensionManager.js'\nimport {\n ClipboardTextSerializer, Commands, Drop, Editable, FocusEvents, Keymap, Paste,\n Tabindex,\n} from './extensions/index.js'\nimport { createDocument } from './helpers/createDocument.js'\nimport { getAttributes } from './helpers/getAttributes.js'\nimport { getHTMLFromFragment } from './helpers/getHTMLFromFragment.js'\nimport { getText } from './helpers/getText.js'\nimport { getTextSerializersFromSchema } from './helpers/getTextSerializersFromSchema.js'\nimport { isActive } from './helpers/isActive.js'\nimport { isNodeEmpty } from './helpers/isNodeEmpty.js'\nimport { resolveFocusPosition } from './helpers/resolveFocusPosition.js'\nimport { NodePos } from './NodePos.js'\nimport { style } from './style.js'\nimport {\n CanCommands,\n ChainedCommands,\n EditorEvents,\n EditorOptions,\n JSONContent,\n SingleCommands,\n TextSerializer,\n} from './types.js'\nimport { createStyleTag } from './utilities/createStyleTag.js'\nimport { isFunction } from './utilities/isFunction.js'\n\nexport * as extensions from './extensions/index.js'\n\n// @ts-ignore\nexport interface TiptapEditorHTMLElement extends HTMLElement {\n editor?: Editor\n}\n\nexport class Editor extends EventEmitter {\n private commandManager!: CommandManager\n\n public extensionManager!: ExtensionManager\n\n private css!: HTMLStyleElement\n\n public schema!: Schema\n\n public view!: EditorView\n\n public isFocused = false\n\n /**\n * The editor is considered initialized after the `create` event has been emitted.\n */\n public isInitialized = false\n\n public extensionStorage: Record = {}\n\n public options: EditorOptions = {\n element: document.createElement('div'),\n content: '',\n injectCSS: true,\n injectNonce: undefined,\n extensions: [],\n autofocus: false,\n editable: true,\n editorProps: {},\n parseOptions: {},\n coreExtensionOptions: {},\n enableInputRules: true,\n enablePasteRules: true,\n enableCoreExtensions: true,\n enableContentCheck: false,\n onBeforeCreate: () => null,\n onCreate: () => null,\n onUpdate: () => null,\n onSelectionUpdate: () => null,\n onTransaction: () => null,\n onFocus: () => null,\n onBlur: () => null,\n onDestroy: () => null,\n onContentError: ({ error }) => { throw error },\n onPaste: () => null,\n onDrop: () => null,\n }\n\n constructor(options: Partial = {}) {\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('contentError', this.options.onContentError)\n this.createView()\n this.injectCSS()\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\n window.setTimeout(() => {\n if (this.isDestroyed) {\n return\n }\n\n this.commands.focus(this.options.autofocus)\n this.emit('create', { editor: this })\n this.isInitialized = true\n }, 0)\n }\n\n /**\n * Returns the editor storage.\n */\n public get storage(): Record {\n return this.extensionStorage\n }\n\n /**\n * An object of all registered commands.\n */\n public get commands(): SingleCommands {\n return this.commandManager.commands\n }\n\n /**\n * Create a command chain to call multiple commands at once.\n */\n public chain(): ChainedCommands {\n return this.commandManager.chain()\n }\n\n /**\n * Check if a command or a command chain can be executed. Without executing it.\n */\n public can(): CanCommands {\n return this.commandManager.can()\n }\n\n /**\n * Inject CSS styles.\n */\n private injectCSS(): void {\n if (this.options.injectCSS && document) {\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 = {}): void {\n this.options = {\n ...this.options,\n ...options,\n }\n\n if (!this.view || !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 })\n }\n }\n\n /**\n * Returns whether the editor is editable.\n */\n public get isEditable(): boolean {\n // since plugins are applied after creating the view\n // `editable` is always `true` for one tick.\n // that’s why we also have to check for `options.editable`\n return this.options.editable && this.view && this.view.editable\n }\n\n /**\n * Returns the editor state.\n */\n public get state(): EditorState {\n return this.view.state\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(nameOrPluginKeyToRemove: string | PluginKey | (string | PluginKey)[]): 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 = prevPlugins.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\n const coreExtensions = this.options.enableCoreExtensions ? [\n Editable,\n ClipboardTextSerializer.configure({\n blockSeparator: this.options.coreExtensionOptions?.clipboardTextSerializer?.blockSeparator,\n }),\n Commands,\n FocusEvents,\n Keymap,\n Tabindex,\n Drop,\n Paste,\n ].filter(ext => {\n if (typeof this.options.enableCoreExtensions === 'object') {\n return this.options.enableCoreExtensions[ext.name as keyof typeof this.options.enableCoreExtensions] !== false\n }\n return true\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 a ProseMirror view.\n */\n private createView(): void {\n let doc: ProseMirrorNode\n\n try {\n doc = createDocument(\n this.options.content,\n this.schema,\n this.options.parseOptions,\n { errorOnInvalidContent: this.options.enableContentCheck },\n )\n } catch (e) {\n if (!(e instanceof Error) || !['[tiptap error]: Invalid JSON content', '[tiptap error]: Invalid HTML content'].includes(e.message)) {\n // Not the content error we were expecting\n throw e\n }\n this.emit('contentError', {\n editor: this,\n error: e as Error,\n disableCollaboration: () => {\n if (this.storage.collaboration) {\n this.storage.collaboration.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(extension => extension.name !== 'collaboration')\n\n // Restart the initialization process by recreating the extension manager with the new set of extensions\n this.createExtensionManager()\n },\n })\n\n // Content is invalid, but attempt to create it anyway, stripping out the invalid parts\n doc = createDocument(\n this.options.content,\n this.schema,\n this.options.parseOptions,\n { errorOnInvalidContent: false },\n )\n }\n const selection = resolveFocusPosition(doc, this.options.autofocus)\n\n this.view = new EditorView(this.options.element, {\n ...this.options.editorProps,\n attributes: {\n // add `role=\"textbox\"` to the editor element\n role: 'textbox',\n ...this.options.editorProps?.attributes,\n },\n dispatchTransaction: this.dispatchTransaction.bind(this),\n state: EditorState.create({\n doc,\n selection: selection || undefined,\n }),\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.createNodeViews()\n this.prependClass()\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 views.\n */\n public createNodeViews(): void {\n if (this.view.isDestroyed) {\n return\n }\n\n this.view.setProps({\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 = `tiptap ${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 const state = this.state.apply(transaction)\n const selectionHasChanged = !this.state.selection.eq(state.selection)\n\n this.emit('beforeTransaction', {\n editor: this,\n transaction,\n nextState: state,\n })\n this.view.updateState(state)\n this.emit('transaction', {\n editor: this,\n transaction,\n })\n\n if (selectionHasChanged) {\n this.emit('selectionUpdate', {\n editor: this,\n transaction,\n })\n }\n\n const focus = transaction.getMeta('focus')\n const blur = transaction.getMeta('blur')\n\n if (focus) {\n this.emit('focus', {\n editor: this,\n event: focus.event,\n transaction,\n })\n }\n\n if (blur) {\n this.emit('blur', {\n editor: this,\n event: blur.event,\n transaction,\n })\n }\n\n if (!transaction.docChanged || transaction.getMeta('preventUpdate')) {\n return\n }\n\n this.emit('update', {\n editor: this,\n transaction,\n })\n }\n\n /**\n * Get attributes of the currently selected node or mark.\n */\n public getAttributes(nameOrType: string | NodeType | MarkType): Record {\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 = 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(): JSONContent {\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\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 * Get the number of characters for the current document.\n *\n * @deprecated\n */\n public getCharacterCount(): number {\n console.warn(\n '[tiptap warn]: \"editor.getCharacterCount()\" is deprecated. Please use \"editor.storage.characterCount.characters()\" instead.',\n )\n\n return this.state.doc.content.size - 2\n }\n\n /**\n * Destroy the editor.\n */\n public destroy(): void {\n this.emit('destroy')\n\n if (this.view) {\n // Cleanup our reference to prevent circular references which caused memory leaks\n // @ts-ignore\n const dom = this.view.dom as TiptapEditorHTMLElement\n\n if (dom && dom.editor) {\n delete dom.editor\n }\n this.view.destroy()\n }\n\n this.removeAllListeners()\n }\n\n /**\n * Check if the editor is already destroyed.\n */\n public get isDestroyed(): boolean {\n // @ts-ignore\n return !this.view?.docView\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\n return new NodePos($pos, this)\n }\n\n get $doc() {\n return this.$pos(0)\n }\n}\n","export function createStyleTag(style: string, nonce?: string, suffix?: string): HTMLStyleElement {\n const tiptapStyleTag = (document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ''}]`))\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","export const style = `.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}`\n","import { 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 = {},\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 { MarkType } from '@tiptap/pm/model'\n\nimport { getMarksBetween } from '../helpers/getMarksBetween.js'\nimport { InputRule, InputRuleFinder } from '../InputRule.js'\nimport { 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 getAttributes?:\n | Record\n | ((match: ExtendedRegExpMatchArray) => Record)\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 })\n}\n","import { NodeType } from '@tiptap/pm/model'\n\nimport { InputRule, InputRuleFinder } from '../InputRule.js'\nimport { 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 * A function that returns the attributes for the node\n * can also be an object of attributes\n */\n getAttributes?:\n | Record\n | ((match: ExtendedRegExpMatchArray) => Record)\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 })\n}\n","import { NodeType } from '@tiptap/pm/model'\n\nimport { InputRule, InputRuleFinder } from '../InputRule.js'\nimport { 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 getAttributes?:\n | Record\n | ((match: ExtendedRegExpMatchArray) => Record)\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 })\n}\n","import { Node as ProseMirrorNode, NodeType } from '@tiptap/pm/model'\nimport { canJoin, findWrapping } from '@tiptap/pm/transform'\n\nimport { Editor } from '../Editor.js'\nimport { InputRule, InputRuleFinder } from '../InputRule.js'\nimport { 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 getAttributes?:\n | Record\n | ((match: ExtendedRegExpMatchArray) => Record)\n | false\n | null\n ,\n joinPredicate?: (match: ExtendedRegExpMatchArray, node: ProseMirrorNode) => boolean,\n}) {\n return new InputRule({\n find: config.find,\n handler: ({\n state, range, match, chain,\n }) => {\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 = config.type.name === 'bulletList' || config.type.name === 'orderedList' ? 'listItem' : '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 })\n}\n","import {\n DOMOutputSpec, Node as ProseMirrorNode, NodeSpec, NodeType,\n} from '@tiptap/pm/model'\nimport { Plugin, Transaction } from '@tiptap/pm/state'\n\nimport { Editor } from './Editor.js'\nimport { getExtensionField } from './helpers/getExtensionField.js'\nimport { NodeConfig } from './index.js'\nimport { InputRule } from './InputRule.js'\nimport { Mark } from './Mark.js'\nimport { PasteRule } from './PasteRule.js'\nimport {\n AnyConfig,\n Attributes,\n Extensions,\n GlobalAttributes,\n KeyboardShortcutCommand,\n NodeViewRenderer,\n ParentConfig,\n RawCommands,\n} from './types.js'\nimport { callOrReturn } from './utilities/callOrReturn.js'\nimport { mergeDeep } from './utilities/mergeDeep.js'\n\ndeclare module '@tiptap/core' {\n interface NodeConfig {\n // @ts-ignore - this is a dynamic key\n [key: string]: 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 * The default options for this extension.\n * @example\n * defaultOptions: {\n * myOption: 'foo',\n * myOtherOption: 10,\n * }\n */\n defaultOptions?: Options\n\n /**\n * This method will add options to this extension\n * @see https://tiptap.dev/guide/custom-extensions#settings\n * @example\n * addOptions() {\n * return {\n * myOption: 'foo',\n * myOtherOption: 10,\n * }\n */\n addOptions?: (this: {\n name: string\n parent: Exclude>['addOptions'], undefined>\n }) => Options\n\n /**\n * The default storage this extension can save data to.\n * @see https://tiptap.dev/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: Exclude>['addStorage'], undefined>\n }) => Storage\n\n /**\n * This function adds globalAttributes to specific nodes.\n * @see https://tiptap.dev/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>['addGlobalAttributes']\n }) => GlobalAttributes\n\n /**\n * This function adds commands to the editor\n * @see https://tiptap.dev/guide/custom-extensions#keyboard-shortcuts\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: NodeType\n parent: ParentConfig>['addCommands']\n }) => Partial\n\n /**\n * This function registers keyboard shortcuts.\n * @see https://tiptap.dev/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: NodeType\n parent: ParentConfig>['addKeyboardShortcuts']\n }) => {\n [key: string]: KeyboardShortcutCommand\n }\n\n /**\n * This function adds input rules to the editor.\n * @see https://tiptap.dev/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: NodeType\n parent: ParentConfig>['addInputRules']\n }) => InputRule[]\n\n /**\n * This function adds paste rules to the editor.\n * @see https://tiptap.dev/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: NodeType\n parent: ParentConfig>['addPasteRules']\n }) => PasteRule[]\n\n /**\n * This function adds Prosemirror plugins to the editor\n * @see https://tiptap.dev/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: NodeType\n parent: ParentConfig>['addProseMirrorPlugins']\n }) => Plugin[]\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>['addExtensions']\n }) => Extensions\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>['extendNodeSchema']\n },\n extension: Node,\n ) => Record)\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>['extendMarkSchema']\n editor?: Editor\n },\n extension: Node,\n ) => Record)\n | null\n\n /**\n * The editor is not ready yet.\n */\n onBeforeCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: NodeType\n parent: ParentConfig>['onBeforeCreate']\n }) => void)\n | null\n\n /**\n * The editor is ready.\n */\n onCreate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: NodeType\n parent: ParentConfig>['onCreate']\n }) => void)\n | null\n\n /**\n * The content has changed.\n */\n onUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: NodeType\n parent: ParentConfig>['onUpdate']\n }) => void)\n | null\n\n /**\n * The selection has changed.\n */\n onSelectionUpdate?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: NodeType\n parent: ParentConfig>['onSelectionUpdate']\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: NodeType\n parent: ParentConfig>['onTransaction']\n },\n props: {\n editor: Editor\n transaction: Transaction\n },\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: NodeType\n parent: ParentConfig>['onFocus']\n },\n props: {\n event: FocusEvent\n },\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: NodeType\n parent: ParentConfig>['onBlur']\n },\n props: {\n event: FocusEvent\n },\n ) => void)\n | null\n\n /**\n * The editor is destroyed.\n */\n onDestroy?:\n | ((this: {\n name: string\n options: Options\n storage: Storage\n editor: Editor\n type: NodeType\n parent: ParentConfig>['onDestroy']\n }) => void)\n | null\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>['addNodeView']\n }) => NodeViewRenderer)\n | null\n\n /**\n * Defines if this node should be a top level node (doc)\n * @default false\n * @example true\n */\n topNode?: boolean\n\n /**\n * The content expression for this node, as described in the [schema\n * guide](/docs/guide/#schema.content_expressions). When not given,\n * the node does not allow any content.\n *\n * You can read more about it on the Prosemirror documentation here\n * @see https://prosemirror.net/docs/guide/#schema.content_expressions\n * @default undefined\n * @example content: 'block+'\n * @example content: 'headline paragraph block*'\n */\n content?:\n | NodeSpec['content']\n | ((this: {\n name: string\n options: Options\n storage: Storage\n parent: ParentConfig>['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>['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>['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>['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>['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>['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>['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>['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>['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>['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>['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>['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>['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>['renderHTML']\n editor?: Editor\n },\n props: {\n node: ProseMirrorNode\n HTMLAttributes: Record\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>['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>['addAttributes']\n editor?: Editor\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n }) => Attributes | {}\n }\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 {\n type = 'node'\n\n name = 'node'\n\n parent: Node | null = null\n\n child: Node | null = null\n\n options: Options\n\n storage: Storage\n\n config: NodeConfig = {\n name: this.name,\n defaultOptions: {},\n }\n\n constructor(config: Partial> = {}) {\n this.config = {\n ...this.config,\n ...config,\n }\n\n this.name = this.config.name\n\n if (config.defaultOptions && Object.keys(config.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${this.name}\".`,\n )\n }\n\n // TODO: remove `addOptions` fallback\n this.options = this.config.defaultOptions\n\n if (this.config.addOptions) {\n this.options = callOrReturn(\n getExtensionField(this, 'addOptions', {\n name: this.name,\n }),\n )\n }\n\n this.storage = callOrReturn(\n getExtensionField(this, 'addStorage', {\n name: this.name,\n options: this.options,\n }),\n ) || {}\n }\n\n static create(config: Partial> = {}) {\n return new Node(config)\n }\n\n configure(options: Partial = {}) {\n // return a new instance so we can use the same extension\n // with different calls of `configure`\n const extension = this.extend({\n ...this.config,\n addOptions: () => {\n return mergeDeep(this.options as Record, options) as Options\n },\n })\n\n // Always preserve the current name\n extension.name = this.name\n // Set the parent to be our parent\n extension.parent = this.parent\n\n return extension\n }\n\n extend(\n extendedConfig: Partial> = {},\n ) {\n const extension = new Node(extendedConfig)\n\n extension.parent = this\n\n this.child = extension\n\n extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name\n\n if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {\n console.warn(\n `[tiptap warn]: BREAKING CHANGE: \"defaultOptions\" is deprecated. Please use \"addOptions\" instead. Found in extension: \"${extension.name}\".`,\n )\n }\n\n extension.options = callOrReturn(\n getExtensionField(extension, 'addOptions', {\n name: extension.name,\n }),\n )\n\n extension.storage = callOrReturn(\n getExtensionField(extension, 'addStorage', {\n name: extension.name,\n options: extension.options,\n }),\n )\n\n return extension\n }\n}\n","import { MarkType } from '@tiptap/pm/model'\n\nimport { getMarksBetween } from '../helpers/getMarksBetween.js'\nimport { PasteRule, PasteRuleFinder } from '../PasteRule.js'\nimport { 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\n | ((match: ExtendedRegExpMatchArray, event: ClipboardEvent) => Record)\n | false\n | null\n}) {\n return new PasteRule({\n find: config.find,\n handler: ({\n state, range, match, pasteEvent,\n }) => {\n const attributes = callOrReturn(config.getAttributes, undefined, match, pasteEvent)\n\n if (attributes === false || attributes === null) {\n return null\n }\n\n const { tr } = state\n const captureGroup = match[match.length - 1]\n const fullMatch = match[0]\n let markEnd = range.to\n\n if (captureGroup) {\n const startSpaces = fullMatch.search(/\\S/)\n const textStart = range.from + fullMatch.indexOf(captureGroup)\n const textEnd = textStart + captureGroup.length\n\n const excludedMarks = getMarksBetween(range.from, range.to, state.doc)\n .filter(item => {\n // @ts-ignore\n const excluded = item.mark.type.excluded as MarkType[]\n\n return excluded.find(type => type === config.type && type !== item.mark.type)\n })\n .filter(item => item.to > textStart)\n\n if (excludedMarks.length) {\n return null\n }\n\n if (textEnd < range.to) {\n tr.delete(textEnd, range.to)\n }\n\n if (textStart > range.from) {\n tr.delete(range.from + startSpaces, textStart)\n }\n\n markEnd = range.from + startSpaces + captureGroup.length\n\n tr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}))\n\n tr.removeStoredMark(config.type)\n }\n },\n })\n}\n","// source: https://stackoverflow.com/a/6969486\nexport function escapeForRegEx(string: string): string {\n return string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, '\\\\$&')\n}\n"],"names":["createChainableState","config","state","transaction","selection","doc","storedMarks","_objectSpread","apply","bind","applyTransaction","plugins","schema","reconfigure","toJSON","tr","CommandManager","constructor","props","this","editor","rawCommands","extensionManager","commands","customState","hasCustomState","_this","view","buildProps","Object","fromEntries","entries","map","_ref","name","command","callback","arguments","getMeta","dispatch","chain","createChain","can","createCan","startTr","_this2","shouldDispatch","length","undefined","callbacks","hasStartTransaction","_ref2","push","run","every","formattedCommands","_ref3","_ref4","EventEmitter","on","event","fn","emit","_len","args","Array","_key","forEach","off","filter","once","_this3","onceFn","_len2","_key2","removeAllListeners","getExtensionField","extension","field","context","parent","splitExtensions","extensions","baseExtensions","type","nodeExtensions","markExtensions","getAttributesFromExtensions","extensionAttributes","nodeAndMarkExtensions","defaultAttribute","default","rendered","renderHTML","parseHTML","keepOnSplit","isRequired","addGlobalAttributes","options","storage","globalAttribute","types","attributes","_ref5","attribute","addAttributes","_ref6","mergedAttr","getNodeType","nameOrType","nodes","Error","concat","mergeAttributes","_len3","objects","_key3","item","reduce","items","mergedAttributes","_ref7","key","value","valueClasses","String","split","existingClasses","insertClasses","valueClass","includes","join","newStyles","style","trim","Boolean","existingStyles","styleMap","Map","property","val","part","set","from","_ref8","getRenderedAttributes","nodeOrMark","attrs","isFunction","callOrReturn","_len4","_key4","injectExtensionAttributesToParseRule","parseRule","getAttrs","node","oldAttributes","newAttributes","match","Number","fromString","getAttribute","cleanUpSchemaItem","data","_ref9","keys","isEmptyObject","getSchemaByResolvedExtensions","allAttributes","topNode","_a","find","extraNodeFields","fields","e","extendNodeSchema","content","marks","group","inline","atom","selectable","draggable","code","whitespace","linebreakReplacement","defining","isolating","extensionAttribute","parseDOM","toDOM","HTMLAttributes","renderText","toText","extraMarkFields","extendMarkSchema","inclusive","excludes","spanning","mark","Schema","getSchemaTypeByName","isExtensionRulesEnabled","enabled","isArray","some","enabledExtension","getHTMLFromFragment","fragment","documentFragment","DOMSerializer","fromSchema","serializeFragment","container","document","implementation","createHTMLDocument","createElement","appendChild","innerHTML","isRegExp","prototype","toString","call","InputRule","handler","run$1","to","text","rules","plugin","composing","$from","resolve","spec","nodeBefore","nodeAfter","matched","textBefore","maxMatch","sliceEndPos","parentOffset","nodesBetween","Math","max","pos","index","chunk","_b","textContent","isAtom","isText","slice","getTextContentFromNodes","rule","inputRuleMatcherHandler","exec","inputRuleMatch","result","input","replaceWith","console","warn","range","steps","setMeta","transform","inputRulesPlugin","Plugin","init","prev","stored","simulatedInputMeta","setTimeout","Fragment","selectionSet","docChanged","handleTextInput","handleDOMEvents","compositionend","$cursor","handleKeyDown","isInputRules","isPlainObject","getType","getPrototypeOf","mergeDeep","target","source","output","Mark","child","defaultOptions","addOptions","create","configure","extend","extendedConfig","handleExit","_ref10","currentPos","end","currentMarks","m","removeMark","removeStoredMark","insertText","PasteRule","pasteEvent","dropEvent","handlers","isTextblock","resolvedFrom","resolvedTo","min","size","pasteRuleMatcherHandler","matchAll","matches","pasteRuleMatch","textBetween","start","mapping","tiptapDragFromOtherEditor","pasteRulesPlugin","dragSourceElement","isPastedFromProseMirror","isDroppedFromProseMirror","ClipboardEvent","DragEvent","_unused","processEvent","_ref11","pasteEvt","chainableState","b","_unused2","handleDragstart","dom","parentElement","contains","handleDragend","window","addEventListener","destroy","removeEventListener","drop","dragFromOtherEditor","deleteRange","paste","_view","html","clipboardData","getData","appendTransaction","transactions","oldState","isPaste","isDrop","simulatedPasteMeta","isSimulatedPaste","DataTransfer","setData","createClipboardPasteEvent","findDiffStart","findDiffEnd","ExtensionManager","splittableMarks","setupExtensions","resolvedExtensions","sort","flatten","duplicatedNames","filtered","el","indexOf","Set","findDuplicates","addExtensions","flat","a","priorityA","priorityB","addCommands","reverse","inputRules","pasteRules","allPlugins","addKeyboardShortcuts","defaultBindings","ArrowRight","bindings","_ref12","shortcut","method","keyMapPlugin","keymap","addInputRules","enableInputRules","addPasteRules","enablePasteRules","addProseMirrorPlugins","proseMirrorPlugins","nodeViews","addNodeView","nodeview","getPos","decorations","innerDecorations","extensionStorage","onBeforeCreate","onCreate","onUpdate","onSelectionUpdate","onTransaction","onFocus","onBlur","onDestroy","Extension","getTextBetween","startNode","blockSeparator","textSerializers","isBlock","textSerializer","getTextSerializersFromSchema","_ref13","_ref14","ClipboardTextSerializer","PluginKey","clipboardTextSerializer","ranges","$to","objectIncludes","object1","object2","strict","test","findMarkInSet","k","isMarkInSet","getMarkRange","$pos","childAfter","childBefore","startIndex","startPos","offset","endIndex","endPos","nodeSize","childCount","getMarkType","isTextSelection","TextSelection","minMax","resolveFocusPosition","position","selectionAtStart","Selection","atStart","selectionAtEnd","atEnd","minPos","maxPos","isAndroid","navigator","platform","userAgent","isiOS","removeWhitespaces","children","childNodes","i","nodeType","nodeValue","removeChild","elementFromString","wrappedValue","DOMParser","parseFromString","body","createNodeFromContent","Node$1","parseOptions","isTextContent","fromArray","nodeFromJSON","errorOnInvalidContent","check","error","cause","hasInvalidContent","invalidContent","contentCheckSchema","append","__tiptap__private__unknown__catch__all__node","tag","outerHTML","parseSlice","parse","parser","isMacOS","isNodeActive","typeOrName","empty","nodeRanges","relativeFrom","relativeTo","selectionRange","matchedNodeRanges","nodeRange","sum","getSchemaTypeNameByName","deleteProps","obj","propOrProps","newObj","prop","createDocument","getMarkAttributes","$head","markItem","combineTransactionSteps","oldDoc","Transform","step","findChildrenInRange","predicate","nodesWithPos","findParentNode","depth","before","findParentNodeClosestToPos","getText","getAttributes","schemaType","nodeItem","getNodeAttributes","simplifyChangedRanges","changes","uniqueChanges","array","by","JSON","stringify","seen","hasOwnProperty","removeDuplicates","change","_","otherChange","oldRange","newRange","getChangedRanges","maps","stepMap","_ref53","newStart","newEnd","oldStart","invert","oldEnd","getMarksBetween","getSplittedAttributes","typeName","_ref54","isMarkActive","markRanges","_ref55","matchedRange","markRange","excludedRange","isList","isNodeEmpty","checkChildren","ignoreWhitespace","isLeaf","isContentEmpty","childNode","isNodeSelection","NodeSelection","posToDOMRect","resolvedEnd","coordsAtPos","top","bottom","left","right","width","height","x","y","ensureMarks","filteredMarks","joinListBackwards","listType","list","nodeAt","canJoin","joinListForwards","after","blur","_ref15","requestAnimationFrame","isDestroyed","getSelection","removeAllRanges","emitUpdate","_ref16","setContent","clearNodes","_ref17","_ref18","$mappedFrom","$mappedTo","blockRange","targetLiftDepth","liftTarget","defaultType","contentMatchAt","setNodeMarkup","lift","createParagraphNear","_ref19","createParagraphNear$1","cut","originRange","targetPos","_ref20","contentSlice","newPos","insert","setSelection","deleteCurrentNode","_ref21","currentNode","$anchor","delete","scrollIntoView","_ref22","_ref23","deleteSelection","_ref24","deleteSelection$1","enter","_ref25","keyboardShortcut","exitCode","_ref26","exitCode$1","_ref27","newSelection","_ref28","delayedFocus","focus","hasFocus","isSameSelection","eq","setStoredMarks","insertContent","_ref29","insertContentAt","_ref30","updateSelection","applyInputRules","applyPasteRules","preserveWhitespace","enableContentCheck","disableCollaboration","collaboration","isDisabled","isOnlyTextContent","isOnlyBlockContent","newContent","v","startLen","bias","last","ReplaceStep","ReplaceAroundStep","_from","_to","_newFrom","newTo","near","selectionToInsertionEnd","joinBackward","_ref33","joinBackward$1","joinDown","_ref32","joinDown$1","joinForward","_ref34","joinForward$1","joinItemBackward","_ref35","point","joinPoint","_unused3","joinItemForward","_ref36","_unused4","joinTextblockBackward","_ref37","joinTextblockBackward$1","joinTextblockForward","_ref38","joinTextblockForward$1","joinUp","_ref31","joinUp$1","_ref39","parts","alt","ctrl","shift","meta","mod","normalizeKeyName","KeyboardEvent","altKey","ctrlKey","metaKey","shiftKey","bubbles","cancelable","capturedTransaction","captureTransaction","someProp","f","newStep","maybeStep","_ref40","lift$1","liftEmptyBlock","_ref41","liftEmptyBlock$1","_ref42","liftListItem$1","newlineInCode","_ref43","newlineInCode$1","resetAttributes","_ref44","markType","addMark","_ref45","selectAll","_ref46","AllSelection","selectNodeBackward","_ref47","selectNodeBackward$1","selectNodeForward","_ref48","selectNodeForward$1","selectParentNode","_ref49","selectParentNode$1","selectTextblockEnd","_ref50","selectTextblockEnd$1","selectTextblockStart","_ref51","selectTextblockStart$1","_ref52","_ref58","addStoredMark","trimmedFrom","trimmedTo","newMarkType","cursor","isInSet","_ref57","someNodeSupportsMark","inlineContent","allowsMarkType","_pos","isInline","parentAllowsMarkType","currentMarksAllowMarkType","otherMark","canSetMark","_ref59","_ref60","attributesToCopy","sameParent","_ref61","setBlockType","_ref62","updatedState","_ref63","_ref64","_ref65","sinkListItem$1","keepMarks","_ref66","canSplit","deflt","edgeCount","edge","hasRequiredAttrs","defaultBlockAt","indexAfter","first","$first","canReplaceWith","overrideAttrs","_ref67","grandParent","wrap","depthBefore","d","copy","depthAfter","newNextTypeAttributes","nextType","contentMatch","createAndFill","replace","Slice","sel","n","newTypeAttributes","listTypeOrName","itemTypeOrName","_ref68","itemType","parentList","liftListItem","validContent","canWrapInList","wrapInList","_ref69","extendEmptyMarkRange","unsetMark","setMark","toggleTypeOrName","_ref70","toggleType","isActive","setNode","_ref71","wrapIn","undoInputRule","_ref72","undoable","getState","toUndo","j","docs","unsetAllMarks","_ref73","_ref74","_ref75","lastPos","lastNode","trimmedFrom2","trimmedTo2","_ref76","wrapIn$1","_ref77","wrapInList$1","Commands","Drop","handleDrop","moved","Editable","editable","FocusEvents","isFocused","Keymap","handleBackspace","_ref78","_ref79","$parentPos","parentIsIsolating","parentPos","isAtStart","handleDelete","_ref80","baseKeymap","Enter","handleEnter","_ref81","splitBlock","Mod-Enter","Backspace","Delete","Mod-a","pcKeymap","macKeymap","Ctrl-a","Ctrl-e","newState","docChanges","ignoreTr","allFrom","allEnd","Paste","handlePaste","Tabindex","isEditable","tabindex","NodePos","actualDepth","resolvedPos","element","domAtPos","isNonTextAtom","childNodePos","firstChild","lastChild","closest","selector","nodeAttributes","attrKeys","querySelector","querySelectorAll","firstItemOnly","childPos","setAttribute","Editor","super","isInitialized","injectCSS","injectNonce","autofocus","editorProps","coreExtensionOptions","enableCoreExtensions","onContentError","_ref82","onPaste","onDrop","isCapturingTransaction","setOptions","createExtensionManager","createCommandManager","createSchema","createView","_ref83","_ref84","commandManager","css","nonce","suffix","tiptapStyleTag","styleNode","getElementsByTagName","createStyleTag","setProps","updateState","setEditable","registerPlugin","handlePlugins","unregisterPlugin","nameOrPluginKeyToRemove","prevPlugins","nameOrPluginKey","startsWith","allExtensions","ext","message","EditorView","role","dispatchTransaction","EditorState","createNodeViews","prependClass","className","selectionHasChanged","nextState","nameOrAttributes","attributesOrUndefined","getJSON","getHTML","isEmpty","getCharacterCount","docView","$node","$doc","$nodes","markInputRule","_ref85","captureGroup","fullMatch","startSpaces","search","textStart","textEnd","excluded","markEnd","nodeInputRule","_ref86","newNode","matchStart","lastIndexOf","lastChar","insertionStart","textblockTypeInputRule","_ref87","$start","wrappingInputRule","_ref89","wrapping","findWrapping","keepAttributes","updateAttributes","joinPredicate","Node","markPasteRule","_ref91","escapeForRegEx","string"],"sourceRoot":""}