@blocknote/core 0.41.0 → 0.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/BlockNoteSchema-Bi-eeHal.js +3288 -0
  2. package/dist/BlockNoteSchema-Bi-eeHal.js.map +1 -0
  3. package/dist/BlockNoteSchema-DjDaA2C3.cjs +6 -0
  4. package/dist/BlockNoteSchema-DjDaA2C3.cjs.map +1 -0
  5. package/dist/blockToNode-DIfPWLH8.js +1140 -0
  6. package/dist/blockToNode-DIfPWLH8.js.map +1 -0
  7. package/dist/blockToNode-w7H99R6p.cjs +7 -0
  8. package/dist/blockToNode-w7H99R6p.cjs.map +1 -0
  9. package/dist/blocknote.cjs +4 -4
  10. package/dist/blocknote.cjs.map +1 -1
  11. package/dist/blocknote.js +1413 -1366
  12. package/dist/blocknote.js.map +1 -1
  13. package/dist/blocks.cjs +1 -1
  14. package/dist/blocks.js +1 -1
  15. package/dist/comments.cjs +1 -1
  16. package/dist/comments.cjs.map +1 -1
  17. package/dist/comments.js +49 -49
  18. package/dist/comments.js.map +1 -1
  19. package/dist/en-Cl87Uuyf.cjs.map +1 -1
  20. package/dist/en-njEqD7AG.js.map +1 -1
  21. package/dist/locales.cjs.map +1 -1
  22. package/dist/locales.js.map +1 -1
  23. package/dist/tsconfig.tsbuildinfo +1 -1
  24. package/dist/webpack-stats.json +1 -1
  25. package/dist/yjs.cjs +2 -0
  26. package/dist/yjs.cjs.map +1 -0
  27. package/dist/yjs.js +44 -0
  28. package/dist/yjs.js.map +1 -0
  29. package/package.json +30 -25
  30. package/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.ts +19 -6
  31. package/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.ts +173 -0
  32. package/src/api/nodeConversions/nodeToBlock.ts +17 -14
  33. package/src/blocks/Code/block.ts +1 -0
  34. package/src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts +2 -1
  35. package/src/blocks/defaultBlockTypeGuards.ts +7 -18
  36. package/src/comments/threadstore/yjs/YjsThreadStoreBase.ts +3 -1
  37. package/src/editor/BlockNoteEditor.test.ts +70 -1
  38. package/src/editor/BlockNoteEditor.ts +55 -4
  39. package/src/editor/managers/ExportManager.ts +1 -1
  40. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor-forked.json +2 -2
  41. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-editor.json +2 -2
  42. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap-forked.html +1 -1
  43. package/src/extensions/Collaboration/__snapshots__/fork-yjs-snap.html +1 -1
  44. package/src/extensions/Collaboration/schemaMigration/SchemaMigrationPlugin.ts +10 -3
  45. package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.ts +130 -0
  46. package/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.ts +34 -21
  47. package/src/extensions/Comments/CommentsPlugin.ts +37 -7
  48. package/src/extensions/KeyboardShortcuts/KeyboardShortcutsExtension.ts +30 -128
  49. package/src/extensions/SideMenu/SideMenuPlugin.ts +2 -0
  50. package/src/index.ts +1 -0
  51. package/src/schema/inlineContent/createSpec.ts +3 -0
  52. package/src/schema/inlineContent/types.ts +1 -0
  53. package/src/schema/schema.ts +49 -6
  54. package/src/schema/styles/createSpec.ts +6 -0
  55. package/src/schema/styles/types.ts +1 -0
  56. package/src/yjs/index.ts +1 -0
  57. package/src/yjs/utils.test.ts +1023 -0
  58. package/src/yjs/utils.ts +150 -0
  59. package/types/src/api/blockManipulation/commands/replaceBlocks/replaceBlocks.d.ts +1 -1
  60. package/types/src/api/blockManipulation/commands/replaceBlocks/util/fixColumnList.d.ts +32 -0
  61. package/types/src/api/nodeConversions/nodeToBlock.d.ts +1 -1
  62. package/types/src/editor/BlockNoteEditor.d.ts +6 -1
  63. package/types/src/editor/managers/ExportManager.d.ts +1 -1
  64. package/types/src/extensions/Collaboration/schemaMigration/migrationRules/moveColorAttributes.test.d.ts +1 -0
  65. package/types/src/extensions/Comments/CommentsPlugin.d.ts +1 -1
  66. package/types/src/index.d.ts +1 -0
  67. package/types/src/schema/inlineContent/createSpec.d.ts +1 -0
  68. package/types/src/schema/inlineContent/types.d.ts +1 -0
  69. package/types/src/schema/styles/createSpec.d.ts +1 -0
  70. package/types/src/schema/styles/types.d.ts +1 -0
  71. package/types/src/yjs/index.d.ts +1 -0
  72. package/types/src/yjs/utils.d.ts +55 -0
  73. package/types/src/yjs/utils.test.d.ts +1 -0
  74. package/dist/BlockNoteSchema-COA0fsXW.cjs +0 -11
  75. package/dist/BlockNoteSchema-COA0fsXW.cjs.map +0 -1
  76. package/dist/BlockNoteSchema-CYRHak18.js +0 -4375
  77. package/dist/BlockNoteSchema-CYRHak18.js.map +0 -1
  78. package/src/extensions/BackgroundColor/BackgroundColorMark.ts +0 -46
  79. package/src/extensions/TextColor/TextColorMark.ts +0 -38
  80. package/types/src/extensions/BackgroundColor/BackgroundColorMark.d.ts +0 -10
  81. package/types/src/extensions/TextColor/TextColorMark.d.ts +0 -10
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BlockNoteSchema-Bi-eeHal.js","sources":["../src/util/browser.ts","../src/blocks/defaultBlockHelpers.ts","../src/util/string.ts","../src/schema/blocks/internal.ts","../src/schema/blocks/createSpec.ts","../src/schema/inlineContent/internal.ts","../src/schema/styles/internal.ts","../src/schema/styles/createSpec.ts","../src/util/topo-sort.ts","../src/schema/schema.ts","../src/api/nodeUtil.ts","../src/api/blockManipulation/commands/updateBlock/updateBlock.ts","../src/editor/defaultColors.ts","../src/blocks/defaultProps.ts","../src/blocks/File/helpers/parse/parseFigureElement.ts","../src/blocks/File/helpers/render/createAddFileButton.ts","../src/blocks/File/helpers/render/createFileNameWithIcon.ts","../src/blocks/File/helpers/render/createFileBlockWrapper.ts","../src/blocks/File/helpers/toExternalHTML/createFigureWithCaption.ts","../src/blocks/File/helpers/toExternalHTML/createLinkWithCaption.ts","../src/blocks/Audio/parseAudioElement.ts","../src/blocks/Audio/block.ts","../src/util/EventEmitter.ts","../src/editor/BlockNoteExtension.ts","../src/blocks/Code/shiki.ts","../src/blocks/Code/block.ts","../src/blocks/Divider/block.ts","../src/blocks/File/helpers/parse/parseEmbedElement.ts","../src/blocks/File/block.ts","../src/blocks/ToggleWrapper/createToggleWrapper.ts","../src/blocks/Heading/block.ts","../src/blocks/File/helpers/render/createResizableFileBlockWrapper.ts","../src/blocks/Image/parseImageElement.ts","../src/blocks/Image/block.ts","../src/api/blockManipulation/commands/splitBlock/splitBlock.ts","../src/blocks/utils/listItemEnterHandler.ts","../src/blocks/ListItem/getListItemContent.ts","../src/blocks/ListItem/BulletListItem/block.ts","../src/blocks/ListItem/CheckListItem/block.ts","../src/blocks/ListItem/NumberedListItem/IndexingPlugin.ts","../src/blocks/ListItem/NumberedListItem/block.ts","../src/blocks/ListItem/ToggleListItem/block.ts","../src/blocks/PageBreak/block.ts","../src/blocks/Paragraph/block.ts","../src/blocks/Quote/block.ts","../src/blocks/Table/TableExtension.ts","../src/blocks/Table/block.ts","../src/blocks/Video/parseVideoElement.ts","../src/blocks/Video/block.ts","../src/blocks/File/helpers/uploadToTmpFilesDotOrg_DEV_ONLY.ts","../src/blocks/defaultBlockTypeGuards.ts","../src/extensions/SuggestionMenu/getDefaultSlashMenuItems.ts","../src/blocks/PageBreak/getPageBreakSlashMenuItems.ts","../src/blocks/defaultBlocks.ts","../src/blocks/BlockNoteSchema.ts"],"sourcesContent":["export const isAppleOS = () =>\n typeof navigator !== \"undefined\" &&\n (/Mac/.test(navigator.platform) ||\n (/AppleWebKit/.test(navigator.userAgent) &&\n /Mobile\\/\\w+/.test(navigator.userAgent)));\n\nexport function formatKeyboardShortcut(shortcut: string, ctrlText = \"Ctrl\") {\n if (isAppleOS()) {\n return shortcut.replace(\"Mod\", \"⌘\");\n } else {\n return shortcut.replace(\"Mod\", ctrlText);\n }\n}\n\nexport function mergeCSSClasses(...classes: (string | false | undefined)[]) {\n return [\n // Converts to & from set to remove duplicates.\n ...new Set(\n classes\n .filter((c) => c)\n // Ensures that if multiple classes are passed as a single string, they\n // are split.\n .join(\" \")\n .split(\" \"),\n ),\n ].join(\" \");\n}\n\nexport const isSafari = () =>\n /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n","import { blockToNode } from \"../api/nodeConversions/blockToNode.js\";\nimport type { BlockNoteEditor } from \"../editor/BlockNoteEditor.js\";\nimport type {\n BlockNoDefaults,\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n} from \"../schema/index.js\";\nimport { mergeCSSClasses } from \"../util/browser.js\";\n\n// Function that creates a ProseMirror `DOMOutputSpec` for a default block.\n// Since all default blocks have the same structure (`blockContent` div with a\n// `inlineContent` element inside), this function only needs the block's name\n// for the `data-content-type` attribute of the `blockContent` element and the\n// HTML tag of the `inlineContent` element, as well as any HTML attributes to\n// add to those.\nexport function createDefaultBlockDOMOutputSpec(\n blockName: string,\n htmlTag: string,\n blockContentHTMLAttributes: Record<string, string>,\n inlineContentHTMLAttributes: Record<string, string>,\n) {\n const blockContent = document.createElement(\"div\");\n blockContent.className = mergeCSSClasses(\n \"bn-block-content\",\n blockContentHTMLAttributes.class,\n );\n blockContent.setAttribute(\"data-content-type\", blockName);\n for (const [attribute, value] of Object.entries(blockContentHTMLAttributes)) {\n if (attribute !== \"class\") {\n blockContent.setAttribute(attribute, value);\n }\n }\n\n const inlineContent = document.createElement(htmlTag);\n inlineContent.className = mergeCSSClasses(\n \"bn-inline-content\",\n inlineContentHTMLAttributes.class,\n );\n for (const [attribute, value] of Object.entries(\n inlineContentHTMLAttributes,\n )) {\n if (attribute !== \"class\") {\n inlineContent.setAttribute(attribute, value);\n }\n }\n\n blockContent.appendChild(inlineContent);\n\n return {\n dom: blockContent,\n contentDOM: inlineContent,\n };\n}\n\n// Function used to convert default blocks to HTML. It uses the corresponding\n// node's `renderHTML` method to do the conversion by using a default\n// `DOMSerializer`.\nexport const defaultBlockToHTML = <\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n block: BlockNoDefaults<BSchema, I, S>,\n editor: BlockNoteEditor<BSchema, I, S>,\n): {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n} => {\n let node = blockToNode(block, editor.pmSchema);\n\n if (node.type.name === \"blockContainer\") {\n // for regular blocks, get the toDOM spec from the blockContent node\n node = node.firstChild!;\n }\n\n const toDOM = editor.pmSchema.nodes[node.type.name].spec.toDOM;\n\n if (toDOM === undefined) {\n throw new Error(\n \"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.\",\n );\n }\n\n const renderSpec = toDOM(node);\n\n if (typeof renderSpec !== \"object\" || !(\"dom\" in renderSpec)) {\n throw new Error(\n \"Cannot use this block's default HTML serialization as its corresponding TipTap node's `renderHTML` function does not return an object with the `dom` property.\",\n );\n }\n\n return renderSpec as {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n };\n};\n\n// Function that merges all paragraphs into a single one separated by line breaks.\n// This is used when parsing blocks like list items and table cells, as they may\n// contain multiple paragraphs that ProseMirror will not be able to handle\n// properly.\nexport function mergeParagraphs(element: HTMLElement, separator = \"<br>\") {\n const paragraphs = element.querySelectorAll(\"p\");\n if (paragraphs.length > 1) {\n const firstParagraph = paragraphs[0];\n for (let i = 1; i < paragraphs.length; i++) {\n const paragraph = paragraphs[i];\n firstParagraph.innerHTML += separator + paragraph.innerHTML;\n paragraph.remove();\n }\n }\n}\n","export function camelToDataKebab(str: string): string {\n return \"data-\" + str.replace(/([a-z])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\nexport function filenameFromURL(url: string): string {\n const parts = url.split(\"/\");\n if (\n !parts.length || // invalid?\n parts[parts.length - 1] === \"\" // for example, URL ends in a directory-like trailing slash\n ) {\n // in this case just return the original url\n return url;\n }\n return parts[parts.length - 1];\n}\n\nexport function isVideoUrl(url: string) {\n const videoExtensions = [\n \"mp4\",\n \"webm\",\n \"ogg\",\n \"mov\",\n \"mkv\",\n \"flv\",\n \"avi\",\n \"wmv\",\n \"m4v\",\n ];\n try {\n const pathname = new URL(url).pathname;\n const ext = pathname.split(\".\").pop()?.toLowerCase() || \"\";\n return videoExtensions.includes(ext);\n } catch (_) {\n return false;\n }\n}\n","import { Attribute, Attributes, Editor, Node } from \"@tiptap/core\";\nimport { defaultBlockToHTML } from \"../../blocks/defaultBlockHelpers.js\";\nimport type { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { BlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { mergeCSSClasses } from \"../../util/browser.js\";\nimport { camelToDataKebab } from \"../../util/string.js\";\nimport { InlineContentSchema } from \"../inlineContent/types.js\";\nimport { PropSchema, Props } from \"../propTypes.js\";\nimport { StyleSchema } from \"../styles/types.js\";\nimport {\n BlockConfig,\n BlockSchemaWithBlock,\n LooseBlockSpec,\n SpecificBlock,\n} from \"./types.js\";\n\n// Function that uses the 'propSchema' of a blockConfig to create a TipTap\n// node's `addAttributes` property.\n// TODO: extract function\nexport function propsToAttributes(propSchema: PropSchema): Attributes {\n const tiptapAttributes: Record<string, Attribute> = {};\n\n Object.entries(propSchema).forEach(([name, spec]) => {\n tiptapAttributes[name] = {\n default: spec.default,\n keepOnSplit: true,\n // Props are displayed in kebab-case as HTML attributes. If a prop's\n // value is the same as its default, we don't display an HTML\n // attribute for it.\n parseHTML: (element) => {\n const value = element.getAttribute(camelToDataKebab(name));\n\n if (value === null) {\n return null;\n }\n\n if (\n (spec.default === undefined && spec.type === \"boolean\") ||\n (spec.default !== undefined && typeof spec.default === \"boolean\")\n ) {\n if (value === \"true\") {\n return true;\n }\n\n if (value === \"false\") {\n return false;\n }\n\n return null;\n }\n\n if (\n (spec.default === undefined && spec.type === \"number\") ||\n (spec.default !== undefined && typeof spec.default === \"number\")\n ) {\n const asNumber = parseFloat(value);\n const isNumeric =\n !Number.isNaN(asNumber) && Number.isFinite(asNumber);\n\n if (isNumeric) {\n return asNumber;\n }\n\n return null;\n }\n\n return value;\n },\n renderHTML: (attributes) => {\n // don't render to html if the value is the same as the default\n return attributes[name] !== spec.default\n ? {\n [camelToDataKebab(name)]: attributes[name],\n }\n : {};\n },\n };\n });\n\n return tiptapAttributes;\n}\n\n// Used to figure out which block should be rendered. This block is then used to\n// create the node view.\nexport function getBlockFromPos<\n BType extends string,\n Config extends BlockConfig,\n BSchema extends BlockSchemaWithBlock<BType, Config>,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n getPos: () => number | undefined,\n editor: BlockNoteEditor<BSchema, I, S>,\n tipTapEditor: Editor,\n type: BType,\n) {\n const pos = getPos();\n // Gets position of the node\n if (pos === undefined) {\n throw new Error(\"Cannot find node position\");\n }\n // Gets parent blockContainer node\n const blockContainer = tipTapEditor.state.doc.resolve(pos!).node();\n // Gets block identifier\n const blockIdentifier = blockContainer.attrs.id;\n\n if (!blockIdentifier) {\n throw new Error(\"Block doesn't have id\");\n }\n\n // Gets the block\n const block = editor.getBlock(blockIdentifier)! as SpecificBlock<\n BSchema,\n BType,\n I,\n S\n >;\n if (block.type !== type) {\n throw new Error(\"Block type does not match\");\n }\n\n return block;\n}\n\n// Function that wraps the `dom` element returned from 'blockConfig.render' in a\n// `blockContent` div, which contains the block type and props as HTML\n// attributes. If `blockConfig.render` also returns a `contentDOM`, it also adds\n// an `inlineContent` class to it.\nexport function wrapInBlockStructure<\n BType extends string,\n PSchema extends PropSchema,\n>(\n element: {\n dom: HTMLElement | DocumentFragment;\n contentDOM?: HTMLElement;\n destroy?: () => void;\n },\n blockType: BType,\n blockProps: Partial<Props<PSchema>>,\n propSchema: PSchema,\n isFileBlock = false,\n domAttributes?: Record<string, string>,\n): {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n destroy?: () => void;\n} {\n // Creates `blockContent` element\n const blockContent = document.createElement(\"div\");\n\n // Adds custom HTML attributes\n if (domAttributes !== undefined) {\n for (const [attr, value] of Object.entries(domAttributes)) {\n if (attr !== \"class\") {\n blockContent.setAttribute(attr, value);\n }\n }\n }\n // Sets blockContent class\n blockContent.className = mergeCSSClasses(\n \"bn-block-content\",\n domAttributes?.class || \"\",\n );\n // Sets content type attribute\n blockContent.setAttribute(\"data-content-type\", blockType);\n // Adds props as HTML attributes in kebab-case with \"data-\" prefix. Skips props\n // which are already added as HTML attributes to the parent `blockContent`\n // element (inheritedProps) and props set to their default values.\n for (const [prop, value] of Object.entries(blockProps)) {\n const spec = propSchema[prop];\n const defaultValue = spec.default;\n if (value !== defaultValue) {\n blockContent.setAttribute(camelToDataKebab(prop), value);\n }\n }\n // Adds file block attribute\n if (isFileBlock) {\n blockContent.setAttribute(\"data-file-block\", \"\");\n }\n\n blockContent.appendChild(element.dom);\n\n if (element.contentDOM) {\n element.contentDOM.className = mergeCSSClasses(\n \"bn-inline-content\",\n element.contentDOM.className,\n );\n }\n\n return {\n ...element,\n dom: blockContent,\n };\n}\n\nexport function createBlockSpecFromTiptapNode<\n const T extends {\n node: Node;\n type: string;\n content: \"inline\" | \"table\" | \"none\";\n },\n P extends PropSchema,\n>(\n config: T,\n propSchema: P,\n extensions?: BlockNoteExtension<any>[],\n): LooseBlockSpec<T[\"type\"], P, T[\"content\"]> {\n return {\n config: {\n type: config.type as T[\"type\"],\n content: config.content,\n propSchema,\n },\n implementation: {\n node: config.node,\n render: defaultBlockToHTML,\n toExternalHTML: defaultBlockToHTML,\n },\n extensions,\n };\n}\n","import { Editor, Node } from \"@tiptap/core\";\nimport { DOMParser, Fragment, TagParseRule } from \"@tiptap/pm/model\";\nimport { NodeView } from \"@tiptap/pm/view\";\nimport { mergeParagraphs } from \"../../blocks/defaultBlockHelpers.js\";\nimport { BlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { PropSchema } from \"../propTypes.js\";\nimport {\n getBlockFromPos,\n propsToAttributes,\n wrapInBlockStructure,\n} from \"./internal.js\";\nimport {\n BlockConfig,\n BlockImplementation,\n BlockSpec,\n LooseBlockSpec,\n} from \"./types.js\";\n\n// Function that causes events within non-selectable blocks to be handled by the\n// browser instead of the editor.\nexport function applyNonSelectableBlockFix(nodeView: NodeView, editor: Editor) {\n nodeView.stopEvent = (event) => {\n // Blurs the editor on mouse down as the block is non-selectable. This is\n // mainly done to prevent UI elements like the formatting toolbar from being\n // visible while content within a non-selectable block is selected.\n if (event.type === \"mousedown\") {\n setTimeout(() => {\n editor.view.dom.blur();\n }, 10);\n }\n\n return true;\n };\n}\n\n// Function that uses the 'parse' function of a blockConfig to create a\n// TipTap node's `parseHTML` property. This is only used for parsing content\n// from the clipboard.\nexport function getParseRules<\n TName extends string,\n TProps extends PropSchema,\n TContent extends \"inline\" | \"none\" | \"table\",\n>(\n config: BlockConfig<TName, TProps, TContent>,\n implementation: BlockImplementation<TName, TProps, TContent>,\n) {\n const rules: TagParseRule[] = [\n {\n tag: \"[data-content-type=\" + config.type + \"]\",\n contentElement: \".bn-inline-content\",\n },\n ];\n\n if (implementation.parse) {\n rules.push({\n tag: \"*\",\n getAttrs(node: string | HTMLElement) {\n if (typeof node === \"string\") {\n return false;\n }\n\n const props = implementation.parse?.(node);\n\n if (props === undefined) {\n return false;\n }\n\n return props;\n },\n getContent:\n config.content === \"inline\" || config.content === \"none\"\n ? (node, schema) => {\n if (implementation.parseContent) {\n return implementation.parseContent({\n el: node as HTMLElement,\n schema,\n });\n }\n\n if (config.content === \"inline\") {\n // Parse the inline content if it exists\n const element = node as HTMLElement;\n\n // Clone to avoid modifying the original\n const clone = element.cloneNode(true) as HTMLElement;\n\n // Merge multiple paragraphs into one with line breaks\n mergeParagraphs(\n clone,\n implementation.meta?.code ? \"\\n\" : \"<br>\",\n );\n\n // Parse the content directly as a paragraph to extract inline content\n const parser = DOMParser.fromSchema(schema);\n const parsed = parser.parse(clone, {\n topNode: schema.nodes.paragraph.create(),\n });\n\n return parsed.content;\n }\n return Fragment.empty;\n }\n : undefined,\n });\n }\n // getContent(node, schema) {\n // const block = blockConfig.parse?.(node as HTMLElement);\n //\n // if (block !== undefined && block.content !== undefined) {\n // return Fragment.from(\n // typeof block.content === \"string\"\n // ? schema.text(block.content)\n // : inlineContentToNodes(block.content, schema)\n // );\n // }\n //\n // return Fragment.empty;\n // },\n // });\n // }\n\n return rules;\n}\n\n// A function to create custom block for API consumers\n// we want to hide the tiptap node from API consumers and provide a simpler API surface instead\nexport function addNodeAndExtensionsToSpec<\n TName extends string,\n TProps extends PropSchema,\n TContent extends \"inline\" | \"none\" | \"table\",\n>(\n blockConfig: BlockConfig<TName, TProps, TContent>,\n blockImplementation: BlockImplementation<TName, TProps, TContent>,\n extensions?: BlockNoteExtension<any>[],\n priority?: number,\n): LooseBlockSpec<TName, TProps, TContent> {\n const node =\n ((blockImplementation as any).node as Node) ||\n Node.create({\n name: blockConfig.type,\n content: (blockConfig.content === \"inline\"\n ? \"inline*\"\n : blockConfig.content === \"none\"\n ? \"\"\n : blockConfig.content) as TContent extends \"inline\" ? \"inline*\" : \"\",\n group: \"blockContent\",\n selectable: blockImplementation.meta?.selectable ?? true,\n isolating: blockImplementation.meta?.isolating ?? true,\n code: blockImplementation.meta?.code ?? false,\n defining: blockImplementation.meta?.defining ?? true,\n priority,\n addAttributes() {\n return propsToAttributes(blockConfig.propSchema);\n },\n\n parseHTML() {\n return getParseRules(blockConfig, blockImplementation);\n },\n\n renderHTML({ HTMLAttributes }) {\n // renderHTML is used for copy/pasting content from the editor back into\n // the editor, so we need to make sure the `blockContent` element is\n // structured correctly as this is what's used for parsing blocks. We\n // just render a placeholder div inside as the `blockContent` element\n // already has all the information needed for proper parsing.\n const div = document.createElement(\"div\");\n return wrapInBlockStructure(\n {\n dom: div,\n contentDOM: blockConfig.content === \"inline\" ? div : undefined,\n },\n blockConfig.type,\n {},\n blockConfig.propSchema,\n blockImplementation.meta?.fileBlockAccept !== undefined,\n HTMLAttributes,\n );\n },\n\n addNodeView() {\n return (props) => {\n // Gets the BlockNote editor instance\n const editor = this.options.editor;\n // Gets the block\n const block = getBlockFromPos(\n props.getPos,\n editor,\n this.editor,\n blockConfig.type,\n );\n // Gets the custom HTML attributes for `blockContent` nodes\n const blockContentDOMAttributes =\n this.options.domAttributes?.blockContent || {};\n\n const nodeView = blockImplementation.render.call(\n { blockContentDOMAttributes, props, renderType: \"nodeView\" },\n block as any,\n editor as any,\n );\n\n if (blockImplementation.meta?.selectable === false) {\n applyNonSelectableBlockFix(nodeView, this.editor);\n }\n\n // See explanation for why `update` is not implemented for NodeViews\n // https://github.com/TypeCellOS/BlockNote/pull/1904#discussion_r2313461464\n return nodeView;\n };\n },\n });\n\n if (node.name !== blockConfig.type) {\n throw new Error(\n \"Node name does not match block type. This is a bug in BlockNote.\",\n );\n }\n\n return {\n config: blockConfig,\n implementation: {\n ...blockImplementation,\n node,\n render(block, editor) {\n const blockContentDOMAttributes =\n node.options.domAttributes?.blockContent || {};\n\n return blockImplementation.render.call(\n {\n blockContentDOMAttributes,\n props: undefined,\n renderType: \"dom\",\n },\n block as any,\n editor as any,\n );\n },\n // TODO: this should not have wrapInBlockStructure and generally be a lot simpler\n // post-processing in externalHTMLExporter should not be necessary\n toExternalHTML: (block, editor) => {\n const blockContentDOMAttributes =\n node.options.domAttributes?.blockContent || {};\n\n return (\n blockImplementation.toExternalHTML?.call(\n { blockContentDOMAttributes },\n block as any,\n editor as any,\n ) ??\n blockImplementation.render.call(\n { blockContentDOMAttributes, renderType: \"dom\", props: undefined },\n block as any,\n editor as any,\n )\n );\n },\n },\n extensions,\n };\n}\n\n/**\n * Helper function to create a block config.\n */\nexport function createBlockConfig<\n TCallback extends (\n options: Partial<Record<string, any>>,\n ) => BlockConfig<any, any, any>,\n TOptions extends Parameters<TCallback>[0],\n TName extends ReturnType<TCallback>[\"type\"],\n TProps extends ReturnType<TCallback>[\"propSchema\"],\n TContent extends ReturnType<TCallback>[\"content\"],\n>(\n callback: TCallback,\n): TOptions extends undefined\n ? () => BlockConfig<TName, TProps, TContent>\n : (options: TOptions) => BlockConfig<TName, TProps, TContent> {\n return callback as any;\n}\n\n/**\n * Helper function to create a block definition.\n * Can accept either functions that return the required objects, or the objects directly.\n */\nexport function createBlockSpec<\n const TName extends string,\n const TProps extends PropSchema,\n const TContent extends \"inline\" | \"none\",\n const TOptions extends Partial<Record<string, any>> | undefined = undefined,\n>(\n blockConfigOrCreator: BlockConfig<TName, TProps, TContent>,\n blockImplementationOrCreator:\n | BlockImplementation<TName, TProps, TContent>\n | (TOptions extends undefined\n ? () => BlockImplementation<TName, TProps, TContent>\n : (\n options: Partial<TOptions>,\n ) => BlockImplementation<TName, TProps, TContent>),\n extensionsOrCreator?:\n | BlockNoteExtension<any>[]\n | (TOptions extends undefined\n ? () => BlockNoteExtension<any>[]\n : (options: Partial<TOptions>) => BlockNoteExtension<any>[]),\n): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;\nexport function createBlockSpec<\n const TName extends string,\n const TProps extends PropSchema,\n const TContent extends \"inline\" | \"none\",\n const BlockConf extends BlockConfig<TName, TProps, TContent>,\n const TOptions extends Partial<Record<string, any>>,\n>(\n blockCreator: (options: Partial<TOptions>) => BlockConf,\n blockImplementationOrCreator:\n | BlockImplementation<\n BlockConf[\"type\"],\n BlockConf[\"propSchema\"],\n BlockConf[\"content\"]\n >\n | (TOptions extends undefined\n ? () => BlockImplementation<\n BlockConf[\"type\"],\n BlockConf[\"propSchema\"],\n BlockConf[\"content\"]\n >\n : (\n options: Partial<TOptions>,\n ) => BlockImplementation<\n BlockConf[\"type\"],\n BlockConf[\"propSchema\"],\n BlockConf[\"content\"]\n >),\n extensionsOrCreator?:\n | BlockNoteExtension<any>[]\n | (TOptions extends undefined\n ? () => BlockNoteExtension<any>[]\n : (options: Partial<TOptions>) => BlockNoteExtension<any>[]),\n): (\n options?: Partial<TOptions>,\n) => BlockSpec<\n BlockConf[\"type\"],\n BlockConf[\"propSchema\"],\n BlockConf[\"content\"]\n>;\nexport function createBlockSpec<\n const TName extends string,\n const TProps extends PropSchema,\n const TContent extends \"inline\" | \"none\",\n const TOptions extends Partial<Record<string, any>> | undefined = undefined,\n>(\n blockConfigOrCreator:\n | BlockConfig<TName, TProps, TContent>\n | (TOptions extends undefined\n ? () => BlockConfig<TName, TProps, TContent>\n : (options: Partial<TOptions>) => BlockConfig<TName, TProps, TContent>),\n blockImplementationOrCreator:\n | BlockImplementation<TName, TProps, TContent>\n | (TOptions extends undefined\n ? () => BlockImplementation<TName, TProps, TContent>\n : (\n options: Partial<TOptions>,\n ) => BlockImplementation<TName, TProps, TContent>),\n extensionsOrCreator?:\n | BlockNoteExtension<any>[]\n | (TOptions extends undefined\n ? () => BlockNoteExtension<any>[]\n : (options: Partial<TOptions>) => BlockNoteExtension<any>[]),\n): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent> {\n return (options = {} as TOptions) => {\n const blockConfig =\n typeof blockConfigOrCreator === \"function\"\n ? blockConfigOrCreator(options as any)\n : blockConfigOrCreator;\n\n const blockImplementation =\n typeof blockImplementationOrCreator === \"function\"\n ? blockImplementationOrCreator(options as any)\n : blockImplementationOrCreator;\n\n const extensions = extensionsOrCreator\n ? typeof extensionsOrCreator === \"function\"\n ? extensionsOrCreator(options as any)\n : extensionsOrCreator\n : undefined;\n\n return {\n config: blockConfig,\n implementation: {\n ...blockImplementation,\n // TODO: this should not have wrapInBlockStructure and generally be a lot simpler\n // post-processing in externalHTMLExporter should not be necessary\n toExternalHTML(block, editor) {\n const output = blockImplementation.toExternalHTML?.call(\n { blockContentDOMAttributes: this.blockContentDOMAttributes },\n block as any,\n editor as any,\n );\n\n if (output === undefined) {\n return undefined;\n }\n\n return wrapInBlockStructure(\n output,\n block.type,\n block.props,\n blockConfig.propSchema,\n blockImplementation.meta?.fileBlockAccept !== undefined,\n );\n },\n render(block, editor) {\n const output = blockImplementation.render.call(\n {\n blockContentDOMAttributes: this.blockContentDOMAttributes,\n renderType: this.renderType,\n props: this.props as any,\n },\n block as any,\n editor as any,\n );\n\n const nodeView = wrapInBlockStructure(\n output,\n block.type,\n block.props,\n blockConfig.propSchema,\n blockImplementation.meta?.fileBlockAccept !== undefined,\n this.blockContentDOMAttributes,\n ) satisfies NodeView;\n\n return nodeView;\n },\n },\n extensions: extensions,\n };\n };\n}\n","import { KeyboardShortcutCommand, Node } from \"@tiptap/core\";\n\nimport { camelToDataKebab } from \"../../util/string.js\";\nimport { PropSchema, Props } from \"../propTypes.js\";\nimport {\n CustomInlineContentConfig,\n InlineContentImplementation,\n InlineContentSchemaFromSpecs,\n InlineContentSpec,\n InlineContentSpecs,\n} from \"./types.js\";\n\n// Function that adds necessary classes and attributes to the `dom` element\n// returned from a custom inline content's 'render' function, to ensure no data\n// is lost on internal copy & paste.\nexport function addInlineContentAttributes<\n IType extends string,\n PSchema extends PropSchema,\n>(\n element: {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n },\n inlineContentType: IType,\n inlineContentProps: Props<PSchema>,\n propSchema: PSchema,\n): {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n} {\n // Sets content type attribute\n element.dom.setAttribute(\"data-inline-content-type\", inlineContentType);\n // Adds props as HTML attributes in kebab-case with \"data-\" prefix. Skips props\n // set to their default values.\n Object.entries(inlineContentProps)\n .filter(([prop, value]) => {\n const spec = propSchema[prop];\n return value !== spec.default;\n })\n .map(([prop, value]) => {\n return [camelToDataKebab(prop), value];\n })\n .forEach(([prop, value]) => element.dom.setAttribute(prop, value));\n\n if (element.contentDOM) {\n element.contentDOM.setAttribute(\"data-editable\", \"\");\n }\n\n return element;\n}\n\n// see https://github.com/TypeCellOS/BlockNote/pull/435\nexport function addInlineContentKeyboardShortcuts<\n T extends CustomInlineContentConfig,\n>(\n config: T,\n): {\n [p: string]: KeyboardShortcutCommand;\n} {\n return {\n Backspace: ({ editor }) => {\n const resolvedPos = editor.state.selection.$from;\n\n return (\n editor.state.selection.empty &&\n resolvedPos.node().type.name === config.type &&\n resolvedPos.parentOffset === 0\n );\n },\n };\n}\n\n// This helper function helps to instantiate a InlineContentSpec with a\n// config and implementation that conform to the type of Config\nexport function createInternalInlineContentSpec<\n const T extends CustomInlineContentConfig,\n>(\n config: T,\n implementation: InlineContentImplementation<NoInfer<T>>,\n): InlineContentSpec<T> {\n return {\n config,\n implementation,\n } as const;\n}\n\nexport function createInlineContentSpecFromTipTapNode<\n T extends Node,\n P extends PropSchema,\n>(\n node: T,\n propSchema: P,\n implementation: Omit<\n InlineContentImplementation<CustomInlineContentConfig>,\n \"node\"\n >,\n) {\n return createInternalInlineContentSpec(\n {\n type: node.name as T[\"name\"],\n propSchema,\n content: node.config.content === \"inline*\" ? \"styled\" : \"none\",\n },\n {\n ...implementation,\n node,\n },\n );\n}\n\nexport function getInlineContentSchemaFromSpecs<T extends InlineContentSpecs>(\n specs: T,\n) {\n return Object.fromEntries(\n Object.entries(specs).map(([key, value]) => [key, value.config]),\n ) as InlineContentSchemaFromSpecs<T>;\n}\n","import { Attributes, Mark } from \"@tiptap/core\";\nimport { DOMSerializer } from \"@tiptap/pm/model\";\nimport {\n StyleConfig,\n StyleImplementation,\n StylePropSchema,\n StyleSchemaFromSpecs,\n StyleSpec,\n StyleSpecs,\n} from \"./types.js\";\n\nexport function stylePropsToAttributes(\n propSchema: StylePropSchema,\n): Attributes {\n if (propSchema === \"boolean\") {\n return {};\n }\n return {\n stringValue: {\n default: undefined,\n keepOnSplit: true,\n parseHTML: (element) => element.getAttribute(\"data-value\"),\n renderHTML: (attributes) =>\n attributes.stringValue !== undefined\n ? {\n \"data-value\": attributes.stringValue,\n }\n : {},\n },\n };\n}\n\n// Function that adds necessary classes and attributes to the `dom` element\n// returned from a custom style's 'render' function, to ensure no data is lost\n// on internal copy & paste.\nexport function addStyleAttributes<\n SType extends string,\n PSchema extends StylePropSchema,\n>(\n element: {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n },\n styleType: SType,\n styleValue: PSchema extends \"boolean\" ? undefined : string,\n propSchema: PSchema,\n): {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n} {\n // Sets content type attribute\n element.dom.setAttribute(\"data-style-type\", styleType);\n // Adds style value as an HTML attribute in kebab-case with \"data-\" prefix, if\n // the style takes a string value.\n if (propSchema === \"string\") {\n element.dom.setAttribute(\"data-value\", styleValue as string);\n }\n\n if (element.contentDOM) {\n element.contentDOM.setAttribute(\"data-editable\", \"\");\n }\n\n return element;\n}\n\n// This helper function helps to instantiate a stylespec with a\n// config and implementation that conform to the type of Config\nexport function createInternalStyleSpec<T extends StyleConfig>(\n config: T,\n implementation: StyleImplementation<T>,\n) {\n return {\n config,\n implementation,\n } satisfies StyleSpec<T>;\n}\n\nexport function createStyleSpecFromTipTapMark<\n T extends Mark,\n P extends StylePropSchema,\n>(mark: T, propSchema: P) {\n return createInternalStyleSpec(\n {\n type: mark.name as T[\"name\"],\n propSchema,\n },\n {\n mark,\n render(value, editor) {\n const toDOM = editor.pmSchema.marks[mark.name].spec.toDOM;\n\n if (toDOM === undefined) {\n throw new Error(\n \"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.\",\n );\n }\n\n const markInstance = editor.pmSchema.mark(mark.name, {\n stringValue: value,\n });\n\n const renderSpec = DOMSerializer.renderSpec(\n document,\n toDOM(markInstance, true),\n );\n\n if (typeof renderSpec !== \"object\" || !(\"dom\" in renderSpec)) {\n throw new Error(\n \"Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.\",\n );\n }\n\n return renderSpec as {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n };\n },\n toExternalHTML(value, editor) {\n const toDOM = editor.pmSchema.marks[mark.name].spec.toDOM;\n\n if (toDOM === undefined) {\n throw new Error(\n \"This block has no default HTML serialization as its corresponding TipTap node doesn't implement `renderHTML`.\",\n );\n }\n\n const markInstance = editor.pmSchema.mark(mark.name, {\n stringValue: value,\n });\n\n const renderSpec = DOMSerializer.renderSpec(\n document,\n toDOM(markInstance, true),\n );\n\n if (typeof renderSpec !== \"object\" || !(\"dom\" in renderSpec)) {\n throw new Error(\n \"Cannot use this block's default HTML serialization as its corresponding TipTap mark's `renderHTML` function does not return an object with the `dom` property.\",\n );\n }\n\n return renderSpec as {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n };\n },\n },\n );\n}\n\nexport function getStyleSchemaFromSpecs<T extends StyleSpecs>(specs: T) {\n return Object.fromEntries(\n Object.entries(specs).map(([key, value]) => [key, value.config]),\n ) as StyleSchemaFromSpecs<T>;\n}\n","import { Mark } from \"@tiptap/core\";\n\nimport { ParseRule, TagParseRule } from \"@tiptap/pm/model\";\nimport {\n addStyleAttributes,\n createInternalStyleSpec,\n stylePropsToAttributes,\n} from \"./internal.js\";\nimport { StyleConfig, StyleSpec } from \"./types.js\";\n\nexport type CustomStyleImplementation<T extends StyleConfig> = {\n render: (value: T[\"propSchema\"] extends \"boolean\" ? undefined : string) => {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n };\n toExternalHTML?: (\n value: T[\"propSchema\"] extends \"boolean\" ? undefined : string,\n ) => {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n };\n parse?: (\n element: HTMLElement,\n ) => (T[\"propSchema\"] extends \"boolean\" ? true : string) | undefined;\n runsBefore?: string[];\n};\n\nexport function getStyleParseRules<T extends StyleConfig>(\n config: T,\n customParseFunction?: CustomStyleImplementation<T>[\"parse\"],\n): ParseRule[] {\n const rules: TagParseRule[] = [\n {\n tag: `[data-style-type=\"${config.type}\"]`,\n contentElement: (element) => {\n const htmlElement = element as HTMLElement;\n\n if (htmlElement.matches(\"[data-editable]\")) {\n return htmlElement;\n }\n\n return htmlElement.querySelector(\"[data-editable]\") || htmlElement;\n },\n },\n ];\n\n if (customParseFunction) {\n rules.push({\n tag: \"*\",\n // By default, styles can overlap each other, so the rules should not\n // completely consume the element they parse (which can have multiple\n // styles).\n consuming: false,\n getAttrs(node: string | HTMLElement) {\n if (typeof node === \"string\") {\n return false;\n }\n\n const stringValue = customParseFunction?.(node);\n\n if (stringValue === undefined) {\n return false;\n }\n\n return { stringValue };\n },\n });\n }\n return rules;\n}\n\nexport function createStyleSpec<const T extends StyleConfig>(\n styleConfig: T,\n styleImplementation: CustomStyleImplementation<T>,\n): StyleSpec<T> {\n const mark = Mark.create({\n name: styleConfig.type,\n\n addAttributes() {\n return stylePropsToAttributes(styleConfig.propSchema);\n },\n\n parseHTML() {\n return getStyleParseRules(styleConfig, styleImplementation.parse);\n },\n\n renderHTML({ mark }) {\n const renderResult = (\n styleImplementation.toExternalHTML || styleImplementation.render\n )(mark.attrs.stringValue);\n\n return addStyleAttributes(\n renderResult,\n styleConfig.type,\n mark.attrs.stringValue,\n styleConfig.propSchema,\n );\n },\n\n addMarkView() {\n return ({ mark }) => {\n const renderResult = styleImplementation.render(mark.attrs.stringValue);\n\n return addStyleAttributes(\n renderResult,\n styleConfig.type,\n mark.attrs.stringValue,\n styleConfig.propSchema,\n );\n };\n },\n });\n\n return createInternalStyleSpec(styleConfig, {\n ...styleImplementation,\n mark,\n render: (value) => {\n const renderResult = styleImplementation.render(value as any);\n\n return addStyleAttributes(\n renderResult,\n styleConfig.type,\n value,\n styleConfig.propSchema,\n );\n },\n toExternalHTML: (value) => {\n const renderResult = (\n styleImplementation.toExternalHTML || styleImplementation.render\n )(value as any);\n\n return addStyleAttributes(\n renderResult,\n styleConfig.type,\n value,\n styleConfig.propSchema,\n );\n },\n });\n}\n","/**\n * Instead of depending on the NPM package, we vendor this file from https://github.com/n1ru4l/toposort/blob/main/src/toposort.ts (MIT)\n *\n * There was a recent publish, despite not having been updated in 2 years, which is suspicious.\n *\n * This file is also simple enough that we can maintain it ourselves.\n */\n\nexport type DirectedAcyclicGraph = Map<string, Iterable<string>>;\nexport type DependencyGraph = DirectedAcyclicGraph;\n\nexport type TaskList = Array<Set<string>>;\n\n// Add more specific types for better type safety\nexport type NodeId = string;\nexport type DependencyMap = Map<NodeId, Set<NodeId>>;\n\nexport function toposort(dag: DirectedAcyclicGraph): TaskList {\n const inDegrees = countInDegrees(dag);\n\n let { roots, nonRoots } = getRootsAndNonRoots(inDegrees);\n\n const sorted: TaskList = [];\n\n while (roots.size) {\n sorted.push(roots);\n\n const newRoots = new Set<NodeId>();\n for (const root of roots) {\n const dependents = dag.get(root);\n if (!dependents) {\n // Handle case where node has no dependents\n continue;\n }\n\n for (const dependent of dependents) {\n const currentDegree = inDegrees.get(dependent);\n if (currentDegree === undefined) {\n // Handle case where dependent node is not in inDegrees\n continue;\n }\n\n const newDegree = currentDegree - 1;\n inDegrees.set(dependent, newDegree);\n\n if (newDegree === 0) {\n newRoots.add(dependent);\n }\n }\n }\n\n roots = newRoots;\n }\n nonRoots = getRootsAndNonRoots(inDegrees).nonRoots;\n\n if (nonRoots.size) {\n throw new Error(\n `Cycle(s) detected; toposort only works on acyclic graphs. Cyclic nodes: ${Array.from(nonRoots).join(\", \")}`,\n );\n }\n\n return sorted;\n}\n\nexport function toposortReverse(deps: DependencyGraph): TaskList {\n const dag = reverse(deps);\n return toposort(dag);\n}\n\ntype InDegrees = Map<NodeId, number>;\n\nfunction countInDegrees(dag: DirectedAcyclicGraph): InDegrees {\n const counts: InDegrees = new Map();\n\n for (const [vx, dependents] of dag.entries()) {\n // Initialize count for current node if not present\n if (!counts.has(vx)) {\n counts.set(vx, 0);\n }\n\n for (const dependent of dependents) {\n const currentCount = counts.get(dependent) ?? 0;\n counts.set(dependent, currentCount + 1);\n }\n }\n\n return counts;\n}\n\nfunction getRootsAndNonRoots(counts: InDegrees) {\n const roots = new Set<NodeId>();\n const nonRoots = new Set<NodeId>();\n\n for (const [id, deg] of counts.entries()) {\n if (deg === 0) {\n roots.add(id);\n } else {\n nonRoots.add(id);\n }\n }\n\n return { roots, nonRoots };\n}\n\nfunction reverse(deps: DirectedAcyclicGraph): DependencyGraph {\n const reversedDeps: DependencyMap = new Map();\n\n for (const [name, dependsOn] of deps.entries()) {\n // Ensure the source node exists in the reversed map\n if (!reversedDeps.has(name)) {\n reversedDeps.set(name, new Set());\n }\n\n for (const dependsOnName of dependsOn) {\n if (!reversedDeps.has(dependsOnName)) {\n reversedDeps.set(dependsOnName, new Set());\n }\n reversedDeps.get(dependsOnName)!.add(name);\n }\n }\n\n return reversedDeps;\n}\n\nexport function createDependencyGraph(): DependencyMap {\n return new Map();\n}\n\nexport function addDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): DependencyMap {\n if (!graph.has(from)) {\n graph.set(from, new Set());\n }\n graph.get(from)!.add(to);\n return graph;\n}\n\nexport function removeDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): boolean {\n const dependents = graph.get(from);\n if (!dependents) {\n return false;\n }\n return dependents.delete(to);\n}\n\nexport function hasDependency(\n graph: DependencyMap,\n from: NodeId,\n to: NodeId,\n): boolean {\n const dependents = graph.get(from);\n return dependents ? dependents.has(to) : false;\n}\n","import { BlockNoteEditor } from \"../editor/BlockNoteEditor.js\";\nimport { createDependencyGraph, toposortReverse } from \"../util/topo-sort.js\";\nimport {\n BlockNoDefaults,\n BlockSchema,\n BlockSpecs,\n InlineContentConfig,\n InlineContentSchema,\n InlineContentSpec,\n InlineContentSpecs,\n LooseBlockSpec,\n PartialBlockNoDefaults,\n StyleSchema,\n StyleSpecs,\n addNodeAndExtensionsToSpec,\n getInlineContentSchemaFromSpecs,\n getStyleSchemaFromSpecs,\n} from \"./index.js\";\n\nfunction removeUndefined<T extends Record<string, any> | undefined>(obj: T): T {\n if (!obj) {\n return obj;\n }\n return Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as T;\n}\n\nexport class CustomBlockNoteSchema<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n> {\n // Helper so that you can use typeof schema.BlockNoteEditor\n public readonly BlockNoteEditor: BlockNoteEditor<BSchema, ISchema, SSchema> =\n \"only for types\" as any;\n\n public readonly Block: BlockNoDefaults<BSchema, ISchema, SSchema> =\n \"only for types\" as any;\n\n public readonly PartialBlock: PartialBlockNoDefaults<\n BSchema,\n ISchema,\n SSchema\n > = \"only for types\" as any;\n\n public inlineContentSpecs: InlineContentSpecs;\n public styleSpecs: StyleSpecs;\n public blockSpecs: {\n [K in keyof BSchema]: K extends string\n ? LooseBlockSpec<K, BSchema[K][\"propSchema\"], BSchema[K][\"content\"]>\n : never;\n };\n\n public blockSchema: BSchema;\n public inlineContentSchema: ISchema;\n public styleSchema: SSchema;\n\n constructor(\n private opts: {\n blockSpecs: BlockSpecs;\n inlineContentSpecs: InlineContentSpecs;\n styleSpecs: StyleSpecs;\n },\n ) {\n const {\n blockSpecs,\n inlineContentSpecs,\n styleSpecs,\n blockSchema,\n inlineContentSchema,\n styleSchema,\n } = this.init();\n this.blockSpecs = blockSpecs;\n this.styleSpecs = styleSpecs;\n this.styleSchema = styleSchema;\n this.inlineContentSpecs = inlineContentSpecs;\n this.blockSchema = blockSchema;\n this.inlineContentSchema = inlineContentSchema;\n }\n\n private init() {\n const dag = createDependencyGraph();\n const defaultSet = new Set<string>();\n dag.set(\"default\", defaultSet);\n\n for (const [key, specDef] of Object.entries({\n ...this.opts.blockSpecs,\n ...this.opts.inlineContentSpecs,\n ...this.opts.styleSpecs,\n })) {\n if (specDef.implementation?.runsBefore) {\n dag.set(key, new Set(specDef.implementation.runsBefore));\n } else {\n defaultSet.add(key);\n }\n }\n const sortedSpecs = toposortReverse(dag);\n const defaultIndex = sortedSpecs.findIndex((set) => set.has(\"default\"));\n\n /**\n * The priority of a block is described relative to the \"default\" block (an arbitrary block which can be used as the reference)\n *\n * Since blocks are topologically sorted, we can see what their relative position is to the \"default\" block\n * Each layer away from the default block is 10 priority points (arbitrarily chosen)\n * The default block is fixed at 101 (1 point higher than any tiptap extension, giving priority to custom blocks than any defaults)\n *\n * This is a bit of a hack, but it's a simple way to ensure that custom blocks are always rendered with higher priority than default blocks\n * and that custom blocks are rendered in the order they are defined in the schema\n */\n const getPriority = (key: string) => {\n const index = sortedSpecs.findIndex((set) => set.has(key));\n // the default index should map to 101\n // one before the default index is 91\n // one after is 111\n return 91 + (index + defaultIndex) * 10;\n };\n\n const blockSpecs = Object.fromEntries(\n Object.entries(this.opts.blockSpecs).map(([key, blockSpec]) => {\n return [\n key,\n addNodeAndExtensionsToSpec(\n blockSpec.config,\n blockSpec.implementation,\n blockSpec.extensions,\n getPriority(key),\n ),\n ];\n }),\n ) as {\n [K in keyof BSchema]: K extends string\n ? LooseBlockSpec<K, BSchema[K][\"propSchema\"], BSchema[K][\"content\"]>\n : never;\n };\n\n const inlineContentSpecs = Object.fromEntries(\n Object.entries(this.opts.inlineContentSpecs).map(\n ([key, inlineContentSpec]) => {\n // Case for text and links.\n if (typeof inlineContentSpec.config !== \"object\") {\n return [key, inlineContentSpec];\n }\n\n return [\n key,\n {\n ...inlineContentSpec,\n implementation: {\n ...inlineContentSpec.implementation,\n node: inlineContentSpec.implementation?.node.extend({\n priority: getPriority(key),\n }),\n },\n },\n ];\n },\n ),\n ) as InlineContentSpecs;\n\n const styleSpecs = Object.fromEntries(\n Object.entries(this.opts.styleSpecs).map(([key, styleSpec]) => [\n key,\n {\n ...styleSpec,\n implementation: {\n ...styleSpec.implementation,\n mark: styleSpec.implementation?.mark.extend({\n priority: getPriority(key),\n }),\n },\n },\n ]),\n ) as StyleSpecs;\n\n return {\n blockSpecs,\n blockSchema: Object.fromEntries(\n Object.entries(blockSpecs).map(([key, blockDef]) => {\n return [key, blockDef.config];\n }),\n ) as any,\n inlineContentSpecs: removeUndefined(inlineContentSpecs),\n styleSpecs: removeUndefined(styleSpecs),\n inlineContentSchema: getInlineContentSchemaFromSpecs(\n inlineContentSpecs,\n ) as any,\n styleSchema: getStyleSchemaFromSpecs(styleSpecs) as any,\n };\n }\n\n /**\n * Adds additional block specs to the current schema in a builder pattern.\n * This method allows extending the schema after it has been created.\n *\n * @param additionalBlockSpecs - Additional block specs to add to the schema\n * @returns The current schema instance for chaining\n */\n public extend<\n AdditionalBlockSpecs extends BlockSpecs = Record<string, never>,\n AdditionalInlineContentSpecs extends Record<\n string,\n InlineContentSpec<InlineContentConfig>\n > = Record<string, never>,\n AdditionalStyleSpecs extends StyleSpecs = Record<string, never>,\n >(opts: {\n blockSpecs?: AdditionalBlockSpecs;\n inlineContentSpecs?: AdditionalInlineContentSpecs;\n styleSpecs?: AdditionalStyleSpecs;\n }): CustomBlockNoteSchema<\n AdditionalBlockSpecs extends undefined | Record<string, never>\n ? BSchema\n : BSchema & {\n [K in keyof AdditionalBlockSpecs]: K extends string\n ? AdditionalBlockSpecs[K][\"config\"]\n : never;\n },\n AdditionalInlineContentSpecs extends undefined | Record<string, never>\n ? ISchema\n : ISchema & {\n [K in keyof AdditionalInlineContentSpecs]: AdditionalInlineContentSpecs[K][\"config\"];\n },\n AdditionalStyleSpecs extends undefined | Record<string, never>\n ? SSchema\n : SSchema & {\n [K in keyof AdditionalStyleSpecs]: AdditionalStyleSpecs[K][\"config\"];\n }\n > {\n // Merge the new specs with existing ones\n Object.assign(this.opts.blockSpecs, opts.blockSpecs);\n Object.assign(this.opts.inlineContentSpecs, opts.inlineContentSpecs);\n Object.assign(this.opts.styleSpecs, opts.styleSpecs);\n\n // Reinitialize the block specs with the merged specs\n const {\n blockSpecs,\n inlineContentSpecs,\n styleSpecs,\n blockSchema,\n inlineContentSchema,\n styleSchema,\n } = this.init();\n this.blockSpecs = blockSpecs;\n this.styleSpecs = styleSpecs;\n this.styleSchema = styleSchema;\n this.inlineContentSpecs = inlineContentSpecs;\n this.blockSchema = blockSchema;\n this.inlineContentSchema = inlineContentSchema;\n\n return this as any;\n }\n}\n","import type { Node } from \"prosemirror-model\";\n\n/**\n * Get a TipTap node by id\n */\nexport function getNodeById(\n id: string,\n doc: Node,\n): { node: Node; posBeforeNode: number } | undefined {\n let targetNode: Node | undefined = undefined;\n let posBeforeNode: number | undefined = undefined;\n\n doc.firstChild!.descendants((node, pos) => {\n // Skips traversing nodes after node with target ID has been found.\n if (targetNode) {\n return false;\n }\n\n // Keeps traversing nodes if block with target ID has not been found.\n if (!isNodeBlock(node) || node.attrs.id !== id) {\n return true;\n }\n\n targetNode = node;\n posBeforeNode = pos + 1;\n\n return false;\n });\n\n if (targetNode === undefined || posBeforeNode === undefined) {\n return undefined;\n }\n\n return {\n node: targetNode,\n posBeforeNode: posBeforeNode,\n };\n}\n\nexport function isNodeBlock(node: Node): boolean {\n return node.type.isInGroup(\"bnBlock\");\n}\n","import {\n Fragment,\n type NodeType,\n type Node as PMNode,\n Slice,\n} from \"prosemirror-model\";\nimport { TextSelection, Transaction } from \"prosemirror-state\";\nimport { TableMap } from \"prosemirror-tables\";\nimport { ReplaceStep, Transform } from \"prosemirror-transform\";\n\nimport type { Block, PartialBlock } from \"../../../../blocks/defaultBlocks.js\";\nimport type {\n BlockIdentifier,\n BlockSchema,\n} from \"../../../../schema/blocks/types.js\";\nimport type { InlineContentSchema } from \"../../../../schema/inlineContent/types.js\";\nimport type { StyleSchema } from \"../../../../schema/styles/types.js\";\nimport { UnreachableCaseError } from \"../../../../util/typescript.js\";\nimport {\n type BlockInfo,\n getBlockInfoFromResolvedPos,\n} from \"../../../getBlockInfoFromPos.js\";\nimport {\n blockToNode,\n inlineContentToNodes,\n tableContentToNodes,\n} from \"../../../nodeConversions/blockToNode.js\";\nimport { nodeToBlock } from \"../../../nodeConversions/nodeToBlock.js\";\nimport { getNodeById } from \"../../../nodeUtil.js\";\nimport { getPmSchema } from \"../../../pmUtil.js\";\n\n// for compatibility with tiptap. TODO: remove as we want to remove dependency on tiptap command interface\nexport const updateBlockCommand = <\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n posBeforeBlock: number,\n block: PartialBlock<BSchema, I, S>,\n) => {\n return ({\n tr,\n dispatch,\n }: {\n tr: Transaction;\n dispatch?: () => void;\n }): boolean => {\n if (dispatch) {\n updateBlockTr(tr, posBeforeBlock, block);\n }\n return true;\n };\n};\n\nexport function updateBlockTr<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n tr: Transform | Transaction,\n posBeforeBlock: number,\n block: PartialBlock<BSchema, I, S>,\n replaceFromPos?: number,\n replaceToPos?: number,\n) {\n const blockInfo = getBlockInfoFromResolvedPos(tr.doc.resolve(posBeforeBlock));\n\n let cellAnchor: CellAnchor | null = null;\n if (blockInfo.blockNoteType === \"table\") {\n cellAnchor = captureCellAnchor(tr);\n }\n\n const pmSchema = getPmSchema(tr);\n\n if (\n replaceFromPos !== undefined &&\n replaceToPos !== undefined &&\n replaceFromPos > replaceToPos\n ) {\n throw new Error(\"Invalid replaceFromPos or replaceToPos\");\n }\n\n // Adds blockGroup node with child blocks if necessary.\n\n const oldNodeType = pmSchema.nodes[blockInfo.blockNoteType];\n const newNodeType = pmSchema.nodes[block.type || blockInfo.blockNoteType];\n const newBnBlockNodeType = newNodeType.isInGroup(\"bnBlock\")\n ? newNodeType\n : pmSchema.nodes[\"blockContainer\"];\n\n if (blockInfo.isBlockContainer && newNodeType.isInGroup(\"blockContent\")) {\n const replaceFromOffset =\n replaceFromPos !== undefined &&\n replaceFromPos > blockInfo.blockContent.beforePos &&\n replaceFromPos < blockInfo.blockContent.afterPos\n ? replaceFromPos - blockInfo.blockContent.beforePos - 1\n : undefined;\n\n const replaceToOffset =\n replaceToPos !== undefined &&\n replaceToPos > blockInfo.blockContent.beforePos &&\n replaceToPos < blockInfo.blockContent.afterPos\n ? replaceToPos - blockInfo.blockContent.beforePos - 1\n : undefined;\n\n updateChildren(block, tr, blockInfo);\n // The code below determines the new content of the block.\n // or \"keep\" to keep as-is\n updateBlockContentNode(\n block,\n tr,\n oldNodeType,\n newNodeType,\n blockInfo,\n replaceFromOffset,\n replaceToOffset,\n );\n } else if (!blockInfo.isBlockContainer && newNodeType.isInGroup(\"bnBlock\")) {\n updateChildren(block, tr, blockInfo);\n // old node was a bnBlock type (like column or columnList) and new block as well\n // No op, we just update the bnBlock below (at end of function) and have already updated the children\n } else {\n // switching from blockContainer to non-blockContainer or v.v.\n // currently breaking for column slash menu items converting empty block\n // to column.\n\n // currently, we calculate the new node and replace the entire node with the desired new node.\n // for this, we do a nodeToBlock on the existing block to get the children.\n // it would be cleaner to use a ReplaceAroundStep, but this is a bit simpler and it's quite an edge case\n const existingBlock = nodeToBlock(blockInfo.bnBlock.node, pmSchema);\n tr.replaceWith(\n blockInfo.bnBlock.beforePos,\n blockInfo.bnBlock.afterPos,\n blockToNode(\n {\n children: existingBlock.children, // if no children are passed in, use existing children\n ...block,\n },\n pmSchema,\n ),\n );\n\n return;\n }\n\n // Adds all provided props as attributes to the parent blockContainer node too, and also preserves existing\n // attributes.\n tr.setNodeMarkup(blockInfo.bnBlock.beforePos, newBnBlockNodeType, {\n ...blockInfo.bnBlock.node.attrs,\n ...block.props,\n });\n\n if (cellAnchor) {\n restoreCellAnchor(tr, blockInfo, cellAnchor);\n }\n}\n\nfunction updateBlockContentNode<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n block: PartialBlock<BSchema, I, S>,\n tr: Transform,\n oldNodeType: NodeType,\n newNodeType: NodeType,\n blockInfo: {\n childContainer?:\n | { node: PMNode; beforePos: number; afterPos: number }\n | undefined;\n blockContent: { node: PMNode; beforePos: number; afterPos: number };\n },\n replaceFromOffset?: number,\n replaceToOffset?: number,\n) {\n const pmSchema = getPmSchema(tr);\n let content: PMNode[] | \"keep\" = \"keep\";\n\n // Has there been any custom content provided?\n if (block.content) {\n if (typeof block.content === \"string\") {\n // Adds a single text node with no marks to the content.\n content = inlineContentToNodes(\n [block.content],\n pmSchema,\n newNodeType.name,\n );\n } else if (Array.isArray(block.content)) {\n // Adds a text node with the provided styles converted into marks to the content,\n // for each InlineContent object.\n content = inlineContentToNodes(block.content, pmSchema, newNodeType.name);\n } else if (block.content.type === \"tableContent\") {\n content = tableContentToNodes(block.content, pmSchema);\n } else {\n throw new UnreachableCaseError(block.content.type);\n }\n } else {\n // no custom content has been provided, use existing content IF possible\n // Since some block types contain inline content and others don't,\n // we either need to call setNodeMarkup to just update type &\n // attributes, or replaceWith to replace the whole blockContent.\n if (oldNodeType.spec.content === \"\") {\n // keep old content, because it's empty anyway and should be compatible with\n // any newContentType\n } else if (newNodeType.spec.content !== oldNodeType.spec.content) {\n // the content type changed, replace the previous content\n content = [];\n } else {\n // keep old content, because the content type is the same and should be compatible\n }\n }\n\n // Now, changes the blockContent node type and adds the provided props\n // as attributes. Also preserves all existing attributes that are\n // compatible with the new type.\n //\n // Use either setNodeMarkup or replaceWith depending on whether the\n // content is being replaced or not.\n if (content === \"keep\") {\n // use setNodeMarkup to only update the type and attributes\n tr.setNodeMarkup(blockInfo.blockContent.beforePos, newNodeType, {\n ...blockInfo.blockContent.node.attrs,\n ...block.props,\n });\n } else if (replaceFromOffset !== undefined || replaceToOffset !== undefined) {\n // first update markup of the containing node\n tr.setNodeMarkup(blockInfo.blockContent.beforePos, newNodeType, {\n ...blockInfo.blockContent.node.attrs,\n ...block.props,\n });\n\n const start =\n blockInfo.blockContent.beforePos + 1 + (replaceFromOffset ?? 0);\n const end =\n blockInfo.blockContent.beforePos +\n 1 +\n (replaceToOffset ?? blockInfo.blockContent.node.content.size);\n\n // for content like table cells (where the blockcontent has nested PM nodes),\n // we need to figure out the correct openStart and openEnd for the slice when replacing\n\n const contentDepth = tr.doc.resolve(blockInfo.blockContent.beforePos).depth;\n const startDepth = tr.doc.resolve(start).depth;\n const endDepth = tr.doc.resolve(end).depth;\n\n tr.replace(\n start,\n end,\n new Slice(\n Fragment.from(content),\n startDepth - contentDepth - 1,\n endDepth - contentDepth - 1,\n ),\n );\n } else {\n // use replaceWith to replace the content and the block itself\n // also reset the selection since replacing the block content\n // sets it to the next block.\n tr.replaceWith(\n blockInfo.blockContent.beforePos,\n blockInfo.blockContent.afterPos,\n newNodeType.createChecked(\n {\n ...blockInfo.blockContent.node.attrs,\n ...block.props,\n },\n content,\n ),\n );\n }\n}\n\nfunction updateChildren<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(block: PartialBlock<BSchema, I, S>, tr: Transform, blockInfo: BlockInfo) {\n const pmSchema = getPmSchema(tr);\n if (block.children !== undefined && block.children.length > 0) {\n const childNodes = block.children.map((child) => {\n return blockToNode(child, pmSchema);\n });\n\n // Checks if a blockGroup node already exists.\n if (blockInfo.childContainer) {\n // Replaces all child nodes in the existing blockGroup with the ones created earlier.\n\n // use a replacestep to avoid the fitting algorithm\n tr.step(\n new ReplaceStep(\n blockInfo.childContainer.beforePos + 1,\n blockInfo.childContainer.afterPos - 1,\n new Slice(Fragment.from(childNodes), 0, 0),\n ),\n );\n } else {\n if (!blockInfo.isBlockContainer) {\n throw new Error(\"impossible\");\n }\n // Inserts a new blockGroup containing the child nodes created earlier.\n tr.insert(\n blockInfo.blockContent.afterPos,\n pmSchema.nodes[\"blockGroup\"].createChecked({}, childNodes),\n );\n }\n }\n}\n\nexport function updateBlock<\n BSchema extends BlockSchema = any,\n I extends InlineContentSchema = any,\n S extends StyleSchema = any,\n>(\n tr: Transform,\n blockToUpdate: BlockIdentifier,\n update: PartialBlock<BSchema, I, S>,\n replaceFromPos?: number,\n replaceToPos?: number,\n): Block<BSchema, I, S> {\n const id =\n typeof blockToUpdate === \"string\" ? blockToUpdate : blockToUpdate.id;\n const posInfo = getNodeById(id, tr.doc);\n if (!posInfo) {\n throw new Error(`Block with ID ${id} not found`);\n }\n\n updateBlockTr(\n tr,\n posInfo.posBeforeNode,\n update,\n replaceFromPos,\n replaceToPos,\n );\n\n const blockContainerNode = tr.doc\n .resolve(posInfo.posBeforeNode + 1) // TODO: clean?\n .node();\n\n const pmSchema = getPmSchema(tr);\n return nodeToBlock(blockContainerNode, pmSchema);\n}\n\ntype CellAnchor = { row: number; col: number; offset: number };\n\n/**\n * Captures the cell anchor from the current selection.\n * @param tr - The transaction to capture the cell anchor from.\n *\n * @returns The cell anchor, or null if no cell is selected.\n */\nexport function captureCellAnchor(tr: Transform): CellAnchor | null {\n const sel = \"selection\" in tr ? tr.selection : null;\n if (!(sel instanceof TextSelection)) {\n return null;\n }\n\n const $head = tr.doc.resolve(sel.head);\n // Find enclosing cell and table\n let cellDepth = -1;\n let tableDepth = -1;\n for (let d = $head.depth; d >= 0; d--) {\n const name = $head.node(d).type.name;\n if (cellDepth < 0 && (name === \"tableCell\" || name === \"tableHeader\")) {\n cellDepth = d;\n }\n if (name === \"table\") {\n tableDepth = d;\n break;\n }\n }\n if (cellDepth < 0 || tableDepth < 0) {\n return null;\n }\n\n // Absolute positions (before the cell)\n const cellPos = $head.before(cellDepth);\n const tablePos = $head.before(tableDepth);\n const table = tr.doc.nodeAt(tablePos);\n if (!table || table.type.name !== \"table\") {\n return null;\n }\n\n // Visual grid position via TableMap (handles spans)\n const map = TableMap.get(table);\n const rel = cellPos - (tablePos + 1); // relative to inside table\n const idx = map.map.indexOf(rel);\n if (idx < 0) {\n return null;\n }\n\n const row = Math.floor(idx / map.width);\n const col = idx % map.width;\n\n // Caret offset relative to the start of paragraph text\n const paraPos = cellPos + 1; // pos BEFORE tableParagraph\n const textStart = paraPos + 1; // start of paragraph text\n const offset = Math.max(0, sel.head - textStart);\n\n return { row, col, offset };\n}\n\nfunction restoreCellAnchor(\n tr: Transform | Transaction,\n blockInfo: BlockInfo,\n a: CellAnchor,\n): boolean {\n if (blockInfo.blockNoteType !== \"table\") {\n return false;\n }\n\n // 1) Resolve the table node in the current document\n let tablePos = -1;\n\n if (blockInfo.isBlockContainer) {\n // Prefer the blockContent position when available (points directly at the PM table node)\n tablePos = tr.mapping.map(blockInfo.blockContent.beforePos);\n } else {\n // Fallback: scan within the mapped bnBlock range to find the inner table node\n const start = tr.mapping.map(blockInfo.bnBlock.beforePos);\n const end = start + (tr.doc.nodeAt(start)?.nodeSize || 0);\n tr.doc.nodesBetween(start, end, (node, pos) => {\n if (node.type.name === \"table\") {\n tablePos = pos;\n return false;\n }\n return true;\n });\n }\n\n const table = tablePos >= 0 ? tr.doc.nodeAt(tablePos) : null;\n if (!table || table.type.name !== \"table\") {\n return false;\n }\n\n // 2) Clamp row/col to the table’s current grid\n const map = TableMap.get(table);\n const row = Math.max(0, Math.min(a.row, map.height - 1));\n const col = Math.max(0, Math.min(a.col, map.width - 1));\n\n // 3) Compute the absolute position of the target cell (pos BEFORE the cell)\n const cellIndex = row * map.width + col;\n const relCellPos = map.map[cellIndex]; // relative to (tablePos + 1)\n if (relCellPos == null) {\n return false;\n }\n const cellPos = tablePos + 1 + relCellPos;\n\n // 4) Place the caret inside the cell, clamping the text offset\n const textPos = cellPos + 1;\n const textNode = tr.doc.nodeAt(textPos);\n const textStart = textPos + 1;\n const max = textNode ? textNode.content.size : 0;\n const head = textStart + Math.max(0, Math.min(a.offset, max));\n\n if (\"selection\" in tr) {\n tr.setSelection(TextSelection.create(tr.doc, head));\n }\n return true;\n}\n","export const COLORS_DEFAULT = {\n gray: {\n text: \"#9b9a97\",\n background: \"#ebeced\",\n },\n brown: {\n text: \"#64473a\",\n background: \"#e9e5e3\",\n },\n red: {\n text: \"#e03e3e\",\n background: \"#fbe4e4\",\n },\n orange: {\n text: \"#d9730d\",\n background: \"#f6e9d9\",\n },\n yellow: {\n text: \"#dfab01\",\n background: \"#fbf3db\",\n },\n green: {\n text: \"#4d6461\",\n background: \"#ddedea\",\n },\n blue: {\n text: \"#0b6e99\",\n background: \"#ddebf1\",\n },\n purple: {\n text: \"#6940a5\",\n background: \"#eae4f2\",\n },\n pink: {\n text: \"#ad1a72\",\n background: \"#f4dfeb\",\n },\n} as Record<string, { text: string; background: string }>;\n\nexport const COLORS_DARK_MODE_DEFAULT = {\n gray: {\n text: \"#bebdb8\",\n background: \"#9b9a97\",\n },\n brown: {\n text: \"#8e6552\",\n background: \"#64473a\",\n },\n red: {\n text: \"#ec4040\",\n background: \"#be3434\",\n },\n orange: {\n text: \"#e3790d\",\n background: \"#b7600a\",\n },\n yellow: {\n text: \"#dfab01\",\n background: \"#b58b00\",\n },\n green: {\n text: \"#6b8b87\",\n background: \"#4d6461\",\n },\n blue: {\n text: \"#0e87bc\",\n background: \"#0b6e99\",\n },\n purple: {\n text: \"#8552d7\",\n background: \"#6940a5\",\n },\n pink: {\n text: \"#da208f\",\n background: \"#ad1a72\",\n },\n} as Record<string, { text: string; background: string }>;\n","import { Attribute } from \"@tiptap/core\";\n\nimport { COLORS_DEFAULT } from \"../editor/defaultColors.js\";\nimport type { Props, PropSchema } from \"../schema/index.js\";\n\n// TODO: this system should probably be moved / refactored.\n// The dependency from schema on this file doesn't make sense\n\nexport const defaultProps = {\n backgroundColor: {\n default: \"default\" as const,\n },\n textColor: {\n default: \"default\" as const,\n },\n textAlignment: {\n default: \"left\" as const,\n values: [\"left\", \"center\", \"right\", \"justify\"] as const,\n },\n} satisfies PropSchema;\n\nexport type DefaultProps = Props<typeof defaultProps>;\n\nexport const parseDefaultProps = (element: HTMLElement) => {\n const props: Partial<DefaultProps> = {};\n\n // If the `data-` attribute is found, set the prop to the value, as this most\n // likely means the parsed element was exported by BlockNote originally.\n // Otherwise, just use whatever is found in the inline styles, if anything.\n if (element.hasAttribute(\"data-background-color\")) {\n props.backgroundColor = element.getAttribute(\"data-background-color\")!;\n } else if (element.style.backgroundColor) {\n props.backgroundColor = element.style.backgroundColor;\n }\n\n // If the `data-` attribute is found, set the prop to the value, as this most\n // likely means the parsed element was exported by BlockNote originally.\n // Otherwise, just use whatever is found in the inline styles, if anything.\n if (element.hasAttribute(\"data-text-color\")) {\n props.textColor = element.getAttribute(\"data-text-color\")!;\n } else if (element.style.color) {\n props.textColor = element.style.color;\n }\n\n props.textAlignment = defaultProps.textAlignment.values.includes(\n element.style.textAlign as DefaultProps[\"textAlignment\"],\n )\n ? (element.style.textAlign as DefaultProps[\"textAlignment\"])\n : undefined;\n\n return props;\n};\n\nexport const addDefaultPropsExternalHTML = (\n props: Partial<DefaultProps>,\n element: HTMLElement,\n) => {\n if (\n props.backgroundColor &&\n props.backgroundColor !== defaultProps.backgroundColor.default\n ) {\n // The color can be any string. If the string matches one of the default\n // theme color names, set the theme color. Otherwise, set the color as-is\n // (may be a CSS color name, hex value, RGB value, etc).\n element.style.backgroundColor =\n props.backgroundColor in COLORS_DEFAULT\n ? COLORS_DEFAULT[props.backgroundColor].background\n : props.backgroundColor;\n }\n\n if (props.textColor && props.textColor !== defaultProps.textColor.default) {\n // The color can be any string. If the string matches one of the default\n // theme color names, set the theme color. Otherwise, set the color as-is\n // (may be a CSS color name, hex value, RGB value, etc).\n element.style.color =\n props.textColor in COLORS_DEFAULT\n ? COLORS_DEFAULT[props.textColor].text\n : props.textColor;\n }\n\n if (\n props.textAlignment &&\n props.textAlignment !== defaultProps.textAlignment.default\n ) {\n element.style.textAlign = props.textAlignment;\n }\n};\n\nexport const getBackgroundColorAttribute = (\n attributeName = \"backgroundColor\",\n): Attribute => ({\n default: defaultProps.backgroundColor.default,\n parseHTML: (element) => {\n if (element.hasAttribute(\"data-background-color\")) {\n return element.getAttribute(\"data-background-color\")!;\n }\n\n if (element.style.backgroundColor) {\n return element.style.backgroundColor;\n }\n\n return defaultProps.backgroundColor.default;\n },\n renderHTML: (attributes) => {\n if (attributes[attributeName] === defaultProps.backgroundColor.default) {\n return {};\n }\n\n return {\n \"data-background-color\": attributes[attributeName],\n };\n },\n});\n\nexport const getTextColorAttribute = (\n attributeName = \"textColor\",\n): Attribute => ({\n default: defaultProps.textColor.default,\n parseHTML: (element) => {\n if (element.hasAttribute(\"data-text-color\")) {\n return element.getAttribute(\"data-text-color\")!;\n }\n\n if (element.style.color) {\n return element.style.color;\n }\n\n return defaultProps.textColor.default;\n },\n renderHTML: (attributes) => {\n if (attributes[attributeName] === defaultProps.textColor.default) {\n return {};\n }\n\n return {\n \"data-text-color\": attributes[attributeName],\n };\n },\n});\n\nexport const getTextAlignmentAttribute = (\n attributeName = \"textAlignment\",\n): Attribute => ({\n default: defaultProps.textAlignment.default,\n parseHTML: (element) => {\n if (element.hasAttribute(\"data-text-alignment\")) {\n return element.getAttribute(\"data-text-alignment\");\n }\n\n if (element.style.textAlign) {\n return element.style.textAlign;\n }\n\n return defaultProps.textAlignment.default;\n },\n renderHTML: (attributes) => {\n if (attributes[attributeName] === defaultProps.textAlignment.default) {\n return {};\n }\n\n return {\n \"data-text-alignment\": attributes[attributeName],\n };\n },\n});\n","export const parseFigureElement = (\n figureElement: HTMLElement,\n targetTag: string,\n) => {\n const targetElement = figureElement.querySelector(\n targetTag,\n ) as HTMLElement | null;\n if (!targetElement) {\n return undefined;\n }\n\n const captionElement = figureElement.querySelector(\"figcaption\");\n const caption = captionElement?.textContent ?? undefined;\n\n return { targetElement, caption };\n};\n","import type { BlockNoteEditor } from \"../../../../editor/BlockNoteEditor.js\";\nimport {\n BlockConfig,\n BlockFromConfigNoChildren,\n} from \"../../../../schema/index.js\";\n\nexport const createAddFileButton = (\n block: BlockFromConfigNoChildren<BlockConfig<string, any, \"none\">, any, any>,\n editor: BlockNoteEditor<any, any, any>,\n buttonIcon?: HTMLElement,\n) => {\n const addFileButton = document.createElement(\"div\");\n addFileButton.className = \"bn-add-file-button\";\n\n const addFileButtonIcon = document.createElement(\"div\");\n addFileButtonIcon.className = \"bn-add-file-button-icon\";\n if (buttonIcon) {\n addFileButtonIcon.appendChild(buttonIcon);\n } else {\n addFileButtonIcon.innerHTML =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>';\n }\n addFileButton.appendChild(addFileButtonIcon);\n\n const addFileButtonText = document.createElement(\"p\");\n addFileButtonText.className = \"bn-add-file-button-text\";\n addFileButtonText.innerHTML =\n block.type in editor.dictionary.file_blocks.add_button_text\n ? editor.dictionary.file_blocks.add_button_text[block.type]\n : editor.dictionary.file_blocks.add_button_text[\"file\"];\n addFileButton.appendChild(addFileButtonText);\n\n // Prevents focus from moving to the button.\n const addFileButtonMouseDownHandler = (event: MouseEvent) => {\n event.preventDefault();\n };\n // Opens the file toolbar.\n const addFileButtonClickHandler = () => {\n editor.transact((tr) =>\n tr.setMeta(editor.filePanel!.plugins[0], {\n block: block,\n }),\n );\n };\n addFileButton.addEventListener(\n \"mousedown\",\n addFileButtonMouseDownHandler,\n true,\n );\n addFileButton.addEventListener(\"click\", addFileButtonClickHandler, true);\n\n return {\n dom: addFileButton,\n destroy: () => {\n addFileButton.removeEventListener(\n \"mousedown\",\n addFileButtonMouseDownHandler,\n true,\n );\n addFileButton.removeEventListener(\n \"click\",\n addFileButtonClickHandler,\n true,\n );\n },\n };\n};\n","import {\n BlockConfig,\n BlockFromConfigNoChildren,\n} from \"../../../../schema/index.js\";\n\nexport const FILE_ICON_SVG = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z\"></path></svg>`;\n\nexport const createFileNameWithIcon = (\n block: BlockFromConfigNoChildren<\n BlockConfig<\n string,\n {\n name: { default: \"\" };\n },\n \"none\"\n >,\n any,\n any\n >,\n): { dom: HTMLElement; destroy?: () => void } => {\n const file = document.createElement(\"div\");\n file.className = \"bn-file-name-with-icon\";\n\n const icon = document.createElement(\"div\");\n icon.className = \"bn-file-icon\";\n icon.innerHTML = FILE_ICON_SVG;\n file.appendChild(icon);\n\n const fileName = document.createElement(\"p\");\n fileName.className = \"bn-file-name\";\n fileName.textContent = block.props.name;\n file.appendChild(fileName);\n\n return {\n dom: file,\n };\n};\n","import type { BlockNoteEditor } from \"../../../../editor/BlockNoteEditor.js\";\nimport {\n BlockConfig,\n BlockFromConfigNoChildren,\n} from \"../../../../schema/index.js\";\nimport { createAddFileButton } from \"./createAddFileButton.js\";\nimport { createFileNameWithIcon } from \"./createFileNameWithIcon.js\";\n\nexport const createFileBlockWrapper = (\n block: BlockFromConfigNoChildren<\n BlockConfig<\n string,\n {\n backgroundColor: { default: \"default\" };\n name: { default: \"\" };\n url: { default: \"\" };\n caption: { default: \"\" };\n showPreview?: { default: true };\n },\n \"none\"\n >,\n any,\n any\n >,\n editor: BlockNoteEditor<any, any, any>,\n element?: { dom: HTMLElement; destroy?: () => void },\n buttonIcon?: HTMLElement,\n) => {\n const wrapper = document.createElement(\"div\");\n wrapper.className = \"bn-file-block-content-wrapper\";\n\n // Show the add file button if the file has not been uploaded yet. Change to\n // show a loader if a file upload for the block begins.\n if (block.props.url === \"\") {\n const addFileButton = createAddFileButton(block, editor, buttonIcon);\n wrapper.appendChild(addFileButton.dom);\n\n const destroyUploadStartHandler = editor.onUploadStart((blockId) => {\n if (blockId === block.id) {\n wrapper.removeChild(addFileButton.dom);\n\n const loading = document.createElement(\"div\");\n loading.className = \"bn-file-loading-preview\";\n loading.textContent = \"Loading...\";\n wrapper.appendChild(loading);\n }\n });\n\n return {\n dom: wrapper,\n destroy: () => {\n destroyUploadStartHandler();\n addFileButton.destroy();\n },\n };\n }\n\n const ret: { dom: HTMLElement; destroy?: () => void } = { dom: wrapper };\n\n // Show the file preview, or the file name and icon.\n if (block.props.showPreview === false || !element) {\n // Show file name and icon.\n const fileNameWithIcon = createFileNameWithIcon(block);\n wrapper.appendChild(fileNameWithIcon.dom);\n\n ret.destroy = () => {\n fileNameWithIcon.destroy?.();\n };\n } else {\n // Show file preview.\n wrapper.appendChild(element.dom);\n }\n\n // Show the caption if there is one.\n if (block.props.caption) {\n const caption = document.createElement(\"p\");\n caption.className = \"bn-file-caption\";\n caption.textContent = block.props.caption;\n wrapper.appendChild(caption);\n }\n\n return ret;\n};\n","export const createFigureWithCaption = (\n element: HTMLElement,\n caption: string,\n) => {\n const figure = document.createElement(\"figure\");\n const captionElement = document.createElement(\"figcaption\");\n captionElement.textContent = caption;\n\n figure.appendChild(element);\n figure.appendChild(captionElement);\n\n return { dom: figure };\n};\n","export const createLinkWithCaption = (\n element: HTMLElement,\n caption: string,\n) => {\n const wrapper = document.createElement(\"div\");\n const fileCaption = document.createElement(\"p\");\n fileCaption.textContent = caption;\n\n wrapper.appendChild(element);\n wrapper.appendChild(fileCaption);\n\n return {\n dom: wrapper,\n };\n};\n","export const parseAudioElement = (audioElement: HTMLAudioElement) => {\n const url = audioElement.src || undefined;\n\n return { url };\n};\n","import { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport {\n BlockFromConfig,\n createBlockConfig,\n createBlockSpec,\n} from \"../../schema/index.js\";\nimport { defaultProps, parseDefaultProps } from \"../defaultProps.js\";\nimport { parseFigureElement } from \"../File/helpers/parse/parseFigureElement.js\";\nimport { createFileBlockWrapper } from \"../File/helpers/render/createFileBlockWrapper.js\";\nimport { createFigureWithCaption } from \"../File/helpers/toExternalHTML/createFigureWithCaption.js\";\nimport { createLinkWithCaption } from \"../File/helpers/toExternalHTML/createLinkWithCaption.js\";\nimport { parseAudioElement } from \"./parseAudioElement.js\";\n\nexport const FILE_AUDIO_ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z\"></path></svg>';\n\nexport interface AudioOptions {\n icon?: string;\n}\n\nexport type AudioBlockConfig = ReturnType<typeof createAudioBlockConfig>;\n\nexport const createAudioBlockConfig = createBlockConfig(\n (_ctx: AudioOptions) =>\n ({\n type: \"audio\" as const,\n propSchema: {\n backgroundColor: defaultProps.backgroundColor,\n // File name.\n name: {\n default: \"\" as const,\n },\n // File url.\n url: {\n default: \"\" as const,\n },\n // File caption.\n caption: {\n default: \"\" as const,\n },\n\n showPreview: {\n default: true,\n },\n },\n content: \"none\",\n }) as const,\n);\n\nexport const audioParse =\n (_config: AudioOptions = {}) =>\n (element: HTMLElement) => {\n if (element.tagName === \"AUDIO\") {\n // Ignore if parent figure has already been parsed.\n if (element.closest(\"figure\")) {\n return undefined;\n }\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseAudioElement(element as HTMLAudioElement),\n backgroundColor,\n };\n }\n\n if (element.tagName === \"FIGURE\") {\n const parsedFigure = parseFigureElement(element, \"audio\");\n if (!parsedFigure) {\n return undefined;\n }\n\n const { targetElement, caption } = parsedFigure;\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseAudioElement(targetElement as HTMLAudioElement),\n backgroundColor,\n caption,\n };\n }\n\n return undefined;\n };\n\nexport const audioRender =\n (config: AudioOptions = {}) =>\n (\n block: BlockFromConfig<ReturnType<typeof createAudioBlockConfig>, any, any>,\n editor: BlockNoteEditor<\n Record<\"audio\", ReturnType<typeof createAudioBlockConfig>>,\n any,\n any\n >,\n ) => {\n const icon = document.createElement(\"div\");\n icon.innerHTML = config.icon ?? FILE_AUDIO_ICON_SVG;\n\n const audio = document.createElement(\"audio\");\n audio.className = \"bn-audio\";\n if (editor.resolveFileUrl) {\n editor.resolveFileUrl(block.props.url).then((downloadUrl) => {\n audio.src = downloadUrl;\n });\n } else {\n audio.src = block.props.url;\n }\n audio.controls = true;\n audio.contentEditable = \"false\";\n audio.draggable = false;\n\n return createFileBlockWrapper(\n block,\n editor,\n { dom: audio },\n icon.firstElementChild as HTMLElement,\n );\n };\n\nexport const audioToExternalHTML =\n (_config: AudioOptions = {}) =>\n (\n block: BlockFromConfig<ReturnType<typeof createAudioBlockConfig>, any, any>,\n _editor: BlockNoteEditor<\n Record<\"audio\", ReturnType<typeof createAudioBlockConfig>>,\n any,\n any\n >,\n ) => {\n if (!block.props.url) {\n const div = document.createElement(\"p\");\n div.textContent = \"Add audio\";\n\n return {\n dom: div,\n };\n }\n\n let audio;\n if (block.props.showPreview) {\n audio = document.createElement(\"audio\");\n audio.src = block.props.url;\n } else {\n audio = document.createElement(\"a\");\n audio.href = block.props.url;\n audio.textContent = block.props.name || block.props.url;\n }\n\n if (block.props.caption) {\n if (block.props.showPreview) {\n return createFigureWithCaption(audio, block.props.caption);\n } else {\n return createLinkWithCaption(audio, block.props.caption);\n }\n }\n\n return {\n dom: audio,\n };\n };\n\nexport const createAudioBlockSpec = createBlockSpec(\n createAudioBlockConfig,\n (config) => ({\n meta: {\n fileBlockAccept: [\"audio/*\"],\n },\n parse: audioParse(config),\n render: audioRender(config),\n toExternalHTML: audioToExternalHTML(config),\n runsBefore: [\"file\"],\n }),\n);\n","// from https://raw.githubusercontent.com/ueberdosis/tiptap/develop/packages/core/src/EventEmitter.ts (MIT)\n\ntype StringKeyOf<T> = Extract<keyof T, string>;\ntype CallbackType<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = T[EventName] extends any[] ? T[EventName] : [T[EventName]];\ntype CallbackFunction<\n T extends Record<string, any>,\n EventName extends StringKeyOf<T>,\n> = (...props: CallbackType<T, EventName>) => any;\n\nexport class EventEmitter<T extends Record<string, any>> {\n // eslint-disable-next-line @typescript-eslint/ban-types\n private callbacks: { [key: string]: Function[] } = {};\n\n public on<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn: CallbackFunction<T, EventName>,\n ) {\n if (!this.callbacks[event]) {\n this.callbacks[event] = [];\n }\n\n this.callbacks[event].push(fn);\n\n return () => this.off(event, fn);\n }\n\n protected emit<EventName extends StringKeyOf<T>>(\n event: EventName,\n ...args: CallbackType<T, EventName>\n ) {\n const callbacks = this.callbacks[event];\n\n if (callbacks) {\n callbacks.forEach((callback) => callback.apply(this, args));\n }\n }\n\n public off<EventName extends StringKeyOf<T>>(\n event: EventName,\n fn?: CallbackFunction<T, EventName>,\n ) {\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\n protected removeAllListeners(): void {\n this.callbacks = {};\n }\n}\n","import { Plugin } from \"prosemirror-state\";\nimport { EventEmitter } from \"../util/EventEmitter.js\";\n\nimport { AnyExtension } from \"@tiptap/core\";\nimport {\n BlockSchema,\n InlineContentSchema,\n PartialBlockNoDefaults,\n StyleSchema,\n} from \"../schema/index.js\";\nimport { BlockNoteEditor } from \"./BlockNoteEditor.js\";\n\nexport abstract class BlockNoteExtension<\n TEvent extends Record<string, any> = any,\n> extends EventEmitter<TEvent> {\n public static key(): string {\n throw new Error(\"You must implement the key method in your extension\");\n }\n\n protected addProsemirrorPlugin(plugin: Plugin) {\n this.plugins.push(plugin);\n }\n\n public readonly plugins: Plugin[] = [];\n public get priority(): number | undefined {\n return undefined;\n }\n\n // eslint-disable-next-line\n constructor(..._args: any[]) {\n super();\n // Allow subclasses to have constructors with parameters\n // without this, we can't easily implement BlockNoteEditor.extension(MyExtension) pattern\n }\n\n /**\n * Input rules for the block\n */\n public inputRules?: InputRule[];\n\n /**\n * A mapping of a keyboard shortcut to a function that will be called when the shortcut is pressed\n *\n * The keys are in the format:\n * - Key names may be strings like `Shift-Ctrl-Enter`—a key identifier prefixed with zero or more modifiers\n * - Key identifiers are based on the strings that can appear in KeyEvent.key\n * - Use lowercase letters to refer to letter keys (or uppercase letters if you want shift to be held)\n * - You may use `Space` as an alias for the \" \" name\n * - Modifiers can be given in any order: `Shift-` (or `s-`), `Alt-` (or `a-`), `Ctrl-` (or `c-` or `Control-`) and `Cmd-` (or `m-` or `Meta-`)\n * - For characters that are created by holding shift, the Shift- prefix is implied, and should not be added explicitly\n * - You can use Mod- as a shorthand for Cmd- on Mac and Ctrl- on other platforms\n *\n * @example\n * ```typescript\n * keyboardShortcuts: {\n * \"Mod-Enter\": (ctx) => { return true; },\n * \"Shift-Ctrl-Space\": (ctx) => { return true; },\n * \"a\": (ctx) => { return true; },\n * \"Space\": (ctx) => { return true; }\n * }\n * ```\n */\n public keyboardShortcuts?: Record<\n string,\n (ctx: {\n editor: BlockNoteEditor<BlockSchema, InlineContentSchema, StyleSchema>;\n }) => boolean\n >;\n\n public tiptapExtensions?: AnyExtension[];\n}\n\nexport type InputRule = {\n /**\n * The regex to match when to trigger the input rule\n */\n find: RegExp;\n /**\n * The function to call when the input rule is matched\n * @returns undefined if the input rule should not be triggered, or an object with the type and props to update the block\n */\n replace: (props: {\n /**\n * The result of the regex match\n */\n match: RegExpMatchArray;\n // TODO this will be a Point, when we have the Location API\n /**\n * The range of the text that was matched\n */\n range: { from: number; to: number };\n /**\n * The editor instance\n */\n editor: BlockNoteEditor<any, any, any>;\n }) => undefined | PartialBlockNoDefaults<any, any, any>;\n};\n\n/**\n * This creates an instance of a BlockNoteExtension that can be used to add to a schema.\n * It is a bit of a hack, but it works.\n */\nexport function createBlockNoteExtension(\n options: Partial<\n Pick<\n BlockNoteExtension,\n \"inputRules\" | \"keyboardShortcuts\" | \"plugins\" | \"tiptapExtensions\"\n >\n > & { key: string },\n) {\n const x = Object.create(BlockNoteExtension.prototype);\n x.key = options.key;\n x.inputRules = options.inputRules;\n x.keyboardShortcuts = options.keyboardShortcuts;\n x.plugins = options.plugins ?? [];\n x.tiptapExtensions = options.tiptapExtensions;\n return x as BlockNoteExtension;\n}\n","import type { HighlighterGeneric } from \"@shikijs/types\";\nimport { Parser, createHighlightPlugin } from \"prosemirror-highlight\";\nimport { createParser } from \"prosemirror-highlight/shiki\";\nimport { CodeBlockOptions, getLanguageId } from \"./block.js\";\n\nexport const shikiParserSymbol = Symbol.for(\"blocknote.shikiParser\");\nexport const shikiHighlighterPromiseSymbol = Symbol.for(\n \"blocknote.shikiHighlighterPromise\",\n);\n\nexport function lazyShikiPlugin(options: CodeBlockOptions) {\n const globalThisForShiki = globalThis as {\n [shikiHighlighterPromiseSymbol]?: Promise<HighlighterGeneric<any, any>>;\n [shikiParserSymbol]?: Parser;\n };\n\n let highlighter: HighlighterGeneric<any, any> | undefined;\n let parser: Parser | undefined;\n let hasWarned = false;\n const lazyParser: Parser = (parserOptions) => {\n if (!options.createHighlighter) {\n if (process.env.NODE_ENV === \"development\" && !hasWarned) {\n // eslint-disable-next-line no-console\n console.log(\n \"For syntax highlighting of code blocks, you must provide a `createCodeBlockSpec({ createHighlighter: () => ... })` function\",\n );\n hasWarned = true;\n }\n return [];\n }\n if (!highlighter) {\n globalThisForShiki[shikiHighlighterPromiseSymbol] =\n globalThisForShiki[shikiHighlighterPromiseSymbol] ||\n options.createHighlighter();\n\n return globalThisForShiki[shikiHighlighterPromiseSymbol].then(\n (createdHighlighter) => {\n highlighter = createdHighlighter;\n },\n );\n }\n const language = getLanguageId(options, parserOptions.language!);\n\n if (\n !language ||\n language === \"text\" ||\n language === \"none\" ||\n language === \"plaintext\" ||\n language === \"txt\"\n ) {\n return [];\n }\n\n if (!highlighter.getLoadedLanguages().includes(language)) {\n return highlighter.loadLanguage(language);\n }\n\n if (!parser) {\n parser =\n globalThisForShiki[shikiParserSymbol] ||\n createParser(highlighter as any);\n globalThisForShiki[shikiParserSymbol] = parser;\n }\n\n return parser(parserOptions);\n };\n\n return createHighlightPlugin({\n parser: lazyParser,\n languageExtractor: (node) => node.attrs.language,\n nodeTypes: [\"codeBlock\"],\n });\n}\n","import type { HighlighterGeneric } from \"@shikijs/types\";\nimport { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport { lazyShikiPlugin } from \"./shiki.js\";\nimport { DOMParser } from \"@tiptap/pm/model\";\n\nexport type CodeBlockOptions = {\n /**\n * Whether to indent lines with a tab when the user presses `Tab` in a code block.\n *\n * @default true\n */\n indentLineWithTab?: boolean;\n /**\n * The default language to use for code blocks.\n *\n * @default \"text\"\n */\n defaultLanguage?: string;\n /**\n * The languages that are supported in the editor.\n *\n * @example\n * {\n * javascript: {\n * name: \"JavaScript\",\n * aliases: [\"js\"],\n * },\n * typescript: {\n * name: \"TypeScript\",\n * aliases: [\"ts\"],\n * },\n * }\n */\n supportedLanguages?: Record<\n string,\n {\n /**\n * The display name of the language.\n */\n name: string;\n /**\n * Aliases for this language.\n */\n aliases?: string[];\n }\n >;\n /**\n * The highlighter to use for code blocks.\n */\n createHighlighter?: () => Promise<HighlighterGeneric<any, any>>;\n};\n\nexport type CodeBlockConfig = ReturnType<typeof createCodeBlockConfig>;\n\nexport const createCodeBlockConfig = createBlockConfig(\n ({ defaultLanguage = \"text\" }: CodeBlockOptions) =>\n ({\n type: \"codeBlock\" as const,\n propSchema: {\n language: {\n default: defaultLanguage,\n },\n },\n content: \"inline\",\n }) as const,\n);\n\nexport const createCodeBlockSpec = createBlockSpec(\n createCodeBlockConfig,\n (options) => ({\n meta: {\n code: true,\n defining: true,\n isolating: false,\n },\n parse: (e) => {\n if (e.tagName !== \"PRE\") {\n return undefined;\n }\n\n if (\n e.childElementCount !== 1 ||\n e.firstElementChild?.tagName !== \"CODE\"\n ) {\n return undefined;\n }\n\n const code = e.firstElementChild!;\n const language =\n code.getAttribute(\"data-language\") ||\n code.className\n .split(\" \")\n .find((name) => name.includes(\"language-\"))\n ?.replace(\"language-\", \"\");\n\n return { language };\n },\n\n parseContent: ({ el, schema }) => {\n const parser = DOMParser.fromSchema(schema);\n const code = el.firstElementChild!;\n\n return parser.parse(code, {\n preserveWhitespace: \"full\",\n topNode: schema.nodes[\"codeBlock\"].create(),\n }).content;\n },\n\n render(block, editor) {\n const wrapper = document.createDocumentFragment();\n const pre = document.createElement(\"pre\");\n const code = document.createElement(\"code\");\n pre.appendChild(code);\n\n let removeSelectChangeListener = undefined;\n\n if (options.supportedLanguages) {\n const select = document.createElement(\"select\");\n\n Object.entries(options.supportedLanguages ?? {}).forEach(\n ([id, { name }]) => {\n const option = document.createElement(\"option\");\n\n option.value = id;\n option.text = name;\n select.appendChild(option);\n },\n );\n select.value =\n block.props.language || options.defaultLanguage || \"text\";\n\n const handleLanguageChange = (event: Event) => {\n const language = (event.target as HTMLSelectElement).value;\n\n editor.updateBlock(block.id, { props: { language } });\n };\n select.addEventListener(\"change\", handleLanguageChange);\n removeSelectChangeListener = () =>\n select.removeEventListener(\"change\", handleLanguageChange);\n\n const selectWrapper = document.createElement(\"div\");\n selectWrapper.contentEditable = \"false\";\n\n selectWrapper.appendChild(select);\n wrapper.appendChild(selectWrapper);\n }\n wrapper.appendChild(pre);\n\n return {\n dom: wrapper,\n contentDOM: code,\n destroy: () => {\n removeSelectChangeListener?.();\n },\n };\n },\n toExternalHTML(block) {\n const pre = document.createElement(\"pre\");\n const code = document.createElement(\"code\");\n code.className = `language-${block.props.language}`;\n code.dataset.language = block.props.language;\n pre.appendChild(code);\n return {\n dom: pre,\n contentDOM: code,\n };\n },\n }),\n (options) => {\n return [\n createBlockNoteExtension({\n key: \"code-block-highlighter\",\n plugins: [lazyShikiPlugin(options)],\n }),\n createBlockNoteExtension({\n key: \"code-block-keyboard-shortcuts\",\n keyboardShortcuts: {\n Delete: ({ editor }) => {\n return editor.transact((tr) => {\n const { block } = editor.getTextCursorPosition();\n if (block.type !== \"codeBlock\") {\n return false;\n }\n const { $from } = tr.selection;\n\n // When inside empty codeblock, on `DELETE` key press, delete the codeblock\n if (!$from.parent.textContent) {\n editor.removeBlocks([block]);\n\n return true;\n }\n\n return false;\n });\n },\n Tab: ({ editor }) => {\n if (options.indentLineWithTab === false) {\n return false;\n }\n\n return editor.transact((tr) => {\n const { block } = editor.getTextCursorPosition();\n if (block.type === \"codeBlock\") {\n // TODO should probably only tab when at a line start or already tabbed in\n tr.insertText(\" \");\n return true;\n }\n\n return false;\n });\n },\n Enter: ({ editor }) => {\n return editor.transact((tr) => {\n const { block, nextBlock } = editor.getTextCursorPosition();\n if (block.type !== \"codeBlock\") {\n return false;\n }\n const { $from } = tr.selection;\n\n const isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;\n const endsWithDoubleNewline =\n $from.parent.textContent.endsWith(\"\\n\\n\");\n\n // The user is trying to exit the code block by pressing enter at the end of the code block\n if (isAtEnd && endsWithDoubleNewline) {\n // Remove the double newline\n tr.delete($from.pos - 2, $from.pos);\n\n // If there is a next block, move the cursor to it\n if (nextBlock) {\n editor.setTextCursorPosition(nextBlock, \"start\");\n return true;\n }\n\n // If there is no next block, insert a new paragraph\n const [newBlock] = editor.insertBlocks(\n [{ type: \"paragraph\" }],\n block,\n \"after\",\n );\n // Move the cursor to the new block\n editor.setTextCursorPosition(newBlock, \"start\");\n\n return true;\n }\n\n tr.insertText(\"\\n\");\n return true;\n });\n },\n \"Shift-Enter\": ({ editor }) => {\n return editor.transact(() => {\n const { block } = editor.getTextCursorPosition();\n if (block.type !== \"codeBlock\") {\n return false;\n }\n\n const [newBlock] = editor.insertBlocks(\n // insert a new paragraph\n [{ type: \"paragraph\" }],\n block,\n \"after\",\n );\n // move the cursor to the new block\n editor.setTextCursorPosition(newBlock, \"start\");\n return true;\n });\n },\n },\n inputRules: [\n {\n find: /^```(.*?)\\s$/,\n replace: ({ match }) => {\n const languageName = match[1].trim();\n const attributes = {\n language: getLanguageId(options, languageName) ?? languageName,\n };\n\n return {\n type: \"codeBlock\",\n props: {\n language: attributes.language,\n },\n content: [],\n };\n },\n },\n ],\n }),\n ];\n },\n);\n\nexport function getLanguageId(\n options: CodeBlockOptions,\n languageName: string,\n): string | undefined {\n return Object.entries(options.supportedLanguages ?? {}).find(\n ([id, { aliases }]) => {\n return aliases?.includes(languageName) || id === languageName;\n },\n )?.[0];\n}\n","import { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\n\nexport type DividerBlockConfig = ReturnType<typeof createDividerBlockConfig>;\n\nexport const createDividerBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"divider\" as const,\n propSchema: {},\n content: \"none\",\n }) as const,\n);\n\nexport const createDividerBlockSpec = createBlockSpec(\n createDividerBlockConfig,\n {\n meta: {\n isolating: false,\n },\n parse(element) {\n if (element.tagName === \"HR\") {\n return {};\n }\n\n return undefined;\n },\n render() {\n const dom = document.createElement(\"hr\");\n\n return {\n dom,\n };\n },\n },\n [\n createBlockNoteExtension({\n key: \"divider-block-shortcuts\",\n inputRules: [\n {\n find: new RegExp(`^---$`),\n replace() {\n return { type: \"divider\", props: {}, content: [] };\n },\n },\n ],\n }),\n ],\n);\n","export const parseEmbedElement = (embedElement: HTMLEmbedElement) => {\n const url = embedElement.src || undefined;\n\n return { url };\n};\n","import { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport { defaultProps, parseDefaultProps } from \"../defaultProps.js\";\nimport { parseEmbedElement } from \"./helpers/parse/parseEmbedElement.js\";\nimport { parseFigureElement } from \"./helpers/parse/parseFigureElement.js\";\nimport { createFileBlockWrapper } from \"./helpers/render/createFileBlockWrapper.js\";\nimport { createLinkWithCaption } from \"./helpers/toExternalHTML/createLinkWithCaption.js\";\n\nexport type FileBlockConfig = ReturnType<typeof createFileBlockConfig>;\n\nexport const createFileBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"file\" as const,\n propSchema: {\n backgroundColor: defaultProps.backgroundColor,\n // File name.\n name: {\n default: \"\" as const,\n },\n // File url.\n url: {\n default: \"\" as const,\n },\n // File caption.\n caption: {\n default: \"\" as const,\n },\n },\n content: \"none\" as const,\n }) as const,\n);\n\nexport const fileParse = () => (element: HTMLElement) => {\n if (element.tagName === \"EMBED\") {\n // Ignore if parent figure has already been parsed.\n if (element.closest(\"figure\")) {\n return undefined;\n }\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseEmbedElement(element as HTMLEmbedElement),\n backgroundColor,\n };\n }\n\n if (element.tagName === \"FIGURE\") {\n const parsedFigure = parseFigureElement(element, \"embed\");\n if (!parsedFigure) {\n return undefined;\n }\n\n const { targetElement, caption } = parsedFigure;\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseEmbedElement(targetElement as HTMLEmbedElement),\n backgroundColor,\n caption,\n };\n }\n\n return undefined;\n};\n\nexport const createFileBlockSpec = createBlockSpec(createFileBlockConfig, {\n meta: {\n fileBlockAccept: [\"*/*\"],\n },\n parse: fileParse(),\n render(block, editor) {\n return createFileBlockWrapper(block, editor);\n },\n toExternalHTML(block) {\n if (!block.props.url) {\n const div = document.createElement(\"p\");\n div.textContent = \"Add file\";\n\n return {\n dom: div,\n };\n }\n\n const fileSrcLink = document.createElement(\"a\");\n fileSrcLink.href = block.props.url;\n fileSrcLink.textContent = block.props.name || block.props.url;\n\n if (block.props.caption) {\n return createLinkWithCaption(fileSrcLink, block.props.caption);\n }\n\n return {\n dom: fileSrcLink,\n };\n },\n});\n","import { ViewMutationRecord } from \"@tiptap/pm/view\";\n\nimport { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { Block } from \"../defaultBlocks.js\";\n\ntype ToggledState = {\n set: (block: Block<any, any, any>, isToggled: boolean) => void;\n get: (block: Block<any, any, any>) => boolean;\n};\n\nexport const defaultToggledState: ToggledState = {\n set: (block, isToggled: boolean) =>\n window.localStorage.setItem(\n `toggle-${block.id}`,\n isToggled ? \"true\" : \"false\",\n ),\n get: (block) => window.localStorage.getItem(`toggle-${block.id}`) === \"true\",\n};\n\nexport const createToggleWrapper = (\n block: Block<any, any, any>,\n editor: BlockNoteEditor<any, any, any>,\n renderedElement: HTMLElement,\n toggledState: ToggledState = defaultToggledState,\n): {\n dom: HTMLElement;\n contentDOM?: HTMLElement;\n ignoreMutation?: (mutation: ViewMutationRecord) => boolean;\n destroy?: () => void;\n} => {\n if (\"isToggleable\" in block.props && !block.props.isToggleable) {\n return {\n dom: renderedElement,\n };\n }\n\n const dom = document.createElement(\"div\");\n\n const toggleWrapper = document.createElement(\"div\");\n toggleWrapper.className = \"bn-toggle-wrapper\";\n\n const toggleButton = document.createElement(\"button\");\n toggleButton.className = \"bn-toggle-button\";\n toggleButton.type = \"button\";\n toggleButton.innerHTML =\n // https://fonts.google.com/icons?selected=Material+Symbols+Rounded:chevron_right:FILL@0;wght@700;GRAD@0;opsz@24&icon.query=chevron&icon.style=Rounded&icon.size=24&icon.color=%23e8eaed\n '<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\" width=\"24px\" fill=\"CURRENTCOLOR\"><path d=\"M320-200v-560l440 280-440 280Z\"/></svg>';\n const toggleButtonMouseDown = (event: MouseEvent) => event.preventDefault();\n toggleButton.addEventListener(\"mousedown\", toggleButtonMouseDown);\n const toggleButtonOnClick = () => {\n // Toggles visibility of child blocks. Also adds/removes the \"add block\"\n // button if there are no child blocks.\n if (toggleWrapper.getAttribute(\"data-show-children\") === \"true\") {\n toggleWrapper.setAttribute(\"data-show-children\", \"false\");\n toggledState.set(editor.getBlock(block)!, false);\n\n if (dom.contains(toggleAddBlockButton)) {\n dom.removeChild(toggleAddBlockButton);\n }\n } else {\n toggleWrapper.setAttribute(\"data-show-children\", \"true\");\n toggledState.set(editor.getBlock(block)!, true);\n\n if (\n editor.getBlock(block)?.children.length === 0 &&\n !dom.contains(toggleAddBlockButton)\n ) {\n dom.appendChild(toggleAddBlockButton);\n }\n }\n };\n toggleButton.addEventListener(\"click\", toggleButtonOnClick);\n\n toggleWrapper.appendChild(toggleButton);\n toggleWrapper.appendChild(renderedElement);\n\n const toggleAddBlockButton = document.createElement(\"button\");\n toggleAddBlockButton.className = \"bn-toggle-add-block-button\";\n toggleAddBlockButton.type = \"button\";\n toggleAddBlockButton.textContent =\n editor.dictionary.toggle_blocks.add_block_button;\n const toggleAddBlockButtonMouseDown = (event: MouseEvent) =>\n event.preventDefault();\n toggleAddBlockButton.addEventListener(\n \"mousedown\",\n toggleAddBlockButtonMouseDown,\n );\n const toggleAddBlockButtonOnClick = () => {\n // Adds a single empty child block.\n editor.transact(() => {\n // dom.removeChild(toggleAddBlockButton);\n\n const updatedBlock = editor.updateBlock(block, {\n // Single empty block with default type.\n children: [{}],\n });\n editor.setTextCursorPosition(updatedBlock.children[0].id, \"end\");\n editor.focus();\n });\n };\n toggleAddBlockButton.addEventListener(\"click\", toggleAddBlockButtonOnClick);\n\n dom.appendChild(toggleWrapper);\n\n let childCount = block.children.length;\n const onEditorChange = editor.onChange(() => {\n const newChildCount = editor.getBlock(block)?.children.length ?? 0;\n\n if (newChildCount > childCount) {\n // If a child block is added while children are hidden, show children.\n if (toggleWrapper.getAttribute(\"data-show-children\") === \"false\") {\n toggleWrapper.setAttribute(\"data-show-children\", \"true\");\n toggledState.set(editor.getBlock(block)!, true);\n }\n\n // Remove the \"add block\" button as we want to show child blocks and\n // there is at least one child block.\n if (dom.contains(toggleAddBlockButton)) {\n dom.removeChild(toggleAddBlockButton);\n }\n } else if (newChildCount === 0 && newChildCount < childCount) {\n // If the last child block is removed while children are shown, hide\n // children.\n if (toggleWrapper.getAttribute(\"data-show-children\") === \"true\") {\n toggleWrapper.setAttribute(\"data-show-children\", \"false\");\n toggledState.set(editor.getBlock(block)!, false);\n }\n\n // Remove the \"add block\" button as we want to hide child blocks,\n // regardless of whether there are child blocks or not.\n if (dom.contains(toggleAddBlockButton)) {\n dom.removeChild(toggleAddBlockButton);\n }\n }\n\n childCount = newChildCount;\n });\n\n if (toggledState.get(block)) {\n toggleWrapper.setAttribute(\"data-show-children\", \"true\");\n\n if (block.children.length === 0) {\n // If the toggle is set to show children, but there are no children,\n // we add the \"add block\" button.\n dom.appendChild(toggleAddBlockButton);\n }\n } else {\n toggleWrapper.setAttribute(\"data-show-children\", \"false\");\n }\n\n return {\n dom,\n // Prevents re-renders when the toggle button is clicked.\n ignoreMutation: (mutation) => {\n if (\n mutation instanceof MutationRecord &&\n // We want to prevent re-renders when the view changes, so we ignore\n // all mutations where the `data-show-children` attribute is changed\n // or the \"add block\" button is added/removed.\n ((mutation.type === \"attributes\" &&\n mutation.target === toggleWrapper &&\n mutation.attributeName === \"data-show-children\") ||\n (mutation.type === \"childList\" &&\n (mutation.addedNodes[0] === toggleAddBlockButton ||\n mutation.removedNodes[0] === toggleAddBlockButton)))\n ) {\n return true;\n }\n return false;\n },\n destroy: () => {\n toggleButton.removeEventListener(\"mousedown\", toggleButtonMouseDown);\n toggleButton.removeEventListener(\"click\", toggleButtonOnClick);\n toggleAddBlockButton.removeEventListener(\n \"mousedown\",\n toggleAddBlockButtonMouseDown,\n );\n toggleAddBlockButton.removeEventListener(\n \"click\",\n toggleAddBlockButtonOnClick,\n );\n onEditorChange?.();\n },\n };\n};\n","import { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../defaultProps.js\";\nimport { createToggleWrapper } from \"../ToggleWrapper/createToggleWrapper.js\";\n\nconst HEADING_LEVELS = [1, 2, 3, 4, 5, 6] as const;\n\nexport interface HeadingOptions {\n defaultLevel?: (typeof HEADING_LEVELS)[number];\n levels?: readonly number[];\n // TODO should probably use composition instead of this\n allowToggleHeadings?: boolean;\n}\n\nexport type HeadingBlockConfig = ReturnType<typeof createHeadingBlockConfig>;\n\nexport const createHeadingBlockConfig = createBlockConfig(\n ({\n defaultLevel = 1,\n levels = HEADING_LEVELS,\n allowToggleHeadings = true,\n }: HeadingOptions = {}) =>\n ({\n type: \"heading\" as const,\n propSchema: {\n ...defaultProps,\n level: { default: defaultLevel, values: levels },\n ...(allowToggleHeadings\n ? { isToggleable: { default: false, optional: true } as const }\n : {}),\n },\n content: \"inline\",\n }) as const,\n);\n\nexport const createHeadingBlockSpec = createBlockSpec(\n createHeadingBlockConfig,\n ({ allowToggleHeadings = true }: HeadingOptions = {}) => ({\n meta: {\n isolating: false,\n },\n parse(e) {\n let level: number;\n switch (e.tagName) {\n case \"H1\":\n level = 1;\n break;\n case \"H2\":\n level = 2;\n break;\n case \"H3\":\n level = 3;\n break;\n case \"H4\":\n level = 4;\n break;\n case \"H5\":\n level = 5;\n break;\n case \"H6\":\n level = 6;\n break;\n default:\n return undefined;\n }\n\n return {\n ...parseDefaultProps(e),\n level,\n };\n },\n render(block, editor) {\n const dom = document.createElement(`h${block.props.level}`);\n\n if (allowToggleHeadings) {\n const toggleWrapper = createToggleWrapper(block, editor, dom);\n return { ...toggleWrapper, contentDOM: dom };\n }\n\n return {\n dom,\n contentDOM: dom,\n };\n },\n toExternalHTML(block) {\n const dom = document.createElement(`h${block.props.level}`);\n addDefaultPropsExternalHTML(block.props, dom);\n\n return {\n dom,\n contentDOM: dom,\n };\n },\n }),\n ({ levels = HEADING_LEVELS }: HeadingOptions = {}) => [\n createBlockNoteExtension({\n key: \"heading-shortcuts\",\n keyboardShortcuts: Object.fromEntries(\n levels.map((level) => [\n `Mod-Alt-${level}`,\n ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"heading\",\n props: {\n level: level as any,\n },\n });\n return true;\n },\n ]) ?? [],\n ),\n inputRules: levels.map((level) => ({\n find: new RegExp(`^(#{${level}})\\\\s$`),\n replace({ match }: { match: RegExpMatchArray }) {\n return {\n type: \"heading\",\n props: {\n level: match[1].length,\n },\n };\n },\n })),\n }),\n ],\n);\n","import type { BlockNoteEditor } from \"../../../../editor/BlockNoteEditor.js\";\nimport {\n BlockConfig,\n BlockFromConfigNoChildren,\n} from \"../../../../schema/index.js\";\nimport { createFileBlockWrapper } from \"./createFileBlockWrapper.js\";\n\nexport const createResizableFileBlockWrapper = (\n block: BlockFromConfigNoChildren<\n BlockConfig<\n string,\n {\n backgroundColor: { default: \"default\" };\n name: { default: \"\" };\n url: { default: \"\" };\n caption: { default: \"\" };\n showPreview?: { default: true };\n previewWidth?: { default: number };\n textAlignment?: { default: \"left\" };\n },\n \"none\"\n >,\n any,\n any\n >,\n editor: BlockNoteEditor<any, any, any>,\n element: { dom: HTMLElement; destroy?: () => void },\n resizeHandlesContainerElement: HTMLElement,\n buttonIcon?: HTMLElement,\n): { dom: HTMLElement; destroy: () => void } => {\n const { dom, destroy } = createFileBlockWrapper(\n block,\n editor,\n element,\n buttonIcon,\n );\n const wrapper = dom;\n wrapper.style.position = \"relative\";\n if (block.props.url && block.props.showPreview) {\n if (block.props.previewWidth) {\n wrapper.style.width = `${block.props.previewWidth}px`;\n } else {\n wrapper.style.width = \"fit-content\";\n }\n }\n\n const leftResizeHandle = document.createElement(\"div\");\n leftResizeHandle.className = \"bn-resize-handle\";\n leftResizeHandle.style.left = \"4px\";\n const rightResizeHandle = document.createElement(\"div\");\n rightResizeHandle.className = \"bn-resize-handle\";\n rightResizeHandle.style.right = \"4px\";\n\n // This element ensures `mousemove` and `mouseup` events are captured while\n // resizing when the cursor is over the wrapper content. This is because\n // embeds are treated as separate HTML documents, so if the content is an\n // embed, the events will only fire within that document.\n const eventCaptureElement = document.createElement(\"div\");\n eventCaptureElement.style.position = \"absolute\";\n eventCaptureElement.style.height = \"100%\";\n eventCaptureElement.style.width = \"100%\";\n\n // Temporary parameters set when the user begins resizing the element, used to\n // calculate the new width of the element.\n let resizeParams:\n | {\n handleUsed: \"left\" | \"right\";\n initialWidth: number;\n initialClientX: number;\n }\n | undefined;\n let width = block.props.previewWidth! as number;\n\n // Updates the element width with an updated width depending on the cursor X\n // offset from when the resize began, and which resize handle is being used.\n const windowMouseMoveHandler = (event: MouseEvent | TouchEvent) => {\n if (!resizeParams) {\n if (\n !editor.isEditable &&\n resizeHandlesContainerElement.contains(leftResizeHandle) &&\n resizeHandlesContainerElement.contains(rightResizeHandle)\n ) {\n resizeHandlesContainerElement.removeChild(leftResizeHandle);\n resizeHandlesContainerElement.removeChild(rightResizeHandle);\n }\n\n return;\n }\n\n let newWidth: number;\n\n const clientX =\n \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n if (block.props.textAlignment === \"center\") {\n if (resizeParams.handleUsed === \"left\") {\n newWidth =\n resizeParams.initialWidth +\n (resizeParams.initialClientX - clientX) * 2;\n } else {\n newWidth =\n resizeParams.initialWidth +\n (clientX - resizeParams.initialClientX) * 2;\n }\n } else {\n if (resizeParams.handleUsed === \"left\") {\n newWidth =\n resizeParams.initialWidth + resizeParams.initialClientX - clientX;\n } else {\n newWidth =\n resizeParams.initialWidth + clientX - resizeParams.initialClientX;\n }\n }\n\n // Min element width in px.\n const minWidth = 64;\n\n // Ensures the element is not wider than the editor and not narrower than a\n // predetermined minimum width.\n width = Math.min(\n Math.max(newWidth, minWidth),\n editor.domElement?.firstElementChild?.clientWidth || Number.MAX_VALUE,\n );\n wrapper.style.width = `${width}px`;\n };\n // Stops mouse movements from resizing the element and updates the block's\n // `width` prop to the new value.\n const windowMouseUpHandler = (event: MouseEvent | TouchEvent) => {\n // Hides the drag handles if the cursor is no longer over the element.\n if (\n (!event.target ||\n !wrapper.contains(event.target as Node) ||\n !editor.isEditable) &&\n resizeHandlesContainerElement.contains(leftResizeHandle) &&\n resizeHandlesContainerElement.contains(rightResizeHandle)\n ) {\n resizeHandlesContainerElement.removeChild(leftResizeHandle);\n resizeHandlesContainerElement.removeChild(rightResizeHandle);\n }\n\n if (!resizeParams) {\n return;\n }\n\n resizeParams = undefined;\n\n if (wrapper.contains(eventCaptureElement)) {\n wrapper.removeChild(eventCaptureElement);\n }\n\n editor.updateBlock(block, {\n props: {\n previewWidth: width,\n },\n });\n };\n\n // Shows the resize handles when hovering over the wrapper with the cursor.\n const wrapperMouseEnterHandler = () => {\n if (editor.isEditable) {\n resizeHandlesContainerElement.appendChild(leftResizeHandle);\n resizeHandlesContainerElement.appendChild(rightResizeHandle);\n }\n };\n // Hides the resize handles when the cursor leaves the wrapper, unless the\n // cursor moves to one of the resize handles.\n const wrapperMouseLeaveHandler = (event: MouseEvent) => {\n if (\n event.relatedTarget === leftResizeHandle ||\n event.relatedTarget === rightResizeHandle\n ) {\n return;\n }\n\n if (resizeParams) {\n return;\n }\n\n if (\n editor.isEditable &&\n resizeHandlesContainerElement.contains(leftResizeHandle) &&\n resizeHandlesContainerElement.contains(rightResizeHandle)\n ) {\n resizeHandlesContainerElement.removeChild(leftResizeHandle);\n resizeHandlesContainerElement.removeChild(rightResizeHandle);\n }\n };\n\n // Sets the resize params, allowing the user to begin resizing the element by\n // moving the cursor left or right.\n const leftResizeHandleMouseDownHandler = (event: MouseEvent | TouchEvent) => {\n event.preventDefault();\n\n if (!wrapper.contains(eventCaptureElement)) {\n wrapper.appendChild(eventCaptureElement);\n }\n\n const clientX =\n \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n resizeParams = {\n handleUsed: \"left\",\n initialWidth: wrapper.clientWidth,\n initialClientX: clientX,\n };\n };\n const rightResizeHandleMouseDownHandler = (\n event: MouseEvent | TouchEvent,\n ) => {\n event.preventDefault();\n\n if (!wrapper.contains(eventCaptureElement)) {\n wrapper.appendChild(eventCaptureElement);\n }\n\n const clientX =\n \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n resizeParams = {\n handleUsed: \"right\",\n initialWidth: wrapper.clientWidth,\n initialClientX: clientX,\n };\n };\n\n window.addEventListener(\"mousemove\", windowMouseMoveHandler);\n window.addEventListener(\"touchmove\", windowMouseMoveHandler);\n window.addEventListener(\"mouseup\", windowMouseUpHandler);\n window.addEventListener(\"touchend\", windowMouseUpHandler);\n wrapper.addEventListener(\"mouseenter\", wrapperMouseEnterHandler);\n wrapper.addEventListener(\"mouseleave\", wrapperMouseLeaveHandler);\n leftResizeHandle.addEventListener(\n \"mousedown\",\n leftResizeHandleMouseDownHandler,\n );\n leftResizeHandle.addEventListener(\n \"touchstart\",\n leftResizeHandleMouseDownHandler,\n );\n rightResizeHandle.addEventListener(\n \"mousedown\",\n rightResizeHandleMouseDownHandler,\n );\n rightResizeHandle.addEventListener(\n \"touchstart\",\n rightResizeHandleMouseDownHandler,\n );\n\n return {\n dom: wrapper,\n destroy: () => {\n destroy?.();\n window.removeEventListener(\"mousemove\", windowMouseMoveHandler);\n window.removeEventListener(\"touchmove\", windowMouseMoveHandler);\n window.removeEventListener(\"mouseup\", windowMouseUpHandler);\n window.removeEventListener(\"touchend\", windowMouseUpHandler);\n wrapper.removeEventListener(\"mouseenter\", wrapperMouseEnterHandler);\n wrapper.removeEventListener(\"mouseleave\", wrapperMouseLeaveHandler);\n leftResizeHandle.removeEventListener(\n \"mousedown\",\n leftResizeHandleMouseDownHandler,\n );\n leftResizeHandle.removeEventListener(\n \"touchstart\",\n leftResizeHandleMouseDownHandler,\n );\n rightResizeHandle.removeEventListener(\n \"mousedown\",\n rightResizeHandleMouseDownHandler,\n );\n rightResizeHandle.removeEventListener(\n \"touchstart\",\n rightResizeHandleMouseDownHandler,\n );\n },\n };\n};\n","export const parseImageElement = (imageElement: HTMLImageElement) => {\n const url = imageElement.src || undefined;\n const previewWidth = imageElement.width || undefined;\n const name = imageElement.alt || undefined;\n\n return { url, previewWidth, name };\n};\n","import { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport {\n BlockFromConfig,\n createBlockConfig,\n createBlockSpec,\n} from \"../../schema/index.js\";\nimport { defaultProps, parseDefaultProps } from \"../defaultProps.js\";\nimport { parseFigureElement } from \"../File/helpers/parse/parseFigureElement.js\";\nimport { createResizableFileBlockWrapper } from \"../File/helpers/render/createResizableFileBlockWrapper.js\";\nimport { createFigureWithCaption } from \"../File/helpers/toExternalHTML/createFigureWithCaption.js\";\nimport { createLinkWithCaption } from \"../File/helpers/toExternalHTML/createLinkWithCaption.js\";\nimport { parseImageElement } from \"./parseImageElement.js\";\n\nexport const FILE_IMAGE_ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z\"></path></svg>';\n\nexport interface ImageOptions {\n icon?: string;\n}\n\nexport type ImageBlockConfig = ReturnType<typeof createImageBlockConfig>;\n\nexport const createImageBlockConfig = createBlockConfig(\n (_ctx: ImageOptions = {}) =>\n ({\n type: \"image\" as const,\n propSchema: {\n textAlignment: defaultProps.textAlignment,\n backgroundColor: defaultProps.backgroundColor,\n // File name.\n name: {\n default: \"\" as const,\n },\n // File url.\n url: {\n default: \"\" as const,\n },\n // File caption.\n caption: {\n default: \"\" as const,\n },\n\n showPreview: {\n default: true,\n },\n // File preview width in px.\n previewWidth: {\n default: undefined,\n type: \"number\" as const,\n },\n },\n content: \"none\" as const,\n }) as const,\n);\n\nexport const imageParse =\n (_config: ImageOptions = {}) =>\n (element: HTMLElement) => {\n if (element.tagName === \"IMG\") {\n // Ignore if parent figure has already been parsed.\n if (element.closest(\"figure\")) {\n return undefined;\n }\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseImageElement(element as HTMLImageElement),\n backgroundColor,\n };\n }\n\n if (element.tagName === \"FIGURE\") {\n const parsedFigure = parseFigureElement(element, \"img\");\n if (!parsedFigure) {\n return undefined;\n }\n\n const { targetElement, caption } = parsedFigure;\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseImageElement(targetElement as HTMLImageElement),\n backgroundColor,\n caption,\n };\n }\n\n return undefined;\n };\n\nexport const imageRender =\n (config: ImageOptions = {}) =>\n (\n block: BlockFromConfig<ReturnType<typeof createImageBlockConfig>, any, any>,\n editor: BlockNoteEditor<\n Record<\"image\", ReturnType<typeof createImageBlockConfig>>,\n any,\n any\n >,\n ) => {\n const icon = document.createElement(\"div\");\n icon.innerHTML = config.icon ?? FILE_IMAGE_ICON_SVG;\n\n const imageWrapper = document.createElement(\"div\");\n imageWrapper.className = \"bn-visual-media-wrapper\";\n\n const image = document.createElement(\"img\");\n image.className = \"bn-visual-media\";\n if (editor.resolveFileUrl) {\n editor.resolveFileUrl(block.props.url).then((downloadUrl) => {\n image.src = downloadUrl;\n });\n } else {\n image.src = block.props.url;\n }\n\n image.alt = block.props.name || block.props.caption || \"BlockNote image\";\n image.contentEditable = \"false\";\n image.draggable = false;\n imageWrapper.appendChild(image);\n\n return createResizableFileBlockWrapper(\n block,\n editor,\n { dom: imageWrapper },\n imageWrapper,\n icon.firstElementChild as HTMLElement,\n );\n };\n\nexport const imageToExternalHTML =\n (_config: ImageOptions = {}) =>\n (\n block: BlockFromConfig<ReturnType<typeof createImageBlockConfig>, any, any>,\n _editor: BlockNoteEditor<\n Record<\"image\", ReturnType<typeof createImageBlockConfig>>,\n any,\n any\n >,\n ) => {\n if (!block.props.url) {\n const div = document.createElement(\"p\");\n div.textContent = \"Add image\";\n\n return {\n dom: div,\n };\n }\n\n let image;\n if (block.props.showPreview) {\n image = document.createElement(\"img\");\n image.src = block.props.url;\n image.alt = block.props.name || block.props.caption || \"BlockNote image\";\n if (block.props.previewWidth) {\n image.width = block.props.previewWidth;\n }\n } else {\n image = document.createElement(\"a\");\n image.href = block.props.url;\n image.textContent = block.props.name || block.props.url;\n }\n\n if (block.props.caption) {\n if (block.props.showPreview) {\n return createFigureWithCaption(image, block.props.caption);\n } else {\n return createLinkWithCaption(image, block.props.caption);\n }\n }\n\n return {\n dom: image,\n };\n };\n\nexport const createImageBlockSpec = createBlockSpec(\n createImageBlockConfig,\n (config) => ({\n meta: {\n fileBlockAccept: [\"image/*\"],\n },\n parse: imageParse(config),\n render: imageRender(config),\n toExternalHTML: imageToExternalHTML(config),\n runsBefore: [\"file\"],\n }),\n);\n","import { EditorState, Transaction } from \"prosemirror-state\";\n\nimport {\n getBlockInfo,\n getNearestBlockPos,\n} from \"../../../getBlockInfoFromPos.js\";\nimport { getPmSchema } from \"../../../pmUtil.js\";\n\nexport const splitBlockCommand = (\n posInBlock: number,\n keepType?: boolean,\n keepProps?: boolean,\n) => {\n return ({\n state,\n dispatch,\n }: {\n state: EditorState;\n dispatch: ((args?: any) => any) | undefined;\n }) => {\n if (dispatch) {\n return splitBlockTr(state.tr, posInBlock, keepType, keepProps);\n }\n\n return true;\n };\n};\n\nexport const splitBlockTr = (\n tr: Transaction,\n posInBlock: number,\n keepType?: boolean,\n keepProps?: boolean,\n): boolean => {\n const nearestBlockContainerPos = getNearestBlockPos(tr.doc, posInBlock);\n\n const info = getBlockInfo(nearestBlockContainerPos);\n\n if (!info.isBlockContainer) {\n return false;\n }\n const schema = getPmSchema(tr);\n\n const types = [\n {\n type: info.bnBlock.node.type, // always keep blockcontainer type\n attrs: keepProps ? { ...info.bnBlock.node.attrs, id: undefined } : {},\n },\n {\n type: keepType ? info.blockContent.node.type : schema.nodes[\"paragraph\"],\n attrs: keepProps ? { ...info.blockContent.node.attrs } : {},\n },\n ];\n\n tr.split(posInBlock, 2, types);\n\n return true;\n};\n","import { splitBlockTr } from \"../../api/blockManipulation/commands/splitBlock/splitBlock.js\";\nimport { updateBlockTr } from \"../../api/blockManipulation/commands/updateBlock/updateBlock.js\";\nimport { getBlockInfoFromTransaction } from \"../../api/getBlockInfoFromPos.js\";\nimport { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\n\nexport const handleEnter = (\n editor: BlockNoteEditor<any, any, any>,\n listItemType: string,\n) => {\n const { blockInfo, selectionEmpty } = editor.transact((tr) => {\n return {\n blockInfo: getBlockInfoFromTransaction(tr),\n selectionEmpty: tr.selection.anchor === tr.selection.head,\n };\n });\n\n if (!blockInfo.isBlockContainer) {\n return false;\n }\n const { bnBlock: blockContainer, blockContent } = blockInfo;\n\n if (!(blockContent.node.type.name === listItemType) || !selectionEmpty) {\n return false;\n }\n\n if (blockContent.node.childCount === 0) {\n editor.transact((tr) => {\n updateBlockTr(tr, blockContainer.beforePos, {\n type: \"paragraph\",\n props: {},\n });\n });\n return true;\n } else if (blockContent.node.childCount > 0) {\n return editor.transact((tr) => {\n tr.deleteSelection();\n return splitBlockTr(tr, tr.selection.from, true);\n });\n }\n\n return false;\n};\n","import { DOMParser, Fragment, Schema } from \"prosemirror-model\";\n\n/**\n * This function is used to parse the content of a list item external HTML node.\n *\n * Due to a change in how prosemirror-model handles parsing elements, we have additional flexibility in how we can \"fit\" content into a list item.\n *\n * We've decided to take an approach that is similar to Notion. The core rules of the algorithm are:\n *\n * - If the first child of an `li` has ONLY text content, take the text content, and flatten it into the list item. Subsequent siblings are carried over as is, as children of the list item.\n * - e.g. `<li><h1>Hello</h1><p>World</p></li> -> <li>Hello<blockGroup><blockContainer><p>World</p></blockContainer></blockGroup></li>`\n * - Else, take the content and insert it as children instead.\n * - e.g. `<li><img src=\"url\" /></li> -> <li><p></p><blockGroup><blockContainer><img src=\"url\" /></blockContainer></blockGroup></li>`\n *\n * This ensures that a list item's content is always valid ProseMirror content. Smoothing over differences between how external HTML may be rendered, and how ProseMirror expects content to be structured.\n */\nexport function getListItemContent(\n /**\n * The `li` element to parse.\n */\n _node: Node,\n /**\n * The schema to use for parsing.\n */\n schema: Schema,\n /**\n * The name of the list item node.\n */\n name: string,\n): Fragment {\n /**\n * To actually implement this algorithm, we need to leverage ProseMirror's \"fitting\" algorithm.\n * Where, if content is parsed which doesn't fit into the current node, it will be moved into the parent node.\n *\n * This allows us to parse multiple pieces of content from within the list item (even though it normally would not match the list item's schema) and \"throw\" the excess content into the list item's children.\n *\n * The expected return value is a `Fragment` which contains the list item's content as the first element, and the children wrapped in a blockGroup node. Like so:\n * ```\n * Fragment<[Node<Text>, Node<BlockGroup<Node<BlockContainer<any>>>>]>\n * ```\n */\n const parser = DOMParser.fromSchema(schema);\n\n // TODO: This will be unnecessary in the future: https://github.com/ProseMirror/prosemirror-model/commit/166188d4f9db96eb86fb7de62e72049c86c9dd79\n const node = _node as HTMLElement;\n\n // Move the `li` element's content into a new `div` element\n // This is a hacky workaround to not re-trigger list item parsing,\n // when we are looking to understand what the list item's content actually is, in terms of the schema.\n const clonedNodeDiv = document.createElement(\"div\");\n // Mark the `div` element as a `blockGroup` to make the parsing easier.\n clonedNodeDiv.setAttribute(\"data-node-type\", \"blockGroup\");\n // Clone all children of the `li` element into the new `div` element\n for (const child of Array.from(node.childNodes)) {\n clonedNodeDiv.appendChild(child.cloneNode(true));\n }\n\n // Parses children of the `li` element into a `blockGroup` with `blockContainer` node children\n // This is the structure of list item children, so parsing into this structure allows for\n // easy separation of list item content from child list item content.\n let blockGroupNode = parser.parse(clonedNodeDiv, {\n topNode: schema.nodes.blockGroup.create(),\n });\n\n // There is an edge case where a list item's content may contain a `<input>` element.\n // Causing it to be recognized as a `checkListItem`.\n // We want to skip this, and just parse the list item's content as is.\n if (blockGroupNode.firstChild?.firstChild?.type.name === \"checkListItem\") {\n // We skip the first child, by cutting it out of the `blockGroup` node.\n // and continuing with the rest of the algorithm.\n blockGroupNode = blockGroupNode.copy(\n blockGroupNode.content.cut(\n blockGroupNode.firstChild.firstChild.nodeSize + 2,\n ),\n );\n }\n\n // Structure above is `blockGroup<blockContainer<any>[]>`\n // We want to extract the first `blockContainer` node's content, and see if it is a text block.\n const listItemsFirstChild = blockGroupNode.firstChild?.firstChild;\n\n // If the first node is not a text block, then it's first child is not compatible with the list item node.\n if (!listItemsFirstChild?.isTextblock) {\n // So, we do not try inserting anything into the list item, and instead return anything we found as children for the list item.\n return Fragment.from(blockGroupNode);\n }\n\n // If it is a text block, then we know it only contains text content.\n // So, we extract it, and insert its content into the `listItemNode`.\n // The remaining nodes in the `blockGroup` stay in-place.\n const listItemNode = schema.nodes[name].create(\n {},\n listItemsFirstChild.content,\n );\n\n // We have `blockGroup<listItemsFirstChild, ...blockContainer<any>[]>`\n // We want to extract out the rest of the nodes as `<...blockContainer<any>[]>`\n const remainingListItemChildren = blockGroupNode.content.cut(\n // +2 for the `blockGroup` node's start and end markers\n listItemsFirstChild.nodeSize + 2,\n );\n const hasRemainingListItemChildren = remainingListItemChildren.size > 0;\n\n if (hasRemainingListItemChildren) {\n // Copy the remaining list item children back into the `blockGroup` node.\n // This will make it back into: `blockGroup<...blockContainer<any>[]>`\n const listItemsChildren = blockGroupNode.copy(remainingListItemChildren);\n\n // Return the `listItem` node's content, then add the parsed children after to be lifted out by ProseMirror \"fitting\" algorithm.\n return listItemNode.content.addToEnd(listItemsChildren);\n }\n\n // Otherwise, just return the `listItem` node's content.\n return listItemNode.content;\n}\n","import { getBlockInfoFromSelection } from \"../../../api/getBlockInfoFromPos.js\";\nimport { createBlockNoteExtension } from \"../../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../../defaultProps.js\";\nimport { handleEnter } from \"../../utils/listItemEnterHandler.js\";\nimport { getListItemContent } from \"../getListItemContent.js\";\n\nexport type BulletListItemBlockConfig = ReturnType<\n typeof createBulletListItemBlockConfig\n>;\n\nexport const createBulletListItemBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"bulletListItem\" as const,\n propSchema: {\n ...defaultProps,\n },\n content: \"inline\",\n }) as const,\n);\n\nexport const createBulletListItemBlockSpec = createBlockSpec(\n createBulletListItemBlockConfig,\n {\n meta: {\n isolating: false,\n },\n parse(element) {\n if (element.tagName !== \"LI\") {\n return undefined;\n }\n\n const parent = element.parentElement;\n\n if (parent === null) {\n return undefined;\n }\n\n if (\n parent.tagName === \"UL\" ||\n (parent.tagName === \"DIV\" && parent.parentElement?.tagName === \"UL\")\n ) {\n return parseDefaultProps(element);\n }\n\n return undefined;\n },\n // As `li` elements can contain multiple paragraphs, we need to merge their contents\n // into a single one so that ProseMirror can parse everything correctly.\n parseContent: ({ el, schema }) =>\n getListItemContent(el, schema, \"bulletListItem\"),\n render() {\n // We use a <p> tag, because for <li> tags we'd need a <ul> element to put\n // them in to be semantically correct, which we can't have due to the\n // schema.\n const dom = document.createElement(\"p\");\n\n return {\n dom,\n contentDOM: dom,\n };\n },\n toExternalHTML(block) {\n const li = document.createElement(\"li\");\n const p = document.createElement(\"p\");\n addDefaultPropsExternalHTML(block.props, li);\n li.appendChild(p);\n\n return {\n dom: li,\n contentDOM: p,\n };\n },\n },\n [\n createBlockNoteExtension({\n key: \"bullet-list-item-shortcuts\",\n keyboardShortcuts: {\n Enter: ({ editor }) => {\n return handleEnter(editor, \"bulletListItem\");\n },\n \"Mod-Shift-8\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"bulletListItem\",\n props: {},\n });\n return true;\n },\n },\n inputRules: [\n {\n find: new RegExp(`^[-+*]\\\\s$`),\n replace({ editor }) {\n const blockInfo = getBlockInfoFromSelection(\n editor.prosemirrorState,\n );\n\n if (blockInfo.blockNoteType === \"heading\") {\n return;\n }\n return {\n type: \"bulletListItem\",\n props: {},\n };\n },\n },\n ],\n }),\n ],\n);\n","import { createBlockNoteExtension } from \"../../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../../defaultProps.js\";\nimport { handleEnter } from \"../../utils/listItemEnterHandler.js\";\nimport { getListItemContent } from \"../getListItemContent.js\";\n\nexport type CheckListItemBlockConfig = ReturnType<\n typeof createCheckListItemConfig\n>;\n\nexport const createCheckListItemConfig = createBlockConfig(\n () =>\n ({\n type: \"checkListItem\" as const,\n propSchema: {\n ...defaultProps,\n checked: { default: false, type: \"boolean\" },\n },\n content: \"inline\",\n }) as const,\n);\n\nexport const createCheckListItemBlockSpec = createBlockSpec(\n createCheckListItemConfig,\n {\n meta: {\n isolating: false,\n },\n parse(element) {\n if (element.tagName === \"input\") {\n // Ignore if we already parsed an ancestor list item to avoid double-parsing.\n if (element.closest(\"[data-content-type]\") || element.closest(\"li\")) {\n return undefined;\n }\n\n if ((element as HTMLInputElement).type === \"checkbox\") {\n return { checked: (element as HTMLInputElement).checked };\n }\n return undefined;\n }\n if (element.tagName !== \"LI\") {\n return undefined;\n }\n\n const parent = element.parentElement;\n\n if (parent === null) {\n return undefined;\n }\n\n if (\n parent.tagName === \"UL\" ||\n (parent.tagName === \"DIV\" && parent.parentElement?.tagName === \"UL\")\n ) {\n const checkbox =\n (element.querySelector(\"input[type=checkbox]\") as HTMLInputElement) ||\n null;\n\n if (checkbox === null) {\n return undefined;\n }\n\n return { ...parseDefaultProps(element), checked: checkbox.checked };\n }\n\n return;\n },\n // As `li` elements can contain multiple paragraphs, we need to merge their contents\n // into a single one so that ProseMirror can parse everything correctly.\n parseContent: ({ el, schema }) =>\n getListItemContent(el, schema, \"checkListItem\"),\n render(block, editor) {\n const dom = document.createDocumentFragment();\n\n const checkbox = document.createElement(\"input\");\n checkbox.type = \"checkbox\";\n checkbox.checked = block.props.checked;\n if (block.props.checked) {\n checkbox.setAttribute(\"checked\", \"\");\n }\n checkbox.addEventListener(\"change\", () => {\n editor.updateBlock(block, { props: { checked: !block.props.checked } });\n });\n // We use a <p> tag, because for <li> tags we'd need a <ul> element to put\n // them in to be semantically correct, which we can't have due to the\n // schema.\n const paragraph = document.createElement(\"p\");\n\n dom.appendChild(checkbox);\n dom.appendChild(paragraph);\n\n return {\n dom,\n contentDOM: paragraph,\n };\n },\n toExternalHTML(block) {\n const dom = document.createElement(\"li\");\n const checkbox = document.createElement(\"input\");\n checkbox.type = \"checkbox\";\n checkbox.checked = block.props.checked;\n if (block.props.checked) {\n checkbox.setAttribute(\"checked\", \"\");\n }\n // We use a <p> tag, because for <li> tags we'd need a <ul> element to put\n // them in to be semantically correct, which we can't have due to the\n // schema.\n const paragraph = document.createElement(\"p\");\n addDefaultPropsExternalHTML(block.props, dom);\n\n dom.appendChild(checkbox);\n dom.appendChild(paragraph);\n\n return {\n dom,\n contentDOM: paragraph,\n };\n },\n runsBefore: [\"bulletListItem\"],\n },\n [\n createBlockNoteExtension({\n key: \"check-list-item-shortcuts\",\n keyboardShortcuts: {\n Enter: ({ editor }) => {\n return handleEnter(editor, \"checkListItem\");\n },\n \"Mod-Shift-9\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"checkListItem\",\n props: {},\n });\n return true;\n },\n },\n inputRules: [\n {\n find: new RegExp(`\\\\[\\\\s*\\\\]\\\\s$`),\n replace() {\n return {\n type: \"checkListItem\",\n props: {\n checked: false,\n },\n content: [],\n };\n },\n },\n {\n find: new RegExp(`\\\\[[Xx]\\\\]\\\\s$`),\n replace() {\n return {\n type: \"checkListItem\",\n props: {\n checked: true,\n },\n };\n },\n },\n ],\n }),\n ],\n);\n","import type { Node } from \"@tiptap/pm/model\";\nimport type { Transaction } from \"@tiptap/pm/state\";\nimport { Plugin, PluginKey } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\n\nimport { getBlockInfo } from \"../../../api/getBlockInfoFromPos.js\";\n\n// Loosely based on https://github.com/ueberdosis/tiptap/blob/7ac01ef0b816a535e903b5ca92492bff110a71ae/packages/extension-mathematics/src/MathematicsPlugin.ts (MIT)\n\ntype DecoSpec = {\n index: number;\n isFirst: boolean;\n hasStart: boolean;\n side: number;\n};\n\ntype Deco = Omit<Decoration, \"spec\"> & { spec: DecoSpec };\n\n/**\n * Calculate the index for a numbered list item based on its position and previous siblings\n */\nfunction calculateListItemIndex(\n node: Node,\n pos: number,\n tr: Transaction,\n map: Map<Node, number>,\n): { index: number; isFirst: boolean; hasStart: boolean } {\n let index: number = node.firstChild!.attrs[\"start\"] || 1;\n let isFirst = true;\n const hasStart = !!node.firstChild!.attrs[\"start\"];\n\n const blockInfo = getBlockInfo({\n posBeforeNode: pos,\n node,\n });\n\n if (!blockInfo.isBlockContainer) {\n throw new Error(\"impossible\");\n }\n\n // Check if this block is the start of a new ordered list\n const prevBlock = tr.doc.resolve(blockInfo.bnBlock.beforePos).nodeBefore;\n const prevBlockIndex = prevBlock ? map.get(prevBlock) : undefined;\n\n if (prevBlockIndex !== undefined) {\n index = prevBlockIndex + 1;\n isFirst = false;\n } else if (prevBlock) {\n // Because we only check the affected ranges, we may need to walk backwards to find the previous block's index\n // We can't just rely on the map, because the map is reset every `apply` call\n const prevBlockInfo = getBlockInfo({\n posBeforeNode: blockInfo.bnBlock.beforePos - prevBlock.nodeSize,\n node: prevBlock,\n });\n\n const isPrevBlockOrderedListItem =\n prevBlockInfo.blockNoteType === \"numberedListItem\";\n if (isPrevBlockOrderedListItem) {\n // recurse to get the index of the previous block\n const itemIndex = calculateListItemIndex(\n prevBlock,\n blockInfo.bnBlock.beforePos - prevBlock.nodeSize,\n tr,\n map,\n );\n index = itemIndex.index + 1;\n isFirst = false;\n }\n }\n // Note: we set the map late, so that when we recurse, we can rely on the map to get the previous block's index in one lookup\n map.set(node, index);\n\n return { index, isFirst, hasStart };\n}\n\n/**\n * Get the decorations for the current state based on the previous state,\n * and the transaction that was applied to get to the current state\n */\nfunction getDecorations(\n tr: Transaction,\n previousPluginState: { decorations: DecorationSet },\n) {\n const map = new Map<Node, number>();\n\n const nextDecorationSet = previousPluginState.decorations.map(\n tr.mapping,\n tr.doc,\n );\n const decorationsToAdd = [] as Deco[];\n\n tr.doc.nodesBetween(0, tr.doc.nodeSize - 2, (node, pos) => {\n if (\n node.type.name === \"blockContainer\" &&\n node.firstChild!.type.name === \"numberedListItem\"\n ) {\n const { index, isFirst, hasStart } = calculateListItemIndex(\n node,\n pos,\n tr,\n map,\n );\n\n // Check if decoration already exists with the same properties (for perf reasons)\n const existingDecorations = nextDecorationSet.find(\n pos,\n pos + node.nodeSize,\n (deco: DecoSpec) =>\n deco.index === index &&\n deco.isFirst === isFirst &&\n deco.hasStart === hasStart,\n );\n\n if (existingDecorations.length === 0) {\n const blockNode = tr.doc.nodeAt(pos + 1);\n // Create a widget decoration to display the index\n decorationsToAdd.push(\n // move in by 1 to account for the block container\n Decoration.node(pos + 1, pos + 1 + blockNode!.nodeSize, {\n \"data-index\": index.toString(),\n }),\n );\n }\n }\n });\n\n // Remove any decorations that exist at the same position, they will be replaced by the new decorations\n const decorationsToRemove = decorationsToAdd.flatMap((deco) =>\n nextDecorationSet.find(deco.from, deco.to),\n );\n\n return {\n decorations: nextDecorationSet\n // Remove existing decorations that are going to be replaced\n .remove(decorationsToRemove)\n // Add any new decorations\n .add(tr.doc, decorationsToAdd),\n };\n}\n\n/**\n * This plugin adds decorations to numbered list items to display their index.\n */\nexport const NumberedListIndexingDecorationPlugin = () => {\n return new Plugin<{ decorations: DecorationSet }>({\n key: new PluginKey(\"numbered-list-indexing-decorations\"),\n\n state: {\n init(_config, state) {\n // We create an empty transaction to get the decorations for the initial state based on the initial content\n return getDecorations(state.tr, {\n decorations: DecorationSet.empty,\n });\n },\n apply(tr, previousPluginState) {\n if (\n !tr.docChanged &&\n !tr.selectionSet &&\n previousPluginState.decorations\n ) {\n // Just reuse the existing decorations, since nothing should have changed\n return previousPluginState;\n }\n return getDecorations(tr, previousPluginState);\n },\n },\n\n props: {\n decorations(state) {\n return this.getState(state)?.decorations ?? DecorationSet.empty;\n },\n },\n });\n};\n","import { getBlockInfoFromSelection } from \"../../../api/getBlockInfoFromPos.js\";\nimport { createBlockNoteExtension } from \"../../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../../defaultProps.js\";\nimport { handleEnter } from \"../../utils/listItemEnterHandler.js\";\nimport { getListItemContent } from \"../getListItemContent.js\";\nimport { NumberedListIndexingDecorationPlugin } from \"./IndexingPlugin.js\";\n\nexport type NumberedListItemBlockConfig = ReturnType<\n typeof createNumberedListItemBlockConfig\n>;\n\nexport const createNumberedListItemBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"numberedListItem\" as const,\n propSchema: {\n ...defaultProps,\n start: { default: undefined, type: \"number\" } as const,\n },\n content: \"inline\",\n }) as const,\n);\n\nexport const createNumberedListItemBlockSpec = createBlockSpec(\n createNumberedListItemBlockConfig,\n {\n meta: {\n isolating: false,\n },\n parse(element) {\n if (element.tagName !== \"LI\") {\n return undefined;\n }\n\n const parent = element.parentElement;\n\n if (parent === null) {\n return undefined;\n }\n\n if (\n parent.tagName === \"OL\" ||\n (parent.tagName === \"DIV\" && parent.parentElement?.tagName === \"OL\")\n ) {\n const startIndex = parseInt(parent.getAttribute(\"start\") || \"1\");\n\n const defaultProps = parseDefaultProps(element);\n\n if (element.previousElementSibling || startIndex === 1) {\n return defaultProps;\n }\n\n return {\n ...defaultProps,\n start: startIndex,\n };\n }\n\n return undefined;\n },\n // As `li` elements can contain multiple paragraphs, we need to merge their contents\n // into a single one so that ProseMirror can parse everything correctly.\n parseContent: ({ el, schema }) =>\n getListItemContent(el, schema, \"numberedListItem\"),\n render() {\n // We use a <p> tag, because for <li> tags we'd need a <ul> element to put\n // them in to be semantically correct, which we can't have due to the\n // schema.\n const dom = document.createElement(\"p\");\n\n return {\n dom,\n contentDOM: dom,\n };\n },\n toExternalHTML(block) {\n const li = document.createElement(\"li\");\n const p = document.createElement(\"p\");\n addDefaultPropsExternalHTML(block.props, li);\n li.appendChild(p);\n\n return {\n dom: li,\n contentDOM: p,\n };\n },\n },\n [\n createBlockNoteExtension({\n key: \"numbered-list-item-shortcuts\",\n inputRules: [\n {\n find: new RegExp(`^(\\\\d+)\\\\.\\\\s$`),\n replace({ match, editor }) {\n const blockInfo = getBlockInfoFromSelection(\n editor.prosemirrorState,\n );\n\n if (blockInfo.blockNoteType === \"heading\") {\n return;\n }\n const start = parseInt(match[1]);\n return {\n type: \"numberedListItem\",\n props: {\n start: start !== 1 ? start : undefined,\n },\n };\n },\n },\n ],\n keyboardShortcuts: {\n Enter: ({ editor }) => {\n return handleEnter(editor, \"numberedListItem\");\n },\n \"Mod-Shift-7\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"numberedListItem\",\n props: {},\n });\n return true;\n },\n },\n plugins: [NumberedListIndexingDecorationPlugin()],\n }),\n ],\n);\n","import { createBlockNoteExtension } from \"../../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n} from \"../../defaultProps.js\";\nimport { createToggleWrapper } from \"../../ToggleWrapper/createToggleWrapper.js\";\nimport { handleEnter } from \"../../utils/listItemEnterHandler.js\";\n\nexport type ToggleListItemBlockConfig = ReturnType<\n typeof createToggleListItemBlockConfig\n>;\n\nexport const createToggleListItemBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"toggleListItem\" as const,\n propSchema: {\n ...defaultProps,\n },\n content: \"inline\" as const,\n }) as const,\n);\n\nexport const createToggleListItemBlockSpec = createBlockSpec(\n createToggleListItemBlockConfig,\n {\n meta: {\n isolating: false,\n },\n render(block, editor) {\n const paragraphEl = document.createElement(\"p\");\n const toggleWrapper = createToggleWrapper(\n block as any,\n editor,\n paragraphEl,\n );\n return { ...toggleWrapper, contentDOM: paragraphEl };\n },\n toExternalHTML(block) {\n const li = document.createElement(\"li\");\n const p = document.createElement(\"p\");\n addDefaultPropsExternalHTML(block.props, li);\n li.appendChild(p);\n\n return {\n dom: li,\n contentDOM: p,\n };\n },\n },\n [\n createBlockNoteExtension({\n key: \"toggle-list-item-shortcuts\",\n keyboardShortcuts: {\n Enter: ({ editor }) => {\n return handleEnter(editor, \"toggleListItem\");\n },\n \"Mod-Shift-6\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"toggleListItem\",\n props: {},\n });\n return true;\n },\n },\n }),\n ],\n);\n","import {\n BlockSchema,\n createBlockConfig,\n createBlockSpec,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\nimport { BlockNoteSchema } from \"../BlockNoteSchema.js\";\n\nexport type PageBreakBlockConfig = ReturnType<\n typeof createPageBreakBlockConfig\n>;\n\nexport const createPageBreakBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"pageBreak\" as const,\n propSchema: {},\n content: \"none\",\n }) as const,\n);\n\nexport const createPageBreakBlockSpec = createBlockSpec(\n createPageBreakBlockConfig,\n {\n parse(element) {\n if (\n element.tagName === \"DIV\" &&\n element.hasAttribute(\"data-page-break\")\n ) {\n return {};\n }\n\n return undefined;\n },\n render() {\n const pageBreak = document.createElement(\"div\");\n\n pageBreak.setAttribute(\"data-page-break\", \"\");\n\n return {\n dom: pageBreak,\n };\n },\n toExternalHTML() {\n const pageBreak = document.createElement(\"div\");\n\n pageBreak.setAttribute(\"data-page-break\", \"\");\n\n return {\n dom: pageBreak,\n };\n },\n },\n);\n\n/**\n * Adds page break support to the given schema.\n */\nexport const withPageBreak = <\n B extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n schema: BlockNoteSchema<B, I, S>,\n) => {\n return schema.extend({\n blockSpecs: {\n pageBreak: createPageBreakBlockSpec(),\n },\n });\n};\n","import { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../defaultProps.js\";\n\nexport type ParagraphBlockConfig = ReturnType<\n typeof createParagraphBlockConfig\n>;\n\nexport const createParagraphBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"paragraph\" as const,\n propSchema: defaultProps,\n content: \"inline\" as const,\n }) as const,\n);\n\nexport const createParagraphBlockSpec = createBlockSpec(\n createParagraphBlockConfig,\n {\n meta: {\n isolating: false,\n },\n parse: (e) => {\n if (e.tagName !== \"P\") {\n return undefined;\n }\n\n // Edge case for things like images directly inside paragraph.\n if (!e.textContent?.trim()) {\n return undefined;\n }\n\n return parseDefaultProps(e);\n },\n render: () => {\n const dom = document.createElement(\"p\");\n return {\n dom,\n contentDOM: dom,\n };\n },\n toExternalHTML: (block) => {\n const dom = document.createElement(\"p\");\n addDefaultPropsExternalHTML(block.props, dom);\n return {\n dom,\n contentDOM: dom,\n };\n },\n runsBefore: [\"default\"],\n },\n [\n createBlockNoteExtension({\n key: \"paragraph-shortcuts\",\n keyboardShortcuts: {\n \"Mod-Alt-0\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"paragraph\",\n props: {},\n });\n return true;\n },\n },\n }),\n ],\n);\n","import { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport {\n addDefaultPropsExternalHTML,\n defaultProps,\n parseDefaultProps,\n} from \"../defaultProps.js\";\n\nexport type QuoteBlockConfig = ReturnType<typeof createQuoteBlockConfig>;\n\nexport const createQuoteBlockConfig = createBlockConfig(\n () =>\n ({\n type: \"quote\" as const,\n propSchema: {\n backgroundColor: defaultProps.backgroundColor,\n textColor: defaultProps.textColor,\n },\n content: \"inline\" as const,\n }) as const,\n);\n\nexport const createQuoteBlockSpec = createBlockSpec(\n createQuoteBlockConfig,\n {\n meta: {\n isolating: false,\n },\n parse(element) {\n if (element.tagName === \"BLOCKQUOTE\") {\n const { backgroundColor, textColor } = parseDefaultProps(element);\n\n return { backgroundColor, textColor };\n }\n\n return undefined;\n },\n render() {\n const quote = document.createElement(\"blockquote\");\n\n return {\n dom: quote,\n contentDOM: quote,\n };\n },\n toExternalHTML(block) {\n const quote = document.createElement(\"blockquote\");\n addDefaultPropsExternalHTML(block.props, quote);\n\n return {\n dom: quote,\n contentDOM: quote,\n };\n },\n },\n [\n createBlockNoteExtension({\n key: \"quote-block-shortcuts\",\n keyboardShortcuts: {\n \"Mod-Alt-q\": ({ editor }) => {\n const cursorPosition = editor.getTextCursorPosition();\n\n if (\n editor.schema.blockSchema[cursorPosition.block.type].content !==\n \"inline\"\n ) {\n return false;\n }\n\n editor.updateBlock(cursorPosition.block, {\n type: \"quote\",\n props: {},\n });\n return true;\n },\n },\n inputRules: [\n {\n find: new RegExp(`^>\\\\s$`),\n replace() {\n return {\n type: \"quote\",\n props: {},\n };\n },\n },\n ],\n }),\n ],\n);\n","import { callOrReturn, Extension, getExtensionField } from \"@tiptap/core\";\nimport { columnResizing, goToNextCell, tableEditing } from \"prosemirror-tables\";\n\nexport const RESIZE_MIN_WIDTH = 35;\nexport const EMPTY_CELL_WIDTH = 120;\nexport const EMPTY_CELL_HEIGHT = 31;\n\nexport const TableExtension = Extension.create({\n name: \"BlockNoteTableExtension\",\n\n addProseMirrorPlugins: () => {\n return [\n columnResizing({\n cellMinWidth: RESIZE_MIN_WIDTH,\n defaultCellMinWidth: EMPTY_CELL_WIDTH,\n // We set this to null as we implement our own node view in the table\n // block content. This node view is the same as what's used by default,\n // but is wrapped in a `blockContent` HTML element.\n View: null,\n }),\n tableEditing(),\n ];\n },\n\n addKeyboardShortcuts() {\n return {\n // Makes enter create a new line within the cell.\n Enter: () => {\n if (\n this.editor.state.selection.empty &&\n this.editor.state.selection.$head.parent.type.name ===\n \"tableParagraph\"\n ) {\n this.editor.commands.insertContent({ type: \"hardBreak\" });\n\n return true;\n }\n\n return false;\n },\n // Ensures that backspace won't delete the table if the text cursor is at\n // the start of a cell and the selection is empty.\n Backspace: () => {\n const selection = this.editor.state.selection;\n const selectionIsEmpty = selection.empty;\n const selectionIsAtStartOfNode = selection.$head.parentOffset === 0;\n const selectionIsInTableParagraphNode =\n selection.$head.node().type.name === \"tableParagraph\";\n\n return (\n selectionIsEmpty &&\n selectionIsAtStartOfNode &&\n selectionIsInTableParagraphNode\n );\n },\n // Enables navigating cells using the tab key.\n Tab: () => {\n return this.editor.commands.command(({ state, dispatch, view }) =>\n goToNextCell(1)(state, dispatch, view),\n );\n },\n \"Shift-Tab\": () => {\n return this.editor.commands.command(({ state, dispatch, view }) =>\n goToNextCell(-1)(state, dispatch, view),\n );\n },\n };\n },\n\n extendNodeSchema(extension) {\n const context = {\n name: extension.name,\n options: extension.options,\n storage: extension.storage,\n };\n\n return {\n tableRole: callOrReturn(\n getExtensionField(extension, \"tableRole\", context),\n ),\n };\n },\n});\n","import { Node, mergeAttributes } from \"@tiptap/core\";\nimport { DOMParser, Fragment, Node as PMNode, Schema } from \"prosemirror-model\";\nimport { CellSelection, TableView } from \"prosemirror-tables\";\nimport { NodeView } from \"prosemirror-view\";\nimport { createBlockNoteExtension } from \"../../editor/BlockNoteExtension.js\";\nimport {\n BlockConfig,\n createBlockSpecFromTiptapNode,\n TableContent,\n} from \"../../schema/index.js\";\nimport { mergeCSSClasses } from \"../../util/browser.js\";\nimport { createDefaultBlockDOMOutputSpec } from \"../defaultBlockHelpers.js\";\nimport { defaultProps } from \"../defaultProps.js\";\nimport { EMPTY_CELL_WIDTH, TableExtension } from \"./TableExtension.js\";\n\nexport const tablePropSchema = {\n textColor: defaultProps.textColor,\n};\n\nconst TiptapTableHeader = Node.create<{\n HTMLAttributes: Record<string, any>;\n}>({\n name: \"tableHeader\",\n\n addOptions() {\n return {\n HTMLAttributes: {},\n };\n },\n\n /**\n * We allow table headers and cells to have multiple tableContent nodes because\n * when merging cells, prosemirror-tables will concat the contents of the cells naively.\n * This would cause that content to overflow into other cells when prosemirror tries to enforce the cell structure.\n *\n * So, we manually fix this up when reading back in the `nodeToBlock` and only ever place a single tableContent back into the cell.\n */\n content: \"tableContent+\",\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: (element) => {\n const colwidth = element.getAttribute(\"colwidth\");\n const value = colwidth\n ? colwidth.split(\",\").map((width) => parseInt(width, 10))\n : null;\n\n return value;\n },\n },\n };\n },\n\n tableRole: \"header_cell\",\n\n isolating: true,\n\n parseHTML() {\n return [\n {\n tag: \"th\",\n // As `th` elements can contain multiple paragraphs, we need to merge their contents\n // into a single one so that ProseMirror can parse everything correctly.\n getContent: (node, schema) =>\n parseTableContent(node as HTMLElement, schema),\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"th\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n});\n\nconst TiptapTableCell = Node.create<{\n HTMLAttributes: Record<string, any>;\n}>({\n name: \"tableCell\",\n\n addOptions() {\n return {\n HTMLAttributes: {},\n };\n },\n\n content: \"tableContent+\",\n\n addAttributes() {\n return {\n colspan: {\n default: 1,\n },\n rowspan: {\n default: 1,\n },\n colwidth: {\n default: null,\n parseHTML: (element) => {\n const colwidth = element.getAttribute(\"colwidth\");\n const value = colwidth\n ? colwidth.split(\",\").map((width) => parseInt(width, 10))\n : null;\n\n return value;\n },\n },\n };\n },\n\n tableRole: \"cell\",\n\n isolating: true,\n\n parseHTML() {\n return [\n {\n tag: \"td\",\n // As `td` elements can contain multiple paragraphs, we need to merge their contents\n // into a single one so that ProseMirror can parse everything correctly.\n getContent: (node, schema) =>\n parseTableContent(node as HTMLElement, schema),\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"td\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n});\n\nconst TiptapTableNode = Node.create({\n name: \"table\",\n content: \"tableRow+\",\n group: \"blockContent\",\n tableRole: \"table\",\n\n marks: \"deletion insertion modification\",\n isolating: true,\n\n parseHTML() {\n return [\n {\n tag: \"table\",\n },\n ];\n },\n\n renderHTML({ node, HTMLAttributes }) {\n const domOutputSpec = createDefaultBlockDOMOutputSpec(\n this.name,\n \"table\",\n {\n ...(this.options.domAttributes?.blockContent || {}),\n ...HTMLAttributes,\n },\n this.options.domAttributes?.inlineContent || {},\n );\n\n // Need to manually add colgroup element\n const colGroup = document.createElement(\"colgroup\");\n for (const tableCell of node.children[0].children) {\n const colWidths: null | (number | undefined)[] =\n tableCell.attrs[\"colwidth\"];\n\n if (colWidths) {\n for (const colWidth of tableCell.attrs[\"colwidth\"]) {\n const col = document.createElement(\"col\");\n if (colWidth) {\n col.style = `width: ${colWidth}px`;\n }\n\n colGroup.appendChild(col);\n }\n } else {\n colGroup.appendChild(document.createElement(\"col\"));\n }\n }\n\n domOutputSpec.dom.firstChild?.appendChild(colGroup);\n\n return domOutputSpec;\n },\n\n // This node view is needed for the `columnResizing` plugin. By default, the\n // plugin adds its own node view, which overrides how the node is rendered vs\n // `renderHTML`. This means that the wrapping `blockContent` HTML element is\n // no longer rendered. The `columnResizing` plugin uses the `TableView` as its\n // default node view. `BlockNoteTableView` extends it by wrapping it in a\n // `blockContent` element, so the DOM structure is consistent with other block\n // types.\n addNodeView() {\n return ({ node, HTMLAttributes }) => {\n class BlockNoteTableView extends TableView {\n constructor(\n public node: PMNode,\n public cellMinWidth: number,\n public blockContentHTMLAttributes: Record<string, string>,\n ) {\n super(node, cellMinWidth);\n\n const blockContent = document.createElement(\"div\");\n blockContent.className = mergeCSSClasses(\n \"bn-block-content\",\n blockContentHTMLAttributes.class,\n );\n blockContent.setAttribute(\"data-content-type\", \"table\");\n for (const [attribute, value] of Object.entries(\n blockContentHTMLAttributes,\n )) {\n if (attribute !== \"class\") {\n blockContent.setAttribute(attribute, value);\n }\n }\n\n const tableWrapper = this.dom;\n\n const tableWrapperInner = document.createElement(\"div\");\n tableWrapperInner.className = \"tableWrapper-inner\";\n tableWrapperInner.appendChild(tableWrapper.firstChild!);\n\n tableWrapper.appendChild(tableWrapperInner);\n\n blockContent.appendChild(tableWrapper);\n const floatingContainer = document.createElement(\"div\");\n floatingContainer.className = \"table-widgets-container\";\n floatingContainer.style.position = \"relative\";\n tableWrapper.appendChild(floatingContainer);\n\n this.dom = blockContent;\n }\n\n ignoreMutation(record: MutationRecord): boolean {\n return (\n !(record.target as HTMLElement).closest(\".tableWrapper-inner\") ||\n super.ignoreMutation(record)\n );\n }\n }\n\n return new BlockNoteTableView(node, EMPTY_CELL_WIDTH, {\n ...(this.options.domAttributes?.blockContent || {}),\n ...HTMLAttributes,\n }) as NodeView; // needs cast, tiptap types (wrongly) doesn't support return tableview here\n };\n },\n});\n\nconst TiptapTableParagraph = Node.create({\n name: \"tableParagraph\",\n group: \"tableContent\",\n content: \"inline*\",\n\n parseHTML() {\n return [\n {\n tag: \"p\",\n getAttrs: (element) => {\n if (typeof element === \"string\" || !element.textContent) {\n return false;\n }\n\n // Only parse in internal HTML.\n if (!element.closest(\"[data-content-type]\")) {\n return false;\n }\n\n const parent = element.parentElement;\n\n if (parent === null) {\n return false;\n }\n\n if (parent.tagName === \"TD\" || parent.tagName === \"TH\") {\n return {};\n }\n\n return false;\n },\n node: \"tableParagraph\",\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\"p\", HTMLAttributes, 0];\n },\n});\n\n/**\n * This extension allows you to create table rows.\n * @see https://www.tiptap.dev/api/nodes/table-row\n */\nconst TiptapTableRow = Node.create<{\n HTMLAttributes: Record<string, any>;\n}>({\n name: \"tableRow\",\n\n addOptions() {\n return {\n HTMLAttributes: {},\n };\n },\n\n content: \"(tableCell | tableHeader)+\",\n\n tableRole: \"row\",\n marks: \"deletion insertion modification\",\n parseHTML() {\n return [{ tag: \"tr\" }];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"tr\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n 0,\n ];\n },\n});\n\n/*\n * This will flatten a node's content to fit into a table cell's paragraph.\n */\nfunction parseTableContent(node: HTMLElement, schema: Schema) {\n const parser = DOMParser.fromSchema(schema);\n\n // This will parse the content of the table paragraph as though it were a blockGroup.\n // Resulting in a structure like:\n // <blockGroup>\n // <blockContainer>\n // <p>Hello</p>\n // </blockContainer>\n // <blockContainer>\n // <p>Hello</p>\n // </blockContainer>\n // </blockGroup>\n const parsedContent = parser.parse(node, {\n topNode: schema.nodes.blockGroup.create(),\n });\n const extractedContent: PMNode[] = [];\n\n // Try to extract any content within the blockContainer.\n parsedContent.content.descendants((child) => {\n // As long as the child is an inline node, we can append it to the fragment.\n if (child.isInline) {\n // And append it to the fragment\n extractedContent.push(child);\n return false;\n }\n\n return undefined;\n });\n\n return Fragment.fromArray(extractedContent);\n}\n\nexport type TableBlockConfig = BlockConfig<\n \"table\",\n {\n textColor: {\n default: \"default\";\n };\n },\n \"table\"\n>;\n\nexport const createTableBlockSpec = () =>\n createBlockSpecFromTiptapNode(\n { node: TiptapTableNode, type: \"table\", content: \"table\" },\n tablePropSchema,\n [\n createBlockNoteExtension({\n key: \"table-extensions\",\n tiptapExtensions: [\n TableExtension,\n TiptapTableParagraph,\n TiptapTableHeader,\n TiptapTableCell,\n TiptapTableRow,\n ],\n }),\n // Extension for keyboard shortcut which deletes the table if it's empty\n // and all cells are selected. Uses a separate extension as it needs\n // priority over keyboard handlers in the `TableExtension`'s\n // `tableEditing` plugin.\n createBlockNoteExtension({\n key: \"table-keyboard-delete\",\n keyboardShortcuts: {\n Backspace: ({ editor }) => {\n if (!(editor.prosemirrorState.selection instanceof CellSelection)) {\n return false;\n }\n\n const block = editor.getTextCursorPosition().block;\n const content = block.content as TableContent<any, any>;\n\n let numCells = 0;\n for (const row of content.rows) {\n for (const cell of row.cells) {\n // Returns `false` if any cell isn't empty.\n if (\n (\"type\" in cell && cell.content.length > 0) ||\n (!(\"type\" in cell) && cell.length > 0)\n ) {\n return false;\n }\n\n numCells++;\n }\n }\n\n // Need to use ProseMirror API to check number of selected cells.\n let selectionNumCells = 0;\n editor.prosemirrorState.selection.forEachCell(() => {\n selectionNumCells++;\n });\n\n if (selectionNumCells < numCells) {\n return false;\n }\n\n editor.transact(() => {\n const selectionBlock =\n editor.getPrevBlock(block) || editor.getNextBlock(block);\n if (selectionBlock) {\n editor.setTextCursorPosition(block);\n }\n\n editor.removeBlocks([block]);\n });\n\n return true;\n },\n },\n }),\n ],\n );\n\n// We need to declare this here because we aren't using the table extensions from tiptap, so the types are not automatically inferred.\ndeclare module \"@tiptap/core\" {\n interface NodeConfig {\n tableRole?: string;\n }\n}\n","export const parseVideoElement = (videoElement: HTMLVideoElement) => {\n const url = videoElement.src || undefined;\n const previewWidth = videoElement.width || undefined;\n\n return { url, previewWidth };\n};\n","import { createBlockConfig, createBlockSpec } from \"../../schema/index.js\";\nimport { defaultProps, parseDefaultProps } from \"../defaultProps.js\";\nimport { parseFigureElement } from \"../File/helpers/parse/parseFigureElement.js\";\nimport { createResizableFileBlockWrapper } from \"../File/helpers/render/createResizableFileBlockWrapper.js\";\nimport { createFigureWithCaption } from \"../File/helpers/toExternalHTML/createFigureWithCaption.js\";\nimport { createLinkWithCaption } from \"../File/helpers/toExternalHTML/createLinkWithCaption.js\";\nimport { parseVideoElement } from \"./parseVideoElement.js\";\n\nexport const FILE_VIDEO_ICON_SVG =\n '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z\"></path></svg>';\n\nexport interface VideoOptions {\n icon?: string;\n}\n\nexport type VideoBlockConfig = ReturnType<typeof createVideoBlockConfig>;\n\nexport const createVideoBlockConfig = createBlockConfig(\n (_ctx: VideoOptions) => ({\n type: \"video\" as const,\n propSchema: {\n textAlignment: defaultProps.textAlignment,\n backgroundColor: defaultProps.backgroundColor,\n name: { default: \"\" as const },\n url: { default: \"\" as const },\n caption: { default: \"\" as const },\n showPreview: { default: true },\n previewWidth: { default: undefined, type: \"number\" as const },\n },\n content: \"none\" as const,\n }),\n);\n\nexport const videoParse = (_config: VideoOptions) => (element: HTMLElement) => {\n if (element.tagName === \"VIDEO\") {\n // Ignore if parent figure has already been parsed.\n if (element.closest(\"figure\")) {\n return undefined;\n }\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseVideoElement(element as HTMLVideoElement),\n backgroundColor,\n };\n }\n\n if (element.tagName === \"FIGURE\") {\n const parsedFigure = parseFigureElement(element, \"video\");\n if (!parsedFigure) {\n return undefined;\n }\n\n const { targetElement, caption } = parsedFigure;\n\n const { backgroundColor } = parseDefaultProps(element);\n\n return {\n ...parseVideoElement(targetElement as HTMLVideoElement),\n backgroundColor,\n caption,\n };\n }\n\n return undefined;\n};\n\nexport const createVideoBlockSpec = createBlockSpec(\n createVideoBlockConfig,\n (config) => ({\n meta: {\n fileBlockAccept: [\"video/*\"],\n },\n parse: videoParse(config),\n render(block, editor) {\n const icon = document.createElement(\"div\");\n icon.innerHTML = config.icon ?? FILE_VIDEO_ICON_SVG;\n\n const videoWrapper = document.createElement(\"div\");\n videoWrapper.className = \"bn-visual-media-wrapper\";\n\n const video = document.createElement(\"video\");\n video.className = \"bn-visual-media\";\n if (editor.resolveFileUrl) {\n editor.resolveFileUrl(block.props.url).then((downloadUrl) => {\n video.src = downloadUrl;\n });\n } else {\n video.src = block.props.url;\n }\n video.controls = true;\n video.contentEditable = \"false\";\n video.draggable = false;\n video.width = block.props.previewWidth;\n videoWrapper.appendChild(video);\n\n return createResizableFileBlockWrapper(\n block,\n editor,\n { dom: videoWrapper },\n videoWrapper,\n icon.firstElementChild as HTMLElement,\n );\n },\n toExternalHTML(block) {\n if (!block.props.url) {\n const div = document.createElement(\"p\");\n div.textContent = \"Add video\";\n\n return {\n dom: div,\n };\n }\n\n let video;\n if (block.props.showPreview) {\n video = document.createElement(\"video\");\n video.src = block.props.url;\n if (block.props.previewWidth) {\n video.width = block.props.previewWidth;\n }\n } else {\n video = document.createElement(\"a\");\n video.href = block.props.url;\n video.textContent = block.props.name || block.props.url;\n }\n\n if (block.props.caption) {\n if (block.props.showPreview) {\n return createFigureWithCaption(video, block.props.caption);\n } else {\n return createLinkWithCaption(video, block.props.caption);\n }\n }\n\n return {\n dom: video,\n };\n },\n runsBefore: [\"file\"],\n }),\n);\n","/**\n * Uploads a file to tmpfiles.org and returns the URL to the uploaded file.\n *\n * @warning This function should only be used for development purposes, replace with your own backend!\n */\nexport const uploadToTmpFilesDotOrg_DEV_ONLY = async (\n file: File,\n): Promise<string> => {\n const body = new FormData();\n body.append(\"file\", file);\n\n const ret = await fetch(\"https://tmpfiles.org/api/v1/upload\", {\n method: \"POST\",\n body: body,\n });\n return (await ret.json()).data.url.replace(\n \"tmpfiles.org/\",\n \"tmpfiles.org/dl/\",\n );\n};\n","import { CellSelection } from \"prosemirror-tables\";\nimport type { BlockNoteEditor } from \"../editor/BlockNoteEditor.js\";\nimport { BlockConfig, PropSchema, PropSpec } from \"../schema/index.js\";\nimport { Block } from \"./defaultBlocks.js\";\nimport { Selection } from \"prosemirror-state\";\n\nexport function editorHasBlockWithType<\n BType extends string,\n Props extends\n | PropSchema\n | Record<string, \"boolean\" | \"number\" | \"string\">\n | undefined = undefined,\n>(\n editor: BlockNoteEditor<any, any, any>,\n blockType: BType,\n props?: Props,\n): editor is BlockNoteEditor<\n {\n [BT in BType]: Props extends PropSchema\n ? BlockConfig<BT, Props>\n : Props extends Record<string, \"boolean\" | \"number\" | \"string\">\n ? BlockConfig<\n BT,\n {\n [PN in keyof Props]: {\n default: undefined;\n type: Props[PN];\n values?: any[];\n };\n }\n >\n : BlockConfig<BT, PropSchema>;\n },\n any,\n any\n> {\n if (!(blockType in editor.schema.blockSpecs)) {\n return false;\n }\n\n if (!props) {\n return true;\n }\n\n for (const [propName, propSpec] of Object.entries(props)) {\n if (!(propName in editor.schema.blockSpecs[blockType].config.propSchema)) {\n return false;\n }\n\n if (typeof propSpec === \"string\") {\n if (\n editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .default !== undefined &&\n typeof editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .default !== propSpec\n ) {\n return false;\n }\n\n if (\n editor.schema.blockSpecs[blockType].config.propSchema[propName].type !==\n undefined &&\n editor.schema.blockSpecs[blockType].config.propSchema[propName].type !==\n propSpec\n ) {\n return false;\n }\n } else {\n if (\n editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .default !== propSpec.default\n ) {\n return false;\n }\n\n if (\n editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .default === undefined &&\n propSpec.default === undefined\n ) {\n if (\n editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .type !== propSpec.type\n ) {\n return false;\n }\n }\n\n if (\n typeof editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .values !== typeof propSpec.values\n ) {\n return false;\n }\n\n if (\n typeof editor.schema.blockSpecs[blockType].config.propSchema[propName]\n .values === \"object\" &&\n typeof propSpec.values === \"object\"\n ) {\n for (const value of propSpec.values) {\n if (\n !editor.schema.blockSpecs[blockType].config.propSchema[\n propName\n ].values.includes(value)\n ) {\n return false;\n }\n }\n }\n }\n }\n\n return true;\n}\n\nexport function blockHasType<\n BType extends string,\n Props extends\n | PropSchema\n | Record<string, \"boolean\" | \"number\" | \"string\">\n | undefined = undefined,\n>(\n block: Block<any, any, any>,\n editor: BlockNoteEditor<any, any, any>,\n blockType: BType,\n props?: Props,\n): block is Block<\n {\n [BT in BType]: Props extends PropSchema\n ? BlockConfig<BT, Props>\n : Props extends Record<string, \"boolean\" | \"number\" | \"string\">\n ? BlockConfig<\n BT,\n {\n [PN in keyof Props]: PropSpec<\n Props[PN] extends \"boolean\"\n ? boolean\n : Props[PN] extends \"number\"\n ? number\n : Props[PN] extends \"string\"\n ? string\n : never\n >;\n }\n >\n : BlockConfig<BT, PropSchema>;\n },\n any,\n any\n> {\n return (\n editorHasBlockWithType(editor, blockType, props) && block.type === blockType\n );\n}\n\nexport function isTableCellSelection(\n selection: Selection,\n): selection is CellSelection {\n return selection instanceof CellSelection;\n}\n","import { Block, PartialBlock } from \"../../blocks/defaultBlocks.js\";\nimport type { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\n\nimport { editorHasBlockWithType } from \"../../blocks/defaultBlockTypeGuards.js\";\nimport {\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n isStyledTextInlineContent,\n} from \"../../schema/index.js\";\nimport { formatKeyboardShortcut } from \"../../util/browser.js\";\nimport { DefaultSuggestionItem } from \"./DefaultSuggestionItem.js\";\n\n// Sets the editor's text cursor position to the next content editable block,\n// so either a block with inline content or a table. The last block is always a\n// paragraph, so this function won't try to set the cursor position past the\n// last block.\nfunction setSelectionToNextContentEditableBlock<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, I, S>) {\n let block: Block<BSchema, I, S> | undefined =\n editor.getTextCursorPosition().block;\n let contentType = editor.schema.blockSchema[block.type].content;\n\n while (contentType === \"none\") {\n block = editor.getTextCursorPosition().nextBlock;\n if (block === undefined) {\n return;\n }\n contentType = editor.schema.blockSchema[block.type].content as\n | \"inline\"\n | \"table\"\n | \"none\";\n editor.setTextCursorPosition(block, \"end\");\n }\n}\n\n// Checks if the current block is empty or only contains a slash, and if so,\n// updates the current block instead of inserting a new one below. If the new\n// block doesn't contain editable content, the cursor is moved to the next block\n// that does.\nexport function insertOrUpdateBlock<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n editor: BlockNoteEditor<BSchema, I, S>,\n block: PartialBlock<BSchema, I, S>,\n): Block<BSchema, I, S> {\n const currentBlock = editor.getTextCursorPosition().block;\n\n if (currentBlock.content === undefined) {\n throw new Error(\"Slash Menu open in a block that doesn't contain content.\");\n }\n\n let newBlock: Block<BSchema, I, S>;\n\n if (\n Array.isArray(currentBlock.content) &&\n ((currentBlock.content.length === 1 &&\n isStyledTextInlineContent(currentBlock.content[0]) &&\n currentBlock.content[0].type === \"text\" &&\n currentBlock.content[0].text === \"/\") ||\n currentBlock.content.length === 0)\n ) {\n newBlock = editor.updateBlock(currentBlock, block);\n // We make sure to reset the cursor position to the new block as calling\n // `updateBlock` may move it out. This generally happens when the content\n // changes, or the update makes the block multi-column.\n editor.setTextCursorPosition(newBlock);\n } else {\n newBlock = editor.insertBlocks([block], currentBlock, \"after\")[0];\n editor.setTextCursorPosition(editor.getTextCursorPosition().nextBlock!);\n }\n\n setSelectionToNextContentEditableBlock(editor);\n\n return newBlock;\n}\n\nexport function getDefaultSlashMenuItems<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, I, S>) {\n const items: DefaultSuggestionItem[] = [];\n\n if (editorHasBlockWithType(editor, \"heading\", { level: \"number\" })) {\n items.push(\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 1 },\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Alt-1\"),\n key: \"heading\",\n ...editor.dictionary.slash_menu.heading,\n },\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 2 },\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Alt-2\"),\n key: \"heading_2\",\n ...editor.dictionary.slash_menu.heading_2,\n },\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 3 },\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Alt-3\"),\n key: \"heading_3\",\n ...editor.dictionary.slash_menu.heading_3,\n },\n );\n }\n\n if (editorHasBlockWithType(editor, \"quote\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"quote\",\n });\n },\n key: \"quote\",\n ...editor.dictionary.slash_menu.quote,\n });\n }\n\n if (editorHasBlockWithType(editor, \"toggleListItem\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"toggleListItem\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Shift-6\"),\n key: \"toggle_list\",\n ...editor.dictionary.slash_menu.toggle_list,\n });\n }\n\n if (editorHasBlockWithType(editor, \"numberedListItem\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"numberedListItem\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Shift-7\"),\n key: \"numbered_list\",\n ...editor.dictionary.slash_menu.numbered_list,\n });\n }\n\n if (editorHasBlockWithType(editor, \"bulletListItem\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"bulletListItem\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Shift-8\"),\n key: \"bullet_list\",\n ...editor.dictionary.slash_menu.bullet_list,\n });\n }\n\n if (editorHasBlockWithType(editor, \"checkListItem\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"checkListItem\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Shift-9\"),\n key: \"check_list\",\n ...editor.dictionary.slash_menu.check_list,\n });\n }\n\n if (editorHasBlockWithType(editor, \"paragraph\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"paragraph\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Alt-0\"),\n key: \"paragraph\",\n ...editor.dictionary.slash_menu.paragraph,\n });\n }\n\n if (editorHasBlockWithType(editor, \"codeBlock\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"codeBlock\",\n });\n },\n badge: formatKeyboardShortcut(\"Mod-Alt-c\"),\n key: \"code_block\",\n ...editor.dictionary.slash_menu.code_block,\n });\n }\n\n if (editorHasBlockWithType(editor, \"divider\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, { type: \"divider\" });\n },\n key: \"divider\",\n ...editor.dictionary.slash_menu.divider,\n });\n }\n\n if (editorHasBlockWithType(editor, \"table\")) {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"table\",\n content: {\n type: \"tableContent\",\n rows: [\n {\n cells: [\"\", \"\", \"\"],\n },\n {\n cells: [\"\", \"\", \"\"],\n },\n ],\n } as any,\n });\n },\n badge: undefined,\n key: \"table\",\n ...editor.dictionary.slash_menu.table,\n });\n }\n\n if (editorHasBlockWithType(editor, \"image\", { url: \"string\" })) {\n items.push({\n onItemClick: () => {\n const insertedBlock = insertOrUpdateBlock(editor, {\n type: \"image\",\n });\n\n // Immediately open the file toolbar\n editor.transact((tr) =>\n tr.setMeta(editor.filePanel!.plugins[0], {\n block: insertedBlock,\n }),\n );\n },\n key: \"image\",\n ...editor.dictionary.slash_menu.image,\n });\n }\n\n if (editorHasBlockWithType(editor, \"video\", { url: \"string\" })) {\n items.push({\n onItemClick: () => {\n const insertedBlock = insertOrUpdateBlock(editor, {\n type: \"video\",\n });\n\n // Immediately open the file toolbar\n editor.transact((tr) =>\n tr.setMeta(editor.filePanel!.plugins[0], {\n block: insertedBlock,\n }),\n );\n },\n key: \"video\",\n ...editor.dictionary.slash_menu.video,\n });\n }\n\n if (editorHasBlockWithType(editor, \"audio\", { url: \"string\" })) {\n items.push({\n onItemClick: () => {\n const insertedBlock = insertOrUpdateBlock(editor, {\n type: \"audio\",\n });\n\n // Immediately open the file toolbar\n editor.transact((tr) =>\n tr.setMeta(editor.filePanel!.plugins[0], {\n block: insertedBlock,\n }),\n );\n },\n key: \"audio\",\n ...editor.dictionary.slash_menu.audio,\n });\n }\n\n if (editorHasBlockWithType(editor, \"file\", { url: \"string\" })) {\n items.push({\n onItemClick: () => {\n const insertedBlock = insertOrUpdateBlock(editor, {\n type: \"file\",\n });\n\n // Immediately open the file toolbar\n editor.transact((tr) =>\n tr.setMeta(editor.filePanel!.plugins[0], {\n block: insertedBlock,\n }),\n );\n },\n key: \"file\",\n ...editor.dictionary.slash_menu.file,\n });\n }\n\n if (\n editorHasBlockWithType(editor, \"heading\", {\n level: \"number\",\n isToggleable: \"boolean\",\n })\n ) {\n items.push(\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 1, isToggleable: true },\n });\n },\n key: \"toggle_heading\",\n ...editor.dictionary.slash_menu.toggle_heading,\n },\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 2, isToggleable: true },\n });\n },\n\n key: \"toggle_heading_2\",\n ...editor.dictionary.slash_menu.toggle_heading_2,\n },\n {\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: 3, isToggleable: true },\n });\n },\n key: \"toggle_heading_3\",\n ...editor.dictionary.slash_menu.toggle_heading_3,\n },\n );\n }\n\n if (editorHasBlockWithType(editor, \"heading\", { level: \"number\" })) {\n (editor.schema.blockSchema.heading.propSchema.level.values || [])\n .filter((level): level is 4 | 5 | 6 => level > 3)\n .forEach((level) => {\n items.push({\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"heading\",\n props: { level: level },\n });\n },\n key: `heading_${level}`,\n ...editor.dictionary.slash_menu[`heading_${level}`],\n });\n });\n }\n\n items.push({\n onItemClick: () => {\n editor.openSuggestionMenu(\":\", {\n deleteTriggerCharacter: true,\n ignoreQueryLength: true,\n });\n },\n key: \"emoji\",\n ...editor.dictionary.slash_menu.emoji,\n });\n\n return items;\n}\n\nexport function filterSuggestionItems<\n T extends { title: string; aliases?: readonly string[] },\n>(items: T[], query: string) {\n return items.filter(\n ({ title, aliases }) =>\n title.toLowerCase().includes(query.toLowerCase()) ||\n (aliases &&\n aliases.filter((alias) =>\n alias.toLowerCase().includes(query.toLowerCase()),\n ).length !== 0),\n );\n}\n","import { BlockNoteEditor } from \"../../editor/BlockNoteEditor.js\";\nimport { DefaultSuggestionItem } from \"../../extensions/SuggestionMenu/DefaultSuggestionItem.js\";\nimport { insertOrUpdateBlock } from \"../../extensions/SuggestionMenu/getDefaultSlashMenuItems.js\";\nimport {\n BlockSchema,\n InlineContentSchema,\n StyleSchema,\n} from \"../../schema/index.js\";\nimport { createPageBreakBlockConfig } from \"./block.js\";\n\nexport function checkPageBreakBlocksInSchema<\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(\n editor: BlockNoteEditor<any, I, S>,\n): editor is BlockNoteEditor<\n {\n pageBreak: ReturnType<typeof createPageBreakBlockConfig>;\n },\n I,\n S\n> {\n return \"pageBreak\" in editor.schema.blockSchema;\n}\n\nexport function getPageBreakSlashMenuItems<\n BSchema extends BlockSchema,\n I extends InlineContentSchema,\n S extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, I, S>) {\n const items: (Omit<DefaultSuggestionItem, \"key\"> & { key: \"page_break\" })[] =\n [];\n\n if (checkPageBreakBlocksInSchema(editor)) {\n items.push({\n ...editor.dictionary.slash_menu.page_break,\n onItemClick: () => {\n insertOrUpdateBlock(editor, {\n type: \"pageBreak\",\n });\n },\n key: \"page_break\",\n });\n }\n\n return items;\n}\n","import Bold from \"@tiptap/extension-bold\";\nimport Code from \"@tiptap/extension-code\";\nimport Italic from \"@tiptap/extension-italic\";\nimport Strike from \"@tiptap/extension-strike\";\nimport Underline from \"@tiptap/extension-underline\";\nimport { COLORS_DEFAULT } from \"../editor/defaultColors.js\";\nimport {\n BlockNoDefaults,\n BlockSchema,\n InlineContentSchema,\n InlineContentSpecs,\n PartialBlockNoDefaults,\n StyleSchema,\n StyleSpecs,\n createStyleSpec,\n createStyleSpecFromTipTapMark,\n getInlineContentSchemaFromSpecs,\n getStyleSchemaFromSpecs,\n} from \"../schema/index.js\";\nimport {\n createAudioBlockSpec,\n createBulletListItemBlockSpec,\n createCheckListItemBlockSpec,\n createCodeBlockSpec,\n createDividerBlockSpec,\n createFileBlockSpec,\n createHeadingBlockSpec,\n createImageBlockSpec,\n createNumberedListItemBlockSpec,\n createParagraphBlockSpec,\n createQuoteBlockSpec,\n createToggleListItemBlockSpec,\n createVideoBlockSpec,\n defaultProps,\n} from \"./index.js\";\nimport { createTableBlockSpec } from \"./Table/block.js\";\n\nexport const defaultBlockSpecs = {\n audio: createAudioBlockSpec(),\n bulletListItem: createBulletListItemBlockSpec(),\n checkListItem: createCheckListItemBlockSpec(),\n codeBlock: createCodeBlockSpec(),\n divider: createDividerBlockSpec(),\n file: createFileBlockSpec(),\n heading: createHeadingBlockSpec(),\n image: createImageBlockSpec(),\n numberedListItem: createNumberedListItemBlockSpec(),\n paragraph: createParagraphBlockSpec(),\n quote: createQuoteBlockSpec(),\n table: createTableBlockSpec(),\n toggleListItem: createToggleListItemBlockSpec(),\n video: createVideoBlockSpec(),\n} as const;\n\n// underscore is used that in case a user overrides DefaultBlockSchema,\n// they can still access the original default block schema\nexport type _DefaultBlockSchema = {\n [K in keyof typeof defaultBlockSpecs]: (typeof defaultBlockSpecs)[K][\"config\"];\n};\nexport type DefaultBlockSchema = _DefaultBlockSchema;\n\nconst TextColor = createStyleSpec(\n {\n type: \"textColor\",\n propSchema: \"string\",\n },\n {\n render: () => {\n const span = document.createElement(\"span\");\n\n return {\n dom: span,\n contentDOM: span,\n };\n },\n toExternalHTML: (value) => {\n const span = document.createElement(\"span\");\n if (value !== defaultProps.textColor.default) {\n span.style.color =\n value in COLORS_DEFAULT ? COLORS_DEFAULT[value].text : value;\n }\n\n return {\n dom: span,\n contentDOM: span,\n };\n },\n parse: (element) => {\n if (element.tagName === \"SPAN\" && element.style.color) {\n return element.style.color;\n }\n\n return undefined;\n },\n },\n);\n\nconst BackgroundColor = createStyleSpec(\n {\n type: \"backgroundColor\",\n propSchema: \"string\",\n },\n {\n render: () => {\n const span = document.createElement(\"span\");\n\n return {\n dom: span,\n contentDOM: span,\n };\n },\n toExternalHTML: (value) => {\n const span = document.createElement(\"span\");\n if (value !== defaultProps.backgroundColor.default) {\n span.style.backgroundColor =\n value in COLORS_DEFAULT ? COLORS_DEFAULT[value].background : value;\n }\n\n return {\n dom: span,\n contentDOM: span,\n };\n },\n parse: (element) => {\n if (element.tagName === \"SPAN\" && element.style.backgroundColor) {\n return element.style.backgroundColor;\n }\n\n return undefined;\n },\n },\n);\n\nexport const defaultStyleSpecs = {\n bold: createStyleSpecFromTipTapMark(Bold, \"boolean\"),\n italic: createStyleSpecFromTipTapMark(Italic, \"boolean\"),\n underline: createStyleSpecFromTipTapMark(Underline, \"boolean\"),\n strike: createStyleSpecFromTipTapMark(Strike, \"boolean\"),\n code: createStyleSpecFromTipTapMark(Code, \"boolean\"),\n textColor: TextColor,\n backgroundColor: BackgroundColor,\n} satisfies StyleSpecs;\n\nexport const defaultStyleSchema = getStyleSchemaFromSpecs(defaultStyleSpecs);\n\n// underscore is used that in case a user overrides DefaultStyleSchema,\n// they can still access the original default style schema\nexport type _DefaultStyleSchema = typeof defaultStyleSchema;\nexport type DefaultStyleSchema = _DefaultStyleSchema;\n\nexport const defaultInlineContentSpecs = {\n text: { config: \"text\", implementation: {} as any },\n link: { config: \"link\", implementation: {} as any },\n} satisfies InlineContentSpecs;\n\nexport const defaultInlineContentSchema = getInlineContentSchemaFromSpecs(\n defaultInlineContentSpecs,\n);\n\n// underscore is used that in case a user overrides DefaultInlineContentSchema,\n// they can still access the original default inline content schema\nexport type _DefaultInlineContentSchema = typeof defaultInlineContentSchema;\nexport type DefaultInlineContentSchema = _DefaultInlineContentSchema;\n\nexport type PartialBlock<\n BSchema extends BlockSchema = DefaultBlockSchema,\n I extends InlineContentSchema = DefaultInlineContentSchema,\n S extends StyleSchema = DefaultStyleSchema,\n> = PartialBlockNoDefaults<BSchema, I, S>;\n\nexport type Block<\n BSchema extends BlockSchema = DefaultBlockSchema,\n I extends InlineContentSchema = DefaultInlineContentSchema,\n S extends StyleSchema = DefaultStyleSchema,\n> = BlockNoDefaults<BSchema, I, S>;\n","import {\n BlockSchema,\n BlockSchemaFromSpecs,\n BlockSpecs,\n CustomBlockNoteSchema,\n InlineContentSchema,\n InlineContentSchemaFromSpecs,\n InlineContentSpecs,\n StyleSchema,\n StyleSchemaFromSpecs,\n StyleSpecs,\n} from \"../schema/index.js\";\nimport {\n defaultBlockSpecs,\n defaultInlineContentSpecs,\n defaultStyleSpecs,\n} from \"./defaultBlocks.js\";\n\nexport class BlockNoteSchema<\n BSchema extends BlockSchema,\n ISchema extends InlineContentSchema,\n SSchema extends StyleSchema,\n> extends CustomBlockNoteSchema<BSchema, ISchema, SSchema> {\n public static create<\n BSpecs extends BlockSpecs | undefined = undefined,\n ISpecs extends InlineContentSpecs | undefined = undefined,\n SSpecs extends StyleSpecs | undefined = undefined,\n >(options?: {\n /**\n * A list of custom block types that should be available in the editor.\n */\n blockSpecs?: BSpecs;\n /**\n * A list of custom InlineContent types that should be available in the editor.\n */\n inlineContentSpecs?: ISpecs;\n /**\n * A list of custom Styles that should be available in the editor.\n */\n styleSpecs?: SSpecs;\n }): BlockNoteSchema<\n BSpecs extends undefined\n ? BlockSchemaFromSpecs<typeof defaultBlockSpecs>\n : BlockSchemaFromSpecs<NonNullable<BSpecs>>,\n ISpecs extends undefined\n ? InlineContentSchemaFromSpecs<typeof defaultInlineContentSpecs>\n : InlineContentSchemaFromSpecs<NonNullable<ISpecs>>,\n SSpecs extends undefined\n ? StyleSchemaFromSpecs<typeof defaultStyleSpecs>\n : StyleSchemaFromSpecs<NonNullable<SSpecs>>\n > {\n return new BlockNoteSchema<any, any, any>({\n blockSpecs: options?.blockSpecs ?? defaultBlockSpecs,\n inlineContentSpecs:\n options?.inlineContentSpecs ?? defaultInlineContentSpecs,\n styleSpecs: options?.styleSpecs ?? defaultStyleSpecs,\n });\n }\n}\n"],"names":["isAppleOS","formatKeyboardShortcut","shortcut","ctrlText","mergeCSSClasses","classes","c","isSafari","createDefaultBlockDOMOutputSpec","blockName","htmlTag","blockContentHTMLAttributes","inlineContentHTMLAttributes","blockContent","attribute","value","inlineContent","defaultBlockToHTML","block","editor","node","blockToNode","toDOM","renderSpec","mergeParagraphs","element","separator","paragraphs","firstParagraph","i","paragraph","camelToDataKebab","str","filenameFromURL","url","parts","isVideoUrl","videoExtensions","ext","_a","propsToAttributes","propSchema","tiptapAttributes","name","spec","asNumber","attributes","getBlockFromPos","getPos","tipTapEditor","type","pos","blockIdentifier","wrapInBlockStructure","blockType","blockProps","isFileBlock","domAttributes","attr","prop","defaultValue","createBlockSpecFromTiptapNode","config","extensions","applyNonSelectableBlockFix","nodeView","event","getParseRules","implementation","rules","props","schema","clone","DOMParser","Fragment","addNodeAndExtensionsToSpec","blockConfig","blockImplementation","priority","Node","_b","_c","_d","HTMLAttributes","div","blockContentDOMAttributes","createBlockConfig","callback","createBlockSpec","blockConfigOrCreator","blockImplementationOrCreator","extensionsOrCreator","options","output","addInlineContentAttributes","inlineContentType","inlineContentProps","addInlineContentKeyboardShortcuts","resolvedPos","createInternalInlineContentSpec","createInlineContentSpecFromTipTapNode","getInlineContentSchemaFromSpecs","specs","key","stylePropsToAttributes","addStyleAttributes","styleType","styleValue","createInternalStyleSpec","createStyleSpecFromTipTapMark","mark","markInstance","DOMSerializer","getStyleSchemaFromSpecs","getStyleParseRules","customParseFunction","htmlElement","stringValue","createStyleSpec","styleConfig","styleImplementation","Mark","renderResult","toposort","dag","inDegrees","countInDegrees","roots","nonRoots","getRootsAndNonRoots","sorted","newRoots","root","dependents","dependent","currentDegree","newDegree","toposortReverse","deps","reverse","counts","vx","currentCount","id","deg","reversedDeps","dependsOn","dependsOnName","createDependencyGraph","removeUndefined","obj","CustomBlockNoteSchema","opts","__publicField","blockSpecs","inlineContentSpecs","styleSpecs","blockSchema","inlineContentSchema","styleSchema","defaultSet","specDef","sortedSpecs","defaultIndex","set","getPriority","blockSpec","inlineContentSpec","styleSpec","blockDef","getNodeById","doc","targetNode","posBeforeNode","isNodeBlock","updateBlockCommand","posBeforeBlock","tr","dispatch","updateBlockTr","replaceFromPos","replaceToPos","blockInfo","getBlockInfoFromResolvedPos","cellAnchor","captureCellAnchor","pmSchema","getPmSchema","oldNodeType","newNodeType","newBnBlockNodeType","replaceFromOffset","replaceToOffset","updateChildren","updateBlockContentNode","existingBlock","nodeToBlock","restoreCellAnchor","content","inlineContentToNodes","tableContentToNodes","UnreachableCaseError","start","end","contentDepth","startDepth","endDepth","Slice","childNodes","child","ReplaceStep","updateBlock","blockToUpdate","update","posInfo","blockContainerNode","sel","TextSelection","$head","cellDepth","tableDepth","d","cellPos","tablePos","table","map","TableMap","rel","idx","row","col","textStart","offset","a","cellIndex","relCellPos","textPos","textNode","max","head","COLORS_DEFAULT","COLORS_DARK_MODE_DEFAULT","defaultProps","parseDefaultProps","addDefaultPropsExternalHTML","getBackgroundColorAttribute","attributeName","getTextColorAttribute","getTextAlignmentAttribute","parseFigureElement","figureElement","targetTag","targetElement","captionElement","caption","createAddFileButton","buttonIcon","addFileButton","addFileButtonIcon","addFileButtonText","addFileButtonMouseDownHandler","addFileButtonClickHandler","FILE_ICON_SVG","createFileNameWithIcon","file","icon","fileName","createFileBlockWrapper","wrapper","destroyUploadStartHandler","blockId","loading","ret","fileNameWithIcon","createFigureWithCaption","figure","createLinkWithCaption","fileCaption","parseAudioElement","audioElement","FILE_AUDIO_ICON_SVG","createAudioBlockConfig","_ctx","audioParse","_config","backgroundColor","parsedFigure","audioRender","audio","downloadUrl","audioToExternalHTML","_editor","createAudioBlockSpec","EventEmitter","fn","args","callbacks","BlockNoteExtension","_args","plugin","createBlockNoteExtension","x","shikiParserSymbol","shikiHighlighterPromiseSymbol","lazyShikiPlugin","globalThisForShiki","highlighter","parser","hasWarned","createHighlightPlugin","parserOptions","createdHighlighter","language","getLanguageId","createParser","createCodeBlockConfig","defaultLanguage","createCodeBlockSpec","e","code","el","pre","removeSelectChangeListener","select","option","handleLanguageChange","selectWrapper","$from","nextBlock","isAtEnd","endsWithDoubleNewline","newBlock","match","languageName","aliases","createDividerBlockConfig","createDividerBlockSpec","parseEmbedElement","embedElement","createFileBlockConfig","fileParse","createFileBlockSpec","fileSrcLink","defaultToggledState","isToggled","createToggleWrapper","renderedElement","toggledState","dom","toggleWrapper","toggleButton","toggleButtonMouseDown","toggleButtonOnClick","toggleAddBlockButton","toggleAddBlockButtonMouseDown","toggleAddBlockButtonOnClick","updatedBlock","childCount","onEditorChange","newChildCount","mutation","HEADING_LEVELS","createHeadingBlockConfig","defaultLevel","levels","allowToggleHeadings","createHeadingBlockSpec","level","cursorPosition","createResizableFileBlockWrapper","resizeHandlesContainerElement","destroy","leftResizeHandle","rightResizeHandle","eventCaptureElement","resizeParams","width","windowMouseMoveHandler","newWidth","clientX","windowMouseUpHandler","wrapperMouseEnterHandler","wrapperMouseLeaveHandler","leftResizeHandleMouseDownHandler","rightResizeHandleMouseDownHandler","parseImageElement","imageElement","previewWidth","FILE_IMAGE_ICON_SVG","createImageBlockConfig","imageParse","imageRender","imageWrapper","image","imageToExternalHTML","createImageBlockSpec","splitBlockCommand","posInBlock","keepType","keepProps","state","splitBlockTr","nearestBlockContainerPos","getNearestBlockPos","info","getBlockInfo","types","handleEnter","listItemType","selectionEmpty","getBlockInfoFromTransaction","blockContainer","getListItemContent","_node","clonedNodeDiv","blockGroupNode","listItemsFirstChild","listItemNode","remainingListItemChildren","listItemsChildren","createBulletListItemBlockConfig","createBulletListItemBlockSpec","parent","li","p","getBlockInfoFromSelection","createCheckListItemConfig","createCheckListItemBlockSpec","checkbox","calculateListItemIndex","index","isFirst","hasStart","prevBlock","prevBlockIndex","getDecorations","previousPluginState","nextDecorationSet","decorationsToAdd","deco","blockNode","Decoration","decorationsToRemove","NumberedListIndexingDecorationPlugin","Plugin","PluginKey","DecorationSet","createNumberedListItemBlockConfig","createNumberedListItemBlockSpec","startIndex","createToggleListItemBlockConfig","createToggleListItemBlockSpec","paragraphEl","createPageBreakBlockConfig","createPageBreakBlockSpec","pageBreak","withPageBreak","createParagraphBlockConfig","createParagraphBlockSpec","createQuoteBlockConfig","createQuoteBlockSpec","textColor","quote","RESIZE_MIN_WIDTH","EMPTY_CELL_WIDTH","EMPTY_CELL_HEIGHT","TableExtension","Extension","columnResizing","tableEditing","selection","selectionIsEmpty","selectionIsAtStartOfNode","selectionIsInTableParagraphNode","view","goToNextCell","extension","context","callOrReturn","getExtensionField","tablePropSchema","TiptapTableHeader","colwidth","parseTableContent","mergeAttributes","TiptapTableCell","TiptapTableNode","domOutputSpec","colGroup","tableCell","colWidth","BlockNoteTableView","TableView","cellMinWidth","tableWrapper","tableWrapperInner","floatingContainer","record","TiptapTableParagraph","TiptapTableRow","parsedContent","extractedContent","createTableBlockSpec","CellSelection","numCells","cell","selectionNumCells","parseVideoElement","videoElement","FILE_VIDEO_ICON_SVG","createVideoBlockConfig","videoParse","createVideoBlockSpec","videoWrapper","video","uploadToTmpFilesDotOrg_DEV_ONLY","body","editorHasBlockWithType","propName","propSpec","blockHasType","isTableCellSelection","setSelectionToNextContentEditableBlock","contentType","insertOrUpdateBlock","currentBlock","isStyledTextInlineContent","getDefaultSlashMenuItems","items","insertedBlock","filterSuggestionItems","query","title","alias","checkPageBreakBlocksInSchema","getPageBreakSlashMenuItems","defaultBlockSpecs","TextColor","span","BackgroundColor","defaultStyleSpecs","Bold","Italic","Underline","Strike","Code","defaultStyleSchema","defaultInlineContentSpecs","defaultInlineContentSchema","BlockNoteSchema"],"mappings":";;;;;;;;;;;;;;;;;AAAO,MAAMA,KAAY,MACvB,OAAO,YAAc,QACpB,MAAM,KAAK,UAAU,QAAQ,KAC3B,cAAc,KAAK,UAAU,SAAS,KACrC,cAAc,KAAK,UAAU,SAAS;AAErC,SAASC,EAAuBC,GAAkBC,IAAW,QAAQ;AAC1E,SAAIH,OACKE,EAAS,QAAQ,OAAO,GAAG,IAE3BA,EAAS,QAAQ,OAAOC,CAAQ;AAE3C;AAEO,SAASC,KAAmBC,GAAyC;AAC1E,SAAO;AAAA;AAAA,IAEL,GAAG,IAAI;AAAA,MACLA,EACG,OAAO,CAACC,MAAMA,CAAC,EAGf,KAAK,GAAG,EAC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