{"version":3,"file":"blocknote-react.cjs","names":[],"sources":["../src/components/Popovers/BlockPopover.tsx","../src/components/FilePanel/DefaultTabs/EmbedTab.tsx","../src/components/FilePanel/DefaultTabs/UploadTab.tsx","../src/components/FilePanel/FilePanel.tsx","../src/components/FilePanel/FilePanelController.tsx","../src/components/FormattingToolbar/DefaultButtons/BasicTextStyleButton.tsx","../src/components/ColorPicker/ColorIcon.tsx","../src/components/ColorPicker/ColorPicker.tsx","../src/components/FormattingToolbar/DefaultButtons/ColorStyleButton.tsx","../src/components/LinkToolbar/EditLinkMenuItems.tsx","../src/components/FormattingToolbar/DefaultButtons/CreateLinkButton.tsx","../src/components/FormattingToolbar/DefaultButtons/FileCaptionButton.tsx","../src/components/FormattingToolbar/DefaultButtons/FileDeleteButton.tsx","../src/components/FormattingToolbar/DefaultButtons/FileRenameButton.tsx","../src/components/FormattingToolbar/DefaultButtons/FileReplaceButton.tsx","../src/components/FormattingToolbar/DefaultButtons/NestBlockButtons.tsx","../src/components/FormattingToolbar/DefaultSelects/BlockTypeSelect.tsx","../src/components/FormattingToolbar/DefaultButtons/AddCommentButton.tsx","../src/components/FormattingToolbar/DefaultButtons/AddTiptapCommentButton.tsx","../src/util/sanitizeUrl.ts","../src/components/FormattingToolbar/DefaultButtons/FileDownloadButton.tsx","../src/components/FormattingToolbar/DefaultButtons/FilePreviewButton.tsx","../src/components/FormattingToolbar/DefaultButtons/TableCellMergeButton.tsx","../src/components/FormattingToolbar/DefaultButtons/TextAlignButton.tsx","../src/components/FormattingToolbar/FormattingToolbar.tsx","../src/components/FormattingToolbar/FormattingToolbarController.tsx","../src/components/LinkToolbar/DefaultButtons/DeleteLinkButton.tsx","../src/components/LinkToolbar/DefaultButtons/EditLinkButton.tsx","../src/components/LinkToolbar/DefaultButtons/OpenLinkButton.tsx","../src/components/LinkToolbar/LinkToolbar.tsx","../src/components/LinkToolbar/LinkToolbarController.tsx","../src/components/SideMenu/DefaultButtons/AddBlockButton.tsx","../src/components/SideMenu/DragHandleMenu/DefaultItems/BlockColorsItem.tsx","../src/components/SideMenu/DragHandleMenu/DefaultItems/RemoveBlockItem.tsx","../src/components/SideMenu/DragHandleMenu/DefaultItems/TableHeadersItem.tsx","../src/components/SideMenu/DragHandleMenu/DragHandleMenu.tsx","../src/components/SideMenu/DefaultButtons/DragHandleButton.tsx","../src/components/SideMenu/SideMenu.tsx","../src/components/SideMenu/SideMenuController.tsx","../src/components/SuggestionMenu/GridSuggestionMenu/getDefaultReactEmojiPickerItems.tsx","../src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenu.tsx","../src/components/SuggestionMenu/hooks/useCloseSuggestionMenuNoItems.ts","../src/components/SuggestionMenu/hooks/useLoadSuggestionMenuItems.ts","../src/components/SuggestionMenu/GridSuggestionMenu/hooks/useGridSuggestionMenuKeyboardNavigation.ts","../src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuWrapper.tsx","../src/components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuController.tsx","../src/components/SuggestionMenu/SuggestionMenu.tsx","../src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardHandler.ts","../src/components/SuggestionMenu/hooks/useSuggestionMenuKeyboardNavigation.ts","../src/components/SuggestionMenu/SuggestionMenuWrapper.tsx","../src/components/SuggestionMenu/getDefaultReactSlashMenuItems.tsx","../src/components/SuggestionMenu/SuggestionMenuController.tsx","../src/components/TableHandles/ExtendButton/ExtendButton.tsx","../src/components/TableHandles/TableCellMenu/DefaultButtons/ColorPicker.tsx","../src/components/TableHandles/TableCellMenu/DefaultButtons/SplitButton.tsx","../src/components/TableHandles/TableCellMenu/TableCellMenu.tsx","../src/components/TableHandles/TableCellButton.tsx","../src/components/TableHandles/TableHandleMenu/DefaultButtons/AddButton.tsx","../src/components/TableHandles/TableHandleMenu/DefaultButtons/DeleteButton.tsx","../src/components/TableHandles/TableHandleMenu/DefaultButtons/ColorPicker.tsx","../src/components/TableHandles/TableHandleMenu/DefaultButtons/TableHeaderButton.tsx","../src/components/TableHandles/TableHandleMenu/TableHandleMenu.tsx","../src/components/TableHandles/TableHandle.tsx","../src/components/TableHandles/TableHandlesController.tsx","../src/editor/BlockNoteDefaultUI.tsx","../src/hooks/useEditorChange.ts","../src/hooks/useEditorSelectionChange.ts","../src/hooks/usePrefersColorScheme.ts","../src/editor/BlockNoteViewContext.ts","../src/editor/EditorContent.tsx","../src/editor/ElementRenderer.tsx","../src/editor/BlockNoteView.tsx","../src/schema/@util/ReactRenderUtil.ts","../src/schema/ReactBlockSpec.tsx","../src/blocks/File/useResolveUrl.tsx","../src/blocks/File/helpers/toExternalHTML/FigureWithCaption.tsx","../src/hooks/useOnUploadEnd.ts","../src/hooks/useOnUploadStart.ts","../src/hooks/useUploadLoading.ts","../src/blocks/File/helpers/render/AddFileButton.tsx","../src/blocks/File/helpers/render/FileNameWithIcon.tsx","../src/blocks/File/helpers/render/FileBlockWrapper.tsx","../src/blocks/File/helpers/toExternalHTML/LinkWithCaption.tsx","../src/blocks/Audio/block.tsx","../src/blocks/File/block.tsx","../src/blocks/File/helpers/render/ResizableFileBlockWrapper.tsx","../src/blocks/Image/block.tsx","../src/blocks/PageBreak/getPageBreakReactSlashMenuItems.tsx","../src/blocks/Video/block.tsx","../src/blocks/ToggleWrapper/ToggleWrapper.tsx","../src/components/FormattingToolbar/ExperimentalMobileFormattingToolbarController.tsx","../src/components/TableHandles/hooks/useExtendButtonsPositioning.ts","../src/components/TableHandles/hooks/useTableHandlesPositioning.ts","../src/components/Comments/ThreadsSidebar.tsx","../src/hooks/useActiveStyles.ts","../src/hooks/useEditorSelectionBoundingBox.ts","../src/hooks/useFocusWithin.ts","../src/hooks/useSelectedBlocks.ts","../src/schema/ReactInlineContentSpec.tsx","../src/schema/ReactStyleSpec.tsx","../src/util/elementOverflow.ts","../src/util/mergeRefs.ts"],"sourcesContent":["import { getNodeById } from \"@blocknote/core\";\nimport { ReactNode, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { FloatingUIOptions } from \"./FloatingUIOptions.js\";\nimport { GenericPopover, GenericPopoverReference } from \"./GenericPopover.js\";\n\nexport const BlockPopover = (\n  props: FloatingUIOptions & {\n    blockId: string | undefined;\n    children: ReactNode;\n  },\n) => {\n  const { blockId, children, ...floatingUIOptions } = props;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const reference = useMemo<GenericPopoverReference | undefined>(\n    () =>\n      editor.transact((tr) => {\n        if (!blockId) {\n          return undefined;\n        }\n\n        // TODO use the location API for this\n        const nodePosInfo = getNodeById(blockId, tr.doc);\n        if (!nodePosInfo) {\n          return undefined;\n        }\n\n        const { node } = editor.prosemirrorView.domAtPos(\n          nodePosInfo.posBeforeNode + 1,\n        );\n        if (!(node instanceof Element)) {\n          return undefined;\n        }\n\n        return {\n          element: node,\n        };\n      }),\n    [editor, blockId],\n  );\n\n  return (\n    <GenericPopover reference={reference} {...floatingUIOptions}>\n      {blockId !== undefined && children}\n    </GenericPopover>\n  );\n};\n","import {\n  BlockSchema,\n  DefaultBlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  InlineContentSchema,\n  StyleSchema,\n  filenameFromURL,\n} from \"@blocknote/core\";\nimport { ChangeEvent, KeyboardEvent, useCallback, useState } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { FilePanelProps } from \"../FilePanelProps.js\";\n\nexport const EmbedTab = <\n  B extends BlockSchema = DefaultBlockSchema,\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(\n  props: FilePanelProps,\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<B, I, S>();\n\n  const block = editor.getBlock(props.blockId)!;\n\n  const [currentURL, setCurrentURL] = useState<string>(\"\");\n\n  const handleURLChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) => {\n      setCurrentURL(event.currentTarget.value);\n    },\n    [],\n  );\n\n  const handleURLEnter = useCallback(\n    (event: KeyboardEvent) => {\n      if (event.key === \"Enter\" && !event.nativeEvent.isComposing) {\n        event.preventDefault();\n        editor.updateBlock(block.id, {\n          props: {\n            name: filenameFromURL(currentURL),\n            url: currentURL,\n          } as any,\n        });\n      }\n    },\n    [editor, block.id, currentURL],\n  );\n\n  const handleURLClick = useCallback(() => {\n    editor.updateBlock(block.id, {\n      props: {\n        name: filenameFromURL(currentURL),\n        url: currentURL,\n      } as any,\n    });\n  }, [editor, block.id, currentURL]);\n\n  return (\n    <Components.FilePanel.TabPanel className={\"bn-tab-panel\"}>\n      <Components.FilePanel.TextInput\n        className={\"bn-text-input\"}\n        placeholder={dict.file_panel.embed.url_placeholder}\n        value={currentURL}\n        onChange={handleURLChange}\n        onKeyDown={handleURLEnter}\n        data-test={\"embed-input\"}\n      />\n      <Components.FilePanel.Button\n        className={\"bn-button\"}\n        onClick={handleURLClick}\n        data-test=\"embed-input-button\"\n      >\n        {dict.file_panel.embed.embed_button[block.type] ||\n          dict.file_panel.embed.embed_button[\"file\"]}\n      </Components.FilePanel.Button>\n    </Components.FilePanel.TabPanel>\n  );\n};\n","import {\n  BlockSchema,\n  DefaultBlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback, useEffect, useState } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { FilePanelProps } from \"../FilePanelProps.js\";\n\nexport const UploadTab = <\n  B extends BlockSchema = DefaultBlockSchema,\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(\n  props: FilePanelProps & {\n    setLoading: (loading: boolean) => void;\n  },\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const { setLoading } = props;\n\n  const editor = useBlockNoteEditor<B, I, S>();\n\n  const block = editor.getBlock(props.blockId)!;\n\n  const [uploadFailed, setUploadFailed] = useState<boolean>(false);\n\n  useEffect(() => {\n    if (uploadFailed) {\n      setTimeout(() => {\n        setUploadFailed(false);\n      }, 3000);\n    }\n  }, [uploadFailed]);\n\n  const handleFileChange = useCallback(\n    (file: File | null) => {\n      if (file === null) {\n        return;\n      }\n\n      async function upload(file: File) {\n        setLoading(true);\n\n        if (editor.uploadFile !== undefined) {\n          try {\n            let updateData = await editor.uploadFile(file, props.blockId);\n            if (typeof updateData === \"string\") {\n              // received a url\n              updateData = {\n                props: {\n                  name: file.name,\n                  url: updateData,\n                },\n              };\n            }\n            editor.updateBlock(props.blockId, updateData);\n          } catch (e) {\n            setUploadFailed(true);\n          } finally {\n            setLoading(false);\n          }\n        }\n      }\n\n      upload(file);\n    },\n    [props.blockId, editor, setLoading],\n  );\n\n  const spec = editor.schema.blockSpecs[block.type];\n  const accept = spec.implementation.meta?.fileBlockAccept?.length\n    ? spec.implementation.meta.fileBlockAccept.join(\",\")\n    : \"*/*\";\n\n  return (\n    <Components.FilePanel.TabPanel className={\"bn-tab-panel\"}>\n      <Components.FilePanel.FileInput\n        className=\"bn-file-input\"\n        data-test=\"upload-input\"\n        accept={accept}\n        placeholder={\n          dict.file_panel.upload.file_placeholder[block.type] ||\n          dict.file_panel.upload.file_placeholder[\"file\"]\n        }\n        value={null}\n        onChange={handleFileChange}\n      />\n      {uploadFailed && (\n        <div className=\"bn-error-text\">\n          {dict.file_panel.upload.upload_error}\n        </div>\n      )}\n    </Components.FilePanel.TabPanel>\n  );\n};\n","import {\n  BlockSchema,\n  DefaultBlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useState } from \"react\";\n\nimport {\n  ComponentProps,\n  useComponentsContext,\n} from \"../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../i18n/dictionary.js\";\nimport { EmbedTab } from \"./DefaultTabs/EmbedTab.js\";\nimport { UploadTab } from \"./DefaultTabs/UploadTab.js\";\nimport { FilePanelProps } from \"./FilePanelProps.js\";\n\ntype PanelProps = ComponentProps[\"FilePanel\"][\"Root\"];\n\n/**\n * By default, the FilePanel component will render with default tabs. However,\n * you can override the tabs to render by passing the `tabs` prop. You can use\n * the default tab panels in the `DefaultTabPanels` directory or make your own\n * using the `FilePanelPanel` component.\n */\nexport const FilePanel = <\n  B extends BlockSchema = DefaultBlockSchema,\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(\n  props: FilePanelProps & Partial<Pick<PanelProps, \"defaultOpenTab\" | \"tabs\">>,\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<B, I, S>();\n\n  const [loading, setLoading] = useState<boolean>(false);\n\n  const tabs: PanelProps[\"tabs\"] = props.tabs ?? [\n    ...(editor.uploadFile !== undefined\n      ? [\n          {\n            name: dict.file_panel.upload.title,\n            tabPanel: (\n              <UploadTab blockId={props.blockId} setLoading={setLoading} />\n            ),\n          },\n        ]\n      : []),\n    {\n      name: dict.file_panel.embed.title,\n      tabPanel: <EmbedTab blockId={props.blockId} />,\n    },\n  ];\n\n  const [openTab, setOpenTab] = useState<string>(\n    props.defaultOpenTab || tabs[0].name,\n  );\n\n  return (\n    <Components.FilePanel.Root\n      className={\"bn-panel\"}\n      defaultOpenTab={openTab}\n      openTab={openTab}\n      setOpenTab={setOpenTab}\n      tabs={tabs}\n      loading={loading}\n    />\n  );\n};\n","import { FilePanelExtension } from \"@blocknote/core/extensions\";\nimport { flip, offset } from \"@floating-ui/react\";\nimport { FC, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension, useExtensionState } from \"../../hooks/useExtension.js\";\nimport { BlockPopover } from \"../Popovers/BlockPopover.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport { FilePanel } from \"./FilePanel.js\";\nimport { FilePanelProps } from \"./FilePanelProps.js\";\n\nexport const FilePanelController = (props: {\n  filePanel?: FC<FilePanelProps>;\n  floatingUIOptions?: FloatingUIOptions;\n}) => {\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const filePanel = useExtension(FilePanelExtension);\n  const blockId = useExtensionState(FilePanelExtension);\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: !!blockId,\n        // Needed as hooks like `useDismiss` call `onOpenChange` to change the\n        // open state.\n        onOpenChange: (open, _event, reason) => {\n          if (!open) {\n            filePanel.closeMenu();\n          }\n\n          if (reason === \"escape-key\") {\n            editor.focus();\n          }\n        },\n        middleware: [offset(10), flip()],\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        style: {\n          zIndex: 90,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [blockId, editor, filePanel, props.floatingUIOptions],\n  );\n\n  const Component = props.filePanel || FilePanel;\n\n  return (\n    <BlockPopover blockId={blockId} {...floatingUIOptions}>\n      {blockId && <Component blockId={blockId} />}\n    </BlockPopover>\n  );\n};\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n  formatKeyboardShortcut,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { IconType } from \"react-icons\";\nimport {\n  RiBold,\n  RiCodeFill,\n  RiItalic,\n  RiStrikethrough,\n  RiUnderline,\n} from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\ntype BasicTextStyle = \"bold\" | \"italic\" | \"underline\" | \"strike\" | \"code\";\n\nconst icons = {\n  bold: RiBold,\n  italic: RiItalic,\n  underline: RiUnderline,\n  strike: RiStrikethrough,\n  code: RiCodeFill,\n} satisfies Record<BasicTextStyle, IconType>;\n\nfunction checkBasicTextStyleInSchema<Style extends BasicTextStyle>(\n  style: Style,\n  editor: BlockNoteEditor<BlockSchema, InlineContentSchema, any>,\n): editor is BlockNoteEditor<\n  BlockSchema,\n  InlineContentSchema,\n  {\n    [k in Style]: {\n      type: k;\n      propSchema: \"boolean\";\n    };\n  }\n> {\n  return (\n    style in editor.schema.styleSchema &&\n    editor.schema.styleSchema[style].type === style &&\n    editor.schema.styleSchema[style].propSchema === \"boolean\"\n  );\n}\n\nexport const BasicTextStyleButton = <Style extends BasicTextStyle>(props: {\n  basicTextStyle: Style;\n}) => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      // Do not show if:\n      if (\n        // The editor is read-only.\n        !editor.isEditable ||\n        // The style is not in the schema.\n        !checkBasicTextStyleInSchema(props.basicTextStyle, editor) ||\n        // None of the selected blocks have inline content\n        !(\n          editor.getSelection()?.blocks || [\n            editor.getTextCursorPosition().block,\n          ]\n        ).find((block) => block.content !== undefined)\n      ) {\n        return undefined;\n      }\n\n      return props.basicTextStyle in editor.getActiveStyles()\n        ? { active: true }\n        : { active: false };\n    },\n  });\n\n  const toggleStyle = useCallback(\n    (style: typeof props.basicTextStyle) => {\n      editor.focus();\n      editor.toggleStyles({ [style]: true } as any);\n    },\n    [editor, props],\n  );\n\n  if (state === undefined) {\n    return null;\n  }\n\n  const Icon = icons[props.basicTextStyle] as any; // TODO\n  return (\n    <Components.FormattingToolbar.Button\n      className=\"bn-button\"\n      data-test={props.basicTextStyle}\n      onClick={() => toggleStyle(props.basicTextStyle)}\n      isSelected={state.active}\n      label={dict.formatting_toolbar[props.basicTextStyle].tooltip}\n      mainTooltip={dict.formatting_toolbar[props.basicTextStyle].tooltip}\n      secondaryTooltip={formatKeyboardShortcut(\n        dict.formatting_toolbar[props.basicTextStyle].secondary_tooltip,\n        dict.generic.ctrl_shortcut,\n      )}\n      icon={<Icon />}\n    />\n  );\n};\n","import { useMemo } from \"react\";\n\nexport const ColorIcon = (\n  props: Partial<{\n    textColor: string | undefined;\n    backgroundColor: string | undefined;\n    size: number | undefined;\n  }>,\n) => {\n  const textColor = props.textColor || \"default\";\n  const backgroundColor = props.backgroundColor || \"default\";\n  const size = props.size || 16;\n\n  const style = useMemo(\n    () =>\n      ({\n        pointerEvents: \"none\",\n        fontSize: (size * 0.75).toString() + \"px\",\n        height: size.toString() + \"px\",\n        lineHeight: size.toString() + \"px\",\n        textAlign: \"center\",\n        width: size.toString() + \"px\",\n      }) as const,\n    [size],\n  );\n\n  return (\n    <div\n      className={\"bn-color-icon\"}\n      data-background-color={backgroundColor}\n      data-text-color={textColor}\n      style={style}\n    >\n      A\n    </div>\n  );\n};\n","import { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../i18n/dictionary.js\";\nimport { ColorIcon } from \"./ColorIcon.js\";\n\nconst colors = [\n  \"default\",\n  \"gray\",\n  \"brown\",\n  \"red\",\n  \"orange\",\n  \"yellow\",\n  \"green\",\n  \"blue\",\n  \"purple\",\n  \"pink\",\n] as const;\n\nexport const ColorPicker = (props: {\n  onClick?: () => void;\n  iconSize?: number;\n  text?: {\n    color: string;\n    setColor: (color: string) => void;\n  };\n  background?: {\n    color: string;\n    setColor: (color: string) => void;\n  };\n}) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n  const TextColorSection = () =>\n    props.text ? (\n      <>\n        <Components.Generic.Menu.Label>\n          {dict.color_picker.text_title}\n        </Components.Generic.Menu.Label>\n        {colors.map((color) => (\n          <Components.Generic.Menu.Item\n            onClick={() => {\n              props.onClick && props.onClick();\n              props.text!.setColor(color);\n            }}\n            data-test={\"text-color-\" + color}\n            icon={<ColorIcon textColor={color} size={props.iconSize} />}\n            checked={props.text!.color === color}\n            key={\"text-color-\" + color}\n          >\n            {dict.color_picker.colors[color]}\n          </Components.Generic.Menu.Item>\n        ))}\n      </>\n    ) : null;\n\n  const BackgroundColorSection = () =>\n    props.background ? (\n      <>\n        <Components.Generic.Menu.Label>\n          {dict.color_picker.background_title}\n        </Components.Generic.Menu.Label>\n        {colors.map((color) => (\n          <Components.Generic.Menu.Item\n            onClick={() => {\n              props.onClick && props.onClick();\n              props.background!.setColor(color);\n            }}\n            data-test={\"background-color-\" + color}\n            icon={<ColorIcon backgroundColor={color} size={props.iconSize} />}\n            key={\"background-color-\" + color}\n            checked={props.background!.color === color}\n          >\n            {dict.color_picker.colors[color]}\n          </Components.Generic.Menu.Item>\n        ))}\n      </>\n    ) : null;\n\n  return (\n    <>\n      <TextColorSection />\n      <BackgroundColorSection />\n    </>\n  );\n};\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { ColorIcon } from \"../../ColorPicker/ColorIcon.js\";\nimport { ColorPicker } from \"../../ColorPicker/ColorPicker.js\";\n\nfunction checkColorInSchema<Color extends \"text\" | \"background\">(\n  color: Color,\n  editor: BlockNoteEditor<any, any, any>,\n): editor is BlockNoteEditor<\n  BlockSchema,\n  InlineContentSchema,\n  Color extends \"text\"\n    ? {\n        textColor: {\n          type: \"textColor\";\n          propSchema: \"string\";\n        };\n      }\n    : {\n        backgroundColor: {\n          type: \"backgroundColor\";\n          propSchema: \"string\";\n        };\n      }\n> {\n  return (\n    `${color}Color` in editor.schema.styleSchema &&\n    editor.schema.styleSchema[`${color}Color`].type === `${color}Color` &&\n    editor.schema.styleSchema[`${color}Color`].propSchema === \"string\"\n  );\n}\n\nexport const ColorStyleButton = () => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const textColorInSchema = checkColorInSchema(\"text\", editor);\n  const backgroundColorInSchema = checkColorInSchema(\"background\", editor);\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      // Do not show if:\n      if (\n        // The editor is read-only.\n        !editor.isEditable ||\n        // None of the selected blocks have inline content\n        !(\n          editor.getSelection()?.blocks || [\n            editor.getTextCursorPosition().block,\n          ]\n        ).find((block) => block.content !== undefined)\n      ) {\n        return undefined;\n      }\n\n      const textColorInSchema = checkColorInSchema(\"text\", editor);\n      const backgroundColorInSchema = checkColorInSchema(\"background\", editor);\n\n      if (!textColorInSchema && !backgroundColorInSchema) {\n        return undefined;\n      }\n\n      return {\n        textColor: (textColorInSchema\n          ? editor.getActiveStyles().textColor || \"default\"\n          : undefined) as string | undefined,\n        backgroundColor: (backgroundColorInSchema\n          ? editor.getActiveStyles().backgroundColor || \"default\"\n          : undefined) as string | undefined,\n      };\n    },\n  });\n\n  const setTextColor = useCallback(\n    (color: string) => {\n      if (!textColorInSchema) {\n        throw Error(\n          \"Tried to set text color, but style does not exist in editor schema.\",\n        );\n      }\n\n      color === \"default\"\n        ? editor.removeStyles({ textColor: color })\n        : editor.addStyles({ textColor: color });\n\n      setTimeout(() => {\n        // timeout needed to ensure compatibility with Mantine Toolbar useFocusTrap\n        editor.focus();\n      });\n    },\n    [editor, textColorInSchema],\n  );\n\n  const setBackgroundColor = useCallback(\n    (color: string) => {\n      if (!backgroundColorInSchema) {\n        throw Error(\n          \"Tried to set background color, but style does not exist in editor schema.\",\n        );\n      }\n\n      color === \"default\"\n        ? editor.removeStyles({ backgroundColor: color })\n        : editor.addStyles({ backgroundColor: color });\n\n      setTimeout(() => {\n        // timeout needed to ensure compatibility with Mantine Toolbar useFocusTrap\n        editor.focus();\n      });\n    },\n    [backgroundColorInSchema, editor],\n  );\n\n  if (state === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Root>\n      <Components.Generic.Menu.Trigger>\n        <Components.FormattingToolbar.Button\n          className={\"bn-button\"}\n          data-test=\"colors\"\n          label={dict.formatting_toolbar.colors.tooltip}\n          mainTooltip={dict.formatting_toolbar.colors.tooltip}\n          icon={\n            <ColorIcon\n              textColor={state.textColor}\n              backgroundColor={state.backgroundColor}\n              size={20}\n            />\n          }\n        />\n      </Components.Generic.Menu.Trigger>\n      <Components.Generic.Menu.Dropdown\n        className={\"bn-menu-dropdown bn-color-picker-dropdown\"}\n      >\n        <ColorPicker\n          text={\n            state.textColor\n              ? {\n                  color: state.textColor,\n                  setColor: setTextColor,\n                }\n              : undefined\n          }\n          background={\n            state.backgroundColor\n              ? {\n                  color: state.backgroundColor,\n                  setColor: setBackgroundColor,\n                }\n              : undefined\n          }\n        />\n      </Components.Generic.Menu.Dropdown>\n    </Components.Generic.Menu.Root>\n  );\n};\n","import {\n  DEFAULT_LINK_PROTOCOL,\n  LinkToolbarExtension,\n  VALID_LINK_PROTOCOLS,\n} from \"@blocknote/core/extensions\";\nimport {\n  ChangeEvent,\n  KeyboardEvent,\n  useCallback,\n  useEffect,\n  useState,\n} from \"react\";\nimport { RiLink, RiText } from \"react-icons/ri\";\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useExtension } from \"../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../i18n/dictionary.js\";\nimport { LinkToolbarProps } from \"./LinkToolbarProps.js\";\n\nconst validateUrl = (url: string) => {\n  for (const protocol of VALID_LINK_PROTOCOLS) {\n    if (url.startsWith(protocol)) {\n      return url;\n    }\n  }\n\n  return `${DEFAULT_LINK_PROTOCOL}://${url}`;\n};\n\nexport const EditLinkMenuItems = (\n  props: Pick<\n    LinkToolbarProps,\n    \"url\" | \"text\" | \"range\" | \"setToolbarOpen\" | \"setToolbarPositionFrozen\"\n  > & {\n    showTextField?: boolean;\n  },\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const { editLink } = useExtension(LinkToolbarExtension);\n\n  const { url, text, showTextField } = props;\n\n  const [currentUrl, setCurrentUrl] = useState<string>(url);\n  const [currentText, setCurrentText] = useState<string>(text);\n\n  useEffect(() => {\n    setCurrentUrl(url);\n    setCurrentText(text);\n  }, [text, url]);\n\n  const handleEnter = useCallback(\n    (event: KeyboardEvent) => {\n      if (event.key === \"Enter\" && !event.nativeEvent.isComposing) {\n        event.preventDefault();\n        editLink(validateUrl(currentUrl), currentText, props.range.from);\n        props.setToolbarOpen?.(false);\n        props.setToolbarPositionFrozen?.(false);\n      }\n    },\n    [editLink, currentUrl, currentText, props],\n  );\n\n  const handleUrlChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) =>\n      setCurrentUrl(event.currentTarget.value),\n    [],\n  );\n\n  const handleTextChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) =>\n      setCurrentText(event.currentTarget.value),\n    [],\n  );\n\n  const handleSubmit = useCallback(() => {\n    editLink(validateUrl(currentUrl), currentText, props.range.from);\n    props.setToolbarOpen?.(false);\n    props.setToolbarPositionFrozen?.(false);\n  }, [editLink, currentUrl, currentText, props]);\n\n  return (\n    <Components.Generic.Form.Root>\n      {/* // TODO: add labels? */}\n      <Components.Generic.Form.TextInput\n        className={\"bn-text-input\"}\n        name=\"url\"\n        icon={<RiLink />}\n        autoFocus={true}\n        placeholder={dict.link_toolbar.form.url_placeholder}\n        value={currentUrl}\n        onKeyDown={handleEnter}\n        onChange={handleUrlChange}\n        onSubmit={handleSubmit}\n      />\n      {showTextField !== false && (\n        <Components.Generic.Form.TextInput\n          className={\"bn-text-input\"}\n          name=\"title\"\n          icon={<RiText />}\n          placeholder={dict.link_toolbar.form.title_placeholder}\n          value={currentText}\n          onKeyDown={handleEnter}\n          onChange={handleTextChange}\n          onSubmit={handleSubmit}\n        />\n      )}\n    </Components.Generic.Form.Root>\n  );\n};\n","import { useEffect, useState } from \"react\";\nimport { RiLink } from \"react-icons/ri\";\n\nimport {\n  BlockNoteEditor,\n  BlockSchema,\n  formatKeyboardShortcut,\n  isTableCellSelection,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport {\n  FormattingToolbarExtension,\n  ShowSelectionExtension,\n} from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useExtension } from \"../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { EditLinkMenuItems } from \"../../LinkToolbar/EditLinkMenuItems.js\";\n\nfunction checkLinkInSchema(\n  editor: BlockNoteEditor<BlockSchema, any, StyleSchema>,\n): editor is BlockNoteEditor<\n  BlockSchema,\n  {\n    link: {\n      type: \"link\";\n      propSchema: any;\n      content: \"styled\";\n    };\n  },\n  StyleSchema\n> {\n  return (\n    \"link\" in editor.schema.inlineContentSchema &&\n    editor.schema.inlineContentSchema[\"link\"] === \"link\"\n  );\n}\n\nexport const CreateLinkButton = () => {\n  const editor = useBlockNoteEditor<any, any, any>();\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const formattingToolbar = useExtension(FormattingToolbarExtension);\n  const { showSelection } = useExtension(ShowSelectionExtension);\n\n  const [showPopover, setShowPopover] = useState(false);\n  useEffect(() => {\n    showSelection(showPopover, \"createLinkButton\");\n    return () => showSelection(false, \"createLinkButton\");\n  }, [showPopover, showSelection]);\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      // Do not show if:\n      if (\n        // The editor is read-only.\n        !editor.isEditable ||\n        // Links are not in the schema.\n        !checkLinkInSchema(editor) ||\n        // Table cells are selected.\n        isTableCellSelection(editor.prosemirrorState.selection) ||\n        // None of the selected blocks have inline content\n        !(\n          editor.getSelection()?.blocks || [\n            editor.getTextCursorPosition().block,\n          ]\n        ).find((block) => block.content !== undefined)\n      ) {\n        return undefined;\n      }\n\n      return {\n        url: editor.getSelectedLinkUrl(),\n        text: editor.getSelectedText(),\n        range: {\n          from: editor.prosemirrorState.selection.from,\n          to: editor.prosemirrorState.selection.to,\n        },\n      };\n    },\n  });\n  useEffect(() => {\n    setShowPopover(false);\n  }, [state]);\n\n  // Makes Ctrl+K/Meta+K open link creation popover.\n  useEffect(() => {\n    const callback = (event: KeyboardEvent) => {\n      if ((event.ctrlKey || event.metaKey) && event.key === \"k\") {\n        setShowPopover(true);\n        event.preventDefault();\n      }\n    };\n\n    const domElement = editor.domElement;\n    domElement?.addEventListener(\"keydown\", callback);\n\n    return () => {\n      domElement?.removeEventListener(\"keydown\", callback);\n    };\n  }, [editor.domElement]);\n\n  if (state === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Popover.Root\n      open={showPopover}\n      onOpenChange={setShowPopover}\n    >\n      <Components.Generic.Popover.Trigger>\n        {/* TODO: hide tooltip on click */}\n        <Components.FormattingToolbar.Button\n          className={\"bn-button\"}\n          data-test=\"createLink\"\n          label={dict.formatting_toolbar.link.tooltip}\n          mainTooltip={dict.formatting_toolbar.link.tooltip}\n          secondaryTooltip={formatKeyboardShortcut(\n            dict.formatting_toolbar.link.secondary_tooltip,\n            dict.generic.ctrl_shortcut,\n          )}\n          icon={<RiLink />}\n          onClick={() => setShowPopover((open) => !open)}\n        />\n      </Components.Generic.Popover.Trigger>\n      <Components.Generic.Popover.Content\n        className={\"bn-popover-content bn-form-popover\"}\n        variant={\"form-popover\"}\n      >\n        <EditLinkMenuItems\n          url={state.url || \"\"}\n          text={state.text}\n          range={state.range}\n          showTextField={false}\n          setToolbarOpen={(open) => formattingToolbar.store.setState(open)}\n        />\n      </Components.Generic.Popover.Content>\n    </Components.Generic.Popover.Root>\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  editorHasBlockWithType,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport {\n  ChangeEvent,\n  KeyboardEvent,\n  useCallback,\n  useEffect,\n  useState,\n} from \"react\";\nimport { RiInputField } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const FileCaptionButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n          caption: \"string\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  const [currentEditingCaption, setCurrentEditingCaption] = useState<string>();\n\n  useEffect(() => {\n    if (block === undefined) {\n      return;\n    }\n    setCurrentEditingCaption(block.props.caption);\n  }, [block]);\n\n  const handleChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) =>\n      setCurrentEditingCaption(event.currentTarget.value),\n    [],\n  );\n\n  const handleEnter = useCallback(\n    (event: KeyboardEvent) => {\n      if (\n        block !== undefined &&\n        editorHasBlockWithType(editor, block.type, {\n          caption: \"string\",\n        }) &&\n        event.key === \"Enter\" &&\n        !event.nativeEvent.isComposing\n      ) {\n        event.preventDefault();\n        editor.updateBlock(block.id, {\n          props: {\n            caption: currentEditingCaption,\n          },\n        });\n      }\n    },\n    [block, currentEditingCaption, editor],\n  );\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Popover.Root>\n      <Components.Generic.Popover.Trigger>\n        <Components.FormattingToolbar.Button\n          className={\"bn-button\"}\n          label={dict.formatting_toolbar.file_caption.tooltip}\n          mainTooltip={dict.formatting_toolbar.file_caption.tooltip}\n          icon={<RiInputField />}\n        />\n      </Components.Generic.Popover.Trigger>\n      <Components.Generic.Popover.Content\n        className={\"bn-popover-content bn-form-popover\"}\n        variant={\"form-popover\"}\n      >\n        <Components.Generic.Form.Root>\n          <Components.Generic.Form.TextInput\n            name={\"file-caption\"}\n            icon={<RiInputField />}\n            value={currentEditingCaption || \"\"}\n            autoFocus={true}\n            placeholder={dict.formatting_toolbar.file_caption.input_placeholder}\n            onKeyDown={handleEnter}\n            onChange={handleChange}\n          />\n        </Components.Generic.Form.Root>\n      </Components.Generic.Popover.Content>\n    </Components.Generic.Popover.Root>\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { RiDeleteBin7Line } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const FileDeleteButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  const onClick = useCallback(() => {\n    if (block !== undefined) {\n      editor.focus();\n      editor.removeBlocks([block.id]);\n    }\n  }, [block, editor]);\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={\n        dict.formatting_toolbar.file_delete.tooltip[block.type] ||\n        dict.formatting_toolbar.file_delete.tooltip[\"file\"]\n      }\n      mainTooltip={\n        dict.formatting_toolbar.file_delete.tooltip[block.type] ||\n        dict.formatting_toolbar.file_delete.tooltip[\"file\"]\n      }\n      icon={<RiDeleteBin7Line />}\n      onClick={onClick}\n    />\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  editorHasBlockWithType,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport {\n  ChangeEvent,\n  KeyboardEvent,\n  useCallback,\n  useEffect,\n  useState,\n} from \"react\";\nimport { RiFontFamily } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const FileRenameButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n          name: \"string\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  const [currentEditingName, setCurrentEditingName] = useState<string>();\n\n  useEffect(() => {\n    if (block === undefined) {\n      return;\n    }\n\n    setCurrentEditingName(block.props.name);\n  }, [block]);\n\n  const handleChange = useCallback(\n    (event: ChangeEvent<HTMLInputElement>) =>\n      setCurrentEditingName(event.currentTarget.value),\n    [],\n  );\n\n  const handleEnter = useCallback(\n    (event: KeyboardEvent) => {\n      if (\n        block !== undefined &&\n        editorHasBlockWithType(editor, block.type, {\n          name: \"string\",\n        }) &&\n        event.key === \"Enter\" &&\n        !event.nativeEvent.isComposing\n      ) {\n        event.preventDefault();\n        editor.updateBlock(block.id, {\n          props: {\n            name: currentEditingName,\n          },\n        });\n      }\n    },\n    [block, currentEditingName, editor],\n  );\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Popover.Root>\n      <Components.Generic.Popover.Trigger>\n        <Components.FormattingToolbar.Button\n          className={\"bn-button\"}\n          label={\n            dict.formatting_toolbar.file_rename.tooltip[block.type] ||\n            dict.formatting_toolbar.file_rename.tooltip[\"file\"]\n          }\n          mainTooltip={\n            dict.formatting_toolbar.file_rename.tooltip[block.type] ||\n            dict.formatting_toolbar.file_rename.tooltip[\"file\"]\n          }\n          icon={<RiFontFamily />}\n        />\n      </Components.Generic.Popover.Trigger>\n      <Components.Generic.Popover.Content\n        className={\"bn-popover-content bn-form-popover\"}\n        variant={\"form-popover\"}\n      >\n        <Components.Generic.Form.Root>\n          <Components.Generic.Form.TextInput\n            name={\"file-name\"}\n            icon={<RiFontFamily />}\n            value={currentEditingName || \"\"}\n            autoFocus={true}\n            placeholder={\n              dict.formatting_toolbar.file_rename.input_placeholder[\n                block.type\n              ] || dict.formatting_toolbar.file_rename.input_placeholder[\"file\"]\n            }\n            onKeyDown={handleEnter}\n            onChange={handleChange}\n          />\n        </Components.Generic.Form.Root>\n      </Components.Generic.Popover.Content>\n    </Components.Generic.Popover.Root>\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { RiImageEditFill } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { FilePanel } from \"../../FilePanel/FilePanel.js\";\n\nexport const FileReplaceButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Popover.Root position={\"bottom\"}>\n      <Components.Generic.Popover.Trigger>\n        <Components.FormattingToolbar.Button\n          className={\"bn-button\"}\n          mainTooltip={\n            dict.formatting_toolbar.file_replace.tooltip[block.type] ||\n            dict.formatting_toolbar.file_replace.tooltip[\"file\"]\n          }\n          label={\n            dict.formatting_toolbar.file_replace.tooltip[block.type] ||\n            dict.formatting_toolbar.file_replace.tooltip[\"file\"]\n          }\n          icon={<RiImageEditFill />}\n        />\n      </Components.Generic.Popover.Trigger>\n      <Components.Generic.Popover.Content\n        className={\"bn-popover-content bn-panel-popover\"}\n        variant={\"panel-popover\"}\n      >\n        <FilePanel blockId={block.id} />\n      </Components.Generic.Popover.Content>\n    </Components.Generic.Popover.Root>\n  );\n};\n","import {\n  BlockSchema,\n  formatKeyboardShortcut,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { RiIndentDecrease, RiIndentIncrease } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const NestBlockButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      // Do not show if:\n      if (\n        // The editor is read-only.\n        !editor.isEditable ||\n        // None of the selected blocks have inline content\n        !(\n          editor.getSelection()?.blocks || [\n            editor.getTextCursorPosition().block,\n          ]\n        ).find((block) => block.content !== undefined)\n      ) {\n        return undefined;\n      }\n\n      return {\n        canNestBlock: editor.canNestBlock(),\n      };\n    },\n  });\n\n  const nestBlock = useCallback(() => {\n    if (state !== undefined && state.canNestBlock) {\n      editor.focus();\n      editor.nestBlock();\n    }\n  }, [editor, state]);\n\n  if (state === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      data-test=\"nestBlock\"\n      onClick={nestBlock}\n      isDisabled={!state.canNestBlock}\n      label={dict.formatting_toolbar.nest.tooltip}\n      mainTooltip={dict.formatting_toolbar.nest.tooltip}\n      secondaryTooltip={formatKeyboardShortcut(\n        dict.formatting_toolbar.nest.secondary_tooltip,\n        dict.generic.ctrl_shortcut,\n      )}\n      icon={<RiIndentIncrease />}\n    />\n  );\n};\n\nexport const UnnestBlockButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      // Do not show if:\n      if (\n        // The editor is read-only.\n        !editor.isEditable ||\n        // None of the selected blocks have inline content\n        !(\n          editor.getSelection()?.blocks || [\n            editor.getTextCursorPosition().block,\n          ]\n        ).find((block) => block.content !== undefined)\n      ) {\n        return undefined;\n      }\n\n      return {\n        canUnnestBlock: editor.canUnnestBlock(),\n      };\n    },\n  });\n\n  const unnestBlock = useCallback(() => {\n    if (state !== undefined && state.canUnnestBlock) {\n      editor.focus();\n      editor.unnestBlock();\n    }\n  }, [editor, state]);\n\n  if (state === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      data-test=\"unnestBlock\"\n      onClick={unnestBlock}\n      isDisabled={!state.canUnnestBlock}\n      label={dict.formatting_toolbar.unnest.tooltip}\n      mainTooltip={dict.formatting_toolbar.unnest.tooltip}\n      secondaryTooltip={formatKeyboardShortcut(\n        dict.formatting_toolbar.unnest.secondary_tooltip,\n        dict.generic.ctrl_shortcut,\n      )}\n      icon={<RiIndentDecrease />}\n    />\n  );\n};\n","import {\n  BlockSchema,\n  Dictionary,\n  editorHasBlockWithType,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useMemo } from \"react\";\nimport type { IconType } from \"react-icons\";\nimport {\n  RiH1,\n  RiH2,\n  RiH3,\n  RiH4,\n  RiH5,\n  RiH6,\n  RiListCheck3,\n  RiListOrdered,\n  RiListUnordered,\n  RiPlayList2Fill,\n  RiQuoteText,\n  RiText,\n} from \"react-icons/ri\";\n\nimport {\n  ComponentProps,\n  useComponentsContext,\n} from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\n\nexport type BlockTypeSelectItem = {\n  name: string;\n  type: string;\n  props?: Record<string, boolean | number | string>;\n  icon: IconType;\n};\n\nexport const blockTypeSelectItems = (\n  dict: Dictionary,\n): BlockTypeSelectItem[] => [\n  {\n    name: dict.slash_menu.paragraph.title,\n    type: \"paragraph\",\n    icon: RiText,\n  },\n  {\n    name: dict.slash_menu.heading.title,\n    type: \"heading\",\n    props: { level: 1, isToggleable: false },\n    icon: RiH1,\n  },\n  {\n    name: dict.slash_menu.heading_2.title,\n    type: \"heading\",\n    props: { level: 2, isToggleable: false },\n    icon: RiH2,\n  },\n  {\n    name: dict.slash_menu.heading_3.title,\n    type: \"heading\",\n    props: { level: 3, isToggleable: false },\n    icon: RiH3,\n  },\n  {\n    name: dict.slash_menu.heading_4.title,\n    type: \"heading\",\n    props: { level: 4, isToggleable: false },\n    icon: RiH4,\n  },\n  {\n    name: dict.slash_menu.heading_5.title,\n    type: \"heading\",\n    props: { level: 5, isToggleable: false },\n    icon: RiH5,\n  },\n  {\n    name: dict.slash_menu.heading_6.title,\n    type: \"heading\",\n    props: { level: 6, isToggleable: false },\n    icon: RiH6,\n  },\n  {\n    name: dict.slash_menu.toggle_heading.title,\n    type: \"heading\",\n    props: { level: 1, isToggleable: true },\n    icon: RiH1,\n  },\n  {\n    name: dict.slash_menu.toggle_heading_2.title,\n    type: \"heading\",\n    props: { level: 2, isToggleable: true },\n    icon: RiH2,\n  },\n  {\n    name: dict.slash_menu.toggle_heading_3.title,\n    type: \"heading\",\n    props: { level: 3, isToggleable: true },\n    icon: RiH3,\n  },\n  {\n    name: dict.slash_menu.quote.title,\n    type: \"quote\",\n    icon: RiQuoteText,\n  },\n  {\n    name: dict.slash_menu.toggle_list.title,\n    type: \"toggleListItem\",\n    icon: RiPlayList2Fill,\n  },\n  {\n    name: dict.slash_menu.bullet_list.title,\n    type: \"bulletListItem\",\n    icon: RiListUnordered,\n  },\n  {\n    name: dict.slash_menu.numbered_list.title,\n    type: \"numberedListItem\",\n    icon: RiListOrdered,\n  },\n  {\n    name: dict.slash_menu.check_list.title,\n    type: \"checkListItem\",\n    icon: RiListCheck3,\n  },\n];\n\nexport const BlockTypeSelect = (props: { items?: BlockTypeSelectItem[] }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const selectedBlocks = useEditorState({\n    editor,\n    selector: ({ editor }) =>\n      editor.getSelection()?.blocks || [editor.getTextCursorPosition().block],\n  });\n  const firstSelectedBlock = selectedBlocks[0];\n\n  // Filters out all items in which the block type and props don't conform to\n  // the schema.\n  const filteredItems = useMemo(\n    () =>\n      (props.items || blockTypeSelectItems(editor.dictionary)).filter((item) =>\n        editorHasBlockWithType(\n          editor,\n          item.type,\n          Object.fromEntries(\n            Object.entries(item.props || {}).map(([propName, propValue]) => [\n              propName,\n              typeof propValue,\n            ]),\n          ) as Record<string, \"string\" | \"number\" | \"boolean\">,\n        ),\n      ),\n    [editor, props.items],\n  );\n\n  // Processes `filteredItems` to an array that can be passed to\n  // `Components.FormattingToolbar.Select`.\n  const selectItems: ComponentProps[\"FormattingToolbar\"][\"Select\"][\"items\"] =\n    useMemo(() => {\n      return filteredItems.map((item) => {\n        const Icon = item.icon;\n\n        const typesMatch = item.type === firstSelectedBlock.type;\n        const propsMatch =\n          Object.entries(item.props || {}).filter(\n            ([propName, propValue]) =>\n              propValue !== firstSelectedBlock.props[propName],\n          ).length === 0;\n\n        return {\n          text: item.name,\n          icon: <Icon size={16} />,\n          onClick: () => {\n            editor.focus();\n            editor.transact(() => {\n              for (const block of selectedBlocks) {\n                editor.updateBlock(block, {\n                  type: item.type as any,\n                  props: item.props as any,\n                });\n              }\n            });\n          },\n          isSelected: typesMatch && propsMatch,\n        };\n      });\n    }, [\n      editor,\n      filteredItems,\n      firstSelectedBlock.props,\n      firstSelectedBlock.type,\n      selectedBlocks,\n    ]);\n\n  const shouldShow: boolean = useMemo(\n    () => selectItems.find((item) => item.isSelected) !== undefined,\n    [selectItems],\n  );\n\n  if (!shouldShow || !editor.isEditable) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Select\n      className={\"bn-select\"}\n      items={selectItems}\n    />\n  );\n};\n","import { FormattingToolbarExtension } from \"@blocknote/core/extensions\";\n// Specifically using type here to avoid pulling in the comments extensions into the main bundle\nimport type { CommentsExtension } from \"@blocknote/core/comments\";\nimport { useCallback } from \"react\";\nimport { RiChat3Line } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useExtension } from \"../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const AddCommentButtonInner = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const comments = useExtension(\"comments\") as unknown as ReturnType<\n    ReturnType<typeof CommentsExtension>\n  >;\n  const { store } = useExtension(FormattingToolbarExtension);\n\n  const onClick = useCallback(() => {\n    comments.startPendingComment();\n    store.setState(false);\n  }, [comments, store]);\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={dict.formatting_toolbar.comment.tooltip}\n      mainTooltip={dict.formatting_toolbar.comment.tooltip}\n      icon={<RiChat3Line />}\n      onClick={onClick}\n    />\n  );\n};\n\nexport const AddCommentButton = () => {\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  if (!editor.getExtension(\"comments\")) {\n    return null;\n  }\n\n  return <AddCommentButtonInner />;\n};\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { RiChat3Line } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\n/**\n * This comment button shows when a addPendingComment command is available on the underlying tiptap editor.\n */\nexport const AddTiptapCommentButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const onClick = useCallback(() => {\n    (editor._tiptapEditor as any).chain().focus().addPendingComment().run();\n  }, [editor]);\n\n  if (\n    // We manually check if a comment extension (like liveblocks) is installed\n    // By adding default support for this, the user doesn't need to customize the formatting toolbar\n    !(editor._tiptapEditor.commands as any)[\"addPendingComment\"] ||\n    !editor.isEditable\n  ) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={dict.formatting_toolbar.comment.tooltip}\n      mainTooltip={dict.formatting_toolbar.comment.tooltip}\n      icon={<RiChat3Line />}\n      onClick={onClick}\n    />\n  );\n};\n","/**\n * Sanitizes a potentially unsafe URL.\n * @param {string} inputUrl - The URL to sanitize.\n * @param {string} baseUrl - The base URL to use for relative URLs.\n * @returns {string} The normalized URL, or \"#\" if the URL is invalid or unsafe.\n */\nexport function sanitizeUrl(inputUrl: string, baseUrl: string): string {\n  try {\n    const url = new URL(inputUrl, baseUrl);\n\n    // eslint-disable-next-line no-script-url -- false positive, we are explicitly checking if the protocol is safe to prevent XSS\n    if (url.protocol !== \"javascript:\") {\n      return url.href;\n    }\n  } catch (error) {\n    // if URL creation fails, it's an invalid URL\n  }\n\n  // return a safe default for invalid or unsafe URLs\n  return \"#\";\n}\n","import {\n  blockHasType,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { RiDownload2Fill } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { sanitizeUrl } from \"../../../util/sanitizeUrl.js\";\n\nexport const FileDownloadButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  const onClick = useCallback(() => {\n    if (block !== undefined) {\n      editor.focus();\n\n      if (!editor.resolveFileUrl) {\n        window.open(sanitizeUrl(block.props.url, window.location.href));\n      } else {\n        editor\n          .resolveFileUrl(block.props.url)\n          .then((downloadUrl) =>\n            window.open(sanitizeUrl(downloadUrl, window.location.href)),\n          );\n      }\n    }\n  }, [block, editor]);\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={\n        dict.formatting_toolbar.file_download.tooltip[block.type] ||\n        dict.formatting_toolbar.file_download.tooltip[\"file\"]\n      }\n      mainTooltip={\n        dict.formatting_toolbar.file_download.tooltip[block.type] ||\n        dict.formatting_toolbar.file_download.tooltip[\"file\"]\n      }\n      icon={<RiDownload2Fill />}\n      onClick={onClick}\n    />\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  editorHasBlockWithType,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useCallback } from \"react\";\nimport { RiImageAddFill } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nexport const FilePreviewButton = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const block = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          url: \"string\",\n          showPreview: \"boolean\",\n        })\n      ) {\n        return undefined;\n      }\n\n      return block;\n    },\n  });\n\n  const onClick = useCallback(() => {\n    if (\n      block !== undefined &&\n      editorHasBlockWithType(editor, block.type, {\n        showPreview: \"boolean\",\n      })\n    ) {\n      editor.updateBlock(block.id, {\n        props: {\n          showPreview: !block.props.showPreview,\n        },\n      });\n    }\n  }, [block, editor]);\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={\"Toggle preview\"}\n      mainTooltip={dict.formatting_toolbar.file_preview_toggle.tooltip}\n      icon={<RiImageAddFill />}\n      isSelected={block.props.showPreview}\n      onClick={onClick}\n    />\n  );\n};\n","import {\n  DefaultBlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { useCallback } from \"react\";\nimport { RiMergeCellsHorizontal, RiMergeCellsVertical } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useExtension } from \"../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\nconst TableCellMergeButtonInner = () => {\n  const dict = useDictionary();\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    {\n      table: DefaultBlockSchema[\"table\"];\n    },\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable || !editor.settings.tables.splitCells) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      if (selectedBlocks.length !== 1) {\n        return undefined;\n      }\n\n      const block = selectedBlocks[0];\n\n      if (block.type !== \"table\") {\n        return undefined;\n      }\n\n      return {\n        mergeDirection: tableHandles.getMergeDirection(block),\n      };\n    },\n  });\n\n  const onClick = useCallback(() => {\n    tableHandles?.mergeCells();\n  }, [tableHandles]);\n\n  if (state === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      label={dict.formatting_toolbar.table_cell_merge.tooltip}\n      mainTooltip={dict.formatting_toolbar.table_cell_merge.tooltip}\n      icon={\n        state.mergeDirection === \"horizontal\" ? (\n          <RiMergeCellsHorizontal />\n        ) : (\n          <RiMergeCellsVertical />\n        )\n      }\n      onClick={onClick}\n    />\n  );\n};\n\nexport const TableCellMergeButton = () => {\n  const editor = useBlockNoteEditor();\n  if (!editor.getExtension(TableHandlesExtension)) {\n    return null;\n  }\n  return <TableCellMergeButtonInner />;\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  defaultProps,\n  DefaultProps,\n  editorHasBlockWithType,\n  InlineContentSchema,\n  mapTableCell,\n  StyleSchema,\n  TableContent,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { useCallback } from \"react\";\nimport { IconType } from \"react-icons\";\nimport {\n  RiAlignCenter,\n  RiAlignJustify,\n  RiAlignLeft,\n  RiAlignRight,\n} from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../../hooks/useEditorState.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\n\ntype TextAlignment = DefaultProps[\"textAlignment\"];\n\nconst icons: Record<TextAlignment, IconType> = {\n  left: RiAlignLeft,\n  center: RiAlignCenter,\n  right: RiAlignRight,\n  justify: RiAlignJustify,\n};\n\nexport const TextAlignButton = (props: { textAlignment: TextAlignment }) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const state = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (!editor.isEditable) {\n        return undefined;\n      }\n\n      const selectedBlocks = editor.getSelection()?.blocks || [\n        editor.getTextCursorPosition().block,\n      ];\n\n      const firstBlock = selectedBlocks[0];\n\n      if (\n        blockHasType(firstBlock, editor, firstBlock.type, {\n          textAlignment: defaultProps.textAlignment,\n        })\n      ) {\n        return {\n          textAlignment: firstBlock.props.textAlignment,\n          blocks: selectedBlocks,\n        };\n      }\n\n      if (\n        selectedBlocks.length === 1 &&\n        blockHasType(firstBlock, editor, \"table\")\n      ) {\n        const cellSelection = editor\n          .getExtension(TableHandlesExtension)\n          ?.getCellSelection();\n\n        if (!cellSelection) {\n          return undefined;\n        }\n\n        return {\n          textAlignment: mapTableCell(\n            (firstBlock.content as TableContent<any, any>).rows[0].cells[0],\n          ).props.textAlignment,\n          blocks: [firstBlock],\n        };\n      }\n\n      return undefined;\n    },\n  });\n\n  const setTextAlignment = useCallback(\n    (textAlignment: TextAlignment) => {\n      if (state === undefined) {\n        return;\n      }\n\n      editor.focus();\n\n      for (const block of state.blocks) {\n        if (\n          blockHasType(block, editor, block.type, {\n            textAlignment: defaultProps.textAlignment,\n          }) &&\n          editorHasBlockWithType(editor, block.type, {\n            textAlignment: defaultProps.textAlignment,\n          })\n        ) {\n          editor.updateBlock(block, {\n            props: { textAlignment: textAlignment },\n          });\n        } else if (block.type === \"table\") {\n          const cellSelection = editor\n            .getExtension(TableHandlesExtension)\n            ?.getCellSelection();\n          if (!cellSelection) {\n            continue;\n          }\n\n          const newTable = (block.content as TableContent<any, any>).rows.map(\n            (row) => {\n              return {\n                ...row,\n                cells: row.cells.map((cell) => {\n                  return mapTableCell(cell);\n                }),\n              };\n            },\n          );\n\n          // Apply the text alignment to the cells that are within the selected range\n          cellSelection.cells.forEach(({ row, col }) => {\n            newTable[row].cells[col].props.textAlignment = textAlignment;\n          });\n\n          editor.updateBlock(block, {\n            type: \"table\",\n            content: {\n              ...(block.content as TableContent<any, any>),\n              type: \"tableContent\",\n              rows: newTable,\n            } as any,\n          });\n\n          // Have to reset text cursor position to the block as `updateBlock`\n          // moves the existing selection out of the block.\n          editor.setTextCursorPosition(block);\n        }\n      }\n    },\n    [editor, state],\n  );\n\n  if (state === undefined) {\n    return null;\n  }\n\n  const Icon: IconType = icons[props.textAlignment];\n  return (\n    <Components.FormattingToolbar.Button\n      className={\"bn-button\"}\n      data-test={`alignText${\n        props.textAlignment.slice(0, 1).toUpperCase() +\n        props.textAlignment.slice(1)\n      }`}\n      onClick={() => setTextAlignment(props.textAlignment)}\n      isSelected={state.textAlignment === props.textAlignment}\n      label={dict.formatting_toolbar[`align_${props.textAlignment}`].tooltip}\n      mainTooltip={\n        dict.formatting_toolbar[`align_${props.textAlignment}`].tooltip\n      }\n      icon={<Icon />}\n    />\n  );\n};\n","import { JSX, ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { BasicTextStyleButton } from \"./DefaultButtons/BasicTextStyleButton.js\";\nimport { ColorStyleButton } from \"./DefaultButtons/ColorStyleButton.js\";\nimport { CreateLinkButton } from \"./DefaultButtons/CreateLinkButton.js\";\nimport { FileCaptionButton } from \"./DefaultButtons/FileCaptionButton.js\";\nimport { FileDeleteButton } from \"./DefaultButtons/FileDeleteButton.js\";\nimport { FileRenameButton } from \"./DefaultButtons/FileRenameButton.js\";\nimport { FileReplaceButton } from \"./DefaultButtons/FileReplaceButton.js\";\nimport {\n  NestBlockButton,\n  UnnestBlockButton,\n} from \"./DefaultButtons/NestBlockButtons.js\";\nimport {\n  BlockTypeSelect,\n  BlockTypeSelectItem,\n} from \"./DefaultSelects/BlockTypeSelect.js\";\n\nimport { AddCommentButton } from \"./DefaultButtons/AddCommentButton.js\";\nimport { AddTiptapCommentButton } from \"./DefaultButtons/AddTiptapCommentButton.js\";\nimport { FileDownloadButton } from \"./DefaultButtons/FileDownloadButton.js\";\nimport { FilePreviewButton } from \"./DefaultButtons/FilePreviewButton.js\";\nimport { TableCellMergeButton } from \"./DefaultButtons/TableCellMergeButton.js\";\nimport { TextAlignButton } from \"./DefaultButtons/TextAlignButton.js\";\nimport { FormattingToolbarProps } from \"./FormattingToolbarProps.js\";\n\nexport const getFormattingToolbarItems = (\n  blockTypeSelectItems?: BlockTypeSelectItem[],\n): JSX.Element[] => [\n  <BlockTypeSelect key={\"blockTypeSelect\"} items={blockTypeSelectItems} />,\n  <TableCellMergeButton key={\"tableCellMergeButton\"} />,\n  <FileCaptionButton key={\"fileCaptionButton\"} />,\n  <FileReplaceButton key={\"replaceFileButton\"} />,\n  <FileRenameButton key={\"fileRenameButton\"} />,\n  <FileDeleteButton key={\"fileDeleteButton\"} />,\n  <FileDownloadButton key={\"fileDownloadButton\"} />,\n  <FilePreviewButton key={\"filePreviewButton\"} />,\n  <BasicTextStyleButton basicTextStyle={\"bold\"} key={\"boldStyleButton\"} />,\n  <BasicTextStyleButton basicTextStyle={\"italic\"} key={\"italicStyleButton\"} />,\n  <BasicTextStyleButton\n    basicTextStyle={\"underline\"}\n    key={\"underlineStyleButton\"}\n  />,\n  <BasicTextStyleButton basicTextStyle={\"strike\"} key={\"strikeStyleButton\"} />,\n  <TextAlignButton textAlignment={\"left\"} key={\"textAlignLeftButton\"} />,\n  <TextAlignButton textAlignment={\"center\"} key={\"textAlignCenterButton\"} />,\n  <TextAlignButton textAlignment={\"right\"} key={\"textAlignRightButton\"} />,\n  <ColorStyleButton key={\"colorStyleButton\"} />,\n  <NestBlockButton key={\"nestBlockButton\"} />,\n  <UnnestBlockButton key={\"unnestBlockButton\"} />,\n  <CreateLinkButton key={\"createLinkButton\"} />,\n  <AddCommentButton key={\"addCommentButton\"} />,\n  <AddTiptapCommentButton key={\"addTiptapCommentButton\"} />,\n];\n\n// TODO: props.blockTypeSelectItems should only be available if no children\n//  are passed\n/**\n * By default, the FormattingToolbar component will render with default\n * selects/buttons. However, you can override the selects/buttons to render\n * by passing children. The children you pass should be:\n *\n * - Default selects: Components found within the `/DefaultSelects` directory.\n * - Default buttons: Components found within the `/DefaultButtons` directory.\n * - Custom selects: The `ToolbarSelect` component in the\n * `components/mantine-shared/Toolbar` directory.\n * - Custom buttons: The `ToolbarButton` component in the\n * `components/mantine-shared/Toolbar` directory.\n */\nexport const FormattingToolbar = (\n  props: FormattingToolbarProps & { children?: ReactNode },\n) => {\n  const Components = useComponentsContext()!;\n\n  return (\n    <Components.FormattingToolbar.Root\n      className={\"bn-toolbar bn-formatting-toolbar\"}\n    >\n      {props.children || getFormattingToolbarItems(props.blockTypeSelectItems)}\n    </Components.FormattingToolbar.Root>\n  );\n};\n","import {\n  blockHasType,\n  BlockSchema,\n  defaultProps,\n  DefaultProps,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { FormattingToolbarExtension } from \"@blocknote/core/extensions\";\nimport { flip, offset, shift } from \"@floating-ui/react\";\nimport { FC, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useEditorState } from \"../../hooks/useEditorState.js\";\nimport { useExtension, useExtensionState } from \"../../hooks/useExtension.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport { PositionPopover } from \"../Popovers/PositionPopover.js\";\nimport { FormattingToolbar } from \"./FormattingToolbar.js\";\nimport { FormattingToolbarProps } from \"./FormattingToolbarProps.js\";\n\nconst textAlignmentToPlacement = (\n  textAlignment: DefaultProps[\"textAlignment\"],\n) => {\n  switch (textAlignment) {\n    case \"left\":\n      return \"top-start\";\n    case \"center\":\n      return \"top\";\n    case \"right\":\n      return \"top-end\";\n    default:\n      return \"top-start\";\n  }\n};\n\nexport const FormattingToolbarController = (props: {\n  formattingToolbar?: FC<FormattingToolbarProps>;\n  floatingUIOptions?: FloatingUIOptions;\n}) => {\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n  const formattingToolbar = useExtension(FormattingToolbarExtension, {\n    editor,\n  });\n  const show = useExtensionState(FormattingToolbarExtension, {\n    editor,\n  });\n\n  const position = useEditorState({\n    editor,\n    selector: ({ editor }) =>\n      formattingToolbar.store.state\n        ? {\n            from: editor.prosemirrorState.selection.from,\n            to: editor.prosemirrorState.selection.to,\n          }\n        : undefined,\n  });\n\n  const placement = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      const block = editor.getTextCursorPosition().block;\n\n      if (\n        !blockHasType(block, editor, block.type, {\n          textAlignment: defaultProps.textAlignment,\n        })\n      ) {\n        return \"top-start\";\n      } else {\n        return textAlignmentToPlacement(block.props.textAlignment);\n      }\n    },\n  });\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: show,\n        // Needed as hooks like `useDismiss` call `onOpenChange` to change the\n        // open state.\n        onOpenChange: (open, _event, reason) => {\n          formattingToolbar.store.setState(open);\n\n          if (reason === \"escape-key\") {\n            editor.focus();\n          }\n        },\n        placement,\n        middleware: [offset(10), shift(), flip()],\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        style: {\n          zIndex: 40,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [show, placement, props.floatingUIOptions, formattingToolbar.store, editor],\n  );\n\n  const Component = props.formattingToolbar || FormattingToolbar;\n\n  return (\n    <PositionPopover position={position} {...floatingUIOptions}>\n      {show && <Component />}\n    </PositionPopover>\n  );\n};\n","import { LinkToolbarExtension } from \"@blocknote/core/extensions\";\nimport { RiLinkUnlink } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { useExtension } from \"../../../hooks/useExtension.js\";\nimport { LinkToolbarProps } from \"../LinkToolbarProps.js\";\n\nexport const DeleteLinkButton = (\n  props: Pick<LinkToolbarProps, \"range\" | \"setToolbarOpen\">,\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const { deleteLink } = useExtension(LinkToolbarExtension);\n\n  return (\n    <Components.LinkToolbar.Button\n      className={\"bn-button\"}\n      label={dict.link_toolbar.delete.tooltip}\n      mainTooltip={dict.link_toolbar.delete.tooltip}\n      isSelected={false}\n      onClick={() => {\n        deleteLink(props.range.from);\n        props.setToolbarOpen?.(false);\n      }}\n      icon={<RiLinkUnlink />}\n    />\n  );\n};\n","import { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { EditLinkMenuItems } from \"../EditLinkMenuItems.js\";\nimport { LinkToolbarProps } from \"../LinkToolbarProps.js\";\n\nexport const EditLinkButton = (\n  props: Pick<\n    LinkToolbarProps,\n    \"url\" | \"text\" | \"range\" | \"setToolbarOpen\" | \"setToolbarPositionFrozen\"\n  >,\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  return (\n    <Components.Generic.Popover.Root\n      onOpenChange={props.setToolbarPositionFrozen}\n    >\n      <Components.Generic.Popover.Trigger>\n        <Components.LinkToolbar.Button\n          className={\"bn-button\"}\n          mainTooltip={dict.link_toolbar.edit.tooltip}\n          isSelected={false}\n        >\n          {dict.link_toolbar.edit.text}\n        </Components.LinkToolbar.Button>\n      </Components.Generic.Popover.Trigger>\n      <Components.Generic.Popover.Content\n        className={\"bn-popover-content bn-form-popover\"}\n        variant={\"form-popover\"}\n      >\n        <EditLinkMenuItems\n          url={props.url}\n          text={props.text}\n          range={props.range}\n          setToolbarOpen={props.setToolbarOpen}\n          setToolbarPositionFrozen={props.setToolbarPositionFrozen}\n        />\n      </Components.Generic.Popover.Content>\n    </Components.Generic.Popover.Root>\n  );\n};\n","import { RiExternalLinkFill } from \"react-icons/ri\";\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { sanitizeUrl } from \"../../../util/sanitizeUrl.js\";\nimport { LinkToolbarProps } from \"../LinkToolbarProps.js\";\n\nexport const OpenLinkButton = (props: Pick<LinkToolbarProps, \"url\">) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  return (\n    <Components.LinkToolbar.Button\n      className={\"bn-button\"}\n      mainTooltip={dict.link_toolbar.open.tooltip}\n      label={dict.link_toolbar.open.tooltip}\n      isSelected={false}\n      onClick={() => {\n        window.open(sanitizeUrl(props.url, window.location.href), \"_blank\");\n      }}\n      icon={<RiExternalLinkFill />}\n    />\n  );\n};\n","import { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { DeleteLinkButton } from \"./DefaultButtons/DeleteLinkButton.js\";\nimport { EditLinkButton } from \"./DefaultButtons/EditLinkButton.js\";\nimport { OpenLinkButton } from \"./DefaultButtons/OpenLinkButton.js\";\nimport { LinkToolbarProps } from \"./LinkToolbarProps.js\";\n\n/**\n * By default, the LinkToolbar component will render with default buttons.\n * However, you can override the selects/buttons to render by passing\n * children. The children you pass should be:\n *\n * - Default buttons: Components found within the `/DefaultButtons` directory.\n * - Custom selects: The `ToolbarSelect` component in the\n * `components/mantine-shared/Toolbar` directory.\n * - Custom buttons: The `ToolbarButton` component in the\n * `components/mantine-shared/Toolbar` directory.\n */\nexport const LinkToolbar = (props: LinkToolbarProps) => {\n  const Components = useComponentsContext()!;\n\n  return (\n    <Components.LinkToolbar.Root className={\"bn-toolbar bn-link-toolbar\"}>\n      {props.children || (\n        <>\n          <EditLinkButton\n            url={props.url}\n            text={props.text}\n            range={props.range}\n            setToolbarOpen={props.setToolbarOpen}\n            setToolbarPositionFrozen={props.setToolbarPositionFrozen}\n          />\n          <OpenLinkButton url={props.url} />\n          <DeleteLinkButton\n            range={props.range}\n            setToolbarOpen={props.setToolbarOpen}\n          />\n        </>\n      )}\n    </Components.LinkToolbar.Root>\n  );\n};\n","import { LinkToolbarExtension } from \"@blocknote/core/extensions\";\nimport { flip, offset, safePolygon } from \"@floating-ui/react\";\nimport { Range } from \"@tiptap/core\";\nimport { FC, useEffect, useMemo, useState } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension } from \"../../hooks/useExtension.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport {\n  GenericPopover,\n  GenericPopoverReference,\n} from \"../Popovers/GenericPopover.js\";\nimport { LinkToolbar } from \"./LinkToolbar.js\";\nimport { LinkToolbarProps } from \"./LinkToolbarProps.js\";\n\nexport const LinkToolbarController = (props: {\n  linkToolbar?: FC<LinkToolbarProps>;\n  floatingUIOptions?: FloatingUIOptions;\n}) => {\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const [toolbarOpen, setToolbarOpen] = useState(false);\n  const [toolbarPositionFrozen, setToolbarPositionFrozen] = useState(false);\n\n  const linkToolbar = useExtension(LinkToolbarExtension);\n\n  // Because the toolbar opens with a delay when a link is hovered by the mouse\n  // cursor, We need separate `toolbarOpen` and `link` states.\n  const [link, setLink] = useState<\n    | {\n        cursorType: \"text\" | \"mouse\";\n        url: string;\n        text: string;\n        range: Range;\n        element: HTMLAnchorElement;\n      }\n    | undefined\n  >(undefined);\n  // Updates the link to show the toolbar for. Uses the link found at the text\n  // cursor position. If there is none, uses the link hovered by the mouse\n  // cursor. Otherwise, the toolbar remains closed.\n  useEffect(() => {\n    const textCursorCallback = () => {\n      const textCursorLink = linkToolbar.getLinkAtSelection();\n      if (!textCursorLink) {\n        setLink(undefined);\n\n        if (!toolbarPositionFrozen) {\n          setToolbarOpen(false);\n        }\n\n        return;\n      }\n\n      setLink({\n        cursorType: \"text\",\n        url: textCursorLink.mark.attrs.href as string,\n        text: textCursorLink.text,\n        range: textCursorLink.range,\n        element: linkToolbar.getLinkElementAtPos(textCursorLink.range.from)!,\n      });\n\n      if (!toolbarPositionFrozen) {\n        setToolbarOpen(true);\n      }\n    };\n\n    // At no point in this callback is `setToolbarOpen` called, even though\n    // hovering a link with the mouse cursor should open the toolbar. This is\n    // because the FloatingUI `useHover` hook basically does this for us, so we\n    // only need to update `link` when a new one is hovered.\n    const mouseCursorCallback = (event: MouseEvent) => {\n      // Links selected by the text cursor take priority over those hovered by\n      // the mouse cursor.\n      if (link !== undefined && link.cursorType === \"text\") {\n        return;\n      }\n\n      if (!(event.target instanceof HTMLElement)) {\n        return;\n      }\n\n      const mouseCursorLink = linkToolbar.getLinkAtElement(event.target);\n      if (!mouseCursorLink) {\n        return;\n      }\n\n      setLink({\n        cursorType: \"mouse\",\n        url: mouseCursorLink.mark.attrs.href as string,\n        text: mouseCursorLink.text,\n        range: mouseCursorLink.range,\n        element: linkToolbar.getLinkElementAtPos(mouseCursorLink.range.from)!,\n      });\n    };\n\n    const destroyOnChangeHandler = editor.onChange(textCursorCallback);\n    const destroyOnSelectionChangeHandler =\n      editor.onSelectionChange(textCursorCallback);\n\n    const domElement = editor.domElement;\n\n    domElement?.addEventListener(\"mouseover\", mouseCursorCallback);\n\n    return () => {\n      destroyOnChangeHandler();\n      destroyOnSelectionChangeHandler();\n      domElement?.removeEventListener(\"mouseover\", mouseCursorCallback);\n    };\n  }, [editor, editor.domElement, linkToolbar, link, toolbarPositionFrozen]);\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: toolbarOpen,\n        onOpenChange: (open, _event, reason) => {\n          if (toolbarPositionFrozen) {\n            return;\n          }\n\n          // We want to prioritize `selectionLink` over `mouseHoverLink`, so we\n          // ignore opening/closing from hover events.\n          if (\n            link !== undefined &&\n            link.cursorType === \"text\" &&\n            reason === \"hover\"\n          ) {\n            return;\n          }\n\n          if (reason === \"escape-key\") {\n            editor.focus();\n          }\n\n          setToolbarOpen(open);\n        },\n        placement: \"top-start\",\n        middleware: [offset(10), flip()],\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      useHoverProps: {\n        // `useHover` hook only enabled when a link is hovered with the\n        // mouse.\n        enabled: link !== undefined && link.cursorType === \"mouse\",\n        delay: {\n          open: 250,\n          close: 250,\n        },\n        handleClose: safePolygon(),\n        ...props.floatingUIOptions?.useHoverProps,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        style: {\n          zIndex: 50,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [editor, link, props.floatingUIOptions, toolbarOpen, toolbarPositionFrozen],\n  );\n\n  const reference = useMemo<GenericPopoverReference | undefined>(\n    () => (link?.element ? { element: link.element } : undefined),\n    [link?.element],\n  );\n\n  // TODO: this should be a hook to be reactive\n  if (!editor.isEditable) {\n    return null;\n  }\n\n  const Component = props.linkToolbar || LinkToolbar;\n\n  return (\n    <GenericPopover reference={reference} {...floatingUIOptions}>\n      {link && (\n        <Component\n          url={link.url}\n          text={link.text}\n          range={link.range}\n          setToolbarOpen={setToolbarOpen}\n          setToolbarPositionFrozen={setToolbarPositionFrozen}\n        />\n      )}\n    </GenericPopover>\n  );\n};\n","import { SideMenuExtension, SuggestionMenu } from \"@blocknote/core/extensions\";\nimport { AiOutlinePlus } from \"react-icons/ai\";\n\nimport { useCallback } from \"react\";\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../hooks/useExtension.js\";\n\nexport const AddBlockButton = () => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const suggestionMenu = useExtension(SuggestionMenu);\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) => state?.block,\n  });\n\n  const onClick = useCallback(() => {\n    if (block === undefined) {\n      return;\n    }\n\n    const blockContent = block.content;\n    const isBlockEmpty =\n      blockContent !== undefined &&\n      Array.isArray(blockContent) &&\n      blockContent.length === 0;\n\n    if (isBlockEmpty) {\n      editor.setTextCursorPosition(block);\n      suggestionMenu.openSuggestionMenu(\"/\");\n    } else {\n      const insertedBlock = editor.insertBlocks(\n        [{ type: \"paragraph\" }],\n        block,\n        \"after\",\n      )[0];\n      editor.setTextCursorPosition(insertedBlock);\n      suggestionMenu.openSuggestionMenu(\"/\");\n    }\n  }, [block, editor, suggestionMenu]);\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.SideMenu.Button\n      className={\"bn-button\"}\n      label={dict.side_menu.add_block_label}\n      icon={\n        <AiOutlinePlus size={24} onClick={onClick} data-test=\"dragHandleAdd\" />\n      }\n    />\n  );\n};\n","import { blockHasType, editorHasBlockWithType } from \"@blocknote/core\";\nimport { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { ColorPicker } from \"../../../ColorPicker/ColorPicker.js\";\nimport { useExtensionState } from \"../../../../hooks/useExtension.js\";\n\nexport const BlockColorsItem = (props: { children: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) => state?.block,\n  });\n\n  if (\n    block === undefined ||\n    (!blockHasType(block, editor, block.type, {\n      textColor: \"string\",\n    }) &&\n      !blockHasType(block, editor, block.type, {\n        backgroundColor: \"string\",\n      }))\n  ) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Root position={\"right\"} sub={true}>\n      <Components.Generic.Menu.Trigger sub={true}>\n        <Components.Generic.Menu.Item\n          className={\"bn-menu-item\"}\n          subTrigger={true}\n        >\n          {props.children}\n        </Components.Generic.Menu.Item>\n      </Components.Generic.Menu.Trigger>\n\n      <Components.Generic.Menu.Dropdown\n        sub={true}\n        className={\"bn-menu-dropdown bn-color-picker-dropdown\"}\n      >\n        <ColorPicker\n          iconSize={18}\n          text={\n            blockHasType(block, editor, block.type, {\n              textColor: \"string\",\n            }) &&\n            editorHasBlockWithType(editor, block.type, {\n              textColor: \"string\",\n            })\n              ? {\n                  color: block.props.textColor,\n                  setColor: (color) =>\n                    editor.updateBlock(block, {\n                      type: block.type,\n                      props: { textColor: color },\n                    }),\n                }\n              : undefined\n          }\n          background={\n            blockHasType(block, editor, block.type, {\n              backgroundColor: \"string\",\n            }) &&\n            editorHasBlockWithType(editor, block.type, {\n              backgroundColor: \"string\",\n            })\n              ? {\n                  color: block.props.backgroundColor,\n                  setColor: (color) =>\n                    editor.updateBlock(block, {\n                      props: { backgroundColor: color },\n                    }),\n                }\n              : undefined\n          }\n        />\n      </Components.Generic.Menu.Dropdown>\n    </Components.Generic.Menu.Root>\n  );\n};\n","import { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../../../hooks/useExtension.js\";\n\nexport const RemoveBlockItem = (props: { children: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) => state?.block,\n  });\n\n  if (block === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Item\n      className={\"bn-menu-item\"}\n      onClick={() => editor.removeBlocks([block])}\n    >\n      {props.children}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import { DefaultBlockSchema, SpecificBlock } from \"@blocknote/core\";\nimport { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../../../hooks/useExtension.js\";\n\nexport const TableRowHeaderItem = (props: { children: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    { table: DefaultBlockSchema[\"table\"] },\n    any,\n    any\n  >();\n\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) =>\n      state?.block as\n        | SpecificBlock<\n            { table: DefaultBlockSchema[\"table\"] },\n            \"table\",\n            any,\n            any\n          >\n        | undefined,\n  });\n\n  if (\n    block === undefined ||\n    block.type !== \"table\" ||\n    !editor.settings.tables.headers\n  ) {\n    return null;\n  }\n\n  // TODO only support 1 header row for now\n  const isHeaderRow = Boolean(block.content.headerRows);\n\n  return (\n    <Components.Generic.Menu.Item\n      className={\"bn-menu-item\"}\n      checked={isHeaderRow}\n      onClick={() => {\n        editor.updateBlock(block, {\n          content: {\n            ...block.content,\n            headerRows: isHeaderRow ? undefined : 1,\n          },\n        });\n      }}\n    >\n      {props.children}\n    </Components.Generic.Menu.Item>\n  );\n};\n\nexport const TableColumnHeaderItem = (props: { children: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<\n    { table: DefaultBlockSchema[\"table\"] },\n    any,\n    any\n  >();\n\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) =>\n      state?.block as\n        | SpecificBlock<\n            { table: DefaultBlockSchema[\"table\"] },\n            \"table\",\n            any,\n            any\n          >\n        | undefined,\n  });\n\n  if (\n    block === undefined ||\n    block.type !== \"table\" ||\n    !editor.settings.tables.headers\n  ) {\n    return null;\n  }\n\n  // TODO only support 1 header column for now\n  const isHeaderColumn = Boolean(block.content.headerCols);\n\n  return (\n    <Components.Generic.Menu.Item\n      className={\"bn-menu-item\"}\n      checked={isHeaderColumn}\n      onClick={() => {\n        editor.updateBlock(block, {\n          content: {\n            ...block.content,\n            headerCols: isHeaderColumn ? undefined : 1,\n          },\n        });\n      }}\n    >\n      {props.children}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { BlockColorsItem } from \"./DefaultItems/BlockColorsItem.js\";\nimport { RemoveBlockItem } from \"./DefaultItems/RemoveBlockItem.js\";\nimport {\n  TableColumnHeaderItem,\n  TableRowHeaderItem,\n} from \"./DefaultItems/TableHeadersItem.js\";\n\n/**\n * By default, the DragHandleMenu component will render with default items.\n * However, you can override the items to render by passing children. The\n * children you pass should be:\n *\n * - Default items: Components found within the `/DefaultItems` directory.\n * - Custom items: The `DragHandleMenuItem` component.\n */\nexport const DragHandleMenu = (props: { children?: ReactNode }) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  return (\n    <Components.Generic.Menu.Dropdown\n      className={\"bn-menu-dropdown bn-drag-handle-menu\"}\n    >\n      {props.children || (\n        <>\n          <RemoveBlockItem>{dict.drag_handle.delete_menuitem}</RemoveBlockItem>\n          <BlockColorsItem>{dict.drag_handle.colors_menuitem}</BlockColorsItem>\n          <TableRowHeaderItem>\n            {dict.drag_handle.header_row_menuitem}\n          </TableRowHeaderItem>\n          <TableColumnHeaderItem>\n            {dict.drag_handle.header_column_menuitem}\n          </TableColumnHeaderItem>\n        </>\n      )}\n    </Components.Generic.Menu.Dropdown>\n  );\n};\n","import { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { MdDragIndicator } from \"react-icons/md\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport { DragHandleMenu } from \"../DragHandleMenu/DragHandleMenu.js\";\nimport { SideMenuProps } from \"../SideMenuProps.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../hooks/useExtension.js\";\n\nexport const DragHandleButton = (\n  props: SideMenuProps & {\n    children?: React.ReactNode;\n  },\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const sideMenu = useExtension(SideMenuExtension);\n  const block = useExtensionState(SideMenuExtension, {\n    selector: (state) => state?.block,\n  });\n\n  if (block === undefined) {\n    return null;\n  }\n\n  const Component = props.dragHandleMenu || DragHandleMenu;\n\n  return (\n    <Components.Generic.Menu.Root\n      onOpenChange={(open: boolean) => {\n        if (open) {\n          sideMenu.freezeMenu();\n        } else {\n          sideMenu.unfreezeMenu();\n        }\n      }}\n      position={\"left\"}\n    >\n      <Components.Generic.Menu.Trigger>\n        <Components.SideMenu.Button\n          label={dict.side_menu.drag_handle_label}\n          draggable={true}\n          onDragStart={(e) => sideMenu.blockDragStart(e, block)}\n          onDragEnd={sideMenu.blockDragEnd}\n          className={\"bn-button\"}\n          icon={<MdDragIndicator size={24} data-test=\"dragHandle\" />}\n        />\n      </Components.Generic.Menu.Trigger>\n      <Component>{props.children}</Component>\n    </Components.Generic.Menu.Root>\n  );\n};\n","import { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode, useMemo } from \"react\";\n\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../hooks/useExtension.js\";\nimport { AddBlockButton } from \"./DefaultButtons/AddBlockButton.js\";\nimport { DragHandleButton } from \"./DefaultButtons/DragHandleButton.js\";\nimport { SideMenuProps } from \"./SideMenuProps.js\";\n\n// TODO: props.dragHandleMenu should only be available if no children are passed\n/**\n * By default, the SideMenu component will render with default buttons. However,\n * you can override the buttons to render by passing children. The children you\n * pass should be:\n *\n * - Default buttons: Components found within the `/DefaultButtons` directory.\n * - Custom buttons: The `SideMenuButton` component.\n */\nexport const SideMenu = (props: SideMenuProps & { children?: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const block = useExtensionState(SideMenuExtension, {\n    editor,\n    selector: (state) => state?.block,\n  });\n\n  const dataAttributes = useMemo(() => {\n    if (block === undefined) {\n      return {};\n    }\n\n    const attrs: Record<string, string> = {\n      \"data-block-type\": block.type,\n    };\n\n    if (block.type === \"heading\") {\n      attrs[\"data-level\"] = (block.props as any).level.toString();\n    }\n\n    if (\n      editor.schema.blockSpecs[block.type].implementation.meta?.fileBlockAccept\n    ) {\n      if (block.props.url) {\n        attrs[\"data-url\"] = \"true\";\n      } else {\n        attrs[\"data-url\"] = \"false\";\n      }\n    }\n\n    return attrs;\n  }, [block, editor.schema.blockSpecs]);\n\n  return (\n    <Components.SideMenu.Root className={\"bn-side-menu\"} {...dataAttributes}>\n      {props.children || (\n        <>\n          <AddBlockButton />\n          <DragHandleButton dragHandleMenu={props.dragHandleMenu} />\n        </>\n      )}\n    </Components.SideMenu.Root>\n  );\n};\n","import { SideMenuExtension } from \"@blocknote/core/extensions\";\nimport { autoUpdate, ReferenceElement } from \"@floating-ui/react\";\nimport { FC, useCallback, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../hooks/useExtension.js\";\nimport { BlockPopover } from \"../Popovers/BlockPopover.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport { SideMenu } from \"./SideMenu.js\";\nimport { SideMenuProps } from \"./SideMenuProps.js\";\n\nexport const SideMenuController = (props: {\n  sideMenu?: FC<SideMenuProps>;\n  floatingUIOptions?: Partial<FloatingUIOptions>;\n}) => {\n  const editor = useBlockNoteEditor();\n  const state = useExtensionState(SideMenuExtension, {\n    selector: (state) => {\n      return state !== undefined\n        ? {\n            show: state.show,\n            block: state.block,\n          }\n        : undefined;\n    },\n  });\n\n  const { show, block } = state || {};\n\n  // Hides the side menu on ancestor scroll so it doesn't overflow outside\n  // the editor's scroll container.\n  const whileElementsMounted = useCallback(\n    (\n      reference: ReferenceElement,\n      floating: HTMLElement,\n      _update: () => void,\n    ) => {\n      let initialized = false;\n      return autoUpdate(\n        reference,\n        floating,\n        () => {\n          if (!initialized) {\n            // autoUpdate calls this function once when the floating element is mounted\n            // we don't want to hide the menu in that case\n            initialized = true;\n            return;\n          }\n          editor.getExtension(SideMenuExtension)?.hideMenuIfNotFrozen();\n        },\n        {\n          ancestorScroll: true,\n          ancestorResize: false,\n          elementResize: false,\n          layoutShift: false,\n        },\n      );\n    },\n    [editor],\n  );\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: show,\n        placement: \"left-start\",\n        whileElementsMounted,\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      useDismissProps: {\n        enabled: false,\n        ...props.floatingUIOptions?.useDismissProps,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        style: {\n          zIndex: 20,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [props.floatingUIOptions, show, whileElementsMounted],\n  );\n\n  const Component = props.sideMenu || SideMenu;\n\n  return (\n    <BlockPopover blockId={show ? block?.id : undefined} {...floatingUIOptions}>\n      {block?.id && <Component />}\n    </BlockPopover>\n  );\n};\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { getDefaultEmojiPickerItems } from \"@blocknote/core/extensions\";\nimport { DefaultReactGridSuggestionItem } from \"./types.js\";\n\nexport async function getDefaultReactEmojiPickerItems<\n  BSchema extends BlockSchema,\n  I extends InlineContentSchema,\n  S extends StyleSchema,\n>(\n  editor: BlockNoteEditor<BSchema, I, S>,\n  query: string,\n): Promise<DefaultReactGridSuggestionItem[]> {\n  return (await getDefaultEmojiPickerItems(editor, query)).map(\n    ({ id, onItemClick }) => ({\n      id,\n      onItemClick,\n      icon: id as any,\n    }),\n  );\n}\n","import { JSX, useMemo } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../i18n/dictionary.js\";\nimport {\n  DefaultReactGridSuggestionItem,\n  GridSuggestionMenuProps,\n} from \"./types.js\";\n\nexport function GridSuggestionMenu<T extends DefaultReactGridSuggestionItem>(\n  props: GridSuggestionMenuProps<T>,\n) {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const { items, loadingState, selectedIndex, onItemClick, columns } = props;\n\n  const loader =\n    loadingState === \"loading-initial\" || loadingState === \"loading\" ? (\n      <Components.GridSuggestionMenu.Loader\n        className={\"bn-grid-suggestion-menu-loader\"}\n        columns={columns}\n      />\n    ) : null;\n\n  const renderedItems = useMemo<JSX.Element[]>(() => {\n    // let currentGroup: string | undefined = undefined;\n    const renderedItems = [];\n\n    for (let i = 0; i < items.length; i++) {\n      const item = items[i];\n      // if (item.group !== currentGroup) {\n      //   currentGroup = item.group;\n      //   renderedItems.push(\n      //     <Components.SuggestionMenu.Label\n      //       className={\"bn-suggestion-menu-label\"}\n      //       key={currentGroup}>\n      //       {currentGroup}\n      //     </Components.SuggestionMenu.Label>\n      //   );\n      // }\n\n      renderedItems.push(\n        <Components.GridSuggestionMenu.Item\n          className={\"bn-grid-suggestion-menu-item\"}\n          item={item}\n          id={`bn-grid-suggestion-menu-item-${i}`}\n          isSelected={i === selectedIndex}\n          key={item.id}\n          onClick={() => onItemClick?.(item)}\n        />,\n      );\n    }\n\n    return renderedItems;\n  }, [Components, items, onItemClick, selectedIndex]);\n\n  return (\n    <Components.GridSuggestionMenu.Root\n      id=\"bn-grid-suggestion-menu\"\n      columns={columns}\n      className=\"bn-grid-suggestion-menu\"\n    >\n      {loader}\n      {renderedItems}\n      {renderedItems.length === 0 && props.loadingState === \"loaded\" && (\n        <Components.GridSuggestionMenu.EmptyItem\n          className={\"bn-grid-suggestion-menu-empty-item\"}\n          columns={columns}\n        >\n          {dict.suggestion_menu.no_items_title}\n        </Components.GridSuggestionMenu.EmptyItem>\n      )}\n    </Components.GridSuggestionMenu.Root>\n  );\n}\n","import { useEffect, useRef } from \"react\";\n\n// Hook which closes the suggestion after a certain number of consecutive\n// invalid queries are made. An invalid query is one which returns no items, and\n// each invalid query must be longer than the previous one to close the menu\nexport function useCloseSuggestionMenuNoItems<Item>(\n  items: Item[],\n  usedQuery: string | undefined,\n  closeMenu: () => void,\n  invalidQueries = 3,\n) {\n  const lastUsefulQueryLength = useRef(0);\n\n  useEffect(() => {\n    if (usedQuery === undefined) {\n      return;\n    }\n\n    if (items.length > 0) {\n      lastUsefulQueryLength.current = usedQuery.length;\n    } else if (\n      usedQuery.length - lastUsefulQueryLength.current >\n      invalidQueries\n    ) {\n      closeMenu();\n    }\n  }, [closeMenu, invalidQueries, items.length, usedQuery]);\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n// Hook which loads the items for a suggestion menu and returns them along with\n// information whether the current query is still being processed, and the\n// query that was used to retrieve the last set of items.\nexport function useLoadSuggestionMenuItems<T>(\n  query: string,\n  getItems: (query: string) => Promise<T[]>,\n): {\n  items: T[];\n  usedQuery: string | undefined;\n  loadingState: \"loading-initial\" | \"loading\" | \"loaded\";\n} {\n  const [items, setItems] = useState<T[]>([]);\n  const [loading, setLoading] = useState(false);\n\n  const currentQuery = useRef<string | undefined>(undefined);\n  const usedQuery = useRef<string | undefined>(undefined);\n\n  useEffect(() => {\n    const thisQuery = query;\n    currentQuery.current = query;\n\n    setLoading(true);\n\n    getItems(query).then((items) => {\n      if (currentQuery.current !== thisQuery) {\n        // outdated query returned, ignore the result\n        return;\n      }\n\n      setItems(items);\n      setLoading(false);\n      usedQuery.current = thisQuery;\n    });\n  }, [query, getItems]);\n\n  return {\n    items: items || [],\n    // The query that was used to retrieve the last set of items may not be the\n    // same as the current query as the items from the current query may not\n    // have been retrieved yet. This is useful when using the returns of this\n    // hook in other hooks.\n    usedQuery: usedQuery.current,\n    loadingState:\n      usedQuery.current === undefined\n        ? \"loading-initial\"\n        : loading\n          ? \"loading\"\n          : \"loaded\",\n  };\n}\n","import { BlockNoteEditor } from \"@blocknote/core\";\nimport { useEffect, useState } from \"react\";\n\n// Hook which handles keyboard navigation of a grid suggestion menu. Arrow keys\n// are used to select a menu item, enter is used to execute it.\nexport function useGridSuggestionMenuKeyboardNavigation<Item>(\n  editor: BlockNoteEditor<any, any, any>,\n  query: string,\n  items: Item[],\n  columns: number,\n  onItemClick?: (item: Item) => void,\n) {\n  const [selectedIndex, setSelectedIndex] = useState<number>(0);\n\n  const isGrid = columns !== undefined && columns > 1;\n\n  useEffect(() => {\n    const handleMenuNavigationKeys = (event: KeyboardEvent) => {\n      if (event.key === \"ArrowLeft\") {\n        event.preventDefault();\n        if (items.length) {\n          setSelectedIndex((selectedIndex - 1 + items!.length) % items!.length);\n        }\n      }\n\n      if (event.key === \"ArrowRight\") {\n        event.preventDefault();\n        if (items.length) {\n          setSelectedIndex((selectedIndex + 1 + items!.length) % items!.length);\n        }\n      }\n\n      if (event.key === \"ArrowUp\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex(\n            (selectedIndex - columns + items!.length) % items!.length,\n          );\n        }\n\n        return true;\n      }\n\n      if (event.key === \"ArrowDown\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex((selectedIndex + columns) % items!.length);\n        }\n\n        return true;\n      }\n\n      if (event.key === \"Enter\" && !event.isComposing) {\n        event.stopPropagation();\n        event.preventDefault();\n\n        if (items.length) {\n          onItemClick?.(items[selectedIndex]);\n        }\n\n        return true;\n      }\n\n      return false;\n    };\n\n    const domElement = editor.domElement;\n    domElement?.addEventListener(\"keydown\", handleMenuNavigationKeys, true);\n\n    return () => {\n      domElement?.removeEventListener(\n        \"keydown\",\n        handleMenuNavigationKeys,\n        true,\n      );\n    };\n  }, [editor.domElement, items, selectedIndex, onItemClick, columns, isGrid]);\n\n  // Resets index when items change\n  useEffect(() => {\n    setSelectedIndex(0);\n  }, [query]);\n\n  return {\n    selectedIndex: items.length === 0 ? undefined : selectedIndex,\n  };\n}\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport { FC, useCallback, useEffect } from \"react\";\n\nimport { useBlockNoteContext } from \"../../../editor/BlockNoteContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport { useCloseSuggestionMenuNoItems } from \"../hooks/useCloseSuggestionMenuNoItems.js\";\nimport { useLoadSuggestionMenuItems } from \"../hooks/useLoadSuggestionMenuItems.js\";\nimport { useGridSuggestionMenuKeyboardNavigation } from \"./hooks/useGridSuggestionMenuKeyboardNavigation.js\";\nimport { GridSuggestionMenuProps } from \"./types.js\";\n\nexport function GridSuggestionMenuWrapper<Item>(props: {\n  query: string;\n  closeMenu: () => void;\n  clearQuery: () => void;\n  getItems: (query: string) => Promise<Item[]>;\n  columns: number;\n  onItemClick?: (item: Item) => void;\n  gridSuggestionMenuComponent: FC<GridSuggestionMenuProps<Item>>;\n}) {\n  const ctx = useBlockNoteContext();\n  const setContentEditableProps = ctx!.setContentEditableProps!;\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const {\n    getItems,\n    gridSuggestionMenuComponent,\n    query,\n    clearQuery,\n    closeMenu,\n    onItemClick,\n    columns,\n  } = props;\n\n  const onItemClickCloseMenu = useCallback(\n    (item: Item) => {\n      closeMenu();\n      clearQuery();\n      onItemClick?.(item);\n    },\n    [onItemClick, closeMenu, clearQuery],\n  );\n\n  const { items, usedQuery, loadingState } = useLoadSuggestionMenuItems(\n    query,\n    getItems,\n  );\n\n  useCloseSuggestionMenuNoItems(items, usedQuery, closeMenu);\n\n  const { selectedIndex } = useGridSuggestionMenuKeyboardNavigation(\n    editor,\n    query,\n    items,\n    columns,\n    onItemClickCloseMenu,\n  );\n\n  // set basic aria attributes when the menu is open\n  useEffect(() => {\n    setContentEditableProps((p) => ({\n      ...p,\n      \"aria-expanded\": true,\n      \"aria-controls\": \"bn-suggestion-menu\",\n    }));\n    return () => {\n      setContentEditableProps((p) => ({\n        ...p,\n        \"aria-expanded\": false,\n        \"aria-controls\": undefined,\n      }));\n    };\n  }, [setContentEditableProps]);\n\n  // set selected item (activedescendent) attributes when selected item changes\n  useEffect(() => {\n    setContentEditableProps((p) => ({\n      ...p,\n      \"aria-activedescendant\": selectedIndex\n        ? \"bn-suggestion-menu-item-\" + selectedIndex\n        : undefined,\n    }));\n    return () => {\n      setContentEditableProps((p) => ({\n        ...p,\n        \"aria-activedescendant\": undefined,\n      }));\n    };\n  }, [setContentEditableProps, selectedIndex]);\n\n  const Component = gridSuggestionMenuComponent;\n\n  return (\n    <Component\n      items={items}\n      onItemClick={onItemClickCloseMenu}\n      loadingState={loadingState}\n      selectedIndex={selectedIndex}\n      columns={columns}\n    />\n  );\n}\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport {\n  SuggestionMenu,\n  SuggestionMenuOptions,\n} from \"@blocknote/core/extensions\";\nimport { autoPlacement, offset, shift, size } from \"@floating-ui/react\";\nimport { FC, useEffect, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../hooks/useExtension.js\";\nimport { FloatingUIOptions } from \"../../Popovers/FloatingUIOptions.js\";\nimport {\n  GenericPopover,\n  GenericPopoverReference,\n} from \"../../Popovers/GenericPopover.js\";\nimport { getDefaultReactEmojiPickerItems } from \"./getDefaultReactEmojiPickerItems.js\";\nimport { GridSuggestionMenu } from \"./GridSuggestionMenu.js\";\nimport { GridSuggestionMenuWrapper } from \"./GridSuggestionMenuWrapper.js\";\nimport {\n  DefaultReactGridSuggestionItem,\n  GridSuggestionMenuProps,\n} from \"./types.js\";\n\ntype ArrayElement<A> = A extends readonly (infer T)[] ? T : never;\n\ntype ItemType<GetItemsType extends (query: string) => Promise<any[]>> =\n  ArrayElement<Awaited<ReturnType<GetItemsType>>>;\n\nexport function GridSuggestionMenuController<\n  // This is a bit hacky, but only way I found to make types work so the optionality\n  // of suggestionMenuComponent depends on the return type of getItems\n  GetItemsType extends (query: string) => Promise<any[]> = (\n    query: string,\n  ) => Promise<DefaultReactGridSuggestionItem[]>,\n>(\n  props: {\n    triggerCharacter: string;\n    getItems?: GetItemsType;\n    columns: number;\n    shouldOpen?: SuggestionMenuOptions[\"shouldOpen\"];\n    minQueryLength?: number;\n    floatingUIOptions?: FloatingUIOptions;\n  } & (ItemType<GetItemsType> extends DefaultReactGridSuggestionItem\n    ? {\n        // can be undefined\n        gridSuggestionMenuComponent?: FC<\n          GridSuggestionMenuProps<ItemType<GetItemsType>>\n        >;\n        onItemClick?: (item: ItemType<GetItemsType>) => void;\n      }\n    : {\n        // getItems doesn't return DefaultSuggestionItem, so suggestionMenuComponent is required\n        gridSuggestionMenuComponent: FC<\n          GridSuggestionMenuProps<ItemType<GetItemsType>>\n        >;\n        onItemClick: (item: ItemType<GetItemsType>) => void;\n      }),\n) {\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const {\n    triggerCharacter,\n    gridSuggestionMenuComponent,\n    columns,\n    shouldOpen,\n    minQueryLength,\n    onItemClick,\n    getItems,\n  } = props;\n\n  const onItemClickOrDefault = useMemo(() => {\n    return (\n      onItemClick ||\n      ((item: ItemType<GetItemsType>) => {\n        item.onItemClick(editor);\n      })\n    );\n  }, [editor, onItemClick]);\n\n  const getItemsOrDefault = useMemo(() => {\n    return (\n      getItems ||\n      ((async (query: string) =>\n        await getDefaultReactEmojiPickerItems(\n          editor,\n          query,\n        )) as any as typeof getItems)\n    );\n  }, [editor, getItems])!;\n\n  const suggestionMenu = useExtension(SuggestionMenu);\n\n  useEffect(() => {\n    suggestionMenu.addSuggestionMenu({ triggerCharacter, shouldOpen });\n  }, [suggestionMenu, triggerCharacter, shouldOpen]);\n\n  const state = useExtensionState(SuggestionMenu);\n  const reference = useExtensionState(SuggestionMenu, {\n    selector: (state) =>\n      ({\n        // Use first child as the editor DOM element may itself be scrollable.\n        // For FloatingUI to auto-update the position during scrolling, the\n        // `contextElement` must be a descendant of the scroll container.\n        element: (editor.domElement?.firstChild || undefined) as\n          | Element\n          | undefined,\n        getBoundingClientRect: () => state?.referencePos || new DOMRect(),\n      }) satisfies GenericPopoverReference,\n  });\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: state?.show && state?.triggerCharacter === triggerCharacter,\n        onOpenChange: (open) => {\n          if (!open) {\n            suggestionMenu.closeMenu();\n          }\n        },\n        placement: \"bottom-start\",\n        middleware: [\n          offset(10),\n          // Flips the menu placement to maximize the space available, and prevents\n          // the menu from being cut off by the confines of the screen.\n          autoPlacement({\n            allowedPlacements: [\"bottom-start\", \"top-start\"],\n            padding: 10,\n          }),\n          shift(),\n          size({\n            apply({ elements, availableHeight }) {\n              elements.floating.style.maxHeight = `${Math.max(0, availableHeight)}px`;\n            },\n            padding: 10,\n          }),\n        ],\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        // Prevents editor blurring when clicking the scroll bar.\n        onMouseDownCapture: (event) => event.preventDefault(),\n        style: {\n          zIndex: 70,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [\n      props.floatingUIOptions,\n      state?.show,\n      state?.triggerCharacter,\n      suggestionMenu,\n      triggerCharacter,\n    ],\n  );\n\n  if (\n    !state ||\n    (!state.ignoreQueryLength &&\n      minQueryLength &&\n      (state.query.startsWith(\" \") || state.query.length < minQueryLength))\n  ) {\n    return null;\n  }\n\n  return (\n    <GenericPopover reference={reference} {...floatingUIOptions}>\n      {triggerCharacter && (\n        <GridSuggestionMenuWrapper\n          query={state.query}\n          closeMenu={suggestionMenu.closeMenu}\n          clearQuery={suggestionMenu.clearQuery}\n          getItems={getItemsOrDefault}\n          columns={columns}\n          gridSuggestionMenuComponent={\n            gridSuggestionMenuComponent ||\n            GridSuggestionMenu<ItemType<GetItemsType>>\n          }\n          onItemClick={onItemClickOrDefault}\n        />\n      )}\n    </GenericPopover>\n  );\n}\n","import { mergeCSSClasses } from \"@blocknote/core\";\nimport { JSX, useMemo } from \"react\";\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../i18n/dictionary.js\";\nimport { DefaultReactSuggestionItem, SuggestionMenuProps } from \"./types.js\";\n\nexport function SuggestionMenu<T extends DefaultReactSuggestionItem>(\n  props: SuggestionMenuProps<T>,\n) {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const { items, loadingState, selectedIndex, onItemClick } = props;\n\n  const loader =\n    loadingState === \"loading-initial\" || loadingState === \"loading\" ? (\n      <Components.SuggestionMenu.Loader\n        className={\"bn-suggestion-menu-loader\"}\n      />\n    ) : null;\n\n  const renderedItems = useMemo<JSX.Element[]>(() => {\n    let currentGroup: string | undefined = undefined;\n    const renderedItems = [];\n\n    for (let i = 0; i < items.length; i++) {\n      const item = items[i];\n      if (item.group !== currentGroup) {\n        currentGroup = item.group;\n        renderedItems.push(\n          <Components.SuggestionMenu.Label\n            className={\"bn-suggestion-menu-label\"}\n            key={currentGroup}\n          >\n            {currentGroup}\n          </Components.SuggestionMenu.Label>,\n        );\n      }\n\n      renderedItems.push(\n        <Components.SuggestionMenu.Item\n          className={mergeCSSClasses(\n            \"bn-suggestion-menu-item\",\n            item.size === \"small\" ? \"bn-suggestion-menu-item-small\" : \"\",\n          )}\n          item={item}\n          id={`bn-suggestion-menu-item-${i}`}\n          isSelected={i === selectedIndex}\n          key={item.title}\n          onClick={() => onItemClick?.(item)}\n        />,\n      );\n    }\n\n    return renderedItems;\n  }, [Components, items, onItemClick, selectedIndex]);\n\n  return (\n    <Components.SuggestionMenu.Root\n      id=\"bn-suggestion-menu\"\n      className=\"bn-suggestion-menu\"\n    >\n      {renderedItems}\n      {renderedItems.length === 0 &&\n        (props.loadingState === \"loading\" ||\n          props.loadingState === \"loaded\") && (\n          <Components.SuggestionMenu.EmptyItem\n            className={\"bn-suggestion-menu-item\"}\n          >\n            {dict.suggestion_menu.no_items_title}\n          </Components.SuggestionMenu.EmptyItem>\n        )}\n      {loader}\n    </Components.SuggestionMenu.Root>\n  );\n}\n","import React, { useState } from \"react\";\n\n// Hook which returns a handler for keyboard navigation of a suggestion menu. Up\n// & down arrow keys are used to select an item, enter is used to execute it.\nexport function useSuggestionMenuKeyboardHandler<Item>(\n  items: Item[],\n  onItemClick?: (item: Item) => void,\n) {\n  const [selectedIndex, setSelectedIndex] = useState<number>(0);\n\n  return {\n    selectedIndex,\n    setSelectedIndex,\n    handler: (event: KeyboardEvent | React.KeyboardEvent) => {\n      if (event.key === \"ArrowUp\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex((selectedIndex - 1 + items!.length) % items!.length);\n        }\n\n        return true;\n      }\n\n      if (event.key === \"ArrowDown\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex((selectedIndex + 1) % items!.length);\n        }\n\n        return true;\n      }\n\n      if (event.key === \"PageUp\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex(0);\n        }\n\n        return true;\n      }\n\n      if (event.key === \"PageDown\") {\n        event.preventDefault();\n\n        if (items.length) {\n          setSelectedIndex(items.length - 1);\n        }\n\n        return true;\n      }\n\n      const isComposing = isReactEvent(event)\n        ? event.nativeEvent.isComposing\n        : event.isComposing;\n      if (event.key === \"Enter\" && !isComposing) {\n        event.preventDefault();\n        event.stopPropagation();\n\n        if (items.length) {\n          onItemClick?.(items[selectedIndex]);\n        }\n\n        return true;\n      }\n\n      return false;\n    },\n  };\n}\n\nfunction isReactEvent(\n  event: KeyboardEvent | React.KeyboardEvent,\n): event is React.KeyboardEvent {\n  return (event as React.KeyboardEvent).nativeEvent !== undefined;\n}\n","import { BlockNoteEditor } from \"@blocknote/core\";\nimport { useEffect } from \"react\";\nimport { useSuggestionMenuKeyboardHandler } from \"./useSuggestionMenuKeyboardHandler.js\";\n\n// Hook which handles keyboard navigation of a suggestion menu. Up & down arrow\n// keys are used to select a menu item, enter is used to execute it.\nexport function useSuggestionMenuKeyboardNavigation<Item>(\n  editor: BlockNoteEditor<any, any, any>,\n  query: string,\n  items: Item[],\n  onItemClick?: (item: Item) => void,\n  element?: HTMLElement,\n) {\n  const { selectedIndex, setSelectedIndex, handler } =\n    useSuggestionMenuKeyboardHandler(items, onItemClick);\n\n  useEffect(() => {\n    const el = element || editor.domElement;\n    el?.addEventListener(\"keydown\", handler, true);\n\n    return () => {\n      el?.removeEventListener(\"keydown\", handler, true);\n    };\n  }, [editor.domElement, items, selectedIndex, onItemClick, element, handler]);\n\n  // Resets index when items change\n  useEffect(() => {\n    setSelectedIndex(0);\n  }, [query, setSelectedIndex]);\n\n  return {\n    selectedIndex: items.length === 0 ? undefined : selectedIndex,\n  };\n}\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport { FC, useCallback, useEffect } from \"react\";\n\nimport { useBlockNoteContext } from \"../../editor/BlockNoteContext.js\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useCloseSuggestionMenuNoItems } from \"./hooks/useCloseSuggestionMenuNoItems.js\";\nimport { useLoadSuggestionMenuItems } from \"./hooks/useLoadSuggestionMenuItems.js\";\nimport { useSuggestionMenuKeyboardNavigation } from \"./hooks/useSuggestionMenuKeyboardNavigation.js\";\nimport { SuggestionMenuProps } from \"./types.js\";\n\nexport function SuggestionMenuWrapper<Item>(props: {\n  query: string;\n  closeMenu: () => void;\n  clearQuery: () => void;\n  getItems: (query: string) => Promise<Item[]>;\n  onItemClick?: (item: Item) => void;\n  suggestionMenuComponent: FC<SuggestionMenuProps<Item>>;\n}) {\n  const ctx = useBlockNoteContext();\n  const setContentEditableProps = ctx!.setContentEditableProps!;\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const {\n    getItems,\n    suggestionMenuComponent,\n    query,\n    clearQuery,\n    closeMenu,\n    onItemClick,\n  } = props;\n\n  const onItemClickCloseMenu = useCallback(\n    (item: Item) => {\n      closeMenu();\n      clearQuery();\n      onItemClick?.(item);\n    },\n    [onItemClick, closeMenu, clearQuery],\n  );\n\n  const { items, usedQuery, loadingState } = useLoadSuggestionMenuItems(\n    query,\n    getItems,\n  );\n\n  useCloseSuggestionMenuNoItems(items, usedQuery, closeMenu);\n\n  const { selectedIndex } = useSuggestionMenuKeyboardNavigation(\n    editor,\n    query,\n    items,\n    onItemClickCloseMenu,\n  );\n\n  // set basic aria attributes when the menu is open\n  useEffect(() => {\n    setContentEditableProps((p) => ({\n      ...p,\n      \"aria-expanded\": true,\n      \"aria-controls\": \"bn-suggestion-menu\",\n    }));\n    return () => {\n      setContentEditableProps((p) => ({\n        ...p,\n        \"aria-expanded\": false,\n        \"aria-controls\": undefined,\n      }));\n    };\n  }, [setContentEditableProps]);\n\n  // set selected item (activedescendent) attributes when selected item changes\n  useEffect(() => {\n    setContentEditableProps((p) => ({\n      ...p,\n      \"aria-activedescendant\": selectedIndex\n        ? \"bn-suggestion-menu-item-\" + selectedIndex\n        : undefined,\n    }));\n    return () => {\n      setContentEditableProps((p) => ({\n        ...p,\n        \"aria-activedescendant\": undefined,\n      }));\n    };\n  }, [setContentEditableProps, selectedIndex]);\n\n  const Component = suggestionMenuComponent;\n\n  return (\n    <Component\n      items={items}\n      onItemClick={onItemClickCloseMenu}\n      loadingState={loadingState}\n      selectedIndex={selectedIndex}\n    />\n  );\n}\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { getDefaultSlashMenuItems } from \"@blocknote/core/extensions\";\nimport {\n  RiCodeBlock,\n  RiEmotionFill,\n  RiFile2Line,\n  RiFilmLine,\n  RiH1,\n  RiH2,\n  RiH3,\n  RiH4,\n  RiH5,\n  RiH6,\n  RiImage2Fill,\n  RiListCheck3,\n  RiListOrdered,\n  RiListUnordered,\n  RiPlayList2Fill,\n  RiQuoteText,\n  RiSubtractLine,\n  RiTable2,\n  RiText,\n  RiVolumeUpFill,\n} from \"react-icons/ri\";\n\nimport { IconType } from \"react-icons\";\nimport { DefaultReactSuggestionItem } from \"./types.js\";\n\nconst icons: Record<string, IconType> = {\n  heading: RiH1,\n  heading_2: RiH2,\n  heading_3: RiH3,\n  heading_4: RiH4,\n  heading_5: RiH5,\n  heading_6: RiH6,\n  toggle_heading: RiH1,\n  toggle_heading_2: RiH2,\n  toggle_heading_3: RiH3,\n  quote: RiQuoteText,\n  toggle_list: RiPlayList2Fill,\n  numbered_list: RiListOrdered,\n  bullet_list: RiListUnordered,\n  check_list: RiListCheck3,\n  paragraph: RiText,\n  table: RiTable2,\n  image: RiImage2Fill,\n  video: RiFilmLine,\n  audio: RiVolumeUpFill,\n  file: RiFile2Line,\n  emoji: RiEmotionFill,\n  code_block: RiCodeBlock,\n  divider: RiSubtractLine,\n};\n\nexport function getDefaultReactSlashMenuItems<\n  BSchema extends BlockSchema,\n  I extends InlineContentSchema,\n  S extends StyleSchema,\n>(editor: BlockNoteEditor<BSchema, I, S>): DefaultReactSuggestionItem[] {\n  return getDefaultSlashMenuItems(editor).map((item) => {\n    const Icon = icons[item.key];\n    return {\n      ...item,\n      icon: <Icon size={18} />,\n    };\n  });\n}\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport {\n  SuggestionMenu as SuggestionMenuExtension,\n  SuggestionMenuOptions,\n  filterSuggestionItems,\n} from \"@blocknote/core/extensions\";\nimport { autoPlacement, offset, shift, size } from \"@floating-ui/react\";\nimport { FC, useEffect, useMemo } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension, useExtensionState } from \"../../hooks/useExtension.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport {\n  GenericPopover,\n  GenericPopoverReference,\n} from \"../Popovers/GenericPopover.js\";\nimport { SuggestionMenu } from \"./SuggestionMenu.js\";\nimport { SuggestionMenuWrapper } from \"./SuggestionMenuWrapper.js\";\nimport { getDefaultReactSlashMenuItems } from \"./getDefaultReactSlashMenuItems.js\";\nimport { DefaultReactSuggestionItem, SuggestionMenuProps } from \"./types.js\";\n\ntype ArrayElement<A> = A extends readonly (infer T)[] ? T : never;\n\ntype ItemType<GetItemsType extends (query: string) => Promise<any[]>> =\n  ArrayElement<Awaited<ReturnType<GetItemsType>>>;\n\nexport function SuggestionMenuController<\n  // This is a bit hacky, but only way I found to make types work so the optionality\n  // of suggestionMenuComponent depends on the return type of getItems\n  GetItemsType extends (query: string) => Promise<any[]> = (\n    query: string,\n  ) => Promise<DefaultReactSuggestionItem[]>,\n>(\n  props: {\n    triggerCharacter: string;\n    getItems?: GetItemsType;\n    shouldOpen?: SuggestionMenuOptions[\"shouldOpen\"];\n    minQueryLength?: number;\n    floatingUIOptions?: FloatingUIOptions;\n  } & (ItemType<GetItemsType> extends DefaultReactSuggestionItem\n    ? {\n        // can be undefined\n        suggestionMenuComponent?: FC<\n          SuggestionMenuProps<ItemType<GetItemsType>>\n        >;\n        onItemClick?: (item: ItemType<GetItemsType>) => void;\n      }\n    : {\n        // getItems doesn't return DefaultSuggestionItem, so suggestionMenuComponent is required\n        suggestionMenuComponent: FC<\n          SuggestionMenuProps<ItemType<GetItemsType>>\n        >;\n        onItemClick: (item: ItemType<GetItemsType>) => void;\n      }),\n) {\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const {\n    triggerCharacter,\n    suggestionMenuComponent,\n    shouldOpen,\n    minQueryLength,\n    onItemClick,\n    getItems,\n  } = props;\n\n  const onItemClickOrDefault = useMemo(() => {\n    return (\n      onItemClick ||\n      ((item: ItemType<GetItemsType>) => {\n        item.onItemClick(editor);\n      })\n    );\n  }, [editor, onItemClick]);\n\n  const getItemsOrDefault = useMemo(() => {\n    return (\n      getItems ||\n      ((async (query: string) =>\n        filterSuggestionItems(\n          getDefaultReactSlashMenuItems(editor),\n          query,\n        )) as any as typeof getItems)\n    );\n  }, [editor, getItems])!;\n\n  const suggestionMenu = useExtension(SuggestionMenuExtension);\n\n  useEffect(() => {\n    suggestionMenu.addSuggestionMenu({ triggerCharacter, shouldOpen });\n  }, [suggestionMenu, triggerCharacter, shouldOpen]);\n\n  const state = useExtensionState(SuggestionMenuExtension);\n  const reference = useExtensionState(SuggestionMenuExtension, {\n    selector: (state) =>\n      ({\n        // Use first child as the editor DOM element may itself be scrollable.\n        // For FloatingUI to auto-update the position during scrolling, the\n        // `contextElement` must be a descendant of the scroll container.\n        element: (editor.domElement?.firstChild || undefined) as\n          | Element\n          | undefined,\n        getBoundingClientRect: () => state?.referencePos || new DOMRect(),\n      }) satisfies GenericPopoverReference,\n  });\n\n  const floatingUIOptions = useMemo<FloatingUIOptions>(\n    () => ({\n      ...props.floatingUIOptions,\n      useFloatingOptions: {\n        open: state?.show && state?.triggerCharacter === triggerCharacter,\n        onOpenChange: (open) => {\n          if (!open) {\n            suggestionMenu.closeMenu();\n          }\n        },\n        placement: \"bottom-start\",\n        middleware: [\n          offset(10),\n          // Flips the menu placement to maximize the space available, and prevents\n          // the menu from being cut off by the confines of the screen.\n          autoPlacement({\n            allowedPlacements: [\"bottom-start\", \"top-start\"],\n            padding: 10,\n          }),\n          shift(),\n          size({\n            apply({ elements, availableHeight }) {\n              elements.floating.style.maxHeight = `${Math.max(0, availableHeight)}px`;\n            },\n            padding: 10,\n          }),\n        ],\n        ...props.floatingUIOptions?.useFloatingOptions,\n      },\n      focusManagerProps: {\n        disabled: true,\n        ...props.floatingUIOptions?.focusManagerProps,\n      },\n      elementProps: {\n        // Prevents editor blurring when clicking the scroll bar.\n        onMouseDownCapture: (event) => event.preventDefault(),\n        style: {\n          zIndex: 80,\n        },\n        ...props.floatingUIOptions?.elementProps,\n      },\n    }),\n    [\n      props.floatingUIOptions,\n      state?.show,\n      state?.triggerCharacter,\n      suggestionMenu,\n      triggerCharacter,\n    ],\n  );\n\n  if (\n    !state ||\n    (!state.ignoreQueryLength &&\n      minQueryLength &&\n      (state.query.startsWith(\" \") || state.query.length < minQueryLength))\n  ) {\n    return null;\n  }\n\n  return (\n    <GenericPopover reference={reference} {...floatingUIOptions}>\n      {triggerCharacter && (\n        <SuggestionMenuWrapper\n          query={state.query}\n          closeMenu={suggestionMenu.closeMenu}\n          clearQuery={suggestionMenu.clearQuery}\n          getItems={getItemsOrDefault}\n          suggestionMenuComponent={\n            suggestionMenuComponent || SuggestionMenu<ItemType<GetItemsType>>\n          }\n          onItemClick={onItemClickOrDefault}\n        />\n      )}\n    </GenericPopover>\n  );\n}\n","import {\n  EMPTY_CELL_HEIGHT,\n  EMPTY_CELL_WIDTH,\n  mergeCSSClasses,\n  PartialTableContent,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport {\n  MouseEvent as ReactMouseEvent,\n  ReactNode,\n  useCallback,\n  useEffect,\n  useRef,\n  useState,\n} from \"react\";\nimport { RiAddFill } from \"react-icons/ri\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../hooks/useBlockNoteEditor.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../hooks/useExtension.js\";\nimport { ExtendButtonProps } from \"./ExtendButtonProps.js\";\n\n// Rounds a number up or down, depending on whether we're close (as defined by\n// `margin`) to the next integer.\nconst marginRound = (num: number, margin = 0.3) => {\n  const lowerBound = Math.floor(num) + margin;\n  const upperBound = Math.ceil(num) - margin;\n\n  if (num >= lowerBound && num <= upperBound) {\n    return Math.round(num);\n  } else if (num < lowerBound) {\n    return Math.floor(num);\n  } else {\n    return Math.ceil(num);\n  }\n};\n\nexport const ExtendButton = (\n  props: ExtendButtonProps & { children?: ReactNode },\n) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const block = useExtensionState(TableHandlesExtension, {\n    selector: (state) => state?.block,\n  });\n\n  // needs to be a ref because it's used immediately in the onClick handler\n  // (state would be async and only have effect after the next render\n  const movedMouse = useRef(false);\n\n  const [editingState, setEditingState] = useState<\n    | {\n        originalContent: PartialTableContent<any, any>;\n        originalCroppedContent: PartialTableContent<any, any>;\n        startPos: number;\n      }\n    | undefined\n  >();\n\n  // Lets the user start extending columns/rows by moving the mouse.\n  const mouseDownHandler = useCallback(\n    (event: ReactMouseEvent) => {\n      tableHandles.freezeHandles();\n      props.hideOtherElements(true);\n\n      if (!block) {\n        return;\n      }\n\n      setEditingState({\n        originalContent: block.content as any,\n        originalCroppedContent: {\n          rows: tableHandles.cropEmptyRowsOrColumns(\n            block,\n            props.orientation === \"addOrRemoveColumns\" ? \"columns\" : \"rows\",\n          ),\n        } as PartialTableContent<any, any>,\n        startPos:\n          props.orientation === \"addOrRemoveColumns\"\n            ? event.clientX\n            : event.clientY,\n      });\n      movedMouse.current = false;\n\n      // preventdefault, otherwise text in the table might be selected\n      event.preventDefault();\n    },\n    [block, props, tableHandles],\n  );\n\n  const onClickHandler = useCallback(() => {\n    if (!block || movedMouse.current) {\n      return;\n    }\n\n    editor.updateBlock(block, {\n      type: \"table\",\n      content: {\n        ...block.content,\n        rows:\n          props.orientation === \"addOrRemoveColumns\"\n            ? tableHandles.addRowsOrColumns(block, \"columns\", 1)\n            : tableHandles.addRowsOrColumns(block, \"rows\", 1),\n      } as any,\n    });\n  }, [block, editor, props.orientation, tableHandles]);\n\n  // Extends columns/rows on when moving the mouse.\n  useEffect(() => {\n    const callback = (event: MouseEvent) => {\n      if (!block) {\n        return;\n      }\n\n      if (!editingState) {\n        throw new Error(\"editingState is undefined\");\n      }\n\n      movedMouse.current = true;\n\n      const diff =\n        (props.orientation === \"addOrRemoveColumns\"\n          ? event.clientX\n          : event.clientY) - editingState.startPos;\n\n      const numCroppedCells =\n        props.orientation === \"addOrRemoveColumns\"\n          ? (editingState.originalCroppedContent.rows[0]?.cells.length ?? 0)\n          : editingState.originalCroppedContent.rows.length;\n\n      const numOriginalCells =\n        props.orientation === \"addOrRemoveColumns\"\n          ? (editingState.originalContent.rows[0]?.cells.length ?? 0)\n          : editingState.originalContent.rows.length;\n\n      const currentNumCells =\n        props.orientation === \"addOrRemoveColumns\"\n          ? block.content.rows[0].cells.length\n          : block.content.rows.length;\n\n      const newNumCells =\n        numOriginalCells +\n        marginRound(\n          diff /\n            (props.orientation === \"addOrRemoveColumns\"\n              ? EMPTY_CELL_WIDTH\n              : EMPTY_CELL_HEIGHT),\n          0.3,\n        );\n\n      if (\n        newNumCells >= numCroppedCells &&\n        newNumCells > 0 &&\n        newNumCells !== currentNumCells\n      ) {\n        editor.updateBlock(block, {\n          type: \"table\",\n          content: {\n            ...block.content,\n            rows:\n              props.orientation === \"addOrRemoveColumns\"\n                ? tableHandles.addRowsOrColumns(\n                    {\n                      type: \"table\",\n                      content: editingState.originalCroppedContent,\n                    } as any,\n                    \"columns\",\n                    newNumCells - numCroppedCells,\n                  )\n                : tableHandles.addRowsOrColumns(\n                    {\n                      type: \"table\",\n                      content: editingState.originalCroppedContent,\n                    } as any,\n                    \"rows\",\n                    newNumCells - numCroppedCells,\n                  ),\n          } as any,\n        });\n\n        // Edge case for updating block content as `updateBlock` causes the\n        // selection to move into the next block, so we have to set it back.\n        if (block.content) {\n          editor.setTextCursorPosition(block);\n        }\n      }\n    };\n\n    if (editingState) {\n      window.addEventListener(\"mousemove\", callback);\n    }\n\n    return () => {\n      window.removeEventListener(\"mousemove\", callback);\n    };\n  }, [block, editingState, editor, props.orientation, tableHandles]);\n\n  // Stops mouse movements from extending columns/rows when the mouse is\n  // released. Also extends columns/rows by 1 if the mouse wasn't moved enough\n  // to add any, imitating a click.\n  useEffect(() => {\n    const callback = () => {\n      props.hideOtherElements(false);\n      tableHandles.unfreezeHandles();\n      setEditingState(undefined);\n    };\n\n    if (editingState) {\n      window.addEventListener(\"mouseup\", callback);\n    }\n\n    return () => {\n      window.removeEventListener(\"mouseup\", callback);\n    };\n  }, [editingState, props, tableHandles]);\n\n  if (!editor.isEditable) {\n    return null;\n  }\n\n  return (\n    <Components.TableHandle.ExtendButton\n      className={mergeCSSClasses(\n        \"bn-extend-button\",\n        props.orientation === \"addOrRemoveColumns\"\n          ? \"bn-extend-button-add-remove-columns\"\n          : \"bn-extend-button-add-remove-rows\",\n        editingState !== null ? \"bn-extend-button-editing\" : \"\",\n      )}\n      onClick={onClickHandler}\n      onMouseDown={mouseDownHandler}\n    >\n      {props.children || <RiAddFill size={18} data-test={\"extendButton\"} />}\n    </Components.TableHandle.ExtendButton>\n  );\n};\n","import { isTableCell, mapTableCell } from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport { ColorPicker } from \"../../../ColorPicker/ColorPicker.js\";\n\nexport const ColorPickerButton = (props: { children?: ReactNode }) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const { block, colIndex, rowIndex } = useExtensionState(\n    TableHandlesExtension,\n    {\n      selector: (state) => ({\n        block: state?.block,\n        colIndex: state?.colIndex,\n        rowIndex: state?.rowIndex,\n      }),\n    },\n  );\n\n  const updateColor = (color: string, type: \"text\" | \"background\") => {\n    if (\n      block === undefined ||\n      colIndex === undefined ||\n      rowIndex === undefined\n    ) {\n      return;\n    }\n\n    const newTable = block.content.rows.map((row) => {\n      return {\n        ...row,\n        cells: row.cells.map((cell) => mapTableCell(cell)),\n      };\n    });\n\n    if (type === \"text\") {\n      newTable[rowIndex].cells[colIndex].props.textColor = color;\n    } else {\n      newTable[rowIndex].cells[colIndex].props.backgroundColor = color;\n    }\n\n    editor.updateBlock(block, {\n      type: \"table\",\n      content: {\n        ...block.content,\n        rows: newTable,\n      },\n    });\n\n    // Have to reset text cursor position to the block as `updateBlock`\n    // moves the existing selection out of the block.\n    editor.setTextCursorPosition(block);\n  };\n\n  if (block === undefined || colIndex === undefined || rowIndex === undefined) {\n    return null;\n  }\n\n  const currentCell = block.content.rows[rowIndex]?.cells?.[colIndex];\n\n  if (\n    !currentCell ||\n    (editor.settings.tables.cellTextColor === false &&\n      editor.settings.tables.cellBackgroundColor === false)\n  ) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Root position={\"right\"} sub={true}>\n      <Components.Generic.Menu.Trigger sub={true}>\n        <Components.Generic.Menu.Item\n          className={\"bn-menu-item\"}\n          subTrigger={true}\n        >\n          {props.children || dict.drag_handle.colors_menuitem}\n        </Components.Generic.Menu.Item>\n      </Components.Generic.Menu.Trigger>\n\n      <Components.Generic.Menu.Dropdown\n        sub={true}\n        className={\"bn-menu-dropdown bn-color-picker-dropdown\"}\n      >\n        <ColorPicker\n          iconSize={18}\n          text={\n            editor.settings.tables.cellTextColor\n              ? {\n                  color: isTableCell(currentCell)\n                    ? currentCell.props.textColor\n                    : \"default\",\n                  setColor: (color) => updateColor(color, \"text\"),\n                }\n              : undefined\n          }\n          background={\n            editor.settings.tables.cellBackgroundColor\n              ? {\n                  color: isTableCell(currentCell)\n                    ? currentCell.props.backgroundColor\n                    : \"default\",\n                  setColor: (color) => updateColor(color, \"background\"),\n                }\n              : undefined\n          }\n        />\n      </Components.Generic.Menu.Dropdown>\n    </Components.Generic.Menu.Root>\n  );\n};\n","import { getColspan, getRowspan, isTableCell } from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../../hooks/useExtension.js\";\n\nexport const SplitButton = () => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const { block, colIndex, rowIndex } = useExtensionState(\n    TableHandlesExtension,\n    {\n      selector: (state) => ({\n        block: state?.block,\n        colIndex: state?.colIndex,\n        rowIndex: state?.rowIndex,\n      }),\n    },\n  );\n\n  if (block === undefined || colIndex === undefined || rowIndex === undefined) {\n    return null;\n  }\n\n  const currentCell = block.content.rows[rowIndex]?.cells?.[colIndex];\n\n  if (\n    !currentCell ||\n    !isTableCell(currentCell) ||\n    (getRowspan(currentCell) === 1 && getColspan(currentCell) === 1) ||\n    !editor.settings.tables.splitCells\n  ) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Item\n      onClick={() => {\n        tableHandles.splitCell({\n          row: rowIndex,\n          col: colIndex,\n        });\n      }}\n    >\n      {dict.table_handle.split_cell_menuitem}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { ColorPickerButton } from \"./DefaultButtons/ColorPicker.js\";\nimport { SplitButton } from \"./DefaultButtons/SplitButton.js\";\n\nexport const TableCellMenu = (props: { children?: ReactNode }) => {\n  const Components = useComponentsContext()!;\n\n  return (\n    <Components.Generic.Menu.Dropdown\n      className={\"bn-menu-dropdown bn-table-handle-menu\"}\n    >\n      {props.children || (\n        <>\n          <SplitButton />\n          <ColorPickerButton />\n        </>\n      )}\n    </Components.Generic.Menu.Dropdown>\n  );\n};\n","import { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode } from \"react\";\nimport { MdArrowDropDown } from \"react-icons/md\";\n\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension } from \"../../hooks/useExtension.js\";\nimport { TableCellButtonProps } from \"./TableCellButtonProps.js\";\nimport { TableCellMenu } from \"./TableCellMenu/TableCellMenu.js\";\n\n/**\n * By default, the TableCellHandle component will render with the default icon.\n * However, you can override the icon to render by passing children.\n */\nexport const TableCellButton = (\n  props: TableCellButtonProps & { children?: ReactNode },\n) => {\n  const Components = useComponentsContext()!;\n\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n\n  const Component = props.tableCellMenu || TableCellMenu;\n\n  if (\n    !editor.settings.tables.splitCells &&\n    !editor.settings.tables.cellBackgroundColor &&\n    !editor.settings.tables.cellTextColor\n  ) {\n    // Hide the button altogether if all table cell settings are disabled\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Root\n      onOpenChange={(open: boolean) => {\n        if (open) {\n          tableHandles.freezeHandles();\n          props.hideOtherElements(true);\n        } else {\n          tableHandles.unfreezeHandles();\n          props.hideOtherElements(false);\n          editor.focus();\n        }\n      }}\n      position={\"right\"}\n    >\n      <Components.Generic.Menu.Trigger>\n        <Components.Generic.Menu.Button className={\"bn-table-cell-handle\"}>\n          {props.children || (\n            <MdArrowDropDown size={12} data-test={\"tableCellHandle\"} />\n          )}\n        </Components.Generic.Menu.Button>\n      </Components.Generic.Menu.Trigger>\n      <Component />\n    </Components.Generic.Menu.Root>\n  );\n};\n","import { TableHandlesExtension } from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../../hooks/useExtension.js\";\n\nexport const AddButton = (\n  props:\n    | { orientation: \"row\"; side: \"above\" | \"below\" }\n    | { orientation: \"column\"; side: \"left\" | \"right\" },\n) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const index = useExtensionState(TableHandlesExtension, {\n    selector: (state) =>\n      props.orientation === \"column\" ? state?.colIndex : state?.rowIndex,\n  });\n\n  if (tableHandles === undefined || index === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Item\n      onClick={() => {\n        tableHandles.addRowOrColumn(\n          index,\n          props.orientation === \"row\"\n            ? { orientation: \"row\", side: props.side }\n            : { orientation: \"column\", side: props.side },\n        );\n      }}\n    >\n      {dict.table_handle[`add_${props.side}_menuitem`]}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import { TableHandlesExtension } from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../../hooks/useExtension.js\";\n\nexport const DeleteButton = (props: { orientation: \"row\" | \"column\" }) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const index = useExtensionState(TableHandlesExtension, {\n    selector: (state) =>\n      props.orientation === \"column\" ? state?.colIndex : state?.rowIndex,\n  });\n\n  if (tableHandles === undefined || index === undefined) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Item\n      onClick={() => tableHandles.removeRowOrColumn(index, props.orientation)}\n    >\n      {props.orientation === \"row\"\n        ? dict.table_handle.delete_row_menuitem\n        : dict.table_handle.delete_column_menuitem}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import {\n  DefaultBlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  InlineContentSchema,\n  isTableCell,\n  mapTableCell,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport { ColorPicker } from \"../../../ColorPicker/ColorPicker.js\";\nimport { ReactNode, useMemo } from \"react\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../../hooks/useExtension.js\";\n\nexport const ColorPickerButton = <\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(props: {\n  orientation: \"row\" | \"column\";\n  children?: ReactNode;\n}) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n  const editor = useBlockNoteEditor<\n    { table: DefaultBlockSchema[\"table\"] },\n    I,\n    S\n  >();\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const { block, index } = useExtensionState(TableHandlesExtension, {\n    selector: (state) => ({\n      block: state?.block,\n      index: props.orientation === \"column\" ? state?.colIndex : state?.rowIndex,\n    }),\n  });\n\n  const currentCells = useMemo(() => {\n    if (\n      tableHandles === undefined ||\n      block === undefined ||\n      index === undefined\n    ) {\n      return [];\n    }\n\n    if (props.orientation === \"row\") {\n      return tableHandles.getCellsAtRowHandle(block, index);\n    }\n\n    return tableHandles.getCellsAtColumnHandle(block, index);\n  }, [block, index, props.orientation, tableHandles]);\n\n  const updateColor = (color: string, type: \"text\" | \"background\") => {\n    if (block === undefined) {\n      return;\n    }\n\n    const newTable = block.content.rows.map((row) => {\n      return {\n        ...row,\n        cells: row.cells.map((cell) => mapTableCell(cell)),\n      };\n    });\n\n    currentCells.forEach(({ row, col }) => {\n      if (type === \"text\") {\n        newTable[row].cells[col].props.textColor = color;\n      } else {\n        newTable[row].cells[col].props.backgroundColor = color;\n      }\n    });\n\n    editor.updateBlock(block, {\n      type: \"table\",\n      content: {\n        ...block.content,\n        rows: newTable,\n      } as any,\n    });\n\n    // Have to reset text cursor position to the block as `updateBlock`\n    // moves the existing selection out of the block.\n    editor.setTextCursorPosition(block);\n  };\n\n  if (\n    !currentCells ||\n    !currentCells[0] ||\n    !tableHandles ||\n    (editor.settings.tables.cellTextColor === false &&\n      editor.settings.tables.cellBackgroundColor === false)\n  ) {\n    return null;\n  }\n\n  const firstCell = mapTableCell(currentCells[0].cell);\n\n  return (\n    <Components.Generic.Menu.Root position={\"right\"} sub={true}>\n      <Components.Generic.Menu.Trigger sub={true}>\n        <Components.Generic.Menu.Item\n          className={\"bn-menu-item\"}\n          subTrigger={true}\n        >\n          {/* TODO should I be using the dictionary here? */}\n          {props.children || dict.drag_handle.colors_menuitem}\n        </Components.Generic.Menu.Item>\n      </Components.Generic.Menu.Trigger>\n\n      <Components.Generic.Menu.Dropdown\n        sub={true}\n        className={\"bn-menu-dropdown bn-color-picker-dropdown\"}\n      >\n        <ColorPicker\n          iconSize={18}\n          text={\n            editor.settings.tables.cellTextColor\n              ? {\n                  // All cells have the same text color\n                  color: currentCells.every(\n                    ({ cell }) =>\n                      isTableCell(cell) &&\n                      cell.props.textColor === firstCell.props.textColor,\n                  )\n                    ? firstCell.props.textColor\n                    : \"default\",\n                  setColor: (color) => {\n                    updateColor(color, \"text\");\n                  },\n                }\n              : undefined\n          }\n          background={\n            editor.settings.tables.cellBackgroundColor\n              ? {\n                  color: currentCells.every(\n                    ({ cell }) =>\n                      isTableCell(cell) &&\n                      cell.props.backgroundColor ===\n                        firstCell.props.backgroundColor,\n                  )\n                    ? firstCell.props.backgroundColor\n                    : \"default\",\n                  setColor: (color) => updateColor(color, \"background\"),\n                }\n              : undefined\n          }\n        />\n      </Components.Generic.Menu.Dropdown>\n    </Components.Generic.Menu.Root>\n  );\n};\n","import {\n  DefaultBlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\n\nimport { useComponentsContext } from \"../../../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport {\n  useExtension,\n  useExtensionState,\n} from \"../../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\n\nexport const TableHeaderRowButton = <\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(props: {\n  orientation: \"row\" | \"column\";\n}) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<\n    { table: DefaultBlockSchema[\"table\"] },\n    I,\n    S\n  >();\n  const tableHandles = useExtension(TableHandlesExtension);\n  const { block, index } = useExtensionState(TableHandlesExtension, {\n    selector: (state) => ({\n      block: state?.block,\n      index: props.orientation === \"column\" ? state?.colIndex : state?.rowIndex,\n    }),\n  });\n\n  if (\n    tableHandles === undefined ||\n    block === undefined ||\n    index !== 0 ||\n    props.orientation !== \"row\" ||\n    !editor.settings.tables.headers\n  ) {\n    return null;\n  }\n\n  // We only support 1 header row for now\n  const isHeaderRow = Boolean(block.content.headerRows);\n\n  return (\n    <Components.Generic.Menu.Item\n      className={\"bn-menu-item\"}\n      checked={isHeaderRow}\n      onClick={() => {\n        editor.updateBlock(block, {\n          ...block,\n          content: {\n            ...block.content,\n            headerRows: isHeaderRow ? undefined : 1,\n          } as any,\n        });\n      }}\n    >\n      {dict.drag_handle.header_row_menuitem}\n    </Components.Generic.Menu.Item>\n  );\n};\n\nexport const TableHeaderColumnButton = <\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(props: {\n  orientation: \"row\" | \"column\";\n}) => {\n  const Components = useComponentsContext()!;\n  const dict = useDictionary();\n\n  const editor = useBlockNoteEditor<\n    { table: DefaultBlockSchema[\"table\"] },\n    I,\n    S\n  >();\n  const tableHandles = useExtension(TableHandlesExtension);\n  const block = useExtensionState(TableHandlesExtension, {\n    selector: (state) => state?.block,\n  });\n  const index = useExtensionState(TableHandlesExtension, {\n    selector: (state) =>\n      props.orientation === \"column\" ? state?.colIndex : state?.rowIndex,\n  });\n\n  if (\n    !tableHandles ||\n    index !== 0 ||\n    !block ||\n    props.orientation !== \"column\" ||\n    !editor.settings.tables.headers\n  ) {\n    return null;\n  }\n\n  // We only support 1 header column for now\n  const isHeaderColumn = Boolean(block.content.headerCols);\n\n  return (\n    <Components.Generic.Menu.Item\n      className={\"bn-menu-item\"}\n      checked={isHeaderColumn}\n      onClick={() => {\n        editor.updateBlock(block, {\n          ...block,\n          content: {\n            ...block.content,\n            headerCols: isHeaderColumn ? undefined : 1,\n          } as any,\n        });\n      }}\n    >\n      {dict.drag_handle.header_column_menuitem}\n    </Components.Generic.Menu.Item>\n  );\n};\n","import { ReactNode } from \"react\";\n\nimport { useComponentsContext } from \"../../../editor/ComponentsContext.js\";\nimport { AddButton } from \"./DefaultButtons/AddButton.js\";\nimport { DeleteButton } from \"./DefaultButtons/DeleteButton.js\";\nimport { ColorPickerButton } from \"./DefaultButtons/ColorPicker.js\";\nimport { TableHeaderColumnButton } from \"./DefaultButtons/TableHeaderButton.js\";\nimport { TableHeaderRowButton } from \"./DefaultButtons/TableHeaderButton.js\";\nimport { TableHandleMenuProps } from \"./TableHandleMenuProps.js\";\n\nexport const TableHandleMenu = (\n  props: TableHandleMenuProps & { children?: ReactNode },\n) => {\n  const Components = useComponentsContext()!;\n\n  return (\n    <Components.Generic.Menu.Dropdown className={\"bn-table-handle-menu\"}>\n      {props.children || (\n        <>\n          <DeleteButton orientation={props.orientation} />\n          <AddButton\n            orientation={props.orientation}\n            side={props.orientation === \"row\" ? \"above\" : (\"left\" as any)}\n          />\n          <AddButton\n            orientation={props.orientation}\n            side={props.orientation === \"row\" ? \"below\" : (\"right\" as any)}\n          />\n          <TableHeaderRowButton orientation={props.orientation} />\n          <TableHeaderColumnButton orientation={props.orientation} />\n          <ColorPickerButton orientation={props.orientation} />\n        </>\n      )}\n    </Components.Generic.Menu.Dropdown>\n  );\n};\n","import { getColspan, getRowspan, mergeCSSClasses } from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode, useMemo, useState } from \"react\";\n\nimport { MdDragIndicator } from \"react-icons/md\";\nimport { useComponentsContext } from \"../../editor/ComponentsContext.js\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension, useExtensionState } from \"../../hooks/useExtension.js\";\nimport { TableHandleMenu } from \"./TableHandleMenu/TableHandleMenu.js\";\nimport { TableHandleProps } from \"./TableHandleProps.js\";\n\n/**\n * By default, the TableHandle component will render with the default icon.\n * However, you can override the icon to render by passing children.\n */\nexport const TableHandle = (\n  props: TableHandleProps & {\n    children?: ReactNode;\n  },\n) => {\n  const editor = useBlockNoteEditor<any, any, any>();\n  const Components = useComponentsContext()!;\n\n  const [isDragging, setIsDragging] = useState(false);\n\n  const Component = props.tableHandleMenu || TableHandleMenu;\n\n  const tableHandles = useExtension(TableHandlesExtension);\n  const state = useExtensionState(TableHandlesExtension);\n\n  const isDraggable = useMemo(() => {\n    if (\n      !tableHandles ||\n      !state ||\n      !state.block ||\n      state.block.type !== \"table\"\n    ) {\n      return false;\n    }\n\n    if (props.orientation === \"column\") {\n      return tableHandles\n        .getCellsAtColumnHandle(state.block, state.colIndex!)\n        .every(({ cell }) => getColspan(cell) === 1);\n    }\n\n    return tableHandles\n      .getCellsAtRowHandle(state.block, state.rowIndex!)\n      .every(({ cell }) => getRowspan(cell) === 1);\n  }, [props.orientation, state, tableHandles]);\n\n  if (!state) {\n    return null;\n  }\n\n  return (\n    <Components.Generic.Menu.Root\n      onOpenChange={(open: boolean) => {\n        if (open) {\n          tableHandles.freezeHandles();\n          props.hideOtherElements(true);\n        } else {\n          tableHandles.unfreezeHandles();\n          props.hideOtherElements(false);\n          editor.focus();\n        }\n      }}\n      position={\"right\"}\n    >\n      <Components.Generic.Menu.Trigger>\n        <Components.TableHandle.Root\n          className={mergeCSSClasses(\n            \"bn-table-handle\",\n            isDragging ? \"bn-table-handle-dragging\" : \"\",\n            !isDraggable ? \"bn-table-handle-not-draggable\" : \"\",\n          )}\n          draggable={isDraggable}\n          onDragStart={(e) => {\n            setIsDragging(true);\n            props.hideOtherElements(true);\n            if (props.orientation === \"column\") {\n              tableHandles.colDragStart(e);\n            } else {\n              tableHandles.rowDragStart(e);\n            }\n          }}\n          onDragEnd={() => {\n            tableHandles.dragEnd();\n            props.hideOtherElements(false);\n            setIsDragging(false);\n          }}\n          style={\n            props.orientation === \"column\"\n              ? { transform: \"rotate(0.25turn)\" }\n              : undefined\n          }\n        >\n          {props.children || (\n            <MdDragIndicator size={24} data-test={\"tableHandle\"} />\n          )}\n        </Components.TableHandle.Root>\n      </Components.Generic.Menu.Trigger>\n      <Component orientation={props.orientation} />\n    </Components.Generic.Menu.Root>\n  );\n};\n","import {\n  BlockSchema,\n  DefaultInlineContentSchema,\n  DefaultStyleSchema,\n  getNodeById,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { TableHandlesExtension } from \"@blocknote/core/extensions\";\nimport { FC, useCallback, useMemo, useState } from \"react\";\n\nimport { autoUpdate, offset, ReferenceElement, size } from \"@floating-ui/react\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../hooks/useExtension.js\";\nimport { FloatingUIOptions } from \"../Popovers/FloatingUIOptions.js\";\nimport {\n  GenericPopover,\n  GenericPopoverReference,\n} from \"../Popovers/GenericPopover.js\";\nimport { ExtendButton } from \"./ExtendButton/ExtendButton.js\";\nimport { ExtendButtonProps } from \"./ExtendButton/ExtendButtonProps.js\";\nimport { TableCellButton } from \"./TableCellButton.js\";\nimport { TableCellButtonProps } from \"./TableCellButtonProps.js\";\nimport { TableHandle } from \"./TableHandle.js\";\nimport { TableHandleProps } from \"./TableHandleProps.js\";\n\nexport const TableHandlesController = <\n  I extends InlineContentSchema = DefaultInlineContentSchema,\n  S extends StyleSchema = DefaultStyleSchema,\n>(props: {\n  tableCellHandle?: FC<TableCellButtonProps>;\n  tableHandle?: FC<TableHandleProps>;\n  extendButton?: FC<ExtendButtonProps>;\n}) => {\n  const editor = useBlockNoteEditor<BlockSchema, I, S>();\n\n  const [onlyShownElement, setOnlyShownElement] = useState<\n    | \"rowTableHandle\"\n    | \"columnTableHandle\"\n    | \"tableCellHandle\"\n    | \"extendRowsButton\"\n    | \"extendColumnsButton\"\n    | undefined\n  >();\n\n  const state = useExtensionState(TableHandlesExtension);\n\n  const references = useMemo<{\n    tableReference?: GenericPopoverReference;\n    cellReference?: GenericPopoverReference;\n    rowReference?: GenericPopoverReference;\n    columnReference?: GenericPopoverReference;\n  }>(() => {\n    const references: {\n      tableReference?: GenericPopoverReference;\n      cellReference?: GenericPopoverReference;\n      rowReference?: GenericPopoverReference;\n      columnReference?: GenericPopoverReference;\n    } = {};\n\n    if (state === undefined) {\n      return {};\n    }\n\n    // TODO use the location API for this\n    const nodePosInfo = getNodeById(\n      state.block.id,\n      editor.prosemirrorState.doc,\n    );\n    if (!nodePosInfo) {\n      return {};\n    }\n\n    const tableBeforePos = nodePosInfo.posBeforeNode + 1;\n\n    const tableElement = editor.prosemirrorView.domAtPos(\n      tableBeforePos + 1,\n    ).node;\n    if (!(tableElement instanceof Element)) {\n      return {};\n    }\n\n    references.tableReference = { element: tableElement };\n\n    if (state.rowIndex === undefined || state.colIndex === undefined) {\n      return references;\n    }\n\n    const rowBeforePos = editor.prosemirrorState.doc\n      .resolve(tableBeforePos + 1)\n      .posAtIndex(state.rowIndex);\n    const cellBeforePos = editor.prosemirrorState.doc\n      .resolve(rowBeforePos + 1)\n      .posAtIndex(state.colIndex);\n\n    const cellElement = editor.prosemirrorView.domAtPos(cellBeforePos + 1).node;\n    if (!(cellElement instanceof Element)) {\n      return {};\n    }\n\n    references.cellReference = { element: cellElement };\n    references.rowReference = {\n      element: tableElement,\n      getBoundingClientRect: () => {\n        const tableBoundingRect = tableElement.getBoundingClientRect();\n        const cellBoundingRect = cellElement.getBoundingClientRect();\n\n        return new DOMRect(\n          tableBoundingRect.x,\n          state.draggingState &&\n          state.draggingState.draggedCellOrientation === \"row\"\n            ? state.draggingState.mousePos - cellBoundingRect.height / 2\n            : cellBoundingRect.y,\n          tableBoundingRect.width,\n          cellBoundingRect.height,\n        );\n      },\n    };\n    references.columnReference = {\n      element: tableElement,\n      getBoundingClientRect: () => {\n        const tableBoundingRect = tableElement.getBoundingClientRect();\n        const cellBoundingRect = cellElement.getBoundingClientRect();\n\n        return new DOMRect(\n          state.draggingState &&\n          state.draggingState.draggedCellOrientation === \"col\"\n            ? state.draggingState.mousePos - cellBoundingRect.width / 2\n            : cellBoundingRect.x,\n          tableBoundingRect.y,\n          cellBoundingRect.width,\n          tableBoundingRect.height,\n        );\n      },\n    };\n\n    return references;\n  }, [editor, state]);\n\n  // Hides the table handles on ancestor scroll so they don't overflow\n  // outside the editor's scroll container.\n  const whileElementsMounted = useCallback(\n    (\n      reference: ReferenceElement,\n      floating: HTMLElement,\n      _update: () => void,\n    ) => {\n      let initialized = false;\n      return autoUpdate(\n        reference,\n        floating,\n        () => {\n          if (!initialized) {\n            initialized = true;\n            return;\n          }\n          editor.getExtension(TableHandlesExtension)?.hideHandlesIfNotFrozen();\n        },\n        {\n          ancestorScroll: true,\n          ancestorResize: false,\n          elementResize: false,\n          layoutShift: false,\n        },\n      );\n    },\n    [editor],\n  );\n\n  const floatingUIOptions = useMemo<\n    | {\n        rowTableHandle: FloatingUIOptions;\n        columnTableHandle: FloatingUIOptions;\n        tableCellHandle: FloatingUIOptions;\n        extendRowsButton: FloatingUIOptions;\n        extendColumnsButton: FloatingUIOptions;\n      }\n    | undefined\n  >(\n    () =>\n      state !== undefined\n        ? {\n            rowTableHandle: {\n              useFloatingOptions: {\n                open:\n                  state.show &&\n                  state.rowIndex !== undefined &&\n                  (!onlyShownElement || onlyShownElement === \"rowTableHandle\"),\n                placement: \"left\",\n                middleware: [offset(-10)],\n                whileElementsMounted,\n              },\n              focusManagerProps: {\n                disabled: true,\n              },\n              elementProps: {\n                style: {\n                  zIndex: 10,\n                },\n              },\n            },\n            columnTableHandle: {\n              useFloatingOptions: {\n                open:\n                  state.show &&\n                  state.colIndex !== undefined &&\n                  (!onlyShownElement ||\n                    onlyShownElement === \"columnTableHandle\"),\n                placement: \"top\",\n                middleware: [offset(-12)],\n                whileElementsMounted,\n              },\n              focusManagerProps: {\n                disabled: true,\n              },\n              elementProps: {\n                style: {\n                  zIndex: 10,\n                },\n              },\n            },\n            tableCellHandle: {\n              useFloatingOptions: {\n                open:\n                  state.show &&\n                  state.rowIndex !== undefined &&\n                  state.colIndex !== undefined &&\n                  (!onlyShownElement || onlyShownElement === \"tableCellHandle\"),\n                placement: \"top-end\",\n                middleware: [offset({ mainAxis: -15, crossAxis: -1 })],\n                whileElementsMounted,\n              },\n              focusManagerProps: {\n                disabled: true,\n              },\n              elementProps: {\n                style: {\n                  zIndex: 10,\n                },\n              },\n            },\n            extendRowsButton: {\n              useFloatingOptions: {\n                open:\n                  state.show &&\n                  state.showAddOrRemoveRowsButton &&\n                  (!onlyShownElement ||\n                    onlyShownElement === \"extendRowsButton\"),\n                placement: \"bottom\",\n                whileElementsMounted,\n                middleware: [\n                  size({\n                    apply({ rects, elements }) {\n                      Object.assign(elements.floating.style, {\n                        width: `${rects.reference.width}px`,\n                      });\n                    },\n                  }),\n                ],\n              },\n              focusManagerProps: {\n                disabled: true,\n              },\n              elementProps: {\n                style: {\n                  zIndex: 10,\n                },\n              },\n            },\n            extendColumnsButton: {\n              useFloatingOptions: {\n                open:\n                  state.show &&\n                  state.showAddOrRemoveColumnsButton &&\n                  (!onlyShownElement ||\n                    onlyShownElement === \"extendColumnsButton\"),\n                placement: \"right\",\n                whileElementsMounted,\n                middleware: [\n                  size({\n                    apply({ rects, elements }) {\n                      Object.assign(elements.floating.style, {\n                        height: `${rects.reference.height}px`,\n                      });\n                    },\n                  }),\n                ],\n              },\n              focusManagerProps: {\n                disabled: true,\n              },\n              elementProps: {\n                style: {\n                  zIndex: 10,\n                },\n              },\n            },\n          }\n        : undefined,\n    [onlyShownElement, state, whileElementsMounted],\n  );\n\n  if (!state) {\n    return null;\n  }\n\n  const TableHandleComponent = props.tableHandle || TableHandle;\n  const ExtendButtonComponent = props.extendButton || ExtendButton;\n  const TableCellHandleComponent = props.tableCellHandle || TableCellButton;\n\n  return (\n    <>\n      <GenericPopover\n        reference={references?.rowReference}\n        {...floatingUIOptions?.rowTableHandle}\n      >\n        {state.show &&\n          state.rowIndex !== undefined &&\n          (!onlyShownElement || onlyShownElement === \"rowTableHandle\") && (\n            <TableHandleComponent\n              orientation=\"row\"\n              hideOtherElements={(hide) =>\n                setOnlyShownElement(hide ? \"rowTableHandle\" : undefined)\n              }\n            />\n          )}\n      </GenericPopover>\n      <GenericPopover\n        reference={references?.columnReference}\n        {...floatingUIOptions?.columnTableHandle}\n      >\n        {state.show &&\n          state.colIndex !== undefined &&\n          (!onlyShownElement || onlyShownElement === \"columnTableHandle\") && (\n            <TableHandleComponent\n              orientation=\"column\"\n              hideOtherElements={(hide) =>\n                setOnlyShownElement(hide ? \"columnTableHandle\" : undefined)\n              }\n            />\n          )}\n      </GenericPopover>\n      <GenericPopover\n        reference={references?.cellReference}\n        {...floatingUIOptions?.tableCellHandle}\n      >\n        {state.show &&\n          state.rowIndex !== undefined &&\n          state.colIndex !== undefined &&\n          (!onlyShownElement || onlyShownElement === \"tableCellHandle\") && (\n            <TableCellHandleComponent\n              hideOtherElements={(hide) =>\n                setOnlyShownElement(hide ? \"tableCellHandle\" : undefined)\n              }\n            />\n          )}\n      </GenericPopover>\n      <GenericPopover\n        reference={references?.tableReference}\n        {...floatingUIOptions?.extendRowsButton}\n      >\n        {state.show &&\n          state.showAddOrRemoveRowsButton &&\n          (!onlyShownElement || onlyShownElement === \"extendRowsButton\") && (\n            <ExtendButtonComponent\n              orientation=\"addOrRemoveRows\"\n              hideOtherElements={(hide) =>\n                setOnlyShownElement(hide ? \"extendRowsButton\" : undefined)\n              }\n            />\n          )}\n      </GenericPopover>\n      <GenericPopover\n        reference={references?.tableReference}\n        {...floatingUIOptions?.extendColumnsButton}\n      >\n        {state.show &&\n          state.showAddOrRemoveColumnsButton &&\n          (!onlyShownElement || onlyShownElement === \"extendColumnsButton\") && (\n            <ExtendButtonComponent\n              orientation=\"addOrRemoveColumns\"\n              hideOtherElements={(hide) =>\n                setOnlyShownElement(hide ? \"extendColumnsButton\" : undefined)\n              }\n            />\n          )}\n      </GenericPopover>\n    </>\n  );\n};\n","import { CommentsExtension } from \"@blocknote/core/comments\";\nimport {\n  FilePanelExtension,\n  FormattingToolbarExtension,\n  LinkToolbarExtension,\n  SideMenuExtension,\n  SuggestionMenu,\n  TableHandlesExtension,\n} from \"@blocknote/core/extensions\";\nimport { lazy, Suspense } from \"react\";\n\nimport { FilePanelController } from \"../components/FilePanel/FilePanelController.js\";\nimport { FormattingToolbarController } from \"../components/FormattingToolbar/FormattingToolbarController.js\";\nimport { LinkToolbarController } from \"../components/LinkToolbar/LinkToolbarController.js\";\nimport { SideMenuController } from \"../components/SideMenu/SideMenuController.js\";\nimport { GridSuggestionMenuController } from \"../components/SuggestionMenu/GridSuggestionMenu/GridSuggestionMenuController.js\";\nimport { SuggestionMenuController } from \"../components/SuggestionMenu/SuggestionMenuController.js\";\nimport { TableHandlesController } from \"../components/TableHandles/TableHandlesController.js\";\nimport { useBlockNoteEditor } from \"../hooks/useBlockNoteEditor.js\";\n\n// Lazily load the comments components to avoid pulling in the comments extensions into the main bundle\nconst FloatingComposerController = lazy(\n  () => import(\"../components/Comments/FloatingComposerController.js\"),\n);\nconst FloatingThreadController = lazy(\n  () => import(\"../components/Comments/FloatingThreadController.js\"),\n);\n\nexport type BlockNoteDefaultUIProps = {\n  /**\n   * Whether the formatting toolbar should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/formatting-toolbar}\n   */\n  formattingToolbar?: boolean;\n\n  /**\n   * Whether the link toolbar should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/link-toolbar}\n   */\n  linkToolbar?: boolean;\n\n  /**\n   * Whether the slash menu should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/suggestion-menus#slash-menu}\n   */\n  slashMenu?: boolean;\n\n  /**\n   * Whether the block side menu should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/side-menu}\n   */\n  sideMenu?: boolean;\n\n  /**\n   * Whether the file panel should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/file-panel}\n   */\n  filePanel?: boolean;\n\n  /**\n   * Whether the table handles should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/table-handles}\n   */\n  tableHandles?: boolean;\n\n  /**\n   * Whether the emoji picker should be enabled.\n   * @see {@link https://blocknotejs.org/docs/advanced/grid-suggestion-menus#emoji-picker}\n   */\n  emojiPicker?: boolean;\n\n  /**\n   * Whether the default comments UI feature should be enabled.\n   * @see {@link https://blocknotejs.org/docs/react/components/comments}\n   */\n  comments?: boolean;\n};\n\nexport function BlockNoteDefaultUI(props: BlockNoteDefaultUIProps) {\n  const editor = useBlockNoteEditor();\n\n  if (!editor) {\n    throw new Error(\n      \"BlockNoteDefaultUI must be used within a BlockNoteContext.Provider\",\n    );\n  }\n\n  return (\n    <>\n      {editor.getExtension(FormattingToolbarExtension) &&\n        props.formattingToolbar !== false && <FormattingToolbarController />}\n      {editor.getExtension(LinkToolbarExtension) &&\n        props.linkToolbar !== false && <LinkToolbarController />}\n      {editor.getExtension(SuggestionMenu) && props.slashMenu !== false && (\n        <SuggestionMenuController\n          triggerCharacter=\"/\"\n          shouldOpen={(state) =>\n            !state.selection.$from.parent.type.isInGroup(\"tableContent\")\n          }\n        />\n      )}\n      {editor.getExtension(SuggestionMenu) && props.emojiPicker !== false && (\n        <GridSuggestionMenuController\n          triggerCharacter=\":\"\n          columns={10}\n          minQueryLength={2}\n        />\n      )}\n      {editor.getExtension(SideMenuExtension) && props.sideMenu !== false && (\n        <SideMenuController />\n      )}\n      {editor.getExtension(FilePanelExtension) && props.filePanel !== false && (\n        <FilePanelController />\n      )}\n      {editor.getExtension(TableHandlesExtension) &&\n        props.tableHandles !== false && <TableHandlesController />}\n      {editor.getExtension(CommentsExtension) && props.comments !== false && (\n        <Suspense>\n          <FloatingComposerController />\n          <FloatingThreadController />\n        </Suspense>\n      )}\n    </>\n  );\n}\n","import type { BlockNoteEditor } from \"@blocknote/core\";\nimport { useEffect } from \"react\";\nimport { useBlockNoteContext } from \"../editor/BlockNoteContext.js\";\n\n/**\n * Subscribes to editor content changes. The callback is invoked whenever the\n * editor's document is modified, and the subscription is automatically cleaned\n * up when the component unmounts.\n *\n * @param callback - Function called when the editor content changes.\n * @param editor - The BlockNote editor instance. If omitted, uses the editor\n * from the nearest `BlockNoteContext`.\n */\nexport function useEditorChange(\n  callback: Parameters<BlockNoteEditor<any, any, any>[\"onChange\"]>[0],\n  editor?: BlockNoteEditor<any, any, any>,\n) {\n  const editorContext = useBlockNoteContext();\n  if (!editor) {\n    editor = editorContext?.editor;\n  }\n\n  useEffect(() => {\n    if (!editor) {\n      throw new Error(\n        \"'editor' is required, either from BlockNoteContext or as a function argument\",\n      );\n    }\n\n    return editor.onChange(callback);\n  }, [callback, editor]);\n}\n","import type { BlockNoteEditor } from \"@blocknote/core\";\nimport { useEffect } from \"react\";\nimport { useBlockNoteContext } from \"../editor/BlockNoteContext.js\";\n\n/**\n * Subscribes to editor selection changes. The callback is invoked whenever the\n * user's cursor position or text selection changes, and the subscription is\n * automatically cleaned up when the component unmounts.\n *\n * @param callback - Function called when the selection changes.\n * @param editor - The BlockNote editor instance. If omitted, uses the editor\n * from the nearest `BlockNoteContext`.\n * @param includeSelectionChangedByRemote - Whether to also fire the callback\n * when the selection is changed by a remote collaborator. Defaults to `false`.\n */\nexport function useEditorSelectionChange(\n  callback: () => void,\n  editor?: BlockNoteEditor<any, any, any>,\n  includeSelectionChangedByRemote?: boolean,\n) {\n  const editorContext = useBlockNoteContext();\n  if (!editor) {\n    editor = editorContext?.editor;\n  }\n\n  useEffect(() => {\n    if (!editor) {\n      throw new Error(\n        \"'editor' is required, either from BlockNoteContext or as a function argument\",\n      );\n    }\n    return editor.onSelectionChange(callback, includeSelectionChangedByRemote);\n  }, [callback, editor, includeSelectionChangedByRemote]);\n}\n","// This code is taken from the `use-prefers-color-scheme` repo:\n// https://github.com/rfoel/use-prefers-color-scheme/blob/v1.0.0/src/index.ts\n// The code is copied instead of being imported as the package seems to cause\n// issues when used in a NextJS project.\nimport { useEffect, useMemo, useState } from \"react\";\n\n/**\n * Returns the user's preferred color scheme (`\"dark\"`, `\"light\"`, or\n * `\"no-preference\"`) based on the `prefers-color-scheme` media query.\n * Automatically updates when the system preference changes.\n *\n * Adapted from the `use-prefers-color-scheme` package.\n *\n * @returns `\"dark\"`, `\"light\"`, or `\"no-preference\"`.\n */\nexport const usePrefersColorScheme = () => {\n  const darkQuery = useMemo(\n    () => window.matchMedia?.(\"(prefers-color-scheme: dark)\"),\n    [],\n  );\n  const lightQuery = useMemo(\n    () => window.matchMedia?.(\"(prefers-color-scheme: light)\"),\n    [],\n  );\n  const isDark = darkQuery?.matches;\n  const isLight = lightQuery?.matches;\n\n  const [preferredColorSchema, setPreferredColorSchema] = useState<\n    \"dark\" | \"light\" | \"no-preference\"\n  >(isDark ? \"dark\" : isLight ? \"light\" : \"no-preference\");\n\n  useEffect(() => {\n    if (isDark) {\n      setPreferredColorSchema(\"dark\");\n    } else if (isLight) {\n      setPreferredColorSchema(\"light\");\n    } else {\n      setPreferredColorSchema(\"no-preference\");\n    }\n  }, [isDark, isLight]);\n\n  useEffect(() => {\n    if (typeof darkQuery?.addEventListener === \"function\") {\n      // In modern browsers MediaQueryList should subclass EventTarget\n      // https://developer.mozilla.org/en-US/docs/Web/API/MediaQueryList\n\n      const darkListener = ({ matches }: MediaQueryListEvent) =>\n        matches && setPreferredColorSchema(\"dark\");\n      const lightListener = ({ matches }: MediaQueryListEvent) =>\n        matches && setPreferredColorSchema(\"light\");\n\n      darkQuery?.addEventListener(\"change\", darkListener);\n      lightQuery?.addEventListener(\"change\", lightListener);\n\n      return () => {\n        darkQuery?.removeEventListener(\"change\", darkListener);\n        lightQuery?.removeEventListener(\"change\", lightListener);\n      };\n    } else {\n      // In some early implementations MediaQueryList existed, but did not\n      // subclass EventTarget\n\n      // Closing over isDark here would cause it to not update when\n      // `darkQuery.matches` changes\n      const listener = () =>\n        setPreferredColorSchema(\n          darkQuery.matches\n            ? \"dark\"\n            : lightQuery.matches\n              ? \"light\"\n              : \"no-preference\",\n        );\n\n      // This is two state updates if a user changes from dark to light, but\n      // both state updates will be consistent and should be batched by React,\n      // resulting in only one re-render\n      darkQuery?.addEventListener(\"change\", listener);\n      lightQuery?.addEventListener(\"change\", listener);\n\n      return () => {\n        darkQuery?.removeEventListener(\"change\", listener);\n        lightQuery?.removeEventListener(\"change\", listener);\n      };\n    }\n  }, [darkQuery, lightQuery]);\n\n  if (typeof window.matchMedia !== \"function\") {\n    return preferredColorSchema;\n  }\n\n  return preferredColorSchema;\n};\n","import { createContext, useContext } from \"react\";\nimport { BlockNoteDefaultUIProps } from \"./BlockNoteDefaultUI.js\";\n\nexport type BlockNoteViewContextValue = {\n  editorProps: {\n    autoFocus?: boolean;\n    contentEditableProps?: Record<string, any>;\n    editable?: boolean;\n  };\n  defaultUIProps: BlockNoteDefaultUIProps;\n};\n\nexport const BlockNoteViewContext = createContext<\n  BlockNoteViewContextValue | undefined\n>(undefined);\n\nexport function useBlockNoteViewContext():\n  | BlockNoteViewContextValue\n  | undefined {\n  const context = useContext(BlockNoteViewContext) as any;\n\n  return context;\n}\n","import { ReactRenderer } from \"@tiptap/react\";\nimport { useSyncExternalStore } from \"react\";\nimport { createPortal } from \"react-dom\";\n\n// this file takes the methods we need from\n// https://github.com/ueberdosis/tiptap/blob/develop/packages/react/src/EditorContent.tsx\n\nexport function getContentComponent() {\n  const subscribers = new Set<() => void>();\n  let renderers: Record<string, React.ReactPortal> = {};\n\n  return {\n    /**\n     * Subscribe to the editor instance's changes.\n     */\n    subscribe(callback: () => void) {\n      subscribers.add(callback);\n      return () => {\n        subscribers.delete(callback);\n      };\n    },\n    getSnapshot() {\n      return renderers;\n    },\n    getServerSnapshot() {\n      return renderers;\n    },\n    /**\n     * Adds a new NodeView Renderer to the editor.\n     */\n    setRenderer(id: string, renderer: ReactRenderer) {\n      renderers = {\n        ...renderers,\n        [id]: createPortal(renderer.reactElement, renderer.element, id),\n      };\n\n      subscribers.forEach((subscriber) => subscriber());\n    },\n    /**\n     * Removes a NodeView Renderer from the editor.\n     */\n    removeRenderer(id: string) {\n      const nextRenderers = { ...renderers };\n\n      delete nextRenderers[id];\n      renderers = nextRenderers;\n      subscribers.forEach((subscriber) => subscriber());\n    },\n  };\n}\n\ntype ContentComponent = ReturnType<typeof getContentComponent>;\n\n/**\n * This component renders all of the editor's node views.\n */\nexport const Portals: React.FC<{ contentComponent: ContentComponent }> = ({\n  contentComponent,\n}) => {\n  // For performance reasons, we render the node view portals on state changes only\n  const renderers = useSyncExternalStore(\n    contentComponent.subscribe,\n    contentComponent.getSnapshot,\n    contentComponent.getServerSnapshot,\n  );\n\n  // This allows us to directly render the portals without any additional wrapper\n  return <>{Object.values(renderers)}</>;\n};\n","import { forwardRef, useImperativeHandle, useState } from \"react\";\nimport { createPortal, flushSync } from \"react-dom\";\n\n/**\n * A helper component to render a single element to a container so we can subsequently read the DOM / HTML contents\n *\n * This is useful so we can render arbitrary React elements (blocks) in the correct context (used by `ReactRenderUtil`)\n */\nexport const ElementRenderer = forwardRef<\n  (node: React.ReactNode, container: HTMLElement) => void\n>((_props, ref) => {\n  const [singleRenderData, setSingleRenderData] = useState<\n    { node: React.ReactNode; container: HTMLElement } | undefined\n  >();\n\n  useImperativeHandle(ref, () => {\n    return (node: React.ReactNode, container: HTMLElement) => {\n      flushSync(() => {\n        setSingleRenderData({ node, container });\n      });\n\n      // clear after it's been rendered to `container`\n      setSingleRenderData(undefined);\n    };\n  }, []);\n\n  return (\n    <>\n      {singleRenderData &&\n        createPortal(singleRenderData.node, singleRenderData.container)}\n    </>\n  );\n});\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n  mergeCSSClasses,\n} from \"@blocknote/core\";\nimport React, {\n  HTMLAttributes,\n  ReactNode,\n  Ref,\n  useCallback,\n  useEffect,\n  useMemo,\n  useState,\n} from \"react\";\nimport { useBlockNoteEditor } from \"../hooks/useBlockNoteEditor.js\";\nimport { useEditorChange } from \"../hooks/useEditorChange.js\";\nimport { useEditorSelectionChange } from \"../hooks/useEditorSelectionChange.js\";\nimport { usePrefersColorScheme } from \"../hooks/usePrefersColorScheme.js\";\nimport {\n  BlockNoteContext,\n  BlockNoteContextValue,\n  useBlockNoteContext,\n} from \"./BlockNoteContext.js\";\nimport {\n  BlockNoteDefaultUI,\n  BlockNoteDefaultUIProps,\n} from \"./BlockNoteDefaultUI.js\";\nimport {\n  BlockNoteViewContext,\n  useBlockNoteViewContext,\n} from \"./BlockNoteViewContext.js\";\nimport { useComponentsContext } from \"./ComponentsContext.js\";\nimport { Portals, getContentComponent } from \"./EditorContent.js\";\nimport { ElementRenderer } from \"./ElementRenderer.js\";\n\nimport \"./styles.css\";\n\nconst emptyFn = () => {\n  // noop\n};\n\nexport type BlockNoteViewProps<\n  BSchema extends BlockSchema,\n  ISchema extends InlineContentSchema,\n  SSchema extends StyleSchema,\n> = {\n  /**\n   * The {@link BlockNoteEditor} instance to render.\n   * @remarks `BlockNoteEditor`\n   */\n  editor: BlockNoteEditor<BSchema, ISchema, SSchema>;\n\n  /**\n   * Forces the editor to use the light or dark theme. See [Themes](https://www.blocknotejs.org/docs/react/styling-theming/themes) for additional customization when using Mantine.\n   */\n  theme?: \"light\" | \"dark\";\n\n  /**\n   * Locks the editor from being editable by the user if set to `false`.\n   *\n   * @default true\n   */\n  editable?: boolean;\n  /**\n   * A callback function that runs whenever the text cursor position or selection changes.\n   */\n  onSelectionChange?: () => void;\n\n  /**\n   * A callback function that runs whenever the editor's contents change.\n   * Same as {@link BlockNoteEditor.onChange}.\n   * @remarks `(editor: BlockNoteEditor) => void`\n   */\n  onChange?: Parameters<\n    BlockNoteEditor<BSchema, ISchema, SSchema>[\"onChange\"]\n  >[0];\n\n  /**\n   * Whether to render the editor element itself.\n   * When `false`, you're responsible for rendering the editor yourself using the {@link BlockNoteViewEditor} component.\n   *\n   * @default true\n   */\n  renderEditor?: boolean;\n\n  /**\n   * Pass child elements to the {@link BlockNoteView} to create or customize toolbars, menus, or other UI components. See [UI Components](https://www.blocknotejs.org/docs/ui-components) for more.\n   */\n  children?: ReactNode;\n\n  ref?: Ref<HTMLDivElement> | undefined; // only here to get types working with the generics. Regular form doesn't work\n} & BlockNoteDefaultUIProps;\n\nfunction BlockNoteViewComponent<\n  BSchema extends BlockSchema,\n  ISchema extends InlineContentSchema,\n  SSchema extends StyleSchema,\n>(\n  props: BlockNoteViewProps<BSchema, ISchema, SSchema> &\n    Omit<\n      HTMLAttributes<HTMLDivElement>,\n      \"onChange\" | \"onSelectionChange\" | \"children\"\n    >,\n  ref: React.Ref<HTMLDivElement>,\n) {\n  const {\n    editor,\n    className,\n    theme,\n    children,\n    editable,\n    onSelectionChange,\n    onChange,\n    formattingToolbar,\n    linkToolbar,\n    slashMenu,\n    emojiPicker,\n    sideMenu,\n    filePanel,\n    tableHandles,\n    comments,\n    autoFocus,\n    renderEditor = true,\n    ...rest\n  } = props;\n\n  // Used so other components (suggestion menu) can set\n  // aria related props to the contenteditable div\n  const [contentEditableProps, setContentEditableProps] =\n    useState<Record<string, any>>();\n\n  const existingContext = useBlockNoteContext();\n  const systemColorScheme = usePrefersColorScheme();\n  const defaultColorScheme =\n    existingContext?.colorSchemePreference || systemColorScheme;\n\n  const editorColorScheme =\n    theme || (defaultColorScheme === \"dark\" ? \"dark\" : \"light\");\n\n  // Disable default UI components if no components context is found.\n  const componentsContext = useComponentsContext();\n  const defaultUIProps: BlockNoteDefaultUIProps = useMemo(\n    () => ({\n      formattingToolbar: componentsContext ? formattingToolbar : false,\n      linkToolbar: componentsContext ? linkToolbar : false,\n      sideMenu: componentsContext ? sideMenu : false,\n      slashMenu: componentsContext ? slashMenu : false,\n      filePanel: componentsContext ? filePanel : false,\n      tableHandles: componentsContext ? tableHandles : false,\n      emojiPicker: componentsContext ? emojiPicker : false,\n      comments: componentsContext ? comments : false,\n    }),\n    [\n      comments,\n      componentsContext,\n      emojiPicker,\n      filePanel,\n      formattingToolbar,\n      linkToolbar,\n      sideMenu,\n      slashMenu,\n      tableHandles,\n    ],\n  );\n\n  useEditorChange(onChange || emptyFn, editor);\n  useEditorSelectionChange(onSelectionChange || emptyFn, editor);\n\n  const setElementRenderer = useCallback(\n    (ref: (typeof editor)[\"elementRenderer\"]) => {\n      editor.elementRenderer = ref;\n    },\n    [editor],\n  );\n\n  useEffect(() => {\n    if (!editor.portalElement) {\n      throw new Error(\"Portal element not found\");\n    }\n    editor.portalElement.className = mergeCSSClasses(\n      \"bn-root\",\n      editorColorScheme,\n      className || \"\",\n    );\n    editor.portalElement.setAttribute(\"data-color-scheme\", editorColorScheme);\n  }, [editor, editorColorScheme, className]);\n\n  // The BlockNoteContext makes sure the editor and some helper methods\n  // are always available to nesteed compoenents\n  const blockNoteContext: BlockNoteContextValue<any, any, any> = useMemo(() => {\n    return {\n      ...existingContext,\n      editor,\n      setContentEditableProps,\n      colorSchemePreference: editorColorScheme,\n    };\n  }, [existingContext, editor, editorColorScheme]);\n\n  // We set defaultUIProps and editorProps on a different context, the BlockNoteViewContext.\n  // This BlockNoteViewContext is used to render the editor and the default UI.\n  const blockNoteViewContextValue = useMemo(() => {\n    return {\n      editorProps: {\n        autoFocus,\n        contentEditableProps,\n        editable,\n      },\n      defaultUIProps,\n    };\n  }, [autoFocus, contentEditableProps, editable, defaultUIProps]);\n\n  return (\n    <BlockNoteContext.Provider value={blockNoteContext}>\n      <BlockNoteViewContext.Provider value={blockNoteViewContextValue}>\n        <ElementRenderer ref={setElementRenderer} />\n        <BlockNoteViewContainer\n          className={className}\n          renderEditor={renderEditor}\n          editorColorScheme={editorColorScheme}\n          ref={ref}\n          {...rest}\n        >\n          {children}\n        </BlockNoteViewContainer>\n      </BlockNoteViewContext.Provider>\n    </BlockNoteContext.Provider>\n  );\n}\n\n/**\n * Renders the div that wraps the editor and all default UI elements\n * (.bn-container element).\n */\nconst BlockNoteViewContainer = React.forwardRef<\n  HTMLDivElement,\n  {\n    renderEditor: boolean;\n    editorColorScheme: \"light\" | \"dark\";\n    children: ReactNode;\n  } & Omit<\n    HTMLAttributes<HTMLDivElement>,\n    \"onChange\" | \"onSelectionChange\" | \"children\"\n  >\n>(({ className, renderEditor, editorColorScheme, children, ...rest }, ref) => (\n  <div\n    className={mergeCSSClasses(\n      \"bn-root\",\n      \"bn-container\",\n      editorColorScheme,\n      className,\n    )}\n    data-color-scheme={editorColorScheme}\n    {...rest}\n    ref={ref}\n  >\n    {renderEditor ? (\n      <BlockNoteViewEditor>{children}</BlockNoteViewEditor>\n    ) : (\n      children\n    )}\n  </div>\n));\n\n// https://fettblog.eu/typescript-react-generic-forward-refs/\nexport const BlockNoteViewRaw = React.forwardRef(BlockNoteViewComponent) as <\n  BSchema extends BlockSchema,\n  ISchema extends InlineContentSchema,\n  SSchema extends StyleSchema,\n>(\n  props: BlockNoteViewProps<BSchema, ISchema, SSchema> & {\n    ref?: React.ForwardedRef<HTMLDivElement>;\n  } & Omit<\n      HTMLAttributes<HTMLDivElement>,\n      \"onChange\" | \"onSelectionChange\" | \"children\"\n    >,\n) => ReturnType<typeof BlockNoteViewComponent<BSchema, ISchema, SSchema>>;\n\n/**\n * Renders the contentEditable editor itself (.bn-editor element) and the\n * default UI elements.\n */\nexport const BlockNoteViewEditor = (props: { children?: ReactNode }) => {\n  const ctx = useBlockNoteViewContext()!;\n  const editor = useBlockNoteEditor();\n\n  const portalManager = useMemo(() => {\n    return getContentComponent();\n  }, []);\n\n  const mount = useCallback(\n    (element: HTMLElement | null) => {\n      // Set editable state of the actual editor.\n      // We need to re-mount the editor when changing `isEditable` as TipTap\n      // removes the `tabIndex=\"0\"` attribute we set (see\n      // `BlockNoteEditor.ts`). Ideally though, this logic would exist in a\n      // separate hook.\n      editor.isEditable = ctx.editorProps.editable !== false;\n      // Since we are not using TipTap's React Components, we need to set up the contentComponent it expects\n      // This is a simple replacement for the state management that Tiptap does internally\n      editor._tiptapEditor.contentComponent = portalManager;\n      if (element) {\n        editor.mount(element);\n      } else {\n        editor.unmount();\n      }\n    },\n    [ctx.editorProps.editable, editor, portalManager],\n  );\n\n  return (\n    <>\n      <Portals contentComponent={portalManager} />\n      <ContentEditableElement {...ctx.editorProps} {...props} mount={mount} />\n      {/* Renders the UI elements such as formatting toolbar, etc, unless they have been explicitly disabled  in defaultUIProps */}\n      <BlockNoteDefaultUI {...ctx.defaultUIProps} />\n      {/* Manually passed in children, such as customized UI elements / controllers */}\n      {props.children}\n    </>\n  );\n};\n\n/**\n * Renders the contentEditable editor itself (.bn-editor element).\n */\nconst ContentEditableElement = (props: {\n  autoFocus?: boolean;\n  mount: (element: HTMLElement | null) => void;\n  contentEditableProps?: Record<string, any>;\n}) => {\n  const { autoFocus, mount, contentEditableProps } = props;\n  return (\n    <div\n      aria-autocomplete=\"list\"\n      aria-haspopup=\"listbox\"\n      data-bn-autofocus={autoFocus}\n      ref={mount}\n      {...contentEditableProps}\n    />\n  );\n};\n","import { BlockNoteEditor } from \"@blocknote/core\";\nimport { flushSync } from \"react-dom\";\nimport { Root, createRoot } from \"react-dom/client\";\n\nexport function renderToDOMSpec(\n  fc: (refCB: (ref: HTMLElement | null) => void) => React.ReactNode,\n  editor: BlockNoteEditor<any, any, any> | undefined,\n) {\n  let contentDOM: HTMLElement | undefined;\n  const div = document.createElement(\"div\");\n\n  let root: Root | undefined;\n\n  if (editor?.elementRenderer) {\n    // Render temporarily using `ElementRenderer`\n    // This way React Context will still work, as `fc` will be rendered inside the existing React tree\n    editor.elementRenderer(\n      fc((el) => (contentDOM = el || undefined)),\n      div,\n    );\n  } else {\n    // If no editor is provided, use a temporary root.\n    // This is currently only used for when we use ServerBlockNoteEditor (@blocknote/server-util)\n    // and without using `withReactContext`\n\n    if (!editor?.headless) {\n      throw new Error(\n        \"elementRenderer not available, expected headless editor\",\n      );\n    }\n    root = createRoot(div);\n\n    flushSync(() => {\n      root!.render(fc((el) => (contentDOM = el || undefined)));\n    });\n  }\n\n  if (!div.childElementCount) {\n    // TODO\n    // eslint-disable-next-line no-console\n    console.warn(\"ReactInlineContentSpec: renderHTML() failed\");\n    return {\n      dom: document.createElement(\"span\"),\n    };\n  }\n\n  // clone so we can unmount the react root\n  contentDOM?.setAttribute(\"data-tmp-find\", \"true\");\n  const cloneRoot = div.cloneNode(true) as HTMLElement;\n  const dom = cloneRoot.firstElementChild! as HTMLElement;\n  const contentDOMClone = cloneRoot.querySelector(\n    \"[data-tmp-find]\",\n  ) as HTMLElement | null;\n  contentDOMClone?.removeAttribute(\"data-tmp-find\");\n\n  root?.unmount();\n\n  return {\n    dom,\n    contentDOM: contentDOMClone || undefined,\n  };\n}\n","import {\n  BlockConfig,\n  BlockConfigOrCreator,\n  BlockImplementation,\n  BlockNoDefaults,\n  BlockNoteEditor,\n  BlockSpec,\n  camelToDataKebab,\n  CustomBlockImplementation,\n  Extension,\n  ExtensionFactoryInstance,\n  ExtractBlockConfigFromConfigOrCreator,\n  getBlockFromPos,\n  mergeCSSClasses,\n  Props,\n  PropSchema,\n} from \"@blocknote/core\";\nimport {\n  NodeViewProps,\n  NodeViewWrapper,\n  ReactNodeViewRenderer,\n  useReactNodeView,\n} from \"@tiptap/react\";\nimport { FC, ReactNode } from \"react\";\nimport { renderToDOMSpec } from \"./@util/ReactRenderUtil.js\";\n\n// this file is mostly analogoues to `customBlocks.ts`, but for React blocks\n\nexport type ReactCustomBlockRenderProps<\n  B extends BlockConfigOrCreator,\n  Config extends\n    ExtractBlockConfigFromConfigOrCreator<B> = ExtractBlockConfigFromConfigOrCreator<B>,\n> = {\n  block: BlockNoDefaults<Record<Config[\"type\"], Config>, any, any>;\n  editor: BlockNoteEditor<Record<Config[\"type\"], Config>, any, any>;\n} & (Config[\"content\"] extends \"inline\"\n  ? {\n      contentRef: (node: HTMLElement | null) => void;\n    }\n  : object);\n\n// extend BlockConfig but use a React render function\nexport type ReactCustomBlockImplementation<\n  B extends BlockConfigOrCreator = BlockConfigOrCreator,\n  Config extends\n    ExtractBlockConfigFromConfigOrCreator<B> = ExtractBlockConfigFromConfigOrCreator<B>,\n> = Omit<\n  CustomBlockImplementation<\n    Config[\"type\"],\n    Config[\"propSchema\"],\n    Config[\"content\"]\n  >,\n  \"render\" | \"toExternalHTML\"\n> & {\n  render: FC<ReactCustomBlockRenderProps<B>>;\n  toExternalHTML?: FC<\n    ReactCustomBlockRenderProps<B> & {\n      context: {\n        nestingLevel: number;\n      };\n    }\n  >;\n};\n\nexport type ReactCustomBlockSpec<\n  B extends BlockConfig<string, PropSchema, \"inline\" | \"none\"> = BlockConfig<\n    string,\n    PropSchema,\n    \"inline\" | \"none\"\n  >,\n> = {\n  config: B;\n  implementation: ReactCustomBlockImplementation<B>;\n  extensions?: Extension<any>[];\n};\n\n// Function that wraps the React component returned from 'blockConfig.render' in\n// a `NodeViewWrapper` which also acts as a `blockContent` div. It contains the\n// block type and props as HTML attributes.\nexport function BlockContentWrapper<\n  BType extends string,\n  PSchema extends PropSchema,\n>(props: {\n  blockType: BType;\n  blockProps: Props<PSchema>;\n  propSchema: PSchema;\n  isFileBlock?: boolean;\n  domAttributes?: Record<string, string>;\n  children: ReactNode;\n}) {\n  return (\n    // Creates `blockContent` element\n    <NodeViewWrapper\n      onDragOver={(event: DragEvent) => event.preventDefault()}\n      // Adds custom HTML attributes\n      {...Object.fromEntries(\n        Object.entries(props.domAttributes || {}).filter(\n          ([key]) => key !== \"class\",\n        ),\n      )}\n      // Sets blockContent class\n      className={mergeCSSClasses(\n        \"bn-block-content\",\n        props.domAttributes?.class || \"\",\n      )}\n      // Sets content type attribute\n      data-content-type={props.blockType}\n      // Adds props as HTML attributes in kebab-case with \"data-\" prefix. Skips\n      // props which are already added as HTML attributes to the parent\n      // `blockContent` element (inheritedProps) and props set to their default\n      // values\n      {...Object.fromEntries(\n        Object.entries(props.blockProps)\n          .filter(([prop, value]) => {\n            const spec = props.propSchema[prop];\n            return value !== spec.default;\n          })\n          .map(([prop, value]) => {\n            return [camelToDataKebab(prop), value];\n          }),\n      )}\n      data-file-block={props.isFileBlock === true || undefined}\n    >\n      {props.children}\n    </NodeViewWrapper>\n  );\n}\n\n/**\n * Helper function to create a React block definition.\n * Can accept either functions that return the required objects, or the objects directly.\n */\nexport function createReactBlockSpec<\n  const TName extends string,\n  const TProps extends PropSchema,\n  const TContent extends \"inline\" | \"none\",\n  const TOptions extends Record<string, any> | undefined = undefined,\n>(\n  blockConfigOrCreator: BlockConfig<TName, TProps, TContent>,\n  blockImplementationOrCreator:\n    | ReactCustomBlockImplementation<BlockConfig<TName, TProps, TContent>>\n    | (TOptions extends undefined\n        ? () => ReactCustomBlockImplementation<\n            BlockConfig<TName, TProps, TContent>\n          >\n        : (\n            options: Partial<TOptions>,\n          ) => ReactCustomBlockImplementation<\n            BlockConfig<TName, TProps, TContent>\n          >),\n  extensionsOrCreator?:\n    | (ExtensionFactoryInstance | Extension)[]\n    | (TOptions extends undefined\n        ? () => (ExtensionFactoryInstance | Extension)[]\n        : (\n            options: Partial<TOptions>,\n          ) => (ExtensionFactoryInstance | Extension)[]),\n): (options?: Partial<TOptions>) => BlockSpec<TName, TProps, TContent>;\nexport function createReactBlockSpec<\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    | ReactCustomBlockImplementation<BlockConf>\n    | (TOptions extends undefined\n        ? () => ReactCustomBlockImplementation<BlockConf>\n        : (\n            options: Partial<TOptions>,\n          ) => ReactCustomBlockImplementation<BlockConf>),\n  extensionsOrCreator?:\n    | (ExtensionFactoryInstance | Extension)[]\n    | (TOptions extends undefined\n        ? () => (ExtensionFactoryInstance | Extension)[]\n        : (\n            options: Partial<TOptions>,\n          ) => (ExtensionFactoryInstance | Extension)[]),\n): (\n  options?: Partial<TOptions>,\n) => BlockSpec<\n  BlockConf[\"type\"],\n  BlockConf[\"propSchema\"],\n  BlockConf[\"content\"]\n>;\nexport function createReactBlockSpec<\n  const TName extends string,\n  const TProps extends PropSchema,\n  const TContent extends \"inline\" | \"none\",\n  const TOptions extends Record<string, any> | undefined = undefined,\n>(\n  blockConfigOrCreator: BlockConfigOrCreator<TName, TProps, TContent, TOptions>,\n  blockImplementationOrCreator:\n    | ReactCustomBlockImplementation<BlockConfig<TName, TProps, TContent>>\n    | (TOptions extends undefined\n        ? () => ReactCustomBlockImplementation<\n            BlockConfig<TName, TProps, TContent>\n          >\n        : (\n            options: Partial<TOptions>,\n          ) => ReactCustomBlockImplementation<\n            BlockConfig<TName, TProps, TContent>\n          >),\n  extensionsOrCreator?:\n    | (ExtensionFactoryInstance | Extension)[]\n    | (TOptions extends undefined\n        ? () => (ExtensionFactoryInstance | Extension)[]\n        : (\n            options: Partial<TOptions>,\n          ) => (ExtensionFactoryInstance | Extension)[]),\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        toExternalHTML(block, editor, context) {\n          const BlockContent =\n            blockImplementation.toExternalHTML || blockImplementation.render;\n          const output = renderToDOMSpec((refCB) => {\n            return (\n              <BlockContentWrapper\n                blockType={block.type}\n                blockProps={block.props}\n                propSchema={blockConfig.propSchema}\n                domAttributes={this.blockContentDOMAttributes}\n                isFileBlock={\n                  blockImplementation.meta?.fileBlockAccept !== undefined\n                }\n              >\n                <BlockContent\n                  block={block as any}\n                  editor={editor as any}\n                  contentRef={(element) => {\n                    refCB(element);\n                    if (element) {\n                      element.className = mergeCSSClasses(\n                        \"bn-inline-content\",\n                        element.className,\n                      );\n                    }\n                  }}\n                  context={context}\n                />\n              </BlockContentWrapper>\n            );\n          }, editor);\n          return output;\n        },\n        render(block, editor) {\n          if (this.renderType === \"nodeView\") {\n            return ReactNodeViewRenderer(\n              (props: NodeViewProps) => {\n                // Vanilla JS node views are recreated on each update. However,\n                // using `ReactNodeViewRenderer` makes it so the node view is\n                // only created once, so the block we get in the node view will\n                // be outdated. Therefore, we have to get the block in the\n                // `ReactNodeViewRenderer` instead.\n                const block = getBlockFromPos(\n                  props.getPos,\n                  editor,\n                  props.editor,\n                  blockConfig.type,\n                );\n\n                const ref = useReactNodeView().nodeViewContentRef;\n\n                if (!ref) {\n                  throw new Error(\"nodeViewContentRef is not set\");\n                }\n\n                const BlockContent = blockImplementation.render;\n                return (\n                  <BlockContentWrapper\n                    blockType={block.type}\n                    blockProps={block.props}\n                    propSchema={blockConfig.propSchema}\n                    isFileBlock={!!blockImplementation.meta?.fileBlockAccept}\n                    domAttributes={this.blockContentDOMAttributes}\n                  >\n                    <BlockContent\n                      block={block as any}\n                      editor={editor as any}\n                      contentRef={(element) => {\n                        ref(element);\n                        if (element) {\n                          element.className = mergeCSSClasses(\n                            \"bn-inline-content\",\n                            element.className,\n                          );\n                          element.dataset.nodeViewContent = \"\";\n                        }\n                      }}\n                    />\n                  </BlockContentWrapper>\n                );\n              },\n              {\n                className: \"bn-react-node-view-renderer\",\n              },\n            )(this.props!) as ReturnType<BlockImplementation[\"render\"]>;\n          } else {\n            const BlockContent = blockImplementation.render;\n            const output = renderToDOMSpec((refCB) => {\n              return (\n                <BlockContentWrapper\n                  blockType={block.type}\n                  blockProps={block.props}\n                  propSchema={blockConfig.propSchema}\n                  domAttributes={this.blockContentDOMAttributes}\n                >\n                  <BlockContent\n                    block={block as any}\n                    editor={editor as any}\n                    contentRef={(element) => {\n                      refCB(element);\n                      if (element) {\n                        element.className = mergeCSSClasses(\n                          \"bn-inline-content\",\n                          element.className,\n                        );\n                      }\n                    }}\n                  />\n                </BlockContentWrapper>\n              );\n            }, editor);\n            return output;\n          }\n        },\n      },\n      extensions: extensions,\n    };\n  };\n}\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport { useEffect, useState } from \"react\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\n\nexport function useResolveUrl(fetchUrl: string) {\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const [loadingState, setLoadingState] = useState<\n    \"loading\" | \"loaded\" | \"error\"\n  >(\"loading\");\n  const [downloadUrl, setDownloadUrl] = useState<string | undefined>();\n\n  useEffect(() => {\n    let mounted = true;\n    (async () => {\n      let url = \"\";\n      setLoadingState(\"loading\");\n\n      try {\n        url = editor.resolveFileUrl\n          ? await editor.resolveFileUrl(fetchUrl)\n          : fetchUrl;\n      } catch (error) {\n        setLoadingState(\"error\");\n        return;\n      }\n\n      if (mounted) {\n        setLoadingState(\"loaded\");\n        setDownloadUrl(url);\n      }\n    })();\n\n    return () => {\n      mounted = false;\n    };\n  }, [editor, fetchUrl]);\n\n  if (loadingState !== \"loaded\") {\n    return {\n      loadingState,\n    };\n  }\n\n  if (!downloadUrl) {\n    throw new Error(\"Finished fetching file but did not get download URL.\");\n  }\n\n  return {\n    loadingState,\n    downloadUrl,\n  };\n}\n","import { ReactNode } from \"react\";\n\nexport const FigureWithCaption = (props: {\n  caption: string;\n  children: ReactNode;\n}) => (\n  <figure>\n    {props.children}\n    <figcaption>{props.caption}</figcaption>\n  </figure>\n);\n","import { useEffect } from \"react\";\nimport { useBlockNoteEditor } from \"./useBlockNoteEditor.js\";\n\n/**\n * Subscribes to file upload completion events. The callback is invoked whenever\n * a file upload finishes within the editor, and the subscription is\n * automatically cleaned up when the component unmounts.\n *\n * @param callback - Function called when an upload completes. Receives the\n * `blockId` of the block whose upload finished, if available.\n */\nexport function useOnUploadEnd(callback: (blockId?: string) => void) {\n  const editor = useBlockNoteEditor();\n\n  useEffect(() => {\n    return editor.onUploadEnd(callback);\n  }, [callback, editor]);\n}\n","import { useEffect } from \"react\";\nimport { useBlockNoteEditor } from \"./useBlockNoteEditor.js\";\n\n/**\n * Subscribes to file upload start events. The callback is invoked whenever a\n * file upload begins within the editor, and the subscription is automatically\n * cleaned up when the component unmounts.\n *\n * @param callback - Function called when an upload starts. Receives the\n * `blockId` of the block where the upload was initiated, if available.\n */\nexport function useOnUploadStart(callback: (blockId?: string) => void) {\n  const editor = useBlockNoteEditor();\n\n  useEffect(() => {\n    return editor.onUploadStart(callback);\n  }, [callback, editor]);\n}\n","import { useState } from \"react\";\nimport { useOnUploadEnd } from \"./useOnUploadEnd.js\";\nimport { useOnUploadStart } from \"./useOnUploadStart.js\";\n\n/**\n * Tracks whether a file upload is in progress for a specific block. Returns\n * `true` while the upload is active and `false` otherwise.\n *\n * @param blockId - The ID of the block to monitor for upload activity.\n * @returns `true` if a file upload is currently in progress for the given block.\n */\nexport function useUploadLoading(blockId?: string) {\n  const [showLoader, setShowLoader] = useState(false);\n\n  useOnUploadStart((uploadBlockId) => {\n    if (uploadBlockId === blockId) {\n      setShowLoader(true);\n    }\n  });\n\n  useOnUploadEnd((uploadBlockId) => {\n    if (uploadBlockId === blockId) {\n      setShowLoader(false);\n    }\n  });\n\n  return showLoader;\n}\n","import { FileBlockConfig } from \"@blocknote/core\";\nimport { FilePanelExtension } from \"@blocknote/core/extensions\";\nimport { ReactNode, useCallback } from \"react\";\nimport { RiFile2Line } from \"react-icons/ri\";\n\nimport { useBlockNoteEditor } from \"../../../../hooks/useBlockNoteEditor.js\";\nimport { useExtension } from \"../../../../hooks/useExtension.js\";\nimport { useDictionary } from \"../../../../i18n/dictionary.js\";\nimport { ReactCustomBlockRenderProps } from \"../../../../schema/ReactBlockSpec.js\";\n\nexport const AddFileButton = (\n  props: Omit<ReactCustomBlockRenderProps<FileBlockConfig>, \"contentRef\"> & {\n    buttonIcon?: ReactNode;\n  },\n) => {\n  const editor = useBlockNoteEditor<any, any, any>();\n  const dict = useDictionary();\n\n  const filePanel = useExtension(FilePanelExtension);\n\n  // Prevents focus from moving to the button.\n  const addFileButtonMouseDownHandler = useCallback(\n    (event: React.MouseEvent) => {\n      event.preventDefault();\n    },\n    [],\n  );\n  // Opens the file toolbar.\n  const addFileButtonClickHandler = useCallback(() => {\n    if (!editor.isEditable) {\n      return;\n    }\n\n    props.editor.transact(() => filePanel.showMenu(props.block.id));\n  }, [editor.isEditable, filePanel, props.block.id, props.editor]);\n\n  return (\n    <div\n      className={\"bn-add-file-button\"}\n      onMouseDown={addFileButtonMouseDownHandler}\n      onClick={addFileButtonClickHandler}\n    >\n      <div className={\"bn-add-file-button-icon\"}>\n        {props.buttonIcon || <RiFile2Line size={24} />}\n      </div>\n      <div className={\"bn-add-file-button-text\"}>\n        {props.block.type in dict.file_blocks.add_button_text\n          ? dict.file_blocks.add_button_text[props.block.type]\n          : dict.file_blocks.add_button_text[\"file\"]}\n      </div>\n    </div>\n  );\n};\n","import { FileBlockConfig } from \"@blocknote/core\";\nimport { RiFile2Line } from \"react-icons/ri\";\n\nimport { ReactCustomBlockRenderProps } from \"../../../../schema/ReactBlockSpec.js\";\n\nexport const FileNameWithIcon = (\n  props: Omit<\n    ReactCustomBlockRenderProps<FileBlockConfig>,\n    \"editor\" | \"contentRef\"\n  >,\n) => (\n  <div\n    className={\"bn-file-name-with-icon\"}\n    contentEditable={false}\n    draggable={false}\n  >\n    <div className={\"bn-file-icon\"}>\n      <RiFile2Line size={24} />\n    </div>\n    <p className={\"bn-file-name\"}>{props.block.props.name}</p>\n  </div>\n);\n","import { BlockConfig, FileBlockConfig } from \"@blocknote/core\";\nimport { CSSProperties, ReactNode } from \"react\";\n\nimport { useUploadLoading } from \"../../../../hooks/useUploadLoading.js\";\nimport { ReactCustomBlockRenderProps } from \"../../../../schema/ReactBlockSpec.js\";\nimport { AddFileButton } from \"./AddFileButton.js\";\nimport { FileNameWithIcon } from \"./FileNameWithIcon.js\";\n\nexport const FileBlockWrapper = (\n  props: Omit<\n    ReactCustomBlockRenderProps<\n      BlockConfig<\n        FileBlockConfig[\"type\"],\n        FileBlockConfig[\"propSchema\"] & { showPreview?: { default: true } },\n        FileBlockConfig[\"content\"]\n      >\n    >,\n    \"contentRef\"\n  > & {\n    buttonIcon?: ReactNode;\n    children?: ReactNode;\n  } & {\n    // These props & the `forwardRef` are just here so we can reuse this\n    // component in `ResizableFileBlockWrapper`.\n    onMouseEnter?: () => void;\n    onMouseLeave?: () => void;\n    style?: CSSProperties;\n  },\n) => {\n  const showLoader = useUploadLoading(props.block.id);\n\n  return (\n    <div\n      className={\"bn-file-block-content-wrapper\"}\n      onMouseEnter={props.onMouseEnter}\n      onMouseLeave={props.onMouseLeave}\n      style={props.style}\n    >\n      {showLoader ? (\n        // Show loader while a file is being uploaded.\n        <div className={\"bn-file-loading-preview\"}>Loading...</div>\n      ) : props.block.props.url === \"\" ? (\n        // Show the add file button if the file has not been uploaded yet.\n        <AddFileButton {...props} />\n      ) : (\n        // Show the file preview, or the file name and icon.\n        <>\n          {props.block.props.showPreview === false || !props.children ? (\n            // Show file name and icon.\n            <FileNameWithIcon {...props} />\n          ) : (\n            // Show preview.\n            props.children\n          )}\n          {props.block.props.caption && (\n            // Show the caption if there is one.\n            <p className={\"bn-file-caption\"}>{props.block.props.caption}</p>\n          )}\n        </>\n      )}\n    </div>\n  );\n};\n","import { ReactNode } from \"react\";\n\nexport const LinkWithCaption = (props: {\n  caption: string;\n  children: ReactNode;\n}) => (\n  <div>\n    {props.children}\n    <p>{props.caption}</p>\n  </div>\n);\n","import { createAudioBlockConfig, audioParse } from \"@blocknote/core\";\n\nimport { RiVolumeUpFill } from \"react-icons/ri\";\n\nimport {\n  ReactCustomBlockRenderProps,\n  createReactBlockSpec,\n} from \"../../schema/ReactBlockSpec.js\";\nimport { useResolveUrl } from \"../File/useResolveUrl.js\";\nimport { FigureWithCaption } from \"../File/helpers/toExternalHTML/FigureWithCaption.js\";\nimport { FileBlockWrapper } from \"../File/helpers/render/FileBlockWrapper.js\";\nimport { LinkWithCaption } from \"../File/helpers/toExternalHTML/LinkWithCaption.js\";\n\nexport const AudioPreview = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createAudioBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  const resolved = useResolveUrl(props.block.props.url!);\n\n  return (\n    <audio\n      className={\"bn-audio\"}\n      src={\n        resolved.loadingState === \"loading\"\n          ? props.block.props.url\n          : resolved.downloadUrl\n      }\n      controls={true}\n      contentEditable={false}\n      draggable={false}\n    />\n  );\n};\n\nexport const AudioToExternalHTML = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createAudioBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  if (!props.block.props.url) {\n    return <p>Add audio</p>;\n  }\n\n  const audio = props.block.props.showPreview ? (\n    <audio src={props.block.props.url} />\n  ) : (\n    <a href={props.block.props.url}>\n      {props.block.props.name || props.block.props.url}\n    </a>\n  );\n\n  if (props.block.props.caption) {\n    return props.block.props.showPreview ? (\n      <FigureWithCaption caption={props.block.props.caption}>\n        {audio}\n      </FigureWithCaption>\n    ) : (\n      <LinkWithCaption caption={props.block.props.caption}>\n        {audio}\n      </LinkWithCaption>\n    );\n  }\n\n  return audio;\n};\n\nexport const AudioBlock = (\n  props: ReactCustomBlockRenderProps<typeof createAudioBlockConfig>,\n) => {\n  return (\n    <FileBlockWrapper\n      {...(props as any)}\n      buttonIcon={<RiVolumeUpFill size={24} />}\n    >\n      <AudioPreview {...(props as any)} />\n    </FileBlockWrapper>\n  );\n};\n\nexport const ReactAudioBlock = createReactBlockSpec(\n  createAudioBlockConfig,\n  (config) => ({\n    meta: {\n      fileBlockAccept: [\"audio/*\"],\n    },\n    render: AudioBlock,\n    parse: audioParse(config),\n    toExternalHTML: AudioToExternalHTML,\n    runsBefore: [\"file\"],\n  }),\n);\n","import { createFileBlockConfig, fileParse } from \"@blocknote/core\";\n\nimport { createReactBlockSpec } from \"../../schema/ReactBlockSpec.js\";\nimport { FileBlockWrapper } from \"./helpers/render/FileBlockWrapper.js\";\nimport { LinkWithCaption } from \"./helpers/toExternalHTML/LinkWithCaption.js\";\n\nexport const ReactFileBlock = createReactBlockSpec(createFileBlockConfig, {\n  render: (props) => <FileBlockWrapper {...props} />,\n  parse: fileParse(),\n  toExternalHTML: (props) => {\n    if (!props.block.props.url) {\n      return <p>Add file</p>;\n    }\n\n    const link = (\n      <a href={props.block.props.url}>\n        {props.block.props.name || props.block.props.url}\n      </a>\n    );\n\n    if (props.block.props.caption) {\n      return (\n        <LinkWithCaption caption={props.block.props.caption}>\n          {link}\n        </LinkWithCaption>\n      );\n    }\n\n    return link;\n  },\n});\n","import { BlockConfig, FileBlockConfig } from \"@blocknote/core\";\nimport { ReactNode, useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useUploadLoading } from \"../../../../hooks/useUploadLoading.js\";\nimport { ReactCustomBlockRenderProps } from \"../../../../schema/ReactBlockSpec.js\";\nimport { FileBlockWrapper } from \"./FileBlockWrapper.js\";\n\nexport const ResizableFileBlockWrapper = (\n  props: Omit<\n    ReactCustomBlockRenderProps<\n      BlockConfig<\n        FileBlockConfig[\"type\"],\n        FileBlockConfig[\"propSchema\"] & {\n          showPreview?: { default: true };\n          previewWidth?: { default: number };\n          textAlignment?: { default: \"left\" };\n        },\n        FileBlockConfig[\"content\"]\n      >\n    >,\n    \"contentRef\"\n  > & {\n    buttonIcon?: ReactNode;\n    children?: ReactNode;\n  },\n) => {\n  // Temporary parameters set when the user begins resizing the element, used to\n  // calculate the new width of the element.\n  const [resizeParams, setResizeParams] = useState<\n    | {\n        initialWidth: number;\n        initialClientX: number;\n        handleUsed: \"left\" | \"right\";\n      }\n    | undefined\n  >(undefined);\n\n  const [width, setWidth] = useState<number | undefined>(\n    props.block.props.previewWidth,\n  );\n  const [hovered, setHovered] = useState<boolean>(false);\n\n  const ref = useRef<HTMLDivElement>(null);\n\n  useEffect(() => {\n    // Updates the child 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      let newWidth: number;\n\n      const clientX =\n        \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n      if (props.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 child width in px.\n      const minWidth = 64;\n\n      // Ensures the child is not wider than the editor and not narrower than a\n      // predetermined minimum width.\n      setWidth(\n        Math.min(\n          Math.max(newWidth, minWidth),\n          props.editor.domElement?.firstElementChild?.clientWidth ||\n            Number.MAX_VALUE,\n        ),\n      );\n    };\n    // Stops mouse movements from resizing the child and updates the block's\n    // `width` prop to the new value.\n    const windowMouseUpHandler = () => {\n      setResizeParams(undefined);\n\n      (props.editor as any).updateBlock(props.block, {\n        props: {\n          previewWidth: width,\n        },\n      });\n    };\n\n    if (resizeParams) {\n      window.addEventListener(\"mousemove\", windowMouseMoveHandler);\n      window.addEventListener(\"touchmove\", windowMouseMoveHandler);\n      window.addEventListener(\"mouseup\", windowMouseUpHandler);\n      window.addEventListener(\"touchend\", windowMouseUpHandler);\n    }\n\n    return () => {\n      window.removeEventListener(\"mousemove\", windowMouseMoveHandler);\n      window.removeEventListener(\"touchmove\", windowMouseMoveHandler);\n      window.removeEventListener(\"mouseup\", windowMouseUpHandler);\n      window.removeEventListener(\"touchend\", windowMouseUpHandler);\n    };\n  }, [props, resizeParams, width]);\n\n  // Shows the resize handles when hovering over the child with the cursor.\n  const wrapperMouseEnterHandler = useCallback(() => {\n    if (props.editor.isEditable) {\n      setHovered(true);\n    }\n  }, [props.editor.isEditable]);\n\n  // Hides the resize handles when the cursor leaves the child, unless the\n  // cursor moves to one of the resize handles.\n  const wrapperMouseLeaveHandler = useCallback(() => {\n    setHovered(false);\n  }, []);\n\n  // Sets the resize params, allowing the user to begin resizing the child by\n  // moving the cursor left or right.\n  const leftResizeHandleMouseDownHandler = useCallback(\n    (event: React.MouseEvent | React.TouchEvent) => {\n      event.preventDefault();\n\n      const clientX =\n        \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n      setResizeParams({\n        handleUsed: \"left\",\n        initialWidth: ref.current!.clientWidth,\n        initialClientX: clientX,\n      });\n    },\n    [],\n  );\n  const rightResizeHandleMouseDownHandler = useCallback(\n    (event: React.MouseEvent | React.TouchEvent) => {\n      event.preventDefault();\n\n      const clientX =\n        \"touches\" in event ? event.touches[0].clientX : event.clientX;\n\n      setResizeParams({\n        handleUsed: \"right\",\n        initialWidth: ref.current!.clientWidth,\n        initialClientX: clientX,\n      });\n    },\n    [],\n  );\n\n  const showLoader = useUploadLoading(props.block.id);\n\n  return (\n    <FileBlockWrapper\n      {...props}\n      onMouseEnter={wrapperMouseEnterHandler}\n      onMouseLeave={wrapperMouseLeaveHandler}\n      style={\n        props.block.props.url && !showLoader && props.block.props.showPreview\n          ? {\n              width: width ? `${width}px` : \"fit-content\",\n            }\n          : undefined\n      }\n    >\n      <div\n        className={\"bn-visual-media-wrapper\"}\n        style={{ position: \"relative\" }}\n        ref={ref}\n      >\n        {props.children}\n        <div\n          className={\"bn-resize-handle\"}\n          style={{\n            left: \"4px\",\n            display: hovered || resizeParams ? \"initial\" : \"none\",\n          }}\n          onMouseDown={leftResizeHandleMouseDownHandler}\n          onTouchStart={leftResizeHandleMouseDownHandler}\n        />\n        <div\n          className={\"bn-resize-handle\"}\n          style={{\n            right: \"4px\",\n            display: hovered || resizeParams ? \"initial\" : \"none\",\n          }}\n          onMouseDown={rightResizeHandleMouseDownHandler}\n          onTouchStart={rightResizeHandleMouseDownHandler}\n        />\n        {/* This element ensures `mousemove` and `mouseup` events are captured\n        while resizing when the cursor is over the wrapper content. This is\n        because embeds are treated as separate HTML documents, so if the \n        content is an embed, the events will only fire within that document. */}\n        {resizeParams && (\n          <div\n            style={{\n              position: \"absolute\",\n              height: \"100%\",\n              width: \"100%\",\n            }}\n          />\n        )}\n      </div>\n    </FileBlockWrapper>\n  );\n};\n","import { createImageBlockConfig, imageParse } from \"@blocknote/core\";\nimport { RiImage2Fill } from \"react-icons/ri\";\n\nimport {\n  createReactBlockSpec,\n  ReactCustomBlockRenderProps,\n} from \"../../schema/ReactBlockSpec.js\";\nimport { useResolveUrl } from \"../File/useResolveUrl.js\";\nimport { FigureWithCaption } from \"../File/helpers/toExternalHTML/FigureWithCaption.js\";\nimport { ResizableFileBlockWrapper } from \"../File/helpers/render/ResizableFileBlockWrapper.js\";\nimport { LinkWithCaption } from \"../File/helpers/toExternalHTML/LinkWithCaption.js\";\n\nexport const ImagePreview = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createImageBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  const resolved = useResolveUrl(props.block.props.url!);\n\n  return (\n    <img\n      className={\"bn-visual-media\"}\n      src={\n        resolved.loadingState === \"loading\"\n          ? props.block.props.url\n          : resolved.downloadUrl\n      }\n      alt={props.block.props.caption || \"BlockNote image\"}\n      contentEditable={false}\n      draggable={false}\n    />\n  );\n};\n\nexport const ImageToExternalHTML = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createImageBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  if (!props.block.props.url) {\n    return <p>Add image</p>;\n  }\n\n  const image = props.block.props.showPreview ? (\n    <img\n      src={props.block.props.url}\n      alt={\n        props.block.props.name || props.block.props.caption || \"BlockNote image\"\n      }\n      width={props.block.props.previewWidth}\n    />\n  ) : (\n    <a href={props.block.props.url}>\n      {props.block.props.name || props.block.props.url}\n    </a>\n  );\n\n  if (props.block.props.caption) {\n    return props.block.props.showPreview ? (\n      <FigureWithCaption caption={props.block.props.caption}>\n        {image}\n      </FigureWithCaption>\n    ) : (\n      <LinkWithCaption caption={props.block.props.caption}>\n        {image}\n      </LinkWithCaption>\n    );\n  }\n\n  return image;\n};\n\nexport const ImageBlock = (\n  props: ReactCustomBlockRenderProps<typeof createImageBlockConfig>,\n) => {\n  return (\n    <ResizableFileBlockWrapper\n      {...(props as any)}\n      buttonIcon={<RiImage2Fill size={24} />}\n    >\n      <ImagePreview {...(props as any)} />\n    </ResizableFileBlockWrapper>\n  );\n};\n\nexport const ReactImageBlock = createReactBlockSpec(\n  createImageBlockConfig,\n  (config) => ({\n    meta: {\n      fileBlockAccept: [\"image/*\"],\n    },\n    render: ImageBlock,\n    parse: imageParse(config),\n    toExternalHTML: ImageToExternalHTML,\n    runsBefore: [\"file\"],\n  }),\n);\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  getPageBreakSlashMenuItems,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { DefaultReactSuggestionItem } from \"../../components/SuggestionMenu/types.js\";\nimport { TbPageBreak } from \"react-icons/tb\";\n\nconst icons = {\n  page_break: TbPageBreak,\n};\n\nexport function getPageBreakReactSlashMenuItems<\n  BSchema extends BlockSchema,\n  I extends InlineContentSchema,\n  S extends StyleSchema,\n>(\n  editor: BlockNoteEditor<BSchema, I, S>,\n): (Omit<DefaultReactSuggestionItem, \"key\"> & { key: \"page_break\" })[] {\n  return getPageBreakSlashMenuItems(editor).map((item) => {\n    const Icon = icons[item.key];\n    return {\n      ...item,\n      icon: <Icon size={18} />,\n    };\n  });\n}\n","import { createVideoBlockConfig, videoParse } from \"@blocknote/core\";\nimport { RiVideoFill } from \"react-icons/ri\";\n\nimport {\n  createReactBlockSpec,\n  ReactCustomBlockRenderProps,\n} from \"../../schema/ReactBlockSpec.js\";\nimport { useResolveUrl } from \"../File/useResolveUrl.js\";\nimport { FigureWithCaption } from \"../File/helpers/toExternalHTML/FigureWithCaption.js\";\nimport { ResizableFileBlockWrapper } from \"../File/helpers/render/ResizableFileBlockWrapper.js\";\nimport { LinkWithCaption } from \"../File/helpers/toExternalHTML/LinkWithCaption.js\";\n\nexport const VideoPreview = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createVideoBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  const resolved = useResolveUrl(props.block.props.url!);\n\n  return (\n    <video\n      className={\"bn-visual-media\"}\n      src={\n        resolved.loadingState === \"loading\"\n          ? props.block.props.url\n          : resolved.downloadUrl\n      }\n      controls={true}\n      contentEditable={false}\n      draggable={false}\n    />\n  );\n};\n\nexport const VideoToExternalHTML = (\n  props: Omit<\n    ReactCustomBlockRenderProps<typeof createVideoBlockConfig>,\n    \"contentRef\"\n  >,\n) => {\n  if (!props.block.props.url) {\n    return <p>Add video</p>;\n  }\n\n  const video = props.block.props.showPreview ? (\n    <video src={props.block.props.url} />\n  ) : (\n    <a href={props.block.props.url}>\n      {props.block.props.name || props.block.props.url}\n    </a>\n  );\n\n  if (props.block.props.caption) {\n    return props.block.props.showPreview ? (\n      <FigureWithCaption caption={props.block.props.caption}>\n        {video}\n      </FigureWithCaption>\n    ) : (\n      <LinkWithCaption caption={props.block.props.caption}>\n        {video}\n      </LinkWithCaption>\n    );\n  }\n\n  return video;\n};\n\nexport const VideoBlock = (\n  props: ReactCustomBlockRenderProps<typeof createVideoBlockConfig>,\n) => {\n  return (\n    <ResizableFileBlockWrapper\n      {...(props as any)}\n      buttonIcon={<RiVideoFill size={24} />}\n    >\n      <VideoPreview {...(props as any)} />\n    </ResizableFileBlockWrapper>\n  );\n};\n\nexport const ReactVideoBlock = createReactBlockSpec(\n  createVideoBlockConfig,\n  (config) => ({\n    meta: {\n      fileBlockAccept: [\"video/*\"],\n    },\n    render: VideoBlock,\n    parse: videoParse(config),\n    toExternalHTML: VideoToExternalHTML,\n    runsBefore: [\"file\"],\n  }),\n);\n","import {\n  Block,\n  BlockConfig,\n  blockHasType,\n  defaultToggledState,\n  UnreachableCaseError,\n} from \"@blocknote/core\";\nimport { ReactNode, useReducer } from \"react\";\n\nimport { useEditorState } from \"../../hooks/useEditorState.js\";\nimport { ReactCustomBlockRenderProps } from \"../../schema/ReactBlockSpec.js\";\n\nconst showChildrenReducer = (\n  showChildren: boolean,\n  action:\n    | {\n        type: \"toggled\";\n      }\n    | {\n        type: \"childAdded\";\n      }\n    | {\n        type: \"lastChildRemoved\";\n      },\n) => {\n  if (action.type === \"toggled\") {\n    return !showChildren;\n  }\n\n  if (action.type === \"childAdded\") {\n    return true;\n  }\n\n  if (action.type === \"lastChildRemoved\") {\n    return false;\n  }\n\n  throw new UnreachableCaseError(action);\n};\n\nexport const ToggleWrapper = (\n  props: Omit<\n    ReactCustomBlockRenderProps<BlockConfig<any, any, any>>,\n    \"contentRef\"\n  > & {\n    children: ReactNode;\n    toggledState?: {\n      set: (block: Block<any, any, any>, isToggled: boolean) => void;\n      get: (block: Block<any, any, any>) => boolean;\n    };\n  },\n) => {\n  const { block, editor, children, toggledState } = props;\n\n  const [showChildren, dispatch] = useReducer(\n    showChildrenReducer,\n    (toggledState || defaultToggledState).get(block),\n  );\n\n  const handleToggle = (block: Block<any, any, any>) => {\n    (toggledState || defaultToggledState).set(\n      editor.getBlock(block)!,\n      !showChildren,\n    );\n    dispatch({\n      type: \"toggled\",\n    });\n  };\n\n  const handleChildAdded = (block: Block<any, any, any>) => {\n    (toggledState || defaultToggledState).set(block, true);\n    dispatch({\n      type: \"childAdded\",\n    });\n  };\n\n  const handleLastChildRemoved = (block: Block<any, any, any>) => {\n    (toggledState || defaultToggledState).set(block, false);\n    dispatch({\n      type: \"lastChildRemoved\",\n    });\n  };\n\n  const childCount = useEditorState({\n    editor,\n    selector: ({ editor }) => {\n      if (\n        !blockHasType(block, editor, block.type, { isToggleable: \"boolean\" }) &&\n        !block.props.isToggleable\n      ) {\n        return 0;\n      }\n\n      const newBlock = editor.getBlock(block)!;\n      const newChildCount = newBlock.children.length || 0;\n\n      if (newChildCount > childCount) {\n        // If a child block is added while children are hidden, show children.\n        if (!showChildren) {\n          handleChildAdded(newBlock);\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 (showChildren) {\n          handleLastChildRemoved(newBlock);\n        }\n      }\n\n      return newChildCount;\n    },\n  });\n\n  if (\"isToggleable\" in block.props && !block.props.isToggleable) {\n    return children;\n  }\n\n  return (\n    <div>\n      <div className=\"bn-toggle-wrapper\" data-show-children={showChildren}>\n        <button\n          className=\"bn-toggle-button\"\n          type=\"button\"\n          onMouseDown={(event) => event.preventDefault()}\n          onClick={() => handleToggle(editor.getBlock(block)!)}\n        >\n          <svg\n            xmlns=\"http://www.w3.org/2000/svg\"\n            height=\"1em\"\n            viewBox=\"0 -960 960 960\"\n            width=\"1em\"\n            fill=\"currentcolor\"\n          >\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            <path d=\"M472-480 332-620q-18-18-18-44t18-44q18-18 44-18t44 18l183 183q9 9 14 21t5 24q0 12-5 24t-14 21L420-252q-18 18-44 18t-44-18q-18-18-18-44t18-44l140-140Z\" />\n          </svg>\n        </button>\n        {children}\n      </div>\n      {editor.isEditable && showChildren && childCount === 0 && (\n        <button\n          className=\"bn-toggle-add-block-button\"\n          type=\"button\"\n          onClick={() => {\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          {editor.dictionary.toggle_blocks.add_block_button}\n        </button>\n      )}\n    </div>\n  );\n};\n","import { BlockSchema, InlineContentSchema, StyleSchema } from \"@blocknote/core\";\nimport { FormattingToolbarExtension } from \"@blocknote/core/extensions\";\nimport { FC, CSSProperties, useMemo, useRef, useState, useEffect } from \"react\";\n\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtensionState } from \"../../hooks/useExtension.js\";\nimport { FormattingToolbar } from \"./FormattingToolbar.js\";\nimport { FormattingToolbarProps } from \"./FormattingToolbarProps.js\";\n\n/**\n * Experimental formatting toolbar controller for mobile devices.\n * Uses Visual Viewport API to position the toolbar above the virtual keyboard.\n *\n * Currently marked experimental due to the flickering issue with positioning cause by the use of the API (and likely a delay in its updates).\n */\nexport const ExperimentalMobileFormattingToolbarController = (props: {\n  formattingToolbar?: FC<FormattingToolbarProps>;\n}) => {\n  const [transform, setTransform] = useState<string>(\"none\");\n  const divRef = useRef<HTMLDivElement>(null);\n  const editor = useBlockNoteEditor<\n    BlockSchema,\n    InlineContentSchema,\n    StyleSchema\n  >();\n\n  const show = useExtensionState(FormattingToolbarExtension, {\n    editor,\n  });\n\n  const style = useMemo<CSSProperties>(() => {\n    return {\n      display: \"flex\",\n      position: \"fixed\",\n      bottom: 0,\n      zIndex: `calc(var(--bn-ui-base-z-index) + 40)`,\n      transform,\n    };\n  }, [transform]);\n\n  useEffect(() => {\n    const viewport = window.visualViewport!;\n    function viewportHandler() {\n      // Calculate the offset necessary to set the toolbar above the virtual keyboard (using the offset info from the visualViewport)\n      const layoutViewport = document.body;\n      const offsetLeft = viewport.offsetLeft;\n      const offsetTop =\n        viewport.height -\n        layoutViewport.getBoundingClientRect().height +\n        viewport.offsetTop;\n\n      setTransform(\n        `translate(${offsetLeft}px, ${offsetTop}px) scale(${\n          1 / viewport.scale\n        })`,\n      );\n    }\n    window.visualViewport!.addEventListener(\"scroll\", viewportHandler);\n    window.visualViewport!.addEventListener(\"resize\", viewportHandler);\n    viewportHandler();\n\n    return () => {\n      window.visualViewport!.removeEventListener(\"scroll\", viewportHandler);\n      window.visualViewport!.removeEventListener(\"resize\", viewportHandler);\n    };\n  }, []);\n\n  if (!show && divRef.current) {\n    // The component is fading out. Use the previous state to render the toolbar with innerHTML,\n    // because otherwise the toolbar will quickly flickr (i.e.: show a different state) while fading out,\n    // which looks weird\n    return (\n      <div\n        ref={divRef}\n        style={style}\n        dangerouslySetInnerHTML={{ __html: divRef.current.innerHTML }}\n      ></div>\n    );\n  }\n\n  const Component = props.formattingToolbar || FormattingToolbar;\n\n  return (\n    <div ref={divRef} style={style}>\n      <Component />\n    </div>\n  );\n};\n","import { size, useFloating, useTransitionStyles } from \"@floating-ui/react\";\nimport { useEffect, useMemo } from \"react\";\n\nfunction useExtendButtonPosition(\n  orientation: \"addOrRemoveRows\" | \"addOrRemoveColumns\",\n  show: boolean,\n  referencePosTable: DOMRect | null,\n): {\n  isMounted: boolean;\n  ref: (node: HTMLElement | null) => void;\n  style: React.CSSProperties;\n} {\n  const { refs, update, context, floatingStyles } = useFloating({\n    open: show,\n    placement: orientation === \"addOrRemoveColumns\" ? \"right\" : \"bottom\",\n    middleware: [\n      size({\n        apply({ rects, elements }) {\n          Object.assign(\n            elements.floating.style,\n            orientation === \"addOrRemoveColumns\"\n              ? {\n                  height: `${rects.reference.height}px`,\n                }\n              : {\n                  width: `${rects.reference.width}px`,\n                },\n          );\n        },\n      }),\n    ],\n  });\n\n  const { isMounted, styles } = useTransitionStyles(context);\n\n  useEffect(() => {\n    update();\n  }, [referencePosTable, update]);\n\n  useEffect(() => {\n    // Will be null on initial render when used in UI component controllers.\n    if (referencePosTable === null) {\n      return;\n    }\n\n    refs.setReference({\n      getBoundingClientRect: () => referencePosTable,\n    });\n  }, [orientation, referencePosTable, refs]);\n\n  return useMemo(\n    () => ({\n      isMounted: isMounted,\n      ref: refs.setFloating,\n      style: {\n        display: \"flex\",\n        ...styles,\n        ...floatingStyles,\n      },\n    }),\n    [floatingStyles, isMounted, refs.setFloating, styles],\n  );\n}\n\nexport function useExtendButtonsPositioning(\n  showAddOrRemoveColumnsButton: boolean,\n  showAddOrRemoveRowsButton: boolean,\n  referencePosTable: DOMRect | null,\n): {\n  addOrRemoveRowsButton: ReturnType<typeof useExtendButtonPosition>;\n  addOrRemoveColumnsButton: ReturnType<typeof useExtendButtonPosition>;\n} {\n  const addOrRemoveRowsButton = useExtendButtonPosition(\n    \"addOrRemoveRows\",\n    showAddOrRemoveRowsButton,\n    referencePosTable,\n  );\n  const addOrRemoveColumnsButton = useExtendButtonPosition(\n    \"addOrRemoveColumns\",\n    showAddOrRemoveColumnsButton,\n    referencePosTable,\n  );\n\n  return useMemo(\n    () => ({\n      addOrRemoveRowsButton,\n      addOrRemoveColumnsButton,\n    }),\n    [addOrRemoveColumnsButton, addOrRemoveRowsButton],\n  );\n}\n","import { offset, useFloating, useTransitionStyles } from \"@floating-ui/react\";\nimport { useEffect, useMemo } from \"react\";\n\nfunction getBoundingClientRectRow(\n  referencePosCell: DOMRect | null,\n  referencePosTable: DOMRect | null,\n  draggingState?: {\n    draggedCellOrientation: \"row\" | \"col\";\n    mousePos: number;\n  },\n) {\n  if (draggingState && draggingState.draggedCellOrientation === \"row\") {\n    return new DOMRect(\n      referencePosTable!.x,\n      draggingState.mousePos,\n      referencePosTable!.width,\n      0,\n    );\n  }\n\n  return new DOMRect(\n    referencePosTable!.x,\n    referencePosCell!.y,\n    referencePosTable!.width,\n    referencePosCell!.height,\n  );\n}\n\nfunction getBoundingClientRectCol(\n  referencePosCell: DOMRect | null,\n  referencePosTable: DOMRect | null,\n  draggingState?: {\n    draggedCellOrientation: \"row\" | \"col\";\n    mousePos: number;\n  },\n) {\n  if (draggingState && draggingState.draggedCellOrientation === \"col\") {\n    return new DOMRect(\n      draggingState.mousePos,\n      referencePosTable!.y,\n      0,\n      referencePosTable!.height,\n    );\n  }\n\n  return new DOMRect(\n    referencePosCell!.x,\n    referencePosTable!.y,\n    referencePosCell!.width,\n    referencePosTable!.height,\n  );\n}\n\nfunction getBoundingClientRectCell(referencePosCell: DOMRect | null) {\n  return new DOMRect(\n    referencePosCell!.x,\n    referencePosCell!.y,\n    referencePosCell!.width,\n    0,\n  );\n}\n\nfunction useTableHandlePosition(\n  orientation: \"row\" | \"col\" | \"cell\",\n  show: boolean,\n  referencePosCell: DOMRect | null,\n  referencePosTable: DOMRect | null,\n  draggingState?: {\n    draggedCellOrientation: \"row\" | \"col\";\n    mousePos: number;\n  },\n): {\n  isMounted: boolean;\n  ref: (node: HTMLElement | null) => void;\n  style: React.CSSProperties;\n} {\n  const { refs, update, context, floatingStyles } = useFloating({\n    open: show,\n    placement:\n      orientation === \"row\"\n        ? \"left\"\n        : orientation === \"col\"\n          ? \"top\"\n          : \"bottom-end\",\n    middleware: [\n      offset(\n        orientation === \"row\"\n          ? -10\n          : orientation === \"col\"\n            ? -12\n            : { mainAxis: 1, crossAxis: -1 },\n      ),\n    ],\n  });\n\n  const { isMounted, styles } = useTransitionStyles(context);\n\n  useEffect(() => {\n    update();\n  }, [referencePosCell, referencePosTable, update]);\n\n  useEffect(() => {\n    // Will be null on initial render when used in UI component controllers.\n    if (\n      referencePosCell === null ||\n      referencePosTable === null ||\n      // Ignore cell handle when dragging\n      (draggingState && orientation === \"cell\")\n    ) {\n      return;\n    }\n\n    refs.setReference({\n      getBoundingClientRect: () => {\n        const fn =\n          orientation === \"row\"\n            ? getBoundingClientRectRow\n            : orientation === \"col\"\n              ? getBoundingClientRectCol\n              : getBoundingClientRectCell;\n        return fn(referencePosCell, referencePosTable, draggingState);\n      },\n    });\n  }, [draggingState, orientation, referencePosCell, referencePosTable, refs]);\n\n  return useMemo(\n    () => ({\n      isMounted: isMounted,\n      ref: refs.setFloating,\n      style: {\n        display: \"flex\",\n        ...styles,\n        ...floatingStyles,\n      },\n    }),\n    [floatingStyles, isMounted, refs.setFloating, styles],\n  );\n}\n\nexport function useTableHandlesPositioning(\n  show: boolean,\n  referencePosCell: DOMRect | null,\n  referencePosTable: DOMRect | null,\n  draggingState?: {\n    draggedCellOrientation: \"row\" | \"col\";\n    mousePos: number;\n  },\n): {\n  rowHandle: ReturnType<typeof useTableHandlePosition>;\n  colHandle: ReturnType<typeof useTableHandlePosition>;\n  cellHandle: ReturnType<typeof useTableHandlePosition>;\n} {\n  const rowHandle = useTableHandlePosition(\n    \"row\",\n    show,\n    referencePosCell,\n    referencePosTable,\n    draggingState,\n  );\n  const colHandle = useTableHandlePosition(\n    \"col\",\n    show,\n    referencePosCell,\n    referencePosTable,\n    draggingState,\n  );\n  const cellHandle = useTableHandlePosition(\n    \"cell\",\n    show,\n    referencePosCell,\n    referencePosTable,\n    draggingState,\n  );\n\n  return useMemo(\n    () => ({\n      rowHandle,\n      colHandle,\n      cellHandle,\n    }),\n    [colHandle, rowHandle, cellHandle],\n  );\n}\n","import { BlockNoteEditor, UnreachableCaseError } from \"@blocknote/core\";\nimport { CommentsExtension } from \"@blocknote/core/comments\";\nimport { ThreadData } from \"@blocknote/core/comments\";\nimport React, { FocusEvent, useCallback, useMemo } from \"react\";\nimport { useBlockNoteEditor } from \"../../hooks/useBlockNoteEditor.js\";\nimport { useExtension, useExtensionState } from \"../../hooks/useExtension.js\";\nimport { Thread } from \"./Thread.js\";\nimport { useThreads } from \"./useThreads.js\";\n\ntype ThreadItemProps = {\n  thread: ThreadData;\n  selectedThreadId?: string;\n  editor: BlockNoteEditor<any, any, any>;\n  maxCommentsBeforeCollapse?: number;\n  referenceText: string;\n};\n\n/**\n * This component is memoized because it's a child of the ThreadsSidebar component,\n * which rerenders on every document update.\n */\nconst ThreadItem = React.memo(\n  ({\n    thread,\n    selectedThreadId,\n    maxCommentsBeforeCollapse,\n    referenceText,\n  }: ThreadItemProps) => {\n    const comments = useExtension(CommentsExtension);\n\n    const onFocus = useCallback(\n      (event: FocusEvent) => {\n        // If the focused element is within the action toolbar, we don't want to\n        // focus the thread for UX reasons.\n        if ((event.target as HTMLElement).closest(\".bn-action-toolbar\")) {\n          return;\n        }\n\n        comments.selectThread(thread.id);\n      },\n      [comments, thread.id],\n    );\n\n    const onBlur = useCallback(\n      (event: React.FocusEvent) => {\n        // If the focused element is within the action toolbar, we don't want to\n        // blur the thread for UX reasons.\n        if (\n          !event.relatedTarget ||\n          event.relatedTarget.closest(\".bn-action-toolbar\")\n        ) {\n          return;\n        }\n\n        const targetElement =\n          event.target instanceof Node ? event.target : null;\n        const parentThreadElement =\n          event.relatedTarget instanceof Node\n            ? event.relatedTarget.closest(\".bn-thread\")\n            : null;\n\n        // When you focus the editor (reply composer), we don't want to unselect the thread\n        // This check prevents that. But we still want to unselect the thread when it gets blurred in all other cases\n        if (\n          !targetElement ||\n          !parentThreadElement ||\n          !parentThreadElement.contains(targetElement)\n        ) {\n          comments.selectThread(undefined);\n        }\n      },\n      [comments],\n    );\n\n    return (\n      <Thread\n        thread={thread}\n        selected={thread.id === selectedThreadId}\n        referenceText={referenceText}\n        maxCommentsBeforeCollapse={maxCommentsBeforeCollapse}\n        onFocus={onFocus}\n        onBlur={onBlur}\n        tabIndex={0}\n      />\n    );\n  },\n);\n\nfunction sortThreads(\n  threads: ThreadData[],\n  sort: \"position\" | \"recent-activity\" | \"oldest\",\n  threadPositions?: Map<string, { from: number; to: number }>,\n) {\n  if (sort === \"recent-activity\") {\n    // sort by latest comment in thread first\n    return threads.sort(\n      (a, b) =>\n        b.comments[b.comments.length - 1].createdAt.getTime() -\n        a.comments[a.comments.length - 1].createdAt.getTime(),\n    );\n  }\n\n  if (sort === \"oldest\") {\n    // sort by oldest thread first\n    return threads.sort(\n      (a, b) => a.createdAt.getTime() - b.createdAt.getTime(),\n    );\n  }\n\n  if (sort === \"position\") {\n    // sort by position in document (when the comment mark is deleted, use Number.MAX_VALUE)\n    return threads.sort((a, b) => {\n      const threadA = threadPositions?.get(a.id)?.from || Number.MAX_VALUE;\n      const threadB = threadPositions?.get(b.id)?.from || Number.MAX_VALUE;\n\n      return threadA - threadB;\n    });\n  }\n\n  throw new UnreachableCaseError(sort);\n}\n\n/**\n * Returns the text for a thread (basically, the text where the mark is).\n *\n * Note / TODO: it might be nicer to store and use the original content\n * when the thread was created, instead of taking the actual content from the editor\n */\nexport function getReferenceText(\n  editor: BlockNoteEditor<any, any, any>,\n  threadPosition?: {\n    from: number;\n    to: number;\n  },\n) {\n  return editor.transact((tr) => {\n    if (!threadPosition) {\n      return \"Original content deleted\";\n    }\n\n    // TODO: Handles an edge case where the editor is re-rendered and the document\n    //  is not yet fetched (causing it to be empty). We should store the original\n    //  reference text in the data model, as not only is it a general improvement,\n    //  but it also means we won't have to handle this edge case.\n    if (tr.doc.nodeSize < threadPosition.to) {\n      return \"\";\n    }\n\n    const referenceText = tr.doc.textBetween(\n      threadPosition.from,\n      threadPosition.to,\n    );\n\n    if (referenceText.length > 15) {\n      return `${referenceText.slice(0, 15)}…`;\n    }\n\n    return referenceText;\n  });\n}\n\n/**\n * The ThreadsSidebar component can be used to display a list of comments in a sidebar.\n *\n * This component is similar to Google Docs \"Show All Comments\" sidebar (cmd+option+shift+A)\n */\nexport function ThreadsSidebar(props: {\n  /**\n   * Filter the comments in the sidebar. Can pass `\"open\"`, `\"resolved\"`, or\n   * `\"all\"`, to only show open, resolved, or all comments.\n   *\n   * @default \"all\"\n   */\n  filter?: \"open\" | \"resolved\" | \"all\";\n  /**\n   * The maximum number of comments that can be in a thread before the replies\n   * get collapsed.\n   *\n   * @default 5\n   */\n  maxCommentsBeforeCollapse?: number;\n  /**\n   * Sort the comments in the sidebar. Can pass `\"position\"`,\n   * `\"recent-activity\"`, or `\"oldest\"`. Sorting by `\"recent-activity\"` uses the\n   * most recently added comment to sort threads, while `\"oldest\"` uses the\n   * thread creation date. Sorting by `\"position\"` puts comments in the same\n   * order as their reference text in the editor.\n   *\n   * @default \"position\"\n   */\n  sort?: \"position\" | \"recent-activity\" | \"oldest\";\n}) {\n  const editor = useBlockNoteEditor<any, any, any>();\n\n  const { selectedThreadId, threadPositions } =\n    useExtensionState(CommentsExtension);\n\n  const threads = useThreads();\n\n  const filteredAndSortedThreads = useMemo(() => {\n    const threadsArray = Array.from(threads.values());\n\n    const sortedThreads = sortThreads(\n      threadsArray,\n      props.sort || \"position\",\n      threadPositions,\n    );\n\n    const ret: Array<{ thread: ThreadData; referenceText: string }> = [];\n\n    for (const thread of sortedThreads) {\n      if (!thread.resolved) {\n        if (props.filter === \"open\" || props.filter === \"all\") {\n          ret.push({\n            thread,\n            referenceText: getReferenceText(\n              editor,\n              threadPositions.get(thread.id),\n            ),\n          });\n        }\n      } else {\n        if (props.filter === \"resolved\" || props.filter === \"all\") {\n          ret.push({\n            thread,\n            referenceText: getReferenceText(\n              editor,\n              threadPositions.get(thread.id),\n            ),\n          });\n        }\n      }\n    }\n\n    return ret;\n  }, [threads, props.sort, props.filter, threadPositions, editor]);\n\n  return (\n    <div className={\"bn-threads-sidebar\"}>\n      {filteredAndSortedThreads.map((thread) => (\n        <ThreadItem\n          key={thread.thread.id}\n          thread={thread.thread}\n          selectedThreadId={selectedThreadId}\n          editor={editor}\n          referenceText={thread.referenceText}\n          maxCommentsBeforeCollapse={props.maxCommentsBeforeCollapse}\n        />\n      ))}\n    </div>\n  );\n}\n","import { BlockNoteEditor, Styles, StyleSchema } from \"@blocknote/core\";\n\nimport { useBlockNoteContext } from \"../editor/BlockNoteContext.js\";\nimport { useEditorState } from \"./useEditorState.js\";\n\n/**\n * Returns the currently active text styles (e.g., bold, italic) at the editor's\n * current cursor position or selection. Re-renders automatically when the active\n * styles change.\n *\n * @param editor - The BlockNote editor instance. If omitted, uses the editor\n * from the nearest `BlockNoteContext`.\n * @returns The set of active styles at the current cursor position or selection.\n */\nexport function useActiveStyles<T extends StyleSchema>(\n  editor?: BlockNoteEditor<any, any, T>,\n): Styles<T> {\n  const editorContext = useBlockNoteContext<any, any, T>();\n  if (!editor) {\n    editor = editorContext?.editor;\n  }\n\n  if (!editor) {\n    throw new Error(\n      \"'editor' is required, either from BlockNoteContext or as a function argument\",\n    );\n  }\n\n  const styles = useEditorState({\n    editor,\n    selector: ({ editor }) => editor.getActiveStyles(),\n  });\n\n  return styles;\n}\n","import type { BlockNoteEditor } from \"@blocknote/core\";\nimport { useEditorState } from \"./useEditorState.js\";\n\n/**\n * Returns the bounding box (`DOMRect`) of the current editor selection.\n * Re-renders automatically when the selection changes. Useful for positioning\n * floating UI elements (e.g., toolbars, tooltips) relative to the selection.\n *\n * @param enabled - Whether to compute the bounding box. When `false`, returns\n * `undefined` without measuring.\n * @param editor - The BlockNote editor instance. If omitted, uses the editor\n * from the nearest `BlockNoteContext`.\n * @returns The `DOMRect` of the current selection, or `undefined` if disabled\n * or no selection exists.\n */\nexport function useEditorSelectionBoundingBox(\n  enabled?: boolean,\n  editor?: BlockNoteEditor<any, any, any>,\n) {\n  return useEditorState({\n    editor,\n    selector: ({ editor }) =>\n      enabled ? editor.getSelectionBoundingBox() : undefined,\n  });\n}\n","// Copied from https://github.com/mantinedev/mantine/blob/90900efc7f107933ba027007cf240fea61d9c9f2/packages/%40mantine/hooks/src/use-focus-within/use-focus-within.ts#L16\nimport { useEffect, useRef, useState } from \"react\";\n\nexport interface UseFocusWithinOptions {\n  onFocus?: (event: FocusEvent) => void;\n  onBlur?: (event: FocusEvent) => void;\n}\n\nfunction containsRelatedTarget(event: FocusEvent) {\n  if (\n    event.currentTarget instanceof HTMLElement &&\n    event.relatedTarget instanceof HTMLElement\n  ) {\n    return event.currentTarget.contains(event.relatedTarget);\n  }\n\n  return false;\n}\n\n/**\n * Tracks whether focus is within a referenced DOM element. Returns a ref to\n * attach to the target element and a `focused` boolean that is `true` whenever\n * the element or any of its descendants has focus.\n *\n * Adapted from Mantine's `useFocusWithin` hook.\n *\n * @param options - Optional `onFocus` and `onBlur` callbacks fired when focus\n * enters or leaves the element.\n * @returns An object with a `ref` to attach to the target element and a\n * `focused` boolean indicating current focus-within state.\n */\nexport function useFocusWithin<T extends HTMLElement = any>({\n  onBlur,\n  onFocus,\n}: UseFocusWithinOptions = {}): { ref: React.RefObject<T>; focused: boolean } {\n  const ref = useRef<T>(null);\n  const [focused, setFocused] = useState(false);\n  const focusedRef = useRef(false);\n\n  const _setFocused = (value: boolean) => {\n    setFocused(value);\n    focusedRef.current = value;\n  };\n\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  const handleFocusIn = (event: FocusEvent) => {\n    if (!focusedRef.current) {\n      _setFocused(true);\n      onFocus?.(event);\n    }\n  };\n\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  const handleFocusOut = (event: FocusEvent) => {\n    if (focusedRef.current && !containsRelatedTarget(event)) {\n      _setFocused(false);\n      onBlur?.(event);\n    }\n  };\n\n  useEffect(() => {\n    const node = ref.current;\n\n    if (node) {\n      node.addEventListener(\"focusin\", handleFocusIn);\n      node.addEventListener(\"focusout\", handleFocusOut);\n\n      return () => {\n        node?.removeEventListener(\"focusin\", handleFocusIn);\n        node?.removeEventListener(\"focusout\", handleFocusOut);\n      };\n    }\n\n    return undefined;\n  }, [handleFocusIn, handleFocusOut]);\n\n  return { ref: ref as React.RefObject<T>, focused };\n}\n","import {\n  BlockNoteEditor,\n  BlockSchema,\n  InlineContentSchema,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { useEditorState } from \"./useEditorState.js\";\n\n/**\n * Returns the blocks that are currently selected in the editor. If no\n * multi-block selection exists, returns an array containing the single block\n * at the text cursor position. Re-renders automatically when the selection\n * changes.\n *\n * @param editor - The BlockNote editor instance. If omitted, uses the editor\n * from the nearest `BlockNoteContext`.\n * @returns An array of the currently selected blocks.\n */\nexport function useSelectedBlocks<\n  BSchema extends BlockSchema,\n  ISchema extends InlineContentSchema,\n  SSchema extends StyleSchema,\n>(editor?: BlockNoteEditor<BSchema, ISchema, SSchema>) {\n  return useEditorState({\n    editor,\n    selector: ({ editor }) =>\n      editor.getSelection()?.blocks || [editor.getTextCursorPosition().block],\n  });\n}\n","import {\n  addInlineContentAttributes,\n  addInlineContentKeyboardShortcuts,\n  BlockNoteEditor,\n  camelToDataKebab,\n  createInternalInlineContentSpec,\n  CustomInlineContentConfig,\n  CustomInlineContentImplementation,\n  getInlineContentParseRules,\n  InlineContentFromConfig,\n  InlineContentSchemaWithInlineContent,\n  InlineContentSpec,\n  inlineContentToNodes,\n  nodeToCustomInlineContent,\n  PartialCustomInlineContentFromConfig,\n  Props,\n  PropSchema,\n  propsToAttributes,\n  StyleSchema,\n} from \"@blocknote/core\";\nimport { Node } from \"@tiptap/core\";\nimport {\n  NodeViewProps,\n  NodeViewWrapper,\n  ReactNodeViewRenderer,\n  useReactNodeView,\n} from \"@tiptap/react\";\n// import { useReactNodeView } from \"@tiptap/react/dist/packages/react/src/useReactNodeView\";\nimport { FC, JSX } from \"react\";\nimport { renderToDOMSpec } from \"./@util/ReactRenderUtil.js\";\n// this file is mostly analogoues to `customBlocks.ts`, but for React blocks\n\nexport type ReactCustomInlineContentRenderProps<\n  T extends CustomInlineContentConfig,\n  S extends StyleSchema,\n> = {\n  inlineContent: InlineContentFromConfig<T, S>;\n  updateInlineContent: (\n    update: PartialCustomInlineContentFromConfig<T, S>,\n  ) => void;\n  editor: BlockNoteEditor<\n    any,\n    InlineContentSchemaWithInlineContent<T[\"type\"], T>,\n    S\n  >;\n  contentRef: (node: HTMLElement | null) => void;\n};\n\n// extend BlockConfig but use a React render function\nexport type ReactInlineContentImplementation<\n  T extends CustomInlineContentConfig,\n  // I extends InlineContentSchema,\n  S extends StyleSchema,\n> = {\n  render: FC<ReactCustomInlineContentRenderProps<T, S>>;\n  toExternalHTML?: FC<ReactCustomInlineContentRenderProps<T, S>>;\n} & Omit<CustomInlineContentImplementation<T, S>, \"render\" | \"toExternalHTML\">;\n\n// Function that adds a wrapper with necessary classes and attributes to the\n// component returned from a custom inline content's 'render' function, to\n// ensure no data is lost on internal copy & paste.\nexport function InlineContentWrapper<\n  IType extends string,\n  PSchema extends PropSchema,\n>(props: {\n  children: JSX.Element;\n  inlineContentType: IType;\n  inlineContentProps: Props<PSchema>;\n  propSchema: PSchema;\n}) {\n  return (\n    // Creates inline content section element\n    <NodeViewWrapper\n      as={\"span\"}\n      // Sets inline content section class\n      className={\"bn-inline-content-section\"}\n      // Sets content type attribute\n      data-inline-content-type={props.inlineContentType}\n      // Adds props as HTML attributes in kebab-case with \"data-\" prefix. Skips\n      // props set to their default values.\n      {...Object.fromEntries(\n        Object.entries(props.inlineContentProps)\n          .filter(([prop, value]) => {\n            const spec = props.propSchema[prop];\n            return value !== spec.default;\n          })\n          .map(([prop, value]) => {\n            return [camelToDataKebab(prop), value];\n          }),\n      )}\n    >\n      {props.children}\n    </NodeViewWrapper>\n  );\n}\n\n/**\n * Creates a custom inline content specification for use with React. This is the\n * React counterpart to the vanilla `createInlineContentSpec` and lets you define\n * custom inline content types (e.g., mentions, tags) using React components for\n * rendering.\n *\n * @param inlineContentConfig - The inline content type configuration, including\n * its `type` name, `propSchema`, and `content` mode (`\"styled\"` or `\"none\"`).\n * @param inlineContentImplementation - The React implementation, including a\n * `render` component and optionally a `toExternalHTML` component and `parse`\n * rules.\n * @returns An `InlineContentSpec` that can be passed to the editor's schema.\n */\nexport function createReactInlineContentSpec<\n  const T extends CustomInlineContentConfig,\n  // I extends InlineContentSchema,\n  S extends StyleSchema,\n>(\n  inlineContentConfig: T,\n  inlineContentImplementation: ReactInlineContentImplementation<T, S>,\n): InlineContentSpec<T> {\n  const node = Node.create({\n    name: inlineContentConfig.type as T[\"type\"],\n    inline: true,\n    group: \"inline\",\n    selectable: inlineContentConfig.content === \"styled\",\n    atom: inlineContentConfig.content === \"none\",\n    draggable: inlineContentImplementation.meta?.draggable,\n    content: (inlineContentConfig.content === \"styled\"\n      ? \"inline*\"\n      : \"\") as T[\"content\"] extends \"styled\" ? \"inline*\" : \"\",\n\n    addAttributes() {\n      return propsToAttributes(inlineContentConfig.propSchema);\n    },\n\n    addKeyboardShortcuts() {\n      return addInlineContentKeyboardShortcuts(inlineContentConfig);\n    },\n\n    parseHTML() {\n      return getInlineContentParseRules(\n        inlineContentConfig,\n        inlineContentImplementation.parse,\n      );\n    },\n\n    renderHTML({ node }) {\n      const editor = this.options.editor;\n\n      const ic = nodeToCustomInlineContent(\n        node,\n        editor.schema.inlineContentSchema,\n        editor.schema.styleSchema,\n      ) as any as InlineContentFromConfig<T, S>; // TODO: fix cast\n      const Content =\n        inlineContentImplementation.toExternalHTML ||\n        inlineContentImplementation.render;\n      const output = renderToDOMSpec(\n        (ref) => (\n          <Content\n            contentRef={(element) => {\n              ref(element);\n              if (element) {\n                element.dataset.editable = \"\";\n              }\n            }}\n            inlineContent={ic}\n            updateInlineContent={() => {\n              // No-op\n            }}\n            editor={editor}\n          />\n        ),\n        editor,\n      );\n\n      return addInlineContentAttributes(\n        output,\n        inlineContentConfig.type,\n        node.attrs as Props<T[\"propSchema\"]>,\n        inlineContentConfig.propSchema,\n      );\n    },\n\n    addNodeView() {\n      const editor: BlockNoteEditor<any, any, any> = this.options.editor;\n      return (props) =>\n        ReactNodeViewRenderer(\n          (props: NodeViewProps) => {\n            const ref = useReactNodeView().nodeViewContentRef;\n\n            if (!ref) {\n              throw new Error(\"nodeViewContentRef is not set\");\n            }\n\n            const Content = inlineContentImplementation.render;\n            return (\n              <InlineContentWrapper\n                inlineContentProps={props.node.attrs as Props<T[\"propSchema\"]>}\n                inlineContentType={inlineContentConfig.type}\n                propSchema={inlineContentConfig.propSchema}\n              >\n                <Content\n                  contentRef={(element) => {\n                    ref(element);\n                    if (element) {\n                      element.dataset.editable = \"\";\n                    }\n                  }}\n                  editor={editor}\n                  inlineContent={\n                    nodeToCustomInlineContent(\n                      props.node,\n                      editor.schema.inlineContentSchema,\n                      editor.schema.styleSchema,\n                    ) as any as InlineContentFromConfig<T, S> // TODO: fix cast\n                  }\n                  updateInlineContent={(update) => {\n                    const content = inlineContentToNodes(\n                      [update],\n                      editor.pmSchema,\n                    );\n\n                    const pos = props.getPos();\n\n                    if (pos === undefined) {\n                      return;\n                    }\n\n                    editor.transact((tr) =>\n                      tr.replaceWith(pos, pos + props.node.nodeSize, content),\n                    );\n                  }}\n                />\n              </InlineContentWrapper>\n            );\n          },\n          {\n            className: \"bn-ic-react-node-view-renderer\",\n            as: \"span\",\n            // contentDOMElementTag: \"span\", (requires tt upgrade)\n          },\n        )(props);\n    },\n  });\n\n  return createInternalInlineContentSpec(\n    inlineContentConfig as CustomInlineContentConfig,\n    {\n      ...inlineContentImplementation,\n      node,\n      render(inlineContent, updateInlineContent, editor) {\n        const Content = inlineContentImplementation.render;\n        const output = renderToDOMSpec((ref) => {\n          return (\n            <InlineContentWrapper\n              inlineContentProps={inlineContent.props}\n              inlineContentType={inlineContentConfig.type}\n              propSchema={inlineContentConfig.propSchema}\n            >\n              <Content\n                contentRef={(element) => {\n                  ref(element);\n                  if (element) {\n                    element.dataset.editable = \"\";\n                  }\n                }}\n                editor={editor}\n                inlineContent={inlineContent}\n                updateInlineContent={updateInlineContent}\n              />\n            </InlineContentWrapper>\n          );\n        }, editor);\n        return output;\n      },\n      toExternalHTML(inlineContent, editor) {\n        const Content =\n          inlineContentImplementation.toExternalHTML ||\n          inlineContentImplementation.render;\n        const output = renderToDOMSpec((ref) => {\n          return (\n            <InlineContentWrapper\n              inlineContentProps={inlineContent.props}\n              inlineContentType={inlineContentConfig.type}\n              propSchema={inlineContentConfig.propSchema}\n            >\n              <Content\n                contentRef={(element) => {\n                  ref(element);\n                  if (element) {\n                    element.dataset.editable = \"\";\n                  }\n                }}\n                editor={editor}\n                inlineContent={inlineContent}\n                updateInlineContent={() => {\n                  // no-op\n                }}\n              />\n            </InlineContentWrapper>\n          );\n        }, editor);\n        return output;\n      },\n    },\n  ) as any;\n}\n","import {\n  BlockNoteEditor,\n  StyleConfig,\n  addStyleAttributes,\n  createInternalStyleSpec,\n  getStyleParseRules,\n  stylePropsToAttributes,\n} from \"@blocknote/core\";\nimport {\n  Mark,\n  ReactMarkViewContext,\n  ReactMarkViewRenderer,\n} from \"@tiptap/react\";\nimport { FC, useContext } from \"react\";\nimport { renderToDOMSpec } from \"./@util/ReactRenderUtil.js\";\n\n// this file is mostly analogoues to `customBlocks.ts`, but for React blocks\n\n// extend BlockConfig but use a React render function\nexport type ReactCustomStyleImplementation<T extends StyleConfig> = {\n  render: FC<{\n    value: T[\"propSchema\"] extends \"boolean\" ? undefined : string;\n    contentRef: (el: HTMLElement | null) => void;\n    editor: BlockNoteEditor<any, any, any>;\n  }>;\n  runsBefore?: string[];\n};\n\n/**\n * Creates a custom style specification for use with React. This is the React\n * counterpart to the vanilla `createStyleSpec` and lets you define custom text\n * styles (e.g., font color, highlight) using React components for rendering.\n *\n * @param styleConfig - The style configuration, including its `type` name and\n * `propSchema` (`\"boolean\"` or `\"string\"`).\n * @param styleImplementation - The React implementation, including a `render`\n * component that receives the style value, a `contentRef`, and the editor.\n * @returns A style spec that can be passed to the editor's schema.\n */\nexport function createReactStyleSpec<T extends StyleConfig>(\n  styleConfig: T,\n  styleImplementation: ReactCustomStyleImplementation<T>,\n) {\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);\n    },\n\n    renderHTML({ mark }) {\n      const Content = styleImplementation.render;\n      const renderResult = renderToDOMSpec(\n        (ref) => (\n          <Content\n            editor={this.options.editor}\n            value={\n              styleConfig.propSchema === \"boolean\"\n                ? undefined\n                : mark.attrs.stringValue\n            }\n            contentRef={(element) => {\n              ref(element);\n              if (element) {\n                element.dataset.editable = \"\";\n              }\n            }}\n          />\n        ),\n        this.options.editor,\n      );\n\n      return addStyleAttributes(\n        renderResult,\n        styleConfig.type,\n        mark.attrs.stringValue,\n        styleConfig.propSchema,\n      );\n    },\n    addMarkView() {\n      const editor: BlockNoteEditor<any, any, any> = this.options.editor;\n\n      return (markViewProps) => {\n        const renderResult = ReactMarkViewRenderer((props) => {\n          const ref = useContext(ReactMarkViewContext).markViewContentRef;\n\n          if (!ref) {\n            throw new Error(\"markViewContentRef is not set\");\n          }\n\n          const Content = styleImplementation.render;\n          return (\n            <Content\n              editor={editor}\n              contentRef={(element) => {\n                ref(element);\n                if (element) {\n                  element.dataset.markViewContent = \"\";\n                }\n              }}\n              value={\n                styleConfig.propSchema === \"boolean\"\n                  ? undefined\n                  : props.mark.attrs.stringValue\n              }\n            />\n          );\n        })(markViewProps);\n\n        /**\n         * See https://github.com/ueberdosis/tiptap/blob/5ba480bcd97a0e92f889019f1a65fc67fd3506f9/packages/react/src/ReactMarkViewRenderer.tsx#L98-L103\n         * If the `contentRef` is not set synchronously, the contentDOM will be null\n         * This is a hack to make sure that it is always defined so that Prosemirror can insert the content into the correct position\n         *\n         * (This is only an issue with Firefox)\n         */\n        (renderResult as any).didMountContentDomElement = true;\n\n        return renderResult;\n      };\n    },\n  });\n\n  return createInternalStyleSpec(styleConfig, {\n    ...styleImplementation,\n    mark,\n    render(value, editor) {\n      const Content = styleImplementation.render;\n      const output = renderToDOMSpec(\n        (ref) => (\n          <Content\n            editor={editor}\n            value={value}\n            contentRef={(element) => {\n              ref(element);\n              if (element) {\n                element.dataset.editable = \"\";\n              }\n            }}\n          />\n        ),\n        editor,\n      );\n\n      return addStyleAttributes(\n        output,\n        styleConfig.type,\n        value,\n        styleConfig.propSchema,\n      );\n    },\n    toExternalHTML(value, editor) {\n      const Content = styleImplementation.render;\n      const output = renderToDOMSpec(\n        (ref) => (\n          <Content\n            editor={editor}\n            value={value}\n            contentRef={(element) => {\n              ref(element);\n              if (element) {\n                element.dataset.editable = \"\";\n              }\n            }}\n          />\n        ),\n        editor,\n      );\n\n      return addStyleAttributes(\n        output,\n        styleConfig.type,\n        value,\n        styleConfig.propSchema,\n      );\n    },\n  });\n}\n","export function elementOverflow(element: HTMLElement, container: HTMLElement) {\n  const elementRect = element.getBoundingClientRect();\n  const parentRect = container.getBoundingClientRect();\n\n  const topOverflow = elementRect.top < parentRect.top;\n  const bottomOverflow = elementRect.bottom > parentRect.bottom;\n\n  return topOverflow && bottomOverflow\n    ? \"both\"\n    : topOverflow\n      ? \"top\"\n      : bottomOverflow\n        ? \"bottom\"\n        : \"none\";\n}\n","// https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx\nexport function mergeRefs<T = any>(\n  refs: Array<\n    React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null\n  >,\n): React.RefCallback<T> {\n  return (value) => {\n    refs.forEach((ref) => {\n      if (typeof ref === \"function\") {\n        ref(value);\n      } else if (ref != null) {\n        (ref as React.MutableRefObject<T | null>).current = value;\n      }\n    });\n  };\n}\n"],"mappings":"opBAOA,IAAa,EACX,GAIG,CACH,GAAM,CAAE,UAAS,WAAU,GAAG,GAAsB,EAE9C,EAAS,EAAA,GAAmC,CA6BlD,OACE,EAAA,EAAA,KAAC,EAAA,EAAD,CAA2B,WAAA,EAAA,EAAA,aA1BzB,EAAO,SAAU,GAAO,CACtB,GAAI,CAAC,EACH,OAIF,IAAM,GAAA,EAAA,EAAA,aAA0B,EAAS,EAAG,IAAI,CAChD,GAAI,CAAC,EACH,OAGF,GAAM,CAAE,QAAS,EAAO,gBAAgB,SACtC,EAAY,cAAgB,EAC7B,CACK,gBAAgB,QAItB,MAAO,CACL,QAAS,EACV,EACD,CACJ,CAAC,EAAQ,EAAQ,CAClB,CAGuC,GAAI,WACvC,IAAY,IAAA,IAAa,EACX,CAAA,EC/BR,EAKX,GACG,CACH,IAAM,EAAa,EAAA,GAAsB,CACnC,EAAO,EAAA,GAAe,CAEtB,EAAS,EAAA,GAA6B,CAEtC,EAAQ,EAAO,SAAS,EAAM,QAAQ,CAEtC,CAAC,EAAY,IAAA,EAAA,EAAA,UAAkC,GAAG,CAElD,GAAA,EAAA,EAAA,aACH,GAAyC,CACx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