{"version":3,"sources":["../src/index.tsx","../src/entry/index.tsx","../src/convert/parse/index.ts","../node_modules/devlop/lib/default.js","../node_modules/mdast-util-gfm-table/lib/index.js","../src/convert/parse/custom-gfm.ts","../src/convert/utils.ts","../src/convert/parse/parse-blockquote.ts","../src/convert/parse/parse-code-block.ts","../src/convert/parse/parse-footnote-definition.ts","../src/convert/parse/parse-phrasing-content/normalize-segments.ts","../src/convert/parse/parse-phrasing-content/normalize-segment.ts","../src/convert/serialize/serialize-line/utils/is-utils.ts","../src/convert/serialize/serialize-line/utils/mark-utils/mark-convert-utils.ts","../src/convert/serialize/serialize-line/utils/mark-utils/mark-get-utils.ts","../src/convert/serialize/serialize-line/utils/mark-utils/mark-order-utils.ts","../src/convert/serialize/serialize-line/utils/text-utils.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/parse-generic-image.ts","../src/convert/parseUrl.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/parse-utils.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/parse-portive-image.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/parse-uncommon-mark-image.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/image-parsers.ts","../src/convert/parse/parse-phrasing-content/parse-inline-image/index.ts","../src/convert/parse/parse-phrasing-content/parse-phrasing-content.ts","../src/convert/parse/parse-heading.ts","../src/convert/parse/parse-html.ts","../src/convert/parse/parse-list/parse-list-item-child.ts","../src/convert/parse/parse-list/parse-list-item.ts","../src/convert/parse/parse-list/parse-list.ts","../src/convert/parse/parse-paragraph.ts","../src/convert/parse/parse-table.ts","../src/convert/parse/parse-thematic-break.ts","../src/convert/parse/parse-content.ts","../src/convert/parse/transform-inline-links.ts","../src/convert/serialize/normalize/normalizeElementListDepths.ts","../src/convert/serialize/serialize-code-block/serialize-code-line.ts","../src/convert/serialize/serialize-code-block/index.ts","../src/convert/serialize/serialize-image-shared/serialize-generic-image-url.ts","../src/convert/serialize/serialize-image-shared/serialize-portive-image-url.ts","../src/convert/serialize/serialize-image-shared/serialize-uncommonmark-image-url.ts","../src/convert/serialize/serialize-image-shared/index.ts","../src/convert/serialize/serialize-image-block/index.ts","../src/convert/serialize/serialize-line/serialize-line.ts","../src/convert/serialize/serialize-line/diff-marks/find-marks-to-add.ts","../src/convert/serialize/serialize-line/diff-marks/find-marks-to-remove.ts","../src/convert/serialize/serialize-line/diff-marks/index.ts","../src/convert/serialize/serialize-line/normalize-line/index.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/merge-adjacent-spaces.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/move-spaces-out-of-anchors.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/must-have-one-text-child.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/slice-spaces-at-node-boundaries.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/trim-spaces-at-end-of-line.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/trim-spaces-at-start-of-line.ts","../src/convert/serialize/serialize-line/normalize-line/normalizers/index.ts","../src/convert/serialize/serialize-line/normalize-line/run-normalizers-on-node.ts","../src/convert/serialize/serialize-line/normalize-line/normalize-nodes.ts","../src/convert/serialize/serialize-line/segment/serialize-segment.ts","../src/convert/serialize/serialize-line/segment/serialize-code-text.ts","../src/convert/serialize/serialize-line/segment/serialize-anchor.ts","../src/convert/serialize/serialize-line/segment/serialize-non-code-text.ts","../src/convert/serialize/serialize-table/index.ts","../src/convert/serialize/serialize-element.ts","../src/convert/serialize/serialize-elements.ts","../src/convert/serialize/index.ts","../src/utils/translations.ts","../src/sink/create-plugin/index.ts","../src/sink/editable/index.tsx","../src/sink/editable/utils.ts","../src/sink/editable/create-decorate.ts","../src/sink/editable/create-editable.tsx","../src/sink/editable/create-handler.ts","../src/sink/editable/create-render-element.ts","../src/sink/editable/create-render-leaf.ts","../src/sink/editable/create-render-placeholder.tsx","../src/sink/editable/styles.tsx","../src/sink/editor/create-boolean-action.ts","../src/sink/editor/create-void-action.ts","../src/sink/editor/index.ts","../src/sink/create-sink/index.tsx","../src/sink/is-debug.ts","../src/sink/utils/core-utils/better-at.ts","../src/sink/utils/core-utils/curry.ts","../src/sink/utils/core-utils/is-mac.ts","../src/sink/utils/core-utils/stop-event.ts","../src/sink/utils/find-utils/find-element-up.ts","../src/sink/utils/standardize-utils/standardize-node-matcher.ts","../src/sink/utils/icon-utils/tabler-icon.tsx","../src/sink/utils/is-utils/is-collapsed.ts","../src/sink/utils/is-utils/is-element-type.ts","../src/sink/utils/is-utils/is-end-of-element.ts","../src/sink/utils/is-utils/is-in-empty-element.ts","../src/sink/utils/is-utils/is-start-of-element.ts","../src/sink/utils/key-utils/create-autocomplete-space-handler.tsx","../src/sink/utils/key-utils/is-better-hotkey.ts","../src/sink/utils/key-utils/create-hotkey-handler.ts","../src/sink/utils/normalize-utils/force-normalize-path.ts","../src/sink/utils/normalize-utils/normalize-siblings.ts","../src/sink/utils/select-utils/index.ts","../src/sink/utils/standardize-utils/target-element.ts","../src/sink/utils/transform-utils/insert-root-element.ts","../src/sink/utils/transform-utils/rewrap-element.ts","../src/sink/utils/transform-utils/set-nodes-dynamic.ts","../src/anchor-plugin/editable/on-paste.tsx","../src/anchor-plugin/methods/editLink.ts","../src/anchor-plugin/methods/insertLink.ts","../src/anchor-plugin/methods/removeLink.ts","../src/anchor-plugin/methods/index.ts","../src/anchor-plugin/normalize-node/index.ts","../src/anchor-plugin/render-element/anchor.tsx","../src/use-layer/layers.tsx","../src/use-layer/portal.tsx","../src/use-layer/use-layer.tsx","../src/anchor-plugin/styles.tsx","../src/anchor-plugin/render-element/AnchorDialog.tsx","../src/shared-overlays/components/CloseMask/index.tsx","../src/shared-overlays/styles/$CloseMask.tsx","../src/shared-overlays/components/Menu/formatHotkey.ts","../src/shared-overlays/components/Menu/Menu.tsx","../src/use-reposition/get-methods/get-fixed-rect.ts","../src/use-reposition/get-methods/get-absolute-rect.ts","../src/use-reposition/get-methods/get-fixed-viewport.ts","../src/use-reposition/get-methods/get-absolute-viewport.ts","../node_modules/just-map-values/index.mjs","../src/use-reposition/utils.ts","../src/use-reposition/hooks/use-reposition.tsx","../src/use-reposition/hooks/use-throttled-refresh.ts","../src/use-reposition/hooks/use-absolute-reposition.tsx","../src/use-reposition/position-methods/index.ts","../src/toolbar-plugin/styles/anchor-dialog-styles.ts","../src/shared-overlays/styles/$Panel.ts","../src/toolbar-plugin/styles/layout-styles.ts","../src/shared-layout/index.ts","../src/toolbar-plugin/styles/menu-styles.ts","../src/toolbar-plugin/styles/toolbar-styles.ts","../src/shared-overlays/components/Menu/MenuItem.tsx","../src/use-tooltip/index.tsx","../src/use-tooltip/tooltip.tsx","../src/use-tooltip/triangle.tsx","../src/anchor-plugin/render-element/AnchorEditDialog.tsx","../src/shared-styles/index.ts","../src/toolbar-plugin/components/dialog/DraggableHeader.tsx","../src/anchor-plugin/render-element/icons.tsx","../src/anchor-plugin/index.tsx","../src/atomic-delete-plugin/index.ts","../src/atomic-delete-plugin/is-safe-delete.ts","../src/image-plugin/index.tsx","../src/image-plugin/methods/index.ts","../src/image-plugin/normalize-node/index.ts","../src/image-plugin/render-element/image-block.tsx","../src/image-plugin/styles/image-block-styles.tsx","../src/image-plugin/render-element/image-with-controls/index.tsx","../src/image-plugin/styles/image-with-controls-styles/image-with-controls-styles.tsx","../src/image-plugin/render-element/image-with-controls/image-resize-controls/image-resize-control.tsx","../src/use-reposition/hooks/use-resize-browser.tsx","../src/image-plugin/styles/image-with-controls-styles/image-resize-handle-styles.tsx","../src/image-plugin/utils/min-max.ts","../src/image-plugin/utils/resize-utils.ts","../src/image-plugin/styles/image-with-controls-styles/image-size-status-styles.tsx","../src/image-plugin/render-element/image-with-controls/image-size-status/image-size-status.tsx","../src/image-plugin/styles/image-with-controls-styles/image-toolbar-styles.tsx","../src/image-plugin/styles/image-with-controls-styles/image-buttons-styles.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-preset-buttons/image-preset-button.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-preset-buttons/image-preset-button-group.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/block-image-type-button.tsx","../src/image-plugin/render-element/icons.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-inline-image.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/inline-image-type-button.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/convert-to-block-image.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-type-buttons/image-type-button-group.tsx","../src/image-plugin/render-element/image-with-controls/image-toolbar/image-toolbar.tsx","../src/image-plugin/render-element/image-inline.tsx","../src/image-plugin/styles/image-inline-styles.tsx","../src/image-plugin/render-element/index.tsx","../src/block-quote-plugin/index.tsx","../src/block-quote-plugin/styles.tsx","../src/code-block-plugin/index.tsx","../src/code-block-plugin/decorate.tsx","../src/code-block-plugin/methods/createCodeBlock.ts","../src/code-block-plugin/methods/setCodeBlockLanguage.ts","../src/code-block-plugin/methods/index.ts","../src/code-block-plugin/prism-theme.ts","../src/code-block-plugin/types.tsx","../src/code-block-plugin/normalizeNode.tsx","../src/code-block-plugin/render-element/CodeBlock.tsx","../src/code-block-plugin/icons/ChevronDownIcon.tsx","../src/code-block-plugin/styles.ts","../src/code-block-plugin/render-element/CodeBlockLine.tsx","../src/code-block-plugin/render-element/index.tsx","../src/html-block-plugin/index.tsx","../src/html-block-plugin/styles.ts","../src/html-block-plugin/render-element.tsx","../src/collapsible-paragraph-plugin/normalize-node/index.ts","../src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-paragraphs.ts","../src/collapsible-paragraph-plugin/normalize-node/normalize-sibling-walls.ts","../src/collapsible-paragraph-plugin/render-element/paragraph.tsx","../src/collapsible-paragraph-plugin/render-element/styles.ts","../src/collapsible-paragraph-plugin/render-element/utils.ts","../src/collapsible-paragraph-plugin/index.tsx","../src/convert-element-plugin/methods/add-convert-element-type.ts","../src/convert-element-plugin/methods/convert-elements.ts","../src/convert-element-plugin/methods/is-convert-element.ts","../src/convert-element-plugin/methods/index.ts","../src/convert-element-plugin/index.tsx","../src/heading-plugin/insert-break.ts","../src/heading-plugin/methods/index.ts","../src/heading-plugin/styles.ts","../src/heading-plugin/index.tsx","../src/horizontal-rule-plugin/horizontal-rule.tsx","../src/horizontal-rule-plugin/styles.tsx","../src/horizontal-rule-plugin/methods/index.ts","../src/horizontal-rule-plugin/index.tsx","../src/inline-code-plugin/styles.ts","../src/inline-code-plugin/index.tsx","../src/list-plugin/index.tsx","../src/list-plugin/methods/convert-list-item.ts","../src/list-plugin/methods/depth.ts","../src/list-plugin/methods/indent.ts","../src/list-plugin/methods/insert-break.ts","../src/list-plugin/methods/outdent.ts","../src/list-plugin/methods/toggleTaskListItem.ts","../src/list-plugin/methods/index.ts","../src/list-plugin/normalize-node/normalize-ordered-first-at-depth.ts","../src/list-plugin/normalize-node/index.ts","../src/list-plugin/render-element/ordered-list-item.tsx","../src/list-plugin/render-element/styles.ts","../src/list-plugin/render-element/task-list-item.tsx","../src/list-plugin/render-element/list-icons.tsx","../src/list-plugin/render-element/unordered-list-item.tsx","../src/list-plugin/render-element/index.tsx","../src/marks-plugin/index.tsx","../src/marks-plugin/methods/removeMarks.ts","../src/marks-plugin/methods/toggle-mark.ts","../src/marks-plugin/methods/index.ts","../src/marks-plugin/styles.tsx","../src/normalize-after-delete-plugin/index.tsx","../src/table-plugin/index.tsx","../src/table-plugin/delete-fragment/index.ts","../src/table-plugin/delete-fragment/get-reversed-delete-safe-ranges.ts","../src/table-plugin/methods/index.ts","../src/table-plugin/methods/get-table-info.ts","../src/table-plugin/methods/insert-column.ts","../src/table-plugin/methods/utils.ts","../src/table-plugin/methods/insert-row.ts","../src/table-plugin/methods/insert-table.ts","../src/table-plugin/methods/navigation/select-element.ts","../src/table-plugin/methods/navigation/utils.ts","../src/table-plugin/methods/navigation/index.ts","../src/table-plugin/methods/remove-column.ts","../src/table-plugin/methods/remove-table.ts","../src/table-plugin/methods/remove-row.ts","../src/table-plugin/methods/setTableColumnAlign.ts","../src/table-plugin/methods/tab.ts","../src/table-plugin/normalize/normalize-table.ts","../src/table-plugin/normalize/normalize-table-cell.ts","../src/table-plugin/render-element/table.tsx","../src/table-plugin/render-element/styles/index.ts","../src/table-plugin/render-element/styles/table-menu-styles.ts","../src/table-plugin/render-element/table-context.tsx","../src/table-plugin/render-element/table-cell/index.tsx","../src/table-plugin/render-element/table-cell/column-menu/index.tsx","../src/table-plugin/icons.tsx","../src/table-plugin/render-element/table-cell/row-menu/index.tsx","../src/table-plugin/render-element/table-cell/table-menu/$table-menu.tsx","../src/table-plugin/render-element/table-cell/table-menu/index.tsx","../src/table-plugin/render-element/table-content.tsx","../src/table-plugin/render-element/table-row.tsx","../src/table-plugin/render-element/index.tsx","../src/theme-plugin/index.tsx","../src/theme-plugin/global-styles.ts","../src/toolbar-plugin/render-editable/index.tsx","../src/toolbar-plugin/components/dialog/table-dialog.tsx","../src/toolbar-plugin/styles/table-styles.ts","../src/toolbar-plugin/components/toolbar/toolbar.tsx","../src/toolbar-plugin/icons.tsx","../src/toolbar-plugin/items/block-items.tsx","../src/toolbar-plugin/components/dialog/image-url-dialog.tsx","../src/toolbar-plugin/styles/file-dialog-styles.ts","../src/toolbar-plugin/components/dialog/anchor-dialog.tsx","../src/toolbar-plugin/styles/dialog-shared-styles.ts","../src/toolbar-plugin/items/dialogItems.tsx","../src/toolbar-plugin/items/mark-items.tsx","../src/toolbar-plugin/items/list-items.tsx","../src/toolbar-plugin/items/quote-items.tsx","../src/toolbar-plugin/items/index.tsx","../src/toolbar-plugin/components/toolbar/toolbar-button.tsx","../src/toolbar-plugin/index.tsx","../src/trailing-block-plugin/index.tsx","../src/paste-markdown-plugin/methods/index.ts","../src/paste-markdown-plugin/index.tsx","../src/placeholder-plugin/index.tsx","../src/entry/plugins.ts","../src/entry/SinkEditable.tsx","../src/entry/useEditor.tsx"],"sourcesContent":["// Ensure this package is treated as a client component (e.g. in Next.js App Router)\n'use client'\n\nimport {\n  createRef,\n  RefObject,\n  useCallback,\n  useImperativeHandle,\n  useRef,\n  useState,\n} from \"react\"\nimport { createRoot } from \"react-dom/client\"\nimport { Editable, useEditor, OnImageChangeHandler } from './entry/index'\nimport { unescapeMarkdown } from './convert'\nimport type { UseEditorOptions } from './entry/useEditor'\n\nexport { Editable, useEditor, unescapeMarkdown }\nexport type { OnImageChangeHandler, UseEditorOptions }\n\n/**\n * The options passed into the standalone version of Wysimark.\n */\ntype StandaloneOptions = Parameters<typeof useEditor>[0] & {\n  onChange?: (markdown: string) => void\n  placeholder?: string\n  initialMarkdown?: string\n  className?: string\n}\n\ntype StandaloneMethods = {\n  getMarkdown: () => string\n  setMarkdown: (markdown: string) => void\n}\n\n/**\n * The object returned by `createWysimark`\n */\nexport type Wysimark = {\n  unmount: () => void\n  getMarkdown: () => string\n  setMarkdown: (markdown: string) => void\n}\n\nfunction StandaloneEditor({\n  standaloneOptions: { onChange, placeholder, className, ...options },\n  standaloneMethodsRef,\n}: {\n  standaloneOptions: StandaloneOptions\n  standaloneMethodsRef: RefObject<StandaloneMethods | null>\n}) {\n  const [markdown, setMarkdown] = useState(options.initialMarkdown || \"\")\n  const markdownRef = useRef(markdown)\n  const editor = useEditor(options)\n\n  markdownRef.current = markdown\n\n  useImperativeHandle(\n    standaloneMethodsRef,\n    () => {\n      return {\n        getMarkdown() {\n          return markdownRef.current\n        },\n        setMarkdown(markdown: string) {\n          markdownRef.current = markdown\n          setMarkdown(markdown)\n        },\n      }\n    },\n    [markdownRef, setMarkdown]\n  )\n\n  const onChangeEditable = useCallback(\n    (markdown: string) => {\n      /**\n       * Setting the ref is important in the case where there is an attempt to\n       * call the `getMarkdown` method from `onChange`. Otherwise the `ref`\n       * doesn't get updated until the next render which happens sometime after\n       * the `onChange` callback is called.\n       */\n      markdownRef.current = markdown\n      setMarkdown(markdown)\n      onChange?.(markdown)\n    },\n    [editor]\n  )\n\n  return (\n    <Editable\n      editor={editor}\n      value={markdown}\n      className={className || \"\"}\n      onChange={onChangeEditable}\n      placeholder={placeholder}\n    />\n  )\n}\n\n/**\n * The primary entry point for the standalone version of Wysimark.\n */\nexport function createWysimark(\n  containerElement: HTMLElement,\n  options: StandaloneOptions\n): Wysimark {\n  const standaloneMethodsRef = createRef<StandaloneMethods | null>()\n\n  const root = createRoot(containerElement)\n\n  root.render(\n    <StandaloneEditor\n      standaloneMethodsRef={standaloneMethodsRef}\n      standaloneOptions={options}\n    />\n  )\n\n  return {\n    unmount() {\n      try {\n        root.unmount()\n      } catch {\n        /* ignore */\n      }\n    },\n    getMarkdown() {\n      return standaloneMethodsRef.current?.getMarkdown() || \"\"\n      // const markdown = editorRef.current?.getMarkdown()\n      // return typeof markdown === \"string\"\n      //   ? markdown\n      //   : options.initialMarkdown || \"\"\n    },\n    setMarkdown(markdown: string) {\n      standaloneMethodsRef.current?.setMarkdown(markdown)\n    },\n  }\n}\n","import throttle from \"lodash.throttle\"\nimport { useCallback, useRef, useState } from \"react\"\nimport { Descendant, Editor, Element, Transforms } from \"slate\"\nimport { ReactEditor, RenderLeafProps, Slate } from \"slate-react\"\n\nimport { parse, serialize, escapeUrlSlashes, unescapeUrlSlashes } from \"../convert\"\nimport { t } from \"../utils/translations\"\nimport { SinkEditable } from \"./SinkEditable\"\nimport { useEditor } from \"./useEditor\"\n\nexport type { Element, Text } from \"./plugins\"\n\nexport { useEditor }\n\nfunction renderLeaf({ children, attributes }: RenderLeafProps) {\n  return <span {...attributes}>{children}</span>\n}\n\nimport type { OnImageChangeHandler, OnFileSelectHandler } from \"./types\"\nexport type { OnImageChangeHandler, OnFileSelectHandler } from \"./types\"\n\nexport type EditableProps = {\n  editor: Editor\n  value: string\n  onChange: (markdown: string) => void\n  throttleInMs?: number\n  placeholder?: string\n  className?: string\n  style?: React.CSSProperties\n  onImageChange?: OnImageChangeHandler\n  onFileSelect?: OnFileSelectHandler\n}\n\nexport function Editable({\n  editor,\n  value,\n  onChange,\n  throttleInMs = 1000,\n  placeholder,\n  className,\n  style,\n  onImageChange,\n  onFileSelect,\n}: EditableProps) {\n  const [isRawMode, setIsRawMode] = useState(false)\n  const [rawText, setRawText] = useState(value)\n  const ignoreNextChangeRef = useRef<boolean>(false)\n  const initialValueRef = useRef<Descendant[] | undefined>(undefined)\n  const prevValueRef = useRef<Descendant[] | undefined>(undefined)\n  // Store rawText to use when switching back to visual mode\n  const pendingRawTextRef = useRef<string | null>(null)\n\n  const onChangeRef = useRef(onChange)\n  onChangeRef.current = onChange\n\n  // eslint-disable-next-line react-hooks/exhaustive-deps\n  const onThrottledSlateChange = useCallback(\n    throttle(\n      () => {\n        const markdown = serialize(editor.children as Element[])\n        editor.wysimark.prevValue = {\n          markdown,\n          children: editor.children,\n        }\n        onChangeRef.current(markdown)\n      },\n      throttleInMs,\n      { leading: false, trailing: true }\n    ),\n    [editor, throttleInMs]\n  )\n\n  /* eslint-disable react-hooks/exhaustive-deps */\n  const onSlateChange = useCallback(() => {\n    if (prevValueRef.current === editor.children) {\n      return\n    }\n    prevValueRef.current = editor.children\n    onThrottledSlateChange()\n  }, [onThrottledSlateChange])\n  /* eslint-enable react-hooks/exhaustive-deps */\n\n  // Skip parsing when in raw mode - only update when in visual mode\n  if (!isRawMode) {\n    // Use pendingRawText if we just switched from raw mode\n    const markdownToUse = pendingRawTextRef.current ?? value\n    if (pendingRawTextRef.current !== null) {\n      pendingRawTextRef.current = null\n    }\n\n    if (editor.wysimark.prevValue == null || initialValueRef.current == null) {\n      ignoreNextChangeRef.current = true\n      const valueToProcess = escapeUrlSlashes(markdownToUse);\n      const children = parse(valueToProcess)\n      editor.children = children\n      prevValueRef.current = initialValueRef.current = children\n      editor.wysimark.prevValue = {\n        markdown: markdownToUse,\n        children,\n      }\n    } else {\n      if (markdownToUse !== editor.wysimark.prevValue.markdown) {\n        ignoreNextChangeRef.current = true\n        const valueToProcess = escapeUrlSlashes(markdownToUse);\n        const documentValue = parse(valueToProcess)\n        editor.children = documentValue\n        editor.selection = null\n        Transforms.select(editor, Editor.start(editor, [0]))\n      }\n    }\n  }\n\n  const onSinkeEditableMouseDown = useCallback(() => {\n    if (navigator.userAgent.toLowerCase().includes(\"firefox\")) {\n      ReactEditor.focus(editor)\n    }\n  }, [editor])\n\n  const onBlur = useCallback(() => {\n    onThrottledSlateChange.flush()\n  }, [onThrottledSlateChange])\n\n  // Handle raw text change\n  const handleRawTextChange = (e: React.ChangeEvent<HTMLTextAreaElement>) => {\n    const newText = e.target.value;\n    setRawText(newText);\n    onChange(newText);\n  }\n\n  // When switching from visual mode to raw mode\n  const updateRawTextFromEditor = useCallback(() => {\n    const currentMarkdown = editor.getMarkdown();\n    setRawText(currentMarkdown);\n  }, [editor]);\n\n  // Handle mode toggle\n  const handleRawModeToggle = () => {\n    if (isRawMode) {\n      // Switching from raw mode to visual mode\n      // Store rawText to use for initialization\n      pendingRawTextRef.current = rawText\n      // Reset initialization refs so the editor re-initializes\n      editor.wysimark.prevValue = undefined\n      initialValueRef.current = undefined\n      prevValueRef.current = undefined\n    } else {\n      // Switching from visual mode to raw mode\n      updateRawTextFromEditor();\n    }\n    setIsRawMode(!isRawMode);\n  };\n\n  editor.wysimark.onImageChange = onImageChange;\n  editor.wysimark.onFileSelect = onFileSelect;\n\n  // Check if raw mode is disabled\n  const disableRawMode = editor.wysimark.disableRawMode\n\n  return (\n    <div style={{ position: 'relative', display: 'flex', flexDirection: 'column', flex: 1, minHeight: 0 }}>\n      {/* Raw mode toggle button - only show if not disabled */}\n      {!disableRawMode && (\n        <div style={{ position: 'absolute', top: '5px', right: '25px', zIndex: 10 }}>\n          <div\n            onClick={handleRawModeToggle}\n            style={{\n              background: 'none',\n              border: isRawMode ? '1px solid #4a90e2' : '1px solid transparent',\n              cursor: 'pointer',\n              padding: '6px',\n              borderRadius: '4px',\n              backgroundColor: isRawMode ? 'rgba(74, 144, 226, 0.1)' : 'transparent',\n              boxShadow: isRawMode ? '0 1px 3px rgba(0, 0, 0, 0.1)' : 'none',\n              transition: 'all 0.2s ease-in-out',\n              display: 'flex',\n              alignItems: 'center',\n              justifyContent: 'center'\n            }}\n            title={isRawMode ? t(\"switchToVisualEditor\") : t(\"switchToRawMarkdown\")}\n            role=\"button\"\n            tabIndex={0}\n            onKeyDown={(e) => {\n              if (e.key === 'Enter' || e.key === ' ') {\n                handleRawModeToggle();\n                e.preventDefault();\n              }\n            }}\n          >\n            <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n              <rect\n                x=\"3\"\n                y=\"3\"\n                width=\"18\"\n                height=\"18\"\n                rx=\"2\"\n                stroke={isRawMode ? \"#4a90e2\" : \"currentColor\"}\n                strokeWidth=\"1.5\"\n                fill={isRawMode ? \"rgba(74, 144, 226, 0.05)\" : \"transparent\"}\n              />\n              <path\n                d=\"M7 15V9L10 12L13 9V15\"\n                stroke={isRawMode ? \"#4a90e2\" : \"currentColor\"}\n                strokeWidth=\"1.5\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n              />\n              <path\n                d=\"M16 9H18V15\"\n                stroke={isRawMode ? \"#4a90e2\" : \"currentColor\"}\n                strokeWidth=\"1.5\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n              />\n              <path\n                d=\"M16 12H18\"\n                stroke={isRawMode ? \"#4a90e2\" : \"currentColor\"}\n                strokeWidth=\"1.5\"\n                strokeLinecap=\"round\"\n                strokeLinejoin=\"round\"\n              />\n            </svg>\n          </div>\n        </div>\n      )}\n\n      {/* Raw mode textarea - always in DOM but hidden when not in raw mode */}\n      <div style={{ display: isRawMode ? 'block' : 'none', textAlign: 'center' }}>\n        <textarea\n          value={unescapeUrlSlashes(rawText)}\n          onChange={handleRawTextChange}\n          placeholder={placeholder}\n          className={className}\n          style={{\n            width: 'calc(100% - 60px)',\n            margin: '0 auto',\n            minHeight: '200px',\n            padding: '20px',\n            fontFamily: 'monospace',\n            fontSize: '1rem',\n            color: '#333',\n            lineHeight: '1.5',\n            backgroundColor: '#fff',\n            border: '1px solid #ddd',\n            borderRadius: '4px',\n            ...style\n          }}\n        />\n      </div>\n\n      {/* Visual editor - always in DOM but hidden when in raw mode */}\n      <div style={{ display: isRawMode ? 'none' : 'flex', flexDirection: 'column', flex: 1, minHeight: 0 }}>\n        <Slate\n          editor={editor}\n          initialValue={initialValueRef.current as Descendant[]}\n          onChange={onSlateChange}\n        >\n          <SinkEditable\n            renderLeaf={renderLeaf}\n            onMouseDown={onSinkeEditableMouseDown}\n            onBlur={onBlur}\n            placeholder={placeholder}\n            className={className}\n            style={style}\n          />\n        </Slate>\n      </div>\n    </div>\n  )\n}\n","import type { Root, TopLevelContent } from \"mdast\"\nimport remarkParse from \"remark-parse\"\nimport { unified } from \"unified\"\n\nimport { Element } from \"../types\"\nimport { customRemarkGfm } from \"./custom-gfm\"\nimport { parseContents } from \"./parse-content\"\nimport { transformInlineLinks } from \"./transform-inline-links\"\n\n// @ts-expect-error - Ignore TypeScript errors for the unified plugin system\nconst parser = unified().use(remarkParse).use(customRemarkGfm())\n\nexport function parseToAst(markdown: string) {\n  const ast = parser.parse(markdown) as Root\n  /**\n   * Takes linkReference and imageReference and turns them into link and image.\n   */\n  transformInlineLinks(ast)\n  return ast\n}\n\n/**\n * Takes a Markdown string as input and returns a remarkParse AST\n */\nexport function parse(markdown: string): Element[] {\n  const ast = parseToAst(markdown)\n  /**\n   * If there is no content, remark returns a root ast with no children (i.e.\n   * no paragraphs) but for Slate, we need it to return an empty paragraph.\n   *\n   * So when this happens, we just generate an empty paragraph and return that\n   * s he result.\n   */\n  if (ast.children.length === 0) {\n    return [{ type: \"paragraph\", children: [{ text: \"\" }] }] as Element[]\n  }\n\n  return parseContents(ast.children as TopLevelContent[])\n}\n","export function deprecate(fn) {\n  return fn\n}\n\nexport function equal() {}\n\nexport function ok() {}\n\nexport function unreachable() {}\n","/**\n * @typedef {import('mdast').InlineCode} InlineCode\n * @typedef {import('mdast').Table} Table\n * @typedef {import('mdast').TableCell} TableCell\n * @typedef {import('mdast').TableRow} TableRow\n *\n * @typedef {import('markdown-table').Options} MarkdownTableOptions\n *\n * @typedef {import('mdast-util-from-markdown').CompileContext} CompileContext\n * @typedef {import('mdast-util-from-markdown').Extension} FromMarkdownExtension\n * @typedef {import('mdast-util-from-markdown').Handle} FromMarkdownHandle\n *\n * @typedef {import('mdast-util-to-markdown').Options} ToMarkdownExtension\n * @typedef {import('mdast-util-to-markdown').Handle} ToMarkdownHandle\n * @typedef {import('mdast-util-to-markdown').State} State\n * @typedef {import('mdast-util-to-markdown').Info} Info\n */\n\n/**\n * @typedef Options\n *   Configuration.\n * @property {boolean | null | undefined} [tableCellPadding=true]\n *   Whether to add a space of padding between delimiters and cells (default:\n *   `true`).\n * @property {boolean | null | undefined} [tablePipeAlign=true]\n *   Whether to align the delimiters (default: `true`).\n * @property {MarkdownTableOptions['stringLength'] | null | undefined} [stringLength]\n *   Function to detect the length of table cell content, used when aligning\n *   the delimiters between cells (optional).\n */\n\nimport {ok as assert} from 'devlop'\nimport {markdownTable} from 'markdown-table'\nimport {defaultHandlers} from 'mdast-util-to-markdown'\n\n/**\n * Create an extension for `mdast-util-from-markdown` to enable GFM tables in\n * markdown.\n *\n * @returns {FromMarkdownExtension}\n *   Extension for `mdast-util-from-markdown` to enable GFM tables.\n */\nexport function gfmTableFromMarkdown() {\n  return {\n    enter: {\n      table: enterTable,\n      tableData: enterCell,\n      tableHeader: enterCell,\n      tableRow: enterRow\n    },\n    exit: {\n      codeText: exitCodeText,\n      table: exitTable,\n      tableData: exit,\n      tableHeader: exit,\n      tableRow: exit\n    }\n  }\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterTable(token) {\n  const align = token._align\n  assert(align, 'expected `_align` on table')\n  this.enter(\n    {\n      type: 'table',\n      align: align.map(function (d) {\n        return d === 'none' ? null : d\n      }),\n      children: []\n    },\n    token\n  )\n  this.data.inTable = true\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitTable(token) {\n  this.exit(token)\n  this.data.inTable = undefined\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterRow(token) {\n  this.enter({type: 'tableRow', children: []}, token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exit(token) {\n  this.exit(token)\n}\n\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction enterCell(token) {\n  this.enter({type: 'tableCell', children: []}, token)\n}\n\n// Overwrite the default code text data handler to unescape escaped pipes when\n// they are in tables.\n/**\n * @this {CompileContext}\n * @type {FromMarkdownHandle}\n */\nfunction exitCodeText(token) {\n  let value = this.resume()\n\n  if (this.data.inTable) {\n    value = value.replace(/\\\\([\\\\|])/g, replace)\n  }\n\n  const node = this.stack[this.stack.length - 1]\n  assert(node.type === 'inlineCode')\n  node.value = value\n  this.exit(token)\n}\n\n/**\n * @param {string} $0\n * @param {string} $1\n * @returns {string}\n */\nfunction replace($0, $1) {\n  // Pipes work, backslashes don’t (but can’t escape pipes).\n  return $1 === '|' ? $1 : $0\n}\n\n/**\n * Create an extension for `mdast-util-to-markdown` to enable GFM tables in\n * markdown.\n *\n * @param {Options | null | undefined} [options]\n *   Configuration.\n * @returns {ToMarkdownExtension}\n *   Extension for `mdast-util-to-markdown` to enable GFM tables.\n */\nexport function gfmTableToMarkdown(options) {\n  const settings = options || {}\n  const padding = settings.tableCellPadding\n  const alignDelimiters = settings.tablePipeAlign\n  const stringLength = settings.stringLength\n  const around = padding ? ' ' : '|'\n\n  return {\n    unsafe: [\n      {character: '\\r', inConstruct: 'tableCell'},\n      {character: '\\n', inConstruct: 'tableCell'},\n      // A pipe, when followed by a tab or space (padding), or a dash or colon\n      // (unpadded delimiter row), could result in a table.\n      {atBreak: true, character: '|', after: '[\\t :-]'},\n      // A pipe in a cell must be encoded.\n      {character: '|', inConstruct: 'tableCell'},\n      // A colon must be followed by a dash, in which case it could start a\n      // delimiter row.\n      {atBreak: true, character: ':', after: '-'},\n      // A delimiter row can also start with a dash, when followed by more\n      // dashes, a colon, or a pipe.\n      // This is a stricter version than the built in check for lists, thematic\n      // breaks, and setex heading underlines though:\n      // <https://github.com/syntax-tree/mdast-util-to-markdown/blob/51a2038/lib/unsafe.js#L57>\n      {atBreak: true, character: '-', after: '[:|-]'}\n    ],\n    handlers: {\n      inlineCode: inlineCodeWithTable,\n      table: handleTable,\n      tableCell: handleTableCell,\n      tableRow: handleTableRow\n    }\n  }\n\n  /**\n   * @type {ToMarkdownHandle}\n   * @param {Table} node\n   */\n  function handleTable(node, _, state, info) {\n    return serializeData(handleTableAsData(node, state, info), node.align)\n  }\n\n  /**\n   * This function isn’t really used normally, because we handle rows at the\n   * table level.\n   * But, if someone passes in a table row, this ensures we make somewhat sense.\n   *\n   * @type {ToMarkdownHandle}\n   * @param {TableRow} node\n   */\n  function handleTableRow(node, _, state, info) {\n    const row = handleTableRowAsData(node, state, info)\n    const value = serializeData([row])\n    // `markdown-table` will always add an align row\n    return value.slice(0, value.indexOf('\\n'))\n  }\n\n  /**\n   * @type {ToMarkdownHandle}\n   * @param {TableCell} node\n   */\n  function handleTableCell(node, _, state, info) {\n    const exit = state.enter('tableCell')\n    const subexit = state.enter('phrasing')\n    const value = state.containerPhrasing(node, {\n      ...info,\n      before: around,\n      after: around\n    })\n    subexit()\n    exit()\n    return value\n  }\n\n  /**\n   * @param {Array<Array<string>>} matrix\n   * @param {Array<string | null | undefined> | null | undefined} [align]\n   */\n  function serializeData(matrix, align) {\n    return markdownTable(matrix, {\n      align,\n      // @ts-expect-error: `markdown-table` types should support `null`.\n      alignDelimiters,\n      // @ts-expect-error: `markdown-table` types should support `null`.\n      padding,\n      // @ts-expect-error: `markdown-table` types should support `null`.\n      stringLength\n    })\n  }\n\n  /**\n   * @param {Table} node\n   * @param {State} state\n   * @param {Info} info\n   */\n  function handleTableAsData(node, state, info) {\n    const children = node.children\n    let index = -1\n    /** @type {Array<Array<string>>} */\n    const result = []\n    const subexit = state.enter('table')\n\n    while (++index < children.length) {\n      result[index] = handleTableRowAsData(children[index], state, info)\n    }\n\n    subexit()\n\n    return result\n  }\n\n  /**\n   * @param {TableRow} node\n   * @param {State} state\n   * @param {Info} info\n   */\n  function handleTableRowAsData(node, state, info) {\n    const children = node.children\n    let index = -1\n    /** @type {Array<string>} */\n    const result = []\n    const subexit = state.enter('tableRow')\n\n    while (++index < children.length) {\n      // Note: the positional info as used here is incorrect.\n      // Making it correct would be impossible due to aligning cells?\n      // And it would need copy/pasting `markdown-table` into this project.\n      result[index] = handleTableCell(children[index], node, state, info)\n    }\n\n    subexit()\n\n    return result\n  }\n\n  /**\n   * @type {ToMarkdownHandle}\n   * @param {InlineCode} node\n   */\n  function inlineCodeWithTable(node, parent, state) {\n    let value = defaultHandlers.inlineCode(node, parent, state)\n\n    if (state.stack.includes('tableCell')) {\n      value = value.replace(/\\|/g, '\\\\$&')\n    }\n\n    return value\n  }\n}\n","import type { Plugin, Processor } from 'unified'\nimport { gfmTableFromMarkdown } from 'mdast-util-gfm-table'\nimport { gfm } from 'micromark-extension-gfm'\nimport { gfmToMarkdown } from 'mdast-util-gfm'\n\n// Internal type for unified processor data\ninterface ProcessorData {\n  micromarkExtensions?: unknown[];\n  fromMarkdownExtensions?: unknown[];\n  toMarkdownExtensions?: unknown[];\n}\n\n/**\n * Helper function to wrap a handler to ensure this.data is initialized\n */\nfunction wrapHandler(originalHandler: Function | undefined) {\n  if (!originalHandler) return undefined;\n  return function(this: any, token: any) {\n    if (!this.data) {\n      this.data = {};\n    }\n    return originalHandler.call(this, token);\n  };\n}\n\n/**\n * Custom wrapper around remark-gfm that ensures the data object is initialized\n * This fixes the \"Cannot read/set properties of undefined\" errors\n * that occur when parsing tables\n */\nexport function customRemarkGfm(): Plugin {\n  // Return a plugin function that initializes the data object\n  return function(this: Processor) {\n    // Make sure 'this' exists\n    if (!this) {\n      return;\n    }\n\n    // Initialize the data object on the processor\n    // Get the data object - unified processor's data() method returns the data object\n    const data = this.data() as ProcessorData;\n\n    // Initialize the extensions arrays if they don't exist\n    const micromarkExtensions = data.micromarkExtensions || (data.micromarkExtensions = []);\n    const fromMarkdownExtensions = data.fromMarkdownExtensions || (data.fromMarkdownExtensions = []);\n    const toMarkdownExtensions = data.toMarkdownExtensions || (data.toMarkdownExtensions = []);\n\n    // Add the GFM extensions\n    // We're using the original extensions from remark-gfm\n    micromarkExtensions.push(gfm());\n\n    // Create a patched version of gfmTableFromMarkdown\n    const patchedFromMarkdown = function() {\n      const extension = gfmTableFromMarkdown();\n\n      // Wrap all enter handlers to ensure this.data is initialized\n      if (extension.enter) {\n        for (const key of Object.keys(extension.enter)) {\n          (extension.enter as any)[key] = wrapHandler((extension.enter as any)[key]);\n        }\n      }\n\n      // Wrap all exit handlers to ensure this.data is initialized\n      if (extension.exit) {\n        for (const key of Object.keys(extension.exit)) {\n          (extension.exit as any)[key] = wrapHandler((extension.exit as any)[key]);\n        }\n      }\n\n      return extension;\n    };\n\n    // Add our patched extensions\n    fromMarkdownExtensions.push(patchedFromMarkdown());\n    toMarkdownExtensions.push(gfmToMarkdown());\n\n    return undefined; // Return undefined as the plugin doesn't need to return anything\n  }\n}\n","import { Element } from \"./types\"\n\n/**\n * Function to escape forward slashes in URLs, but only for plain text URLs (not in markdown links or HTML blocks)\n * This is necessary because the markdown parser doesn't handle unescaped forward slashes in URLs correctly\n */\nexport function escapeUrlSlashes(text: string): string {\n  // First, we need to identify markdown links to exclude them\n  const markdownLinkPattern = /\\[([^\\]]+)\\]\\(([^)]+)\\)/g;\n  const placeholderPrefix = \"\\u0007WYSIMARK_\";\n  const linkPrefix = `${placeholderPrefix}LINK_`;\n  const htmlPrefix = `${placeholderPrefix}HTML_`;\n  const placeholderSuffix = \"\\u0007\";\n\n  // Store the markdown links to restore them later\n  const links: string[] = [];\n  let linkIndex = 0;\n\n  // Replace markdown links with placeholders\n  let result = text.replace(markdownLinkPattern, (match) => {\n    links.push(match);\n    return `${linkPrefix}${linkIndex++}${placeholderSuffix}`;\n  });\n\n  // Also exclude HTML blocks (tags plus their contents when a closing tag exists)\n  const htmlBlocks: string[] = [];\n  const masked = maskHtmlBlocks(result, htmlBlocks, htmlPrefix, placeholderSuffix);\n  result = masked;\n\n  // URL regex pattern to identify plain text URLs\n  const urlPattern = /(https?:\\/\\/[^\\s]+)/g;\n\n  // Escape forward slashes in plain text URLs\n  result = result.replace(urlPattern, (url) => {\n    return url.replace(/\\//g, '\\\\/');\n  });\n\n  // Restore HTML blocks first (they may contain markdown links placeholders)\n  for (let i = 0; i < htmlBlocks.length; i++) {\n    result = result.replace(\n      `${htmlPrefix}${i}${placeholderSuffix}`,\n      htmlBlocks[i]\n    );\n  }\n\n  // Restore the markdown links\n  for (let i = 0; i < links.length; i++) {\n    result = result.replace(\n      `${linkPrefix}${i}${placeholderSuffix}`,\n      links[i]\n    );\n  }\n\n  return result;\n}\n\n/**\n * Function to unescape forward slashes in URLs that were previously escaped\n * This is used when switching to raw mode to display the unescaped markdown\n */\nexport function unescapeUrlSlashes(text: string): string {\n  // Only unescape forward slashes that we previously escaped.\n  return text.replace(/\\\\\\//g, \"/\");\n}\n\n/**\n * Remove inline escape backslashes added by the serializer's escapeText.\n * Matches `\\` followed by any of: \\ ` * _ [ ] ~ | <\n * and replaces with just the character itself.\n */\nexport function unescapeMarkdown(text: string): string {\n  return text.replace(/\\\\([\\\\`*_\\[\\]~|<])/g, '$1');\n}\n\ntype TagInfo = {\n  name: string | null\n  endIndex: number\n  isClosing: boolean\n  isSelfClosing: boolean\n}\n\nconst RAW_TEXT_TAGS = new Set([\"script\", \"style\"])\n\nfunction maskHtmlBlocks(\n  text: string,\n  htmlBlocks: string[],\n  htmlPrefix: string,\n  placeholderSuffix: string\n): string {\n  let output = \"\"\n  let index = 0\n\n  while (index < text.length) {\n    const ltIndex = text.indexOf(\"<\", index)\n    if (ltIndex === -1) {\n      output += text.slice(index)\n      break\n    }\n\n    output += text.slice(index, ltIndex)\n\n    if (text.startsWith(\"<!--\", ltIndex)) {\n      const end = text.indexOf(\"-->\", ltIndex + 4)\n      if (end === -1) {\n        output += text.slice(ltIndex)\n        break\n      }\n      const block = text.slice(ltIndex, end + 3)\n      htmlBlocks.push(block)\n      output += `${htmlPrefix}${htmlBlocks.length - 1}${placeholderSuffix}`\n      index = end + 3\n      continue\n    }\n\n    if (text.startsWith(\"<![CDATA[\", ltIndex)) {\n      const end = text.indexOf(\"]]>\", ltIndex + 9)\n      if (end === -1) {\n        output += text.slice(ltIndex)\n        break\n      }\n      const block = text.slice(ltIndex, end + 3)\n      htmlBlocks.push(block)\n      output += `${htmlPrefix}${htmlBlocks.length - 1}${placeholderSuffix}`\n      index = end + 3\n      continue\n    }\n\n    const tag = parseTag(text, ltIndex)\n    if (!tag) {\n      output += \"<\"\n      index = ltIndex + 1\n      continue\n    }\n\n    const blockIndex = htmlBlocks.length\n    const placeholder = `${htmlPrefix}${blockIndex}${placeholderSuffix}`\n\n    if (!tag.name) {\n      const block = text.slice(ltIndex, tag.endIndex + 1)\n      htmlBlocks.push(block)\n      output += placeholder\n      index = tag.endIndex + 1\n      continue\n    }\n\n    const tagName = tag.name.toLowerCase()\n\n    if (tag.isClosing || tag.isSelfClosing) {\n      const block = text.slice(ltIndex, tag.endIndex + 1)\n      htmlBlocks.push(block)\n      output += placeholder\n      index = tag.endIndex + 1\n      continue\n    }\n\n    if (RAW_TEXT_TAGS.has(tagName)) {\n      const closeStart = text.toLowerCase().indexOf(`</${tagName}`, tag.endIndex + 1)\n      if (closeStart !== -1) {\n        const closeTag = parseTag(text, closeStart)\n        if (closeTag) {\n          const block = text.slice(ltIndex, closeTag.endIndex + 1)\n          htmlBlocks.push(block)\n          output += placeholder\n          index = closeTag.endIndex + 1\n          continue\n        }\n      }\n    }\n\n    const closingTagEnd = findClosingTagEnd(text, tagName, tag.endIndex + 1)\n    if (closingTagEnd !== null) {\n      const block = text.slice(ltIndex, closingTagEnd + 1)\n      htmlBlocks.push(block)\n      output += placeholder\n      index = closingTagEnd + 1\n      continue\n    }\n\n    const block = text.slice(ltIndex, tag.endIndex + 1)\n    htmlBlocks.push(block)\n    output += placeholder\n    index = tag.endIndex + 1\n  }\n\n  return output\n}\n\nfunction parseTag(text: string, startIndex: number): TagInfo | null {\n  if (text[startIndex] !== \"<\") return null\n  const endIndex = findTagEnd(text, startIndex)\n  if (endIndex === -1) return null\n\n  let cursor = startIndex + 1\n  if (cursor >= text.length) return null\n\n  const firstChar = text[cursor]\n  if (firstChar === \"!\" || firstChar === \"?\") {\n    return {\n      name: null,\n      endIndex,\n      isClosing: false,\n      isSelfClosing: true,\n    }\n  }\n\n  let isClosing = false\n  if (firstChar === \"/\") {\n    isClosing = true\n    cursor += 1\n  }\n\n  const nameMatch = /^[A-Za-z][A-Za-z0-9-]*/.exec(text.slice(cursor))\n  if (!nameMatch) return null\n\n  const name = nameMatch[0]\n  const tagText = text.slice(startIndex, endIndex + 1)\n  const isSelfClosing = /\\/\\s*>$/.test(tagText)\n\n  return {\n    name,\n    endIndex,\n    isClosing,\n    isSelfClosing,\n  }\n}\n\nfunction findTagEnd(text: string, startIndex: number): number {\n  let quote: \"'\" | '\"' | null = null\n  for (let i = startIndex + 1; i < text.length; i++) {\n    const char = text[i]\n    if (quote) {\n      if (char === quote) {\n        quote = null\n      }\n      continue\n    }\n    if (char === \"'\" || char === '\"') {\n      quote = char\n      continue\n    }\n    if (char === \">\") {\n      return i\n    }\n  }\n  return -1\n}\n\nfunction findClosingTagEnd(text: string, tagName: string, startIndex: number): number | null {\n  let depth = 1\n  let cursor = startIndex\n  const lowerTag = tagName.toLowerCase()\n\n  while (cursor < text.length) {\n    const ltIndex = text.indexOf(\"<\", cursor)\n    if (ltIndex === -1) return null\n\n    const tag = parseTag(text, ltIndex)\n    if (!tag || !tag.name) {\n      cursor = ltIndex + 1\n      continue\n    }\n\n    if (tag.name.toLowerCase() === lowerTag) {\n      if (tag.isClosing) {\n        depth -= 1\n      } else if (!tag.isSelfClosing) {\n        depth += 1\n      }\n      if (depth === 0) {\n        return tag.endIndex\n      }\n    }\n\n    cursor = tag.endIndex + 1\n  }\n\n  return null\n}\n\nexport function assert(pass: boolean, message: string) {\n  if (!pass) throw new Error(`${message}`)\n}\n\nexport function assertElementType(element: Element, type: Element[\"type\"]) {\n  if (element.type !== type)\n    throw new Error(\n      `Expected element to be of type ${JSON.stringify(\n        element\n      )} but is ${JSON.stringify(element, null, 2)}`\n    )\n}\n\nexport function assertUnreachable(x: never): never {\n  throw new Error(\n    `Didn't expect to get here with value ${JSON.stringify(x, null, 2)}`\n  )\n}\n","import type { Blockquote } from \"mdast\"\n\nimport { Element } from \"../types\"\nimport { parseContents } from \"./parse-content\"\n\nexport function parseBlockquote(content: Blockquote): Element[] {\n  return [{ type: \"block-quote\", children: parseContents(content.children) }]\n}\n","import type { Code } from \"mdast\"\n\nimport { Element } from \"../types\"\n\nexport function parseCodeBlock(content: Code): Element[] {\n  const codeLines = content.value.split(\"\\n\")\n  return [\n    {\n      type: \"code-block\",\n      language: content.lang || \"text\",\n      children: codeLines.map((codeLine) => ({\n        type: \"code-block-line\",\n        children: [{ text: codeLine }],\n      })),\n    },\n  ]\n}\n","import type { FootnoteDefinition } from \"mdast\"\n\nimport { Element } from \"../types\"\nimport { parseContents } from \"./parse-content\"\n\n/**\n * GitHub Flavored Markdown does not support footnotes and therefore, at the\n * moment, Wysimark does not support footnotes.\n *\n * However, we do provide some compatibility. Remarks, by default, parses\n * Footnote Definitions and we convert them into a blockquote. We insert an\n * extra paragraph at the top that contains the footnote identifier in square\n * brackets like `[1]`\n */\nexport function parseFootnoteDefinition(\n  footnote: FootnoteDefinition\n): Element[] {\n  return [\n    {\n      type: \"block-quote\",\n      children: [\n        /**\n         * Insert an initial paragraph with the footnote identifier in square\n         * brackets.\n         */\n        { type: \"paragraph\", children: [{ text: `[${footnote.identifier}]` }] },\n        /**\n         * The rest of the children are parsed as is and supports the full range\n         * of element types like headings, lists and nested block quotes.\n         */\n        ...parseContents(footnote.children),\n      ],\n    },\n  ]\n}\n","import { Text as SlateText } from \"slate\"\n\nimport { Segment } from \"../../types\"\nimport { normalizeSegment } from \"./normalize-segment\"\n\n/**\n * After generating segments by just pushing them onto an Array, we want to get\n * them into proper form for use in Slate.\n *\n * Slate expects its data structure to follow [certain\n * rules](https://docs.slatejs.org/concepts/11-normalizing) and we make sure\n * they are followed.\n *\n * These are the rules for segments (text/inline) that we enforce:\n *\n * - Rule 1: All Element nodes must contain at least one Text descendant\n * - Rule 2: Two adjacent texts with the same custom properties will be merged.\n * - Rule 4: Inline nodes cannot be the first or last child of a parent block,\n *   nor can it be next to another inline node in the children array.\n *\n */\nexport function normalizeSegments(segments: Segment[]): Segment[] {\n  const nextSegments: Segment[] = []\n\n  /**\n   * Rule 2:\n   *\n   * Build up the nextSegments. The `normalizeSegment` function called inside\n   * does the work of checking to see if the segment before is a Text with the\n   * exact same marks. If it is, then instead of pushing on another Text\n   * segment, it merges the current segment Text into the previous Segment.\n   *\n   * Rule 4 (part 3):\n   *\n   * It also checks for two inline elements and inserts an empty Text node\n   * between them by emitting a `{text: ''}` before the inline Element segment.\n   */\n  for (let i = 0; i < segments.length; i++) {\n    /**\n     * When we provide the `prevSegment` notice that is is actually the\n     * `prevSegment` from our `nextSegments` and not `segments[i-1]`.\n     *\n     * This is important because `normalizeSegment` will mutate `prevSegment`\n     */\n\n    const mutablePrevSegment: Segment | undefined =\n      nextSegments[nextSegments.length - 1]\n    nextSegments.push(...normalizeSegment(segments[i], mutablePrevSegment))\n  }\n\n  /**\n   * Rule 1:\n   *\n   * If there are no segments, we ensure there is at least one by inserting an\n   * empty Text\n   */\n  if (nextSegments.length === 0) nextSegments.push({ text: \"\" })\n  /**\n   * Rule 4 (part 1 & part 2):\n   *\n   * If the first segment isn't Text, insert a Text\n   */\n  if (!SlateText.isText(nextSegments[0])) nextSegments.unshift({ text: \"\" })\n  /**\n   * Rule 4:\n   *\n   * If the last segment isn't Text, insert a Text\n   */\n  if (!SlateText.isText(nextSegments[nextSegments.length - 1]))\n    nextSegments.push({ text: \"\" })\n  return nextSegments\n}\n","import { Text as SlateText } from \"slate\"\n\nimport { getMarksFromText } from \"../../serialize/serialize-line/utils\"\nimport { Segment, Text } from \"../../types\"\n\n/**\n * This is algorithm checks for equality of marks.\n */\nexport function areMarksEqual(a: Text, b: Text): boolean {\n  const marksA = getMarksFromText(a)\n  const marksB = getMarksFromText(b)\n  /**\n   *\n   * WARNING:\n   *\n   * This algorithm is specific to our use case. a, b contain non-repeated\n   * items. It will fail in other scenarios.\n   *\n   * > If you want to check if both arrays are equals, containing the same\n   * > unsorted items (but not used multiple times)\n   *\n   * https://stackoverflow.com/questions/7837456/how-to-compare-arrays-in-javascript#comment68674302_19746771\n   */\n  return (\n    marksA.length == marksB.length && marksA.every((v) => marksB.includes(v))\n  )\n}\n\n/**\n * Enforces Rule 2\n *\n * Two adjacent texts with the same custom properties will be merged.\n * https://docs.slatejs.org/concepts/11-normalizing\n *\n * normalizeSegment does most of the work for merging two segments with the same\n * marks together.\n *\n * Normally, this method emits the current `segment`; however, if the current\n * segment and the previous segment have the same marks, it instead emits an\n * empty array indicating not to add the current segment. Instead, it merges the\n * current segment text into the text of the previous segment.\n *\n * Enforce Rule 4 (part 3)\n *\n * \"Inline nodes cannot be the first or last child of a parent block, nor can it\n * be next to another inline node in the children array.\"\n *\n * Mainly, it's enforcing the part about the fact that there must be a Text node\n * between two inline Element nodes.\n */\nexport function normalizeSegment(\n  segment: Segment,\n  /**\n   * Let's be explicit that we are doing something unusual here in that we are\n   * mutating the previous segment by naming it as such.\n   */\n  mutablePrevSegment?: Segment\n): Segment[] {\n  const segmentIsText = SlateText.isText(segment)\n  const prevSegmentIsText = SlateText.isText(mutablePrevSegment)\n\n  /**\n   * Rule 4 (part 3):\n   *\n   * If there is a previous segment and the previous segment and the current\n   * segment are both inline elements, we want to insert a space between them\n   * which this does.\n   *\n   * It stops checking for merging two texts with each other since if they are\n   * two inline elements, it doesn't need to check for text anymore.\n   */\n  if (mutablePrevSegment && !prevSegmentIsText && !segmentIsText) {\n    return [{ text: \"\" }, segment]\n  }\n\n  /**\n   * If the current segment is an Inline Element, then we can't merge it so we\n   * return it as is\n   */\n  if (!segmentIsText) return [segment]\n  /**\n   * If the previous segment is an Inline Element or it's node defined, then we\n   * can't merge into it so we return it as is\n   */\n  if (mutablePrevSegment === undefined || !prevSegmentIsText) return [segment]\n\n  /**\n   * If the two Text segments have the same marks, then merge them\n   */\n  const marksEqual = areMarksEqual(mutablePrevSegment, segment)\n  if (marksEqual) {\n    mutablePrevSegment.text = [mutablePrevSegment.text, segment.text].join(\"\")\n    return []\n  }\n\n  return [segment]\n}\n","import * as Slate from \"slate\"\n\nimport { AnchorElement } from \"../../../../anchor-plugin\"\n\nimport { Segment, Text } from \"../../../types\"\nimport { LineElement, Node } from \"../normalize-line/types\"\n\n/**\n * Is this a Text Node\n */\nexport function isText(segment: Node | undefined): segment is Text {\n  return Slate.Text.isText(segment)\n}\n\n/**\n * Is this an Element Node\n *\n * In the context of our normalizers, passing `isElement` means that it is\n * a `LineElement` or `AnchorElement`\n *\n * TODO:\n *\n * We should also add the following in the future:\n *\n * - `ImageInlineElement`\n * - `AttachmentElement`\n */\nexport function isElement(\n  segment: Node\n): segment is LineElement | AnchorElement {\n  return Slate.Element.isElement(segment)\n}\n\n/**\n * Identify this as a plain, non-code Text space. This is fairly specific\n * because we only want to manipulate non-code Text spaces. If the Text is\n * `code` then we can apply our marks next to it.\n *\n * - Does the passed in `Text` node made up of only one or more spaces\n * - The `Text` node must not be `code`\n */\nexport function isPlainSpace(segment: Segment): boolean {\n  return (\n    Slate.Text.isText(segment) && !!segment.text.match(/^\\s+$/) && !segment.code\n  )\n}\n","import { MarkKey } from \"../../../../types\"\n\nexport const MARK_KEY_TO_OPEN_TOKEN = {\n  bold: \"**\",\n  italic: \"_\",\n  // ins: \"++\",\n  strike: \"~~\",\n  highlight: \"<mark>\",\n  /**\n   * IMPORTANT!\n   *\n   * We noop `code` here.\n   *\n   * We accept the `code` mark so as not to throw an error if it is found. We do\n   * this because we handle `code` text specially because of the way it needs to\n   * be escaped.\n   *\n   * This is handled in the `serializeLine` code.\n   */\n  code: \"\",\n} as Record<MarkKey, string>\n\nexport const MARK_KEY_TO_CLOSE_TOKEN = {\n  bold: \"**\",\n  italic: \"_\",\n  // ins: \"++\",\n  strike: \"~~\",\n  highlight: \"</mark>\",\n  code: \"\",\n} as Record<MarkKey, string>\n\n/**\n * @deprecated Use MARK_KEY_TO_OPEN_TOKEN instead\n */\nexport const MARK_KEY_TO_TOKEN = MARK_KEY_TO_OPEN_TOKEN\n\n/**\n * Convert a single mark to its opening symbol/tag\n */\nfunction convertMarkToOpenSymbol(mark: MarkKey): string {\n  if (mark in MARK_KEY_TO_OPEN_TOKEN) return MARK_KEY_TO_OPEN_TOKEN[mark]\n  throw new Error(\n    `Could not find mark ${JSON.stringify(mark)} in MARK_KEY_TO_OPEN_TOKEN lookup`\n  )\n}\n\n/**\n * Convert a single mark to its closing symbol/tag\n */\nfunction convertMarkToCloseSymbol(mark: MarkKey): string {\n  if (mark in MARK_KEY_TO_CLOSE_TOKEN) return MARK_KEY_TO_CLOSE_TOKEN[mark]\n  throw new Error(\n    `Could not find mark ${JSON.stringify(mark)} in MARK_KEY_TO_CLOSE_TOKEN lookup`\n  )\n}\n\n/**\n * Convert an array of marks to opening symbols/tags\n */\nexport function convertMarksToOpenSymbols(marks: MarkKey[]) {\n  return marks.map(convertMarkToOpenSymbol).join(\"\")\n}\n\n/**\n * Convert an array of marks to closing symbols/tags\n */\nexport function convertMarksToCloseSymbols(marks: MarkKey[]) {\n  return marks.map(convertMarkToCloseSymbol).join(\"\")\n}\n\n/**\n * Convert an array of marks to a string\n * @deprecated Use convertMarksToOpenSymbols or convertMarksToCloseSymbols instead\n */\nexport function convertMarksToSymbolsExceptCode(marks: MarkKey[]) {\n  return marks.map(convertMarkToOpenSymbol).join(\"\")\n}\n","import { Text as SlateText } from \"slate\"\n\nimport { MarkKey, Segment, Text } from \"../../../../types\"\nimport { isPlainSpace, isText } from \"../is-utils\"\n\n/**\n * Gets all the marks in current `Text`\n */\nexport function getMarksFromText(text: Text): MarkKey[] {\n  const { text: _textContent, ...marks } = text\n  void _textContent\n  return Object.keys(marks) as (keyof typeof marks)[]\n}\n\n/**\n * Gets all the marks from the current segment\n */\nexport function getMarksFromSegment(segment: Segment): MarkKey[] {\n  if (SlateText.isText(segment)) {\n    if (isPlainSpace(segment)) {\n      throw new Error(\n        `You probably didn't mean to do this. We should only be getting marks from segments that are not plain space segments.`\n      )\n    }\n    return getMarksFromText(segment)\n  } else if (segment.type === \"anchor\") {\n    return getCommonAnchorMarks(segment.children as Segment[])\n  } else {\n    /**\n     * TODO: Need to handle images still.\n     */\n    throw new Error(`Unhandled type ${segment.type}`)\n  }\n}\n\nexport function getCommonAnchorMarks(segments: Segment[]): MarkKey[] {\n  let commonMarks: MarkKey[] | undefined\n  for (const segment of segments) {\n    if (!isText(segment)) {\n      /**\n       * Use this to test for images in anchors\n       *\n       * [![Semantic description](https://roneo.org/img/ok.png \"Your title\")](http://jamstack.club)\n       */\n      if (segment.type === \"image-inline\") continue\n      /**\n       * TODO: This is not actually true. It can be an inline image which we\n       * still need to add.\n       */\n      throw new Error(\n        `Expected every segment in an anchor to be a Text segment`\n      )\n    }\n    if (isPlainSpace(segment)) continue\n    const currentMarks = getMarksFromText(segment)\n    if (commonMarks === undefined) {\n      commonMarks = currentMarks\n      continue\n    }\n    commonMarks = commonMarks.filter((commonMark) =>\n      currentMarks.includes(commonMark)\n    )\n  }\n  if (commonMarks === undefined) return []\n  return commonMarks\n}\n","import { MarkKey } from \"../../../../types\"\n\n/**\n * When adding back marks, this is the order in which we add them back.\n *\n * The order is determined by an educated guess about which marks are more\n * likely to be chaging inside other marks. For example, this is probably pretty\n * common:\n *\n * **This is x^2^**\n *\n * Having a superscript inside of a bold. But it's probably rare to have bold\n * switched on/off inside a superscript.\n */\nconst ORDERED_MARK_KEYS: MarkKey[] = [\n  \"bold\",\n  \"italic\",\n  \"underline\",\n  \"strike\",\n  \"highlight\",\n  \"code\",\n]\n\n/**\n * Sort Algorithm\n *\n * https://stackoverflow.com/a/44063445\n */\nexport function sortMarks(marks: MarkKey[]): MarkKey[] {\n  return marks\n    .slice()\n    .sort((a, b) => ORDERED_MARK_KEYS.indexOf(a) - ORDERED_MARK_KEYS.indexOf(b))\n}\n","/**\n * Characters that always need escaping in inline markdown text regardless\n * of surrounding context.\n */\nconst ALWAYS_ESCAPE = new Set([\"`\", \"*\", \"[\", \"]\", \"|\"])\n\n// ASCII punctuation per CommonMark: !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~\n// These are the only characters `\\` can escape, so a `\\` not followed by one\n// of them is a literal backslash (e.g. Windows paths like `C:\\Users`).\nfunction isAsciiPunct(ch: string): boolean {\n  return /[!-/:-@\\[-`{-~]/.test(ch)\n}\n\nfunction isWhitespace(ch: string): boolean {\n  return ch === \"\" || /\\s/u.test(ch)\n}\n\nfunction isPunctOrSymbol(ch: string): boolean {\n  return ch !== \"\" && /[\\p{P}\\p{S}]/u.test(ch)\n}\n\n// `<` only starts an HTML tag or autolink when followed by a letter, `/`,\n// `?`, or `!`. Otherwise (e.g. `a < b`, `a<5`) it is literal.\nfunction isHtmlTagStart(ch: string): boolean {\n  return /[a-zA-Z/?!]/.test(ch)\n}\n\nfunction getDelimitersThatCanPair(chars: string[], delimiter: string): Set<number> {\n  const escaped = new Set<number>()\n  const openers: number[] = []\n\n  for (let i = 0; i < chars.length; i++) {\n    if (chars[i] !== delimiter) continue\n\n    const prev = i > 0 ? chars[i - 1] : \"\"\n    const next = i + 1 < chars.length ? chars[i + 1] : \"\"\n    const leftFlanking =\n      !isWhitespace(next) &&\n      (!isPunctOrSymbol(next) || isWhitespace(prev) || isPunctOrSymbol(prev))\n    const rightFlanking =\n      !isWhitespace(prev) &&\n      (!isPunctOrSymbol(prev) || isWhitespace(next) || isPunctOrSymbol(next))\n\n    const canOpen = leftFlanking && (!rightFlanking || isPunctOrSymbol(prev))\n    const canClose = rightFlanking && (!leftFlanking || isPunctOrSymbol(next))\n\n    if (canClose && openers.length > 0) {\n      escaped.add(openers.pop() as number)\n      escaped.add(i)\n    }\n    if (canOpen) openers.push(i)\n  }\n\n  return escaped\n}\n\nfunction getTildesThatCanPair(chars: string[]): Set<number> {\n  const escaped = new Set<number>()\n  const openers: number[] = []\n\n  for (let i = 0; i < chars.length; i++) {\n    if (chars[i] !== \"~\") continue\n\n    const prev = i > 0 ? chars[i - 1] : \"\"\n    const next = i + 1 < chars.length ? chars[i + 1] : \"\"\n    const canOpen = !isWhitespace(next)\n    const canClose = !isWhitespace(prev)\n\n    if (canClose && openers.length > 0) {\n      escaped.add(openers.pop() as number)\n      escaped.add(i)\n    }\n    if (canOpen) openers.push(i)\n  }\n\n  return escaped\n}\n\n/**\n * Escape text that could have an ambiguous meaning in markdown.\n *\n * Only escapes characters that genuinely need escaping:\n * - `` ` ``, `*`, `[`, `]`, `|` — always escaped\n * - `\\` — escaped only when followed by an ASCII punctuation character\n * - `<` — escaped only when it could start an HTML tag or autolink\n * - `_`, `~` — escaped only when they could open/close emphasis/strikethrough\n *   (not between word-like characters)\n * - `#`, ordered list markers, `-`/`+`/`>` — escaped only at the start of a line\n */\nexport function escapeText(s: string) {\n  const chars = Array.from(s)\n  const emphasisUnderscores = getDelimitersThatCanPair(chars, \"_\")\n  const strikethroughTildes = getTildesThatCanPair(chars)\n  let result = \"\"\n  for (let i = 0; i < chars.length; i++) {\n    const ch = chars[i]\n    const prev = i > 0 ? chars[i - 1] : \"\"\n    const next = i + 1 < chars.length ? chars[i + 1] : \"\"\n\n    if (ALWAYS_ESCAPE.has(ch)) {\n      result += `\\\\${ch}`\n    } else if (ch === \"\\\\\") {\n      result += isAsciiPunct(next) ? \"\\\\\\\\\" : \"\\\\\"\n    } else if (ch === \"<\") {\n      result += isHtmlTagStart(next) ? \"\\\\<\" : \"<\"\n    } else if (ch === \"_\") {\n      result += emphasisUnderscores.has(i) ? `\\\\${ch}` : ch\n    } else if (ch === \"~\") {\n      result += strikethroughTildes.has(i) ? `\\\\${ch}` : ch\n    } else {\n      result += ch\n    }\n  }\n\n  // Escape characters that only have special meaning at the start of a line\n  result = result.replace(/^(#{1,6})(\\s)/m, \"\\\\$1$2\") // headings\n  result = result.replace(/^(\\d+)([.)]\\s)/m, \"$1\\\\$2\") // ordered list\n  result = result.replace(/^([-+>])\\s/m, \"\\\\$1 \") // list / blockquote\n\n  return result\n}\n","import type { Image } from \"mdast\"\n\nimport { ImageData } from \"./index\"\n\n/**\n * As a fallback, we don't\n */\nexport function parseGenericImage(image: Image): ImageData {\n  return {\n    url: image.url,\n    title: image.title || undefined,\n    alt: image.alt || undefined,\n  }\n}\n","type ParsedUrl = {\n  origin: string\n  hostname: string\n  pathname: string\n  searchParams: URLSearchParams\n  hash: string\n}\n\n/**\n * NOTE: As per the URL spec:\n *\n * - searchParams part does not include the \"?\"\n * - hash part includes the \"#\"\n */\nconst URL_REGEX = /^([^?#]*)(?:\\?([^#]*))?(#.*)?$/\n\nexport function parseUrl(url: string): ParsedUrl {\n  try {\n    const urlData = new URL(url)\n    return {\n      origin: urlData.origin,\n      hostname: urlData.hostname,\n      pathname: urlData.pathname,\n      searchParams: urlData.searchParams,\n      hash: urlData.hash,\n    }\n  } catch {\n    const matchdata = url.match(URL_REGEX)\n    if (matchdata === null)\n      throw new Error(`Invalid format should not happen: ${url}`)\n    const [, pathname, searchParams, hash] = [...matchdata]\n    return {\n      origin: \"\",\n      hostname: \"\",\n      pathname: pathname || \"\",\n      searchParams: new URLSearchParams(searchParams),\n      hash: hash || \"\",\n    }\n  }\n}\n","/**\n * Takes a `string` in the form `640x480` (i.e. number x number) and return an\n * ImageSize object with `width` and `height`.\n */\nexport function parseSize(\n  s: string | null\n): { width: number; height: number } | null {\n  if (typeof s !== \"string\") return null\n  const sizeMatch = s.match(/^(\\d+)x(\\d+)$/)\n  if (sizeMatch === null) return null\n  return {\n    width: parseInt(sizeMatch[1], 10),\n    height: parseInt(sizeMatch[2], 10),\n  }\n}\n","import type { Image } from \"mdast\"\n\nimport { parseUrl } from \"../../../parseUrl\"\nimport { ImageData } from \"./index\"\nimport { parseSize } from \"./parse-utils\"\n\nexport function parsePortiveImage(image: Image): ImageData | undefined {\n  // const url = new URL(image.url)\n  const url = parseUrl(image.url)\n  /**\n   * Only parse portive URL if it is a portive recognized domain\n   */\n  if (!url.hostname.match(/[.]portive[.]com$/i)) return\n  /**\n   * Should have a size param as part of the query string\n   */\n  const sizeParam = url.searchParams.get(\"size\")\n  if (sizeParam === null) return\n  /**\n   * And the query string should parse properly as an ImageSize\n   */\n  const size = parseSize(sizeParam)\n  if (size === null) return\n  /**\n   * The Portive image URL should end in something like `--640x480.jpg` which\n   * identifies its width/height.\n   */\n  const srcSizeMatch = url.pathname.match(/[-][-](\\d+)x(\\d+)[.][a-zA-Z]+$/)\n  if (srcSizeMatch === null) return\n  /**\n   * Return the `ImageData`\n   */\n  return {\n    url: `${url.origin}${url.pathname}`,\n    title: image.title || undefined,\n    alt: image.alt || undefined,\n    width: size.width,\n    height: size.height,\n    srcWidth: parseInt(srcSizeMatch[1], 10),\n    srcHeight: parseInt(srcSizeMatch[2], 10),\n  }\n}\n","import type { Image } from \"mdast\"\n\nimport { parseUrl } from \"../../../parseUrl\"\nimport { ImageData } from \"./index\"\nimport { parseSize } from \"./parse-utils\"\n\n/**\n * UncommonMark images are just regular images with some additional encoding in\n * the URL hash which allows us to embed extra information without affecting the\n * image that is rendered nor does it affect the `title` or `alt` attributes.\n */\nexport function parseUncommonMarkImage(image: Image): ImageData | undefined {\n  const url = parseUrl(image.url)\n  /**\n   * If there's no hash, it's not UncommonMark\n   */\n  if (url.hash.length === 0) return\n  /**\n   * We use `URLSearchParams` to decode the size data after the `#` because it's\n   * free (embedded in every browser without more code) and available (including\n   * Node)!\n   */\n  const params = new URLSearchParams(url.hash.slice(1))\n  const size = parseSize(params.get(\"size\"))\n  const srcSize = parseSize(params.get(\"srcSize\"))\n  if (!size || !srcSize) return\n  /**\n   * If we successfully parsed all the ImageSize info, then return the\n   * `ImageData`\n   */\n  return {\n    url: `${url.origin}${url.pathname}`,\n    title: image.title || undefined,\n    alt: image.alt || undefined,\n    width: size.width,\n    height: size.height,\n    srcWidth: srcSize.width,\n    srcHeight: srcSize.height,\n  }\n}\n","import { parseGenericImage } from \"./parse-generic-image\"\nimport { parsePortiveImage } from \"./parse-portive-image\"\nimport { parseUncommonMarkImage } from \"./parse-uncommon-mark-image\"\n\nexport const imageParsers = [\n  parsePortiveImage,\n  parseUncommonMarkImage,\n  parseGenericImage,\n]\n","import type { Image } from \"mdast\"\n\nimport { ImageSharedElement } from \"../../../../image-plugin/types\"\n\nimport { Segment } from \"../../../types\"\nimport { imageParsers } from \"./image-parsers\"\n\nexport type ImageData = Omit<ImageSharedElement, \"children\">\n\n/**\n * Iterate through all the image parsers utnil we find one that returns\n * `ImageData`. Combine that `ImageData` with the `type` and `children` and\n * return it as the `ImageInlineElement`\n */\nexport function parseInlineImage(image: Image): Segment[] {\n  for (const imageParser of imageParsers) {\n    const imageData = imageParser(image)\n    if (!imageData) continue\n    return [\n      {\n        type: \"image-inline\",\n        ...imageData,\n        children: [{ text: \"\" }],\n      },\n    ]\n  }\n  throw new Error(`Shouldn't get here because last parser always returns data`)\n}\n","import type { PhrasingContent } from \"mdast\"\n\nimport { MarkProps, Segment } from \"../../types\"\nimport { assertUnreachable } from \"../../utils\"\nimport { normalizeSegments } from \"./normalize-segments\"\nimport { parseInlineImage } from \"./parse-inline-image\"\nimport { Descendant } from \"slate\"\n\n/**\n * Parse inline HTML content, with special handling for <mark> tags\n */\nfunction parseInlineHtml(htmlValue: string, marks: MarkProps): Segment[] {\n  // Check for <br> / <br/> / <br /> tags — treat as soft line break\n  if (/^<br\\s*\\/?>$/i.test(htmlValue)) {\n    return [{ text: \"\\n\", ...marks }]\n  }\n  // Check for <mark>...</mark> pattern\n  const markMatch = htmlValue.match(/^<mark>(.+?)<\\/mark>$/s)\n  if (markMatch) {\n    return [{ text: markMatch[1], ...marks, highlight: true }]\n  }\n  // For other HTML, treat as code\n  return [{ text: htmlValue, code: true }]\n}\n\nexport function parsePhrasingContents(\n  phrasingContents: PhrasingContent[],\n  marks: MarkProps = {}\n): Segment[] {\n  const segments: Segment[] = []\n  for (const phrasingContent of phrasingContents) {\n    segments.push(...parsePhrasingContent(phrasingContent, marks))\n  }\n  const nextInlines = normalizeSegments(segments)\n  return nextInlines\n}\n\nfunction parsePhrasingContent(\n  phrasingContent: PhrasingContent,\n  marks: MarkProps = {}\n): Segment[] {\n  switch (phrasingContent.type) {\n    case \"delete\":\n      return parsePhrasingContents(phrasingContent.children, {\n        ...marks,\n        strike: true,\n      })\n    case \"emphasis\":\n      return parsePhrasingContents(phrasingContent.children, {\n        ...marks,\n        italic: true,\n      })\n    case \"footnoteReference\":\n      return [{ text: `[${phrasingContent.identifier}]` }]\n    case \"html\":\n      return parseInlineHtml(phrasingContent.value, marks)\n    case \"image\":\n      return parseInlineImage(phrasingContent)\n    case \"inlineCode\": {\n      return [{ text: phrasingContent.value, ...marks, code: true }]\n    }\n    case \"link\":\n      return [\n        {\n          type: \"anchor\",\n          href: phrasingContent.url,\n          title:\n            /**\n             * Ensure that `title` is undefined if it's null.\n             */\n            phrasingContent.title == null ? undefined : phrasingContent.title,\n          children: parsePhrasingContents(phrasingContent.children, marks) as Descendant[],\n        },\n      ]\n    case \"strong\":\n      return parsePhrasingContents(phrasingContent.children, {\n        ...marks,\n        bold: true,\n      })\n    case \"text\":\n      return [{ text: phrasingContent.value, ...marks }]\n    case \"linkReference\":\n    case \"imageReference\":\n      throw new Error(\n        `linkReference and imageReference should be converted to link and image through our transformInlineLinks function`\n      )\n    case \"break\":\n      /**\n       * NOTE:\n       *\n       * I don't think this is doing anything at the moment as a \"\\n\" is being\n       * read without being turned into a break. We can test this by doing a\n       * console.log before the return below.\n       */\n      return [{ text: \"\\n\" }]\n    case \"footnote\":\n      /**\n       * TODO: Support footnotes\n       *\n       * This is a footnote, and should be converte to a suitable alternative or\n       * for us to explicitly support a Footnote type in the future. At the\n       * moment, we don't explicitly support a footnote as it's (a) not part of\n       * GFM and (b) not really that useful while (c) adding complexity to the\n       * UI for something that's not used.\n       */\n      throw new Error(\"footnote is not supported yet\")\n  }\n  assertUnreachable(phrasingContent)\n}\n","import type { Heading } from \"mdast\"\nimport { Descendant } from \"slate\"\n\nimport { Element } from \"../types\"\nimport { parsePhrasingContents } from \"./parse-phrasing-content/parse-phrasing-content\"\n\nexport function parseHeading(content: Heading): Element[] {\n  return [\n    {\n      type: \"heading\",\n      level: content.depth,\n      children: parsePhrasingContents(content.children) as Descendant[],\n    },\n  ]\n}\n","import type { HTML } from \"mdast\"\n\nimport { Element } from \"../types\"\n\nexport function parseHTML(content: HTML): Element[] {\n  return [\n    {\n      type: \"html-block\",\n      html: content.value,\n      children: [{ text: \"\" }],\n    },\n  ]\n}\n","import type { ListItem } from \"mdast\"\nimport { Descendant } from \"slate\"\n\nimport { Element } from \"../../types\"\nimport { parseContent } from \"../parse-content\"\nimport { parsePhrasingContents } from \"../parse-phrasing-content/parse-phrasing-content\"\nimport { parseList } from \"./parse-list\"\n\nexport function parseListItemChild(\n  child: ListItem[\"children\"][number],\n  {\n    depth,\n    ordered,\n    checked,\n  }: { depth: number; ordered: boolean; checked: boolean | null | undefined }\n): Element[] {\n  switch (child.type) {\n    case \"paragraph\":\n      if (checked === true || checked === false) {\n        return [\n          {\n            type: \"task-list-item\",\n            depth,\n            checked,\n            children: parsePhrasingContents(child.children) as Descendant[],\n          },\n        ]\n      } else if (ordered) {\n        return [\n          {\n            type: \"ordered-list-item\",\n            depth,\n            children: parsePhrasingContents(child.children) as Descendant[],\n          },\n        ]\n      } else {\n        return [\n          {\n            type: \"unordered-list-item\",\n            depth,\n            children: parsePhrasingContents(child.children) as Descendant[],\n          },\n        ]\n      }\n    case \"list\":\n      return parseList(child, depth + 1)\n    default:\n      /**\n       * NOTE:\n       *\n       * We break out of a list when the children of a list item are not more\n       * lists/list items.\n       *\n       * This is one area where we don't strictly adhere to the Markdown\n       * specification and it is intentional because adhering strictly to the\n       * Markdown specification would create a harmful user experience.\n       *\n       * It appears that Markdown allows nesting other block types in lists\n       * other than list items. For example, one can place a table, block\n       * quote, heading or something else in a list item.\n       *\n       * There are a few problems with this from a user perspective:\n       *\n       * - It's unexpected. No other editors provide such a feature.\n       * - If we were to adopt this as a feature, the user experience would be\n       *   terrible, namely because it would be unpredictable what commands do\n       *   toggle headings or list items should do if they were nested.\n       *\n       */\n      return parseContent(child)\n  }\n}\n","import type { ListItem } from \"mdast\"\n\nimport { Element } from \"../../types\"\nimport { parseListItemChild } from \"./parse-list-item-child\"\n\nexport function parseListItem(\n  listItem: ListItem,\n  options: { depth: number; ordered: boolean }\n): Element[] {\n  const elements: Element[] = []\n  for (const child of listItem.children) {\n    elements.push(\n      ...parseListItemChild(child, { ...options, checked: listItem.checked })\n    )\n  }\n  return elements\n}\n","import type { List } from \"mdast\"\n\nimport { Element } from \"../../types\"\nimport { parseListItem } from \"./parse-list-item\"\n\nexport function parseList(list: List, depth = 0): Element[] {\n  // console.log(JSON.stringify(list, null, 2))\n  const elements: Element[] = []\n  for (const listItem of list.children) {\n    elements.push(\n      ...parseListItem(listItem, { depth, ordered: !!list.ordered })\n    )\n  }\n  return elements\n}\n","import type { Paragraph } from \"mdast\"\nimport { Descendant } from \"slate\"\n\nimport { ImageBlockElement, ImageInlineElement } from \"../../image-plugin/types\"\n\nimport { Element, Segment } from \"../types\"\nimport { parsePhrasingContents } from \"./parse-phrasing-content/parse-phrasing-content\"\n\nfunction isImageBlock(segments: Segment[]): boolean {\n  if (segments.length !== 3) return false\n  if (!(\"text\" in segments[0]) || segments[0].text !== \"\") return false\n  if (!(\"text\" in segments[2]) || segments[2].text !== \"\") return false\n  if (!(\"type\" in segments[1]) || segments[1].type !== \"image-inline\")\n    return false\n  return true\n}\n\nconst NBSP = \"\\u00A0\"\n\nfunction isSingleNBSP(segments: Segment[]): boolean {\n  if (segments.length !== 1) return false\n  if (!(\"text\" in segments[0]) || segments[0].text !== NBSP) return false\n  return true\n}\n\n/**\n * Parses to a Paragraph or an ImageBlock element.\n *\n * We need to do it this way because an ImageBlock is a Paragraph that happens\n * to have exactly one ImageInline child.\n */\nexport function parseParagraph(content: Paragraph): Element[] {\n  const segments = parsePhrasingContents(content.children)\n  if (isImageBlock(segments)) {\n    const imageSegment = segments[1] as ImageInlineElement\n    const imageBlockElement: ImageBlockElement = {\n      ...imageSegment,\n      type: \"image-block\",\n    }\n    return [imageBlockElement]\n  }\n  if (isSingleNBSP(segments)) {\n    return [\n      {\n        type: \"paragraph\",\n        children: [{ text: \"\" }],\n      },\n    ]\n  }\n\n  return [\n    {\n      type: \"paragraph\",\n      children: segments as Descendant[],\n    },\n  ]\n}\n","import type { Table, TableCell, TableRow } from \"mdast\"\nimport { Descendant } from \"slate\"\n\nimport {\n  TableCellElement,\n  TableElement,\n  TableRowElement,\n} from \"../../table-plugin\"\n\nimport { parsePhrasingContents } from \"./parse-phrasing-content/parse-phrasing-content\"\n\nexport function parseTable(table: Table): [TableElement] {\n  if (table.align == null)\n    throw new Error(`Expected an array of AlignType for table.align`)\n  return [\n    {\n      type: \"table\",\n      columns: table.align.map((align) => ({\n        align: align || \"left\",\n      })),\n      children: table.children.map(parseTableRow),\n    },\n  ]\n}\n\nfunction parseTableRow(row: TableRow): TableRowElement {\n  if (row.type !== \"tableRow\") throw new Error(`Expected a tableRow`)\n  return { type: \"table-row\", children: row.children.map(parseTableCell) }\n}\n\nfunction parseTableCell(cell: TableCell): TableCellElement {\n  if (cell.type !== \"tableCell\") throw new Error(`Expected a tableCell`)\n  return {\n    type: \"table-cell\",\n    children: [\n      {\n        type: \"table-content\",\n        children: parsePhrasingContents(cell.children) as Descendant[],\n      },\n    ],\n  }\n}\n","import { Element } from \"../types\"\n\nexport function parseThematicBreak(): Element[] {\n  return [\n    {\n      type: \"horizontal-rule\",\n      children: [{ text: \"\" }],\n    },\n  ]\n}\n","import type { TopLevelContent } from \"mdast\"\n\nimport { Element } from \"../types\"\nimport { assertUnreachable } from \"../utils\"\nimport { parseBlockquote } from \"./parse-blockquote\"\nimport { parseCodeBlock } from \"./parse-code-block\"\nimport { parseFootnoteDefinition } from \"./parse-footnote-definition\"\nimport { parseHeading } from \"./parse-heading\"\nimport { parseHTML } from \"./parse-html\"\nimport { parseList } from \"./parse-list\"\nimport { parseParagraph } from \"./parse-paragraph\"\nimport { parseTable } from \"./parse-table\"\nimport { parseThematicBreak } from \"./parse-thematic-break\"\n\nexport function parseContents(contents: TopLevelContent[]): Element[] {\n  const elements: Element[] = []\n  for (let i = 0; i < contents.length; i++) {\n    /**\n     * Detect extra blank lines between MDAST nodes using position info.\n     * remark-parse collapses consecutive blank lines, but we can recover\n     * them by comparing the end line of the previous node with the start\n     * line of the current node. A standard block separation is 1 blank line\n     * (gap === 1). Each additional blank line gets an empty paragraph.\n     */\n    if (i > 0) {\n      const prev = contents[i - 1]\n      const curr = contents[i]\n      if (prev.position && curr.position) {\n        const gap = curr.position.start.line - prev.position.end.line - 1\n        for (let b = 1; b < gap; b++) {\n          elements.push({\n            type: \"paragraph\",\n            children: [{ text: \"\" }],\n          } as Element)\n        }\n      }\n    }\n    elements.push(...parseContent(contents[i]))\n  }\n  return elements\n}\n\nexport function parseContent(content: TopLevelContent): Element[] {\n  switch (content.type) {\n    case \"blockquote\":\n      return parseBlockquote(content)\n    case \"code\":\n      return parseCodeBlock(content)\n    case \"definition\":\n      /**\n       * A `definition` is used by a `linkRef` or `imageRef`; however, we inline\n       * these with our `./remark-inline-links`\n       */\n      throw new Error(`The type \"definition\" should not exist. See comments`)\n    case \"footnoteDefinition\":\n      return parseFootnoteDefinition(content)\n    case \"heading\":\n      return parseHeading(content)\n    case \"html\":\n      return parseHTML(content)\n    case \"list\":\n      return parseList(content)\n    case \"paragraph\":\n      /**\n       * Returns a `paragraph` or an `image-block` Element.\n       */\n      return parseParagraph(content)\n    case \"table\":\n      return parseTable(content)\n    case \"thematicBreak\":\n      return parseThematicBreak()\n    case \"yaml\":\n      /**\n       * YAML FrontMatter is not used in Wysimark.\n       */\n      return []\n  }\n  assertUnreachable(content)\n}\n","import type { Content, Image, Link, Parent, Root } from \"mdast\"\nimport { definitions } from \"mdast-util-definitions\"\nimport type { Node } from \"unist\"\nimport { SKIP, visit } from \"unist-util-visit\"\n\n/**\n * Based on the code from `remark-inline-links` but rewritten here because, for\n * reasons unknown to me, the plugin doesn't seem to execute at all despite not\n * throwing an error. Looks like the function that `remarkInlineLinks` returns\n * is never executed. Not sure if this is due to a change in `unified` but I\n * can't seem to find any mention anywhere of this no longer working including\n * in discussion or issues and the list of plugins show that\n * `remark-inline-links` is currently working and compatible with the lateste\n * version.\n *\n * Never-the-less, pulling it out and working on the ast directly (this function\n * modifies the AST in place) seems to work.\n *\n * https://github.com/remarkjs/remark-inline-links\n */\nexport function transformInlineLinks(tree: Root): void {\n  const definition = definitions(tree)\n\n  visit<Node>(tree as Node, (n, index, p) => {\n    const node = n as unknown as Content\n    const parent = p as unknown as Parent | null\n    if (\n      node.type === \"definition\" &&\n      parent !== null &&\n      typeof index === \"number\"\n    ) {\n      parent.children.splice(index, 1)\n      return [SKIP, index]\n    }\n\n    if (node.type === \"imageReference\" || node.type === \"linkReference\") {\n      const identifier =\n        \"identifier\" in node && typeof node.identifier === \"string\"\n          ? node.identifier\n          : \"\"\n      const def = definition(identifier)\n\n      if (def && parent !== null && typeof index === \"number\") {\n        const replacement: Image | Link =\n          node.type === \"imageReference\"\n            ? { type: \"image\", url: def.url, title: def.title, alt: node.alt }\n            : {\n                type: \"link\",\n                url: def.url,\n                title: def.title,\n                children: node.children,\n              }\n\n        parent.children[index] = replacement\n        return [SKIP, index]\n      }\n    }\n  })\n}\n","import { ListItemElement } from \"../../../list-plugin/types\"\n\nimport { Element } from \"../../types\"\n\n/**\n * Provides a type guard for `ListItemElement`.\n */\nfunction isListItemElement(element: Element): element is ListItemElement {\n  return (\n    element.type === \"ordered-list-item\" ||\n    element.type === \"unordered-list-item\" ||\n    element.type === \"task-list-item\"\n  )\n}\n\nexport function normalizeElementListDepths(elements: Element[]) {\n  const normalizedElements: Element[] = []\n\n  /**\n   * previousDepth of -1 indicates that the previous element was not a list\n   * item.\n   */\n  let previousDepth = -1\n\n  for (const element of elements) {\n    /**\n     * If it's not a list item, just reset previousDepth and add the element\n     * to `normalizedElements`.\n     */\n    if (!isListItemElement(element)) {\n      normalizedElements.push(element)\n      previousDepth = -1\n      continue\n    }\n\n    /**\n     * If it is a list item, we need to make sure the depth never increases by\n     * more than 1. This is important because if we skip the first depth (i.e.\n     * we start at depth of 2) then we get the first list indented which makes\n     * Markdown think it's a code block. After the first list item, we don't\n     * want to indent by more than one depth level because Markdown will assume\n     * that's still a single depth level. When we outdent a level, Markdown\n     * could get confused.\n     *\n     * WARNING:\n     *\n     * This does create a situation where the list in Wysimark is not saved and\n     * loaded to return the same document; however, the alternative is that we\n     * prevent the editor from creating a list which skips a depth. This could\n     * be perceived as broken UI by the user. This appraoch feels less obtrusive\n     * to the user.\n     */\n    const nextDepth =\n      element.depth > previousDepth + 1 ? previousDepth + 1 : element.depth\n    normalizedElements.push({ ...element, depth: nextDepth })\n    previousDepth = nextDepth\n  }\n\n  return normalizedElements\n}\n","import { CodeBlockLineElement } from \"../../../code-block-plugin\"\n\n/**\n * Serializing a code line is simple under the assumption that the normalizers\n * in Wysimark are working correctly. Technically, a code-line should have\n * exactly one child with one `Text` node with no marks in it.\n */\nexport function serializeCodeLine(codeLine: CodeBlockLineElement): string {\n  /**\n   * As a safety measure, we make sure that we are receiving a `codeLine`\n   */\n  if (codeLine.type !== \"code-block-line\")\n    throw new Error(\n      `Expected all children of code-block to be a codeline but is ${JSON.stringify(\n        codeLine,\n        null,\n        2\n      )}`\n    )\n  /**\n   * We are converting all segments under the assumption that they are text\n   * segments.\n   */\n  return codeLine.children.map((segment) => segment.text).join(\"\")\n}\n","import { CodeBlockElement } from \"../../../code-block-plugin\"\n\nimport { serializeCodeLine } from \"./serialize-code-line\"\n\n/**\n * Serializing a code block is usually three backticks folloed by the language,\n * then the code is raw verbatim and then three backticks to close.\n *\n * However, we have to account for if any line in the code starts with three\n * backticks. In that case, we need to start our code block with 4 backticks.\n * And if there are 4 backticks in the code, then we need to start it with 5.\n *\n * We always need to start our code block with one more backtick than can be\n * found starting any line in the code block.\n */\nexport function serializeCodeBlock(codeBlock: CodeBlockElement): string {\n  const lines: string[] = []\n  /**\n   * Start with the default number of backticks\n   */\n  let backticks = 3\n  for (const codeLine of codeBlock.children) {\n    /**\n     * Grab a raw code line from it\n     */\n    const lineOfCode = serializeCodeLine(codeLine)\n    /**\n     * Check if it starts with any backticks and if it does, make our backticks\n     * one larger than the largest one.\n     */\n    const match = lineOfCode.match(/^([`]+)/)\n    if (match) backticks = Math.max(backticks, match[1].length + 1)\n    /**\n     * Add it to our lines\n     */\n    lines.push(lineOfCode)\n  }\n  /**\n   * At the very end, when we know how many backticks we need, add our backticks\n   * and language at the start and the closing backticks at the end.\n   */\n  lines.unshift(`${\"`\".repeat(backticks)}${codeBlock.language}`)\n  lines.push(`${\"`\".repeat(backticks)}`)\n  return `${lines.join(\"\\n\")}\\n\\n`\n}\n","import { ImageSharedElement } from \"../../../image-plugin/types\"\n\n/**\n * As a fallback, if there is no width/height or srcWidth/srcHeight info then\n * just save the image url and do not save with uncommonMark hints.\n */\nexport function serializeGenericImageUrl(image: ImageSharedElement): string {\n  return image.url\n}\n","import { ImageSharedElement } from \"../../../image-plugin/types\"\n\nimport { parseUrl } from \"../../parseUrl\"\n\n/**\n * When an image is in the `.portive.com` subdomain like `files.portive.com` or\n * `staging.files.portive.com` and if the image has a `width` and `height` then\n * we encode the `width` and `height in the `url` as part of the query string.\n *\n * https://files.portive.com/f/abcdef--640x480.jpg?size=320x240\n *\n * Indicates a src image of 640x480 that will be resized and sent to the browser\n * at 320x240\n *\n * This does these things:\n *\n * - When parsing the image URL, we are able to pull the width/height out of the\n *   URL and use it to populate those values in the editor.\n *\n * - The query string will also physically resize the image before delivering it\n *   from Portive. This means that in regular Markdown that doesn't have any\n *   special understanding of Portive's special querystring encodings, the image\n *   is still returned in the correct size.\n */\nexport function serializePortiveImageUrl(\n  image: ImageSharedElement\n): string | undefined {\n  if (image.url.startsWith(\"$\")) return \"\"\n  const { hostname } = parseUrl(image.url)\n  /**\n   * Only parse portive URL if it is a portive recognized domain\n   */\n  if (hostname.match(/[.]portive[.]com$/i) && image.width && image.height)\n    return `${image.url}?size=${image.width}x${image.height}`\n}\n","import { ImageSharedElement } from \"../../../image-plugin/types\"\n\n/**\n * In UncommonMark, we provide hints after the hash `#` portion of the URL that\n * does not affect the URL of the image being delivered. It is usually used to\n * tell the browser to scroll to the given section in a linked document.\n *\n * https://imageservice.com/abcdefg.jpg#srcSize=1024x768&size=640x480\n */\nexport function serializeUncommonmarkImageUrl(\n  image: ImageSharedElement\n): string | undefined {\n  if (image.width && image.height && image.srcWidth && image.srcHeight)\n    return `${image.url}#srcSize=${image.srcWidth}x${image.srcHeight}&size=${image.width}x${image.height}`\n}\n","import { ImageSharedElement } from \"../../../image-plugin/types\"\n\nimport { serializeGenericImageUrl } from \"./serialize-generic-image-url\"\nimport { serializePortiveImageUrl } from \"./serialize-portive-image-url\"\nimport { serializeUncommonmarkImageUrl } from \"./serialize-uncommonmark-image-url\"\n\nconst urlSerializers = [\n  serializePortiveImageUrl,\n  serializeUncommonmarkImageUrl,\n  serializeGenericImageUrl,\n]\n\nexport function serializeImageShared(image: ImageSharedElement): string {\n  for (const urlSerializer of urlSerializers) {\n    const url = urlSerializer(image)\n    if (typeof url === \"string\") {\n      /**\n       * Sometimes the serialized URL will return \"\" which means that the URL\n       * hasn't returned yet. When this happens, we don't want the markdown for\n       * the image to be added to the final value because the image would be\n       * invalid. This happens when the image is uploading.\n       */\n      if (url === \"\") return \"\"\n      return `![${image.alt}](${url}${\n        typeof image.title === \"string\" ? ` \"${image.title}\"` : \"\"\n      })`\n    }\n  }\n  /**\n   * Shouldn't get here because the last url seializer `serializeGenericUrl`\n   * always returns a value.\n   */\n  throw new Error(`Shouldn't get here`)\n}\n","import { ImageBlockElement } from \"../../../image-plugin/types\"\n\nimport { serializeImageShared } from \"../serialize-image-shared\"\n\n/**\n * Serialize an image block element to markdown.\n *\n * Block-level images require trailing newlines (\\n\\n) to properly separate\n * them from subsequent content. Without these newlines, content immediately\n * following an image (like headings) would be parsed as part of the same\n * paragraph, breaking the markdown structure.\n *\n * Example:\n *   Correct:   ![alt](url)\\n\\n# Heading\n *   Incorrect: ![alt](url)# Heading  <- heading becomes plain text\n */\nexport function serializeImageBlock(element: ImageBlockElement): string {\n  const imageMarkdown = serializeImageShared(element)\n  return imageMarkdown ? `${imageMarkdown}\\n\\n` : \"\"\n}\n","import { Element as SlateElement, Text as SlateText } from \"slate\"\n\nimport { MarkKey, Segment } from \"../../types\"\nimport { diffMarks } from \"./diff-marks\"\nimport { normalizeLine } from \"./normalize-line\"\nimport { serializeSegment } from \"./segment/serialize-segment\"\nimport {\n  convertMarksToOpenSymbols,\n  convertMarksToCloseSymbols,\n  getMarksFromSegment,\n  isPlainSpace,\n} from \"./utils\"\n\n/**\n * Takes a line (an array of Segment) and turns it into markdown.\n *\n * The majority of this code deals with how we convert marks like `bold` and\n * `italic` into symbols and where to place them. There are several complicated\n * cases we need to handle like:\n *\n * - Symbols must always be placed on the inside of spaces next to the word like\n *   \" **bold** \" and not \"** bold **\". We need to be aware of our placement of\n *   symbols around spaces but spaces themselves can safely and actually must\n *   ignore the actual marks on them. A bold space and a not-bold space are\n *   considered the same in Markdown.\n * - Anchors must have common marks moved out of them\n * - Anchors must have not common marks set inside of them\n */\nexport function serializeLine(\n  inputSegments: Segment[],\n  leadingMarks: MarkKey[] = [],\n  trailingMarks: MarkKey[] = []\n): string {\n  /**\n   * Normalize line does a lot of the work here to take any spaces that can be\n   * found around the edges of segments and turns them into their own segments.\n   * We don't need to do this in spaces on the inside of segments though.\n   *\n   * This is important because at the boundaries of segments, that's when marks\n   * change (e.g. bold/italic) and it is at these points, we need to put spaces\n   * into separate segments so that we can place the symbols for the marks\n   * around them.\n   */\n  const segments = normalizeLine(inputSegments)\n  const substrings: string[] = []\n\n  /**\n   * In order to seed the loop, we start by creating a `leadingDiff` going from\n   * the `leadingMarks` provided to this method and the marks in the first\n   * segment.\n   *\n   * The `leadingMarks` will always be `[]` at the beginning. When we get into a\n   * nested `anchor` though, there may be some marks that had been previously\n   * set outside of the anchor that need to be considered.\n   */\n  let leadingDiff = diffMarks(leadingMarks, getMarksFromSegment(segments[0]))\n\n  /**\n   * In each iteration, we want to serialize the following:\n   *\n   * - Symbols that represent all the marks to add to this segment\n   * - The markdown for the segment itself (text, inline code, anchor, inline\n   *   image)\n   * - Symbols that represent all the marks to remove from this segment\n   */\n  for (let i = 0; i < segments.length; i++) {\n    /**\n     * This is the current segment that we are looking at.\n     */\n    const segment = segments[i]\n\n    /**\n     * If it's plain space, add it to markdown and start at the top of the loop\n     * again\n     *\n     * Basically, ignore the symbols we need to add when it's a space.\n     *\n     * The symbols get handled by the non-space segments.\n     *\n     * When we continue, we end up with the same `leadingDiff` from the last\n     * segment which is what we want. This is because the `leadingDiff` actually\n     * applies to the next Segment which should be either a not space Text or an\n     * Element.\n     */\n    if (SlateText.isText(segment) && isPlainSpace(segment)) {\n      substrings.push(segment.text)\n      continue\n    }\n\n    /**\n     * Here is where we add the serialization of the segment.\n     *\n     * First we start by adding the symbols needed to add the marks to this\n     * segment.\n     */\n    substrings.push(convertMarksToOpenSymbols(leadingDiff.add))\n\n    /**\n     * Then we add the Text or the Anchor for the segment\n     */\n    substrings.push(serializeSegment(segment))\n\n    /**\n     * Now we are searching for the next segment which we want to grab the marks\n     * from. Basically, any segment that isn't a space. For clarity, in this\n     * algorithm, we should never have two `isPlainSpace` segments in a row\n     * because this would have been normalized to one `isPlainSpace` segment in\n     * the call to `normalizeLine`\n     */\n    const nextMarks = getNextMarks(segments, i, trailingMarks)\n    const trailingDiff = diffMarks(leadingDiff.nextOrderedMarks, nextMarks)\n    substrings.push(convertMarksToCloseSymbols(trailingDiff.remove))\n\n    /**\n     * The `trailingDiff` becomes the new `leadingDiff`\n     */\n    leadingDiff = trailingDiff\n  }\n  return substrings.join(\"\")\n}\n\n/**\n * Looks for the next set of valid marks by\n *\n * This method is local to `serialize-line` as it's intimiately tied with the\n * call to `getNextMarks` in `serializeLine`\n */\nfunction getNextMarks(\n  segments: Segment[],\n  index: number,\n  trailingMarks: MarkKey[]\n): MarkKey[] {\n  /**\n   * Starting at the index `i` following the current index `index`\n   *\n   * If it's a plain space, skip it.\n   *\n   * If it isn't, get the marks for the segment.\n   *\n   * NOTE:\n   *\n   * If the segment is an `anchor` we the common marks for all the segments in\n   * the anchor not including the plain spaces.\n   */\n  for (let i = index + 1; i < segments.length; i++) {\n    const segment = segments[i]\n    if (isPlainSpace(segment)) continue\n    if (SlateElement.isElement(segment)) {\n      const element = segment as { type?: string }\n      if (element.type === \"image-inline\") continue\n    }\n    return getMarksFromSegment(segment)\n  }\n  return trailingMarks\n}\n","import { MarkKey } from \"../../../types\"\nimport { sortMarks } from \"../utils\"\n\n/**\n * Find the marks to add in ordere to get our orderedMarks to match the\n * `targetMarks`.\n *\n * We do this in a smart, but perhaps, imperfect way.\n *\n * When we need to add marks, we add them in an order that is more likely to\n * reduce the number of marks we add. See the comments under `MARK_KEY_ORDER` to\n * find out how.\n *\n * That said, we could probably choose a more complex algorithm that looks at\n * all the text to find out how to most efficiently place which marks as outer\n * or inner marks; however, there will still be situations in which the choice\n * will be arbitrary and this would likely greatly increase the complexity of\n * the code.\n *\n * This feels like a good trade-off and is likely to cause an unreadable\n * markdown representation. I suppose if for some reason a user had a bunch of\n * superscripted text which was intermittently styled with bold and italic, then\n * we'd have less than ideal markdown.\n */\nexport function findMarksToAdd(\n  orderedMarks: MarkKey[],\n  targetMarks: MarkKey[]\n) {\n  const marksWeNeedToAdd = targetMarks.filter(\n    (mark) => !orderedMarks.includes(mark)\n  )\n  const orderedMarksToAdd = sortMarks(marksWeNeedToAdd)\n  return { orderedMarksToAdd }\n}\n","import { MarkKey } from \"../../../types\"\n\n/**\n * Takes a list of our current `orderedMarks` (i.e. what marks have been applied\n * to our text and in which order) and then gives us a list of `targetMarks`\n * which, for clarity, the order doesn't matter.\n *\n * We then create a list of `orderedMarksToRemove` which is a list of marks we\n * need to remove in the correct order, in order to satisfy that there aren't\n * any marks left that aren't also in the `targetMarks`.\n */\nexport function findMarksToRemove(\n  orderedMarks: MarkKey[],\n  targetMarks: MarkKey[]\n): { orderedMarksToRemove: MarkKey[]; nextOrderedMarks: MarkKey[] } {\n  /**\n   * As a good practice, don't manipulate the incoming argument (even though\n   * technically it doesn't matter here)\n   */\n  const nextOrderedMarks = [...orderedMarks]\n\n  /**\n   * Find the marks that we need to remove.\n   */\n  const marksWeNeedToRemove = orderedMarks.filter(\n    (mark) => !targetMarks.includes(mark)\n  )\n\n  /**\n   * An ordered array of marks to remove\n   */\n  const orderedMarksToRemove: MarkKey[] = []\n\n  /**\n   * We iterate a maximum number of times with an upper limit of\n   * `nextOrderedMarks.length` to prevent infinite loops.\n   *\n   * If we meet our condition of removing all the `marksWeNeedToRemove` we are\n   * going to break out of this loop early which is common. Used a for loop\n   * instead of counting the number of loops and throwing an error.\n   */\n  for (let i = 0; i < orderedMarks.length; i++) {\n    /**\n     * If we don't have any more marks we need to remove, we are done so leave\n     * the loop.\n     */\n    if (marksWeNeedToRemove.length === 0) break\n    /**\n     * Remove the last mark\n     */\n    const markToRemove = nextOrderedMarks.pop()\n    if (markToRemove === undefined) {\n      throw new Error(\n        `This shouldn't happen unless we made a mistake in the algorithm`\n      )\n    }\n    /**\n     * Add to our `orderedMarkToRemove` which is done in the correct order\n     * because we are popping them off from the right.\n     */\n    orderedMarksToRemove.push(markToRemove)\n\n    /**\n     * Whatever we added to our list of `orderedMarksToRemove` we can now take\n     * off our list of `marksWeNeedToRemove`. Sometimes we will be removed marks\n     * that don't take anything off our list of `marksWeNeedToRemove` because of\n     * the order in which we need to remove marks.\n     *\n     * For this reason, the check to see if the `mark` was in our list of\n     * `marksWeNeedToRemove` is important.\n     */\n    const index = marksWeNeedToRemove.indexOf(markToRemove)\n    if (index !== -1) {\n      marksWeNeedToRemove.splice(index, 1)\n    }\n  }\n\n  return { orderedMarksToRemove, nextOrderedMarks }\n}\n","import { MarkKey } from \"../../../types\"\nimport { findMarksToAdd } from \"./find-marks-to-add\"\nimport { findMarksToRemove } from \"./find-marks-to-remove\"\n\n/**\n * Takes a set of incoming marks and a set of target markets and returns what\n * marks need to be removed including the order in which they need to be removed\n * and what marks need to be added including the order in which they needed to\n * be added.\n *\n * The algorithm, collectively, is a little complex because we must always\n * remove an inner set of mark symbols before we can remove an outer set. This\n * means that sometimes when we want to remove a mark, we end up actually having\n * to add one. Like in this scenario:\n *\n * **_bold italic_** _italic_\n *\n * In order to go from bold and italic to just italic, we need to first remove\n * the inner italic, then remove the outer bold, and because the italic was\n * removed we need to add back the italic.\n *\n * Note that the algorithm is asymmetrical. It's just the way it has to be.\n */\nexport function diffMarks(orderedMarks: MarkKey[], targetMarks: MarkKey[]) {\n  /**\n   * First we remove the marks in order to arrive at our target marks.\n   *\n   * The algorithm basically just takes off the inner-most (right-most) marks\n   * and adds them to `marsToRemove` until we don't have any marks that aren't\n   * also in the `targetMarks`.\n   *\n   * Because we may be over-removing the marks, the method returns a\n   * `nextOrderedMarks` or basically the `orderedMarks` after the remove has\n   * happened. We then use this as the basis to add any marks we need back to\n   * arrive at our `targetMarks`.\n   */\n  const { orderedMarksToRemove, nextOrderedMarks } = findMarksToRemove(\n    orderedMarks,\n    targetMarks\n  )\n  /**\n   * We call out to a method that adds the necessary marks back in. The\n   * algorithm here is pretty straightforward. Just add back the marks we need\n   * and to achieve some level of consistency, add them back in a specific order\n   * that feels nice and makes sense. For example, superscript/subscript is more\n   * nested than bold because they are more likely to be toggled.\n   */\n  const { orderedMarksToAdd } = findMarksToAdd(nextOrderedMarks, targetMarks)\n  return {\n    remove: orderedMarksToRemove,\n    add: orderedMarksToAdd,\n    nextOrderedMarks: [...nextOrderedMarks, ...orderedMarksToAdd],\n  }\n}\n","import { Element } from \"slate\"\n\nimport { Segment } from \"../../../types\"\nimport { normalizeNodes } from \"./normalize-nodes\"\nimport { LineElement } from \"./types\"\n\n/**\n * A very focused duplicate function that only duplicates the `children` of\n * `anchor` elements.\n *\n * It's designed this way to be fast and to avoid duplicating the entire tree\n * as only anchors have children that will be manipulated.\n */\nconst duplicateSegments = (segments: Segment[]): Segment[] => {\n  return segments.map((segment) => {\n    if (Element.isElement(segment) && segment.type === \"anchor\") {\n      return {\n        ...segment,\n        children: duplicateSegments(segment.children as Segment[]) as typeof segment.children,\n      } as typeof segment\n    } else {\n      return segment\n    }\n  })\n}\n\n/**\n * Entry Point for normalizing\n */\nexport function normalizeLine(segments: Segment[]) {\n  /**\n   * We need to duplicate `segments` because `normalizeNodes` will manipulate the\n   * array but the original array coming from Slate will be readOnly.\n   */\n  const line: LineElement = {\n    type: \"line\",\n    children: duplicateSegments(segments),\n  }\n  normalizeNodes([line], undefined)\n  return line.children\n}\n","import { isPlainSpace, isText } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\n/**\n * If we ever find two spaces next to each other, merge them together.\n *\n * This can happen, for example, if there were spaces next to each other but\n * with different marks. It can also happen from other normalizers. For example,\n * there is a normalizer that moves spaces at the outer edges of an anchor\n * outside of the anchor.\n */\nexport function mergeAdjacentSpaces({\n  node,\n  nextNode,\n  nodes: nodes,\n  index,\n}: NormalizeOptions): boolean {\n  if (!isText(node) || !isPlainSpace(node) || node.code) return false\n  if (!isText(nextNode) || !isPlainSpace(nextNode) || nextNode.code) return false\n  nodes.splice(index, 2, { text: `${node.text}${nextNode.text}` })\n  return true\n}\n","import { Segment } from \"../../../../types\"\nimport { isElement, isPlainSpace, isText } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\nexport function moveSpacesAtStartOfAnchor({\n  node,\n  nodes,\n  prevNode,\n  index,\n}: NormalizeOptions): boolean {\n  if (!isElement(node)) return false\n  if (node.type !== \"anchor\") return false\n  const firstChild = node.children[0] as Segment\n  if (isText(firstChild) && isPlainSpace(firstChild)) {\n    // remove the first child from the anchor\n    node.children.splice(0, 1)\n    // add the first child\n    if (isText(prevNode) && isPlainSpace(prevNode)) {\n      prevNode.text = `${prevNode.text}${firstChild.text}`\n    } else {\n      nodes.splice(index, 0, { text: firstChild.text })\n    }\n    return true\n  }\n  return false\n}\n\nexport function moveSpacesAtEndOfAnchor({\n  node,\n  nodes,\n  nextNode,\n  index,\n}: NormalizeOptions): boolean {\n  if (!isElement(node)) return false\n  if (node.type !== \"anchor\") return false\n  const lastChild = node.children[node.children.length - 1] as Segment\n  if (isText(lastChild) && isPlainSpace(lastChild)) {\n    // remove the first child from the anchor\n    node.children.splice(node.children.length - 1, 1)\n    // add the first child\n    if (isText(nextNode) && isPlainSpace(nextNode)) {\n      nextNode.text = `${lastChild.text}${nextNode.text}`\n    } else {\n      nodes.splice(index + 1, 0, { text: lastChild.text })\n    }\n    return true\n  }\n  return false\n}\n","import { isElement } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\nexport function mustHaveOneTextChild({ node }: NormalizeOptions): boolean {\n  if (!isElement(node)) return false\n  if (node.type !== \"line\") return false\n  if (node.children.length > 0) return false\n  node.children.push({ text: \"\" })\n  return true\n}\n","import { Text } from \"../../../../types\"\nimport { isPlainSpace, isText } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\n/**\n * If a Text Node has spaces at the very start, or at the very end, we slice\n * those spaces into their own nodes.\n *\n * This is to help us later with the serialize process because we need spaces\n * to be isolated so that when we apple tokens like `**bold**` we are able\n * to place the tokens so that they are always against the non-space characters.\n *\n * For example, `** bold**` would not bold the text because the `**` is not\n * touching the word `bold` on the left.\n *\n * The algorithm here works by looking for a RegExp match on spaces on the\n * left or the right. If either are found, then it splits it into three parts\n * (left space, middle and right space) and then filteres out any zero length\n * spaces at the end. In this way, we handle left and right spaces in one\n * pass.\n */\nexport function sliceSpacesAtNodeBoundaries({\n  node,\n  nodes,\n  index,\n}: NormalizeOptions): boolean {\n  if (!isText(node)) return false\n  if (isPlainSpace(node)) return false\n  /**\n   * The content of Inline Code is literal so don't move the spaces out of it.\n   */\n  if (node.code) return false\n  const match = node.text.match(/^(\\s*)(.*?)(\\s*)$/)\n  if (!match) return false\n  if (match[1].length === 0 && match[3].length === 0) return false\n  const nextSegments: Text[] = [\n    { text: match[1] },\n    { ...node, text: match[2] },\n    { text: match[3] },\n  ].filter((text) => text.text !== \"\")\n  nodes.splice(index, 1, ...nextSegments)\n  return true\n}\n","import { isElement, isPlainSpace, isText } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\nexport function trimSpaceAtEndOfLine({\n  index,\n  nodes,\n  node,\n  parent,\n}: NormalizeOptions): boolean {\n  if (index !== nodes.length - 1) return false\n  if (nodes.length <= 1) return false\n  if (!isText(node)) return false\n  if (!isPlainSpace(node)) return false\n  if (parent && isElement(parent) && parent.type === \"line\") {\n    nodes.splice(nodes.length - 1, 1)\n    return true\n  }\n  return false\n}\n","import { isElement, isPlainSpace, isText } from \"../../utils\"\nimport { NormalizeOptions } from \"../types\"\n\nexport function trimSpaceAtStartOfLine({\n  index,\n  nodes,\n  node,\n  parent,\n}: NormalizeOptions): boolean {\n  if (index !== 0) return false\n  if (nodes.length === 0) return false\n  if (!isText(node)) return false\n  if (!isPlainSpace(node)) return false\n  if (parent && isElement(parent) && parent.type === \"line\") {\n    nodes.splice(0, 1)\n    return true\n  }\n  return false\n}\n","import { NormalizeOptions } from \"../types\"\nimport { mergeAdjacentSpaces } from \"./merge-adjacent-spaces\"\nimport {\n  moveSpacesAtEndOfAnchor,\n  moveSpacesAtStartOfAnchor,\n} from \"./move-spaces-out-of-anchors\"\nimport { mustHaveOneTextChild } from \"./must-have-one-text-child\"\nimport { sliceSpacesAtNodeBoundaries } from \"./slice-spaces-at-node-boundaries\"\nimport { trimSpaceAtEndOfLine } from \"./trim-spaces-at-end-of-line\"\nimport { trimSpaceAtStartOfLine } from \"./trim-spaces-at-start-of-line\"\n\nexport const normalizers: Array<(options: NormalizeOptions) => boolean> = [\n  sliceSpacesAtNodeBoundaries,\n  moveSpacesAtStartOfAnchor,\n  moveSpacesAtEndOfAnchor,\n  mergeAdjacentSpaces,\n  trimSpaceAtStartOfLine,\n  trimSpaceAtEndOfLine,\n  mustHaveOneTextChild,\n]\n","import { normalizers } from \"./normalizers\"\nimport { NormalizeOptions } from \"./types\"\n\n/**\n * Attempts to run all normalizers on the given Node one by one.\n *\n * If any normalizer makes an update, this function exits immediately and\n * returns a `true` value indicating that a normalizer has made an update.\n *\n * Because we don't know how that update modified the data structure, another\n * pass will be made at running all the normalizers.\n *\n * This is not the most efficient route, but there isn't a lot of processing\n * we need to do and this reduces the likelihood of bugs. Normalization is\n * similar to how it works in Slate but we don't keep track of dirty paths\n * and simply rerun the normalizations at the given level until it is clean.\n */\nexport function runNormalizersOnNode(normalizeOptions: NormalizeOptions) {\n  for (const normalizer of normalizers) {\n    const isHandled = normalizer(normalizeOptions)\n    if (isHandled) {\n      return true\n    }\n  }\n  return false\n}\n","import { AnchorElement } from \"../../../../anchor-plugin\"\n\nimport { isElement } from \"../utils\"\nimport { runNormalizersOnNode } from \"./run-normalizers-on-node\"\nimport { LineElement, Node, NormalizeOptions } from \"./types\"\n\nconst MAX_RERUNS = 72\n\nexport function normalizeNodes(\n  nodes: Node[],\n  parent?: AnchorElement | LineElement\n): boolean {\n  let isAnyUpdated = false\n  let isUpdated\n  let runs = 0\n  const maxReruns = (nodes.length + 1) * MAX_RERUNS\n  do {\n    isUpdated = false\n    runs = runs + 1\n    if (runs > maxReruns)\n      throw new Error(\n        `There have been ${runs} normalization passes (72x the number of nodes at this level). This likely indicates a bug in the code.`\n      )\n    segmentLoop: for (let i = 0; i < nodes.length; i++) {\n      const node: Node = nodes[i]\n      /**\n       * Normalize the children of the current Node before normalizing the\n       * Node itself.\n       */\n      if (isElement(node)) {\n        const isChildrenUpdated = normalizeNodes(\n          node.children as Array<AnchorElement | LineElement>,\n          node\n        )\n        if (isChildrenUpdated) {\n          isUpdated = true\n          isAnyUpdated = true\n          break segmentLoop\n        }\n      }\n      /**\n       * Create the normalizeOptions\n       */\n      const prevNode: Node | undefined = nodes[i - 1]\n      const nextNode: Node | undefined = nodes[i + 1]\n      const options: NormalizeOptions = {\n        parent,\n        node,\n        prevNode,\n        nextNode,\n        index: i,\n        nodes,\n      }\n\n      /**\n       * Run the normalizers on this node.\n       */\n      if (runNormalizersOnNode(options)) {\n        isUpdated = true\n        isAnyUpdated = true\n        break segmentLoop\n      }\n    }\n  } while (isUpdated)\n  return isAnyUpdated\n}\n","import { Text as SlateText } from \"slate\"\n\nimport { Segment } from \"../../../types\"\nimport { assertUnreachable } from \"../../../utils\"\nimport { serializeImageShared } from \"../../serialize-image-shared\"\nimport { serializeCodeText } from \"../segment/serialize-code-text\"\nimport { serializeAnchor } from \"./serialize-anchor\"\nimport { serializeNonCodeText } from \"./serialize-non-code-text\"\n\nexport function serializeSegment(segment: Segment): string {\n  if (SlateText.isText(segment)) {\n    /**\n     * If the segment is a `code` segment, we need to use a different strategy\n     * for escaping the `code` segment. This is why it needs a separate\n     * serializing function.\n     */\n    if (segment.code) return serializeCodeText(segment)\n    /**\n     * Otherwise, we use the standard text escaping code.\n     */\n    return serializeNonCodeText(segment)\n  }\n  switch (segment.type) {\n    case \"anchor\": {\n      return serializeAnchor(segment)\n    }\n    case \"image-inline\":\n      return serializeImageShared(segment)\n    default:\n      assertUnreachable(segment)\n  }\n}\n","import { Text } from \"../../../types\"\n\nexport function serializeCodeText(text: Text): string {\n  let max = 0\n  for (const match of text.text.matchAll(/[`]+/g)) {\n    max = Math.max(max, match[0].length)\n  }\n  if (max === 0) return `\\`${text.text.replace(/[`]/g, \"\\\\`\")}\\``\n  return `${\"`\".repeat(max + 1)} ${text.text} ${\"`\".repeat(max + 1)}`\n}\n","import { AnchorElement } from \"../../../../anchor-plugin\"\n\nimport { Segment } from \"../../../types\"\nimport { serializeLine } from \"../serialize-line\"\nimport { getCommonAnchorMarks } from \"../utils\"\n\nfunction escapeTitle(title: string): string {\n  return title.replace(/\"/g, '\\\\\"')\n}\n\nexport function serializeAnchor(anchor: AnchorElement): string {\n  const commonAnchorMarks = getCommonAnchorMarks(anchor.children as Segment[])\n  if (anchor.href.startsWith(\"$\"))\n    return serializeLine(\n      anchor.children as Segment[],\n      commonAnchorMarks,\n      commonAnchorMarks\n    )\n  if (typeof anchor.title === \"string\" && anchor.title.length > 0) {\n    return (\n      /**\n       * TODO: Handle anchor children more elegantly in serializeAnchor.\n       *\n       * We type cast `children` as `Segment` here because the children of an\n       * `anchor` is limited to be Inline types. There are two things to do\n       * related to this though:\n       *\n       * - [ ] consider fixing the `anchor` type to actually limit the\n       *   children as expected.\n       * - [ ] consider expanding the definition of `Segment` to include\n       *   inline images as that is an acceptable inline value which is\n       *   currently not defined as part of Segment.\n       */\n      `[${serializeLine(\n        anchor.children as Segment[],\n        commonAnchorMarks,\n        commonAnchorMarks\n      )}](${anchor.href} \"${escapeTitle(anchor.title)}\")`\n    )\n  } else {\n    return (\n      /**\n       * TODO: Handle anchor children more elegantly in serializeAnchor.\n       *\n       * We type cast `children` as `Segment` here because the children of an\n       * `anchor` is limited to be Inline types. There are two things to do\n       * related to this though:\n       *\n       * - [ ] consider fixing the `anchor` type to actually limit the\n       *   children as expected.\n       * - [ ] consider expanding the definition of `Segment` to include\n       *   inline images as that is an acceptable inline value which is\n       *   currently not defined as part of Segment.\n       */\n      `[${serializeLine(\n        anchor.children as Segment[],\n        commonAnchorMarks,\n        commonAnchorMarks\n      )}](${anchor.href})`\n    )\n  }\n}\n","import { Text } from \"../../../types\"\nimport { escapeText } from \"../utils\"\n\nexport function serializeNonCodeText(text: Text): string {\n  const escaped = escapeText(text.text)\n  // Convert soft breaks (\\n) to markdown line breaks (two trailing spaces + newline)\n  // so they render as <br> in markdown preview.\n  return escaped.replace(/\\n/g, \"  \\n\")\n}\n","import {\n  TableCellElement,\n  TableColumnAlign,\n  TableContentElement,\n  TableElement,\n  TableRowElement,\n} from \"../../../table-plugin\"\n\nimport { Segment } from \"../../types\"\nimport { assert, assertElementType } from \"../../utils\"\nimport { serializeLine } from \"../serialize-line\"\n\nexport function serializeTable(element: TableElement): string {\n  const lines: string[] = []\n  lines.push(serializeTableRow(element.children[0]))\n  lines.push(serializeColumns(element.columns))\n  element.children.slice(1).forEach((row) => {\n    lines.push(serializeTableRow(row))\n  })\n  return `${lines.join(\"\\n\")}\\n\\n`\n}\n\nfunction serializeColumns(columns: TableElement[\"columns\"]): string {\n  const isAllLeft = columns.every((column) => column.align === \"left\")\n  /**\n   * If all of the columns are to the left, it looks nicer if we don't specify\n   * column alignment in the markdown at all. Just use the default `---` to\n   * specify each column.\n   */\n  if (isAllLeft) {\n    return `|${columns.map(() => \"---\").join(\"|\")}|`\n  }\n  /**\n   * If one or more of the columns is not aligned left, let's add some clarity\n   * and specify the alignment of all the columns including the `left` aligned\n   * ones.\n   */\n  return `|${columns.map((column) => serializeAlign(column.align)).join(\"|\")}|`\n}\n\nfunction serializeAlign(align: TableColumnAlign) {\n  switch (align) {\n    case \"left\":\n      return \":---\"\n    case \"center\":\n      return \":---:\"\n    case \"right\":\n      return \"---:\"\n  }\n}\n\nfunction serializeTableRow(element: TableRowElement): string {\n  assertElementType(element, \"table-row\")\n  return `|${element.children.map(serializeTableCell).join(\"|\")}|`\n}\n\nfunction serializeTableCell(element: TableCellElement): string {\n  assertElementType(element, \"table-cell\")\n  assert(\n    element.children.length === 1,\n    `Expected table-cell to have one child but is ${JSON.stringify(\n      element.children\n    )}`\n  )\n  return element.children.map(serializeTableContent).join(\"\")\n}\n\nfunction serializeTableContent(element: TableContentElement): string {\n  assertElementType(element, \"table-content\")\n  const line = serializeLine(element.children as Segment[])\n  // Replace soft breaks (two trailing spaces + newline) and bare newlines\n  // with <br> so the table row stays on a single line in GFM markdown.\n  return line.replace(/ {2}\\n/g, \"<br>\").replace(/\\n/g, \"<br>\")\n}\n","import { Element, Segment } from \"../types\"\nimport { assertUnreachable } from \"../utils\"\nimport { serializeElements } from \"./serialize-elements\"\nimport { serializeCodeBlock } from \"./serialize-code-block\"\nimport { serializeImageBlock } from \"./serialize-image-block\"\nimport { serializeLine } from \"./serialize-line\"\nimport { serializeTable } from \"./serialize-table\"\n\nconst LIST_INDENT_SIZE = 4\n\nexport function serializeElement(element: Element, orders: number[]): string {\n  switch (element.type) {\n    case \"anchor\":\n      return `[${serializeLine(element.children as Segment[])}](${element.href\n        })`\n    case \"block-quote\": {\n      const lines = serializeElements(element.children as Element[])\n      return `${lines\n        .split(\"\\n\")\n        .map((line) => (line ? `> ${line}` : \">\"))\n        .join(\"\\n\")}\\n\\n`\n    }\n    case \"heading\":\n      return `${\"#\".repeat(element.level)} ${serializeLine(\n        element.children as Segment[]\n      )}\\n\\n`\n    case \"horizontal-rule\":\n      return \"---\\n\\n\"\n    case \"paragraph\": {\n      const content = serializeLine(element.children as Segment[])\n      if (content === \"\") {\n        return `\\u00A0\\n\\n`\n      }\n      return `${content}\\n\\n`\n    }\n    /**\n     * Table\n     */\n    case \"table\":\n      return serializeTable(element)\n    case \"table-row\":\n    case \"table-cell\":\n    case \"table-content\":\n      throw new Error(\n        `Table elements should only be present as children of table which should be handled by serializeTable. Got ${element.type} may indicate an error in normalization.`\n      )\n    /**\n     * List\n     */\n    case \"unordered-list-item\": {\n      const indent = \" \".repeat(element.depth * LIST_INDENT_SIZE)\n      return `${indent}- ${serializeLine(element.children as Segment[])}\\n`\n    }\n    case \"ordered-list-item\": {\n      const indent = \" \".repeat(element.depth * LIST_INDENT_SIZE)\n      return `${indent}${orders[element.depth]}. ${serializeLine(\n        element.children as Segment[]\n      )}\\n`\n    }\n    case \"task-list-item\": {\n      const indent = \" \".repeat(element.depth * LIST_INDENT_SIZE)\n      let line = serializeLine(element.children as Segment[])\n      if (line.trim() === \"\") {\n        line = \"&#32;\"\n      }\n      return `${indent}- [${element.checked ? \"x\" : \" \"}] ${line}\\n`\n    }\n    case \"image-block\":\n      return serializeImageBlock(element)\n    case \"image-inline\":\n      return `![${element.alt || \"\"}](${element.url})`\n    case \"code-block\":\n      return serializeCodeBlock(element)\n    case \"code-block-line\":\n      throw new Error(\n        `Code block line elements should only be present as children of code-block which should be handled by serializeCodeBlock. Got code-block-line may indicate an error in normalization.`\n      )\n    case \"html-block\":\n      return `${element.html}\\n\\n`\n  }\n  assertUnreachable(element)\n}\n","import { Element } from \"../types\"\nimport { serializeElement } from \"./serialize-element\"\n\nexport function serializeElements(elements: Element[]): string {\n  const segments: string[] = []\n\n  /**\n   * The orders array keeps track of the number of ordered list items at each\n   * depth. This is used to generate the number for each ordered list item.\n   */\n  let orders: number[] = []\n\n  for (let i = 0; i < elements.length; i++) {\n    const element = elements[i];\n    const nextElement = i < elements.length - 1 ? elements[i + 1] : null;\n\n    if (element.type === \"ordered-list-item\") {\n      /**\n       * When we're at an ordered list item, we increment the order at the\n       * current depth level and we remove any orders at a deeper depth level.\n       */\n      orders[element.depth] = (orders[element.depth] || 0) + 1\n      orders = orders.slice(0, element.depth + 1)\n    } else if (\n      element.type === \"unordered-list-item\" ||\n      element.type === \"task-list-item\"\n    ) {\n      /**\n       * When we're at an unordered list item, we slice the orders array to\n       * remove any orders at a deeper depth level.\n       */\n      orders = orders.slice(0, element.depth)\n    } else {\n      /**\n       * When we're at any other element, we reset the orders array because\n       * we're no longer in a list.\n       */\n      orders = []\n    }\n\n    // Get the serialized element\n    let serialized = serializeElement(element, orders);\n\n    // If this is a list item and the next element is not a list item,\n    // add an extra newline to create proper spacing between list and paragraph\n    if ((element.type === \"ordered-list-item\" ||\n      element.type === \"unordered-list-item\" ||\n      element.type === \"task-list-item\") &&\n      (!nextElement ||\n        (nextElement.type !== \"ordered-list-item\" &&\n          nextElement.type !== \"unordered-list-item\" &&\n          nextElement.type !== \"task-list-item\"))) {\n      serialized = serialized.replace(/\\n$/, \"\\n\\n\");\n    }\n\n    segments.push(serialized);\n  }\n  /**\n   * NOTE:\n   *\n   * We remove trailing whitespace because we want minimum viable markdown.\n   * It also makes it easier to test.\n   */\n  const joined = segments.join(\"\") //.trim()\n\n  /**\n   * If there is no content return an empty string for the Markdown.\n   * Use a regex that only matches ASCII whitespace (not \\u00A0) so that\n   * documents consisting entirely of blank lines (NBSP paragraphs) are\n   * preserved.\n   */\n  if (joined.replace(/[\\t\\n\\r ]/g, \"\") === \"\") return \"\"\n\n  /**\n   * Remove leading newlines and trim trailing ASCII whitespace only.\n   * We use a regex instead of .trim() because .trim() also removes\n   * non-breaking space (\\u00A0) which is used to represent empty\n   * paragraphs (blank lines) in the serialized markdown.\n   */\n  return joined.replace(/^\\n+/, \"\").replace(/[\\t\\n\\r ]+$/, \"\")\n}\n","import { Element } from \"../types\"\nimport { normalizeElementListDepths } from \"./normalize/normalizeElementListDepths\"\nimport { serializeElements } from \"./serialize-elements\"\n\nexport function serialize(elements: Element[]): string {\n  const normalizedElements = normalizeElementListDepths(elements)\n  return serializeElements(normalizedElements)\n}\n","interface Translations {\n  [key: string]: {\n    bold: string;\n    italic: string;\n    strike: string;\n    inlineCode: string;\n    underline: string;\n    highlight: string;\n    increaseDepth: string;\n    decreaseDepth: string;\n    heading1: string;\n    heading2: string;\n    heading3: string;\n    normal: string;\n    paragraph: string;\n    paragraphStyle: string;\n    bulletList: string;\n    numberedList: string;\n    checkList: string;\n    list: string;\n    linkUrl: string;\n    linkText: string;\n    linkTextHint: string;\n    tooltipText: string;\n    tooltipHint: string;\n    apply: string;\n    cancel: string;\n    insertLink: string;\n    quote: string;\n    insertTable: string;\n    insertImage: string;\n    insertImageFromUrl: string;\n    insert: string;\n    format: string;\n    imageUrlRequired: string;\n    altText: string;\n    title: string;\n    imageDescription: string;\n    imageTitle: string;\n    switchToVisualEditor: string;\n    switchToRawMarkdown: string;\n    codeBlock: string;\n    increaseQuoteDepth: string;\n    horizontalRule: string;\n    register: string;\n    imageSourceUrl: string;\n    imageSourceFile: string;\n    selectFile: string;\n    uploading: string;\n    saving: string;\n    uploadComplete: string;\n    imageSourceSelect: string;\n    vaultPath: string;\n    vaultPathHint: string;\n  };\n}\n\nexport const translations: Translations = {\n  ja: {\n    bold: \"太字\",\n    italic: \"斜体\",\n    strike: \"取り消し線\",\n    inlineCode: \"インラインコード\",\n    underline: \"下線\",\n    highlight: \"ハイライト\",\n    increaseDepth: \"階層を深くする\",\n    decreaseDepth: \"階層を浅くする\",\n    heading1: \"見出し1\",\n    heading2: \"見出し2\",\n    heading3: \"見出し3\",\n    normal: \"標準\",\n    paragraph: \"段落\",\n    paragraphStyle: \"段落スタイル\",\n    bulletList: \"箇条書き\",\n    numberedList: \"番号付きリスト\",\n    checkList: \"チェックリスト\",\n    list: \"リスト\",\n    linkUrl: \"リンクのURL\",\n    linkText: \"リンクテキスト\",\n    linkTextHint: \"リンクとして表示されるテキスト\",\n    tooltipText: \"ツールチップテキスト\",\n    tooltipHint: \"マウスホバー時に表示されるツールチップ\",\n    apply: \"適用\",\n    cancel: \"キャンセル\",\n    insertLink: \"リンク\",\n    quote: \"引用\",\n    insertTable: \"表\",\n    insertImage: \"画像\",\n    insertImageFromUrl: \"画像\",\n    insert: \"挿入\",\n    format: \"書式\",\n    imageUrlRequired: \"画像URL（必須）：\",\n    altText: \"代替テキスト：\",\n    title: \"ツールチップ：\",\n    imageDescription: \"画像の説明\",\n    imageTitle: \"画像のツールチップ\",\n    switchToVisualEditor: \"ビジュアルエディタに切り替え\",\n    switchToRawMarkdown: \"マークダウン表示に切り替え\",\n    codeBlock: \"コードブロック\",\n    increaseQuoteDepth: \"引用を重ねる\",\n    horizontalRule: \"区切り線\",\n    register: \"登録\",\n    imageSourceUrl: \"URL\",\n    imageSourceFile: \"アップロード\",\n    selectFile: \"ファイルを選択\",\n    uploading: \"アップロード中...\",\n    saving: \"保存中...\",\n    uploadComplete: \"アップロード完了\",\n    imageSourceSelect: \"アップロード済み\",\n    vaultPath: \"保存先パス：\",\n    vaultPathHint: \"vault内の保存先パスを入力してください\",\n  },\n  en: {\n    bold: \"Bold\",\n    italic: \"Italic\",\n    strike: \"Strikethrough\",\n    inlineCode: \"Inline Code\",\n    underline: \"Underline\",\n    highlight: \"Highlight\",\n    increaseDepth: \"Increase Depth\",\n    decreaseDepth: \"Decrease Depth\",\n    heading1: \"Heading 1\",\n    heading2: \"Heading 2\",\n    heading3: \"Heading 3\",\n    normal: \"Normal\",\n    paragraph: \"Paragraph\",\n    paragraphStyle: \"Paragraph Style\",\n    bulletList: \"Bullet List\",\n    numberedList: \"Numbered List\",\n    checkList: \"Check List\",\n    list: \"List\",\n    linkUrl: \"Link URL\",\n    linkText: \"Link Text\",\n    linkTextHint: \"Text displayed as the link\",\n    tooltipText: \"Tooltip Text\",\n    tooltipHint: \"Tooltip shown on mouse hover\",\n    apply: \"Apply\",\n    cancel: \"Cancel\",\n    insertLink: \"Link\",\n    quote: \"Quote\",\n    insertTable: \"Table\",\n    insertImage: \"Image\",\n    insertImageFromUrl: \"Image\",\n    insert: \"Insert\",\n    format: \"Format\",\n    imageUrlRequired: \"Image URL (required):\",\n    altText: \"Alt Text:\",\n    title: \"tooltip:\",\n    imageDescription: \"Description of the image\",\n    imageTitle: \"tooltip\",\n    switchToVisualEditor: \"Switch to visual editor\",\n    switchToRawMarkdown: \"Switch to raw markdown\",\n    codeBlock: \"Code Block\",\n    increaseQuoteDepth: \"Increase Quote Depth\",\n    horizontalRule: \"Horizontal Rule\",\n    register: \"Register\",\n    imageSourceUrl: \"URL\",\n    imageSourceFile: \"Upload\",\n    selectFile: \"Select File\",\n    uploading: \"Uploading...\",\n    saving: \"Saving...\",\n    uploadComplete: \"Upload Complete\",\n    imageSourceSelect: \"Uploaded\",\n    vaultPath: \"Save Path:\",\n    vaultPathHint: \"Enter the path within the vault to save the file\",\n  },\n};\n\nexport type TranslationKey = keyof Translations[\"en\"];\n\nconst getLanguage = (): string => {\n  try {\n    // Check if we're in a browser environment\n    if (typeof window !== 'undefined' && window.navigator) {\n      return window.navigator.language.split(\"-\")[0];\n    }\n  } catch {\n    // Ignore any errors\n  }\n  // Default to 'en' in server environment\n  return 'en';\n};\n\nexport const t = (key: TranslationKey): string => {\n  const lang = getLanguage();\n  return translations[lang === \"ja\" ? \"ja\" : \"en\"][key];\n};\n\nexport const r = (value: string): string => {\n  const lang = getLanguage();\n  // 値がvalueと一致するキーを取得\n  const key = Object.keys(translations[lang === \"ja\" ? \"ja\" : \"en\"]).find(\n    (k) => translations[lang === \"ja\" ? \"ja\" : \"en\"][k as TranslationKey] === value\n  ) as TranslationKey;\n  return key || \"\";\n};\n","import { InputPluginSchema, TypedPluginFunction } from \"../types\"\nimport { BasePlugin } from \"../types/plugin/plugin\"\n\n/**\n * The `createPlugin` method here takes a function and returns the same\n * function.\n *\n * From a JavaScript point of view, it does nothing itself return itself.\n *\n * From a typing point of view, it takes these two arguments...\n *\n * - The CustomTypes used by the plugin as a Generic\n * - A function that when executed with an `Editor` object, returns a\n *   PluginObject as a function argument\n *\n * ...and ensure that the function argument adheres to the limits of the\n * Generic Argument.\n *\n * For example, if the CustomTypes defines an `Element`, then the function\n * argument will have its element related methods constrained to the Element\n * given in CustomTypes.\n *\n * The benefit of this is that it helps the Plugin only see what is relevant\n * to this plugin. In fact, it insists on it. This will prevent accidental\n * dependency on another plugin.\n *\n * You can add dependencies between plugins, but when we do that, it insists\n * on having that done explicitly.\n */\nexport const createPlugin = <T extends InputPluginSchema>(\n  fn: TypedPluginFunction<T>\n) => {\n  return { fn } as BasePlugin\n}\n","import { useEffect, useMemo, useRef } from \"react\"\nimport { Editor, Transforms } from \"slate\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { SinkEditor } from \"../types\"\nimport { createDecorate } from \"./create-decorate\"\nimport { createEditable } from \"./create-editable\"\nimport {\n  createOnDrop,\n  createOnKeyDown,\n  createOnKeyUp,\n  createOnPaste,\n} from \"./create-handler\"\nimport { createRenderElement } from \"./create-render-element\"\nimport { createRenderLeaf } from \"./create-render-leaf\"\nimport { createRenderPlaceholder } from \"./create-render-placeholder\"\nexport { SinkReset } from \"./styles\"\n\ntype DOMBeforeInputHandler = NonNullable<EditableProps[\"onDOMBeforeInput\"]>\ntype InputHandler = NonNullable<EditableProps[\"onInput\"]>\n\nconst hasNonAsciiText = (text: string): boolean => /[^\\x00-\\x7F]/.test(text)\n\nfunction selectDOMTargetRange(editor: Editor, event: InputEvent): void {\n  const [targetRange] = event.getTargetRanges()\n\n  if (!targetRange) return\n\n  try {\n    const range = ReactEditor.toSlateRange(\n      editor as unknown as ReactEditor,\n      targetRange,\n      {\n        exactMatch: false,\n        suppressThrow: false,\n      }\n    )\n    Transforms.select(editor, range)\n  } catch {\n    // Keep the current Slate selection if the browser target range is stale.\n  }\n}\n\nfunction createOnDOMBeforeInput(\n  originalFn: DOMBeforeInputHandler | undefined,\n  editor: Editor,\n  skipInputTextRef: React.MutableRefObject<string | null>\n): DOMBeforeInputHandler {\n  return (event) => {\n    const originalResult = originalFn?.(event)\n\n    if (originalResult != null || event.defaultPrevented) return originalResult\n    if (event.inputType !== \"insertText\") return originalResult\n    if (event.isComposing) return originalResult\n    if (typeof event.data !== \"string\" || event.data.length === 0) {\n      return originalResult\n    }\n    if (!hasNonAsciiText(event.data)) return originalResult\n\n    selectDOMTargetRange(editor, event)\n    event.preventDefault()\n    Editor.insertText(editor, event.data)\n    skipInputTextRef.current = event.data\n    return true\n  }\n}\n\nfunction createOnInput(\n  originalFn: InputHandler | undefined,\n  editor: Editor,\n  skipInputTextRef: React.MutableRefObject<string | null>\n): InputHandler {\n  return (event) => {\n    const originalResult = originalFn?.(event)\n\n    if (originalResult != null || event.defaultPrevented) return originalResult\n\n    const nativeEvent = event.nativeEvent\n\n    if (!(nativeEvent instanceof InputEvent)) return originalResult\n    if (nativeEvent.inputType !== \"insertText\") return originalResult\n    if (nativeEvent.isComposing) return originalResult\n    if (\n      typeof nativeEvent.data !== \"string\" ||\n      nativeEvent.data.length === 0\n    ) {\n      return originalResult\n    }\n    if (!hasNonAsciiText(nativeEvent.data)) return originalResult\n\n    if (skipInputTextRef.current === nativeEvent.data) {\n      skipInputTextRef.current = null\n      return originalResult\n    }\n\n    Editor.insertText(editor, nativeEvent.data)\n    return originalResult\n  }\n}\n\n/**\n * In Editable, we use the Slate context to grab the right things from\n * the editor.\n */\nexport function SinkEditable(originalProps: EditableProps): React.ReactElement {\n  const editor = useSlateStatic() as unknown as Editor & SinkEditor\n  const skipInputTextRef = useRef<string | null>(null)\n\n  /**\n   * We ask Slate to normalize the editor once at the very start.\n   *\n   * This is helpful for plugins that need to store some useful state in the\n   * document and to add or fix certain parts of the document. Not all of\n   * these values are stored in the saved documents.\n   *\n   * Some examples:\n   *\n   * - inserting collapsible paragraphs between void components. These should\n   *   not be saved.\n   *\n   * - Add column and row indexes to help with rendering which should not\n   *   be saved.\n   *\n   * Ideally, we wouldn't have to do any of this but pragmatically, it is\n   * the most performant route.\n   *\n   * Once we normalize the document once, the document is kept up to date\n   * through regular normalizing steps that are more performance because\n   * they only check changed nodes.\n   */\n  useEffect(() => {\n    Editor.normalize(editor, { force: true })\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [editor])\n\n  const { plugins } = editor.sink\n\n  const nextProps: EditableProps = useMemo(\n    () => ({\n      ...originalProps,\n      decorate: createDecorate(originalProps.decorate, plugins),\n      renderElement: createRenderElement(originalProps.renderElement, plugins),\n      renderLeaf: createRenderLeaf(originalProps.renderLeaf, plugins),\n      renderPlaceholder: createRenderPlaceholder(\n        originalProps.renderPlaceholder,\n        plugins\n      ),\n      /**\n       * NOTE: We skip `onKeyUp` as it is deprecated. If somebody needs it in new\n       * code, we can add it back in.\n       *\n       * https://developer.mozilla.org/en-US/docs/Web/API/Element/keypress_event\n       */\n      onKeyDown: createOnKeyDown(originalProps.onKeyDown, plugins),\n      onKeyUp: createOnKeyUp(originalProps.onKeyUp, plugins),\n      onPaste: createOnPaste(originalProps.onPaste, plugins),\n      onDrop: createOnDrop(originalProps.onDrop, plugins),\n      onDOMBeforeInput: createOnDOMBeforeInput(\n        originalProps.onDOMBeforeInput,\n        editor,\n        skipInputTextRef\n      ),\n      onInput: createOnInput(originalProps.onInput, editor, skipInputTextRef),\n    }),\n    [\n      originalProps.decorate,\n      originalProps.renderElement,\n      originalProps.renderLeaf,\n      originalProps.renderPlaceholder,\n      originalProps.onKeyDown,\n      originalProps.onKeyUp,\n      originalProps.onPaste,\n      originalProps.onDrop,\n      originalProps.onDOMBeforeInput,\n      originalProps.onInput,\n      originalProps.placeholder,\n      originalProps.className,\n      editor,\n      plugins,\n    ]\n  )\n\n  const NextEditable = useMemo(() => createEditable(plugins), [plugins])\n\n  /**\n   * NOTE:\n   *\n   * The following code is used to see if we are getting unnecessary re-renders.\n   *\n   * Comment it out when we are happy.\n   *\n   * - We SHOULD see `SinkeEditable render` whenever the markdown is updated\n   * - We SHOULD NOT see `SinkEditable mount` or unmount at each update\n   */\n  // console.log(\"SinkEditable render\")\n\n  // console.log(Object.values(nextProps))\n\n  // useEffect(() => {\n  //   console.log(\"SinkEditable mount\")\n  //   return () => {\n  //     console.log(\"SinkEditable unmount\")\n  //   }\n  // }, [NextEditable, nextProps])\n\n  return <NextEditable {...nextProps} />\n}\n","export function defined<T>(value: T | undefined): value is T {\n  return !!value\n}\n","import { NodeEntry, Range } from \"slate\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\nimport { defined } from \"./utils\"\n\n/**\n * Create the substituted `decorate` method.\n *\n * With decorate, we are taking all the ranges from all the decorators and\n * combining them together, including the ranges created from the `decorate`\n * attribute on `SinkEditable`.\n */\nexport function createDecorate(\n  originalFn: EditableProps[\"decorate\"],\n  plugins: BasePluginPolicy[]\n): NonNullable<EditableProps[\"decorate\"]> {\n  const fns = plugins\n    .map((plugin) => plugin.editableProps?.decorate)\n    .filter(defined)\n  return function (entry: NodeEntry): Range[] {\n    const ranges: Range[] = []\n    for (const fn of fns) {\n      const resultRanges = fn(entry)\n      ranges.push(...resultRanges)\n    }\n    if (originalFn) ranges.push(...originalFn(entry))\n    return ranges\n  }\n}\n","import { Editable } from \"slate-react\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\nimport { defined } from \"./utils\"\n\ntype EditableType = (editableProps: EditableProps) => React.JSX.Element\n\n/**\n * create a new Editable component that takes all the `renderEditable` functions\n * which are components and have them wrap around the original Editable component.\n */\nexport function createEditable(\n  plugins: BasePluginPolicy[]\n): NonNullable<EditableType> {\n  const fns = plugins.map((plugin) => plugin.renderEditable).filter(defined)\n\n  /**\n   * This creates the inner-most RenderEditable.\n   */\n  let CurrentRenderEditable = (props: EditableProps) => <Editable {...props} />\n  /**\n   * We iterate through all the `renderEditable` functions and wrap them\n   * around the next inner-most `renderEditable`.\n   */\n  for (const fn of fns) {\n    /**\n     * Assigns the CurrentRenderEditable as the previous one so that we can\n     * have it available to call in the NextRenderEditable\n     */\n    const PrevRenderEditable = CurrentRenderEditable\n\n    CurrentRenderEditable = (props: EditableProps) => {\n      return fn({\n        attributes: props,\n        Editable: PrevRenderEditable,\n      })\n    }\n  }\n\n  return CurrentRenderEditable\n}\n","import { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\n\n/**\n * Create the substituted event handler method.\n *\n * Generally, we are looking for the first result from any plugin or on\n * SinkEditable and return the first one that returns a value only.\n *\n * Iterate over all the plugin handlers. If one handler returns `false`\n * then we go to the next one until we get one that returns `true`. If we don't\n * fine on that returns `true`, then we go to the handler passed to the\n * `SinkEditable` component.\n */\n\n/**\n * TODO:\n *\n * It's probably not THAT important, but the holy grail as a programmer here is\n * to:\n *\n * 1. Have these functions created without the boilerplate. It really feels\n *    like it could be one function that takes `plugins` and a `key` and all\n *    the typing and stuff would work.\n *\n * 2. Build it in a way that's easy to reason about. There is probably a way\n *    to do this that works, but nobody will ever be able to work on it if there\n *    is a problem, and probably a way to do it where it's somewhat\n *    comprehensible.\n */\n\n/**\n * Here we define strictly the type for a method that creates an Event Handler\n * on Editable. We define this separately because (a) it is easier to do it and\n * give clarity to it as a separate type and (b) we want to check the actual\n * method that we created against this type as an early warning signal if we\n * did something wrong.\n *\n * A method that creates a method, that pulls from a plugin a function that is\n * similar to, but not exactly, like the function that it is going to be\n * returning, is a bit of a nightmare and this helps make sure we don't make\n * mistakes.\n *\n * In other words, don't remove this and use the automatic typing as it's a\n * good way to make sure that this method is typed correctly.\n */\ntype CreateHandler<K extends keyof EditableProps> = (\n  originalFn: EditableProps[K],\n  plugins: BasePluginPolicy[]\n) => NonNullable<EditableProps[K]>\n\n/**\n * Takes an array of Plugin objects and extracts all of the specified\n * `editableProps` handler functions from it. If it's not defined, we skip it\n * so that we end up with an Array that is populated with the functions only\n * and no `undefined` in it.\n */\nfunction extractEditableFns<\n  K extends keyof Required<BasePluginPolicy>[\"editableProps\"]\n>(\n  plugins: BasePluginPolicy[],\n  key: K\n): NonNullable<Required<BasePluginPolicy>[\"editableProps\"][K]>[] {\n  const fns: NonNullable<Required<BasePluginPolicy>[\"editableProps\"][K]>[] = []\n  for (const plugin of plugins) {\n    const maybeFn = plugin.editableProps?.[key]\n    if (maybeFn) fns.push(maybeFn)\n  }\n  return fns\n}\n\n/**\n * Takes an array of handler functions that will return a boolean which\n * indicates that an event was handled. If the function was handled, then we\n * return and stop execution immediately.\n *\n * We keep going through all the handlers until something handles it.\n *\n * If none of the plugin fns handle it, then we check to see if there was an\n * original function defined and execute that if there is.\n */\nfunction createHandlerFn<A>(\n  fns: ((arg: A) => boolean)[],\n  originalFn: ((arg: A) => void) | undefined\n) {\n  return function (event: A) {\n    for (const fn of fns) {\n      if (fn(event)) return\n    }\n    originalFn?.(event)\n  }\n}\n\n/**\n * keyDown handler\n */\nexport const createOnKeyDown: CreateHandler<\"onKeyDown\"> = (\n  originalFn,\n  plugins\n) => {\n  const fns = extractEditableFns(plugins, \"onKeyDown\")\n  return createHandlerFn(fns, originalFn)\n}\n\n/**\n * keyUp handler\n */\nexport const createOnKeyUp: CreateHandler<\"onKeyUp\"> = (\n  originalFn,\n  plugins\n) => {\n  const fns = extractEditableFns(plugins, \"onKeyUp\")\n  return createHandlerFn(fns, originalFn)\n}\n\n/**\n * onPaste handler\n */\nexport const createOnPaste: CreateHandler<\"onPaste\"> = (\n  originalFn,\n  plugins\n) => {\n  const fns = extractEditableFns(plugins, \"onPaste\")\n  return createHandlerFn(fns, originalFn)\n}\n\n/**\n * onDrop handler\n */\nexport const createOnDrop: CreateHandler<\"onDrop\"> = (originalFn, plugins) => {\n  const fns = extractEditableFns(plugins, \"onDrop\")\n  return createHandlerFn(fns, originalFn)\n}\n","import React from \"react\"\nimport { RenderElementProps } from \"slate-react\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\nimport { defined } from \"./utils\"\n\n/**\n * Create the substituted `renderElement` method.\n *\n * Generally, we are looking for the first result from any plugin or on\n * SinkEditable and return the first one that returns a value only.\n *\n * Iterate over all the plugin `renderElement`. If they return nothing\n * then we go to the next one until we hit a result. If we don't hit a\n * result, then we go to the `renderElement` passed to the `SinkEditable`\n * component.\n */\n\nexport function createRenderElement(\n  originalFn: EditableProps[\"renderElement\"],\n  plugins: BasePluginPolicy[]\n): NonNullable<EditableProps[\"renderElement\"]> {\n  const fns = plugins\n    .map((plugin) => plugin.editableProps?.renderElement)\n    .filter(defined)\n  return function renderElement(\n    renderElementProps: RenderElementProps\n  ): React.JSX.Element {\n    for (const fn of fns) {\n      const result = fn(renderElementProps)\n      if (result) return result\n    }\n    if (originalFn === undefined) {\n      throw new Error(\n        `Element with type ${renderElementProps.element.type} not handled. Note that renderElement is not defined on SinkEditable so this is only the result of checking the Sink Plugins.`\n      )\n    }\n    return originalFn(renderElementProps)\n  }\n}\n","import { cloneElement } from \"react\"\nimport { RenderLeafProps } from \"slate-react\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\nimport { defined } from \"./utils\"\n\n/**\n * Create the substituted `renderLeaf` method.\n *\n * Generally, we are looking for all the results from all the plugins and\n * SinkEditable and merge the results together by nesting the responses\n * starting from the first plugin on the outside to the `renderLeaf` method\n * on `SinkEditable` on the inside.\n */\n\nexport function createRenderLeaf(\n  originalFn: EditableProps[\"renderLeaf\"],\n  plugins: BasePluginPolicy[]\n): NonNullable<EditableProps[\"renderLeaf\"]> {\n  if (originalFn === undefined) {\n    throw new Error(`renderLeaf was not defined on SinkEditable`)\n  }\n\n  /**\n   * These get handled in reverse order. We wrap the last one around the\n   * actual `Text` and the earlier ones wrap around those. This\n   * feels more natural because the first plugin handles the outermost\n   * and we work our way inward.\n   */\n  const fns = plugins\n    .map((plugin) => plugin.editableProps?.renderLeaf)\n    .filter(defined)\n    .reverse()\n\n  return function (renderLeafProps) {\n    let value = originalFn({\n      ...renderLeafProps,\n      /**\n       * We override this because `attributes` should only appear on the\n       * uppermost leaf element if there are several nested ones and it's\n       * possible that this won't be the uppermost leaf.\n       *\n       * We add attributes back on at the very end so no need to worry if\n       * we omit it here.\n       */\n      attributes: {} as RenderLeafProps[\"attributes\"],\n    })\n    for (const fn of fns) {\n      const possibleValue = fn({\n        ...renderLeafProps,\n        children: value,\n      })\n      if (possibleValue) {\n        value = possibleValue\n      }\n    }\n    value = cloneElement(value, renderLeafProps.attributes) //{ key: 'your-unique-key-here' })\n    return value\n  }\n}\n","import React from \"react\"\nimport { RenderPlaceholderProps } from \"slate-react\"\nimport { EditableProps } from \"slate-react/dist/components/editable\"\n\nimport { BasePluginPolicy } from \"../types\"\nimport { defined } from \"./utils\"\n\n/**\n * Create the substituted `renderElement` method.\n *\n * Generally, we are looking for the first result from any plugin or on\n * SinkEditable and return the first one that returns a value only.\n *\n * Iterate over all the plugin `renderElement`. If they return nothing\n * then we go to the next one until we hit a result. If we don't hit a\n * result, then we go to the `renderElement` passed to the `SinkEditable`\n * component.\n */\n\nexport function createRenderPlaceholder(\n  originalFn: EditableProps[\"renderPlaceholder\"],\n  plugins: BasePluginPolicy[]\n): NonNullable<EditableProps[\"renderPlaceholder\"]> | undefined {\n  if (originalFn) return originalFn\n  const fns = plugins\n    .map((plugin) => plugin.editableProps?.renderPlaceholder)\n    .filter(defined)\n  if (fns.length === 0) return undefined\n  return function (\n    renderPlaceholderProps: RenderPlaceholderProps\n  ): React.JSX.Element {\n    if (fns.length > 1) {\n      throw new Error(\n        `Only one plugin can define renderPlaceholder but there are ${fns.length}`\n      )\n    }\n    const fn = fns[0]\n    if (fn == null) throw new Error(`Expected fn to be defined`)\n    return fn(renderPlaceholderProps)\n  }\n}\n","import styled from \"@emotion/styled\"\n\nexport const SinkReset = styled(\"div\")`\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  font-size: 1rem;\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto,\n    Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n  box-sizing: border-box;\n`\n","import { Element, Node } from \"slate\"\n\nimport { BasePluginPolicy, FullSinkEditor } from \"../types\"\n\n/**\n * Creates an overrideable editor action that takes a `Node` and returns a\n * `boolean` and creates a new version of the action that incorporates the\n * plugins.\n *\n * If the plugin returns a boolean, it takes the result and returns it.\n *\n * If the plugin returns undefined, it tries the next one.\n *\n * If no plugin handles the result, it returns the result of the original action.\n */\nexport function createBooleanAction<\n  K extends \"isVoid\" | \"isInline\" | \"isMaster\" | \"isSlave\" | \"isStandalone\"\n>(\n  editor: FullSinkEditor,\n  actionKey: K,\n  plugins: BasePluginPolicy[]\n): (node: Element) => boolean {\n  const originalAction = editor[actionKey]\n  const actionPlugins = plugins.filter((plugin) => plugin.editor?.[actionKey])\n  return function nextBooleanAction(node: Node): boolean {\n    for (const plugin of actionPlugins) {\n      const editorPlugin = plugin.editor as Record<string, ((n: Node) => boolean | undefined) | undefined> | undefined\n      const actionFn = editorPlugin?.[actionKey]\n      const result = actionFn?.(node)\n      if (typeof result === \"boolean\") return result\n    }\n    const origFn = originalAction as (n: Node) => boolean\n    return origFn(node)\n  }\n}\n","import { BaseEditor } from \"slate\"\n\nimport { BasePluginPolicy } from \"../types\"\n\n/**\n * Creates an overrideable editor action like `insertBreak` or `deleteBackward`\n * that usually returns `void` and creates a new version of the action that\n * adds the action from the plugin.\n *\n * If the plugin returns `true` it takes the result and returns it.\n *\n * If the plugin returns `false`, it tries the next one.\n *\n * If no plugin handles the result, it executed the original action.\n */\nexport function createVoidAction<\n  K extends\n    | \"normalizeNode\"\n    | \"deleteBackward\"\n    | \"deleteForward\"\n    | \"deleteFragment\"\n    | \"insertBreak\"\n    | \"insertFragment\"\n    | \"insertNode\"\n    | \"insertText\"\n>(editor: BaseEditor, actionKey: K, plugins: BasePluginPolicy[]) {\n  const originalAction = editor[actionKey]\n  const actionPlugins = plugins.filter((plugin) => plugin.editor?.[actionKey])\n  return function nextVoidAction(...args: Parameters<BaseEditor[K]>[]): void {\n    let isHandled = false\n    const afterHandledCallbacks: (() => void)[] = []\n    for (const plugin of actionPlugins) {\n      // @ts-expect-error - dynamic key access\n      const response = plugin.editor?.[actionKey]?.(...args)\n      if (typeof response === \"function\") {\n        afterHandledCallbacks.push(response)\n      } else if (response === true) {\n        isHandled = true\n        break\n      }\n    }\n    if (!isHandled) {\n      // @ts-expect-error - dynamic args spread\n      originalAction(...args)\n    }\n    afterHandledCallbacks.forEach((callback) => callback())\n  }\n}\n","import { BaseEditor } from \"slate\"\n\nimport { BasePluginFn, ExtractedPluginSchema, FullSinkEditor } from \"../types\"\nimport { createBooleanAction } from \"./create-boolean-action\"\nimport { createVoidAction } from \"./create-void-action\"\n\nexport function createWithSink<T extends ExtractedPluginSchema>(\n  pluginFns: BasePluginFn[]\n) {\n  /**\n   * The `editor` in the props can be a `BaseEditor` but we transform it\n   * into a `SinkEditor` before returning it.\n   */\n  return <E extends BaseEditor>(\n    originalEditor: E,\n    options: T[\"Options\"]\n  ): E & FullSinkEditor => {\n    const editor = originalEditor as E & FullSinkEditor\n\n    /**\n     * Executes the plugin on the `editor` with every one of the\n     * `pluginFunctions` to get the `pluginObject`\n     */\n    const plugins = pluginFns.map((plugin) =>\n      plugin(editor, options, { createPolicy: (x) => x })\n    )\n    editor.sink = { plugins }\n\n    /**\n     * Create the default for SinkEditor methods if they don't already exist.\n     */\n    editor.isMaster = \"isMaster\" in editor ? editor.isMaster : () => false\n    editor.isSlave = \"isSlave\" in editor ? editor.isSlave : () => false\n    editor.isStandalone =\n      \"isStandalone\" in editor ? editor.isStandalone : () => false\n\n    Object.assign(editor, {\n      /**\n       * void\n       */\n      normalizeNode: createVoidAction(editor, \"normalizeNode\", plugins),\n      deleteBackward: createVoidAction(editor, \"deleteBackward\", plugins),\n      deleteForward: createVoidAction(editor, \"deleteForward\", plugins),\n      deleteFragment: createVoidAction(editor, \"deleteFragment\", plugins),\n      insertBreak: createVoidAction(editor, \"insertBreak\", plugins),\n      insertFragment: createVoidAction(editor, \"insertFragment\", plugins),\n      insertNode: createVoidAction(editor, \"insertNode\", plugins),\n      insertText: createVoidAction(editor, \"insertText\", plugins),\n      /**\n       * boolean\n       */\n      isInline: createBooleanAction(editor, \"isInline\", plugins),\n      isVoid: createBooleanAction(editor, \"isVoid\", plugins),\n      isMaster: createBooleanAction(editor, \"isMaster\", plugins),\n      isSlave: createBooleanAction(editor, \"isSlave\", plugins),\n      isStandalone: createBooleanAction(editor, \"isStandalone\", plugins),\n    })\n\n    return editor\n  }\n}\n","import { SinkEditable } from \"../editable\"\nimport { createWithSink } from \"../editor\"\nimport { BasePlugin, ExtractedPluginSchema } from \"../types\"\n\n/**\n * A sink is just a function\n */\nexport const createSink = <T extends ExtractedPluginSchema>(\n  pluginFunctions: BasePlugin[]\n) => {\n  const fns = pluginFunctions.map((plugin) => plugin.fn)\n  const withSink = createWithSink<T>(fns)\n\n  const returnValue = { withSink, SinkEditable }\n  return returnValue\n}\n","export const isDebug = false\n","import { Editor, Element, Location } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\n/**\n * Defines a value you'd find in a function's parameters as a replacement for\n * `at`. The benefit of using `BetterAt` is that it allows you to search\n * using an `Element`.\n */\nexport type BetterAt = Location | Element | null\n\n/**\n * Takes a `BetterAt` type which can include an `Element` and returns a\n * Location.\n */\nexport function betterAt(editor: Editor, at: Location | Element): Location {\n  if (!Element.isElement(at)) return at\n  return ReactEditor.findPath(editor, at)\n}\n","/**\n * Takes a function and returns a new function with the first X arguments of\n * that function pre-filled with the provided values.\n *\n * NOTE:\n *\n * This is not a full implementation of a curry but gives us what we want in a\n * lightweight manner, with low complexity and good typing. Namely, we need to\n * specify how many arguments to curry.\n *\n * This can probably be done in a way where the argument number doesn't have to\n * be specified ahead of time; however, these are the reasons I've kept it this\n * way for now.\n *\n * - It's easier to understand. We don't need to create a recursive TypeScript\n *   type.\n * - We only ever need currying a little anyways\n * - It's probably a little more performant this way\n *\n * WARNING FOR GENERICS:\n *\n * If the function you are currying has a generic, you will need to write a\n * generic manually for it then apply it manually using `as`. For example:\n *\n * const curriedToggleElements = curry(toggleElements, editor) as\n *   CurriedToggleElements\n */\n\n/**\n * Curry one argument from the left\n */\nexport function curryOne<CurriedArg, RestArgs extends unknown[], R>(\n  fn: (curriedArg: CurriedArg, ...restArgs: RestArgs) => R,\n  curriedArg: CurriedArg\n): (...args: RestArgs) => R {\n  return fn.bind(null, curriedArg)\n}\n\n/**\n * Curry two arguments from the left\n */\nexport function curryTwo<Arg1, Arg2, RestArgs extends unknown[], R>(\n  fn: (arg1: Arg1, arg2: Arg2, ...restArgs: RestArgs) => R,\n  arg1: Arg1,\n  arg2: Arg2\n): (...args: RestArgs) => R {\n  return fn.bind(null, arg1, arg2)\n}\n","const IS_MAC_REGEX = /mac os x|macintosh/i\n\nlet isMacValue: boolean | undefined = undefined\n\n/**\n * `isMac` is a function and not a const because `window.navigator` only exists\n * on the browser and will throw an Error on the server.\n */\nexport function isMac() {\n  /**\n   * Memoized for performance\n   */\n  if (isMacValue !== undefined) return isMacValue\n  try {\n    const { userAgent } = window.navigator\n    isMacValue = IS_MAC_REGEX.test(userAgent)\n  } catch {\n    isMacValue = false\n  }\n  return isMacValue\n}\n","/**\n * Tiny helper to call `e.preventDefault()` and `e.stopPropagation()` as the\n * same time.\n */\nexport function stopEvent(e: Event | React.SyntheticEvent) {\n  e.preventDefault()\n  e.stopPropagation()\n}\n","import { Ancestor, Editor, Element, NodeEntry, Path } from \"slate\"\n\nimport { BetterAt, betterAt } from \"../core-utils/better-at\"\nimport {\n  NodeMatcher,\n  standardizeNodeMatcher,\n} from \"../standardize-utils/standardize-node-matcher\"\n\n/**\n * Checks to see if the current selection is inside of a Node that matches\n * `matchNode`.\n */\nexport function findElementUp<T extends Ancestor & Element = Element>(\n  editor: Editor,\n  matchNode: NodeMatcher,\n  { at = editor.selection }: { at?: BetterAt } = {}\n): NodeEntry<T> | undefined {\n  // if no selection, there will be no match\n  if (at === null) return\n  const nextAt = betterAt(editor, at)\n  const match = standardizeNodeMatcher(matchNode)\n  /**\n   * Normally, we are looking up from a range or a point, but if the `at`\n   * `Location` is a `Path`, then we need to check for an exact match at the\n   * `at` `Location` in addition to looking `Editor.above` the current\n   * `at` `Location`\n   */\n  if (Path.isPath(nextAt)) {\n    const nodeEntryExactlyAt = Editor.node(editor, nextAt)\n    if (nodeEntryExactlyAt && match(nodeEntryExactlyAt[0])) {\n      return nodeEntryExactlyAt as NodeEntry<T>\n    }\n  }\n  // look for a matching element\n  return Editor.above(editor, { at: nextAt, match })\n}\n\nexport function findElementUpPath(...args: Parameters<typeof findElementUp>) {\n  const entry = findElementUp(...args)\n  return entry?.[1]\n}\n","import { Element, Node } from \"slate\"\n\nexport type NodeMatcher = string | string[] | ((node: Node) => boolean)\n\n/**\n * Takes a string or a function that matches a Node and in both cases,\n * returns a function that matches a Node.\n *\n * The `matchNode` argument can either be a function that takes a `Node` and\n * returns a boolean or it can be a string representing the `type` property of\n * an `Element`\n */\n\nexport function standardizeNodeMatcher(\n  matchNode: NodeMatcher\n): (node: Node) => boolean {\n  if (typeof matchNode === \"function\") return matchNode\n  if (typeof matchNode === \"string\")\n    return (node: Node) => Element.isElement(node) && node.type === matchNode\n  if (Array.isArray(matchNode))\n    return (node: Node) =>\n      Element.isElement(node) && matchNode.includes(node.type)\n  const exhaustiveCheck: never = matchNode\n  throw new Error(\n    `Expected matchNode to be a function, string or array but is ${exhaustiveCheck as string}`\n  )\n}\n","import { SVGProps } from \"react\"\n\n/**\n * A shortcut type to SVGProps<SVGSVGElement> but also more explicit in its\n * intent and allows for changing the props in the future without another\n * refactor.\n */\nexport type TablerIconProps = SVGProps<SVGSVGElement>\n\n/**\n * Efficient way to create a Tabler Icon.\n *\n * https://tabler-icons.io/\n *\n * - Grab the SVG from the Tabler Icon.\n * - Run it through https://react-svgr.com/playground/?icon=true&typescript=true\n * - Grab everything EXCEPT the first `path` which is unnecessary\n * - Place it as the children of this `<Icon>`\n */\nexport const TablerIcon = ({\n  strokeWidth = 1.5,\n  ...props\n}: TablerIconProps) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    width=\"1em\"\n    height=\"1em\"\n    strokeWidth={strokeWidth}\n    stroke=\"currentColor\"\n    fill=\"none\"\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n    viewBox=\"0 0 24 24\"\n    {...props}\n  />\n)\n","import { Range } from \"slate\"\n\nexport function isCollapsed(\n  selection: Range | null | undefined\n): selection is Range {\n  if (selection == null) return false\n  return Range.isCollapsed(selection)\n}\n","import { Element, Node } from \"slate\"\n\nexport function isElementType<T extends Element>(\n  node: Node,\n  type: T[\"type\"] | Array<T[\"type\"]>\n): node is T {\n  if (Array.isArray(type)) {\n    return Element.isElement(node) && type.includes(node.type)\n  }\n  if (typeof type === \"string\") {\n    return Element.isElement(node) && node.type === type\n  }\n  const exhaustiveCheck: never = type\n  throw new Error(\n    `Expected elementType to be string or array of string but is ${exhaustiveCheck as string}`\n  )\n}\n\nexport function createIsElementType<T extends Element>(\n  type: T[\"type\"] | Array<T[\"type\"]>\n): (node: Node) => node is T {\n  if (Array.isArray(type)) {\n    return (node: Node): node is T =>\n      Element.isElement(node) && type.includes(node.type)\n  } else {\n    return (node: Node): node is T =>\n      Element.isElement(node) && type == node.type\n  }\n}\n","import { Editor } from \"slate\"\n\nimport { findElementUp } from \"../find-utils/find-element-up\"\nimport { NodeMatcher } from \"../standardize-utils/standardize-node-matcher\"\nimport { isCollapsed } from \"./is-collapsed\"\n\n/**\n * Checks to see if the current selection is at the end of line for a node\n * that matches the `matchNode` argument.\n *\n * The `matchNode` argument can either be a function that takes a `Node` and\n * returns a boolean or it can be a string representing the `type` property of\n * an `Element`\n */\n\nexport function isEndOfElement(\n  editor: Editor,\n  matchNode: NodeMatcher\n): boolean {\n  const { selection } = editor\n  if (!isCollapsed(selection)) return false\n  const entry = findElementUp(editor, matchNode, { at: selection })\n  return !!entry && Editor.isEnd(editor, selection.anchor, entry[1])\n}\n","import { Editor } from \"slate\"\n\nimport { findElementUp } from \"../find-utils/find-element-up\"\nimport { NodeMatcher } from \"../standardize-utils/standardize-node-matcher\"\nimport { isCollapsed } from \"./is-collapsed\"\n\n/**\n * Checks to see if we are currently in an empty element.\n *\n * All these must be true:\n *\n * - There is a selection\n * - The selection is inside the matching element\n * - The matching element is empty\n */\nexport function isInEmptyElement(\n  editor: Editor,\n  matchNode: NodeMatcher\n): boolean {\n  const { selection } = editor\n  if (!isCollapsed(selection)) return false\n  const entry = findElementUp(editor, matchNode)\n  if (entry === undefined) return false\n  return Editor.isEmpty(editor, entry[0])\n}\n","import { Editor } from \"slate\"\n\nimport { findElementUp } from \"../find-utils/find-element-up\"\nimport { NodeMatcher } from \"../standardize-utils/standardize-node-matcher\"\nimport { isCollapsed } from \"./is-collapsed\"\n\n/**\n * Checks to see if the current selection is at the end of line for a node\n * that matches the `matchNode` argument.\n *\n * The `matchNode` argument can either be a function that takes a `Node` and\n * returns a boolean or it can be a string representing the `type` property of\n * an `Element`\n */\n\nexport function isStartOfElement(\n  editor: Editor,\n  matchNode: NodeMatcher\n): boolean {\n  const { selection } = editor\n  if (!isCollapsed(selection)) return false\n  const entry = findElementUp(editor, matchNode, { at: selection })\n  return !!entry && Editor.isStart(editor, selection.anchor, entry[1])\n}\n","import { isHotkey } from \"is-hotkey\"\nimport { Editor, Element as SlateElement, Range, Transforms } from \"slate\"\n\nimport { findElementUp, stopEvent } from \"../..\"\n\nexport const isSpace = isHotkey(\" \")\nexport const isShiftSpace = isHotkey(\"SHIFT+SPACE\")\n\nexport function createAutocompleteSpaceHandler(\n  editor: Editor,\n  methods: Record<string, undefined | (() => void)>\n) {\n  return (e: React.SyntheticEvent<Element, KeyboardEvent>): boolean => {\n    /**\n     * We support `shift+space` as well because when we are typing something\n     * like `## ` sometimes the finger hasn't left the shift key yet. In normal\n     * usage, we still get a space and so the feature feels intermittently\n     * broken if we don't support `shift+space`.\n     */\n    if (!isSpace(e.nativeEvent) && !isShiftSpace(e.nativeEvent)) return false\n\n    /**\n     * Make sure theere is a selection and it's collapsed\n     */\n    const { selection } = editor\n    if (selection === null) return false\n    if (Range.isExpanded(selection)) return false\n\n    /**\n     * Find a convertible block and if we can't find one, exit.\n     */\n    const convertibleBlockEntry = findElementUp(\n      editor,\n      (node) =>\n        /**\n         * NOTE: We alias to SlateElement because this page needs acces to both\n         * the global Eleent and the Slate Element.\n         */\n        SlateElement.isElement(node) &&\n        editor.convertElement.isConvertibleElement(node)\n    )\n    if (!convertibleBlockEntry) return false\n\n    /**\n     * Find a matching method. Note that the keys in `methods` are the `string`\n     * prefixes we are looking for like `##` for heading level 2.\n     *\n     * If no match, exit.\n     */\n    const range = {\n      anchor: Editor.start(editor, convertibleBlockEntry[1]),\n      focus: selection.focus,\n    }\n    const text = Editor.string(editor, range)\n    const method = methods[text]\n    if (!method) return false\n\n    /**\n     * We have a match. Stop other event handlers.\n     */\n    stopEvent(e)\n\n    /**\n     * Delete the autocomplete text that came before the space bar was pressed.\n     */\n    const deleteRange = {\n      anchor: Editor.start(editor, convertibleBlockEntry[1]),\n      focus: selection.focus,\n    }\n    Transforms.delete(editor, { at: deleteRange })\n\n    /**\n     * Execute the matching method.\n     */\n    method()\n    return true\n  }\n}\n","import { isHotkey } from \"is-hotkey\"\n\nimport { isMac } from \"../core-utils/is-mac\"\n\nexport function isBetterHotkey(hotkey: string) {\n  const modifiedHotkey = hotkey.replace(\n    /\\bsuper\\b/g,\n    isMac() ? \"cmd+alt\" : \"ctrl+shift\"\n  )\n  return isHotkey(modifiedHotkey)\n}\n","import { isBetterHotkey } from \"./is-better-hotkey\"\n\n/**\n * The function that is executed when the hotkey is pressed.\n *\n * If it returns `void` (undefined) we assume the Action was executed.\n * If we return a `boolean`, the Action is considered executed if it returns\n * `true` or not handled if it returns `false`.\n */\ntype Action = () => boolean | void\n\ntype IsKeyboardShortcut = (event: KeyboardEvent) => boolean\n\ntype ShortcutTuple = [IsKeyboardShortcut, Action]\n\n/**\n * Creates a `keyDown` handler from an object where the keys are the shortcut\n * and the values are the `Action` function to execute. If the\n * function returns `true`, the event is considered handled and the event\n * is stopped.\n *\n * In some situations, we don't want the event to be stopped.\n *\n * For example, hitting `up` or `down` in a table, starts a `setTimeout` but\n * we want the original keyboard event to be handled by the browser.\n */\n\nexport function createHotkeyHandler(shortcutsObject: Record<string, Action>) {\n  /**\n   * Don't populate the shortcuts at this point because it will run on the\n   * server. We can't run it on the server because we need to determine if we\n   * are on Mac or Windows and checking `window.navigate.userAgent` will cause\n   * a failure.\n   */\n  let shortcuts: ShortcutTuple[] | null = null\n\n  return function handleShortcuts(\n    event: React.SyntheticEvent<Element, KeyboardEvent>\n  ) {\n    /**\n     * We initialize shortcuts once on first usage.\n     */\n    if (shortcuts == null) {\n      shortcuts = Object.entries(shortcutsObject).map(([shortcut, fn]) => [\n        isBetterHotkey(shortcut),\n        fn,\n      ])\n    }\n    for (const [isShortcut, action] of shortcuts) {\n      if (isShortcut(event.nativeEvent)) {\n        /**\n         * If the keyboardAction returns true then the event has been handled.\n         * We can stop the event at this point and exit the loop.\n         */\n        const response = action()\n        if (response === true || response === undefined) {\n          event.preventDefault()\n          event.stopPropagation()\n          return true\n        }\n      }\n    }\n    return false\n  }\n}\n","import { Editor, Path, Transforms } from \"slate\"\n\n/**\n * Takes a given and makes that specific path dirty with respect to\n * normalization and executes a normalization path (unless in a\n * `withoutNormalizing` block in which case it will wait until it is completed).\n *\n * A few things you should know:\n *\n * - It doesn't dirty the ancestors. So if you are targeting an Element to be\n *   dirtied, make sure you aren't dirtying the Text node as that won't cause\n *   the parent Element to be dirtied.\n *\n * - It works by setting a key that doesn't make sense to a value and then\n *   unsetting it. This adds some unnecessary noise to the list of operations.\n *\n * The ideal method to implement this would be to modify the DIRTY_PATHS and\n * DIRTY_PATH_KEYS directly; however, these are presently not being exported.\n * This should probably be fixed in the future by an exported function called\n * something like `addDirtyPaths`.\n */\nexport function forceNormalizePath(editor: Editor, path: Path) {\n  Editor.withoutNormalizing(editor, () => {\n    Transforms.setNodes(\n      editor,\n      // @ts-expect-error - intentional dummy property for normalization\n      { __DOESNT_MATTER_JUST_TO_START_NORMALIZING__: \"123\" },\n      { at: path }\n    )\n    Transforms.setNodes(\n      editor,\n      // @ts-expect-error - intentional dummy property for normalization\n      { __DOESNT_MATTER_JUST_TO_START_NORMALIZING__: null },\n      { at: path }\n    )\n  })\n}\n","import { Descendant, Editor, NodeEntry } from \"slate\"\n\n/**\n * This normalization utility is useful when you need to adjust an Element\n * depending on the Element before or after it.\n *\n * For example, if two of the same nodes are next to each other, they can be\n * merged together.\n *\n * Or in the case of a numbered list, we want to reset the counter only if\n * the list is deeper than the previous one.\n *\n * The thing that makes these method efficient is that it can often replace\n * having to search through all children of the parent of the current element.\n * Normally, to compare siblings, you'd have to look at the parent in order\n * to make sure you normalize siblings propertly; however, this method will\n * look both at the pair before/current and current/after to make sure that\n * neighbor siblings do the right thing.\n *\n * When used through a full normalization, it can solve bigger problems. For\n * example, if you have 5 elements that are all the same and they need to\n * all be merged, one by one, they will merged into a single Element.\n *\n * HINT:\n *\n * If there is a bug related to not being able to find a Path, remember to\n * return `true` in the `transform` function when a `transform` is executed.\n *\n * After a `transform` is run, the state of the document is changed and\n * running the second `transform` may result in accessing an invalid path.\n */\nexport function normalizeSiblings<T extends Descendant>(\n  editor: Editor,\n  entry: NodeEntry<T>,\n  transform: (a: NodeEntry<T>, b: NodeEntry<T>) => boolean\n): boolean {\n  const [, path] = entry\n\n  const prevEntry = Editor.previous<T>(editor, { at: path })\n  if (prevEntry && transform(prevEntry, entry)) return true\n\n  const nextEntry = Editor.next<T>(editor, { at: path })\n  if (nextEntry && transform(entry, nextEntry)) return true\n\n  return false\n}\n","import { Editor, Path, Transforms } from \"slate\"\n\n/**\n * Puts the selection at the start of a Node at the given path.\n */\nexport function selectStartOfElement(editor: Editor, path: Path) {\n  Transforms.select(editor, Editor.start(editor, path))\n}\n\n/**\n * Puts the selection at the start of a Node at the given path.\n */\nexport function selectEndOfElement(editor: Editor, path: Path) {\n  Transforms.select(editor, Editor.end(editor, path))\n}\n","import { Element } from \"slate\"\n\n/**\n * The TargetElement can be specified either as the actual value or as a\n * function that takes a srcElement and returns the targetElement.\n */\nexport type TargetElement<T extends Element = Element> =\n  | Omit<T, \"children\">\n  | ((srcElement: Element) => Omit<T, \"children\">)\n\n/**\n * TODO:\n *\n * This should probably just be moved into the `rewrapElement` function page\n * since it is not used outside of it. Originally, this may have served a\n * dual purpose but currently it seems like it only exists for the use of\n * `rewrapElement`.\n */\n\n/**\n * This function takes a `srcElement` and the idea is that we convert it into\n * some other type of element, which is the `targetElement`.\n *\n * The `TargetElement` can be specified either as:\n *\n * - an actual `Element` but without the `children`. This is because we are\n *   converting the `srcElement` to the `targetElement` and the `targetElement`\n *   will take on the `children` of the `srcElement`\n *\n * - A function that takes the `srcElement` and returns the `targetElement`\n *   without the `children`. This form of `TargetElement` can be useful in\n *   cases where we want to retain some of the properties of the `srcElement`.\n *   An example of this is a list item where we convert from a bullet to a\n *   numbered item. We would like to keep the `depth` information if it exists\n *   in this scenario.\n */\nexport function createTargetElement<T extends Element>(\n  srcElement: Element,\n  targetElement: TargetElement<T>\n) {\n  if (typeof targetElement !== \"function\") return targetElement\n  return targetElement(srcElement)\n}\n","import { Editor, Element, Location, Path, Transforms } from \"slate\"\n\nimport { findElementUp } from \"../..\"\n\n/**\n * Inserts an Element into the document such that if it is in a `isMaster`\n * element (i.e. an Element that has a number of dependants like a table or\n * code block) then then inserted Element will appear after the `isMaster`\n * element.\n *\n * This prevents invalid states from happening like inserting a table inside\n * a table, or a code block in a table, or a table in a code block.\n */\nexport function insertRootElement(\n  editor: Editor,\n  element: Element,\n  { at = editor.selection }: { at?: Location | null } = {}\n): boolean {\n  /**\n   * If there's no `at` then insertion does not happen\n   */\n  if (at == null) return false\n  /**\n   * Look for a parent that `isMaster`\n   */\n  const entry = findElementUp(\n    editor,\n    (node) => Element.isElement(node) && editor.isMaster(node)\n  )\n  if (entry == null) {\n    /**\n     * If not `isMaster` then do a regular insert, select the original\n     * insertion point and move forward to select the first position inside\n     * the newly inserted element.\n     */\n    const selection = editor.selection\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, element, { at })\n      if (selection) {\n        Transforms.select(editor, selection)\n        Transforms.move(editor)\n      }\n    })\n  } else {\n    /**\n     * If it `isMaster` then find the next adjacent path to the master, insert\n     * there, and then select at the start of the insertion point.\n     */\n    const nextPath = Path.next(entry[1])\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, element, { at: nextPath })\n      Transforms.select(editor, Editor.start(editor, nextPath))\n    })\n  }\n  return true\n}\n","import { Editor, Element, NodeEntry, Path, Transforms } from \"slate\"\n\nimport {\n  createTargetElement,\n  TargetElement,\n} from \"../standardize-utils/target-element\"\n\n/**\n * Takes an existing Element at path `at` and swaps out that Element with a\n * new Element. It does this by unwrapping the Element and rewrapping it with\n * the new Element.\n *\n * This is useful because if we do it this way, we can preserve the selection.\n */\nexport function rewrapElement<T extends Element = Element>(\n  editor: Editor,\n  targetElement: TargetElement<T>,\n  at: Path\n) {\n  Editor.withoutNormalizing(editor, () => {\n    const originalEntry = Editor.node(editor, at) as NodeEntry<Element>\n    const nextElement = createTargetElement(originalEntry[0], targetElement)\n    /**\n     * Technicall, it's Omit<Element, 'children'> but `wrapNodes` actually\n     * accepts that just fine so we override the type.\n     */\n    Transforms.wrapNodes(editor, nextElement as T, { at })\n    Transforms.unwrapNodes(editor, { at: [...at, 0] })\n  })\n}\n","import { Editor, EditorNodesOptions, Node, Transforms } from \"slate\"\n\n/**\n * An improved version of `setNodes` that takes a `convert` option.\n *\n * In existing `setNodes` we can specify how we want to setNodes statically.\n * That is, before we execute `setNodes` we need to know which properties\n * we want to set.\n *\n * This version of `setNodes` allows us to dynamically setNodes by allowing\n * us to specify a function argument. The function takes the original value of\n * an Element and returns the match.\n */\nexport function setNodesDynamic<T extends Node>(\n  editor: Editor,\n  convert: (node: T) => Partial<T>,\n  options: EditorNodesOptions<T>\n) {\n  const entries = Array.from(Editor.nodes<T>(editor, options))\n  if (entries.length === 0) return false\n  for (const entry of entries) {\n    const [node] = entry\n    Transforms.setNodes(editor, convert(node), { at: entry[1] })\n  }\n  return true\n}\n","import { Editor } from \"slate\"\n\nexport function onPaste(\n  editor: Editor,\n  e: React.ClipboardEvent<HTMLDivElement>\n) {\n  const clipboardData = e.clipboardData\n  const { types } = clipboardData\n\n  // Remove debug console log\n  // console.log(clipboardData.getData(\"text/html\"))\n\n  /**\n   * We don't want to handle it if it's not just plain text. If it is\n   * plain text, it will have only one type and it will be \"text/plain\".\n   * HTML, for example, also has \"text/plain\" but also \"text/html\"\n   */\n  if (types.length > 1) return false\n  if (types[0] !== \"text/plain\") return false\n\n  /**\n   * Check to make sure the text is a URL\n   */\n  const text = clipboardData.getData(\"text/plain\")\n  if (!isUrl(text)) return false\n\n  /**\n   * If it is a URL, then insert the link\n   */\n  e.preventDefault()\n  e.stopPropagation()\n  editor.anchor.insertLink(text)\n  return true\n}\nfunction isUrl(s: string): boolean {\n  let url\n  try {\n    url = new URL(s)\n  } catch {\n    return false\n  }\n  return (\n    url.protocol === \"http:\" ||\n    url.protocol === \"https:\" ||\n    url.protocol === \"mailto:\"\n  )\n}\n","import { Editor, Node, Transforms } from \"slate\"\n\nimport { BetterAt, findElementUp } from \"../../sink\"\nimport { AnchorElement } from \"..\"\n\nexport function editLink(\n  editor: Editor,\n  { href, title, text }: { href: string; title?: string; text?: string },\n  { at }: { at?: BetterAt }\n) {\n  const link = findElementUp(editor, \"anchor\", { at })\n  if (!link) return false\n  const [element, path] = link\n\n  // Update href and title\n  Transforms.setNodes<AnchorElement>(editor, { href, title }, { at: path })\n\n  // Update text if provided and different from current\n  if (text !== undefined) {\n    const currentText = Node.string(element)\n    if (text !== currentText) {\n      // Remove all children and insert new text\n      Editor.withoutNormalizing(editor, () => {\n        const childCount = element.children.length\n        for (let i = childCount - 1; i >= 0; i--) {\n          Transforms.removeNodes(editor, { at: [...path, i] })\n        }\n        Transforms.insertNodes(editor, { text }, { at: [...path, 0] })\n      })\n    }\n  }\n\n  return true\n}\n","import { Editor, Element, Range, Text, Transforms } from \"slate\"\n\nexport function insertLink(\n  editor: Editor,\n  href: string,\n  text: string = href,\n  { select = true, title }: { select?: boolean; title?: string } = {}\n) {\n  /**\n   * If there is no selection, we default by inserting at the start of document.\n   */\n  const selection = editor.selection || {\n    anchor: Editor.start(editor, [0]),\n    focus: Editor.start(editor, [0]),\n  }\n  if (Range.isCollapsed(selection)) {\n    /**\n     * Insert the node and select it if select is true\n     */\n    Transforms.insertNodes(\n      editor,\n      {\n        type: \"anchor\",\n        href,\n        title,\n        children: [{ text }],\n      },\n      { select, at: selection }\n    )\n    /**\n     * If select is true then select the inserted link\n     */\n    if (select && editor.selection) {\n      const entry = Editor.node(editor, editor.selection)\n      Transforms.select(editor, entry[1])\n    }\n  } else {\n    /**\n     * If there is a selection, we wrap the selection with our anchor.\n     */\n    Transforms.wrapNodes(\n      editor,\n      { type: \"anchor\", href, title, children: [] },\n      {\n        split: true,\n        match: (node) => Text.isText(node) || (Element.isElement(node) && Editor.isInline(editor, node)),\n      }\n    )\n  }\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt, findElementUp } from \"../../sink\"\n\nexport function removeLink(editor: Editor, { at }: { at?: BetterAt }) {\n  const link = findElementUp(editor, \"anchor\", { at })\n  if (!link) return false\n  Transforms.unwrapNodes(editor, { at: link[1] })\n  return true\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { editLink } from \"./editLink\"\nimport { insertLink } from \"./insertLink\"\nimport { removeLink } from \"./removeLink\"\n\nexport function createAnchorMethods(editor: Editor) {\n  return {\n    insertLink: curryOne(insertLink, editor),\n    removeLink: curryOne(removeLink, editor),\n    editLink: curryOne(editLink, editor),\n  }\n}\n","import { Editor, Element, Node, NodeEntry, Transforms } from \"slate\"\n\n/**\n * If there is an anchor node inside an anchor node, unwrap the inner anchor\n * node as that is not allowed.\n *\n * Another approach would be to lift the nodes but I think unwrapping the\n * inner one makes more sense. Consider these two scenarios (keeping in mind\n * that they will likely be rare):\n *\n * - User selects text that includes a link. Then user links it. The user would\n *   have a strong expectation that the link just applied would override the\n *   link on the inside.\n *\n * - The opposite: User select text inside an existing link then tries to link\n *   it. That's unusual and while the user may expect that inner selection to\n *   get linked, I think this is a rare enough case whereas the prior one seems\n *   like a slightly more natural one.\n *\n * We could, of course, solve both of these by adding more code paths at the\n * time the link is inserted. That won't change this normalization code and\n * not sure if it is worth the extra complexity.\n */\nexport function normalizeNode(editor: Editor, entry: NodeEntry<Node>): boolean {\n  if (!Element.isElement(entry[0])) return false\n  if (entry[0].type !== \"anchor\") return false\n  const children = entry[0].children\n  for (let i = 0; i < children.length; i++) {\n    const child = children[i]\n    if (!Element.isElement(child) || child.type !== \"anchor\") continue\n    Transforms.unwrapNodes(editor, { at: [...entry[1], i] })\n    return true\n  }\n  return false\n}\n","import { clsx } from \"clsx\"\nimport { useEffect, useRef } from \"react\"\nimport { useSelected, useSlate } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { useLayer } from \"../../use-layer\"\nimport { AnchorElement } from \"../index\"\nimport { $Anchor, $Edge } from \"../styles\"\nimport { AnchorDialog } from \"./AnchorDialog\"\n\nexport function Anchor({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<AnchorElement>) {\n  const startEdgeRef = useRef<HTMLSpanElement>(null)\n  const anchorRef = useRef<HTMLAnchorElement>(null)\n  const selected = useSelected()\n  const editor = useSlate()\n  const dialog = useLayer(\"dialog\")\n\n  /**\n   * TODO:\n   *\n   * Finish implementing the anchor dialog.\n   *\n   * Stopped partway through because the entire document is being re-rendered\n   * on every keypress.\n   */\n\n  useEffect(() => {\n    const anchor = anchorRef.current\n    const startEdge = startEdgeRef.current\n    if (!anchor || !startEdge) return\n    /**\n     * NOTE: Do not use `focused && selected` here because when we click or\n     * focus on the pop up dialogs themselves, this will cause the dialogs to\n     * close.\n     *\n     * TODO: Figure out how to make the dialogs not close when clicking on them.\n     *\n     * It has to support these use cases:\n     *\n     * - Closes when user clicks somewhere in the document outside the link\n     * - Stays open when user clicks on the dialog\n     * - Stays open when user is in an input in the dialog\n     * - Closes when the editor loses focus but stays open when the editor loses\n     *   focus to the anchor dialog or the anchor edit dialog\n     */\n    // Only show dialog when the link is precisely selected (not part of a larger selection)\n    const hasSelection = editor.selection &&\n      editor.selection.anchor.offset !== editor.selection.focus.offset;\n\n    if (selected && !hasSelection) {\n      /**\n       * The setTimeout delay is necessary when first clicking into the browser\n       * and when switching from one link to another. Without it, the dialog\n       * will not open.\n       */\n      setTimeout(() => {\n        dialog.open(() => (\n          <AnchorDialog\n            destAnchor={anchor}\n            destStartEdge={startEdge}\n            element={element}\n          />\n        ))\n      })\n    } else {\n      dialog.close()\n    }\n  }, [selected, element])\n\n  return (\n    <$Anchor\n      className={clsx({ \"--selected\": selected })}\n      href={element.href}\n      target={element.target}\n      {...attributes}\n      ref={anchorRef}\n    >\n      {/* Edge allow Chrome to differentiate in/out of the link */}\n      <$Edge ref={startEdgeRef} contentEditable={false} />\n      <span>{children}</span>\n      {/* Edge allow Chrome to differentiate in/out of the link */}\n      <$Edge contentEditable={false} />\n    </$Anchor>\n  )\n}\n","import { createContext, useState } from \"react\"\n\nimport { Portal } from \"./portal\"\nimport { Layer, LayersContextValue, LayersRecord } from \"./types\"\n\n/**\n * Wrap this around the Component in which you want to have the ability to\n * display one or more layers at once.\n */\nexport const LayersContext = createContext<LayersContextValue>(\n  /**\n   * This is set to an invalid value and then typecast as the correct type.\n   *\n   * This is okay though because in `LayersProvider` we set the value to the\n   * proper type before they are used for the first time.\n   */\n  {} as LayersContextValue\n)\n\nexport const LayerContext = createContext<Layer>({} as Layer)\n\n/**\n * The `Layers` Component should be wrapped around the Component or Components\n * which you want to have layer support.\n *\n * The `useLayer` hook must be called inside a `Layers` Component.\n *\n * It provides these necessary functions:\n *\n * - Makes available the resources necessary to open and close layers.\n *\n * - Renders the currently open layers to the DOM at the top level of the\n *   DOM. We do this to simplify positioning as we can position everything\n *   relative to the full window which is what is returned by\n *   `getBoundingClientRect`\n *\n * NOTE:\n *\n * As a design decision, we wrap many components with the Layer instead of\n * having a Layer per component. This design decision is important because\n * we may want to open multiple layers of the same type and if we open another\n * layer of the same type, we want any other layers to close.\n *\n * For example, consider a Dialog. If we open a differnet Dialog, we want the\n * first one to close. This can only be done when a single component knows\n * about the existence of both.\n */\nexport function Layers({ children }: { children: React.ReactNode }) {\n  const [layers, setLayers] = useState<LayersRecord>({})\n\n  /**\n   * Open a layer of the given type\n   */\n  function openLayer(layer: Layer) {\n    setLayers((layers) => {\n      return {\n        ...layers,\n        [layer.type]: layer,\n      }\n    })\n  }\n\n  /**\n   * Close a layer of the given type\n   */\n  function closeLayer(layerType: string) {\n    setLayers((layers) => {\n      const nextLayers = { ...layers }\n      delete nextLayers[layerType]\n      return nextLayers\n    })\n  }\n\n  /**\n   * - provide the layers context\n   * - render the layers at the top of the DOM using a Portal\n   */\n  return (\n    <LayersContext.Provider\n      value={{ layers, setLayers, openLayer, closeLayer }}\n    >\n      {children}\n      {Object.entries(layers).map(([, layer]) => {\n        return (\n          <Portal key={layer.type}>\n            <LayerContext.Provider value={layer}>\n              <layer.Component />\n            </LayerContext.Provider>\n          </Portal>\n        )\n      })}\n    </LayersContext.Provider>\n  )\n}\n","import { createPortal } from \"react-dom\"\n\n/**\n * Portal to `document.body`\n *\n * NOTE:\n * Consider creating a version of Portal with a Reset in it.\n *\n * The reason is that when showing a portal, it will carry the baggage of\n * any styling from `<html>` and `<body>` element.\n */\nexport function Portal({ children }: { children: React.ReactNode }) {\n  if (typeof document === \"undefined\" || !document.body) return null\n  return createPortal(children, document.body)\n}\n","import { FunctionComponent, useContext } from \"react\"\n\nimport { LayersContext } from \"./layers\"\nimport { Layer } from \"./types\"\n\n/**\n * `useLayer` may only be called when it is inside a Component that is itself\n * nested under the `Layers` component. This is necessary because `useLayer`\n * uses a React Context which is set up in the `Layers` component.\n *\n * Using the `useLayer` hook returns a layer object that has an `open` and\n * `close` method. You can use it something like this:\n *\n * ```typescript\n * function MyComponent() {\n *\n *   const tooltip = useLayer('tooltip')\n *\n *   const openTootlip = () => {\n *     tooltip.open(() => <Tooltip title=\"Hey Dudes\" />)\n *   }\n *\n *   return <div\n *     onMouseEnter={openTooltip}\n *     onMouseLeave={tooltip.close}\n *   >Thing that needs a tooltip</div>\n * }\n * ```\n *\n * In this scenario, it opens a `Tooltip` component when the mouse enters the\n * div and closes it when the mouse leave it.\n *\n * This library is simple but flexible enough to be used to handle different\n * kinds of components that pop up in the DOM.\n *\n * - tooltips\n * - dialog boxes positioned where a button is clicked\n * - dialog boxes positioned in the center of a viewport\n * - notifications\n *\n * `useLayer` is designed to handle just the opening and closing of the layers\n * that overlays on top of all the other components at the top of the DOM.\n *\n * It also ensures only one of each kind of layer is open at a time. So when\n * a second tooltip is opened, the first is closed.\n *\n * The positioning of the tooltips, dialogs and notifications, especially when\n * the position is relative to another element like a button that was clicked\n * it the domain of the `useReposition` micro library.\n *\n * These libraries are not tied together in any way (there is nothing\n * opinionated that ties them toegher); however they were designed and built\n * at the same time and work together well to solve all the issues related to\n * popup windows/dialogs/tooltips of any kind.\n */\nexport function useLayer(type: string) {\n  const { openLayer, closeLayer, layers } = useContext(LayersContext)\n\n  /**\n   * Call this method to open a layer that contains the Component at the given\n   * layer type.\n   *\n   * Opening a layer of this type will close any other layers of this type.\n   * For example, if a `tooltip` layer was currently open, opening a new\n   * tooltip would close the previously open one.\n   *\n   * When opening a layer, we pass in a function (that takes no arguments) and\n   * returns our rendered Component something like:\n   *\n   * ```ts\n   * const dialog = useLayer('dialog')\n   *\n   * const openDialog = () => {\n   *   dialog.open(() => <MyDialog title=\"My Title\" />)\n   * }\n   * ```\n   *\n   * If you are getting TypeScript issues, especially when passing props as\n   * properties of some other object, the easiest way to fix these issues are\n   * to assign those values to a `const` first. This can happen when the\n   * values on the object could potentially be `undefined` or change during\n   * a re-render.\n   *\n   * For example, this could give typing issues:\n   *\n   * ```ts\n   * type Item = {\n   *   title?: string\n   * }\n   *\n   * const dialog = useLayer('dialog')\n   *\n   * const openDialog = () => {\n   *   if (item.title === undefined) return\n   *   dialog.open(() => <MyDialog title={item.title} />)\n   * }\n   * ```\n   *\n   * It's a little non-obvious because it looks like we did a check to make\n   * sure that `item.title` is defined. But remember that it could change\n   * during a re-render.\n   *\n   * Here's how to fix this.\n   *\n   * ```ts\n   * type Item = {\n   *   title?: string\n   * }\n   *\n   * const dialog = useLayer('dialog')\n   *\n   * const openDialog = () => {\n   *   if (item.title === undefined) return\n   *   const title = item.title\n   *   dialog.open(() => <MyDialog title={title} />)\n   * }\n   * ```\n   *\n   * Now `title` is of type `string` because we already asserted that\n   * `item.title` was a string. We assigned it to a `const` meaning that it\n   * won't change, even if re-rendered later.\n   */\n  function open(Component: FunctionComponent<Record<string, never>>) {\n    const layer: Layer = { type, Component }\n    openLayer(layer)\n  }\n\n  /**\n   * Call this method to close the current layer of the given layer type.\n   */\n  function close() {\n    closeLayer(type)\n  }\n\n  return {\n    open,\n    close,\n    layer: layers[type],\n    type,\n  }\n}\n","import styled from \"@emotion/styled\"\n\nexport const $Anchor = styled(\"a\")`\n  /**\n   * Link colors\n   */\n  color: var(--link-color, blue);\n  &:hover {\n    color: var(--link-hover-color, blue);\n  }\n  /**\n   * When the cursor is in the anchor and not outside the anchor, we style the\n   * anchor with a very light shade. This is enough to subtly intuit to the user\n   * that when they type, it will appear inside the link. When the shade is\n   * not present, they intuit they are just outside the link.\n   */\n  border-radius: 0.125em;\n  transition: background-color 250ms;\n  &.--selected {\n    background: var(--blue-50);\n  }\n`\n/**\n * This edge piece that are at the edge of the inside of the anchor are visibly\n * designed to be 1px wide. A <span> can't be given a width so we fake this by\n * creating an empty span with 1px of width.\n */\nexport const $Edge = styled(\"span\")`\n  display: inline;\n  padding: 0 1px 0 0;\n`\n\n/**\n * Shows progress bar of an uploading attachment. This part is the outline.\n */\nexport const $ProgressBar = styled(\"span\")`\n  position: fixed;\n  width: 100px;\n  background: var(--shade-50);\n  height: 8px;\n  border-radius: 7px;\n  border: 1px solid var(--shade-400);\n  overflow: hidden;\n  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);\n`\n\n/**\n * Show the fill part of the progress bar.\n */\nexport const $ProgressBarFill = styled(\"span\")`\n  position: absolute;\n  left: 0;\n  top: 0;\n  height: 14px;\n  background: var(--blue-400);\n  transition: width 100ms linear;\n`\n","import styled from \"@emotion/styled\"\nimport { useCallback, useRef, useState } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { $Panel } from \"../../shared-overlays\"\nimport { useLayer } from \"../../use-layer\"\nimport { positionInside, useAbsoluteReposition } from \"../../use-reposition\"\nimport { useTooltip } from \"../../use-tooltip\"\nimport { AnchorElement } from \"../index\"\nimport { AnchorEditDialog } from \"./AnchorEditDialog\"\nimport { CloseIcon, ExternalLinkIcon, LinkOffIcon, PencilIcon } from \"./icons\"\nimport { DraggableHeader } from \"../../toolbar-plugin/components/dialog/DraggableHeader\"\n\nconst $AnchorDialog = styled($Panel)`\n  position: absolute;\n  width: 20em;\n  z-index: 1000;\n  padding: 0;\n  overflow: hidden;\n  color: var(--shade-400);\n\n  .--icons {\n    display: flex;\n    overflow: hidden;\n    flex: 0 0 6em;\n  }\n\n  .--link {\n    text-decoration: none;\n    display: flex;\n    flex: 1 1 auto;\n    min-width: 0;\n    overflow: hidden;\n    color: var(--shade-400);\n    &:hover {\n      color: var(--blue-600);\n    }\n    transition: all 200ms;\n  }\n\n  .--url {\n    margin-left: 0.5em;\n    .--hostname {\n      font-size: 0.875em;\n      max-width: 14em;\n      line-height: 1.5em;\n      color: var(--blue-600);\n      overflow-wrap: break-word;\n      /* width: 13.5em;\n      white-space: nowrap;\n      overflow: hidden;\n      text-overflow: ellipsis; */\n    }\n    .--pathname {\n      margin-top: 0.125em;\n      font-size: 0.75em;\n      max-width: 16.25em;\n      line-height: 1.5em;\n      overflow-wrap: break-word;\n    }\n    .--tooltip {\n      box-sizing: border-box;\n      position: relative;\n      margin-top: 1em;\n      font-size: 0.875em;\n      max-width: 14em;\n      line-height: 1.5em;\n      background: var(--shade-200);\n      border-radius: 0.5em;\n      padding: 0.5em 0.75em;\n      color: var(--shade-600);\n      overflow-wrap: break-word;\n    }\n    .--tooltip::before {\n      content: \"\";\n      position: absolute;\n      top: -0.5em; /* Height of the triangle */\n      left: 0.5em; /* Position it on the left side */\n      border-left: 0.5em solid transparent; /* Half the width of the triangle */\n      border-right: 0.5em solid transparent; /* Half the width of the triangle */\n      border-bottom: 0.5em solid var(--shade-200); /* Height and color of the triangle */\n    }\n  }\n\n  .--icon {\n    cursor: pointer;\n    margin-left: 0.5em;\n    &:hover {\n      color: var(--blue-600);\n    }\n  }\n\n  svg {\n    flex: 0 0 auto;\n    width: 1.25em;\n    height: 1.25em;\n    stroke-width: 1.5;\n  }\n`\n\nfunction parseUrl(s: string): { hostname: string; pathname: string } {\n  try {\n    const url = new URL(s)\n    return { hostname: url.hostname, pathname: url.pathname }\n  } catch {\n    return { hostname: \"\", pathname: \"\" }\n  }\n}\n\nexport function AnchorDialog({\n  destAnchor,\n  destStartEdge,\n  element,\n}: {\n  destAnchor: HTMLAnchorElement\n  destStartEdge: HTMLSpanElement\n  element: AnchorElement\n}) {\n  const dialog = useLayer(\"dialog\")\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLDivElement>(null)\n  const url = parseUrl(element.href)\n  const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 })\n\n  const handleDrag = useCallback((deltaX: number, deltaY: number) => {\n    setDragOffset(prev => ({ x: prev.x + deltaX, y: prev.y + deltaY }))\n  }, [])\n\n  const baseStyle = useAbsoluteReposition(\n    { src: ref, destAnchor, destStartEdge },\n    ({ src, destAnchor, destStartEdge }, viewport) => {\n      return positionInside(\n        src,\n        viewport,\n        {\n          left: destStartEdge.left,\n          top: destAnchor.top + destAnchor.height,\n        },\n        { margin: 16 }\n      )\n    }\n  )\n\n  const style = {\n    ...baseStyle,\n    left: (baseStyle.left as number) + dragOffset.x,\n    top: (baseStyle.top as number) + dragOffset.y,\n  }\n\n  const removeTooltip = useTooltip({ title: \"リンクを削除\" })\n  const editTooltip = useTooltip({ title: \"リンクを編集\" })\n  const closeTooltip = useTooltip({ title: \"閉じる\" })\n\n  const closeDialog = useCallback(() => {\n    dialog.close()\n  }, [dialog])\n\n  const removeLink = useCallback(() => {\n    editor.anchor.removeLink({ at: element })\n    // Close the dialog after removing the link\n    dialog.close()\n  }, [editor, dialog])\n\n  const openEditDialog = useCallback(() => {\n    /**\n     * Force close the tooltip otherwise it will stay open because the\n     * `onMouseLeave` never gets called. Technically, the mouse never leaves\n     * the icon through a mouse movement. The edit icon simply disappears.\n     */\n    editTooltip.onMouseLeave()\n    dialog.open(() => {\n      return (\n        <AnchorEditDialog\n          destAnchor={destAnchor}\n          destStartEdge={destStartEdge}\n          element={element}\n        />\n      )\n    })\n  }, [destAnchor, destStartEdge, element])\n\n  return (\n    <$AnchorDialog ref={ref} contentEditable={false} style={style}>\n      <DraggableHeader onDrag={handleDrag} />\n      <div style={{ display: \"flex\", padding: \"1em\" }}>\n        <a\n          className=\"--link\"\n          href={element.href}\n          target=\"_blank\"\n          rel=\"noreferrer\"\n        >\n          <ExternalLinkIcon />\n          <div className=\"--url\">\n            <div className=\"--hostname\">{url.hostname}</div>\n            {url.pathname === \"\" || url.pathname === \"/\" ? null : (\n              <div className=\"--pathname\">{url.pathname}</div>\n            )}\n            {element.title == null || element.title === \"\" ? null : (\n              <div className=\"--tooltip\">{element.title}</div>\n            )}\n          </div>\n        </a>\n        <span className=\"--icons\">\n          <span\n            className=\"--icon\"\n            onClick={removeLink}\n            onMouseEnter={removeTooltip.onMouseEnter}\n            onMouseLeave={removeTooltip.onMouseLeave}\n          >\n            <LinkOffIcon />\n          </span>\n          <span\n            className=\"--icon\"\n            onMouseEnter={editTooltip.onMouseEnter}\n            onMouseLeave={editTooltip.onMouseLeave}\n            onClick={openEditDialog}\n          >\n            <PencilIcon />\n          </span>\n          <span\n            className=\"--icon\"\n            onClick={closeDialog}\n            onMouseEnter={closeTooltip.onMouseEnter}\n            onMouseLeave={closeTooltip.onMouseLeave}\n          >\n            <CloseIcon />\n          </span>\n        </span>\n      </div>\n    </$AnchorDialog>\n  )\n}\n","import { useRef } from \"react\"\n\nimport { $CloseMask } from \"../../styles/$CloseMask\"\n\n/**\n * Add this `CloseMask` before the Component you want this `CloseMask` to be\n * the background for.\n *\n * When users click on the `CloseMask`, it will close the layer.\n */\nexport function CloseMask({ close }: { close: () => void }) {\n  const ref = useRef<HTMLDivElement>(null)\n  return <$CloseMask ref={ref} onClick={close} />\n}\n","import styled from \"@emotion/styled\"\n\nexport const $CloseMask = styled(\"div\")`\n  position: fixed;\n  user-select: none;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  overflow-y: auto;\n  background: rgba(0, 0, 0, 0.01);\n`\n","import { isMac } from \"../../../sink\"\n\n/**\n * Character Reference\n *\n * Ctrl+P Ctrl+Shift+P Ctrl+Alt+P\n * ⌘P ⇧⌘P ⌥⌘P\n */\n\nexport const key = {\n  cmd: \"\\u2318\",\n  ctrl: \"\\u2303\",\n  shift: \"⇧\",\n  opt: \"⌥\",\n  enter: \"⏎\",\n}\n\nconst MAC_KEYS = {\n  shift: key.shift,\n  opt: key.opt,\n  alt: key.opt,\n  ctrl: key.ctrl,\n  mod: key.cmd,\n  cmd: key.cmd,\n  enter: key.enter,\n  super: `${key.opt}${key.cmd}`,\n}\n\nconst PC_KEYS = {\n  alt: \"ALT\",\n  ctrl: \"CTRL\",\n  opt: \"ALT\",\n  shift: \"SHIFT\",\n  mod: \"CTRL\",\n  cmd: \"CTRL\",\n  enter: key.enter,\n  super: \"CTRL+SHIFT\",\n}\n\nfunction pull<T>(arr: T[], value: T): void {\n  const index: number = arr.findIndex((el: T) => el === value)\n  if (index !== -1) {\n    arr.splice(index, 1)\n  }\n}\n\nfunction formatMac(segments: string[]) {\n  const result = []\n  Object.entries(MAC_KEYS).forEach(([key, symbol]) => {\n    if (segments.includes(key)) {\n      result.push(symbol)\n      pull(segments, key)\n    }\n  })\n  result.push(...segments.map((s) => s.toUpperCase()))\n  return result.join(\"\")\n}\n\nfunction formatPC(segments: string[]) {\n  const result = []\n  Object.entries(PC_KEYS).forEach(([key, symbol]) => {\n    if (segments.includes(key)) {\n      result.push(symbol)\n      pull(segments, key)\n    }\n  })\n  result.push(...segments.map((s) => s.toUpperCase()))\n  return result.join(\"+\")\n}\n\nexport function formatHotkey(shortcut: string) {\n  const segments = shortcut.toLowerCase().split(\"+\")\n  if (isMac()) {\n    return formatMac(segments)\n  } else {\n    return formatPC(segments)\n  }\n}\n","import { CSSProperties, useRef } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { useAbsoluteReposition } from \"../../../use-reposition\"\n\nimport { $Menu, $MenuDivider } from \"../../../toolbar-plugin/styles\"\nimport { MenuItemData } from \"../../types\"\nimport { CloseMask } from \"../CloseMask\"\nimport { MenuItem } from \"./MenuItem\"\n\nexport function Menu({\n  dest,\n  items,\n  close,\n}: {\n  dest: HTMLElement\n  close: () => void\n  items: MenuItemData[]\n}) {\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLDivElement>(null)\n  const style = useAbsoluteReposition({ src: ref, dest }, ({ dest }) => {\n    if (!dest) return { left: 0, top: 0 }\n    return { left: dest.left - 8, top: dest.top + dest.height }\n  }) as CSSProperties\n\n  return (\n    <>\n      <CloseMask close={close} />\n      <$Menu ref={ref} style={style}>\n        {items.map((item, index) => {\n          if (item === \"divider\") {\n            return <$MenuDivider key={index} />\n          } else if (item.show && !item.show(editor)) {\n            return null\n          } else {\n            return (\n              <MenuItem\n                key={index}\n                editor={editor}\n                item={item}\n                close={close}\n                dest={dest}\n              />\n            )\n          }\n        })}\n      </$Menu>\n    </>\n  )\n}\n","import { Rect } from \"../types\"\n\n/**\n * Returns a `Rect` representing the `fixed` positioning coordinates of\n * the `HTMLElement`\n */\nexport function getFixedRect(domElement: HTMLElement): Rect {\n  const bounds = domElement.getBoundingClientRect()\n  return {\n    top: bounds.top,\n    right: bounds.right,\n    bottom: bounds.bottom,\n    left: bounds.left,\n    width: bounds.width,\n    height: bounds.height,\n  }\n}\n","import { Rect } from \"../types\"\nimport { getFixedRect } from \"./get-fixed-rect\"\n\n/**\n * Returns a `Rect` representing the `absolute` positioning coordinates of\n * the `HTMLElement`\n *\n * NOTE: we add `window.scrollY` to get the `absolute` position.\n */\nexport function getAbsoluteRect(domElement: HTMLElement): Rect {\n  const rect = getFixedRect(domElement)\n  const { scrollY } = window\n  return Object.assign(rect, {\n    top: rect.top + scrollY,\n    bottom: rect.bottom + scrollY,\n  })\n}\n","import { Rect } from \"../types\"\n\n/**\n * Returns a `Rect` representing the `fixed` positioning coordinates of\n * the window viewport.\n */\nexport function getFixedViewport(): Rect {\n  /**\n   * Get the width of the viewport not including the scrollbar\n   *\n   * https://stackoverflow.com/a/25298418\n   */\n  const width =\n    document.documentElement.clientWidth || document.body.clientWidth\n  return {\n    top: 0,\n    right: width,\n    bottom: window.innerHeight,\n    left: 0,\n    width: width,\n    height: window.innerHeight,\n  }\n}\n","import { Rect } from \"../types\"\nimport { getFixedViewport } from \"./get-fixed-viewport\"\n\n/**\n * Returns a `Rect` representing the `absolute` positioning coordinates of\n * the window viewport.\n *\n * NOTE: we add `window.scrollY` to get the `absolute` position.\n */\nexport function getAbsoluteViewport(): Rect {\n  const rect = getFixedViewport()\n  return Object.assign(rect, {\n    top: window.scrollY,\n    bottom: window.scrollY + rect.height,\n  })\n}\n","var objectMapValues = map;\n\n/*\n  // returns a new object with the predicate applied to each value\n  // like just-map-object, but (value, key, object) are passed to the predicate\n  map({a: 3, b: 5, c: 9}, (value) => value + 1); // {a: 4, b: 6, c: 10}\n  map({a: 3, b: 5, c: 9}, (value, key) => value + key); // {a: 3a, b: 5b, c: 9c}\n  map({a: 3, b: 5, c: 9}, (value, key, object) => object.b); // {a: 5, b: 5, c: 5}\n*/\n\nfunction map(obj, predicate) {\n  var result = {};\n  var keys = Object.keys(obj);\n  var len = keys.length;\n  for (var i = 0; i < len; i++) {\n    var key = keys[i];\n    result[key] = predicate(obj[key], key, obj);\n  }\n  return result;\n}\n\nexport {objectMapValues as default};\n","import mapValues from \"just-map-values\"\nimport { RefObject } from \"react\"\n\nimport { MapHTMLElementLikeRecordToRectRecord, Rect } from \"./types\"\n\n/**\n * Tries to convert an `HTMLElement` to a `Rect` using the supplied\n * `convertElementToRect` method.\n *\n * The input Record can have as its values either an `HTMLElement` or a\n * `RefObject<HTMLElement>`. When it is a `RefObject` then it may or may not\n * refer to an `HTMLElement` so...\n *\n * - If the value is an `HTMLElement` we convert it to a `Rect`\n * - If the value is a `RefObject<HTMLElement>` we convert it to a\n *   `Rect | null` depending on whether the `RefObject` contains the\n *   `HTMLElement`.\n */\nexport function mapHTMLElementLikeRecordToRectRecord<\n  T extends Record<string, HTMLElement | RefObject<HTMLElement | null>>\n>(\n  elementLikeRecord: T,\n  converElementToRect: (element: HTMLElement) => Rect\n): MapHTMLElementLikeRecordToRectRecord<T> {\n  const rectRecord = mapValues(elementLikeRecord, (value) => {\n    const maybeHTMLElement =\n      value instanceof HTMLElement ? value : value.current\n    const nextValue = maybeHTMLElement\n      ? converElementToRect(maybeHTMLElement)\n      : null\n    return nextValue\n  }) as MapHTMLElementLikeRecordToRectRecord<T>\n  return rectRecord\n}\n","import { useEffect } from \"react\"\n\nimport {\n  useThrottledRefresh,\n  UseThrottledRefreshReturnType,\n} from \"./use-throttled-refresh\"\n\n/**\n * Refreshes the Component whenever the page is resized or the window is\n * scrolled. This is because these are usually the only two events that cause\n * the elements on a page to be repositioned.\n *\n * If there are yet other events that can cause the elements to be repositioned\n * or resized, you can also call the returned `refresh` method. This will\n * update the components while still respected the fact that the updates will\n * be throttled so as not to overload the browser.\n */\nexport function useReposition(): UseThrottledRefreshReturnType {\n  /**\n   * Create a throttled `refresh` method.\n   */\n  const refresh = useThrottledRefresh()\n\n  /**\n   * refresh on page resize or scroll (throttled)\n   */\n  useEffect(() => {\n    refresh()\n    window.addEventListener(\"resize\", refresh)\n    window.addEventListener(\"scroll\", refresh)\n    return () => {\n      window.removeEventListener(\"resize\", refresh)\n      window.removeEventListener(\"scroll\", refresh)\n    }\n  }, [])\n\n  return refresh\n}\n","/**\n * NOTE:\n *\n * We have a preference for `just` packages like `just-throttle` since they\n * tend to be micro, but `just-throttle` has a bug. It does not execute\n * on the trailing edge even when told to do so.\n *\n * We ran a test where we logged the call to `refresh` and when the refresh was\n * executed and there were leftover `refresh` calls without a trailing\n * execution.\n */\nimport throttle from \"lodash.throttle\"\nimport { useMemo, useState } from \"react\"\n\nexport type UseThrottledRefreshReturnType = ReturnType<typeof throttle> & {\n  counter: number\n}\n\n/**\n * Creates a hook that rerenders a component when the returned `refresh`\n * method is called; however, it throttles the refresh based on the\n * `intervalInMs` argument passed in.\n *\n * This is a useful component used when throttling reposition updates.\n */\nexport function useThrottledRefresh(\n  intervalInMs = 100\n): UseThrottledRefreshReturnType {\n  const [counter, setState] = useState(0)\n\n  const refresh = useMemo(\n    () =>\n      throttle(\n        () => {\n          setState((counter) => counter + 1)\n        },\n        intervalInMs,\n        { trailing: true }\n      ),\n    [intervalInMs]\n  )\n\n  return Object.assign(refresh, { counter })\n}\n","import { RefObject } from \"react\"\n\nimport { getAbsoluteRect } from \"../get-methods/get-absolute-rect\"\nimport { getAbsoluteViewport } from \"../get-methods/get-absolute-viewport\"\nimport { MapHTMLElementLikeRecordToRectRecord, Rect } from \"../types\"\nimport { mapHTMLElementLikeRecordToRectRecord } from \"../utils\"\nimport { useReposition } from \"./use-reposition\"\n\n/**\n * For `absolute` positioning.\n *\n * For `fixed` positioning see `useFixedReposition`\n *\n * An all-in-one hook that helps you position elements relative to other\n * elements and to the viewport.\n *\n * It automatically refreshes when the user scrolls or the window is resized.\n *\n * The method takes as its first argument an object where the values can be\n * either an `HTMLElement` or a ref to an `HTMLElement` created using\n * `useRef(null)`.\n *\n * As the second argument, it takes a function that you use to process\n * everything and return a value you can use to position the element. It's\n * typical to return this in the form of a `style` Object but it doesn't have\n * to be.\n *\n * That function you pass in can take these arguments:\n *\n * - The first argument is in the same shape as the object of `HTMLElement` or\n *   `ref` to `HTMLElement`; however, instead, its values are `Rect` or\n *   if the original value was a `ref`, a `Rect | null`. The value can be\n *   `null` because a `ref` can potentially contain no value and hence we can't\n *   find a `Rect` for it.\n * - The second argument is a `Rect` representing the viewport of the `window`.\n * - The third argument is a `refresh` method you can call to force a\n *   refresh. The refresh is throttled in sync with the ot\n */\nexport function useAbsoluteReposition<\n  T extends Record<string, HTMLElement | RefObject<HTMLElement | null>>,\n  NV\n>(\n  elementLikeRecord: T,\n  fn: (\n    elementRecord: MapHTMLElementLikeRecordToRectRecord<T>,\n    viewport: Rect,\n    refresh: () => void\n  ) => NV\n) {\n  const refresh = useReposition()\n  const rectRecord = mapHTMLElementLikeRecordToRectRecord(\n    elementLikeRecord,\n    (element) => getAbsoluteRect(element)\n  )\n  return fn(rectRecord, getAbsoluteViewport(), refresh)\n}\n","import { Rect } from \"../types\"\n\n/**\n * Takes a source Rect of the Element you are trying to position and makes\n * sure it is inside the container Rect.\n *\n * The source Rect can be `null` (e.g. when the `ref` hasn't been set yet) and\n * while it is, the item is positioned far off to the left of the screen.\n *\n * Can specify an optional `margin` as well.\n */\nexport function positionInside(\n  src: Rect | null,\n  container: Rect,\n  pos: { left: number; top: number },\n  { margin = 0 }: { margin?: number } = {}\n) {\n  if (src == null) return { ...pos, left: -1024 }\n\n  const { top } = pos\n  let { left } = pos\n\n  const containerWidth = container.right - container.left - margin * 2\n\n  // If modal is wider than container, align to left edge\n  if (src.width >= containerWidth) {\n    left = container.left + margin\n  } else {\n    // Check if it goes beyond right edge\n    const right = left + src.width\n    if (right > container.right - margin) {\n      left = container.right - src.width - margin\n    }\n\n    // Check if it goes beyond left edge\n    if (left < container.left + margin) {\n      left = container.left + margin\n    }\n  }\n\n  return { left, top }\n}\n","import styled from \"@emotion/styled\"\n\nimport { $Panel } from \"../../shared-overlays/styles/$Panel\"\n\nexport const $AnchorDialog = styled($Panel)`\n  width: 24em;\n  padding: 0;\n  overflow: hidden;\n`\nexport const $AnchorDialogInputLine = styled(\"div\")`\n  display: flex;\n  gap: 0.5em;\n`\n\nexport const $AnchorDialogInput = styled(\"input\")`\n  flex: 1 1 auto;\n  padding: 0.5em 0.75em;\n  border-radius: 0.25em;\n  color: var(--shade-700);\n  background: var(--shade-50);\n  border: 1px solid var(--shade-300);\n  font-size: 0.9375em;\n  &:focus {\n    outline: 2px solid var(--blue-200);\n  }\n`\n","import styled from \"@emotion/styled\"\n\nimport { SinkReset } from \"../../sink/editable\"\n\n/**\n * $Panel is a nice box that goes around a Drop Down menu or a Dialog Box.\n *\n * We don't use $Panel directly and instead we extend it.\n *\n * The $Panel itself extends the `SinkReset` and we do this because the\n * Component appears at the root. So any styling, for example like from\n * Bootstrap or Material UI will affect what's in the Panel.\n */\nexport const $Panel = styled(SinkReset)`\n  position: absolute;\n  z-index: 1000;\n  border: 1px solid var(--table-border-color);\n  border-radius: 0.5em;\n  overflow: clip;\n  filter: drop-shadow(0 4px 3px rgb(0 0 0 / 0.07))\n    drop-shadow(0 2px 2px rgb(0 0 0 / 0.06));\n  background: white;\n  color: #333;\n  max-width: calc(100vw - 32px);\n  box-sizing: border-box;\n  /**\n   * If you are tempted to add the transitions back in, here's why we left\n   * them off:\n   *\n   * - When we initially unhide the panel (by setting a negative 'left' pos)\n   *   the panel slides in very quickly. So we'd need to fix this first which\n   *   adds complexity.\n   *\n   * - Even if we fixed it, the browser window updates the scrolls and resizes\n   *   in a stepped manner (i.e. like frames in an animation). Keeping the\n   *   smooth animations makes the panel step in sync with the page refreshes\n   *   and so actually looks better.\n   *\n   * In other words, there's a technical issue we'd still need to solve but\n   * even if we did, it looks better this way.\n   */\n  /* transition: left 100ms, top 100ms; */\n`\n","import styled from \"@emotion/styled\"\n\nimport { $Container } from \"../../shared-layout\"\n\nexport const $Editable = styled(\"div\")`\n  padding: 2em;\n  flex: 1;\n  min-height: 0;\n`\n\nexport const $OuterContainer = styled($Container)`\n  /**\n   * We use this to make sure the top of the container is rounded even though\n   * the toolbar inside is square. We keep the toolbar square so that as the\n   * toolbar hits the top when scrolling, it can become sticky. We can try to\n   * round the toolbar, but it causes an issue where the part under the\n   * rounded part is still visible (i.e. the edge of the container). We can\n   * then try to put an absolutely positioned background on it with an opaque\n   * color, but that doesn't work unless we know the color of the background\n   * so... ultimately, it's not a good solution.\n   *\n   * NOTE:\n   *\n   * Using \"overflow: hidden;\" will break the \"position: sticky;\" and it will\n   * not work. \"overflow: clip;\" does work though.\n   *\n   * https://stackoverflow.com/a/73051006\n   */\n  overflow-y: clip;\n  display: flex;\n  flex-direction: column;\n  flex: 1;\n  min-height: 0;\n`\n","import styled from \"@emotion/styled\"\n\nimport { SinkReset } from \"../sink/editable\"\n\n/**\n * NOTE:\n *\n * This $Container should be extended and the following should be\n * added to it:\n *\n * - padding: We add this separately because if there is a toolbar, there\n *   should be no padding on the container but there should be\n *   padding on the actual editable. If it is the basic layout, we can add\n *   the padding on the $Container but also use the $Container styling\n *   directly on the Editable Component.\n */\nexport const $Container = styled(SinkReset)`\n  border: 1px solid var(--shade-300); /* shade-300 */\n  border-radius: 0.5em;\n  color: rgb(39 39 42); /* shade-800 */\n  line-height: 1.5;\n  /**\n   * !important is required because of role=\"textbox\" I think\n   */\n  outline: 2px solid transparent !important;\n  transition: all 250ms;\n  &.--focused {\n    /**\n     * !important is required because of role=\"textbox\" I think\n     */\n    outline: 2px solid var(--select-editor-color) !important;\n  }\n`\n","import styled from \"@emotion/styled\"\n\nimport { $Panel } from \"../../shared-overlays/styles/$Panel\"\n\n/**\n * Drop Down Menu\n */\nexport const $Menu = styled($Panel)`\n  position: absolute;\n  padding-top: 0.5em;\n  padding-bottom: 0.5em;\n  transition: all 200ms;\n  min-width: 12em;\n  /**\n   * Prevent clicks from stealing focus from the editor\n   */\n  user-select: none;\n`\n\n/**\n * Individual items in Drop Down Menu\n */\nexport const $MenuItem = styled(\"div\")`\n  display: flex;\n  z-index: 10;\n  padding: 0 1em 0 1.5em;\n  height: 2em;\n  align-items: center;\n  /**\n   * Normally we don't do it this way but since each part of the MenuItem\n   * is tightly related to the display: flex, this seemed the easiest way\n   * to set this up.\n   */\n  .--icon {\n    flex: 0 0;\n    display: block;\n    font-size: 1.25em;\n    height: 1em;\n    padding-right: 0.75em;\n    color: var(--shade-400);\n    svg {\n      position: relative;\n      stroke-width: 1.5px;\n    }\n  }\n  .--title {\n    flex: 1 1 auto;\n    font-size: 0.875em;\n    color: var(--shade-800);\n    white-space: nowrap;\n  }\n  .--hotkey {\n    flex: 0 0;\n    font-size: 0.75em;\n    padding-left: 1.5em;\n    color: var(--shade-500);\n  }\n  background: white;\n  cursor: pointer;\n  &:hover {\n    background: var(--blue-50);\n  }\n`\n\nexport const $MenuDivider = styled(\"div\")`\n  height: 1px;\n  background: var(--shade-200);\n  margin-top: 0.25em;\n  margin-bottom: 0.25em;\n`\n","import styled from \"@emotion/styled\"\n\nexport const $ToolbarContainer = styled(\"div\")`\n  /**\n   * This flex rule applies to the \"display: flex;\" of the parent container.\n   * Ensures the toolbar does not shrink or grow vertically.\n   */\n  flex: 0 0 auto;\n  /**\n   * If \"position: sticky;\" is not working, check the ancestor for \"overflow:\n   * hidden;\" of any kind. This will stop sticky from working. A good workaround\n   * is to use \"overflow: clip;\" instead.\n   *\n   * https://stackoverflow.com/a/73051006\n   */\n  position: sticky;\n  top: 0;\n  z-index: 2;\n  background: var(--shade-50);\n  /* font-size: 0.875em; */\n  font-size: 0.9375em;\n  padding: 0 0.5em;\n  border-bottom: 1px solid var(--shade-300);\n  /**\n   * Prevent clicks from stealing focus from the editor\n   */\n  user-select: none;\n  /**\n   * Extreme attention to detail. When the sticky is ending and the toolbar\n   * is stuck to the bottom of the editor, setting margin-bottom to -1px will\n   * fix the 2px bottom border and make it the proper 1px.\n   */\n  margin-bottom: -1px;\n\n  /**\n   * NOTE: The space in the equation is significant\n   */\n  height: calc(\n    3em + 1px\n  ); // $ToolbarDivider height + border-bottom of 1px above\n  overflow: hidden;\n`\n\nexport const $Toolbar = styled(\"div\")`\n  display: inline-block;\n  height: calc(\n    3em + 1px\n  ); // $ToolbarDivider height + border-bottom of 1px above\n`\n\nexport const $ToolbarDividerContainer = styled(\"div\")`\n  display: inline-block;\n  height: 3em;\n  padding: 0 0.375em;\n`\n\nexport const $ToolbarDivider = styled(\"div\")`\n  display: inline-block;\n  background: var(--shade-300);\n  opacity: 50%;\n  width: 1px;\n  height: 3em;\n`\n\nexport const $ToolbarButton = styled(\"div\")`\n  box-sizing: border-box;\n  position: relative;\n  display: inline-block;\n  vertical-align: top;\n  font-size: 1.25em;\n  margin-top: 0.25em;\n  height: 2em;\n  padding: 0.375em 0.375em;\n  border-radius: 0.25em;\n  text-align: center;\n  color: var(--shade-500);\n  transition: all 100ms;\n  cursor: pointer;\n  border: 1px solid rgba(0, 0, 0, 0);\n  &.--disabled {\n    opacity: 0.3;\n    cursor: default;\n    pointer-events: none;\n  }\n  &.--active {\n    color: var(--shade-700);\n    background: rgba(0, 0, 0, 0.05);\n    svg {\n      /* stroke-width: 2px; */\n    }\n  }\n  svg {\n    stroke-width: 1.5px;\n  }\n  @media (hover: hover) {\n    &:not(.--disabled):hover {\n      color: var(--shade-700);\n      background: var(--blue-100);\n      svg {\n        /* stroke-width: 2px; */\n      }\n    }\n  }\n\n  &.--more {\n    padding: 0.375em 0.5em;\n  }\n  .--more-icon {\n    position: absolute;\n    bottom: -0.2em;\n    left: 50%;\n    margin-left: -0.25em;\n    opacity: 0.375;\n  }\n`\n","import { useCallback } from \"react\"\nimport { Editor } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { $MenuItem } from \"../../../toolbar-plugin/styles\"\nimport { useLayer } from \"../../../use-layer\"\nimport { MenuItemData } from \"../../types\"\nimport { formatHotkey } from \"./formatHotkey\"\n\nexport function MenuItem({\n  editor,\n  item,\n  close,\n  dest,\n}: {\n  editor: Editor\n  item: Exclude<MenuItemData, \"divider\">\n  close: () => void\n  dest: HTMLElement\n}) {\n  const menuLayer = useLayer(\"menu\")\n\n  const onClick = useCallback(() => {\n    if (item.Component) {\n      const Component = item.Component\n      menuLayer.open(() => <Component dest={dest} close={menuLayer.close} />)\n    } else if (item.action) {\n      item.action(editor)\n      ReactEditor.focus(editor)\n      close()\n    }\n  }, [editor, item])\n  return (\n    <>\n      <$MenuItem onClick={onClick}>\n        <div className=\"--icon\">\n          <item.icon />\n        </div>\n        <div className=\"--title\">{item.title}</div>\n        <div className=\"--hotkey\">\n          {item.hotkey ? formatHotkey(item.hotkey) : undefined}\n        </div>\n      </$MenuItem>\n    </>\n  )\n}\n","import { MouseEvent, useCallback } from \"react\"\n\nimport { useLayer } from \"../use-layer\"\n\nimport { Tooltip } from \"./tooltip\"\nimport { Triangle } from \"./triangle\"\n\n/**\n * Takes a title and a hotkey and renders it as a tooltip.\n *\n * You'll notice that hotkey can be a function and the reason is very specific\n * to our needs which is that we don't know what the hotkey should look like\n * until we are in the browser (i.e. not the server) because it checks the user\n * agent to see if we are on a Mac or on Windows.\n *\n * We can defer this request until the tooltip is displayed.\n *\n * The editor currently has no need to display this hotkey shortcuts except in\n * things like tooltips so this isn't a problem for us. Potentially, we may need\n * to figure out a way to render this on the server or figure out a way to\n * render on the server without the hotkey and then fill it in when we are in\n * the browser.\n *\n * If we ever fix this requirement that hotkeys can only be shown in the browser\n * (i.e. we get server side rendering of hotkeys working) then `useTooltip` can\n * be simplified to not take a function.\n */\nexport function useTooltip(\n  {\n    title,\n    hotkey,\n  }: {\n    title: string\n    hotkey?: string | (() => string | undefined)\n  },\n  deps: React.DependencyList = []\n) {\n  const label = useLayer(\"tooltip-label\")\n  const triangle = useLayer(\"tooltip-triangle\")\n\n  /**\n   * On hover over\n   */\n  const onMouseEnter = useCallback((e: MouseEvent<HTMLElement>) => {\n    const dest = e.currentTarget\n    /**\n     * Open tooltip\n     */\n    if (title !== undefined) {\n      label.open(() => (\n        <Tooltip\n          title={title}\n          hotkey={typeof hotkey === \"function\" ? hotkey() : hotkey}\n          dest={dest}\n        />\n      ))\n      triangle.open(() => <Triangle dest={dest} />)\n    }\n  }, [title, hotkey, label, triangle, ...deps])\n\n  /**\n   * On hover out\n   */\n  const onMouseLeave = useCallback(() => {\n    label.close()\n    triangle.close()\n  }, [label, triangle, ...deps])\n  return { onMouseEnter, onMouseLeave }\n}\n","import styled from \"@emotion/styled\"\n\nexport function useRect(dest: HTMLElement): DOMRect {\n  return dest.getBoundingClientRect()\n}\n\nconst $Tooltip = styled(\"div\")`\n  position: fixed;\n  z-index: 10;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n  font-size: 1rem;\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto,\n    Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n  color: white;\n  font-size: 0.875em;\n  line-height: 1.5em;\n  padding: 0 0.5em;\n  color: var(--shade-300);\n  background: var(--shade-700);\n  border-radius: 0.25em;\n  white-space: nowrap;\n`\n\nconst $Hotkey = styled(\"span\")`\n  margin-left: 0.75em;\n  font-size: 0.875em;\n  font-weight: 500;\n  color: var(--shade-400);\n`\n\nexport function Tooltip({\n  title,\n  hotkey,\n  dest,\n}: {\n  title: string\n  hotkey?: string\n  dest: HTMLElement\n}) {\n  const rect = useRect(dest)\n  return (\n    <$Tooltip\n      style={{\n        left: rect.left,\n        top: `calc(${rect.top}px - 2em)`,\n      }}\n    >\n      {title}\n\n      {hotkey ? <$Hotkey>{hotkey}</$Hotkey> : null}\n    </$Tooltip>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nimport { useRect } from \"./tooltip\"\n\nconst $Triangle = styled(\"span\")`\n  position: fixed;\n  z-index: 10;\n  width: 0;\n  height: 0;\n  border-left: 0.375em solid transparent;\n  border-right: 0.375em solid transparent;\n  border-top: 0.375em solid var(--shade-700);\n`\n\nexport function Triangle({ dest }: { dest: HTMLElement }) {\n  const rect = useRect(dest)\n  return (\n    <$Triangle\n      style={{\n        left: `calc(${rect.left + rect.width / 2}px - 0.375em)`,\n        top: `calc(${rect.top}px - 0.5em)`,\n      }}\n    />\n  )\n}\n","import styled from \"@emotion/styled\"\nimport { useCallback, useRef, useState } from \"react\"\nimport { Node } from \"slate\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { $Panel } from \"../../shared-overlays\"\nimport { t } from \"../../utils/translations\"\nimport {\n  $CancelButton,\n  $FormCaption,\n  $FormGroup,\n  $FormHint,\n  $Input,\n  $PrimaryButton,\n  $Textarea,\n} from \"../../shared-styles\"\nimport { useLayer } from \"../../use-layer\"\nimport { positionInside, useAbsoluteReposition } from \"../../use-reposition\"\nimport { AnchorElement } from \"../index\"\nimport { AnchorDialog } from \"./AnchorDialog\"\nimport { DraggableHeader } from \"../../toolbar-plugin/components/dialog/DraggableHeader\"\n\nconst $AnchorEditDialog = styled($Panel)`\n  position: absolute;\n  width: 20em;\n  padding: 0;\n  overflow: hidden;\n`\n\nexport function AnchorEditDialog({\n  destAnchor,\n  destStartEdge,\n  element,\n}: {\n  destAnchor: HTMLAnchorElement\n  destStartEdge: HTMLSpanElement\n  element: AnchorElement\n}) {\n  const dialog = useLayer(\"dialog\")\n  const ref = useRef<HTMLDivElement>(null)\n  const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 })\n\n  const handleDrag = useCallback((deltaX: number, deltaY: number) => {\n    setDragOffset(prev => ({ x: prev.x + deltaX, y: prev.y + deltaY }))\n  }, [])\n\n  const baseStyle = useAbsoluteReposition(\n    { src: ref, destAnchor, destStartEdge },\n    ({ src, destAnchor, destStartEdge }, viewport) => {\n      return positionInside(\n        src,\n        viewport,\n        {\n          left: destStartEdge.left,\n          top: destAnchor.top + destAnchor.height,\n        },\n        { margin: 16 }\n      )\n    }\n  )\n\n  const style = {\n    ...baseStyle,\n    left: (baseStyle.left as number) + dragOffset.x,\n    top: (baseStyle.top as number) + dragOffset.y,\n  }\n\n  const editor = useSlateStatic()\n\n  const [href, setHref] = useState<string>(element.href)\n  const [text, setText] = useState<string>(Node.string(element))\n  const [title, setTitle] = useState<string>(element.title || \"\")\n\n  const formRef = useRef({ href, text, title })\n  formRef.current = { href, text, title }\n\n  const handleHrefChange = useCallback<\n    React.ChangeEventHandler<HTMLInputElement>\n  >((e) => {\n    setHref(e.target.value)\n  }, [])\n\n  const handleTextChange = useCallback<\n    React.ChangeEventHandler<HTMLInputElement>\n  >((e) => {\n    setText(e.target.value)\n  }, [])\n\n  const handleTitleChange = useCallback<\n    React.ChangeEventHandler<HTMLInputElement>\n  >((e) => {\n    setTitle(e.target.value)\n  }, [])\n\n  const openAnchorDialog = useCallback(() => {\n    dialog.open(() => (\n      <AnchorDialog\n        destAnchor={destAnchor}\n        destStartEdge={destStartEdge}\n        element={element}\n      />\n    ))\n  }, [destAnchor, destStartEdge, element])\n\n  const handleSubmit = useCallback(() => {\n    const { href, text, title } = formRef.current\n    editor.anchor.editLink({ href, text, title }, { at: element })\n    openAnchorDialog()\n  }, [openAnchorDialog])\n\n  return (\n    <$AnchorEditDialog ref={ref} contentEditable={false} style={style}>\n      <DraggableHeader onDrag={handleDrag} />\n      <div style={{ padding: \"1em\" }}>\n        <$FormGroup>\n          <$FormCaption>{t(\"linkUrl\")}</$FormCaption>\n          <$Textarea as=\"textarea\" value={href} onChange={handleHrefChange} />\n        </$FormGroup>\n        <$FormGroup>\n          <$FormCaption>{t(\"linkText\")}</$FormCaption>\n          <$Input type=\"text\" value={text} onChange={handleTextChange} />\n          <$FormHint>{t(\"linkTextHint\")}</$FormHint>\n        </$FormGroup>\n        <$FormGroup>\n          <$FormCaption>{t(\"tooltipText\")}</$FormCaption>\n          <$Input type=\"text\" value={title} onChange={handleTitleChange} />\n          <$FormHint>{t(\"tooltipHint\")}</$FormHint>\n        </$FormGroup>\n        <$FormGroup>\n          <$PrimaryButton onClick={handleSubmit}>{t(\"apply\")}</$PrimaryButton>\n        </$FormGroup>\n        <$FormGroup>\n          <$CancelButton onClick={openAnchorDialog}>{t(\"cancel\")}</$CancelButton>\n        </$FormGroup>\n      </div>\n    </$AnchorEditDialog>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $FormGroup = styled(\"div\")`\n  margin: 0.5em 0;\n  &:first-of-type {\n    margin-top: 0;\n  }\n  &:last-of-type {\n    margin-bottom: 0;\n  }\n`\n\nexport const $FormCaption = styled(\"div\")`\n  font-size: 0.9375em;\n  margin-bottom: 0.25em;\n  color: var(--shade-700);\n`\n\nexport const $FormHint = styled(\"div\")`\n  font-size: 0.875em;\n  margin-top: 0.25em;\n  color: var(--shade-500);\n`\n\nexport const $Textarea = styled(\"input\")`\n  box-sizing: border-box;\n  width: 100%;\n  height: 6em;\n  padding: 0.5em 0.75em;\n  border-radius: 0.25em;\n  color: var(--shade-700);\n  background: var(--shade-50);\n  font-family: inherit;\n  border: 1px solid var(--shade-300);\n  font-size: 0.9375em;\n  &:focus {\n    outline: 2px solid var(--blue-200);\n  }\n`\n\nexport const $Input = styled(\"input\")`\n  box-sizing: border-box;\n  width: 100%;\n  padding: 0.5em 0.75em;\n  border-radius: 0.25em;\n  color: var(--shade-700);\n  background: var(--shade-50);\n  border: 1px solid var(--shade-300);\n  font-size: 0.9375em;\n  &:focus {\n    outline: 2px solid var(--blue-200);\n  }\n`\n\nexport const $BaseButton = styled(\"div\")`\n  /* Center vertically and horizontally */\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  padding: 0.25em 0.75em;\n  text-align: center;\n  transition: all 100ms;\n  border-radius: 0.25em;\n  svg {\n    font-size: 1.25em;\n    stroke-width: 2px;\n  }\n`\n\nexport const $PrimaryButton = styled($BaseButton)`\n  color: var(--blue-50);\n  background: var(--blue-500);\n  outline: 0px solid white;\n  &:hover {\n    color: white;\n    background: var(--blue-600);\n    outline: 2px solid var(--blue-200);\n  }\n  svg {\n    color: var(--blue-200);\n  }\n`\n\nexport const $CancelButton = styled($BaseButton)`\n  color: var(--shade-500);\n  background: var(--shade-200);\n  outline: 0px solid white;\n  &:hover {\n    color: var(--shade-600);\n    background: var(--shade-300);\n    outline: 2px solid var(--shade-200);\n  }\n  svg {\n    color: var(--shade-400);\n  }\n`\n","import { useRef, useCallback } from \"react\"\nimport styled from \"@emotion/styled\"\n\nconst $DragHandle = styled.div`\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  padding: 6px 0;\n  cursor: grab;\n  background: linear-gradient(to bottom, #f8f8f8, #e8e8e8);\n  border-bottom: 1px solid #ddd;\n  border-radius: 4px 4px 0 0;\n  user-select: none;\n  touch-action: none;\n\n  &:active {\n    cursor: grabbing;\n  }\n`\n\nconst $DragIndicator = styled.div`\n  width: 32px;\n  height: 4px;\n  background: #ccc;\n  border-radius: 2px;\n`\n\ninterface DraggableHeaderProps {\n  onDrag: (deltaX: number, deltaY: number) => void\n}\n\nexport function DraggableHeader({ onDrag }: DraggableHeaderProps) {\n  const startPos = useRef<{ x: number; y: number } | null>(null)\n\n  const handleStart = useCallback((clientX: number, clientY: number) => {\n    startPos.current = { x: clientX, y: clientY }\n  }, [])\n\n  const handleMove = useCallback((clientX: number, clientY: number) => {\n    if (!startPos.current) return\n    const deltaX = clientX - startPos.current.x\n    const deltaY = clientY - startPos.current.y\n    startPos.current = { x: clientX, y: clientY }\n    onDrag(deltaX, deltaY)\n  }, [onDrag])\n\n  const handleEnd = useCallback(() => {\n    startPos.current = null\n  }, [])\n\n  // Mouse events\n  const onMouseDown = useCallback((e: React.MouseEvent) => {\n    e.preventDefault()\n    handleStart(e.clientX, e.clientY)\n\n    const onMouseMove = (e: MouseEvent) => {\n      handleMove(e.clientX, e.clientY)\n    }\n    const onMouseUp = () => {\n      handleEnd()\n      document.removeEventListener(\"mousemove\", onMouseMove)\n      document.removeEventListener(\"mouseup\", onMouseUp)\n    }\n\n    document.addEventListener(\"mousemove\", onMouseMove)\n    document.addEventListener(\"mouseup\", onMouseUp)\n  }, [handleStart, handleMove, handleEnd])\n\n  // Touch events\n  const onTouchStart = useCallback((e: React.TouchEvent) => {\n    if (e.touches.length !== 1) return\n    const touch = e.touches[0]\n    handleStart(touch.clientX, touch.clientY)\n  }, [handleStart])\n\n  const onTouchMove = useCallback((e: React.TouchEvent) => {\n    if (e.touches.length !== 1) return\n    // touch-action: none in CSS prevents scrolling, so no need for preventDefault\n    const touch = e.touches[0]\n    handleMove(touch.clientX, touch.clientY)\n  }, [handleMove])\n\n  const onTouchEnd = useCallback(() => {\n    handleEnd()\n  }, [handleEnd])\n\n  return (\n    <$DragHandle\n      onMouseDown={onMouseDown}\n      onTouchStart={onTouchStart}\n      onTouchMove={onTouchMove}\n      onTouchEnd={onTouchEnd}\n    >\n      <$DragIndicator />\n    </$DragHandle>\n  )\n}\n","import { SVGProps } from \"react\"\n\nimport { TablerIcon } from \"../../sink\"\n\nexport const ExternalLinkIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"M12 6H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6M11 13l9-9M15 4h5v5\" />\n  </TablerIcon>\n)\n\nexport const LinkOffIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"m9 15 3-3m2-2 1-1M11 6l.463-.536a5 5 0 0 1 7.071 7.072L18 13M3 3l18 18M13 18l-.397.534a5.068 5.068 0 0 1-7.127 0 4.972 4.972 0 0 1 0-7.071L6 11\" />\n  </TablerIcon>\n)\n\nexport const PencilIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"M4 20h4L18.5 9.5a1.5 1.5 0 0 0-4-4L4 16v4M13.5 6.5l4 4\" />\n  </TablerIcon>\n)\n\nexport const CloseIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"M18 6L6 18M6 6l12 12\" />\n  </TablerIcon>\n)\n","import { Descendant } from \"slate\"\n\nimport { createPlugin, curryOne } from \"../sink\"\n\nimport { TypedPlugin } from \"../sink/types/plugin/plugin\"\nimport { onPaste } from \"./editable/on-paste\"\nimport { createAnchorMethods } from \"./methods\"\nimport { normalizeNode } from \"./normalize-node\"\nimport { Anchor } from \"./render-element/anchor\"\n\ntype AnchorMethods = ReturnType<typeof createAnchorMethods>\n\nexport type AnchorEditor = {\n  anchor: AnchorMethods\n}\n\nexport type AnchorElement = {\n  type: \"anchor\"\n  href: string\n  target?: string\n  title?: string\n  children: Descendant[]\n}\n\nexport type AnchorPluginCustomTypes = {\n  Name: \"anchor\"\n  Editor: AnchorEditor\n  Element: AnchorElement\n}\n\nexport const AnchorPlugin = createPlugin<AnchorPluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    editor.anchor = createAnchorMethods(editor)\n    return createPolicy({\n      name: \"anchor\",\n      editor: {\n        isInline(element) {\n          if (element.type === \"anchor\") return true\n        },\n        normalizeNode: curryOne(normalizeNode, editor),\n      },\n      editableProps: {\n        onPaste: curryOne(onPaste, editor),\n        renderElement: ({ element, attributes, children }) => {\n          if (element.type === \"anchor\") {\n            return (\n              <Anchor element={element} attributes={attributes}>\n                {children}\n              </Anchor>\n            )\n          }\n        },\n      },\n    })\n  }\n) as TypedPlugin<AnchorPluginCustomTypes>\n","import { Editor, Transforms } from \"slate\"\n\nimport { createPlugin, TypedPlugin } from \"../sink\"\n\nimport { isSafeDelete } from \"./is-safe-delete\"\n\ntype AtomicDeleteEditor = {\n  atomicDelete: true\n}\n\nexport type AtomicDeletePluginCustomTypes = {\n  Name: \"atomic-delete\"\n  Editor: AtomicDeleteEditor\n}\n\n/**\n * The Atomic Delete plugin protects master/slave related elements from being\n * put into a bad state after a delete.\n *\n * This can happen because Slate's default delete behavior does not take into\n * account the relationship between master/slave elements.\n *\n * Specifically, atomic delete protects against the following situations:\n *\n * - User forward deletes from just before a table. The first cell in the\n *   table is deleted leaving a first row with one less cell than the rest\n *   of the table.\n *\n * - User forward deletes at the end of a code block. Text from outside the\n *   code block is pulled into the code block.\n *\n * - User backward deletes from just after a code block. Text from outside the\n *   code block is pulled into the code block.\n *\n * - User backward deletes at the start of a code block. Text from inside the\n *   code block is pulled outside the code block.\n */\nexport const AtomicDeletePlugin = createPlugin<AtomicDeletePluginCustomTypes>(\n  (editor) => {\n    editor.atomicDelete = true\n    return {\n      name: \"atomic-delete\",\n      editor: {\n        deleteBackward() {\n          if (editor.selection == null) return false\n          const entry = Editor.node(editor, editor.selection)\n          const prevEntry = Editor.previous(editor, { mode: \"lowest\" })\n          if (isSafeDelete(editor, entry, prevEntry)) return false\n          Transforms.move(editor, { unit: \"character\", reverse: true })\n          return true\n        },\n        deleteForward() {\n          if (editor.selection == null) return false\n          const entry = Editor.node(editor, editor.selection)\n          const nextEntry = Editor.next(editor, { mode: \"lowest\" })\n          if (isSafeDelete(editor, entry, nextEntry)) return false\n          Transforms.move(editor, { unit: \"character\" })\n          return true\n        },\n      },\n    }\n  }\n) as TypedPlugin<AtomicDeletePluginCustomTypes>\n","import { Editor, Element, NodeEntry, Path } from \"slate\"\n\nimport { findElementUp } from \"../sink\"\n\nexport function isSafeDelete(\n  editor: Editor,\n  a: NodeEntry | undefined,\n  b: NodeEntry | undefined\n) {\n  if (!a || !b) return true\n  /**\n   * If the current Node and the next Node are the same, short circuit\n   * and leave early. Good for performance.\n   */\n  if (Path.equals(a[1], b[1])) return true\n  const masterEntryA = findElementUp(\n    editor,\n    (el) => Element.isElement(el) && editor.isMaster(el),\n    { at: a[1] }\n  )\n  const masterEntryB = findElementUp(\n    editor,\n    (el) => {\n      return Element.isElement(el) && editor.isMaster(el)\n    },\n    { at: b[1] }\n  )\n  /**\n   * If neither have a master, then don't worry about it.\n   */\n  if (!masterEntryA && !masterEntryB) return true\n  /**\n   * If they both have a master but it's the same master, then don't\n   * worry about it.\n   */\n  if (\n    masterEntryA &&\n    masterEntryB &&\n    Path.equals(masterEntryA[1], masterEntryB[1])\n  )\n    return true\n  return false\n}\n","import { Editor, Transforms } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { createPlugin, curryOne, TypedPlugin } from \"../sink\"\n\nimport { createImageMethods } from \"./methods\"\nimport { normalizeNode } from \"./normalize-node\"\nimport { renderElement } from \"./render-element\"\nimport { ImagePluginConfig, ImagePluginCustomTypes } from \"./types\"\n\n/**\n * Handle drop events for image files\n */\nfunction createOnDrop(editor: Editor) {\n  return (event: React.DragEvent<HTMLDivElement>): boolean => {\n    const { dataTransfer } = event\n\n    // Check if there are files being dropped\n    if (!dataTransfer.files || dataTransfer.files.length === 0) {\n      return false\n    }\n\n    // Check if any of the files are images\n    const imageFiles = Array.from(dataTransfer.files).filter((file) =>\n      file.type.startsWith(\"image/\")\n    )\n\n    if (imageFiles.length === 0) {\n      return false\n    }\n\n    event.preventDefault()\n    event.stopPropagation()\n\n    // Get the drop position and move cursor there\n    const range = ReactEditor.findEventRange(editor, event)\n    if (range) {\n      Transforms.select(editor, range)\n    }\n\n    // Get the onImageChange handler from the editor\n    const onImageChange = editor.wysimark?.onImageChange\n\n    // Process each image file\n    for (const file of imageFiles) {\n      if (onImageChange) {\n        onImageChange(file)\n          .then((url) => {\n            if (url) {\n              editor.image.insertImageFromUrl(url, file.name, \"\")\n            }\n          })\n          .catch(() => {\n            // Failed to upload image - silently ignore\n          })\n      } else {\n        // If no onImageChange handler, create a data URL\n        const reader = new FileReader()\n        reader.onload = () => {\n          const dataUrl = reader.result as string\n          editor.image.insertImageFromUrl(dataUrl, file.name, \"\")\n        }\n        reader.readAsDataURL(file)\n      }\n    }\n\n    return true\n  }\n}\n\nconst DEFAULT_OPTIONS: ImagePluginConfig = {\n  maxInitialInlineImageSize: { width: 64, height: 64 },\n  maxInitialImageSize: { width: 320, height: 320 },\n  maxImageSize: { width: 1024, height: 1024 },\n  imageBlockPresets: [\n    /**\n     * Pixel Presets\n     */\n    { name: \"S\", title: \"Small\", type: \"bounds\", width: 160, height: 160 },\n    { name: \"M\", title: \"Medium\", type: \"bounds\", width: 320, height: 320 },\n    { name: \"L\", title: \"Large\", type: \"bounds\", width: 640, height: 640 },\n    /**\n     * Scale Presets\n     */\n    { name: \"⅓\", title: \"1/3 scale\", type: \"scale\", scale: 1 / 3 },\n    { name: \"½\", title: \"1/2 scale\", type: \"scale\", scale: 0.5 },\n    { name: \"Full\", title: \"Full size\", type: \"scale\", scale: 1 },\n  ],\n  imageInlinePresets: [\n    /**\n     * Pixel Presets\n     */\n    {\n      name: \"16\",\n      title: \"16 pixels\",\n      type: \"bounds\",\n      width: 16,\n      height: 16,\n    },\n    {\n      name: \"24\",\n      title: \"24 pixels\",\n      type: \"bounds\",\n      width: 24,\n      height: 24,\n    },\n    {\n      name: \"32\",\n      title: \"32 pixels\",\n      type: \"bounds\",\n      width: 32,\n      height: 32,\n    },\n    /**\n     * Scale Presets\n     */\n    { name: \"⅓\", title: \"1/3 scale\", type: \"scale\", scale: 1 / 3 },\n    { name: \"½\", title: \"1/2 scale\", type: \"scale\", scale: 0.5 },\n    { name: \"Full\", title: \"Full size\", type: \"scale\", scale: 1 },\n  ],\n}\n\nexport const ImagePlugin = //({\n  createPlugin<ImagePluginCustomTypes>(\n    (editor, sinkOptions, { createPolicy }) => {\n      const options: ImagePluginConfig = {\n        ...DEFAULT_OPTIONS,\n        ...sinkOptions.image,\n      }\n      editor.image = {\n        ...createImageMethods(editor),\n        maxInitialInlineImageSize: options.maxInitialInlineImageSize,\n        maxInitialImageSize: options.maxInitialImageSize,\n        maxImageSize: options.maxImageSize,\n        imageBlockPresets: options.imageBlockPresets,\n        imageInlinePresets: options.imageInlinePresets,\n      }\n\n      return createPolicy({\n        name: \"image\",\n        editor: {\n          isVoid: (element) => {\n            if ([\"image-block\", \"image-inline\"].includes(element.type)) {\n              return true\n            }\n          },\n          isInline: (element) => {\n            if (element.type === \"image-inline\") return true\n          },\n          normalizeNode: curryOne(normalizeNode, editor),\n        },\n        editableProps: {\n          renderElement,\n          onDrop: createOnDrop(editor),\n        },\n      })\n    }\n  ) as TypedPlugin<ImagePluginCustomTypes>\n","import { Editor, Transforms } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { curryOne } from \"../../sink\"\nimport { ImageBlockElement} from \"../types\"\n\nfunction noop(_editor: Editor) {\n  // Intentionally empty - noop function\n}\n\nfunction insertImageFromUrl(\n  editor: Editor,\n  url: string,\n  alt?: string,\n  title?: string,\n) {\n  const { selection } = editor\n  \n  Transforms.insertNodes(editor, {\n    type: \"image-block\",\n    url,\n    alt: alt || \"\",\n    title: title || \"\",\n    width: 320,\n    height: 240,\n    children: [{ text: \"\" }],\n  } as ImageBlockElement)\n\n  /**\n   * If there is no selection the element is inserted at the bottom of the\n   * editor. When this happens, the insertion point may not be visible and\n   * so this code scrolls to the bottom of the editor. We don't do this if\n   * there is a selection because if the user made a selection, it is\n   * likely already in view.\n   */\n  if (!selection) {\n    const lastPos = Editor.end(editor, [])\n    Transforms.select(editor, lastPos)\n    ReactEditor.focus(editor)\n  }\n}\n\nexport function createImageMethods(editor: Editor) {\n  return {\n    noop: curryOne(noop, editor),\n    insertImageFromUrl: curryOne(insertImageFromUrl, editor),\n  }\n}\n","import { Editor, Node, NodeEntry } from \"slate\"\n\nexport function normalizeNode(_editor: Editor, _entry: NodeEntry<Node>): boolean {\n  // No normalization needed for image nodes\n  return false\n}\n","import { useSlateStatic } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { $ImageBlock } from \"../styles/image-block-styles\"\nimport { ImageBlockElement } from \"../types\"\nimport { ImageWithControls } from \"./image-with-controls\"\n\nexport function ImageBlock({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<ImageBlockElement>) {\n  const editor = useSlateStatic()\n  return (\n    <div {...attributes}>\n      <$ImageBlock contentEditable={false}>\n        <ImageWithControls\n          element={element}\n          presets={editor.image.imageBlockPresets}\n        />\n      </$ImageBlock>\n      {children}\n    </div>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $ImageBlock = styled(\"div\")`\n  display: block;\n  margin: 1em 0;\n`\n","import { clsx } from \"clsx\"\nimport { useState } from \"react\"\nimport { useSelected } from \"slate-react\"\n\nimport {\n  $Image,\n  $ImageContainer,\n} from \"../../styles/image-with-controls-styles/image-with-controls-styles\"\nimport {\n  ImageBlockElement,\n  ImageInlineElement,\n  ImageSizePreset,\n} from \"../../types\"\nimport { ImageResizeControl } from \"./image-resize-controls/image-resize-control\"\nimport { ImageSizeStatus } from \"./image-size-status/image-size-status\"\nimport { ImageToolbar } from \"./image-toolbar/image-toolbar\"\n\n/**\n * The `Image` Component is responsible for:\n *\n * - rendering the image\n * - displaying the UI for the image including\n *   - resize controls\n *   - current width/height\n *   - image preset size controls\n *\n * It's outer $ImageContainer is represented as an `inline-block` and is\n * placed inside a `block` element for the `image-block` and a `span` element\n * for `image-inline`.\n */\nexport function ImageWithControls({\n  element,\n  presets,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n  presets: ImageSizePreset[]\n}) {\n  const url = element.url\n  const selected = useSelected()\n  const [isDragging, setIsDragging] = useState(false)\n  const [size, setSize] = useState(\n    element.srcWidth && element.srcHeight && element.width && element.height\n      ? { width: element.width, height: element.height }\n      : null\n  )\n\n  /**\n   * Creates a `srcSize` object if there is both a srcWidth and a srcHeight.\n   * This also acts as an indicator that the image can be resized. If there is\n   * a `srcSize` present we know that the image can be resized.\n   */\n  const srcSize =\n    element.srcWidth && element.srcHeight\n      ? { width: element.srcWidth, height: element.srcHeight }\n      : null\n\n  /**\n   * Show resize controls if the element is selected, it has a `size` and\n   * it has a `srcSize`\n   */\n  const showControls = selected && size && srcSize\n\n  /**\n   * Add classes for different states.\n   */\n  const className = clsx({\n    \"--selected\": selected,\n    \"--dragging\": isDragging,\n    \"--small\": size && (size.width <= 64 || size.height <= 64),\n  })\n\n  /**\n   * The purpose of the surrounding $ImageContainer is simply to surround the\n   * image tightly so that we can place the other control elements relative\n   * to the image.\n   *\n   * In order to do this, the $ImageContainer must be an `inline-block` or else\n   * space gets added on the inside of the container.\n   *\n   * NOTE:\n   *\n   * Everything inside the $ImageContainer must be safe to insert into a\n   * `<p>` tag which means `<div>` tags are not allowed. Use `<span>` tags\n   * instead, even if they are blocks. This is because we get some invalid\n   * nested warning otherwise as `<div>` tags are not supposed to be children\n   * of `<p>` tags.\n   */\n  return (\n    <$ImageContainer className={className}>\n      <$Image src={url} width={size?.width} height={size?.height} />\n      {showControls ? (\n        <ImageToolbar\n          element={element}\n          size={size}\n          setSize={setSize}\n          srcSize={srcSize}\n          presets={presets}\n        />\n      ) : null}\n      {/**\n       * Show the size status bar only when the user is dragging to resize the\n       * image.\n       */}\n      {isDragging && size ? <ImageSizeStatus size={size} /> : null}\n      {showControls ? (\n        <ImageResizeControl\n          element={element}\n          srcSize={srcSize}\n          isDragging={isDragging}\n          setIsDragging={setIsDragging}\n          size={size}\n          setSize={setSize}\n        />\n      ) : null}\n    </$ImageContainer>\n  )\n}\n","import styled from \"@emotion/styled\"\n\n/**\n * Wrap the image with a container so we can accurately place UI elements\n * around it.\n */\nexport const $ImageContainer = styled(\"span\")`\n  /**\n   * In order for this container to wrap tightly (without space), it needs to be\n   * an \"inline-block\". If it's just an \"inline\" we end up with spacing\n   * artificats related to how spacing is placed around text.\n   */\n  display: inline-block;\n  /**\n   * This wrapper's primary purpose (why we don't use the image by itself) is\n   * so that we can place UI controls for the image in and around the image.\n   */\n  position: relative;\n`\n\nexport const $Image = styled(\"img\")`\n  /**\n   * TODO:\n   *\n   * This is a bit of a hack but is a better experience than not anything.\n   *\n   * Constrains the maximum resize width of an image to 100% of the space\n   * available. This prevents the image from stepping outside its boundaries.\n   *\n   * Problem:\n   *\n   * - The \"height\" is set to \"auto\" which likely conflicts with the height\n   *   provided as an image attribute of \"height\" set by the application.\n   *   Effectively, this means that the \"height\" is ignored which is fine\n   *   except when the image hasn't been loaded yet, I think it's possible\n   *   and perhaps likely that there may be a reflow that happens before/after\n   *   the image is loaded.\n   */\n  max-width: 100%;\n  max-height: 50vh;\n  height: auto;\n\n  /**\n   * Rounded borders are pretty and also help the selection outline look\n   * pretty.\n   */\n  transition: border-radius 250ms;\n  border-radius: 0.5em;\n  .--small > & {\n    border-radius: 1px;\n  }\n  display: block;\n\n  /**\n   * Selection border. We leave a space between the outline and the image so\n   * that an image that is the same color as the selection border will still\n   * look selected.\n   */\n  .--selected > & {\n    outline: 2px solid var(--select-color);\n    outline-offset: 1px;\n  }\n  /**\n   * If the image isn't loaded yet, we want to have some color filling the space\n   * that the image will eventually load into. This helps indicates to the user\n   * the space that the image will fill into.\n   *\n   * Once the image is finished loading, we want to respect transparency so at\n   * that point we hide the background shading.\n   */\n  .--loading > & {\n    background: var(--shade-100);\n  }\n\n  /**\n   * When we change the image via a preset, we want to animate the change;\n   * however, when we are dragging to resize, a transition adds a janky delay\n   * to the resize so we remove the transition during drag resizing.\n   */\n  transition: width 100ms, height 100ms;\n  .--dragging > & {\n    transition: border-radius 250ms;\n  }\n`\n","import { clsx } from \"clsx\"\nimport { Dispatch, SetStateAction, useCallback, useEffect, useRef } from \"react\"\nimport { Editor, Transforms } from \"slate\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\n\nimport { stopEvent } from \"../../../../sink\"\nimport { useResizeBrowser } from \"../../../../use-reposition/hooks\"\n\nimport {\n  $ImageResizeHandle,\n  $ImageResizeInvisibleHandle,\n} from \"../../../styles/image-with-controls-styles/image-resize-handle-styles\"\nimport {\n  ImageBlockElement,\n  ImageInlineElement,\n  ImageSize,\n} from \"../../../types\"\nimport { getEditorWidth, minMax, resizeToWidth } from \"../../../utils\"\n\n/**\n * Helper function finds the `img` inside the current Slate `Element`.\n *\n * The `Element` in the DOM points to the surrounding container, so we search\n * inside of it for the `img` tag which know there is only one of.\n *\n * We then get the client rect from it.\n */\nfunction getImageBoundsFromSlateElement(\n  editor: Editor,\n  element: ImageBlockElement | ImageInlineElement\n): DOMRect {\n  const imageContainerDOMNode = ReactEditor.toDOMNode(editor, element)\n  const imgDOMNode = imageContainerDOMNode.querySelector(\"img\")\n  if (!imgDOMNode)\n    throw new Error(`Image Element could not be found but should exist`)\n  return imgDOMNode.getBoundingClientRect()\n}\n\nexport function ImageResizeControl({\n  element,\n  srcSize,\n  size,\n  setSize,\n  isDragging,\n  setIsDragging,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n  srcSize: ImageSize\n  size: ImageSize\n  setSize: Dispatch<SetStateAction<ImageSize | null>>\n  isDragging: boolean\n  setIsDragging: Dispatch<SetStateAction<boolean>>\n}) {\n  const editor = useSlateStatic()\n  const mouseMoveRef = useRef<((e: MouseEvent) => void) | null>(null)\n  const mouseUpRef = useRef<(() => void) | null>(null)\n  const touchMoveRef = useRef<((e: TouchEvent) => void) | null>(null)\n  const touchEndRef = useRef<(() => void) | null>(null)\n\n  /**\n   * Refreshes the rendering of the resize handle if the browser width is\n   * changed. This is useful, for example, if the browser is resized, making\n   * the editable area smaller, which in some cases shoudl cause the resize\n   * handle to indicate that the image can only be resized smaller.\n   */\n  useResizeBrowser()\n\n  /**\n   * Retrieve the inner (usable) width of the editor.\n   */\n  const editorWidth = getEditorWidth(editor)\n\n  /**\n   * Create some convenience constants that we use a lot below\n   */\n  const width = size.width\n  const maxWidth = Math.min(srcSize.width, editorWidth)\n  const minWidth = Math.min(12, srcSize.width)\n\n  /**\n   * Start dragging\n   */\n  const onMouseDown = useCallback(\n    (e: React.MouseEvent) => {\n      stopEvent(e)\n      setIsDragging(true)\n\n      /**\n       * Position of mouse pointer when mouse down is pressed\n       */\n      const startX = e.clientX\n\n      /**\n       * The initial image size for the visual image (i.e. the image we are\n       * seeing on the screen) can vary from the image width as stored in the\n       * Document value.\n       *\n       * This is because if the document image width value is larger than the\n       * screen width, we have constrained the image so that it fits.\n       *\n       * When we start a resize, we want the resize to start at the visual\n       * image width though or the drag may appear broken. For example, if you\n       * start resizing smaller, if the image is larger than the width of the\n       * screen, the resize will take no effect.\n       *\n       * For this reason, we start with the visual screen width.\n       */\n      const bounds = getImageBoundsFromSlateElement(editor, element)\n      const startWidth = bounds.width\n\n      let nextSize = { ...size }\n\n      /**\n       * Watch mouse movement during dragging\n       */\n      const onDocumentMouseMove = (e: MouseEvent) => {\n        const nextWidth = minMax({\n          value: startWidth + e.clientX - startX,\n          min: minWidth,\n          max: maxWidth,\n        })\n        nextSize = resizeToWidth(nextWidth, srcSize)\n\n        setSize(nextSize)\n      }\n\n      /**\n       * Remove dragging event listeners when releasing mouse button\n       */\n      const onDocumentMouseUp = () => {\n        document.removeEventListener(\"mousemove\", onDocumentMouseMove)\n        document.removeEventListener(\"mouseup\", onDocumentMouseUp)\n        mouseMoveRef.current = null\n        mouseUpRef.current = null\n        const path = ReactEditor.findPath(editor, element)\n        /**\n         * When we save the image to the document, at the moment, we have\n         * decided to save the image at the actual resize width, as stored\n         * in the resize state. This is different than using the visual\n         * image width which is constrained to the width of the screen.\n         *\n         * Not sure if this is the right approach, but it does allow for a\n         * manual workaround if desired where the content is being edited in\n         * a smaller screen than the output window and the user wants to have\n         * the image display at a larger size.\n         *\n         * Note that this is already possible (to save at a larger size than\n         * the screen width) when using presets so it's not entirely out of\n         * character for our editor either.\n         */\n        const size = {\n          width: nextSize.width,\n          height: nextSize.height,\n        }\n        /**\n         * It's not, at the moment, strictly necessary to set the size because\n         * the size is set during mouse move; however, I'm keeping this here\n         * as (a) a sanity check to ensure this is always correct and (b) if\n         * we ever decide to modify the size before saving (see the comment\n         * above when setting size) then we don't end up in a bad state. This\n         * is something that already occurred once during experimenting.\n         */\n        setSize(size)\n        Transforms.setNodes(editor, size, { at: path })\n        setIsDragging(false)\n      }\n\n      /**\n       * Attach event listeners directly to document\n       */\n      mouseMoveRef.current = onDocumentMouseMove\n      mouseUpRef.current = onDocumentMouseUp\n      document.addEventListener(\"mousemove\", onDocumentMouseMove)\n      document.addEventListener(\"mouseup\", onDocumentMouseUp)\n    },\n    [srcSize.width, srcSize.height, size.width, element]\n  )\n\n  /**\n   * FIXME:\n   *\n   * This can be refactored so that it shares more code with `onMouseDown`\n   * above. They are nearly identical except:\n   *\n   * - the event listeners that are added/removed\n   * - the way way in which clientX is retrieved\n   */\n  const onTouchStart = useCallback(\n    (e: React.TouchEvent) => {\n      stopEvent(e)\n      setIsDragging(true)\n      const startX = e.changedTouches[0].clientX\n      const startWidth = size.width\n\n      let nextSize = { ...size }\n\n      const onDocumentTouchMove = (te: TouchEvent) => {\n        // stopEvent(te)\n        const e = te.changedTouches[0]\n\n        const nextWidth = minMax({\n          value: startWidth + e.clientX - startX,\n          min: minWidth,\n          max: maxWidth,\n        })\n        nextSize = resizeToWidth(nextWidth, srcSize)\n\n        setSize(nextSize)\n      }\n      const onDocumentTouchEnd = () => {\n        document.removeEventListener(\"touchmove\", onDocumentTouchMove)\n        document.removeEventListener(\"touchend\", onDocumentTouchEnd)\n        touchMoveRef.current = null\n        touchEndRef.current = null\n        const path = ReactEditor.findPath(editor, element)\n        Transforms.setNodes(\n          editor,\n          { width: nextSize.width, height: nextSize.height },\n          { at: path }\n        )\n        setIsDragging(false)\n      }\n\n      touchMoveRef.current = onDocumentTouchMove\n      touchEndRef.current = onDocumentTouchEnd\n      document.addEventListener(\"touchmove\", onDocumentTouchMove)\n      document.addEventListener(\"touchend\", onDocumentTouchEnd)\n    },\n    [srcSize.width, srcSize.height, size.width, element]\n  )\n\n  useEffect(() => {\n    return () => {\n      if (mouseMoveRef.current) {\n        document.removeEventListener(\"mousemove\", mouseMoveRef.current)\n      }\n      if (mouseUpRef.current) {\n        document.removeEventListener(\"mouseup\", mouseUpRef.current)\n      }\n      if (touchMoveRef.current) {\n        document.removeEventListener(\"touchmove\", touchMoveRef.current)\n      }\n      if (touchEndRef.current) {\n        document.removeEventListener(\"touchend\", touchEndRef.current)\n      }\n    }\n  }, [])\n\n  /**\n   * Add special classNames to modify appearance of resize controls\n   */\n  const className = clsx({\n    \"--center\": width < maxWidth && width > minWidth,\n    \"--left\": width >= maxWidth && width > minWidth,\n    \"--right\": width <= minWidth && width < maxWidth,\n    \"--dragging\": isDragging,\n    \"--small\": width <= 64 || size.height <= 64,\n  })\n\n  return (\n    <>\n      {/**\n       * The invisible handle is not visible but gives a larger drag handle\n       * target for the mouse and touch events\n       */}\n      <$ImageResizeInvisibleHandle\n        className={className}\n        onMouseDown={onMouseDown}\n        onTouchStart={onTouchStart}\n      >\n        <$ImageResizeHandle>\n          <span className=\"--bar --bar-left\" />\n          <span className=\"--bar --bar-center\" />\n          <span className=\"--bar --bar-right\" />\n        </$ImageResizeHandle>\n      </$ImageResizeInvisibleHandle>\n    </>\n  )\n}\n","import { useEffect } from \"react\"\n\nimport { useThrottledRefresh } from \"./use-throttled-refresh\"\n\n/**\n * Refreshes the Component whenever the page is resized or the window is\n * scrolled. This is because these are usually the only two events that cause\n * the elements on a page to be repositioned.\n *\n * If there are yet other events that can cause the elements to be repositioned\n * or resized, you can also call the returned `refresh` method. This will\n * update the components while still respected the fact that the updates will\n * be throttled so as not to overload the browser.\n */\nexport function useResizeBrowser() {\n  /**\n   * Create a throttled `refresh` method.\n   */\n  const refresh = useThrottledRefresh()\n\n  /**\n   * refresh on page resize or scroll (throttled)\n   */\n  useEffect(() => {\n    refresh()\n    window.addEventListener(\"resize\", refresh)\n    return () => {\n      window.removeEventListener(\"resize\", refresh)\n    }\n  }, [])\n\n  return refresh\n}\n","import styled from \"@emotion/styled\"\n\nexport const $ImageResizeInvisibleHandle = styled(\"span\")`\n  position: absolute;\n  display: block;\n  /**\n   * Prevent touch dragging from exhibiting a kind of scroll bounce behavior\n   * when we just want the image to resize.\n   */\n  touch-action: none;\n  background: rgba(127, 127, 127, 0.001);\n  top: 0;\n  right: calc(-1em - 2px);\n  width: 2em;\n  bottom: 0;\n  &.--left {\n    cursor: w-resize;\n  }\n  &.--center {\n    cursor: ew-resize;\n  }\n  &.--right {\n    cursor: e-resize;\n  }\n  &.--small {\n    right: calc(-1.25em);\n    /* background: green; */\n    width: 1.25em;\n  }\n`\nexport const $ImageResizeHandle = styled(\"span\")`\n  position: absolute;\n  display: block;\n  background: var(--select-color);\n  top: 50%;\n  margin-top: -1em;\n  width: 1em;\n  height: 2em;\n  outline: 1px solid white;\n  transition: all 250ms;\n  /**\n   * The handle is 3 visible states depending on whether the image is at\n   * maximum size or minimum size.\n   *\n   * There are three indicators that let the user know which directions are\n   * available (left, right or both) that the user can drag:\n   *\n   * - rounded corners on the side that are available to drag towards\n   * - on larger size image, the handle is on the inside, middle or outside\n   *   of the outline\n   * - the cursor pointer indicates the direction available for resizing.\n   */\n  .--center > & {\n    left: 0.5em;\n    border-radius: 0.375em;\n  }\n  .--left > & {\n    border-radius: 0.5em 0 0 0.5em;\n    left: 1px;\n  }\n  .--right > & {\n    border-radius: 0 0.5em 0.5em 0;\n    left: calc(50% - 1px);\n  }\n  .--bar {\n    position: absolute;\n    background: var(--blue-200);\n    width: 1px;\n    top: 0.5em;\n    bottom: 0.5em;\n  }\n  /**\n   * Each of 3 bars is 1px wide and 3px apart\n   */\n  .--bar-left {\n    left: calc(50% - 3.5px);\n  }\n  .--bar-center {\n    left: calc(50% - 0.5px);\n  }\n  .--bar-right {\n    left: calc(50% + 2.5px);\n  }\n  /**\n   * When the image is small, we reduce the size of the handler and place it\n   * outside the image. The reasons we do this:\n   * \n   * - If the handle is not outside the image at small sizes, the handle\n   *   obscures the image too much. At larger sizes, it works okay and the\n   *   inside handle placement makes the available direction of the drags more\n   *   intuitive.\n   *\n   * - Also, at small sizes, a large handle can overwhelm the image. That is,\n   *   the handle can be twice as tall as the image itself which looks poor.\n   *   It's still possible for the handle to be larger than the image at small\n   *   sizes, but this is okay in that we don't want the handle to become so\n   *   small that it is hard to see and hard to click.\n   */\n  .--small > & {\n    /**\n     * We opt to mainly adjust the size of the handle at smaller sizes by\n     * adjusting the font-size. This is more efficient than changing all the\n     * border-sizes because changing the font-size automatically changes the\n     * size of the border, but we don't have to redo the different combinations\n     * border-size and the corner that they need to display on.\n     */\n    font-size: 0.5em;\n    width: 1.5em;\n    left: 0.5em;\n    margin-top: -1em;\n  }\n  /**\n   * Each of 2 bars is 1px wide and 3px apart\n   */\n  .--small > & > .--bar-left {\n    left: calc(50% - 2px);\n  }\n  .--small > & > .--bar-center {\n    display: none;\n  }\n  .--small > & > .--bar-right {\n    left: calc(50% + 1px);\n  }\n`\n","/**\n * A more intuitive of ensuring a value is within a min/max range.\n */\n\nexport function minMax({\n  value,\n  min,\n  max,\n}: {\n  value: number\n  min: number\n  max: number\n}): number {\n  if (!(max >= min)) throw new Error(`Expected max >= min but is not`)\n  return Math.max(min, Math.min(max, value))\n}\n","import { Editor } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { ImageSize, ImageSizePreset } from \"../types\"\n\n/**\n * Takes a src image and resizes it to the exact width while preserving the\n * aspect ratio.\n *\n * NOTE: This is resizing to exact width, and not to inside width.\n */\nexport function resizeToWidth(width: number, srcSize: ImageSize): ImageSize {\n  width = Math.round(width)\n  const aspect = srcSize.width / srcSize.height\n  return { width, height: Math.round(width / aspect) }\n}\n\n/**\n * Takes a src image and resizes it to the exact height while preserving the\n * aspect ratio.\n *\n * NOTE: This is resizing to exact height, and not to inside height.\n */\nexport function resizeToHeight(height: number, srcSize: ImageSize): ImageSize {\n  height = Math.round(height)\n  const aspect = srcSize.width / srcSize.height\n  return { width: Math.round(height * aspect), height }\n}\n\n/**\n * Intuitive way of taking a size and a bounds and shrinking the size within\n * the given bounds if necessary.\n */\nexport function resizeInBounds(size: ImageSize, bounds: ImageSize): ImageSize {\n  const aspect = size.width / size.height\n  const boundsAspect = bounds.width / bounds.height\n  if (aspect >= boundsAspect) {\n    if (size.width > bounds.width) {\n      return resizeToWidth(bounds.width, size)\n    }\n  } else {\n    if (size.height > bounds.height) {\n      return resizeToHeight(bounds.height, size)\n    }\n  }\n  return size\n}\n\n/**\n * Takes an image size and an image resize preset and calculates the size of\n * the image when the preset is applied.\n *\n * Notably, there are two `preset` algorithms.\n *\n * - `bounds` which sets a maximum width/height and we find the maximum image\n *   size that fits within those bounds.\n *\n * - `scale` which multiples the width/height by a given scale. Note that by\n *   convention that scale should be 1 or less.\n */\nexport function resizeInPreset(\n  _size: ImageSize,\n  srcSize: ImageSize,\n  preset: ImageSizePreset\n): ImageSize {\n  switch (preset.type) {\n    case \"bounds\":\n      return resizeInBounds(srcSize, preset)\n    case \"scale\":\n      return {\n        width: Math.round(srcSize.width * preset.scale),\n        height: Math.round(srcSize.height * preset.scale),\n      }\n  }\n}\n\n/**\n * Takes an editor object and returns the maximum width that elements inside of\n * the editor can be rendered at without overflowing.\n *\n * We get the `clientWidth` which is the \"box\" without the border but including\n * the padding. We then subtract the padding to get the value we want.\n */\nexport function getEditorWidth(editor: Editor) {\n  const element = ReactEditor.toDOMNode(editor, editor)\n  const computed = getComputedStyle(element)\n  const padding =\n    parseInt(computed.paddingLeft, 10) + parseInt(computed.paddingRight, 10)\n  return element.clientWidth - padding\n}\n","import styled from \"@emotion/styled\"\n\nexport const $ImageSizeStatus = styled(\"span\")`\n  position: absolute;\n  /**\n   * The status appears with a 1px gap from the outline.\n   *\n   * - 1px for gap from image to outline\n   * - 2px for outline width\n   * - 1px more for the space to the status\n   */\n  bottom: calc(-2em - 4px);\n  left: 0;\n  font-size: 0.625em; /* 10px tiny */\n  line-height: 2em;\n  padding: 0 0.5em;\n  color: var(--shade-100);\n  background: var(--shade-600);\n  outline: 1px solid rgba(255, 255, 255, 0.5);\n  border-radius: 0.5em;\n  white-space: nowrap;\n\n  /* force numbers to be monospaced for better alignment */\n  font-variant-numeric: tabular-nums;\n`\n","import { $ImageSizeStatus } from \"../../../styles/image-with-controls-styles/image-size-status-styles\"\nimport { ImageSize } from \"../../../types\"\n\nexport function ImageSizeStatus({ size }: { size: ImageSize }) {\n  return (\n    <$ImageSizeStatus>\n      {size.width} &times; {size.height}\n    </$ImageSizeStatus>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $ImageToolbar = styled(\"span\")`\n  position: absolute;\n  /**\n   * On top of the image +1 for space inside outline, +2 for outline,\n   * +2 for space outside outline.\n   *\n   * DO NOT MOVE TO BOTTOM:\n   *\n   * This is a reminder not to move the preset to the bottom. Visually, it is\n   * less obtrusive at the bottom; however, an issue is that when switching\n   * between different presets, the preset UI moves up/down making it difficult\n   * to switch between different presets. When kept at the top, the preset\n   * UI doesn't move.\n   */\n  top: calc(-1.5em - 5px);\n  /**\n   * Align left to the outline: +1 for space inside outline, +2 for outline\n   * width\n   */\n  left: -3px;\n  /**\n   * When we're resizing, the controls aren't usable and just add to visual\n   * clutter so we hide it. The transition lets us do it smoothly and less\n   * obtrusively.\n   */\n  transition: opacity 200ms;\n  .--dragging & {\n    opacity: 0;\n  }\n  display: flex;\n  gap: 0.25em;\n`\n","import styled from \"@emotion/styled\"\n\n/**\n * Styling for a collection of buttons in the $ImageButtonsContainer at the top\n * of the image.\n */\nexport const $ImageButtonGroup = styled(\"span\")`\n  /* font-size: 0.75em; */\n  border-radius: 0.5em;\n  display: flex;\n  /**\n   * So that inner Preset design shows within the rounded corners.\n   */\n  overflow: clip;\n  /**\n   * Let's the menu pop a little over other content. Without it, may be able to\n   * see the border of the buttons.\n   */\n  outline: 1px solid white;\n`\n\nexport const $ImageButton = styled(\"span\")`\n  font-size: 0.75em;\n  line-height: 2em;\n  padding: 0 0.625em;\n  &:last-child {\n    border-right: none;\n  }\n  cursor: pointer;\n\n  /**\n   * We don't want it to wrap\n   */\n  white-space: nowrap;\n\n  /**\n   * Preset default colors\n   */\n  color: var(--shade-600);\n  background: var(--shade-200);\n  border-right: 1px solid var(--shade-100);\n  /**\n   * When preset is disabled, it is lighter in color and with elss contrast.\n   */\n  &.--disabled {\n    cursor: default;\n    color: var(--shade-300);\n    background: var(--shade-100);\n    &:hover {\n      color: var(--shade-300);\n      background: var(--shade-100);\n    }\n  }\n  &.--selected {\n    cursor: default;\n    color: var(--blue-700);\n    background: var(--blue-200);\n    &:hover {\n      color: var(--blue-700);\n      background: var(--blue-200);\n    }\n  }\n  /**\n   * On hover, it is dark, and with higher contrast.\n   */\n  &:hover {\n    color: var(--shade-700);\n    background: var(--shade-300);\n  }\n  svg {\n    position: relative;\n    top: 0.25em;\n    font-size: 1.33em;\n    line-height: 1em;\n  }\n`\n","import { clsx } from \"clsx\"\nimport { Dispatch, SetStateAction, useCallback } from \"react\"\nimport { Transforms } from \"slate\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\n\nimport { useTooltip } from \"../../../../../use-tooltip\"\n\nimport { $ImageButton } from \"../../../../styles/image-with-controls-styles/image-buttons-styles\"\nimport {\n  ImageBlockElement,\n  ImageInlineElement,\n  ImageSize,\n  ImageSizePreset,\n} from \"../../../../types\"\nimport { resizeInPreset } from \"../../../../utils\"\n\n/**\n * Shows a single preset image sizes as defined by the `Preset` type.\n *\n * If the srcSize is smaller than the preset, clicking the preset would do\n * nothing except show the image at its full size. For this reason, the\n * preset is disabled if the srcSize is smaller than the preset.\n */\nexport function ImagePresetButton({\n  element,\n  preset,\n  size,\n  setSize,\n  srcSize,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n  preset: ImageSizePreset\n  size: ImageSize\n  setSize: Dispatch<SetStateAction<ImageSize | null>>\n  srcSize: ImageSize\n}) {\n  const editor = useSlateStatic()\n  const presetSize = resizeInPreset(size, srcSize, preset)\n  const tooltip = useTooltip({\n    title: preset.title,\n    hotkey: `${presetSize.width}x${presetSize.height}`,\n  })\n\n  const onClick = useCallback(() => {\n    const path = ReactEditor.findPath(editor, element)\n    const nextSize = resizeInPreset(size, srcSize, preset)\n    setSize(nextSize)\n    Transforms.setNodes(editor, nextSize, { at: path })\n  }, [element, preset, size, srcSize])\n\n  const isEnabled =\n    preset.type === \"scale\"\n      ? true\n      : preset.width <= srcSize.width || preset.height <= srcSize.height\n\n  const isDisabled = !isEnabled\n\n  const isSelected =\n    size.width === presetSize.width && size.height === presetSize.height\n\n  const className = clsx({\n    \"--disabled\": isDisabled,\n    \"--selected\": !isDisabled && isSelected,\n  })\n\n  return (\n    <$ImageButton\n      className={className}\n      onClick={isDisabled ? undefined : onClick}\n      onMouseEnter={tooltip.onMouseEnter}\n      onMouseLeave={tooltip.onMouseLeave}\n    >\n      {preset.name}\n    </$ImageButton>\n  )\n}\n","import { Dispatch, SetStateAction } from \"react\"\n\nimport { $ImageButtonGroup } from \"../../../../styles/image-with-controls-styles/image-buttons-styles\"\nimport {\n  ImageBlockElement,\n  ImageInlineElement,\n  ImageSize,\n  ImageSizePreset,\n} from \"../../../../types\"\nimport { ImagePresetButton } from \"./image-preset-button\"\n\nexport function ImagePresetButtonGroup({\n  element,\n  size,\n  setSize,\n  srcSize,\n  presets,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n  size: ImageSize\n  setSize: Dispatch<SetStateAction<ImageSize | null>>\n\n  srcSize: ImageSize\n  presets: ImageSizePreset[]\n}) {\n  return (\n    <$ImageButtonGroup>\n      {presets.map((preset, i) => {\n        return (\n          <ImagePresetButton\n            element={element}\n            key={i}\n            preset={preset}\n            size={size}\n            setSize={setSize}\n            srcSize={srcSize}\n          />\n        )\n      })}\n    </$ImageButtonGroup>\n  )\n}\n","import { useCallback } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { useTooltip } from \"../../../../../use-tooltip\"\n\nimport { $ImageButton } from \"../../../../styles/image-with-controls-styles/image-buttons-styles\"\nimport { ImageBlockElement, ImageInlineElement } from \"../../../../types\"\nimport { InlineIcon } from \"../../../icons\"\nimport { convertToInlineImage } from \"./convert-to-inline-image\"\n\nexport function BlockImageTypeButton({\n  element,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n}) {\n  const editor = useSlateStatic()\n  const tooltip = useTooltip({\n    title: \"Inline Image\",\n    hotkey: \"In a line with text\",\n  })\n\n  const onClickInline = useCallback(() => {\n    if (element.type !== \"image-block\") return\n    convertToInlineImage(editor, element)\n  }, [editor, element])\n  return (\n    <$ImageButton\n      className={element.type === \"image-inline\" ? \"--selected\" : \"\"}\n      onClick={element.type === \"image-inline\" ? undefined : onClickInline}\n      onMouseEnter={tooltip.onMouseEnter}\n      onMouseLeave={tooltip.onMouseLeave}\n    >\n      <InlineIcon />\n    </$ImageButton>\n  )\n}\n","import { SVGProps } from \"react\"\n\nimport { TablerIcon } from \"../../sink\"\n\nexport const ResizeIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"m7 8-4 4 4 4M17 8l4 4-4 4M3 12h18\" />\n  </TablerIcon>\n)\n\nexport const BlockIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <rect width={6} height={6} x={4} y={5} rx={1} />\n    <path d=\"M4 15h16M4 19h16\" />\n  </TablerIcon>\n)\n\nexport const InlineIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <rect width={6} height={6} x={9} y={5} rx={1} />\n    <path d=\"M4 7h1M4 11h1M19 7h1M19 11h1M4 15h16M4 19h16\" />\n  </TablerIcon>\n)\n","import { Editor, Transforms } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { ImageBlockElement } from \"../../../../types\"\nimport { resizeInPreset } from \"../../../../utils\"\n\nexport function convertToInlineImage(\n  editor: Editor,\n  element: ImageBlockElement\n) {\n  /**\n   * TODO:\n   *\n   * This should be handled or thought about better. Like maybe if these\n   * values don't exist, we still change the type.\n   */\n  if (\n    !element.width ||\n    !element.height ||\n    !element.srcWidth ||\n    !element.srcHeight\n  )\n    return\n  const size = { width: element.width, height: element.height }\n  const srcSize = { width: element.srcWidth, height: element.srcHeight }\n  const path = ReactEditor.findPath(editor, element)\n  Editor.withoutNormalizing(editor, () => {\n    /**\n     * TODO:\n     *\n     * `resizeInPreset` should probably be renamed to something like\n     * `resizeIn` which can be used more generically. Perhaps it takes the\n     * `type`, `width` and `height` as an Interface making it compatible with\n     * a Preset which would extend it.\n     */\n    const nextSize = resizeInPreset(size, srcSize, {\n      name: \"initial-inline-image\",\n      title: \"\",\n      type: \"bounds\",\n      width: 24,\n      height: 24,\n    })\n    Transforms.setNodes(\n      editor,\n      { type: \"image-inline\" as const, ...nextSize },\n      { at: path }\n    )\n    Transforms.wrapNodes(\n      editor,\n      { type: \"paragraph\", children: [] },\n      { at: path }\n    )\n  })\n}\n","import { useCallback } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { useTooltip } from \"../../../../../use-tooltip\"\n\nimport { $ImageButton } from \"../../../../styles/image-with-controls-styles/image-buttons-styles\"\nimport { ImageBlockElement, ImageInlineElement } from \"../../../../types\"\nimport { BlockIcon } from \"../../../icons\"\nimport { convertToBlockImage } from \"./convert-to-block-image\"\n\nexport function InlineImageTypeButton({\n  element,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n}) {\n  const editor = useSlateStatic()\n  const tooltip = useTooltip({\n    title: \"Block Image\",\n    hotkey: \"On a line by itself\",\n  })\n\n  const onClickBlock = useCallback(() => {\n    if (element.type !== \"image-inline\") return\n    convertToBlockImage(editor, element)\n  }, [editor, element])\n\n  return (\n    <$ImageButton\n      className={element.type === \"image-block\" ? \"--selected\" : \"\"}\n      onClick={element.type === \"image-block\" ? undefined : onClickBlock}\n      onMouseEnter={tooltip.onMouseEnter}\n      onMouseLeave={tooltip.onMouseLeave}\n    >\n      <BlockIcon />\n    </$ImageButton>\n  )\n}\n","import { Editor, Element, Text, Transforms } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { findElementUp } from \"../../../../../sink\"\nimport { ImageInlineElement } from \"../../../../types\"\nimport { resizeInPreset } from \"../../../../utils\"\n\nexport function convertToBlockImage(\n  editor: Editor,\n  element: ImageInlineElement\n) {\n  /**\n   * TODO:\n   *\n   * This should be handled or thought about better. Like maybe if these\n   * values don't exist, we still change the type.\n   */\n  if (\n    !element.width ||\n    !element.height ||\n    !element.srcWidth ||\n    !element.srcHeight\n  )\n    return\n  const size = { width: element.width, height: element.height }\n  const srcSize = { width: element.srcWidth, height: element.srcHeight }\n  const path = ReactEditor.findPath(editor, element)\n\n  Editor.withoutNormalizing(editor, () => {\n    /**\n     * TODO:\n     *\n     * `resizeInPreset` should probably be renamed to something like\n     * `resizeIn` which can be used more generically. Perhaps it takes the\n     * `type`, `width` and `height` as an Interface making it compatible with\n     * a Preset which would extend it.\n     */\n    const nextSize = resizeInPreset(size, srcSize, {\n      name: \"initial-block-image\",\n      title: \"\",\n      type: \"bounds\",\n      width: 320,\n      height: 320,\n    })\n    /**\n     * Convert the inline image to a block image.\n     *\n     * When we make this change, it causes the normalization rules to change\n     * from the rules of an inline to the rules of a block. Inlines can only\n     * co-exist with Text and other Inline elments. They must also always be\n     * followed by and preceded by a Text nod.\n     *\n     * Some of the code below help to fix the inconsistencies caused by this\n     * change.\n     */\n    Transforms.setNodes(\n      editor,\n      { type: \"image-block\", ...nextSize },\n      { at: path }\n    )\n    /**\n     * Here we find the enclosing parent block for the inline.\n     *\n     * Note that there should always be a parent block for an inline. If there\n     * isn't, something isn't working properly because the Slate normalization\n     * rules require a block parent to an inline.\n     */\n    const parentEntry = findElementUp(\n      editor,\n      (node) => Element.isElement(node) && Editor.isBlock(editor, node) && node.type !== \"image-block\"\n    )\n    if (!parentEntry) throw new Error(\"This shouldn't happen\")\n    const [parentElement, parentPath] = parentEntry\n    const siblings = parentElement.children\n    const siblingCount = parentElement.children.length\n    const index = path.slice(-1)[0]\n\n    /**\n     * Before we lift the inline node, we want to remove **empty** Text blocks\n     * at the beginning of the block when the inline node is the second item\n     * and at the end of the block when the inline is the second to last item.\n     *\n     * We do this because Slate adds empty text nodes always at the beginning\n     * and end of a line if the node next to it is an inline. This behavior\n     * works fine in most cases, but when we want to lift the inline element\n     * up, Slate sees that there is content next to it and when the element is\n     * lifted up, the block is split into 3 pieces, including a piece with an\n     * empty Text node.\n     *\n     * From a user expectation point of view though, we don't want these extra\n     * blocks inserted. If the inline image is at the end of the line, we want\n     * it converted to a block image with a block of stuff before it. There is\n     * no use for the extra block at the end with no content in it.\n     */\n    /**\n     * Remove the last sibling if it's empty and next to the inline image\n     */\n    const lastSibling = siblings[siblingCount - 1]\n    if (\n      index === siblingCount - 2 &&\n      Text.isText(lastSibling) &&\n      lastSibling.text === \"\"\n    ) {\n      Transforms.removeNodes(editor, {\n        at: [...parentPath, siblingCount - 1],\n      })\n    }\n    /**\n     * Remove the first sibling if it's empty and next to the inline image\n     */\n    const firstSibling = siblings[0]\n    const removeFirstSibling =\n      index === 1 && Text.isText(firstSibling) && firstSibling.text === \"\"\n    if (removeFirstSibling) {\n      Transforms.removeNodes(editor, { at: [...parentPath, 0] })\n    }\n    /**\n     * Now lift the node, but if the first sibling was removed, we need to account fo rthe fact that the index of the image changed.\n     */\n    Transforms.liftNodes(editor, {\n      at: [...parentPath, removeFirstSibling ? index - 1 : index],\n    })\n  })\n}\n","import { $ImageButtonGroup } from \"../../../../styles/image-with-controls-styles/image-buttons-styles\"\nimport { ImageBlockElement, ImageInlineElement } from \"../../../../types\"\nimport { BlockImageTypeButton } from \"./block-image-type-button\"\nimport { InlineImageTypeButton } from \"./inline-image-type-button\"\n\nexport function ImageTypeButtonGroup({\n  element,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n}) {\n  return (\n    <$ImageButtonGroup>\n      <InlineImageTypeButton element={element} />\n      <BlockImageTypeButton element={element} />\n    </$ImageButtonGroup>\n  )\n}\n","import { Dispatch, SetStateAction } from \"react\"\n\nimport { $ImageToolbar } from \"../../../styles/image-with-controls-styles/image-toolbar-styles\"\nimport {\n  ImageBlockElement,\n  ImageInlineElement,\n  ImageSize,\n  ImageSizePreset,\n} from \"../../../types\"\nimport { ImagePresetButtonGroup } from \"./image-preset-buttons/image-preset-button-group\"\nimport { ImageTypeButtonGroup } from \"./image-type-buttons/image-type-button-group\"\n\n/**\n * The ImageToolbar appears above an image when the image is selected.\n *\n * It includes:\n *\n * - A set of image resize presets when clicked resizes the image to the preset\n * - Buttons to toggle between a block image and an inline image\n */\nexport function ImageToolbar({\n  element,\n  size,\n  setSize,\n  srcSize,\n  presets,\n}: {\n  element: ImageBlockElement | ImageInlineElement\n  size: ImageSize\n  setSize: Dispatch<SetStateAction<ImageSize | null>>\n  srcSize: ImageSize\n  presets: ImageSizePreset[]\n}) {\n  return (\n    <$ImageToolbar>\n      <ImageTypeButtonGroup element={element} />\n      <ImagePresetButtonGroup\n        element={element}\n        size={size}\n        setSize={setSize}\n        srcSize={srcSize}\n        presets={presets}\n      />\n    </$ImageToolbar>\n  )\n}\n","import { useSlateStatic } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { $ImageInline } from \"../styles/image-inline-styles\"\nimport { ImageInlineElement } from \"../types\"\nimport { ImageWithControls } from \"./image-with-controls\"\n\nexport function ImageInline({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<ImageInlineElement>) {\n  const editor = useSlateStatic()\n  return (\n    <span {...attributes} style={{ display: \"inline-block\" }}>\n      <$ImageInline contentEditable={false}>\n        <ImageWithControls\n          element={element}\n          presets={editor.image.imageInlinePresets}\n        />\n      </$ImageInline>\n      {children}\n    </span>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $ImageInline = styled(\"span\")`\n  display: inline;\n`\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { ImageBlockElement, ImageInlineElement } from \"../types\"\nimport { ImageBlock } from \"./image-block\"\nimport { ImageInline } from \"./image-inline\"\n\nexport function renderElement({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<ImageBlockElement | ImageInlineElement>) {\n  switch (element.type) {\n    case \"image-block\":\n      return (\n        <ImageBlock element={element} attributes={attributes}>\n          {children}\n        </ImageBlock>\n      )\n    case \"image-inline\":\n      return (\n        <ImageInline element={element} attributes={attributes}>\n          {children}\n        </ImageInline>\n      )\n  }\n}\n","import { Descendant, Editor, Element, Node, Transforms } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createPlugin,\n  normalizeSiblings,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { $BlockQuote } from \"./styles\"\n\nexport type BlockQuoteEditor = {\n  supportsBlockQuote: true\n  blockQuotePlugin: {\n    indent: () => void\n    outdent: () => void\n    isActive: () => boolean\n    increaseDepth: () => void\n    decreaseDepth: () => void\n    canIncreaseDepth: () => boolean\n    canDecreaseDepth: () => boolean\n  }\n}\n\nexport type BlockQuoteElement = {\n  type: \"block-quote\"\n  children: Descendant[]\n}\n\nexport type BlockQuotePluginCustomTypes = {\n  Name: \"block-quote\"\n  Editor: BlockQuoteEditor\n  Element: BlockQuoteElement\n}\n\nfunction matchBlockQuoteSafe(node: Node) {\n  return (\n    Element.isElement(node) &&\n    /**\n     * TODO:\n     *\n     * This is probably:\n     * Element.isElement(node) && !Element.isInline(node) &&\n     * !Element.isDependant(node)\n     */\n    (node.type === \"paragraph\" ||\n      node.type === \"code-block\" ||\n      node.type === \"table\" ||\n      node.type === \"horizontal-rule\" ||\n      node.type === \"task-list-item\" ||\n      node.type === \"unordered-list-item\" ||\n      node.type === \"ordered-list-item\" ||\n      node.type === \"heading\")\n  )\n}\n\nconst MAX_DEPTH = 2\n\nexport const BlockQuotePlugin = createPlugin<BlockQuotePluginCustomTypes>(\n  (editor) => {\n    editor.supportsBlockQuote = true\n    editor.blockQuotePlugin = {\n      indent: () => {\n        Transforms.wrapNodes(\n          editor,\n          { type: \"block-quote\", children: [] },\n          { match: matchBlockQuoteSafe }\n        )\n      },\n      outdent: () => {\n        Transforms.liftNodes(editor, {\n          match: (node, path) => matchBlockQuoteSafe(node) && path.length > 1,\n        })\n      },\n      isActive: () => {\n        const [match] = Editor.nodes(editor, {\n          match: (n: Node) => Element.isElement(n) && n.type === \"block-quote\",\n        })\n        return !!match\n      },\n      increaseDepth: () => {\n        // Find the current block-quote\n        const [match] = Editor.nodes(editor, {\n          match: (n: Node) => Element.isElement(n) && n.type === \"block-quote\",\n        })\n\n        if (!match) return\n\n        // Check if we're already at max depth\n        if (!editor.blockQuotePlugin.canIncreaseDepth()) return\n\n        const [, path] = match\n\n        // Select all content inside the block-quote\n        Transforms.select(editor, path)\n\n        // Create a new block-quote wrapping the selected content\n        Transforms.wrapNodes(\n          editor,\n          { type: \"block-quote\", children: [] },\n          { at: path, split: false }\n        )\n      },\n      decreaseDepth: () => {\n        // Find the current block-quote\n        const [match] = Editor.nodes(editor, {\n          match: (n: Node) => Element.isElement(n) && n.type === \"block-quote\",\n        })\n\n        if (!match) return\n\n        // Check if we can decrease depth\n        if (!editor.blockQuotePlugin.canDecreaseDepth()) return\n\n        const [node, path] = match\n\n        // Get the children of the block-quote\n        const children = (node as Element).children\n\n        // Check if the first child is a block-quote\n        if (\n          children.length === 1 &&\n          Element.isElement(children[0]) &&\n          children[0].type === \"block-quote\"\n        ) {\n          // Unwrap the nested block-quote\n          Transforms.unwrapNodes(editor, {\n            at: [...path, 0], // Path to the nested block-quote\n            match: (n) => Element.isElement(n) && n.type === \"block-quote\",\n          })\n        }\n      },\n      canIncreaseDepth: () => {\n        // Find the current block-quote\n        const [match] = Editor.nodes(editor, {\n          match: (n: Node) => Element.isElement(n) && n.type === \"block-quote\",\n        })\n\n        if (!match) return false\n\n        const [node] = match\n\n        // Calculate the current depth\n        let depth = 0\n        let current = node\n\n        while (\n          (current as Element).children.length === 1 &&\n          Element.isElement((current as Element).children[0]) &&\n          ((current as Element).children[0] as Element).type === \"block-quote\"\n        ) {\n          depth++\n          current = (current as Element).children[0]\n        }\n\n        return depth < MAX_DEPTH\n      },\n      canDecreaseDepth: () => {\n        // Find the current block-quote\n        const [match] = Editor.nodes(editor, {\n          match: (n: Node) => Element.isElement(n) && n.type === \"block-quote\",\n        })\n\n        if (!match) return false\n\n        const [node] = match\n\n        // Check if the first child is a block-quote\n        return (\n          (node as Element).children.length === 1 &&\n          Element.isElement((node as Element).children[0]) &&\n          (node as Element).children[0] &&\n          ((node as Element).children[0] as Element).type === \"block-quote\"\n        )\n      },\n    }\n    return {\n      name: \"block-quote\",\n      editor: {\n        normalizeNode(entry) {\n          const [node, path] = entry\n          if (!Element.isElement(node)) return false\n          if (node.type !== \"block-quote\") return false\n          return normalizeSiblings<Element>(editor, [node, path], (a, b) => {\n            if (\n              Element.isElement(a[0]) &&\n              Element.isElement(b[0]) &&\n              a[0].type === \"block-quote\" &&\n              b[0].type === \"block-quote\"\n            ) {\n              Transforms.mergeNodes(editor, { at: b[1] })\n            }\n            return true\n          })\n        },\n      },\n      editableProps: {\n        renderElement: ({ element, attributes, children }) => {\n          if (element.type === \"block-quote\") {\n            return <$BlockQuote {...attributes}>{children}</$BlockQuote>\n          }\n        },\n        onKeyDown: createHotkeyHandler({\n          \"super+.\": editor.blockQuotePlugin.indent,\n          \"super+,\": editor.blockQuotePlugin.outdent,\n        }),\n      },\n    }\n  }\n) as TypedPlugin<BlockQuotePluginCustomTypes>\n","import styled from \"@emotion/styled\"\n\nexport const $BlockQuote = styled(\"blockquote\")`\n  position: relative;\n  margin-top: 1em;\n  margin-bottom: 1em;\n  margin-left: 0;\n  border-left: 0.25em solid rgba(0, 0, 0, 0.075);\n  padding-left: 1.5em;\n`\n","import { Editor, Element, Transforms } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createPlugin,\n  curryOne,\n  findElementUp,\n  isCollapsed,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { decorate } from \"./decorate\"\nimport { createCodeBlockMethods } from \"./methods\"\nimport { tokenStyles } from \"./prism-theme\"\nimport { CodeBlockPluginCustomTypes } from \"./types\"\nexport * from \"./decorate\"\nexport * from \"./types\"\n\nimport { normalizeNode } from \"./normalizeNode\"\nimport { renderElement } from \"./render-element\"\n\nexport const CodeBlockPlugin = createPlugin<CodeBlockPluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    editor.codeBlock = createCodeBlockMethods(editor)\n\n    function onDelete(): boolean {\n      const { selection } = editor\n      if (!isCollapsed(selection)) return false\n      const codeBlockEntry = findElementUp(editor, \"code-block\")\n      if (codeBlockEntry == null) return false\n      const codeBlockText = Editor.string(editor, codeBlockEntry[1])\n      if (codeBlockText === \"\") {\n        Transforms.removeNodes(editor, { at: codeBlockEntry[1] })\n        return true\n      }\n      return false\n    }\n\n    return createPolicy({\n      name: \"code-block\",\n      editor: {\n        deleteBackward: onDelete,\n        deleteForward: onDelete,\n        isInline(element) {\n          if (\n            element.type === \"code-block\" ||\n            element.type === \"code-block-line\"\n          )\n            return false\n        },\n        isVoid(element) {\n          if (\n            element.type === \"code-block\" ||\n            element.type === \"code-block-line\"\n          )\n            return false\n        },\n        isMaster(element) {\n          if (element.type === \"code-block\") return true\n        },\n        normalizeNode: curryOne(normalizeNode, editor),\n      },\n      editableProps: {\n        decorate,\n        onKeyDown: createHotkeyHandler({\n          \"super+`\": () =>\n            editor.codeBlock.createCodeBlock({ language: \"text\" }),\n          \"mod+a\": () => {\n            /**\n             * When selection is in code-block and the user pressed mod+a,\n             * select the code-block instead of the full document.\n             */\n            const entry = findElementUp(\n              editor,\n              (el) => Element.isElement(el) && el.type === \"code-block\"\n            )\n            if (!entry) return false\n            Transforms.select(editor, entry[1])\n            return true\n          },\n        }),\n        renderElement,\n        renderLeaf: ({ leaf, children }) => {\n          const style = leaf.prismToken\n            ? tokenStyles[leaf.prismToken] || null\n            : null\n          if (style === null) {\n            return <>{children}</>\n          } else {\n            return <span style={style}>{children}</span>\n          }\n        },\n      },\n    })\n  }\n) as TypedPlugin<CodeBlockPluginCustomTypes>\n","import Prism from \"prismjs\"\nconst { languages, tokenize } = Prism\nimport { Element, Node, Path, Range } from \"slate\"\n\nimport { CodeBlockElement, CodeBlockLineElement } from \"./types\"\n\n/**\n * Decorate Overview:\n *\n * We decorate the entire `code-block` at once because if we do it by line,\n * code that continues through multiple lines is not higlighted correctly.\n *\n * In order to higlight the entire `code-block` at once, we need to add a\n * newline to the end of each `code-line`. We cannot use `Node.string` on the\n * entire `code-block`.\n *\n * Once we receive the Prism tokens back, we need to create the ranges.\n *\n * The important part is that we track the offsets from the start. With the\n * offsets, we need to map those back to a `path` and `offset` of each\n * `code-line`. We also need to take into consideration that we have added\n * newlines to the end of each line so the algorithm needs to account for that.\n */\n\n/**\n * Takes an array of text lines and returns an array with the offset\n * in characters of the start of each line.\n */\n\nfunction getLineOffsets(lines: string[]) {\n  let offset = 0\n  const lineOffsets: number[] = []\n  for (const line of lines) {\n    lineOffsets.push(offset)\n    offset = offset + line.length\n  }\n  return lineOffsets\n}\n\n/**\n * `decorate` method passed to `Editable`\n */\n\nexport function decorate(\n  nodeEntry: [CodeBlockElement | CodeBlockLineElement, Path]\n): Range[] {\n  const [node, path] = nodeEntry\n\n  if (!Element.isElement(node)) return []\n  if (node.type !== \"code-block\") return []\n\n  const lang: Prism.Grammar | undefined = languages[node.language]\n\n  if (lang === undefined) return []\n\n  /**\n   * To decorate a code-block, we need to look at all the code in a code-block.\n   *\n   * We can't `Node.string` the entire block because it will join lines\n   * together without newlines.\n   *\n   * For this reason, we create an array of `textLines` which is the text of\n   * each codeLine plus a newline on the end of it.\n   *\n   * Then we join all of those together to get the text that was pass into\n   * Prism.\n   *\n   * We need to keep `textLines` around so that we can extract the\n   * `linePositions`\n   */\n\n  const codeLineElements = node.children\n\n  const textLines = codeLineElements.map((node) => `${Node.string(node)}\\n`)\n\n  const text = textLines.join(\"\")\n\n  const lineOffsets: number[] = getLineOffsets(textLines)\n\n  /**\n   * Takes a character offset from the beginning of the `code-block` and\n   * returns the `path` to the `code-line` and the `offset` within the\n   * `code-line` which Slate needs to make the decoration.\n   */\n\n  function getPointFromOffset(offset: number) {\n    for (let i = lineOffsets.length - 1; i >= 0; i--) {\n      const lineOffset = lineOffsets[i]\n      if (lineOffset <= offset) {\n        return {\n          path: [...path, i],\n          offset: offset - lineOffset,\n        }\n      }\n    }\n    throw new Error(\"This shouldn't happen and indicates a bug in the logic\")\n  }\n\n  const ranges: (Range & { prismToken: string })[] = []\n\n  const tokens = tokenize(text, lang)\n\n  /**\n   * Track current character offset from beginning of `textLines` joined\n   * together.\n   */\n\n  let offset = 0\n\n  /**\n   * Tokens are either:\n   *\n   * - string: which means it is not syntax highlighted\n   * - { type: string, content: string, length: number }: the highlight and content\n   */\n  for (const token of tokens) {\n    if (typeof token === \"string\") {\n      offset += token.length\n    } else {\n      const anchor = getPointFromOffset(offset)\n      const focus = getPointFromOffset(offset + token.length)\n      ranges.push({\n        anchor,\n        focus,\n        prismToken: token.type,\n      })\n      offset += token.length\n    }\n  }\n\n  return ranges\n}\n","import { Editor } from \"slate\"\n\nimport { insertRootElement } from \"../../sink\"\n\nimport { BuiltInLanguage } from \"../types\"\n\nexport function createCodeBlock(\n  editor: Editor,\n  { language }: { language: BuiltInLanguage }\n) {\n  insertRootElement(editor, {\n    type: \"code-block\",\n    language,\n    children: [{ type: \"code-block-line\", children: [{ text: \"\" }] }],\n  })\n}\n","import { Editor, Element, Transforms } from \"slate\"\n\nimport { BetterAt, findElementUp } from \"../../sink\"\n\nimport { BuiltInLanguage } from \"../types\"\n\n/**\n * Set the current CodeBlock's language if the selection is currently in a\n * CodeBlock. Returns true if the language was set, false otherwise.\n */\nexport function setCodeBlockLanguage(\n  editor: Editor,\n  language: BuiltInLanguage,\n  options: { at?: BetterAt } = {}\n): boolean {\n  const entry = findElementUp(\n    editor,\n    (el) => Element.isElement(el) && el.type === \"code-block\",\n    { at: options.at }\n  )\n  if (!entry) return false\n  Transforms.setNodes(editor, { language }, { at: entry[1] })\n  return true\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { createCodeBlock } from \"./createCodeBlock\"\nimport { setCodeBlockLanguage } from \"./setCodeBlockLanguage\"\n\nexport function createCodeBlockMethods(editor: Editor) {\n  return {\n    createCodeBlock: curryOne(createCodeBlock, editor),\n    setCodeBlockLanguage: curryOne(setCodeBlockLanguage, editor),\n  }\n}\n","/**\n * Styles from\n * https://github.com/PrismJS/prism-themes/blob/master/themes/prism-ghcolors.css\n */\n\nimport { CSSProperties } from \"react\"\n\nconst commentStyle = { color: \"#999988\", fontStyle: \"italic\" }\nconst dimStyle = { opacity: \"0.7\" }\nconst stringStyle = { color: \"#e3116c\" }\nconst operatorStyle = { color: \"#393a34\" }\nconst valueStyle = { color: \"#36acaa\" }\nconst keywordStyle = { color: \"#00a4db\" }\nconst functionStyle = { color: \"#9a050f\" }\nconst tagStyle = { color: \"#00009f\" }\nconst boldStyle = { fontWeight: \"bold\" }\nconst italicStyle = { fontStyle: \"italic\" }\n\ntype TokenStyles = Record<string, CSSProperties>\n\nexport const tokenStyles: TokenStyles = {\n  comment: commentStyle,\n  prolog: commentStyle,\n  doctype: commentStyle,\n  cdata: commentStyle,\n  namespace: dimStyle,\n  string: stringStyle,\n  \"attr-value\": stringStyle,\n  puncutation: operatorStyle,\n  operator: operatorStyle,\n  entity: valueStyle,\n  url: valueStyle,\n  symbol: valueStyle,\n  number: valueStyle,\n  boolean: valueStyle,\n  variable: valueStyle,\n  constant: valueStyle,\n  property: valueStyle,\n  regex: valueStyle,\n  insert: valueStyle,\n  atrule: keywordStyle,\n  keyword: keywordStyle,\n  \"attr-name\": keywordStyle,\n  function: { ...functionStyle, ...boldStyle },\n  delete: functionStyle,\n  tag: tagStyle,\n  selector: tagStyle,\n  important: boldStyle,\n  bold: boldStyle,\n  italic: italicStyle,\n}\n","import { Text } from \"slate\"\n\nimport { createCodeBlockMethods } from \"./methods\"\n\ntype CodeBlockMethods = ReturnType<typeof createCodeBlockMethods>\n\nexport type BuiltInLanguage =\n  | \"text\"\n  | \"html\"\n  | \"svg\"\n  | \"markup\"\n  | \"css\"\n  | \"javascript\"\n  | \"js\"\n  | \"java\"\n  | \"c\"\n  | \"clike\"\n\n/**\n * Maps a number of supported or semi-supported syntax highlighting languages\n * to the built-in Prism languages.\n */\nexport const LanguageMap: Record<string, BuiltInLanguage> = {\n  plain: \"text\",\n  plaintext: \"text\",\n  text: \"text\",\n  txt: \"text\",\n  html: \"markup\",\n  mathml: \"markup\",\n  svg: \"markup\",\n  xml: \"markup\",\n  ssml: \"markup\",\n  atom: \"markup\",\n  rss: \"markup\",\n  css: \"css\",\n  c: \"clike\",\n  clike: \"clike\",\n  \"c#\": \"clike\",\n  \"c++\": \"clike\",\n  java: \"clike\",\n  javascript: \"javascript\",\n  js: \"javascript\",\n}\n\nexport const LanguageCaptionMap: Record<string, string> = {\n  javascript: \"Javascript\",\n  js: \"Javascript\",\n}\n\nexport const LanguageList: BuiltInLanguage[] = [\n  \"text\",\n  \"html\",\n  \"css\",\n  \"svg\",\n  \"javascript\",\n  \"java\",\n  \"c\",\n]\n\nexport type CodeBlockEditor = {\n  codeBlock: CodeBlockMethods\n}\n\n/**\n * The code block element is the root element of a code block.\n */\nexport type CodeBlockElement = {\n  type: \"code-block\"\n  /**\n   * The language of the code block. Can accept any string because Markdown can\n   * accept any string; however, the built-in Prism languages are defined in:\n   * `BuiltInLanguage`\n   */\n  language: string\n  children: CodeBlockLineElement[]\n}\n\nexport type CodeBlockLineElement = {\n  type: \"code-block-line\"\n  children: Text[]\n}\n\nexport type CodeBlockPluginCustomTypes = {\n  Name: \"code-block\"\n  Editor: CodeBlockEditor\n  Element: CodeBlockElement | CodeBlockLineElement\n  Text: { text: string; prismToken?: string }\n}\n","import { Editor, Element, Node, NodeEntry, Transforms } from \"slate\"\n\nexport function normalizeNode(editor: Editor, entry: NodeEntry<Node>): boolean {\n  if (!Element.isElement(entry[0])) return false\n  /**\n   * Code lines should only contain plain text.\n   *\n   * - If they contain void elements like images, remove them\n   * - If they contain non-void elements, unwrap them\n   *\n   * TODO:\n   *\n   * Convert pasted in elements to Markdown code\n   */\n  if (entry[0].type === \"code-block-line\") {\n    for (const [child, path] of Node.children(editor, entry[1])) {\n      if (!Element.isElement(child)) continue\n      if (editor.isVoid(child)) {\n        Transforms.removeNodes(editor, { at: path })\n        return true\n      } else {\n        Transforms.unwrapNodes(editor, { at: path })\n        return true\n      }\n    }\n  }\n  /**\n   * Code blocks should only contain code lines.\n   *\n   * - If they contain void blocks like images, remove them\n   * - If they contain non-void blocks, then convert them to code lines\n   *\n   * TODO:\n   *\n   * Convert pasted in elements to Markdown code\n   */\n  if (entry[0].type === \"code-block\") {\n    for (const [child, path] of Node.children(editor, entry[1])) {\n      if (!Element.isElement(child)) continue\n      if (child.type === \"code-block-line\") continue\n      if (child.type === \"code-block\") {\n        /**\n         * When pasting two or more lines of `code-block-line`, Slate will paste\n         * it as a `code-block` which will create a `code-block` in a\n         * `code-block`. The following code removes the lower `code-block`.\n         */\n        Transforms.unwrapNodes(editor, { at: path })\n        return true\n      } else if (editor.isVoid(child)) {\n        Transforms.removeNodes(editor, { at: path })\n        return true\n      } else {\n        Transforms.removeNodes(editor, { at: path })\n        Transforms.insertNodes(editor, {\n          type: \"code-block-line\",\n          children: [{ text: Node.string(child) }],\n        })\n        return true\n      }\n    }\n  }\n  return false\n}\n","import { useCallback, useRef } from \"react\"\nimport { useSelected } from \"slate-react\"\n\nimport { Menu, MenuItemData } from \"../../shared-overlays\"\nimport { ConstrainedRenderElementProps } from \"../../sink\"\nimport { useLayer } from \"../../use-layer\"\nimport { ChevronDownIcon } from \"../icons/ChevronDownIcon\"\nimport { $CodeBlock, $CodeBlockLanguage, $CodeBlockScroller } from \"../styles\"\nimport { CodeBlockElement, LanguageList } from \"../types\"\n\nexport function CodeBlock({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<CodeBlockElement>) {\n  const ref = useRef<HTMLDivElement>(null)\n  const selected = useSelected()\n  const dropdown = useLayer(\"code-block-dropdown\")\n  const onClick = useCallback(() => {\n    if (dropdown.layer) dropdown.close()\n    const dest = ref.current\n    if (dest === null) return\n    const items: MenuItemData[] = LanguageList.map((language) => {\n      return {\n        icon: () => <span />,\n        title: language,\n        action: (editor) => {\n          editor.codeBlock.setCodeBlockLanguage(language, { at: element })\n        },\n      }\n    })\n    // Menu\n    dropdown.open(() => (\n      <Menu dest={dest} items={items} close={dropdown.close} />\n    ))\n  }, [element])\n\n  return (\n    <$CodeBlock className={selected ? \"--selected\" : \"\"} {...attributes}>\n      <$CodeBlockLanguage contentEditable={false} onClick={onClick} ref={ref}>\n        <span>{element.language}</span>\n        <ChevronDownIcon />\n      </$CodeBlockLanguage>\n      <$CodeBlockScroller>{children}</$CodeBlockScroller>\n    </$CodeBlock>\n  )\n}\n","import { SVGProps } from \"react\"\n\nimport { TablerIcon } from \"../../sink\"\n\nexport const ChevronDownIcon = (props: SVGProps<SVGSVGElement>) => (\n  <TablerIcon {...props}>\n    <path d=\"m6 9 6 6 6-6\" />\n  </TablerIcon>\n)\n","import styled from \"@emotion/styled\"\n\nexport const $CodeBlock = styled(\"div\")`\n  position: relative;\n  background: var(--code-block-bgcolor);\n  margin: 1em 0;\n  border-radius: 0.5em;\n  border: 1px solid var(--code-block-border-color);\n  /**\n   * DO NOT REMOVE: Code for adding line numbering if enabled. See $CodeBlockLine\n  * for more details.\n   * counter-reset: line;\n   */\n  &.--selected {\n    outline: 2px solid var(--select-color);\n  }\n  /**\n   * NOTE: Required to make the border radius work on the first and last lines.\n   * Otherwise they will be square.\n   */\n  overflow-x: hidden;\n`\n\nexport const $CodeBlockScroller = styled(\"div\")`\n  padding: 2.25em 1em 1.5em 1em;\n  border-radius: 0.5em;\n  overflow-x: auto;\n`\n\nexport const $CodeBlockLanguage = styled(\"span\")`\n  cursor: pointer;\n  position: absolute;\n  top: 0.25em;\n  right: 0.25em;\n  width: 8em;\n  display: flex;\n  font-size: 0.75em;\n  color: var(--shade-700);\n  background: var(--shade-200);\n  padding: 0.25em 0.5em;\n  border-radius: 0.5em;\n  align-items: center;\n  gap: 0.25em;\n  span {\n    text-align: right;\n    flex: 1 1 auto;\n  }\n  svg {\n    flex: 0 0 auto;\n    position: relative;\n  }\n  &:hover {\n    color: var(--shade-800);\n    background: var(--shade-300);\n  }\n`\n\nexport const $CodeBlockLine = styled(\"div\")`\n  white-space: pre;\n  line-height: 1.5em;\n  counter-increment: line;\n  font-family: \"andale mono\", AndaleMono, monospace;\n  font-size: 0.875em;\n  &.--selected {\n    background-color: var(--shade-100);\n  }\n  /*\n    DO NOT REMOVE: Code for adding line numbering.\n    TODO: Make optional in future.\n    */\n  /* &:before {\n    content: counter(line);\n    color: rgba(0, 0, 0, 0.25);\n    border-right: 1px solid rgba(0, 0, 0, 0.05);\n    margin-right: 1em;\n    padding: 0em 1em 0 0;\n    text-align: right;\n    display: inline-block;\n    width: 2em;\n  } */\n`\n","import { useSelected } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\nimport { $CodeBlockLine } from \"../styles\"\nimport { CodeBlockLineElement } from \"../types\"\n\nexport function CodeBlockLine({\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<CodeBlockLineElement>) {\n  const selected = useSelected()\n  return (\n    <$CodeBlockLine\n      className={selected ? \"--selected\" : \"\"}\n      {...attributes}\n      spellCheck=\"false\"\n    >\n      {children}\n    </$CodeBlockLine>\n  )\n}\n","import { ConstrainedRenderElementProps } from \"../../sink\"\nimport { CodeBlockElement, CodeBlockLineElement } from \"../types\"\nimport { CodeBlock } from \"./CodeBlock\"\nimport { CodeBlockLine } from \"./CodeBlockLine\"\n\nexport function renderElement({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<CodeBlockElement | CodeBlockLineElement>) {\n  if (element.type === \"code-block\") {\n    return (\n      <CodeBlock element={element} attributes={attributes}>\n        {children}\n      </CodeBlock>\n    )\n  } else if (element.type === \"code-block-line\") {\n    return (\n      <CodeBlockLine element={element} attributes={attributes}>\n        {children}\n      </CodeBlockLine>\n    )\n  }\n}\n","import { Transforms } from \"slate\"\n\nimport { createPlugin, findElementUp, isCollapsed, TypedPlugin } from \"../sink\"\n\nimport { HtmlBlockPluginCustomTypes } from \"./types\"\nimport { HtmlBlock } from \"./render-element\"\nexport * from \"./types\"\n\nexport const HtmlBlockPlugin = createPlugin<HtmlBlockPluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    function onDelete(): boolean {\n      const { selection } = editor\n      if (!isCollapsed(selection)) return false\n      const htmlBlockEntry = findElementUp(editor, \"html-block\")\n      if (htmlBlockEntry == null) return false\n      Transforms.removeNodes(editor, { at: htmlBlockEntry[1] })\n      return true\n    }\n\n    return createPolicy({\n      name: \"html-block\",\n      editor: {\n        deleteBackward: onDelete,\n        deleteForward: onDelete,\n        isInline(element) {\n          if (element.type === \"html-block\") return false\n        },\n        isVoid(element) {\n          if (element.type === \"html-block\") return true\n        },\n        isMaster(element) {\n          if (element.type === \"html-block\") return true\n        },\n      },\n      editableProps: {\n        renderElement: ({ element, attributes, children }) => {\n          if (element.type === \"html-block\") {\n            return (\n              <HtmlBlock element={element} attributes={attributes}>\n                {children}\n              </HtmlBlock>\n            )\n          }\n        },\n      },\n    })\n  }\n) as TypedPlugin<HtmlBlockPluginCustomTypes>\n","import styled from \"@emotion/styled\"\n\nexport const $HtmlBlock = styled(\"div\")`\n  position: relative;\n  background-color: var(--shade-100);\n  border: 1px solid var(--shade-300);\n  border-radius: 0.5em;\n  padding: 2em 1em 1em 1em;\n  margin: 1em 0;\n  font-family: \"andale mono\", AndaleMono, monospace;\n  font-size: 0.875em;\n  line-height: 1.5;\n  white-space: pre-wrap;\n  word-break: break-word;\n  color: var(--shade-700);\n  overflow-x: auto;\n\n  &.--selected {\n    outline: 2px solid var(--select-color);\n  }\n`\n\nexport const $HtmlBlockLabel = styled(\"span\")`\n  position: absolute;\n  top: 0.25em;\n  right: 0.5em;\n  font-size: 0.625em;\n  color: var(--shade-500);\n  text-transform: uppercase;\n  letter-spacing: 0.5px;\n`\n","import { RenderElementProps } from \"slate-react\"\nimport { HtmlBlockElement } from \"./types\"\nimport { $HtmlBlock, $HtmlBlockLabel } from \"./styles\"\nimport { unescapeUrlSlashes } from \"../convert/utils\"\n\ntype HtmlBlockRenderElementProps = RenderElementProps & {\n  element: HtmlBlockElement\n}\n\nexport function HtmlBlock({\n  attributes,\n  children,\n  element,\n}: HtmlBlockRenderElementProps) {\n  return (\n    <$HtmlBlock {...attributes} contentEditable={false}>\n      <$HtmlBlockLabel>HTML</$HtmlBlockLabel>\n      <div>{unescapeUrlSlashes(element.html)}</div>\n      {children}\n    </$HtmlBlock>\n  )\n}\n","import { Editor, Element, Node, NodeEntry } from \"slate\"\n\nimport { normalizeSiblingParagraphs } from \"./normalize-sibling-paragraphs\"\nimport { normalizeSiblingWalls } from \"./normalize-sibling-walls\"\n\nexport function normalizeNode(editor: Editor, entry: NodeEntry<Node>): boolean {\n  const [node, path] = entry\n  if (!Element.isElement(node)) return false\n  if (normalizeSiblingWalls(editor, [node, path])) return true\n  if (normalizeSiblingParagraphs(editor, [node, path])) return true\n  return false\n}\n","import { Editor, Element, NodeEntry, Transforms } from \"slate\"\n\nimport { normalizeSiblings } from \"../../sink\"\n\nimport { ParagraphElement } from \"..\"\n\nfunction isParagraph(node: Element): node is ParagraphElement {\n  return Element.isElement(node) && node.type === \"paragraph\"\n}\n/**\n * If there are two sibling paragraphs next to each other and they are both\n * marked as `__collapsible`, this indicates to us that some kind of wall\n * Element was removed.\n *\n * These two collapsible paragraphs should then be merged into one.\n */\nexport function normalizeSiblingParagraphs(\n  editor: Editor,\n  entry: NodeEntry<Element>\n): boolean {\n  return normalizeSiblings(editor, entry, (a, b) => {\n    if (!isParagraph(a[0]) || !isParagraph(b[0])) return false\n    if (a[0].__collapsible && b[0].__collapsible) {\n      Transforms.removeNodes(editor, { at: a[1] })\n      return true\n    }\n    return false\n  })\n}\n","import { Editor, Element, Node, NodeEntry, Transforms } from \"slate\"\n\nimport { normalizeSiblings } from \"../../sink\"\n\nfunction isWall(editor: Editor, node: Node) {\n  if (!Element.isElement(node)) return false\n  return editor.isVoid(node) || editor.isMaster(node)\n}\n/**\n * We want to create collapsible paragraphs in places where we can't easily\n * create them. For example, between two images.\n *\n * Currently, we look for elements that are\n *\n * - `isVoid` like images or\n * - `isMaster` like `table` and `code-block`.\n *\n * If there is nothing between them, we insert a collapsible paragraph.\n */\n\nexport function normalizeSiblingWalls(\n  editor: Editor,\n  entry: NodeEntry<Element>\n): boolean {\n  if (!isWall(editor, entry[0])) return false\n  return normalizeSiblings(editor, entry, (a, b) => {\n    if (!isWall(editor, a[0]) || !isWall(editor, b[0])) return false\n    Transforms.insertNodes(\n      editor,\n      {\n        type: \"paragraph\",\n        __collapsible: true,\n        children: [{ text: \"\" }],\n      },\n      { at: b[1] }\n    )\n    return true\n  })\n}\n","import { clsx } from \"clsx\"\nimport { useSelected } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { ParagraphElement } from \"..\"\nimport { $Paragraph } from \"./styles\"\nimport { getIsEmpty } from \"./utils\"\n\nexport function Paragraph({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<ParagraphElement>) {\n  const selected = useSelected()\n  const isEmpty = getIsEmpty(element)\n  return (\n    <$Paragraph\n      {...attributes}\n      className={clsx({\n        \"--selected\": selected,\n        \"--empty\": isEmpty,\n        \"--collapsible\": !!element.__collapsible,\n      })}\n    >\n      {children}\n    </$Paragraph>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $Paragraph = styled(\"p\")`\n  padding: 0;\n  margin: 0;\n  &:first-of-type {\n    margin-top: 0;\n  }\n\n  transition: background-color 200ms, margin-top 200ms, padding-top 200ms,\n    margin-bottom 200ms, padding-bottom 200ms, font-size 200ms;\n\n  &:not(.--collapsible)&.--empty {\n    min-height: 1em;\n  }\n\n  &.--collapsible&.--empty {\n    font-size: 0.25em; /* font-size is collapsed to 1/4 of regular em */\n    margin: -0.4em 0;\n    padding: 0.1em 0; /* this is kind of eye-balling it */\n    border-radius: 1em;\n    &:hover {\n      background: rgba(0, 127, 255, 0.1);\n      cursor: pointer;\n    }\n  }\n  &.--collapsible&.--empty&.--selected {\n    font-size: 1em;\n    padding: 0;\n    margin: 0;\n    &:hover {\n      background: none;\n      cursor: default;\n    }\n    border-radius: 8px;\n  }\n`\n","import { Element, Node } from \"slate\"\n\n/**\n * We check for empty by checking for one node that contains a text that is\n * empty. If there is an inline element, this will introduce at a minimum\n * 3 nodes based on the way Slate normalizes to always have text nodes at\n * the end which is why this check works.\n */\nexport function getIsEmpty(element: Element) {\n  return (\n    element.children.length === 1 &&\n    Node.string(element.children[0]).length === 0\n  )\n}\n","import { Descendant } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createPlugin,\n  curryOne,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { normalizeNode } from \"./normalize-node\"\nimport { Paragraph } from \"./render-element/paragraph\"\n\nexport type CollapsibleParagraphEditor = {\n  collapsibleParagraph: {\n    convertParagraph: () => void\n  }\n}\n\nexport type ParagraphElement = {\n  type: \"paragraph\"\n  __collapsible?: true\n  children: Descendant[]\n}\n\nexport type CollapsibleParagraphPluginCustomTypes = {\n  Name: \"collapsible-paragraph\"\n  Editor: CollapsibleParagraphEditor\n  Element: ParagraphElement\n}\n\nexport const CollapsibleParagraphPlugin =\n  createPlugin<CollapsibleParagraphPluginCustomTypes>((editor) => {\n    const { insertBreak } = editor\n    editor.insertBreak = () => {\n      // Enter = new paragraph, Shift+Enter = soft break (handled in onKeyDown)\n      insertBreak()\n    }\n\n    /**\n     * Insert a soft break (line break within the same paragraph).\n     * Called by Shift+Enter via onKeyDown.\n     */\n    editor.insertSoftBreak = () => {\n      editor.insertText('\\n')\n    }\n\n    editor.convertElement.addConvertElementType(\"paragraph\")\n    editor.collapsibleParagraph = {\n      convertParagraph: () => {\n        editor.convertElement.convertElements<ParagraphElement>(\n          () => false,\n          {\n            type: \"paragraph\",\n          },\n          false\n        )\n      },\n    }\n    if (!editor.normalizeAfterDelete) {\n      throw new Error(\n        `The collapsible-paragraph-plugin has a dependency on the normalize-after-delete plugin. Please add that plugin before this one.`\n      )\n    }\n\n    return {\n      name: \"collapsible-paragraph\",\n      editor: {\n        normalizeNode: curryOne(normalizeNode, editor),\n      },\n      editableProps: {\n        renderElement: ({ element, attributes, children }) => {\n          switch (element.type) {\n            case \"paragraph\": {\n              return (\n                <Paragraph element={element} attributes={attributes}>\n                  {children}\n                </Paragraph>\n              )\n            }\n          }\n        },\n        onKeyDown: (e) => {\n          if (e.key === \"Enter\" && !e.nativeEvent.isComposing) {\n            e.preventDefault()\n            if (e.shiftKey) {\n              // Shift+Enter = soft break (line break within paragraph)\n              editor.insertSoftBreak()\n            } else {\n              // Enter = new paragraph\n              editor.insertBreak()\n            }\n            return true\n          }\n          return createHotkeyHandler({\n            \"super+0\": editor.collapsibleParagraph.convertParagraph,\n          })(e)\n        },\n      },\n    }\n  }) as TypedPlugin<CollapsibleParagraphPluginCustomTypes>\n","import { Editor, Element } from \"slate\"\n\n/**\n * This method lets other plugins register specific elements by their `type`\n * being able to be toggled with a paragraph.\n *\n * In order for an Element to be toggle compatible, generally it should be a\n * non-void block Element whose direct descendants are `Text` or inline elements\n * like:\n *\n * - headings\n * - list items\n */\nexport function addConvertElementType(\n  editor: Editor,\n  type: Element[\"type\"] | Array<Element[\"type\"]>\n): void {\n  if (Array.isArray(type)) {\n    editor.convertElement.convertElementTypes.push(...type)\n  } else {\n    editor.convertElement.convertElementTypes.push(type)\n  }\n}\n","import { Editor, Element, Node, Path, Point, Range, Transforms } from \"slate\"\n\nimport { rewrapElement, TargetElement } from \"../../sink\"\n\n/**\n * Calculates the character offset of a point within an element.\n * Returns -1 if the point is not within the element.\n */\nfunction getOffsetInElement(\n  editor: Editor,\n  point: Point,\n  elementPath: Path\n): number {\n  try {\n    const elementStart = Editor.start(editor, elementPath)\n    const elementEnd = Editor.end(editor, elementPath)\n\n    // Check if point is within element\n    if (Point.isBefore(point, elementStart) || Point.isAfter(point, elementEnd)) {\n      return -1\n    }\n\n    // Calculate offset from element start to point\n    const range = { anchor: elementStart, focus: point }\n    return Editor.string(editor, range).length\n  } catch {\n    return -1\n  }\n}\n\n/**\n * Restores the selection to a specific offset within an element.\n */\nfunction restoreSelectionInElement(\n  editor: Editor,\n  elementPath: Path,\n  offset: number\n): void {\n  try {\n    const element = Node.get(editor, elementPath)\n    if (!Element.isElement(element)) return\n\n    const text = Node.string(element)\n    const safeOffset = Math.min(offset, text.length)\n\n    // Find the exact point at the offset\n    const elementStart = Editor.start(editor, elementPath)\n    let currentOffset = 0\n    let targetPath = elementStart.path\n    let targetOffset = 0\n\n    // Traverse through text nodes to find the correct position\n    for (const [node, path] of Node.texts(element)) {\n      const nodeLength = node.text.length\n      if (currentOffset + nodeLength >= safeOffset) {\n        // path is already relative to element, so just concat with elementPath\n        targetPath = [...elementPath, ...path]\n        targetOffset = safeOffset - currentOffset\n        break\n      }\n      currentOffset += nodeLength\n    }\n\n    const point: Point = { path: targetPath, offset: targetOffset }\n    Transforms.select(editor, { anchor: point, focus: point })\n  } catch {\n    // If restoration fails, don't crash\n  }\n}\n\n/**\n * A type with generic for `convertElements` (below) to be used with the curry\n * method. TypeScript, unfortunately, cannot automatically curry generics for\n * us so we have to do it manually.\n */\nexport type CurriedConvertElements = <T extends Element = Element>(\n  matchForToggle: (element: Element) => boolean,\n  targetElement: TargetElement<T>,\n  allowToggle: boolean\n) => void\n\n/**\n * Checks if an element contains newline characters in its text content\n */\nfunction elementContainsNewlines(element: Element): boolean {\n  const text = Node.string(element)\n  return text.includes(\"\\n\")\n}\n\n/**\n * Given a selection range and an element, determines which line indices are selected.\n * Returns an object with startLineIndex and endLineIndex.\n */\nfunction getSelectedLineIndices(\n  editor: Editor,\n  element: Element,\n  elementPath: Path,\n  selection: Range\n): { startLineIndex: number; endLineIndex: number } {\n  const text = Node.string(element)\n  const lines = text.split(\"\\n\")\n\n  // Get the start and end points relative to this element\n  const elementStart = Editor.start(editor, elementPath)\n  const elementEnd = Editor.end(editor, elementPath)\n\n  // Clamp selection to element boundaries\n  const start = Point.isBefore(selection.anchor, elementStart)\n    ? elementStart\n    : Point.isAfter(selection.anchor, elementEnd)\n      ? elementEnd\n      : selection.anchor\n  const end = Point.isBefore(selection.focus, elementStart)\n    ? elementStart\n    : Point.isAfter(selection.focus, elementEnd)\n      ? elementEnd\n      : selection.focus\n\n  // Calculate offsets from element start\n  const startOffset = Math.min(\n    Editor.string(editor, { anchor: elementStart, focus: start }).length,\n    text.length\n  )\n  const endOffset = Math.min(\n    Editor.string(editor, { anchor: elementStart, focus: end }).length,\n    text.length\n  )\n\n  const minOffset = Math.min(startOffset, endOffset)\n  const maxOffset = Math.max(startOffset, endOffset)\n\n  // Find which lines contain these offsets\n  let currentOffset = 0\n  let startLineIndex = 0\n  let endLineIndex = lines.length - 1\n\n  for (let i = 0; i < lines.length; i++) {\n    const lineEnd = currentOffset + lines[i].length\n    if (currentOffset <= minOffset && minOffset <= lineEnd) {\n      startLineIndex = i\n    }\n    if (currentOffset <= maxOffset && maxOffset <= lineEnd) {\n      endLineIndex = i\n      break\n    }\n    currentOffset = lineEnd + 1 // +1 for newline\n  }\n\n  return { startLineIndex, endLineIndex }\n}\n\n/**\n * Splits an element at cursor/selection line boundaries.\n * Only splits out the lines that are selected, keeping other lines in original element.\n * Returns the path of the selected line(s) block.\n */\nfunction splitElementAtSelectedLines(\n  editor: Editor,\n  element: Element,\n  path: Path,\n  selection: Range\n): Path {\n  const text = Node.string(element)\n  if (!text.includes(\"\\n\")) {\n    return path\n  }\n\n  const lines = text.split(\"\\n\")\n  if (lines.length <= 1) {\n    return path\n  }\n\n  const { startLineIndex, endLineIndex } = getSelectedLineIndices(\n    editor,\n    element,\n    path,\n    selection\n  )\n\n  // Lines before selection, selected lines, and lines after selection\n  const beforeLines = lines.slice(0, startLineIndex)\n  const selectedLines = lines.slice(startLineIndex, endLineIndex + 1)\n  const afterLines = lines.slice(endLineIndex + 1)\n\n  // If all lines are selected, no need to split\n  if (beforeLines.length === 0 && afterLines.length === 0) {\n    return path\n  }\n\n  Editor.withoutNormalizing(editor, () => {\n    const basePath = path.slice(0, -1)\n    const baseIndex = path[path.length - 1]\n\n    // Insert after lines as new element (if any) - do this first as it goes after\n    if (afterLines.length > 0) {\n      const afterText = afterLines.join(\"\\n\")\n      const afterElement: Element = {\n        ...element,\n        children: [{ text: afterText }],\n      } as Element\n      Transforms.insertNodes(editor, afterElement, {\n        at: [...basePath, baseIndex + 1],\n      })\n    }\n\n    // Update original element to contain only before lines + selected lines\n    const childrenCount = element.children.length\n    for (let j = childrenCount - 1; j >= 0; j--) {\n      Transforms.removeNodes(editor, { at: [...path, j] })\n    }\n\n    if (beforeLines.length > 0) {\n      // Original element keeps before lines\n      Transforms.insertNodes(\n        editor,\n        { text: beforeLines.join(\"\\n\") },\n        { at: [...path, 0] }\n      )\n\n      // Insert selected lines as new element after before lines\n      const selectedText = selectedLines.join(\"\\n\")\n      const selectedElement: Element = {\n        type: \"paragraph\",\n        children: [{ text: selectedText }],\n      }\n      Transforms.insertNodes(editor, selectedElement, {\n        at: [...basePath, baseIndex + 1],\n      })\n    } else {\n      // No before lines, original element becomes selected lines\n      Transforms.insertNodes(\n        editor,\n        { text: selectedLines.join(\"\\n\") },\n        { at: [...path, 0] }\n      )\n    }\n  })\n\n  // Return the path of the selected lines block\n  if (beforeLines.length > 0) {\n    return [...path.slice(0, -1), path[path.length - 1] + 1]\n  }\n  return path\n}\n\n/**\n * The `convertElements` takes a Block Element that has been identified as being\n * convertible and converts it into another type of Element.\n *\n * For example:\n *\n * - headings\n * - list items\n *\n * It also allows for toggling. In this scenario, if all the convertible\n * elements are already in the target state (e.g. we are converting to a heading\n * 2 and all the convertible elemtns are already a heading 2) then the elements\n * will convert back to a `paragraph` element.\n *\n * NOTE:\n *\n * Why is there an unusual signature?\n *\n * This method has a somewhat unusual and not-DRY signature which is in the form\n * of having a `matchForToggle` (which allows us to specify when an Element is\n * already matching the `targetElement`) and also an `allowToggle`; however, we\n * could make `matchForToggle` optional and only `allowToggle` if it is\n * specified.\n *\n * That being said, the signature is set up this way to reduce friction when\n * creating a specific convert function like `convertHeading`. In this scenario,\n * we can have the created `convertHeading` pass through the argument to\n * `allowToggle` and pass it through to this `convertElements` function making\n * that code easier to understand.\n */\nexport function convertElements<T extends Element = Element>(\n  editor: Editor,\n  matchForToggle: (element: Element) => boolean,\n  targetElement: TargetElement<T>,\n  allowToggle: boolean\n): boolean {\n  const { selection } = editor\n  if (!selection) return false\n\n  /**\n   * Save the cursor position (anchor offset) within the first convertible element\n   * so we can restore it after conversion\n   */\n  let savedAnchorOffset = -1\n  let savedFocusOffset = -1\n  const isCollapsed = Range.isCollapsed(selection)\n\n  /**\n   * Find convertible elements\n   */\n  const entries = Array.from(\n    Editor.nodes<Element>(editor, {\n      match: (node) =>\n        Element.isElement(node) &&\n        editor.convertElement.isConvertibleElement(node),\n    })\n  )\n\n  /**\n   * Save cursor offset relative to the first entry before any transformations\n   */\n  if (entries.length > 0) {\n    const [, firstPath] = entries[0]\n    savedAnchorOffset = getOffsetInElement(editor, selection.anchor, firstPath)\n    savedFocusOffset = getOffsetInElement(editor, selection.focus, firstPath)\n  }\n  /**\n   * If there aren't any convertible elements, there's nothing to do\n   */\n  if (entries.length === 0) return false\n\n  /**\n   * Split elements that contain newlines at selected line boundaries\n   * Process in reverse order to maintain path validity\n   */\n  const allPaths: Path[] = []\n  Editor.withoutNormalizing(editor, () => {\n    for (let i = entries.length - 1; i >= 0; i--) {\n      const [element, path] = entries[i]\n      if (elementContainsNewlines(element)) {\n        const splitPath = splitElementAtSelectedLines(\n          editor,\n          element,\n          path,\n          selection\n        )\n        allPaths.unshift(splitPath)\n      } else {\n        allPaths.unshift(path)\n      }\n    }\n  })\n\n  /**\n   * Re-fetch all elements at the updated paths\n   */\n  const updatedEntries: [Element, Path][] = allPaths\n    .map((path) => {\n      try {\n        const node = Node.get(editor, path)\n        if (Element.isElement(node)) {\n          return [node, path] as [Element, Path]\n        }\n        return null\n      } catch {\n        return null\n      }\n    })\n    .filter((entry): entry is [Element, Path] => entry !== null)\n\n  if (updatedEntries.length === 0) return false\n\n  /**\n   * If `allowToggle` is `true` and all of the convertible elements match the\n   * `matchForToggle` (for example, if converting to a heading level 2, if all\n   * the matching convertible elements are heading level 2) then we want to\n   * toggle back to a paragraph.\n   */\n  const shouldToggle =\n    allowToggle && updatedEntries.every((entry) => matchForToggle(entry[0]))\n\n  if (shouldToggle) {\n    /**\n     * If all of the entries are already the target type, then revert them to\n     * a paragraph\n     */\n    Editor.withoutNormalizing(editor, () => {\n      for (const entry of updatedEntries) {\n        rewrapElement(editor, { type: \"paragraph\" }, entry[1])\n      }\n    })\n  } else {\n    /**\n     * If any of the entries aren't the target type, then convert them to the\n     * target type.\n     */\n    Editor.withoutNormalizing(editor, () => {\n      for (const entry of updatedEntries) {\n        rewrapElement(editor, targetElement, entry[1])\n      }\n    })\n  }\n\n  /**\n   * Restore cursor position after conversion.\n   * Use the first updated entry's path to restore the cursor at the saved offset.\n   */\n  if (updatedEntries.length > 0 && savedAnchorOffset >= 0) {\n    const [, firstPath] = updatedEntries[0]\n    if (isCollapsed) {\n      // For collapsed selection (cursor), just restore anchor position\n      restoreSelectionInElement(editor, firstPath, savedAnchorOffset)\n    } else if (savedFocusOffset >= 0) {\n      // For expanded selection, restore both anchor and focus\n      try {\n        const element = Node.get(editor, firstPath)\n        if (Element.isElement(element)) {\n          const text = Node.string(element)\n          const safeAnchorOffset = Math.min(savedAnchorOffset, text.length)\n          const safeFocusOffset = Math.min(savedFocusOffset, text.length)\n\n          const elementStart = Editor.start(editor, firstPath)\n\n          // Calculate anchor point\n          let anchorPath = elementStart.path\n          let anchorOffset = safeAnchorOffset\n          let currentOffset = 0\n          for (const [node, path] of Node.texts(element)) {\n            const nodeLength = node.text.length\n            if (currentOffset + nodeLength >= safeAnchorOffset) {\n              // path is already relative to element, so just concat with firstPath\n              anchorPath = [...firstPath, ...path]\n              anchorOffset = safeAnchorOffset - currentOffset\n              break\n            }\n            currentOffset += nodeLength\n          }\n\n          // Calculate focus point\n          let focusPath = elementStart.path\n          let focusOffset = safeFocusOffset\n          currentOffset = 0\n          for (const [node, path] of Node.texts(element)) {\n            const nodeLength = node.text.length\n            if (currentOffset + nodeLength >= safeFocusOffset) {\n              // path is already relative to element, so just concat with firstPath\n              focusPath = [...firstPath, ...path]\n              focusOffset = safeFocusOffset - currentOffset\n              break\n            }\n            currentOffset += nodeLength\n          }\n\n          Transforms.select(editor, {\n            anchor: { path: anchorPath, offset: anchorOffset },\n            focus: { path: focusPath, offset: focusOffset },\n          })\n        }\n      } catch {\n        // Fall back to collapsed selection at anchor\n        restoreSelectionInElement(editor, firstPath, savedAnchorOffset)\n      }\n    }\n  }\n\n  return true\n}\n","import { Editor, Element } from \"slate\"\n\n/**\n * Returns true if the passed in `element` object is an element type that has\n * previously been registered as a convertible element using the\n * `editor.convertElement.addConvertElementType` method.\n */\nexport function isConvertElement(editor: Editor, element: Element): boolean {\n  return editor.convertElement.convertElementTypes.includes(element.type)\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { addConvertElementType } from \"./add-convert-element-type\"\nimport { convertElements, CurriedConvertElements } from \"./convert-elements\"\nimport { isConvertElement } from \"./is-convert-element\"\n\nexport function createConvertElementMethods(editor: Editor) {\n  return {\n    convertElementTypes: [] as string[],\n    addConvertElementType: curryOne(addConvertElementType, editor),\n    isConvertibleElement: curryOne(isConvertElement, editor),\n    convertElements: curryOne(\n      convertElements,\n      editor\n    ) as CurriedConvertElements,\n  }\n}\n","import { createPlugin, TypedPlugin } from \"../sink\"\n\nimport { createConvertElementMethods } from \"./methods\"\n\nexport type ConvertElementEditor = {\n  convertElement: ReturnType<typeof createConvertElementMethods>\n}\n\nexport type ConvertElementPluginCustomTypes = {\n  Name: \"convert-element\"\n  Editor: ConvertElementEditor\n}\n\nexport const ConvertElementPlugin =\n  createPlugin<ConvertElementPluginCustomTypes>((editor) => {\n    editor.convertElement = createConvertElementMethods(editor)\n    return {\n      name: \"convert-element\",\n    }\n  }) as TypedPlugin<ConvertElementPluginCustomTypes>\n","import { Editor, Path, Range, Transforms } from \"slate\"\n\nimport { findElementUp } from \"../sink\"\nimport { HeadingElement } from \"./types\"\n\nexport function insertBreak(editor: Editor) {\n  const entry = findElementUp<HeadingElement>(editor, \"heading\")\n  if (!entry) return false\n  if (!editor.selection) return false\n  if (Range.isExpanded(editor.selection)) return false\n  if (!Editor.isEnd(editor, editor.selection.anchor, entry[1])) return false\n  const nextPath = Path.next(entry[1])\n  Transforms.insertNodes(\n    editor,\n    { type: \"paragraph\", children: [{ text: \"\" }] },\n    { at: nextPath }\n  )\n  Transforms.select(editor, {\n    anchor: Editor.start(editor, nextPath),\n    focus: Editor.start(editor, nextPath),\n  })\n  return true\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { HeadingElement } from \"../types\"\n\nfunction convertHeading(\n  editor: Editor,\n  level: 1 | 2 | 3 | 4 | 5 | 6,\n  allowToggle: boolean\n) {\n  editor.convertElement.convertElements<HeadingElement>(\n    (element) => element.type === \"heading\" && element.level == level,\n    { type: \"heading\", level },\n    allowToggle\n  )\n}\n\nfunction isHeadingActive(editor: Editor, level: 1 | 2 | 3 | 4 | 5 | 6) {\n  const [match] = Editor.nodes(editor, {\n    match: n => {\n      return (\n        'type' in n &&\n        'level' in n &&\n        n.type === 'heading' &&\n        n.level === level\n      )\n    },\n  })\n  return !!match\n}\n\nexport function createHeadingMethods(editor: Editor) {\n  return {\n    convertHeading: curryOne(convertHeading, editor),\n    isHeadingActive: curryOne(isHeadingActive, editor),\n  }\n}\n","import { css } from \"@emotion/react\"\nimport styled from \"@emotion/styled\"\n\nconst headingStyles = css`\n  margin-top: 1em;\n  &:first-of-type {\n    margin-top: 0;\n  }\n  font-weight: bold;\n`\n\nexport const $H1 = styled(\"h1\")`\n  ${headingStyles}\n  font-size: 2.25em;\n  letter-spacing: -0.01em;\n`\n\nexport const $H2 = styled(\"h2\")`\n  ${headingStyles}\n  font-size: 1.5em;\n`\n\nexport const $H3 = styled(\"h3\")`\n  ${headingStyles}\n  font-size: 1.25em;\n`\n\nexport const $H4 = styled(\"h4\")`\n  ${headingStyles}\n  font-size: 1em;\n`\n\nexport const $H5 = styled(\"h5\")`\n  ${headingStyles}\n  font-size: 1em;\n`\n\nexport const $H6 = styled(\"h6\")`\n  ${headingStyles}\n  font-size: 1em;\n`\n","export * from \"./types\"\n\nimport {\n  createAutocompleteSpaceHandler,\n  createHotkeyHandler,\n  createPlugin,\n  curryOne,\n  curryTwo,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { insertBreak } from \"./insert-break\"\nimport { createHeadingMethods } from \"./methods\"\nimport { $H1, $H2, $H3, $H4, $H5, $H6 } from \"./styles\"\nimport { HeadingPluginCustomTypes } from \"./types\"\n\nexport const HeadingPlugin = createPlugin<HeadingPluginCustomTypes>(\n  (editor) => {\n    editor.convertElement.addConvertElementType(\"heading\")\n    editor.heading = createHeadingMethods(editor)\n    const hotkeyHandler = createHotkeyHandler({\n      \"super+1\": curryTwo(editor.heading.convertHeading, 1, true),\n      \"super+2\": curryTwo(editor.heading.convertHeading, 2, true),\n      \"super+3\": curryTwo(editor.heading.convertHeading, 3, true),\n      \"super+4\": curryTwo(editor.heading.convertHeading, 4, true),\n      \"super+5\": curryTwo(editor.heading.convertHeading, 5, true),\n      \"super+6\": curryTwo(editor.heading.convertHeading, 6, true),\n    })\n    const autocompleteHandler = createAutocompleteSpaceHandler(editor, {\n      \"#\": curryTwo(editor.heading.convertHeading, 1, false),\n      \"##\": curryTwo(editor.heading.convertHeading, 2, false),\n      \"###\": curryTwo(editor.heading.convertHeading, 3, false),\n      \"####\": curryTwo(editor.heading.convertHeading, 4, false),\n      \"#####\": curryTwo(editor.heading.convertHeading, 5, false),\n      \"######\": curryTwo(editor.heading.convertHeading, 6, false),\n    })\n    return {\n      name: \"heading\",\n      editor: {\n        insertBreak: curryOne(insertBreak, editor),\n      },\n      editableProps: {\n        renderElement: ({ element, attributes, children }) => {\n          if (element.type === \"heading\") {\n            switch (element.level) {\n              case 1:\n                return <$H1 {...attributes}>{children}</$H1>\n              case 2:\n                return <$H2 {...attributes}>{children}</$H2>\n              case 3:\n                return <$H3 {...attributes}>{children}</$H3>\n              case 4:\n                return <$H4 {...attributes}>{children}</$H4>\n              case 5:\n                return <$H5 {...attributes}>{children}</$H5>\n              case 6:\n                return <$H6 {...attributes}>{children}</$H6>\n              default: {\n                const exhaustiveCheck: never = element.level\n                throw new Error(\n                  `Expected element.level to be 1-6 but got ${exhaustiveCheck as number}`\n                )\n              }\n            }\n          }\n        },\n        onKeyDown: (e) => {\n          if (hotkeyHandler(e)) return true\n          if (autocompleteHandler(e)) return true\n          return false\n        },\n      },\n    }\n  }\n) as TypedPlugin<HeadingPluginCustomTypes>\n","import { useSelected } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../sink\"\n\nimport { HorizontalRuleElement } from \".\"\nimport { $HorizontalRule } from \"./styles\"\n\nexport function HorizontalRule({\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<HorizontalRuleElement>) {\n  const selected = useSelected()\n  return (\n    <div {...attributes} draggable>\n      {children}\n      <div contentEditable={false}>\n        <$HorizontalRule className={selected ? \"--selected\" : \"\"} />\n      </div>\n    </div>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $HorizontalRule = styled(\"hr\")`\n  position: relative;\n  height: 1em;\n  /* background-color: var(--hr-color); */\n  margin: 1em 0;\n  &::before {\n    position: absolute;\n    content: \"\";\n    left: 0.125em;\n    right: 0.125em;\n    top: 50%;\n    height: 1px;\n    background-color: var(--hr-color);\n    border-radius: 1px;\n  }\n  border-radius: 0.25em;\n  cursor: pointer;\n  border: none;\n  &:hover {\n    background-color: rgba(0, 127, 255, 0.1);\n    /* &::before {\n      outline: 2px solid var(--hover-color);\n    } */\n  }\n  &.--selected {\n    background: none;\n    &::before {\n      outline: 2px solid var(--select-color, blue);\n    }\n  }\n`\n","import { Editor, Element, Path, Transforms } from \"slate\"\n\nimport { curryOne, findElementUp } from \"../../sink\"\n\nfunction insertHorizontalRule(editor: Editor) {\n  const { selection } = editor\n  if (!selection) return false\n\n  // Look for a parent that `isMaster`\n  const entry = findElementUp(\n    editor,\n    (node) => Element.isElement(node) && editor.isMaster(node)\n  )\n\n  const hrElement = {\n    type: \"horizontal-rule\" as const,\n    children: [{ text: \"\" }] as [{ text: string }],\n  }\n  const paragraphElement = {\n    type: \"paragraph\" as const,\n    children: [{ text: \"\" }],\n  }\n\n  if (entry == null) {\n    // Insert horizontal rule and a new paragraph after it\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, [hrElement, paragraphElement])\n      // Move cursor to the new paragraph\n      Transforms.move(editor)\n    })\n  } else {\n    // If inside a master element (like table), insert after it\n    const nextPath = Path.next(entry[1])\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, [hrElement, paragraphElement], { at: nextPath })\n      // Select the start of the new paragraph\n      const paragraphPath = Path.next(nextPath)\n      Transforms.select(editor, Editor.start(editor, paragraphPath))\n    })\n  }\n  return true\n}\n\nexport function createHorizontalRuleMethods(editor: Editor) {\n  return {\n    insertHorizontalRule: curryOne(insertHorizontalRule, editor),\n  }\n}\n","import { createHotkeyHandler, createPlugin, TypedPlugin } from \"../sink\"\n\nimport { HorizontalRule } from \"./horizontal-rule\"\nimport { createHorizontalRuleMethods } from \"./methods\"\nimport { HorizontalRulePluginCustomTypes } from \"./types\"\nexport * from \"./types\"\n\nexport const HorizontalRulePlugin =\n  createPlugin<HorizontalRulePluginCustomTypes>(\n    (editor, _options, { createPolicy }) => {\n      editor.horizontalRule = createHorizontalRuleMethods(editor)\n      return createPolicy({\n        name: \"horizontal-rule\",\n        editor: {\n          isVoid(element) {\n            if (element.type === \"horizontal-rule\") return true\n          },\n        },\n        editableProps: {\n          renderElement: (props) => {\n            if (props.element.type === \"horizontal-rule\") {\n              return <HorizontalRule {...props} />\n            }\n          },\n          onKeyDown: createHotkeyHandler({\n            \"super+-\": editor.horizontalRule.insertHorizontalRule,\n          }),\n        },\n      })\n    }\n  ) as TypedPlugin<HorizontalRulePluginCustomTypes>\n","import styled from \"@emotion/styled\"\n\nexport const $InlineCode = styled(\"code\")`\n  color: var(--shade-600);\n  background-color: var(--inline-code-bgcolor);\n  border: 1px solid var(--inline-code-border-color);\n  border-radius: 0.25em;\n  padding: 0.1375em 0.125em;\n  /**\n   * Font Stack from\n   * https://qwtel.com/posts/software/the-monospaced-system-ui-css-font-stack/\n   */\n  font-family: ui-monospace, Menlo, Monaco, \"Cascadia Mono\", \"Segoe UI Mono\",\n    \"Roboto Mono\", \"Oxygen Mono\", \"Ubuntu Monospace\", \"Source Code Pro\",\n    \"Fira Mono\", \"Droid Sans Mono\", \"Courier New\", monospace;\n  /**\n   * This font size may seem smaller but any larger (including 0.875) means that\n   * it messes up the line height of the normal text. Not sure why this happens\n   * with the monospace font but seems to happen on both the default 'monospace'\n   * font as well as the font stack above.\n   */\n  font-size: 0.75em;\n  vertical-align: baseline;\n`\n\n/**\n * These invisible spans fix a bug in Chrome which doesn't allow the cursor to\n * sit on both the \"inside\" and \"outside\" of the inline-code span. By placing\n * this 1px wide span just inside of the inline code, we are able to workaround\n * this limitation.\n */\nexport const $InvisibleSpan = styled(\"span\")`\n  display: inline-block;\n  opacity: 0;\n  width: 1px;\n  overflow: hidden;\n`\n","import { createHotkeyHandler, createPlugin, TypedPlugin } from \"../sink\"\n\nimport { $InlineCode, $InvisibleSpan } from \"./styles\"\nimport { InlineCodePluginCustomTypes } from \"./types\"\nexport * from \"./styles\"\nexport * from \"./types\"\n\nexport const InlineCodePlugin = createPlugin<InlineCodePluginCustomTypes>(\n  (editor) => {\n    if (!editor.marksPlugin)\n      throw new Error(\n        \"InlineCodePlugin has a dependency on the MarksPlugin but the MarksPlugin has not been added or is added after the InlineCodePlugin\"\n      )\n    editor.inlineCode = {\n      toggleInlineCode: () => editor.marksPlugin.toggleMark(\"code\"),\n    }\n    return {\n      name: \"inline-code\",\n      editableProps: {\n        renderLeaf: ({ leaf, children }) => {\n          if (leaf.code) {\n            return (\n              /**\n               * Disable spellCheck because it's computer code usually.\n               */\n              <$InlineCode spellCheck={false}>\n                {/* These invisible spans are necessary. See comments for $InvisibleSpan. */}\n                <$InvisibleSpan contentEditable={false}>|</$InvisibleSpan>\n                {children}\n                {/* These invisible spans are necessary. See comments for $InvisibleSpan. */}\n                <$InvisibleSpan contentEditable={false}>|</$InvisibleSpan>\n              </$InlineCode>\n            )\n          } else {\n            return children\n          }\n        },\n        onKeyDown: createHotkeyHandler({\n          \"mod+j\": () => editor.inlineCode.toggleInlineCode(),\n        }),\n      },\n    }\n  }\n) as TypedPlugin<InlineCodePluginCustomTypes>\n","import { Editor, Transforms } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createIsElementType,\n  createPlugin,\n  curryOne,\n  findElementUp,\n  isStartOfElement,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { createListMethods } from \"./methods\"\nimport { normalizeNode } from \"./normalize-node\"\nimport { renderElement } from \"./render-element\"\nimport { ListItemElement, ListPluginCustomTypes } from \"./types\"\n\nexport * from \"./types\"\n\nexport const LIST_ITEM_TYPES: ListItemElement[\"type\"][] = [\n  \"unordered-list-item\",\n  \"ordered-list-item\",\n  \"task-list-item\",\n]\n\nexport const isListItem = createIsElementType<ListItemElement>(LIST_ITEM_TYPES)\n\nexport const ListPlugin = createPlugin<ListPluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    editor.convertElement.addConvertElementType(LIST_ITEM_TYPES)\n    const list = (editor.list = createListMethods(editor))\n    const hotkeyHandler = createHotkeyHandler({\n      tab: list.indent,\n      \"shift+tab\": list.outdent,\n      \"super+7\": curryOne(list.convertOrderedList, true),\n      \"super+8\": curryOne(list.convertUnorderedList, true),\n      \"super+9\": curryOne(list.convertTaskList, true),\n    })\n\n    return createPolicy({\n      name: \"list\",\n      editor: {\n        normalizeNode: (entry) => normalizeNode(editor, entry),\n        insertBreak: list.insertBreak,\n        deleteBackward: (unit) => {\n          if (unit !== \"character\") return false\n          if (!isStartOfElement(editor, isListItem)) return false\n          const listItem = findElementUp<ListItemElement>(editor, isListItem)\n          if (!listItem) return false\n          const [element, path] = listItem\n          if (element.depth > 0) {\n            Transforms.setNodes(\n              editor,\n              { depth: element.depth - 1 },\n              { at: path }\n            )\n            return true\n          }\n          editor.collapsibleParagraph.convertParagraph()\n          return true\n        },\n      },\n      editableProps: {\n        renderElement,\n        onKeyDown(e) {\n          if (!Editor.nodes(editor, { match: isListItem })) return false\n          return hotkeyHandler(e)\n        },\n      },\n    })\n  }\n) as TypedPlugin<ListPluginCustomTypes>\n","import { Editor } from \"slate\"\n\nimport {\n  OrderedListItemElement,\n  TaskListItemElement,\n  UnorderedListItemElement,\n} from \"..\"\n\nexport function convertOrderedList(editor: Editor, allowToggle: boolean) {\n  return editor.convertElement.convertElements<OrderedListItemElement>(\n    (element) => element.type === \"ordered-list-item\",\n    (element) => {\n      return {\n        type: \"ordered-list-item\",\n        depth: \"depth\" in element ? element.depth : 0,\n      }\n    },\n    allowToggle\n  )\n}\n\nexport function convertTaskList(editor: Editor, allowToggle: boolean) {\n  return editor.convertElement.convertElements<TaskListItemElement>(\n    (element) => element.type === \"task-list-item\",\n    (element) => {\n      return {\n        type: \"task-list-item\",\n        checked: \"checked\" in element ? element.checked : false,\n        depth: \"depth\" in element ? element.depth : 0,\n      }\n    },\n    allowToggle\n  )\n}\n\nexport function convertUnorderedList(editor: Editor, allowToggle: boolean) {\n  return editor.convertElement.convertElements<UnorderedListItemElement>(\n    (element) => element.type === \"unordered-list-item\",\n    (element) => {\n      return {\n        type: \"unordered-list-item\",\n        depth: \"depth\" in element ? element.depth : 0,\n      }\n    },\n    allowToggle\n  )\n}\n","import { Editor } from \"slate\"\nimport { findElementUp, isStartOfElement } from \"../../sink\"\nimport { isListItem } from \"..\"\nimport { ListItemElement } from \"../types\"\n\nconst MAX_DEPTH = 2\n\nexport function getListDepth(editor: Editor): number {\n  const listItem = findElementUp<ListItemElement>(editor, isListItem)\n  if (!listItem) return 0\n  return listItem[0].depth\n}\n\nexport function canIncreaseDepth(editor: Editor): boolean {\n  if (!isStartOfElement(editor, isListItem)) return false\n  const depth = getListDepth(editor)\n  return depth < MAX_DEPTH\n}\n\nexport function canDecreaseDepth(editor: Editor): boolean {\n  if (!isStartOfElement(editor, isListItem)) return false\n  const depth = getListDepth(editor)\n  return depth > 0\n}\n\nexport function increaseDepth(editor: Editor): void {\n  if (!canIncreaseDepth(editor)) return\n  editor.list.indent()\n}\n\nexport function decreaseDepth(editor: Editor): void {\n  if (!canDecreaseDepth(editor)) return\n  editor.list.outdent()\n}\n","import { Editor } from \"slate\"\n\nimport { setNodesDynamic } from \"../../sink\"\n\nimport { isListItem, ListItemElement } from \"..\"\n\nexport function indent(editor: Editor) {\n  return setNodesDynamic<ListItemElement>(\n    editor,\n    (node) => ({ depth: node.depth + 1 }),\n    {\n      match: isListItem,\n    }\n  )\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { findElementUp, rewrapElement } from \"../../sink\"\n\nimport { isListItem } from \"..\"\nimport { ListItemElement } from \"../types\"\n\nexport function insertBreak(editor: Editor): boolean {\n  const entry = findElementUp<ListItemElement>(editor, isListItem)\n  if (!entry) return false\n  const [element, path] = entry\n\n  /**\n   * If we're in an empty list\n   */\n  if (Editor.isEmpty(editor, element)) {\n    if (element.depth > 0) {\n      /**\n       * If it's indented, then unindent it\n       */\n      Transforms.setNodes(editor, { depth: element.depth - 1 }, { at: path })\n      return true\n    } else {\n      /**\n       * If it's fully unindented, turn it into a paragraph\n       */\n      rewrapElement(editor, { type: \"paragraph\" }, path)\n      return true\n    }\n  }\n  /**\n   * Otherwise perform default insertBreak transform\n   */\n  Transforms.splitNodes(editor, { always: true })\n  /**\n   * Then find the list item we are now in\n   */\n  const nextEntry = findElementUp<ListItemElement>(editor, isListItem)\n  if (!nextEntry) return true\n  /**\n   * And if it's a checked task list that is checked, we want to uncheck it.\n   * New list items are by default always unchecked.\n   */\n  if (nextEntry[0].type === \"task-list-item\" && nextEntry[0].checked === true) {\n    Transforms.setNodes(editor, { checked: false }, { at: nextEntry[1] })\n  }\n  return true\n}\n","import { Editor } from \"slate\"\n\nimport { setNodesDynamic } from \"../../sink\"\n\nimport { isListItem, ListItemElement } from \"..\"\n\nexport function outdent(editor: Editor): boolean {\n  const entries = Array.from(\n    Editor.nodes<ListItemElement>(editor, {\n      match: isListItem,\n    })\n  )\n  /**\n   * Don't allow `shift+tab` if any of the list items are already at a\n   * depth of `0`\n   */\n  for (const entry of entries) {\n    if (entry[0].depth === 0) return true\n  }\n  return setNodesDynamic<ListItemElement>(\n    editor,\n    (node) => ({ depth: Math.max(0, node.depth - 1) }),\n    {\n      match: isListItem,\n    }\n  )\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt, findElementUp } from \"../../sink\"\n\nimport { TaskListItemElement } from \"../types\"\n\nexport function toggleTaskListItem(\n  editor: Editor,\n  { at = editor.selection }: { at?: BetterAt } = {}\n) {\n  const taskListItem = findElementUp<TaskListItemElement>(\n    editor,\n    \"task-list-item\",\n    { at }\n  )\n  if (!taskListItem) return false\n  const nextChecked = !taskListItem[0].checked\n  Transforms.setNodes<TaskListItemElement>(\n    editor,\n    { checked: nextChecked },\n    { at: taskListItem[1] }\n  )\n  return true\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport {\n  convertOrderedList,\n  convertTaskList,\n  convertUnorderedList,\n} from \"./convert-list-item\"\nimport {\n  getListDepth,\n  canIncreaseDepth,\n  canDecreaseDepth,\n  increaseDepth,\n  decreaseDepth,\n} from \"./depth\"\nimport { indent } from \"./indent\"\nimport { insertBreak } from \"./insert-break\"\nimport { outdent } from \"./outdent\"\nimport { toggleTaskListItem } from \"./toggleTaskListItem\"\n\nexport function createListMethods(editor: Editor) {\n  return {\n    indent: curryOne(indent, editor),\n    outdent: curryOne(outdent, editor),\n    convertUnorderedList: curryOne(convertUnorderedList, editor),\n    convertOrderedList: curryOne(convertOrderedList, editor),\n    convertTaskList: curryOne(convertTaskList, editor),\n    insertBreak: curryOne(insertBreak, editor),\n    toggleTaskListItem: curryOne(toggleTaskListItem, editor),\n    getListDepth: curryOne(getListDepth, editor),\n    canIncreaseDepth: curryOne(canIncreaseDepth, editor),\n    canDecreaseDepth: curryOne(canDecreaseDepth, editor),\n    increaseDepth: curryOne(increaseDepth, editor),\n    decreaseDepth: curryOne(decreaseDepth, editor),\n  }\n}\n","import { Editor, Element, Node, NodeEntry, Transforms } from \"slate\"\n\nimport { createIsElementType, normalizeSiblings } from \"../../sink\"\n\nimport { isListItem, OrderedListItemElement } from \"..\"\n\nconst isOrderedListItem = createIsElementType<OrderedListItemElement>([\n  \"ordered-list-item\",\n])\n\n/**\n * Makes sure that when a list item is deeper than a preceding one, that we\n * reset the counter.\n *\n * How it works:\n *\n * If we have any two list item siblings where the second sibling is an\n * `ordered-list-item`, then the second sibling should have the property\n * `_firstOfType` be `true` if the depth of the second sibling is higher or\n * the previous sibling is not an ordered list item (e.g. a paragraph or a\n * bullet)\n *\n * Why we need it:\n *\n * We need to do this manually because our implementation of lists does not\n * actually nest lists within lists. We took the approach because the cost\n * of actually nesting lists is very high in terms of added complexity. It is\n * much easier to manually reset the counters than it is to implement\n * everything to W3C specifications, especially given that from a UI\n * perspective, users expect lists to behave similar to paragraphs and\n * headings.\n */\n\nexport function normalizeOrderedFirstAtDepth(\n  editor: Editor,\n  entry: NodeEntry<Node>\n): boolean {\n  const [node, path] = entry\n  if (!Element.isElement(node)) return false\n  return normalizeSiblings<Element>(editor, [node, path], (a, b) => {\n    /**\n     * If the second item (the item we are actually looking at) is not an\n     * ordered list item, then we aren't interested.\n     */\n    if (!isOrderedListItem(b[0])) return false\n    /**\n     * The second item is an ordered-list-item. If the item before it is not\n     * or the second item is deeper than the first, then we want to set\n     * `__firstAtDepth` to `true`.\n     */\n    // For non-list items, treat them as depth 0\n    const __firstAtDepth = isOrderedListItem(a[0]) ? b[0].depth > a[0].depth : isListItem(a[0]) ? b[0].depth > a[0].depth : true\n    /**\n     * Check if the setting is already correct.\n     */\n    if (b[0].__firstAtDepth !== __firstAtDepth) {\n      Transforms.setNodes(editor, { __firstAtDepth }, { at: b[1] })\n      return true\n    }\n    return false\n  })\n}\n","import { Editor, Node, NodeEntry } from \"slate\"\n\nimport { isListItem } from \"..\"\nimport { normalizeOrderedFirstAtDepth } from \"./normalize-ordered-first-at-depth\"\nexport * from \"./normalize-ordered-first-at-depth\"\n\nexport function normalizeNode(editor: Editor, entry: NodeEntry<Node>): boolean {\n  const [node] = entry\n  /**\n   * Short circuit return if current entry isn't any type of list item element.\n   */\n  if (!isListItem(node)) return false\n  return normalizeOrderedFirstAtDepth(editor, entry)\n}\n","import { clsx } from \"clsx\"\nimport { useEffect } from \"react\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { normalizeOrderedFirstAtDepth } from \"../normalize-node\"\nimport { OrderedListItemElement as OrderedListItemElement } from \"../types\"\nimport { $OrderedListItem } from \"./styles\"\n\nexport function OrderedListItem({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<OrderedListItemElement>) {\n  const editor = useSlateStatic()\n  useEffect(() => {\n    const path = ReactEditor.findPath(editor, element)\n    normalizeOrderedFirstAtDepth(editor, [element, path])\n  }, [])\n  const style = {\n    marginLeft: `${2 + element.depth * 2}em`,\n    \"--list-item-var\": `list-item-depth-${element.depth}`,\n  } as React.CSSProperties\n  const className = clsx({ \"--first-at-depth\": element.__firstAtDepth })\n  return (\n    <$OrderedListItem {...attributes} className={className} style={style}>\n      {children}\n    </$OrderedListItem>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nimport { isDebug } from \"../../sink\"\n\nconst $ListItem = styled(\"li\")`\n  margin-top: 0.5em;\n  margin-bottom: 0.5em;\n  list-style-position: outside;\n`\n\nexport const $UnorderedListItem = styled($ListItem)`\n  position: relative;\n  list-style-type: none;\n  .--list-item-icon {\n    position: absolute;\n    top: 0.25em;\n    left: -1.375em;\n    line-height: 1.5em;\n    color: var(--shade-600);\n  }\n`\n\nexport const $OrderedListItem = styled($ListItem)`\n  position: relative;\n  list-style-type: none;\n  counter-increment: var(--list-item-var);\n\n  &.--first-at-depth {\n    counter-reset: var(--list-item-var);\n    /**\n     * if isDebug is true, then show a highlight on list items that are marked\n     * as the first at a given depth.\n     */\n    background: ${isDebug ? \"rgba(0, 255, 0, 0.2)\" : \"inherit\"};\n  }\n\n  &:before {\n    position: absolute;\n    content: counter(var(--list-item-var)) \".\";\n    top: 0;\n    left: -2em;\n    width: 1.5em;\n    text-align: right;\n    color: var(--shade-500);\n    /* force numbers to be monospaced for better alignment */\n    font-variant-numeric: tabular-nums;\n  }\n`\n\nexport const $TaskListItem = styled($ListItem)`\n  position: relative;\n  list-style-type: none;\n  .--list-item-icon {\n    position: absolute;\n    top: 0.25em;\n    left: -1.5em;\n    line-height: 1.5em;\n    color: var(--shade-300);\n    .--checkmark {\n      color: green;\n      stroke-width: 3px;\n    }\n  }\n`\n","import { useCallback } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { TaskListItemElement } from \"../types\"\nimport { CheckedIcon, UncheckedIcon } from \"./list-icons\"\nimport { $TaskListItem } from \"./styles\"\n\nexport function TaskListItem({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<TaskListItemElement>) {\n  const editor = useSlateStatic()\n  const toggle = useCallback(() => {\n    editor.list.toggleTaskListItem({ at: element })\n  }, [editor, element])\n\n  const marginLeft = `${2 + element.depth * 2}em`\n  return (\n    <$TaskListItem {...attributes} style={{ marginLeft }}>\n      <div className=\"--list-item-icon\" contentEditable={false}>\n        {element.checked ? (\n          <CheckedIcon onClick={toggle} style={{ cursor: \"pointer\" }} />\n        ) : (\n          <UncheckedIcon onClick={toggle} style={{ cursor: \"pointer\" }} />\n        )}\n      </div>\n      {children}\n    </$TaskListItem>\n  )\n}\n","import { SVGProps } from \"react\"\n\n/**\n * https://tabler-icons.io/\n */\nexport const UncheckedIcon = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    width=\"1em\"\n    height=\"1em\"\n    strokeWidth={2}\n    stroke=\"currentColor\"\n    fill=\"none\"\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n    viewBox=\"0 0 24 24\"\n    {...props}\n  >\n    <path d=\"M0 0h24v24H0z\" stroke=\"none\" />\n    <rect x={4} y={4} width={16} height={16} rx={2} />\n  </svg>\n)\n\n/**\n * https://tabler-icons.io/\n */\nexport const CheckedIcon = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    className=\"icon icon-tabler icon-tabler-checkbox\"\n    width=\"1em\"\n    height=\"1em\"\n    strokeWidth={2}\n    stroke=\"currentColor\"\n    fill=\"none\"\n    strokeLinecap=\"round\"\n    strokeLinejoin=\"round\"\n    viewBox=\"0 0 24 24\"\n    {...props}\n  >\n    <path d=\"M0 0h24v24H0z\" stroke=\"none\" />\n    <path d=\"m9 11 3 3 8-8\" className=\"--checkmark\" />\n    <path d=\"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9\" />\n  </svg>\n)\n\n/**\n * Modified viewfinder-circle from https://heroicons.com/\n */\nexport const BulletIcon = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    viewBox=\"0 0 24 24\"\n    fill=\"currentColor\"\n    width=\"1em\"\n    height=\"1em\"\n    {...props}\n  >\n    <path d=\"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z\" />\n  </svg>\n)\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { UnorderedListItemElement } from \"../types\"\nimport { BulletIcon } from \"./list-icons\"\nimport { $UnorderedListItem } from \"./styles\"\n\nexport function UnorderedListItem({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<UnorderedListItemElement>) {\n  const marginLeft = `${2 + element.depth * 2}em`\n  return (\n    <$UnorderedListItem {...attributes} style={{ marginLeft }}>\n      <div className=\"--list-item-icon\" contentEditable={false}>\n        <BulletIcon />\n      </div>\n      {children}\n    </$UnorderedListItem>\n  )\n}\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { ListItemElement } from \"../types\"\nimport { OrderedListItem } from \"./ordered-list-item\"\nimport { TaskListItem } from \"./task-list-item\"\nimport { UnorderedListItem } from \"./unordered-list-item\"\n\nexport function renderElement({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<ListItemElement>) {\n  switch (element.type) {\n    case \"ordered-list-item\":\n      return (\n        <OrderedListItem element={element} attributes={attributes}>\n          {children}\n        </OrderedListItem>\n      )\n    case \"unordered-list-item\":\n      return (\n        <UnorderedListItem element={element} attributes={attributes}>\n          {children}\n        </UnorderedListItem>\n      )\n    case \"task-list-item\":\n      return (\n        <TaskListItem element={element} attributes={attributes}>\n          {children}\n        </TaskListItem>\n      )\n  }\n}\n","import { clsx } from \"clsx\"\nimport { Editor, Range } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createPlugin,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { createMarksMethods } from \"./methods\"\nimport { $MarksSpan } from \"./styles\"\n\nexport type MarksEditor = {\n  /**\n   * IMPORTANT:\n   *\n   * This cannot be named `marks` because it conflicts with the `editor.marks`\n   * built into the BaseEditor.j\n   */\n  marksPlugin: ReturnType<typeof createMarksMethods>\n  activeMarks?: {\n    bold?: boolean\n    italic?: boolean\n    underline?: boolean\n    strike?: boolean\n    highlight?: boolean\n  }\n}\n\nexport type MarksText = {\n  text: string\n  bold?: true\n  italic?: true\n  underline?: true\n  strike?: true\n  highlight?: true\n}\n\nexport type MarksPluginCustomTypes = {\n  Name: \"marks\"\n  Editor: MarksEditor\n  Text: MarksText\n}\n\nexport const MarksPlugin = createPlugin<MarksPluginCustomTypes>((editor) => {\n  editor.marksPlugin = createMarksMethods(editor)\n  editor.activeMarks = {}\n  const hotkeyHandler = createHotkeyHandler({\n    \"mod+b\": editor.marksPlugin.toggleBold,\n    \"mod+i\": editor.marksPlugin.toggleItalic,\n    \"mod+u\": editor.marksPlugin.toggleUnderline,\n    \"super+0\": editor.marksPlugin.removeMarks,\n    \"super+k\": editor.marksPlugin.toggleStrike,\n    \"mod+h\": editor.marksPlugin.toggleHighlight,\n  })\n  // Override insertText to apply active marks\n  const { insertText: defaultInsertText } = editor\n  editor.insertText = (text) => {\n    if (editor.activeMarks && Object.keys(editor.activeMarks).length > 0) {\n      const { activeMarks } = editor\n      // Apply marks before inserting text\n      Object.entries(activeMarks).forEach(([mark, isActive]) => {\n        if (isActive) {\n          editor.addMark(mark, true)\n        }\n      })\n    }\n    defaultInsertText(text)\n  }\n\n  // Override removeMarks to clear activeMarks at line end\n  const { removeMarks } = editor.marksPlugin\n  editor.marksPlugin.removeMarks = () => {\n    removeMarks()\n    if (editor.selection && Range.isRange(editor.selection)) {\n      const point = editor.selection.focus\n      const isAtLineEnd = Editor.after(editor, point) === null ||\n        Editor.isEnd(editor, point, Editor.end(editor, []))\n      if (isAtLineEnd) {\n        editor.activeMarks = {}\n      }\n    }\n  }\n\n  return {\n    name: \"marks\",\n    editableProps: {\n      renderLeaf: ({ leaf, children }) => {\n        return (\n          <$MarksSpan\n            className={clsx({\n              \"--bold\": leaf.bold,\n              \"--italic\": leaf.italic,\n              \"--underline\": leaf.underline,\n              \"--strike\": leaf.strike,\n              \"--highlight\": leaf.highlight,\n            })}\n          >\n            {children}\n          </$MarksSpan>\n        )\n      },\n      onKeyDown: (e) => {\n        if (hotkeyHandler(e)) return true\n        // if (\n        //   autocompleteMarker(editor, e, {\n        //     triggerMarker: \"`\",\n        //     regexp: /([`])(\\S.*?)([`])$/,\n        //     mark: \"code\",\n        //   })\n        // ) {\n        //   return true\n        // }\n        // if (\n        //   autocompleteMarker(editor, e, {\n        //     triggerMarker: \"*\",\n        //     regexp: /([*])(.+?)([*])$/,\n        //     mark: \"italic\",\n        //   })\n        // ) {\n        //   return true\n        // }\n        return false\n      },\n    },\n  }\n}) as TypedPlugin<MarksPluginCustomTypes>\n\n// function autocompleteMarker(\n//   editor: Editor,\n//   e: React.KeyboardEvent<HTMLDivElement>,\n//   {\n//     triggerMarker,\n//     regexp,\n//     mark,\n//   }: { triggerMarker: string; regexp: RegExp; mark: keyof Text }\n// ): boolean {\n//   /**\n//    * Make sure theere is a selection and it's collapsed\n//    */\n//   console.log(\n//     { triggerMarker, mark },\n//     e.key,\n//     e.which,\n//     toKeyCode(\"*\"),\n//     toKeyName(\"*\"),\n//     isHotkey(\"*\", { byKey: true })(e.nativeEvent)\n//   )\n//   if (editor.selection === null) return false\n//   if (Range.isExpanded(editor.selection)) return false\n//   /**\n//    * WHAT I'M WORKING ON:\n//    *\n//    * So, basically, `is-hotkey` doesn't work with an asterisk. We need to find\n//    * an alternate way of testing but it's a little tricky and there are a few\n//    * approaches we can take:\n//    *\n//    * - The first approach is to write our own key checker, but be careful\n//    *   because we want to make sure we aren't interception hotkeys with modifier\n//    *   keys for example. Like CMD+OPTION+8 should not trigger the `*` trigger.\n//    *\n//    * - NOTE: tested and paste does not trigger insertText. The second approach\n//    *   is to tie into `insertText` instead. This may be a more reliable method\n//    *   but we also need to at least think about whether insertText gets\n//    *   triggered during a paste event, for example, and if it does, that would\n//    *   be weird to have that suddenly bold some text.\n//    *\n//    */\n//   // if (isHotkey(triggerMarker, e.nativeEvent)) {\n//   if (isHotkey(triggerMarker, e.nativeEvent)) {\n//     console.log(\"triggered\")\n//     stopEvent(e)\n//     const markerText = triggerMarker\n//     Transforms.insertText(editor, markerText)\n//     const { selection } = editor\n\n//     /**\n//      * Make sure we are in a block that is not void.\n//      */\n//     const blockEntry = findElementUp(\n//       editor,\n//       (node) =>\n//         Element.isElement(node) &&\n//         !Editor.isVoid(editor, node) &&\n//         Editor.isBlock(editor, node)\n//     )\n//     if (blockEntry == null) return true\n\n//     /**\n//      * Grab all the text from the beginning of the block until now\n//      */\n//     const range = {\n//       anchor: Editor.start(editor, blockEntry[1]),\n//       focus: selection.focus,\n//     }\n//     const text = Editor.string(editor, range)\n\n//     /**\n//      * See if the text matches our pattern\n//      */\n//     const match = text.match(regexp)\n//     if (match == null) return true\n//     if (match.length !== 4)\n//       throw new Error(\n//         `Expected the RegExp to have 3 grouped subexpressions but returned ${\n//           match.length - 1\n//         }`\n//       )\n\n//     /**\n//      * Delete the closing markers\n//      */\n//     const closingMarkersRange = getRangeBackwards(\n//       editor,\n//       editor.selection.focus,\n//       match[3].length\n//     )\n//     Transforms.delete(editor, { at: closingMarkersRange })\n\n//     /**\n//      * Delete the opening markers\n//      */\n//     const openingMarkersRange = getRangeBackwards(\n//       editor,\n//       editor.selection.focus,\n//       match[2].length + match[3].length,\n//       match[2].length\n//     )\n//     Transforms.delete(editor, { at: openingMarkersRange })\n\n//     /**\n//      * Create a range that represents the selected text\n//      */\n//     const matchRange = getRangeBackwards(\n//       editor,\n//       editor.selection.focus,\n//       match[2].length\n//     )\n\n//     /**\n//      * Feels like `withoutMerging` should work but if we undo twice after this,\n//      * causes a crash.\n//      *\n//      * This looks like a good solution that isn't in main\n//      * https://github.com/ianstormtaylor/slate/issues/3874\n//      *\n//      * NOTE:\n//      *\n//      * Manually calling `editor.onChange()` won't work\n//      *\n//      * An appropriate starting point for searching more in issues\n//      * https://github.com/ianstormtaylor/slate/issues?q=is%3Aissue+withoutMerging+is%3Aclosed\n//      */\n//     editor.marksPlugin.toggleMark(mark, undefined, { at: matchRange })\n\n//     return true\n//   }\n//   return false\n// }\n\n// function getRangeBackwards(\n//   editor: Editor,\n//   point: Point,\n//   startDistance: number,\n//   endDistance?: number\n// ) {\n//   const startPoint = Editor.before(editor, point, {\n//     unit: \"character\",\n//     distance: startDistance,\n//   })\n//   const endPoint =\n//     endDistance === undefined\n//       ? point\n//       : Editor.before(editor, point, {\n//           unit: \"character\",\n//           distance: endDistance,\n//         })\n//   if (!startPoint)\n//     throw new Error(\n//       `startPoint not found. The distance backward from the point may be invalid.`\n//     )\n//   if (!endPoint)\n//     throw new Error(\n//       `endPoint not found. The distance backward from the point may be invalid.`\n//     )\n//   return {\n//     anchor: startPoint,\n//     focus: endPoint,\n//   }\n// }\n","import { Editor, Location, Text, Transforms } from \"slate\"\n\n/**\n * Toggles a mark.\n *\n * Certain marks may not be able to co-exist with another mark. For example,\n * superscript and subscript cannot be applied at the same time. In these\n * cases, you can provide a final argument of `unsetKey` that when the mark\n * is toggled on, the `unsetKey` mark is toggled off automatically. When the\n * mark is toggled off, it will ignore the `unsetKey`\n */\n\nexport function removeMarks(\n  editor: Editor,\n  { at = editor.selection }: { at?: Location | null } = {}\n) {\n  if (at == null) return\n  const nodeEntries = [\n    ...Editor.nodes(editor, {\n      match: (n) => Text.isText(n),\n      at,\n    }),\n  ]\n  const setter: Record<string, null> = {}\n  for (const [node] of nodeEntries) {\n    for (const key of Object.keys(node)) {\n      if (key === \"text\") continue\n      setter[key] = null\n    }\n  }\n  Transforms.setNodes(editor, setter, {\n    match: (n) => Text.isText(n),\n    split: true,\n    at,\n  })\n}\n","import { Editor, Location, Point, Range, Text } from \"slate\"\n\n/**\n * Toggles a mark.\n *\n * Certain marks may not be able to co-exist with another mark. For example,\n * superscript and subscript cannot be applied at the same time. In these\n * cases, you can provide a final argument of `unsetKey` that when the mark\n * is toggled on, the `unsetKey` mark is toggled off automatically. When the\n * mark is toggled off, it will ignore the `unsetKey`\n */\n\nexport function toggleMark(\n  editor: Editor,\n  markKey: keyof Text,\n  unsetKey?: keyof Text,\n  { at = editor.selection }: { at?: Location | null } = {}\n) {\n  if (at == null) return\n\n  // Check if selection is at end of line\n  const point = Range.isRange(at) ? at.focus : at\n  const isAtLineEnd = Point.isPoint(point) && (\n    Editor.after(editor, point) === null || \n    Editor.isEnd(editor, point, Editor.end(editor, []))\n  )\n\n  const validMarkKey = markKey as 'bold' | 'italic' | 'underline' | 'strike'\n  const marks = Editor.marks(editor) || {}\n  const isActive = marks[validMarkKey] === true\n\n  // Store mark state for next insert if at line end\n  if (isAtLineEnd) {\n    if (!isActive) {\n      // Turning mark on\n      editor.activeMarks = {\n        ...editor.activeMarks,\n        [validMarkKey]: true\n      }\n    } else {\n      // Turning mark off\n      const { [validMarkKey]: _unused, ...remainingMarks } = editor.activeMarks || {}\n      void _unused\n      editor.activeMarks = remainingMarks\n    }\n  }\n\n  // Toggle mark in current selection\n  if (isActive) {\n    Editor.removeMark(editor, validMarkKey)\n  } else {\n    Editor.addMark(editor, validMarkKey, true)\n  }\n\n  // Handle unset key if provided\n  if (typeof unsetKey === \"string\") {\n    Editor.removeMark(editor, unsetKey)\n  }\n}\n","import { Editor } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { removeMarks } from \"./removeMarks\"\nimport { toggleMark } from \"./toggle-mark\"\n\nexport function createMarksMethods(editor: Editor) {\n  return {\n    removeMarks: curryOne(removeMarks, editor),\n    toggleMark: curryOne(toggleMark, editor),\n    toggleBold: () => toggleMark(editor, \"bold\"),\n    toggleItalic: () => toggleMark(editor, \"italic\"),\n    toggleUnderline: () => toggleMark(editor, \"underline\"),\n    toggleStrike: () => toggleMark(editor, \"strike\"),\n    toggleHighlight: () => toggleMark(editor, \"highlight\"),\n  }\n}\n","import styled from \"@emotion/styled\"\n\nexport const $MarksSpan = styled(\"span\")`\n  &.--bold {\n    font-weight: bold;\n  }\n  &.--italic {\n    font-style: italic;\n  }\n  &.--underline {\n    text-decoration: underline;\n  }\n  &.--strike {\n    text-decoration: line-through;\n  }\n  /**\n   * Text decorations don't merge automatically so we make a special one\n   * when there is both an underline and a strike through.\n   */\n  &.--underline.--strike {\n    text-decoration: underline line-through;\n  }\n  &.--highlight {\n    background-color: #ffff00;\n  }\n`\n","import { Editor, Point } from \"slate\"\n\nimport { createPlugin, forceNormalizePath, TypedPlugin } from \"../sink\"\n\nexport type NormalizeAfterDeleteEditor = {\n  normalizeAfterDelete: true\n}\n\nexport type NormalizeAfterDeletePluginCustomTypes = {\n  Name: \"normalize-after-delete\"\n  Editor: NormalizeAfterDeleteEditor\n}\n\nfunction forceNormalizeNearestElement(editor: Editor) {\n  if (!editor.selection) return\n  const entry = Editor.parent(editor, editor.selection)\n  forceNormalizePath(editor, entry[1])\n}\n\n/**\n * The purpose of this plugin is to have the Slate normalizer execute when an\n * Element is deleted. When text is deleted, the normalizer executes properly\n * but if an entire element is deleted, Slate behaves as if no normalization\n * is required.\n *\n * This fails us in a few normalization scenarios:\n *\n * - The normalizer needs to run when a sibling (previous or next) changes.\n * - The normalizer needs to run when a child is removed\n *\n * The plugin takes a few steps to make things more efficient. Namely, it only\n * executes a normalization if we are deleting backwards and we are at the\n * start of an element, or deleting forwards and we are at the end of an\n * Element. If neither of these are true, the delete will cause a normalzation\n * on its own because the text will have changed.\n */\nexport const NormalizeAfterDeletePlugin =\n  createPlugin<NormalizeAfterDeletePluginCustomTypes>((editor) => {\n    editor.normalizeAfterDelete = true\n    return {\n      name: \"normalize-after-delete\",\n      editor: {\n        deleteBackward() {\n          if (!editor.selection) return false\n          const entry = Editor.parent(editor, editor.selection)\n          const isStart = Point.equals(\n            Editor.start(editor, entry[1]),\n            editor.selection.anchor\n          )\n          if (!isStart) return false\n          return function () {\n            forceNormalizeNearestElement(editor)\n          }\n        },\n        deleteForward() {\n          if (!editor.selection) return false\n          const entry = Editor.parent(editor, editor.selection)\n          const isEnd = Point.equals(\n            Editor.end(editor, entry[1]),\n            editor.selection.anchor\n          )\n          if (!isEnd) return false\n          return function () {\n            forceNormalizeNearestElement(editor)\n          }\n        },\n      },\n      editableProps: {},\n    }\n  }) as TypedPlugin<NormalizeAfterDeletePluginCustomTypes>\n","import { Element, NodeEntry } from \"slate\"\n\nimport {\n  createHotkeyHandler,\n  createPlugin,\n  findElementUp,\n  isEndOfElement,\n  isStartOfElement,\n  TypedPlugin,\n} from \"../sink\"\n\nimport { deleteFragmentWithProtectedTypes } from \"./delete-fragment\"\nimport { createTableMethods } from \"./methods\"\nimport { normalizeTableIndexes } from \"./normalize/normalize-table\"\nimport { normalizeTableCell } from \"./normalize/normalize-table-cell\"\nimport { renderElement } from \"./render-element\"\nimport {\n  TableCellElement,\n  TableContentElement,\n  TableElement,\n  TableRowElement,\n} from \"./types\"\n\nexport * from \"./types\"\n\nexport type TableEditor = {\n  supportsTable: true\n  tablePlugin: ReturnType<typeof createTableMethods>\n}\n\nexport type TablePluginCustomTypes = {\n  Name: \"table\"\n  Editor: TableEditor\n  Element:\n  | TableElement\n  | TableRowElement\n  | TableCellElement\n  | TableContentElement\n}\n\nexport const TablePlugin = createPlugin<TablePluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    editor.supportsTable = true\n    editor.tablePlugin = createTableMethods(editor)\n    return createPolicy({\n      name: \"table\",\n      editor: {\n        deleteBackward: () => {\n          /**\n           * If we're at start of a cell, disable delete backward because we\n           * don't want the cell to be deleted.\n           */\n          return isStartOfElement(editor, \"table-cell\")\n        },\n        deleteForward: () => {\n          /**\n           * If we're at end of a cell, disable delete forward because we don't\n           * want the cell to be deleted.\n           */\n          return isEndOfElement(editor, \"table-cell\")\n        },\n        deleteFragment: () =>\n          deleteFragmentWithProtectedTypes(editor, [\"table-cell\"]),\n        insertBreak: () => {\n          /**\n           * IF we're anywhere in a table cell, insert a soft break instead\n           */\n          const entry = findElementUp(editor, \"table-cell\")\n          if (entry) {\n            editor.insertText(\"\\n\")\n            return true\n          }\n          return false\n        },\n        isMaster(element) {\n          if (element.type === \"table\") return true\n        },\n        normalizeNode: (entry): boolean => {\n          const [node] = entry\n          if (!Element.isElement(node)) return false\n          switch (node.type) {\n            case \"table\":\n              return normalizeTableIndexes(\n                editor,\n                entry as NodeEntry<TableElement>\n              )\n            case \"table-cell\": {\n              return normalizeTableCell(\n                editor,\n                entry as NodeEntry<TableCellElement>\n              )\n            }\n          }\n          return false\n        },\n      },\n      editableProps: {\n        renderElement,\n        onKeyDown: createHotkeyHandler({\n          /**\n           * navigation\n           */\n          tab: editor.tablePlugin.tabForward,\n          \"shift+tab\": editor.tablePlugin.tabBackward,\n          \"shift+enter\": editor.tablePlugin.shiftEnterForward,\n          down: editor.tablePlugin.down,\n          up: editor.tablePlugin.up,\n          /**\n           * selection\n           */\n          \"mod+a\": editor.tablePlugin.selectCell,\n          /**\n           * insert\n           */\n          \"super+t\": () => editor.tablePlugin.insertTable(3, 2),\n          \"mod+shift+enter\": () => editor.tablePlugin.insertRow({ offset: 0 }),\n          \"mod+enter\": () => editor.tablePlugin.insertRow({ offset: 1 }),\n          \"super+[\": () => editor.tablePlugin.insertColumn({ offset: 0 }),\n          \"super+]\": () => editor.tablePlugin.insertColumn({ offset: 1 }),\n          /**\n           * remove\n           */\n          \"super+backspace\": editor.tablePlugin.removeTable,\n          \"mod+backspace\": editor.tablePlugin.removeRow,\n          \"mod+shift+backspace\": editor.tablePlugin.removeColumn,\n        }),\n      },\n    })\n  }\n) as TypedPlugin<TablePluginCustomTypes>\n","import { Editor, Path, Transforms } from \"slate\"\n\nimport { findElementUpPath } from \"../../sink\"\n\nimport { getReversedDeleteSafeRanges } from \"./get-reversed-delete-safe-ranges\"\n\n/**\n * This is a special version of deleteFragment that respects elements of the\n * given `protectedTypes` so that they aren't deleted whole and only their\n * children are deleted.\n *\n * This is used in cases like a `table-cell` where we want to protect the\n * shape of the `table`.\n *\n * If the start or end of the deletion range isn't in a protectedType, we don't\n * need to anything special so we let the default delete handle it.\n *\n * If the start or end of the deletion range is in a protectedType but it is\n * the same Element, then the default handler works fine too.\n *\n * In other cases, we break down the full deletion range into multiple ranges.\n * Each range won't go across a protectedType. In effect, this means that we\n * only delete the content of protectedTypes and we do the regular deletes\n * across everything else.\n */\nexport function deleteFragmentWithProtectedTypes(\n  editor: Editor,\n  protectedTypes: string[]\n) {\n  if (editor.selection == null) return false\n  const [start, end] = Editor.edges(editor, editor.selection)\n  const startProtectedPath = findElementUpPath(editor, protectedTypes, {\n    at: start,\n  })\n  const endProtectedPath = findElementUpPath(editor, protectedTypes, {\n    at: end,\n  })\n  /**\n   * If the start or the end of the selection isn't in a protectedType element\n   * then just do a normal delete so we return `false`.\n   */\n  if (!startProtectedPath && !endProtectedPath) {\n    return false\n  }\n\n  /**\n   * If the start and end are in the same protectedType element, then the\n   * default handler works fine so return `false`\n   */\n  if (\n    startProtectedPath &&\n    endProtectedPath &&\n    Path.equals(startProtectedPath, endProtectedPath)\n  ) {\n    return false\n  }\n\n  /**\n   * Breaks the range to delete into chunks of ranges that are safe to delete.\n   * We do this by not allowing a deletion across one of the `protectedTypes`\n   */\n  const reversedRanges = getReversedDeleteSafeRanges(\n    editor,\n    editor.selection,\n    protectedTypes\n  )\n\n  /**\n   * We iterate through the ranges backwards deleting each delete safe range.\n   * At the end, we collapse the originally selected deletion range to the\n   * front.\n   *\n   * NOTE:\n   *\n   * Ideally, we'd actually collapse this to the start or end depending on the\n   * direction of the delete; however, that information is not presently\n   * provided to us. Might be a small improvement in the future that requires\n   * us to update Slate.\n   */\n  Editor.withoutNormalizing(editor, () => {\n    for (const range of reversedRanges) {\n      Transforms.delete(editor, { at: range })\n    }\n    Transforms.collapse(editor, { edge: \"start\" })\n  })\n\n  return true\n}\n","import { BasePoint, Editor, Path, Range } from \"slate\"\n\nimport { findElementUpPath } from \"../../sink\"\n\nexport function getReversedDeleteSafeRanges(\n  editor: Editor,\n  deleteRange: Range,\n  protectedTypes: string[]\n): Range[] {\n  /**\n   * Editor.positions returns a bunch of positions which essentially represent\n   * the start and end of Nodes with the exception of the start of the passed\n   * in Range and the end of the passed in Range.\n   */\n  const positions = [...Editor.positions(editor, { at: deleteRange })]\n\n  /**\n   * We create our own set of deleteSafeRanges here\n   */\n  const deleteSafeRanges: Range[] = []\n\n  let startPos: BasePoint, prevPos: BasePoint, startTdPath: Path | undefined\n  startPos = prevPos = positions[0]\n  startTdPath = findElementUpPath(editor, protectedTypes, {\n    at: startPos,\n  })\n\n  for (const pos of positions) {\n    const tdPath = findElementUpPath(editor, protectedTypes, {\n      at: pos,\n    })\n    /**\n     * What we're looking for is that if we search for a protectedType from\n     * this point, and the protectedType is the same as the prvious point we\n     * looked at, then keep going.\n     *\n     * We keep track of the `prevPos` though because when we are in a different\n     * protectedType (or switch to not being in one) then we need the `prevPos`\n     */\n    if (\n      (startTdPath && tdPath && Path.equals(startTdPath, tdPath)) ||\n      (startTdPath == undefined && tdPath == undefined)\n    ) {\n      prevPos = pos\n    } else {\n      /**\n       * Once we see a difference (i.e. a new protectedType or we switch to\n       * being or not being in a protectedType) then we create a Range and\n       * add it to `deleteSafeRanges`.\n       *\n       * We also reset some of our variables that we are tracking.\n       */\n      const range = { anchor: startPos, focus: prevPos }\n      deleteSafeRanges.push(range)\n      startPos = prevPos = pos\n      startTdPath = tdPath\n    }\n  }\n  const range = { anchor: startPos, focus: prevPos }\n  deleteSafeRanges.push(range)\n  deleteSafeRanges.reverse()\n  return deleteSafeRanges\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt, curryOne } from \"../../sink\"\n\nimport { getTableInfo } from \"./get-table-info\"\nimport { insertColumn } from \"./insert-column\"\nimport { insertRow } from \"./insert-row\"\nimport { insertTable } from \"./insert-table\"\nimport { down, up } from \"./navigation\"\nimport { removeColumn } from \"./remove-column\"\nimport { removeRow } from \"./remove-row\"\nimport { removeTable } from \"./remove-table\"\nimport { setTableColumnAlign } from \"./setTableColumnAlign\"\nimport { shiftEnterForward, tabBackward, tabForward } from \"./tab\"\n\nexport function createTableMethods(editor: Editor) {\n  return {\n    getTableInfo: curryOne(getTableInfo, editor),\n    insertTable: curryOne(insertTable, editor),\n    insertColumn: curryOne(insertColumn, editor),\n    insertRow: curryOne(insertRow, editor),\n    removeTable: curryOne(removeTable, editor),\n    removeColumn: curryOne(removeColumn, editor),\n    removeRow: curryOne(removeRow, editor),\n    tabForward: curryOne(tabForward, editor),\n    tabBackward: curryOne(tabBackward, editor),\n    shiftEnterForward: curryOne(shiftEnterForward, editor),\n    selectCell: curryOne(selectCell, editor),\n    down: curryOne(down, editor),\n    up: curryOne(up, editor),\n    setTableColumnAlign: curryOne(setTableColumnAlign, editor),\n  }\n}\n\nfunction selectCell(\n  editor: Editor,\n  { at = editor.selection }: { at?: BetterAt } = {}\n) {\n  const t = getTableInfo(editor, { at })\n  if (t === undefined) return false\n  const { cellPath } = t\n  Transforms.select(editor, cellPath)\n  return true\n}\n","import { Editor, Element, Location, Path } from \"slate\"\n\nimport { findElementUp } from \"../../sink\"\n\nimport {\n  TableCellElement,\n  TableColumn,\n  TableElement,\n  TableRowElement,\n} from \"../types\"\n\n/**\n * The TableInfo object that includes quick access information starting from a\n * cell in a table including information about the row and the table.\n *\n * NOTE:\n *\n * This is flat and not nested because it makes destructuring easier, for\n * example, in the table methods.\n */\nexport type TableInfo = {\n  tableElement: TableElement\n  tablePath: Path\n  tableColumns: TableColumn[]\n  rowElement: TableRowElement\n  rowPath: Path\n  rowIndex: number\n  rowCount: number\n  cellElement: TableCellElement\n  cellPath: Path\n  cellIndex: number\n  cellCount: number\n}\n\n/**\n * get table info\n */\n\nexport function getTableInfo(\n  editor: Editor,\n  { at = editor.selection }: { at?: Location | Element | null } = {}\n): TableInfo | undefined {\n  if (at == null) return undefined\n  const cellMatch = findElementUp<TableCellElement>(editor, \"table-cell\", {\n    at,\n  })\n  if (!cellMatch) return undefined\n  const rowMatch = findElementUp<TableRowElement>(editor, \"table-row\", {\n    at,\n  })\n  if (!rowMatch) return undefined\n  const tableMatch = findElementUp<TableElement>(editor, \"table\", { at })\n  if (!tableMatch) return undefined\n  const [tableElement, tablePath] = tableMatch\n  const [rowElement, rowPath] = rowMatch\n  const [cellElement, cellPath] = cellMatch\n  return {\n    tableElement,\n    tablePath,\n    tableColumns: tableElement.columns,\n    rowElement,\n    rowPath,\n    rowIndex: rowPath.slice(-1)[0],\n    rowCount: tableElement.children.length,\n    cellElement,\n    cellPath,\n    cellIndex: cellPath.slice(-1)[0],\n    cellCount: rowElement.children.length,\n  }\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt } from \"../../sink\"\n\nimport { getTableInfo } from \"./get-table-info\"\nimport { createCell } from \"./utils\"\n\nexport function insertColumn(\n  editor: Editor,\n  { offset = 0, at = editor.selection }: { offset?: 0 | 1; at?: BetterAt } = {}\n): boolean {\n  const t = getTableInfo(editor, { at })\n  if (t === undefined) return false\n  const { tableElement, tablePath, cellIndex } = t\n  const nextCellIndex = cellIndex + offset\n  Editor.withoutNormalizing(editor, () => {\n    const { columns } = tableElement\n    const nextColumns = [...columns]\n    /**\n     * Insert a Column into `TableElement.columns` which is the same as the\n     * value of the current column. This is the `alignment` of the column.\n     */\n    const sourceIndex = Math.min(nextCellIndex, columns.length - 1)\n    nextColumns.splice(nextCellIndex, 0, columns[sourceIndex])\n    Transforms.setNodes(editor, { columns: nextColumns }, { at: tablePath })\n\n    /**\n     * Insert a `TableCell` at the correct spot.\n     */\n    tableElement.children.forEach((_rowElement, i) => {\n      Transforms.insertNodes(editor, createCell(nextCellIndex), {\n        at: [...tablePath, i, nextCellIndex],\n      })\n    })\n  })\n  return true\n}\n\n// export function insertColumnLeft(\n//   editor: Editor,\n//   { at }: { at?: MatchAt } = {}\n// ) {\n//   return insertColumn(editor, { at })\n// }\n\n// export function insertColumnRight(\n//   editor: Editor,\n//   { at }: { at?: MatchAt } = {}\n// ) {\n//   return insertColumn(editor, { at, offset: 1 })\n// }\n","import { TableCellElement, TableContentElement } from \"../types\"\n\nexport function createCell(\n  _index: number,\n  children: TableContentElement[] = [\n    {\n      type: \"table-content\",\n      children: [{ text: \"\" }],\n    },\n  ]\n): TableCellElement {\n  return {\n    type: \"table-cell\",\n    children,\n  }\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt } from \"../../sink\"\n\nimport { TableRowElement } from \"../types\"\nimport { getTableInfo } from \"./get-table-info\"\nimport { createCell } from \"./utils\"\n\nfunction createRow(columnCount: number): TableRowElement {\n  return {\n    type: \"table-row\",\n    children: [...Array(columnCount).keys()].map((index) => createCell(index)),\n  }\n}\n\n/**\n * Used internally for `insertRowAbove` and `insertRowBelow` to do an insert\n * with an offset to improve code reused.\n */\nexport function insertRow(\n  editor: Editor,\n  { at = editor.selection, offset = 0 }: { at?: BetterAt; offset?: 0 | 1 } = {}\n): boolean {\n  const t = getTableInfo(editor, { at })\n  if (!t) return false\n  const nextRowElement = createRow(t.tableElement.columns.length)\n  Transforms.insertNodes(editor, nextRowElement, {\n    at: [...t.tablePath, t.rowIndex + offset],\n  })\n  return true\n}\n\n/**\n * Insert row above current selection\n */\nexport function insertRowAbove(\n  editor: Editor,\n  { at }: { at?: BetterAt } = {}\n): boolean {\n  return insertRow(editor, { at })\n}\n\n/**\n * Insert row below current selection\n */\nexport function insertRowBelow(\n  editor: Editor,\n  { at }: { at?: BetterAt } = {}\n): boolean {\n  return insertRow(editor, { at, offset: 1 })\n}\n","import { Editor, Element, Location, Path, Transforms } from \"slate\"\n\nimport { findElementUp } from \"../../sink\"\n\nimport { TableColumn, TableElement, TableRowElement } from \"../types\"\nimport { createCell } from \"./utils\"\n\nfunction createRange(size: number): number[] {\n  return [...Array(size).keys()]\n}\n\nfunction createColumns(columnCount: number): TableColumn[] {\n  return createRange(columnCount).map(() => ({ align: \"left\" }))\n}\n\nfunction createTable(columnCount: number, rowCount: number): TableElement {\n  return {\n    type: \"table\",\n    columns: createColumns(columnCount),\n    children: createRange(rowCount).map(() => createRow(columnCount)),\n  }\n}\n\nfunction createRow(columnCount: number): TableRowElement {\n  return {\n    type: \"table-row\",\n    children: [...Array(columnCount).keys()].map((index) => createCell(index)),\n  }\n}\n\n/**\n * Used internally for `insertRowAbove` and `insertRowBelow` to do an insert\n * with an offset to improve code reused.\n */\nexport function insertTable(\n  editor: Editor,\n  columnCount: number,\n  rowCount: number,\n  { at = editor.selection }: { at?: Location | null } = {}\n): boolean {\n  const table = createTable(columnCount, rowCount)\n  return insertRootElement(editor, table, { at })\n}\n\nexport function insertRootElement(\n  editor: Editor,\n  element: Element,\n  { at = editor.selection }: { at?: Location | null } = {}\n) {\n  if (at == null) return false\n  const entry = findElementUp(\n    editor,\n    (node) => Element.isElement(node) && editor.isMaster(node)\n  )\n  if (entry == null) {\n    const selection = editor.selection\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, element, { at })\n      if (selection) {\n        Transforms.select(editor, selection)\n        Transforms.move(editor)\n      }\n    })\n  } else {\n    const nextPath = Path.next(entry[1])\n    Editor.withoutNormalizing(editor, () => {\n      Transforms.insertNodes(editor, element, { at: nextPath })\n      Transforms.select(editor, Editor.start(editor, nextPath))\n    })\n  }\n  return true\n}\n","import { Editor, Path } from \"slate\"\n\nimport { selectEndOfElement, selectStartOfElement } from \"../../../sink\"\n\nimport { TableInfo } from \"../get-table-info\"\n\nexport function selectElementBelow(editor: Editor, t: TableInfo) {\n  const { cellIndex, rowIndex, rowCount, tablePath } = t\n  /**\n   * if we aren't in the last row of a table, move down a row\n   */\n  if (rowIndex < rowCount - 1) {\n    selectStartOfElement(editor, [...tablePath, rowIndex + 1, cellIndex])\n    return true\n  }\n  /**\n   * If we are in the last row of a table, move to the start of the Element\n   * after the table\n   */\n  try {\n    selectStartOfElement(editor, Path.next(tablePath))\n    return true\n  } catch {\n    return false\n  }\n}\n\nexport function selectElementAbove(editor: Editor, t: TableInfo) {\n  const { cellIndex, rowIndex, tablePath } = t\n  /**\n   * if we aren't in the first row of a table, move up a row\n   */\n  if (rowIndex > 0) {\n    selectStartOfElement(editor, [...tablePath, rowIndex - 1, cellIndex])\n    return true\n  }\n  /**\n   * If we are in the first row of a table, move to the end of the Element\n   * before the table\n   */\n  try {\n    selectEndOfElement(editor, Path.previous(tablePath))\n    return true\n  } catch {\n    return false\n  }\n}\n","import { Descendant, Editor, Element } from \"slate\"\nimport { ReactEditor } from \"slate-react\"\n\n/**\n * This is named with `...Unreliable...` because at the beginning of a line\n * (e.g. the second line of a paragraph) the DOMRect returned will be for a\n * position at the end of the previous line.\n *\n * So why have an unreliable version? Because, there actually is no reliable\n * version and the unreliable one works in most cases. It's better than not\n * having an unreliable selection rect.\n *\n * So it's useful, but we need to handle the case where it's on the end of the\n * previous line instead of the beginning of the line.\n *\n * NOTE:\n *\n * Inserting a `span` and removing it does not work. We can kind of getting it\n * to work by inserting a span with some with (like has the letter \"A\") inside.\n * It will then sometimes switch the problem so that the DOMRect return is on\n * the next line instead of the previous; however, makes the cursor move into\n * the wrong position when cursoring down the right side and this is worse than\n * the problem is solves.\n */\nexport function getUnreliableSelectionRect(): DOMRect | null {\n  const s = window.getSelection()\n  if (!s || s.rangeCount === 0) return null\n  try {\n    const range = s.getRangeAt(0)\n    return range.getBoundingClientRect()\n  } catch {\n    return null\n  }\n}\n\n/**\n * Takes a Slate Element and returns a DOMRect representing the Element as\n * it is in the DOM.\n */\nfunction getElementRect(editor: Editor, element: Descendant) {\n  return ReactEditor.toDOMNode(editor, element).getBoundingClientRect()\n}\n\nexport function checkIsInElement(editor: Editor, element: Element): boolean {\n  /**\n   * Get the unreliable selection rect. If there is no selection, we consider\n   * that the selection is not in the last line which will usually indicates\n   * default behavior.\n   */\n  const selectionRect = getUnreliableSelectionRect()\n  if (!selectionRect) return false\n  const elementRect = getElementRect(editor, element)\n  return (\n    selectionRect.right < elementRect.right &&\n    selectionRect.left > elementRect.left &&\n    selectionRect.bottom < elementRect.bottom &&\n    selectionRect.top > elementRect.top\n  )\n}\n","import { Editor } from \"slate\"\n\nimport { getTableInfo } from \"../get-table-info\"\nimport { selectElementAbove, selectElementBelow } from \"./select-element\"\nimport { checkIsInElement } from \"./utils\"\n\n/**\n * arrow down\n */\nexport function down(editor: Editor): boolean {\n  const t = getTableInfo(editor)\n  /**\n   * don't handle if we're not in a table\n   */\n  if (!t) return false\n  setTimeout(() => {\n    if (!checkIsInElement(editor, t.cellElement)) {\n      selectElementBelow(editor, t)\n    }\n  })\n  return false\n}\n\n/**\n * arrow up\n */\nexport function up(editor: Editor): boolean {\n  const t = getTableInfo(editor)\n  /**\n   * don't handle if we're not in a table\n   */\n  if (!t) return false\n  setTimeout(() => {\n    if (!checkIsInElement(editor, t.cellElement)) {\n      selectElementAbove(editor, t)\n    }\n  })\n  return false\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt } from \"../../sink\"\n\nimport { getTableInfo } from \"./get-table-info\"\nimport { removeTable } from \"./remove-table\"\n\nexport function removeColumn(\n  editor: Editor,\n  { at = editor.selection }: { at?: BetterAt } = {}\n) {\n  const t = getTableInfo(editor, { at })\n  if (!t) return false\n\n  const { tableElement, tablePath, rowIndex, cellIndex, cellCount } = t\n  if (cellCount === 1) {\n    return removeTable(editor)\n  }\n  Editor.withoutNormalizing(editor, () => {\n    // Set the new `align` value based on the current `td` column (not the position\n    // to insert at)\n    const columns = [...tableElement.columns]\n    columns.splice(cellIndex, 1)\n    Transforms.setNodes(editor, { columns }, { at: tablePath })\n    tableElement.children.forEach((_rowElement, rowIndex) => {\n      Transforms.removeNodes(editor, {\n        at: [...tablePath, rowIndex, cellIndex],\n      })\n    })\n    const selection = Editor.start(editor, [\n      ...tablePath,\n      rowIndex,\n      Math.min(cellIndex, cellCount - 2),\n    ])\n    Transforms.select(editor, selection)\n  })\n}\n","import { Editor, Transforms } from \"slate\"\n\nexport function removeTable(editor: Editor): boolean {\n  const t = editor.tablePlugin.getTableInfo()\n  if (t === undefined) return false\n  Transforms.removeNodes(editor, { at: t.tablePath })\n  return true\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { BetterAt } from \"../../sink\"\n\nimport { getTableInfo } from \"./get-table-info\"\nimport { removeTable } from \"./remove-table\"\n\nexport function removeRow(\n  editor: Editor,\n  { at = editor.selection }: { at?: BetterAt } = {}\n) {\n  const t = getTableInfo(editor, { at })\n  if (t === undefined) return false\n  if (t.rowCount === 1) {\n    removeTable(editor)\n    return true\n  }\n  Editor.withoutNormalizing(editor, () => {\n    Transforms.removeNodes(editor, { at: t.rowPath })\n    Transforms.select(\n      editor,\n      Editor.start(editor, [\n        ...t.tablePath,\n        Math.min(t.rowIndex, t.rowCount - 2),\n        t.cellIndex,\n      ])\n    )\n  })\n  return true\n}\n","import { Editor, Transforms } from \"slate\"\n\nimport { getTableInfo } from \"./get-table-info\"\n\nexport function setTableColumnAlign(\n  editor: Editor,\n  options: { align: \"left\" | \"center\" | \"right\" }\n) {\n  const t = getTableInfo(editor)\n  if (t === undefined) return false\n  const { tableElement, tablePath, cellIndex } = t\n  const nextColumns = tableElement.columns.slice()\n  nextColumns.splice(cellIndex, 1, { align: options.align })\n  Transforms.setNodes(editor, { columns: nextColumns }, { at: tablePath })\n  return true\n}\n","import { Editor, Path, Transforms } from \"slate\"\n\nimport { selectStartOfElement } from \"../../sink\"\n\nimport { getTableInfo } from \"./get-table-info\"\nimport { insertRowBelow } from \"./insert-row\"\n\nexport function tabForward(editor: Editor) {\n  const t = getTableInfo(editor)\n  if (!t) return false\n\n  const { cellIndex, cellCount, rowIndex, rowCount, tablePath } = t\n\n  /**\n   * If we aren't in the last cell of the row, then select the next cell\n   */\n  if (cellIndex < cellCount - 1) {\n    selectStartOfElement(editor, [...tablePath, rowIndex, cellIndex + 1])\n    return true\n  }\n\n  /**\n   * If we are in the last cell of the row but we aren't in the last row of\n   * the table, then select the first cell in the next row.\n   */\n  if (rowIndex < rowCount - 1) {\n    selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0])\n    return true\n  }\n\n  /**\n   * If we are in the last cell of the table, exit the table\n   * by inserting a new paragraph after the table and selecting it.\n   */\n  const nextPath = Path.next(tablePath)\n  Transforms.insertNodes(\n    editor,\n    { type: \"paragraph\", children: [{ text: \"\" }] },\n    { at: nextPath }\n  )\n  selectStartOfElement(editor, nextPath)\n\n  return true\n}\n\nexport function tabBackward(editor: Editor) {\n  const t = getTableInfo(editor)\n  if (!t) return false\n\n  const { cellIndex, cellCount, rowIndex, tablePath } = t\n\n  if (cellIndex > 0) {\n    selectStartOfElement(editor, [...tablePath, rowIndex, cellIndex - 1])\n    return true\n  }\n\n  if (rowIndex > 0) {\n    selectStartOfElement(editor, [...tablePath, rowIndex - 1, cellCount - 1])\n    return true\n  }\n}\n\n/**\n * Shift+Enter: Move to next cell, or add new row at end of table\n */\nexport function shiftEnterForward(editor: Editor) {\n  const t = getTableInfo(editor)\n  if (!t) return false\n\n  const { cellIndex, cellCount, rowIndex, rowCount, tablePath } = t\n\n  /**\n   * If we aren't in the last cell of the row, then select the next cell\n   */\n  if (cellIndex < cellCount - 1) {\n    selectStartOfElement(editor, [...tablePath, rowIndex, cellIndex + 1])\n    return true\n  }\n\n  /**\n   * If we are in the last cell of the row but we aren't in the last row of\n   * the table, then select the first cell in the next row.\n   */\n  if (rowIndex < rowCount - 1) {\n    selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0])\n    return true\n  }\n\n  /**\n   * If we are in the last cell of the table, insert a new row and then\n   * select the first cell in the new row.\n   */\n  insertRowBelow(editor)\n  selectStartOfElement(editor, [...tablePath, rowIndex + 1, 0])\n\n  return true\n}\n","import { Editor, NodeEntry, Transforms } from \"slate\"\n\nimport { TableElement } from \"../types\"\n\nexport function normalizeTableIndexes(\n  editor: Editor,\n  entry: NodeEntry<TableElement>\n): boolean {\n  let isTransformed = false\n  const rowElements = entry[0].children\n  rowElements.forEach((rowElement, y) => {\n    const cellElements = rowElement.children\n    cellElements.forEach((cellElement, x) => {\n      if (cellElement.x !== x || cellElement.y !== y) {\n        Transforms.setNodes(editor, { x, y }, { at: [...entry[1], y, x] })\n        isTransformed = true\n      }\n    })\n  })\n  return isTransformed\n}\n","import { Editor, NodeEntry, Transforms } from \"slate\"\n\nimport { TableCellElement } from \"../types\"\n\nexport function normalizeTableCell(\n  editor: Editor,\n  entry: NodeEntry<TableCellElement>\n): boolean {\n  const [node, path] = entry\n  if (node.children.length === 1 && node.children[0].type === \"table-content\") {\n    return false\n  }\n  Editor.withoutNormalizing(editor, () => {\n    /**\n     * This ensures that the first child node of a `table-cell`\n     * is a `table-content` node. It won't be if a user pastes\n     * in the start of a `table-cell`.\n     *\n     * We want this because our algorithm will merge all following\n     * nodes into this node. If we don't do this, we are merging\n     * into a potentially non `table-content` cell and might end up\n     * with some other `Element` like a `code-block`.\n     *\n     * NOTE:\n     *\n     * In order to make sure this doesn't turn into a noop, we add\n     * some text here. It is arbitrarily an `X`.\n     */\n    Transforms.insertNodes(\n      editor,\n      {\n        type: \"table-content\",\n        children: [{ text: \"X\" }],\n      },\n      { at: [...entry[1], 0] }\n    )\n    /**\n     * We then iterate from the back of the children to the front\n     * and merging left. Because we inserted an extra node, the\n     * for loop looks a little unusual in that `i` starts at\n     * `node.children.length` instead of `node.children.length - 1`.\n     */\n    for (let i = node.children.length; i >= 0; i--) {\n      Transforms.mergeNodes(editor, { at: [...path, i] })\n    }\n    /**\n     * When we're done, we remove the `X`.\n     *\n     * There might be a cleaner way to do this whout adding and\n     * removing the `X` and when we find it, we can improve this\n     * code.\n     *\n     * IMPORTANT:\n     *\n     * Whatever a replacement is, remember that we need to execute\n     * the commands such that it preserves the cursor position.\n     */\n    Transforms.delete(editor, {\n      at: { path: [...path, 0, 0], offset: 0 },\n      unit: \"character\",\n    })\n  })\n  return true\n}\n","import { useEffect } from \"react\"\nimport { ReactEditor, useSelected, useSlateStatic } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { normalizeTableIndexes } from \"../normalize/normalize-table\"\nimport { TableElement } from \"../types\"\nimport { $Table } from \"./styles\"\nimport { TableContext } from \"./table-context\"\n\nexport function Table({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<TableElement>) {\n  const editor = useSlateStatic()\n  const isSelected = useSelected()\n  /**\n   * The first time we render a table, we make sure it is normalized.\n   * When it comes out of an `initialValue` it's not guaranteed to include\n   * `x` and `y` properties as they are optional.\n   *\n   * This mainly helps us not have to manually add these values when the\n   * `x` and `y` are purely an internal requirement for rendering.\n   */\n  useEffect(() => {\n    try {\n      const path = ReactEditor.findPath(editor, element)\n      normalizeTableIndexes(editor, [element, path])\n    } catch {\n      // The element path may be stale if other normalizations (e.g.\n      // collapsible-paragraph inserting nodes) shifted indices before\n      // this effect runs. The plugin's normalizeNode handler already\n      // sets x/y during Slate's normalization cycle, so this is safe\n      // to skip.\n    }\n  }, [])\n  return (\n    <TableContext.Provider value={{ isSelected }}>\n      <$Table {...attributes} columns={element.columns}>\n        <tbody>{children}</tbody>\n      </$Table>\n    </TableContext.Provider>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nimport { TableColumn } from \"../../types\"\nexport * from \"./table-menu-styles\"\n\n/**\n * Table\n */\nexport const $Table = styled(\"table\")<{ columns: TableColumn[] }>`\n  border-collapse: collapse;\n  margin: 1em 0;\n  ${({ columns }) =>\n    columns\n      .map(\n        (column, index) =>\n          `td:nth-of-type(${index + 1}) { text-align: ${column.align}; }`\n      )\n      .join(\"\\n\")}\n`\n\n/**\n * Table Row\n */\nexport const $TableRow = styled(\"tr\")`\n  position: relative;\n  &:first-of-type {\n    background: var(--table-head-bgcolor);\n  }\n`\n\n/**\n * Table Cell\n *\n * - `--selected` indicates selected cell\n */\nexport const $TableCell = styled(\"td\")`\n  position: relative;\n  border-width: 1px;\n  border-style: solid;\n  border-color: rgba(0, 0, 0, 0.2) rgba(0, 0, 0, 0.05);\n  border-color: var(--table-row-border-color) var(--table-column-border-color);\n  padding: 0.75em 1em;\n  min-width: 2em;\n  &.--selected {\n    outline: 2px solid var(--select-color, blue);\n  }\n  /**\n   * Stronger borders on the left and right edge\n   */\n  &:first-of-type {\n    border-left-color: var(--table-border-color);\n  }\n  &:last-of-type {\n    border-right-color: var(--table-border-color);\n  }\n`\n\n/**\n * Table Content (inside Table Cell)\n */\nexport const $TableContent = styled(\"div\")`\n  /**\n   * Smaller font inside a table than outside of it\n   */\n  font-size: 0.9375em; /* 15px */\n  /**\n   * Even smaller font and dimmer for the heading row\n   */\n  tr:first-of-type & {\n    color: rgba(0, 0, 0, 0.6);\n    font-size: 0.875em; /* 14px */\n  }\n`\n","import styled from \"@emotion/styled\"\n\n/**\n * Table Menu\n */\n\nconst $BaseMenu = styled(\"div\")`\n  position: absolute;\n  /**\n   * very slightly shaded\n   */\n  background: rgba(0, 0, 0, 0.001);\n\n  /**\n   * hover \n   */\n  &:hover {\n    /**\n     * needs to pop up so that it doesn't jump back and forth with neighbor\n     * below\n     */\n    z-index: 1000;\n    /**\n     * Makes the visible tile get darker on hover over any part of the\n     * menu including the invisible part\n     */\n    .--tile {\n      background: rgba(0, 0, 0, 0.15);\n    }\n  }\n`\n\nexport const $ColumnMenu = styled($BaseMenu)`\n  cursor: pointer;\n  /**\n   * hangs out on top\n   */\n  left: -1px;\n  right: -1px;\n  right: 0;\n  height: 3em;\n  top: -3em;\n`\n\nexport const $RowMenu = styled($BaseMenu)`\n  /**\n   * hangs out on left\n   */\n  top: -1px;\n  bottom: -1px;\n  width: 3em;\n  left: -3em;\n`\n\n/**\n * Menu Tile\n */\n\nconst $MenuTile = styled(\"div\")`\n  position: absolute;\n  background: rgba(0, 0, 0, 0.05);\n  border: 1px solid rgba(0, 0, 0, 0.05);\n  transition: all 200ms;\n  /**\n   * NOTE: One of these should be overridden\n   */\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n`\n\n/**\n * The `$RowMenuTile` is the visible part of the `$RowMenu` and is the right\n * half of the `$RowMenu`.\n */\nexport const $ColumnMenuTile = styled($MenuTile)`\n  top: 50%;\n  border-bottom: none;\n  border-right: none;\n  bottom: 1px;\n  td:first-of-type & {\n    border-top-left-radius: 0.5em;\n  }\n  td:last-of-type & {\n    border-top-right-radius: 0.5em;\n    border-right: 1px solid rgba(0, 0, 0, 0.05);\n    right: -1px;\n  }\n  svg {\n    position: absolute;\n    top: 0.1875em;\n    left: 50%;\n    margin-left: -0.5em;\n    color: rgba(0, 0, 0, 0.2);\n  }\n  &:hover svg {\n    color: rgba(0, 0, 0, 0.5);\n  }\n\n  /* border-top-left-radius: 0.5em;\n  border-top-right-radius: 0.5em; */\n`\n\n/**\n * The `$RowMenuTile` is the visible part of the `$RowMenu` and is the right\n * half of the `$RowMenu`.\n */\nexport const $RowMenuTile = styled($MenuTile)`\n  left: 50%;\n  border-right: none;\n  border-bottom: none;\n  right: 1px;\n  tr:first-of-type & {\n    border-top-left-radius: 0.5em;\n  }\n  tr:last-of-type & {\n    border-bottom-left-radius: 0.5em;\n    border-bottom: 1px solid rgba(0, 0, 0, 0.05);\n    bottom: 0;\n  }\n  svg {\n    position: absolute;\n    left: 0.25em;\n    top: 50%;\n    margin-top: -0.5em;\n    color: rgba(0, 0, 0, 0.2);\n  }\n  &:hover svg {\n    color: rgba(0, 0, 0, 0.5);\n  }\n\n  /* border-top-left-radius: 0.5em;\n  border-bottom-left-radius: 0.5em; */\n`\n\n/**\n * Menu Button\n */\n\nconst $MenuButton = styled(\"div\")`\n  position: absolute;\n  font-size: 1.5em;\n  background: white;\n  border-radius: 50%;\n  cursor: pointer;\n  svg {\n    display: block;\n  }\n`\n\nexport const $AddMenuButton = styled($MenuButton)`\n  color: #c0c0c0;\n  &:hover {\n    color: royalblue;\n  }\n`\n\nexport const $RemoveMenuButton = styled($MenuButton)`\n  color: #c0c0c0;\n  &:hover {\n    color: firebrick;\n  }\n`\n","import { createContext } from \"react\"\n\nexport const TableContext = createContext<{ isSelected: boolean }>({\n  isSelected: false,\n})\n","import { useContext } from \"react\"\nimport { useSelected } from \"slate-react\"\n\nimport { ConstrainedRenderElementProps } from \"../../../sink\"\n\nimport { TableCellElement } from \"../../types\"\nimport { $TableCell } from \"../styles\"\nimport { TableContext } from \"../table-context\"\nimport { ColumnMenu } from \"./column-menu\"\nimport { RowMenu } from \"./row-menu\"\nimport { TableMenu } from \"./table-menu\"\n\nexport function TableCell({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<TableCellElement>) {\n  const tableContext = useContext(TableContext)\n  const selected = useSelected()\n  /**\n   * table has slection and we are in the top left cell\n   */\n  const showTableMenu =\n    tableContext.isSelected && element.x === 0 && element.y === 0\n  /**\n   * table has selection and we are in the left columns\n   */\n  const showRowMenu = tableContext.isSelected && element.x === 0\n  /**\n   * table has selection and we are in the top row\n   */\n  const showColumnMenu = tableContext.isSelected && element.y === 0\n  return (\n    <$TableCell\n      className={selected ? \"--selected\" : \"\"}\n      {...attributes}\n      data-x={element.x}\n      data-y={element.y}\n    >\n      {children}\n      {showTableMenu ? <TableMenu /> : null}\n      {showRowMenu ? <RowMenu cellElement={element} /> : null}\n      {showColumnMenu ? <ColumnMenu cellElement={element} /> : null}\n    </$TableCell>\n  )\n}\n","import { useCallback, useRef, useState } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { Menu, MenuItemData } from \"../../../../shared-overlays\"\nimport { useLayer } from \"../../../../use-layer\"\n\nimport {\n  AlignCenter,\n  AlignLeft,\n  AlignRight,\n  BarsIcon,\n  MinusIcon,\n  PlusIcon,\n} from \"../../../icons\"\nimport { TableCellElement } from \"../../../types\"\nimport {\n  $AddMenuButton,\n  $ColumnMenu,\n  $ColumnMenuTile,\n  $RemoveMenuButton,\n} from \"../../styles\"\n\nexport function ColumnMenu({ cellElement }: { cellElement: TableCellElement }) {\n  const editor = useSlateStatic()\n  const menu = useLayer(\"column-menu\")\n  const buttonRef = useRef<HTMLDivElement>(null)\n  const [hover, setHover] = useState(false)\n\n  const onMouseEnter = useCallback(() => {\n    setHover(true)\n  }, [])\n\n  const onMouseLeave = useCallback(() => {\n    setHover(false)\n  }, [])\n\n  const onClick = useCallback(() => {\n    if (menu.layer) menu.close()\n    const dest = buttonRef.current\n    if (dest === null) return\n    const items: MenuItemData[] = [\n      {\n        icon: AlignLeft,\n        title: \"左揃え\",\n        action: () => {\n          editor.tablePlugin.setTableColumnAlign({ align: \"left\" })\n        },\n      },\n      {\n        icon: AlignCenter,\n        title: \"中央揃え\",\n        action: () => {\n          editor.tablePlugin.setTableColumnAlign({ align: \"center\" })\n        },\n      },\n      {\n        icon: AlignRight,\n        title: \"右揃え\",\n        action: () => {\n          editor.tablePlugin.setTableColumnAlign({ align: \"right\" })\n        },\n      },\n    ]\n    // Menu\n    menu.open(() => <Menu dest={dest} items={items} close={menu.close} />)\n  }, [])\n\n  return (\n    <$ColumnMenu\n      ref={buttonRef}\n      contentEditable={false}\n      onClick={onClick}\n      onMouseEnter={onMouseEnter}\n      onMouseLeave={onMouseLeave}\n    >\n      <$ColumnMenuTile className=\"--tile\">\n        <BarsIcon />\n      </$ColumnMenuTile>\n      {hover ? (\n        <>\n          <$RemoveMenuButton\n            style={{\n              top: 0,\n              left: \"50%\",\n              marginLeft: \"-0.5em\",\n            }}\n            onMouseDown={() =>\n              editor.tablePlugin.removeColumn({ at: cellElement })\n            }\n          >\n            <MinusIcon />\n          </$RemoveMenuButton>\n\n          <$AddMenuButton\n            style={{ left: \"-0.5em\", top: 0 }}\n            onMouseDown={() =>\n              editor.tablePlugin.insertColumn({ at: cellElement })\n            }\n          >\n            <PlusIcon />\n          </$AddMenuButton>\n          <$AddMenuButton\n            style={{ right: \"-0.5em\", top: 0 }}\n            onMouseDown={() =>\n              editor.tablePlugin.insertColumn({ at: cellElement, offset: 1 })\n            }\n          >\n            <PlusIcon />\n          </$AddMenuButton>\n        </>\n      ) : null}\n    </$ColumnMenu>\n  )\n}\n","import { SVGProps } from \"react\"\n\nimport { TablerIcon } from \"../sink\"\n\nexport const PlusIcon = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    viewBox=\"0 0 20 20\"\n    fill=\"currentColor\"\n    width=\"1em\"\n    height=\"1em\"\n    {...props}\n  >\n    <path\n      fillRule=\"evenodd\"\n      d=\"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-11.25a.75.75 0 0 0-1.5 0v2.5h-2.5a.75.75 0 0 0 0 1.5h2.5v2.5a.75.75 0 0 0 1.5 0v-2.5h2.5a.75.75 0 0 0 0-1.5h-2.5v-2.5z\"\n      clipRule=\"evenodd\"\n    />\n  </svg>\n)\n\nexport const MinusIcon = (props: SVGProps<SVGSVGElement>) => (\n  <svg\n    xmlns=\"http://www.w3.org/2000/svg\"\n    viewBox=\"0 0 20 20\"\n    fill=\"currentColor\"\n    width=\"1em\"\n    height=\"1em\"\n    {...props}\n  >\n    <path\n      fillRule=\"evenodd\"\n      d=\"M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zM6.75 9.25a.75.75 0 0 0 0 1.5h6.5a.75.75 0 0 0 0-1.5h-6.5z\"\n      clipRule=\"evenodd\"\n    />\n  </svg>\n)\n\nexport const BarsIcon = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M4 12h16M4 18h16\" />\n  </TablerIcon>\n)\n\nexport const AlignLeft = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M4 12h10M4 18h14\" />\n  </TablerIcon>\n)\n\nexport const AlignCenter = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M8 12h8M6 18h12\" />\n  </TablerIcon>\n)\n\nexport const AlignRight = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M10 12h10M6 18h14\" />\n  </TablerIcon>\n)\n","import { useState } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { BarsIcon, MinusIcon, PlusIcon } from \"../../../icons\"\nimport { TableCellElement } from \"../../../types\"\nimport {\n  $AddMenuButton,\n  $RemoveMenuButton,\n  $RowMenu,\n  $RowMenuTile,\n} from \"../../styles\"\n\nexport function RowMenu({ cellElement }: { cellElement: TableCellElement }) {\n  const editor = useSlateStatic()\n  const [hover, setHover] = useState(false)\n\n  return (\n    <$RowMenu\n      contentEditable={false}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n    >\n      <$RowMenuTile className=\"--tile\">\n        <BarsIcon />\n      </$RowMenuTile>\n      {hover ? (\n        <>\n          <$RemoveMenuButton\n            style={{\n              top: \"50%\",\n              left: \"0.5em\",\n              marginTop: \"-0.5em\",\n            }}\n            onMouseDown={() =>\n              editor.tablePlugin.removeRow({ at: cellElement })\n            }\n          >\n            <MinusIcon />\n          </$RemoveMenuButton>\n          <$AddMenuButton\n            style={{ top: \"-0.5em\", left: \"0.5em\" }}\n            onMouseDown={() =>\n              editor.tablePlugin.insertRow({ at: cellElement })\n            }\n          >\n            <PlusIcon />\n          </$AddMenuButton>\n          <$AddMenuButton\n            style={{ bottom: \"-0.5em\", left: \"0.5em\" }}\n            onMouseDown={() =>\n              editor.tablePlugin.insertRow({ at: cellElement, offset: 1 })\n            }\n          >\n            <PlusIcon />\n          </$AddMenuButton>\n        </>\n      ) : null}\n    </$RowMenu>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $TableMenu = styled(\"div\")`\n  position: absolute;\n  /**\n   * very slightly shaded\n   */\n  background: rgba(0, 0, 0, 0.001);\n\n  /**\n   * hangs out on left\n   */\n  top: -1.5em;\n  left: -4em;\n  height: 2.5em;\n  width: 2.5em;\n\n  /**\n   * hover \n   */\n  &:hover {\n    /**\n     * needs to pop up so that it doesn't jump back and forth with neighbor\n     * below\n     */\n    z-index: 1000;\n    /**\n     * Makes the visible tile get darker on hover over any part of the\n     * menu including the invisible part\n     */\n    .--row-menu-tile {\n      background: rgba(0, 0, 0, 0.15);\n    }\n  }\n`\n\n/**\n * The `$RowMenuTile` is the visible part of the `$RowMenu` and is the right\n * half of the `$RowMenu`.\n */\nexport const $TableMenuTile = styled(\"div\")`\n  position: absolute;\n  left: 0;\n  top: 0;\n  width: 1.5em;\n  height: 1.5em;\n  background: rgba(0, 0, 0, 0.05);\n  border-radius: 50%;\n`\n","import { $TableMenu, $TableMenuTile } from \"./$table-menu\"\n\nexport function TableMenu() {\n  return (\n    <$TableMenu contentEditable={false}>\n      <$TableMenuTile className=\"--table-menu-tile\" />\n    </$TableMenu>\n  )\n}\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { TableContentElement } from \"../types\"\nimport { $TableContent } from \"./styles\"\n\nexport function TableContent({\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<TableContentElement>) {\n  return <$TableContent {...attributes}>{children}</$TableContent>\n}\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport { TableRowElement } from \"../types\"\nimport { $TableRow } from \"./styles\"\n\nexport function TableRow({\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<TableRowElement>) {\n  return <$TableRow {...attributes}>{children}</$TableRow>\n}\n","import { ConstrainedRenderElementProps } from \"../../sink\"\n\nimport {\n  TableCellElement,\n  TableContentElement,\n  TableElement,\n  TableRowElement,\n} from \"../types\"\nimport { Table } from \"./table\"\nimport { TableCell } from \"./table-cell\"\nimport { TableContent } from \"./table-content\"\nimport { TableRow } from \"./table-row\"\n\nexport function renderElement({\n  element,\n  attributes,\n  children,\n}: ConstrainedRenderElementProps<\n  TableElement | TableRowElement | TableCellElement | TableContentElement\n>) {\n  switch (element.type) {\n    case \"table\":\n      return (\n        <Table element={element} attributes={attributes}>\n          {children}\n        </Table>\n      )\n    case \"table-row\":\n      return (\n        <TableRow element={element} attributes={attributes}>\n          {children}\n        </TableRow>\n      )\n    case \"table-cell\":\n      return (\n        <TableCell element={element} attributes={attributes}>\n          {children}\n        </TableCell>\n      )\n    case \"table-content\":\n      return (\n        <TableContent element={element} attributes={attributes}>\n          {children}\n        </TableContent>\n      )\n  }\n}\n","import { Global } from \"@emotion/react\"\n\nimport { createPlugin, TypedPlugin } from \"../sink\"\n\nimport { globalStyles } from \"./global-styles\"\n\nexport type ThemeEditor = {\n  theme: true\n}\n\nexport type ThemePluginCustomTypes = {\n  Name: \"theme\"\n  Editor: ThemeEditor\n}\n\nexport const ThemePlugin = createPlugin<ThemePluginCustomTypes>((editor) => {\n  editor.theme = true\n  return {\n    name: \"theme\",\n    editor: {},\n    renderEditable: ({ attributes, Editable }) => {\n      return (\n        <>\n          <Global styles={globalStyles} />\n          <Editable {...attributes} />\n        </>\n      )\n    },\n    editableProps: {},\n  }\n}) as TypedPlugin<ThemePluginCustomTypes>\n","import { css } from \"@emotion/react\"\n\nconst blue = `\n--blue-50: rgb(239 246 255);\n--blue-100: rgb(219 234 254);\n--blue-200: rgb(191 219 254);\n--blue-300: rgb(147 197 253);\n--blue-400: rgb(96 165 250);\n--blue-500: rgb(59 130 246);\n--blue-600: rgb(37 99 235);\n--blue-700: rgb(29 78 216);\n--blue-800: rgb(30 64 175);\n--blue-900: rgb(30 58 138);\n`\n\nconst zincShades = `\n--shade-50: rgb(250 250 250);\n--shade-100: rgb(244 244 245);\n--shade-200: rgb(228 228 231);\n--shade-300: rgb(212 212 216);\n--shade-400: rgb(161 161 170);\n--shade-500: rgb(113 113 122);\n--shade-600: rgb(82 82 91);\n--shade-700: rgb(63 63 70);\n--shade-800: rgb(39 39 42);\n--shade-900: rgb(24 24 27);\n`\n\nexport const globalStyles = css`\n  :root {\n    /* Tailwind Colors */\n    ${blue}\n    ${zincShades}\n    /* Select Colors */\n    --select-color: var(--blue-400);\n    --select-editor-color: var(--blue-200);\n    --hover-color: var(--blue-200);\n    /* Link Colors */\n    --link-color: var(--blue-600);\n    --link-hover-color: var(--blue-700);\n    /* Code Block Colors */\n    /* Inline Code Colors */\n    --inline-code-bgcolor: var(--shade-100);\n    --inline-code-border-color: var(--shade-200);\n    /* Table Colors */\n    --table-border-color: var(--shade-300);\n    --table-row-border-color: var(--shade-300);\n    --table-column-border-color: var(--shade-100);\n    --table-head-bgcolor: var(--shade-50);\n    --table-menu-bgcolor: var(--shade-100);\n    --table-menu-hover-bgcolor: var(--shade-200);\n    /* Horizontal Rule Colors */\n    --hr-color: var(--shade-300);\n  }\n`\n","import { clsx } from \"clsx\"\nimport { useCallback, useRef } from \"react\"\nimport { Editor, Transforms } from \"slate\"\nimport { ReactEditor, useFocused, useSlateStatic } from \"slate-react\"\n\nimport { RenderEditableProps } from \"../../sink\"\nimport { Layers } from \"../../use-layer\"\n\nimport { Toolbar } from \"../components\"\nimport { $Editable, $OuterContainer } from \"../styles\"\n\nexport function renderEditable({ attributes, Editable }: RenderEditableProps) {\n  const outerContainerRef = useRef<HTMLDivElement>(null)\n\n  const editor = useSlateStatic()\n  const focused = useFocused()\n\n  /**\n   * When the user clicks inside the outer container but outside of the content\n   * or the toolbar, we want the user to see the cursor inside the editable\n   * region.\n   */\n  const onClickOuterContainer = useCallback(\n    (e: React.MouseEvent<HTMLDivElement>) => {\n      /**\n       * If the user clicked on the toolbar, we don't want to do anything.\n       *\n       * If the user clicked on the content, we don't want to do anything\n       * because focus and selection will be handled by Slate.\n       */\n      if (e.target !== e.currentTarget) return\n      /**\n       * Select the last position in the editor\n       */\n      Transforms.select(editor, Editor.end(editor, []))\n      ReactEditor.focus(editor)\n    },\n    [editor]\n  )\n\n  return (\n    <Layers>\n      <$OuterContainer\n        ref={outerContainerRef}\n        className={clsx({ \"--focused\": focused })}\n        style={{\n          height: editor.toolbar.height,\n          minHeight: editor.toolbar.minHeight,\n          maxHeight: editor.toolbar.maxHeight,\n        }}\n        onClick={onClickOuterContainer}\n      >\n        <Toolbar />\n        <Editable\n          as={$Editable}\n          {...attributes}\n          style={{ overflowY: \"auto\" }}\n        />\n      </$OuterContainer>\n    </Layers>\n  )\n}\n","import { clsx } from \"clsx\"\nimport { CSSProperties, useCallback, useRef, useState } from \"react\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\n\nimport { CloseMask } from \"../../../shared-overlays\"\nimport { useAbsoluteReposition } from \"../../../use-reposition\"\n\nimport {\n  $TableDialog,\n  $TableDialogGrid,\n  $TableDialogGridCell,\n} from \"../../styles/table-styles\"\n\nfunction createRange(size: number): number[] {\n  return [...Array(size).keys()]\n}\n\nexport function TableDialog({\n  dest,\n  close,\n}: {\n  dest: HTMLElement\n  close: () => void\n}) {\n  const [hover, setHover] = useState({ x: 0, y: 0 })\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLDivElement>(null)\n  const style = useAbsoluteReposition({ src: ref, dest }, ({ dest }) => {\n    if (!dest) return { left: 0, top: 0 }\n    return { left: dest.left - 8, top: dest.top + dest.height }\n  }) as CSSProperties\n  const rows = createRange(5).map((i) => i + 1)\n  const cols = createRange(5).map((i) => i + 1)\n\n  const hoverCell = useCallback(\n    (x: number, y: number) => {\n      setHover({ x, y })\n    },\n    [setHover]\n  )\n\n  const createTable = useCallback(\n    (x: number, y: number) => {\n      editor.tablePlugin.insertTable(x, y)\n      ReactEditor.focus(editor)\n      close()\n    },\n    [editor]\n  )\n\n  return (\n    <>\n      <CloseMask close={close} />\n      <$TableDialog ref={ref} style={style}>\n        <$TableDialogGrid onMouseLeave={() => hoverCell(0, 0)}>\n          {rows.map((y) => {\n            return cols.map((x) => {\n              const selected = x <= hover.x && y <= hover.y\n              return (\n                <$TableDialogGridCell\n                  className={clsx({ \"--selected\": selected })}\n                  key={`${x},${y}`}\n                  onMouseEnter={() => hoverCell(x, y)}\n                  onClick={() => createTable(x, y)}\n                />\n              )\n            })\n          })}\n        </$TableDialogGrid>\n      </$TableDialog>\n    </>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nimport { $Panel } from \"../../shared-overlays\"\n\nexport const $TableDialog = styled($Panel)`\n  padding: 0.5em;\n`\nexport const $TableDialogGrid = styled(\"div\")`\n  display: grid;\n  grid-template-columns: repeat(5, 1.75em);\n  grid-template-rows: 1.5em;\n  /* grid-gap: 1px; */\n`\nexport const $TableDialogGridCell = styled(\"div\")`\n  background: var(--shade-100);\n  height: 1.5em;\n  border-radius: 0.125em;\n  border-right: 1px solid white;\n  border-top: 1px solid white;\n  cursor: pointer;\n  &.--selected {\n    background: var(--blue-100);\n  }\n`\n","import { useEffect, useRef, useState } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { MenuItemData } from \"../../../shared-overlays/types\"\nimport { initialItems, itemSets } from \"../../items\"\nimport {\n  $Toolbar,\n  $ToolbarContainer,\n  $ToolbarDivider,\n  $ToolbarDividerContainer,\n} from \"../../styles\"\nimport { ToolbarButton } from \"./toolbar-button\"\n\n/**\n * Render a toolbar item which is either a button or a divider.\n */\nfunction ToolbarItem({ item }: { item: MenuItemData }) {\n  const editor = useSlateStatic()\n  if (item === \"divider\") {\n    return (\n      <$ToolbarDividerContainer data-item-type=\"divider\">\n        <$ToolbarDivider />\n      </$ToolbarDividerContainer>\n    )\n  }\n  const show = item.show === undefined ? true : item.show(editor)\n  if (!show) return null\n  return <ToolbarButton item={item} />\n}\n\n/**\n * Returns the width of the toolbar, the width of a button, and the width of a\n * divider.\n */\nfunction getWidths(toolbar: HTMLDivElement) {\n  const button = toolbar.querySelector<HTMLDivElement>(\n    \"[data-item-type=button]\"\n  )\n  const divider = toolbar.querySelector<HTMLDivElement>(\n    \"[data-item-type=divider]\"\n  )\n  if (!button || !divider) return null\n  return {\n    toolbar: toolbar.offsetWidth,\n    button: button.offsetWidth,\n    divider: divider.offsetWidth,\n  }\n}\n\n/**\n * Takes an array of items representing a set of toolbar buttons and items and\n * returns the width of the set in pixels\n */\nfunction measureItemSetWidth(\n  items: MenuItemData[],\n  buttonWidth: number,\n  dividerWidth: number\n): number {\n  let width = 0\n  for (const item of items) {\n    width += item === \"divider\" ? dividerWidth : buttonWidth\n  }\n  return width\n}\n\n// Small buffer to account for sub-pixel rounding in measurements.\n// The container padding (0.5em each side) already provides visual slack.\nconst WIDTH_BUFFER_PX = 4\n\nexport function Toolbar() {\n  const ref = useRef<HTMLDivElement>(null)\n  const [items, setItems] = useState<MenuItemData[]>(initialItems)\n  useEffect(() => {\n    const toolbar = ref.current\n    if (!toolbar) return\n    const refresh = () => {\n      const widths = getWidths(toolbar)\n      if (!widths) return\n      /**\n       * Iterate through the item sets and find the first one that fits within\n       * the toolbar width. If none fit, use the last item set.\n       */\n      for (let i = 0; i < itemSets.length - 1; i++) {\n        const itemSetWidth = measureItemSetWidth(\n          itemSets[i],\n          widths.button,\n          widths.divider\n        )\n        if (itemSetWidth < widths.toolbar - WIDTH_BUFFER_PX) {\n          setItems(itemSets[i])\n          return\n        }\n      }\n      setItems(itemSets[itemSets.length - 1])\n    }\n    const observer = new ResizeObserver(refresh)\n    observer.observe(toolbar)\n    return () => {\n      observer.disconnect()\n    }\n  }, [])\n  return (\n    <$ToolbarContainer ref={ref}>\n      <$Toolbar>\n        {items.map((item, index) => (\n          <ToolbarItem\n            key={typeof item === \"string\" ? index : item.title}\n            item={item}\n          />\n        ))}\n      </$Toolbar>\n    </$ToolbarContainer>\n  )\n}\n","import { TablerIcon } from \"../sink\"\n\nexport const H = () => (\n  <TablerIcon>\n    <path d=\"M7 12h10M7 5v14M17 5v14M15 19h4M15 5h4M5 19h4M5 5h4\" />\n  </TablerIcon>\n)\n\nexport const More = () => (\n  <TablerIcon className=\"--more-icon\" width=\"0.5em\" viewBox=\"0 0 12 24\">\n    <path d=\"m2 12 4 4 4-4\" />\n  </TablerIcon>\n)\n\nexport const LinkPlus = () => (\n  <TablerIcon width=\"0.5em\" viewBox=\"6 0 12 24\">\n    <path d=\"M9 12h6M12 9v6\" />\n  </TablerIcon>\n)\n\nexport const H1 = () => (\n  <TablerIcon>\n    <path d=\"M19 18v-8l-2 2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const H2 = () => (\n  <TablerIcon>\n    <path d=\"M17 12a2 2 0 1 1 4 0c0 .591-.417 1.318-.816 1.858L17 18.001h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const H3 = () => (\n  <TablerIcon>\n    <path d=\"M19 14a2 2 0 1 0-2-2M17 16a2 2 0 1 0 2-2M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const H4 = () => (\n  <TablerIcon>\n    <path d=\"M20 18v-8l-4 6h5M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const H5 = () => (\n  <TablerIcon>\n    <path d=\"M17 18h2a2 2 0 1 0 0-4h-2v-4h4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const H6 = () => (\n  <TablerIcon>\n    <path d=\"M19 14a2 2 0 1 0 0 4 2 2 0 0 0 0-4z\" />\n    <path d=\"M21 12a2 2 0 1 0-4 0v4M4 6v12M12 6v12M11 18h2M3 18h2M4 12h8M3 6h2M11 6h2\" />\n  </TablerIcon>\n)\n\nexport const Normal = () => (\n  <TablerIcon>\n    <path d=\"M8 18V6h2l6 9V6h2v12h-2l-6-9v9H8z\" />\n  </TablerIcon>\n)\n\nexport const Bold = () => (\n  <TablerIcon>\n    {/* <path d=\"M0 0h24v24H0z\" stroke=\"none\" /> */}\n    <path d=\"M7 5h6a3.5 3.5 0 0 1 0 7H7zM13 12h1a3.5 3.5 0 0 1 0 7H7v-7\" />\n  </TablerIcon>\n)\n\nexport const Italic = () => (\n  <TablerIcon>\n    <path d=\"M11 5h6M7 19h6M14 5l-4 14\" />\n  </TablerIcon>\n)\n\nexport const Style = () => (\n  <TablerIcon>\n    <path d=\"M4 20h3M14 20h7M6.9 15h6.9M10.2 6.3 16 20M5 20l6-16h2l7 16\" />\n  </TablerIcon>\n)\n\nexport const Link = () => (\n  <TablerIcon>\n    <path d=\"M10 14a3.5 3.5 0 0 0 5 0l4-4a3.5 3.5 0 0 0-5-5l-.5.5\" />\n    <path d=\"M14 10a3.5 3.5 0 0 0-5 0l-4 4a3.5 3.5 0 0 0 5 5l.5-.5\" />\n  </TablerIcon>\n)\n\n/**\n * Block Quote\n */\n\nexport const Blockquote = () => (\n  <TablerIcon>\n    <path d=\"M6 15h15M21 19H6M15 11h6M21 7h-6M9 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2M3 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2\" />\n  </TablerIcon>\n)\n\nexport const Quote = () => (\n  <TablerIcon>\n    <path d=\"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5M19 11h-4a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 2.667-1.333 4.333-4 5\" />\n  </TablerIcon>\n)\n\nexport const DoubleQuote = () => (\n  <TablerIcon>\n    <path d=\"M10 9l4 3-4 3\" />\n    <path d=\"M16 9l4 3-4 3\" />\n  </TablerIcon>\n)\n\nexport const QuoteOff = () => (\n  <TablerIcon>\n    <path d=\"M10 11H6a1 1 0 0 1-1-1V7a1 1 0 0 1 1-1m4 4v3c0 2.667-1.333 4.333-4 5M19 11h-4m-1-1V7a1 1 0 0 1 1-1h3a1 1 0 0 1 1 1v6c0 .66-.082 1.26-.245 1.798m-1.653 2.29c-.571.4-1.272.704-2.102.912M3 3l18 18\" />\n  </TablerIcon>\n)\n\n/**\n * List\n */\n\nexport const BulletList = () => (\n  <TablerIcon>\n    <path d=\"M9 6h11M9 12h11M9 18h11M5 6v.01M5 12v.01M5 18v.01\" />\n  </TablerIcon>\n)\n\n/**\n * Table\n */\n\nexport const Table = () => (\n  <TablerIcon>\n    <rect x={4} y={4} width={16} height={16} rx={2} />\n    <path d=\"M4 10h16M10 4v16\" />\n  </TablerIcon>\n)\n\n/**\n * Code\n */\n\nexport const Code = () => (\n  <TablerIcon>\n    <path d=\"m7 8-4 4 4 4M17 8l4 4-4 4M14 4l-4 16\" />\n  </TablerIcon>\n)\n\nexport const CodeBlock = () => (\n  <TablerIcon>\n    <path d=\"M9 8L5 12L9 16M15 8L19 12L15 16\" />\n  </TablerIcon>\n)\n\n/**\n * Media and Files\n */\n\nexport const Image = () => (\n  <TablerIcon>\n    <path d=\"M15 8h.01\" />\n    <rect x={4} y={4} width={16} height={16} rx={3} />\n    <path d=\"m4 15 4-4a3 5 0 0 1 3 0l5 5\" />\n    <path d=\"m14 14 1-1a3 5 0 0 1 3 0l2 2\" />\n  </TablerIcon>\n)\n\nexport const Attachment = () => (\n  <TablerIcon>\n    <path stroke=\"none\" d=\"M0 0h24v24H0z\" />\n    <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n    <path d=\"M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2zM12 11v6M9 14h6\" />\n  </TablerIcon>\n)\n\nexport const FileUpload = () => (\n  <TablerIcon>\n    <path stroke=\"none\" d=\"M0 0h24v24H0z\" />\n    <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n    <path d=\"M17 21H7a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7l5 5v11a2 2 0 0 1-2 2zM12 11v6\" />\n    <path d=\"M9.5 13.5 12 11l2.5 2.5\" />\n  </TablerIcon>\n)\n\nexport const PhotoUp = () => (\n  <TablerIcon>\n    <path stroke=\"none\" d=\"M0 0h24v24H0z\" />\n    <path d=\"M15 8h.01M12.5 21H6a3 3 0 0 1-3-3V6a3 3 0 0 1 3-3h12a3 3 0 0 1 3 3v6.5\" />\n    <path d=\"m3 16 5-5c.928-.893 2.072-.893 3 0l3.5 3.5\" />\n    <path d=\"m14 14 1-1c.679-.653 1.473-.829 2.214-.526M19 22v-6M22 19l-3-3-3 3\" />\n  </TablerIcon>\n)\n\n/**\n * Text Styles\n */\n\nexport const Plus = () => (\n  <TablerIcon>\n    <path d=\"M12 5v14M5 12h14\" />\n  </TablerIcon>\n)\n\nexport const Strikethrough = () => (\n  <TablerIcon>\n    <path d=\"M5 12h14M16 6.5A4 2 0 0 0 12 5h-1a3.5 3.5 0 0 0 0 7h2a3.5 3.5 0 0 1 0 7h-1.5a4 2 0 0 1-4-1.5\" />\n  </TablerIcon>\n)\n\nexport const Underline = () => (\n  <TablerIcon>\n    <path d=\"M7 5v5a5 5 0 0 0 10 0V5M5 19h14\" />\n  </TablerIcon>\n)\n\nexport const RemoveStyles = () => (\n  <TablerIcon>\n    <path d=\"m14 6 7 7-2 2M10 10l-4.172 4.172a2.828 2.828 0 1 0 4 4L14 14\" />\n    <path d=\"m16 12 4.414-4.414a2 2 0 0 0 0-2.829l-1.171-1.171a2 2 0 0 0-2.829 0L12 8M4 20l1.768-1.768M3 3l18 18\" />\n  </TablerIcon>\n)\n\nexport const ListCheck = () => (\n  <TablerIcon>\n    <path d=\"m9 11 3 3 8-8\" />\n    <path d=\"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9\" />\n  </TablerIcon>\n)\n\nexport const ListNumbers = () => (\n  <TablerIcon>\n    <path d=\"M11 6h9M11 12h9M12 18h8M4 16a2 2 0 1 1 4 0c0 .591-.5 1-1 1.5L4 20h4M6 10V4L4 6\" />\n  </TablerIcon>\n)\n\nexport const IncreaseDepth = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M8 12h12M12 18h8M7 12l-3-3M7 12l-3 3\" />\n  </TablerIcon>\n)\n\nexport const DecreaseDepth = () => (\n  <TablerIcon>\n    <path d=\"M4 6h16M8 12h12M12 18h8M4 12l3-3M4 12l3 3\" />\n  </TablerIcon>\n)\n\n/**\n * Markdown\n */\nexport const Markdown = () => (\n  <TablerIcon>\n    <path d=\"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z\" />\n    <path d=\"M7 15V9l2 2 2-2v6M14 9v6h4M14 13h2\" />\n  </TablerIcon>\n)\n\n/**\n * Visual Editor\n */\nexport const VisualEditor = () => (\n  <TablerIcon>\n    <path d=\"M5 5h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7a2 2 0 0 1 2-2z\" />\n    <path d=\"M8 8h8M8 12h8M8 16h5\" />\n    <path d=\"M16 16h1\" />\n  </TablerIcon>\n)\n\nexport const Close = () => (\n  <TablerIcon>\n    <path d=\"M18 6L6 18M6 6l12 12\" />\n  </TablerIcon>\n)\n\nexport const Highlight = () => (\n  <TablerIcon>\n    <path d=\"M4 20h4l10.5-10.5a2.828 2.828 0 1 0-4-4L4 16v4\" />\n    <path d=\"M13.5 6.5l4 4\" />\n    <path d=\"m14 19 6-6M18 15l2 2M5 21h4\" />\n  </TablerIcon>\n)\n\nexport const HorizontalRule = () => (\n  <TablerIcon>\n    <path d=\"M5 12h14\" />\n  </TablerIcon>\n)\n","import { MenuItemData } from \"../../shared-overlays/types\"\n\nimport * as Icon from \"../icons\"\nimport { t } from \"../../utils/translations\"\n\nconst listDepthItems: MenuItemData[] = [\n  {\n    icon: Icon.IncreaseDepth,\n    title: t(\"increaseDepth\"),\n    hotkey: \"tab\",\n    action: (editor) => editor.list.increaseDepth(),\n    active: (editor) => editor.list.canIncreaseDepth(),\n  },\n  {\n    icon: Icon.DecreaseDepth,\n    title: t(\"decreaseDepth\"),\n    hotkey: \"shift+tab\",\n    action: (editor) => editor.list.decreaseDepth(),\n    active: (editor) => editor.list.canDecreaseDepth(),\n  },\n]\n\nconst blockItems: MenuItemData[] = [\n  {\n    icon: Icon.Normal,\n    title: t(\"normal\"),\n    hotkey: \"super+0\",\n    action: (editor) => {\n      editor.collapsibleParagraph.convertParagraph()\n    },\n  },\n  {\n    icon: Icon.H1,\n    title: t(\"heading1\"),\n    hotkey: \"super+1\",\n    action: (editor) => editor.heading.convertHeading(1, true),\n    active: (editor) => editor.heading.isHeadingActive(1),\n  },\n  {\n    icon: Icon.H2,\n    title: t(\"heading2\"),\n    hotkey: \"super+2\",\n    action: (editor) => editor.heading.convertHeading(2, true),\n    active: (editor) => editor.heading.isHeadingActive(2),\n  },\n  {\n    icon: Icon.H3,\n    title: t(\"heading3\"),\n    hotkey: \"super+3\",\n    action: (editor) => editor.heading.convertHeading(3, true),\n    active: (editor) => editor.heading.isHeadingActive(3),\n  },\n]\n\nexport const expandedBlockItems: MenuItemData[] = [...blockItems]\n\nexport const compactBlockItems: MenuItemData[] = [\n  {\n    icon: Icon.H,\n    title: t(\"paragraphStyle\"),\n    more: true,\n    children: blockItems,\n  }\n]\n\n// Export listDepthItems so they can be used in list-items.tsx\nexport { listDepthItems }\n","import { useState, useRef, CSSProperties, useEffect, useCallback } from \"react\"\nimport { useSlateStatic } from \"slate-react\"\n\nimport { CloseMask } from \"../../../shared-overlays\"\nimport { positionInside, useAbsoluteReposition } from \"../../../use-reposition\"\nimport { t } from \"../../../utils/translations\"\n\nimport { $FileDialog } from \"../../styles/file-dialog-styles\"\nimport { DraggableHeader } from \"./DraggableHeader\"\n\ntype ImageSource = \"url\" | \"file\" | \"select\"\n\nexport function ImageUrlDialog({\n    dest,\n    close,\n}: {\n    dest: HTMLElement\n    close: () => void\n}) {\n    const editor = useSlateStatic()\n    const ref = useRef<HTMLDivElement>(null)\n    const fileInputRef = useRef<HTMLInputElement>(null)\n    const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 })\n\n    const handleDrag = useCallback((deltaX: number, deltaY: number) => {\n        setDragOffset(prev => ({ x: prev.x + deltaX, y: prev.y + deltaY }))\n    }, [])\n\n    // Persist dialog values in editor.wysimark so they survive dialog close/reopen\n    const savedState = editor.wysimark?.imageDialogState\n    const hasOnImageChange = !!editor.wysimark?.onImageChange\n    const hasOnFileSelect = !!editor.wysimark?.onFileSelect\n\n    const defaultSource: ImageSource = savedState?.imageSource ?? (hasOnImageChange ? \"file\" : hasOnFileSelect ? \"select\" : \"url\")\n\n    const [url, setUrl] = useState(savedState?.url ?? \"\")\n    const [alt, setAlt] = useState(savedState?.alt ?? \"\")\n    const [title, setTitle] = useState(savedState?.title ?? \"\")\n    const [titleManuallyEdited, setTitleManuallyEdited] = useState(false)\n    const [imageSource, setImageSource] = useState<ImageSource>(defaultSource)\n    const [isUploading, setIsUploading] = useState(false)\n    const [uploadedUrl, setUploadedUrl] = useState(savedState?.uploadedUrl ?? \"\")\n\n    // Reset uploadedUrl when switching image source modes\n    const handleImageSourceChange = (source: ImageSource) => {\n        setImageSource(source)\n        setUploadedUrl(\"\")\n        setUploadedFileName(\"\")\n    }\n    const [uploadedFileName, setUploadedFileName] = useState(\"\")\n\n    // Handlers for alt and title with sync\n    const handleAltChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n        const newAlt = e.target.value\n        setAlt(newAlt)\n        // Sync title with alt if title hasn't been manually edited\n        if (!titleManuallyEdited) {\n            setTitle(newAlt)\n        }\n    }, [titleManuallyEdited])\n\n    const handleTitleChange = useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n        setTitle(e.target.value)\n        setTitleManuallyEdited(true)\n    }, [])\n\n    // Save state to editor when values change\n    useEffect(() => {\n        if (editor.wysimark) {\n            editor.wysimark.imageDialogState = { url, alt, title, imageSource, uploadedUrl }\n        }\n    }, [editor, url, alt, title, imageSource, uploadedUrl])\n\n    // Clear state on successful submit or cancel\n    const clearState = () => {\n        if (editor.wysimark) {\n            editor.wysimark.imageDialogState = undefined\n        }\n    }\n\n    const baseStyle = useAbsoluteReposition(\n        { src: ref, dest },\n        ({ src, dest }, viewport) => {\n            return positionInside(\n                src,\n                viewport,\n                {\n                    left: dest.left - 16,\n                    top: dest.top + dest.height,\n                },\n                { margin: 16 }\n            )\n        }\n    ) as CSSProperties\n\n    const style = {\n        ...baseStyle,\n        left: (baseStyle.left as number) + dragOffset.x,\n        top: (baseStyle.top as number) + dragOffset.y,\n    }\n\n    function handleSubmit(e: React.FormEvent) {\n        e.preventDefault()\n        const finalUrl = (imageSource === \"file\" || imageSource === \"select\") ? uploadedUrl : url\n        if (finalUrl.trim() === \"\") return\n\n        editor.image.insertImageFromUrl(finalUrl, alt, title)\n        clearState()\n        close()\n    }\n\n    function handleCancel() {\n        clearState()\n        close()\n    }\n\n    async function handleFileSelect(e: React.ChangeEvent<HTMLInputElement>) {\n        const file = e.target.files?.[0]\n        if (!file || !editor.wysimark?.onImageChange) return\n\n        setUploadedFileName(file.name)\n        setIsUploading(true)\n        try {\n            const resultUrl = await editor.wysimark.onImageChange(file)\n            setUploadedUrl(resultUrl)\n        } catch (error) {\n            void error\n        } finally {\n            setIsUploading(false)\n        }\n    }\n\n    function handleSelectFileClick() {\n        fileInputRef.current?.click()\n    }\n\n    async function handleFileSelectFromPicker() {\n        if (!editor.wysimark?.onFileSelect) return\n        setIsUploading(true)\n        try {\n            const resultUrl = await editor.wysimark.onFileSelect()\n            if (resultUrl) {\n                setUploadedUrl(resultUrl)\n            }\n        } catch (error) {\n            void error\n        } finally {\n            setIsUploading(false)\n        }\n    }\n\n    const isSubmitDisabled = (imageSource === \"file\" || imageSource === \"select\")\n        ? uploadedUrl.trim() === \"\" || isUploading\n        : url.trim() === \"\"\n\n    return (\n        <>\n            <CloseMask close={close} />\n            <$FileDialog ref={ref} style={style}>\n                <DraggableHeader onDrag={handleDrag} />\n                <form onSubmit={(e) => void handleSubmit(e)} style={{ padding: \"8px\" }}>\n                    {(hasOnImageChange || hasOnFileSelect) && (\n                        <div style={{ marginBottom: \"12px\" }}>\n                            {hasOnImageChange && (\n                                <label style={{ display: \"inline-flex\", alignItems: \"center\", marginRight: \"16px\", cursor: \"pointer\" }}>\n                                    <input\n                                        type=\"radio\"\n                                        name=\"imageSource\"\n                                        value=\"file\"\n                                        checked={imageSource === \"file\"}\n                                        onChange={() => handleImageSourceChange(\"file\")}\n                                        style={{ marginRight: \"4px\" }}\n                                    />\n                                    {t(\"imageSourceFile\")}\n                                </label>\n                            )}\n                            {hasOnFileSelect && (\n                                <label style={{ display: \"inline-flex\", alignItems: \"center\", marginRight: \"16px\", cursor: \"pointer\" }}>\n                                    <input\n                                        type=\"radio\"\n                                        name=\"imageSource\"\n                                        value=\"select\"\n                                        checked={imageSource === \"select\"}\n                                        onChange={() => handleImageSourceChange(\"select\")}\n                                        style={{ marginRight: \"4px\" }}\n                                    />\n                                    {t(\"imageSourceSelect\")}\n                                </label>\n                            )}\n                            <label style={{ display: \"inline-flex\", alignItems: \"center\", cursor: \"pointer\" }}>\n                                <input\n                                    type=\"radio\"\n                                    name=\"imageSource\"\n                                    value=\"url\"\n                                    checked={imageSource === \"url\"}\n                                    onChange={() => handleImageSourceChange(\"url\")}\n                                    style={{ marginRight: \"4px\" }}\n                                />\n                                {t(\"imageSourceUrl\")}\n                            </label>\n                        </div>\n                    )}\n\n                    {imageSource === \"url\" ? (\n                        <div style={{ marginBottom: \"8px\" }}>\n                            <label style={{ display: \"block\", marginBottom: \"4px\" }}>\n                                {t(\"imageUrlRequired\")}\n                            </label>\n                            <input\n                                type=\"text\"\n                                value={url}\n                                onChange={(e) => setUrl(e.target.value)}\n                                style={{\n                                    width: \"100%\",\n                                    padding: \"6px\",\n                                    boxSizing: \"border-box\",\n                                    border: \"1px solid var(--shade-300)\",\n                                    borderRadius: \"4px\",\n                                    backgroundColor: \"var(--shade-50)\",\n                                    color: \"var(--shade-700)\"\n                                }}\n                                placeholder=\"https://example.com/image.jpg\"\n                            />\n                        </div>\n                    ) : imageSource === \"select\" ? (\n                        <div style={{ marginBottom: \"8px\" }}>\n                            <button\n                                type=\"button\"\n                                onClick={() => void handleFileSelectFromPicker()}\n                                disabled={isUploading}\n                                style={{\n                                    padding: \"8px 16px\",\n                                    backgroundColor: isUploading ? \"#ccc\" : \"#0078d4\",\n                                    color: isUploading ? \"#666\" : \"white\",\n                                    border: \"none\",\n                                    borderRadius: \"4px\",\n                                    cursor: isUploading ? \"not-allowed\" : \"pointer\",\n                                    marginBottom: \"8px\",\n                                    fontWeight: \"bold\"\n                                }}\n                            >\n                                {isUploading ? t(\"uploading\") : t(\"imageSourceSelect\")}\n                            </button>\n\n                            {uploadedUrl && (\n                                <div style={{ marginTop: \"8px\", padding: \"8px\", backgroundColor: \"var(--shade-100)\", borderRadius: \"4px\" }}>\n                                    <div style={{ color: \"green\", marginBottom: \"4px\" }}>✓ {uploadedUrl.split(\"/\").pop()}</div>\n                                </div>\n                            )}\n                        </div>\n                    ) : (\n                        <div style={{ marginBottom: \"8px\" }}>\n                            <input\n                                ref={fileInputRef}\n                                type=\"file\"\n                                accept=\"image/*\"\n                                onChange={(e) => void handleFileSelect(e)}\n                                style={{ display: \"none\" }}\n                            />\n                            <button\n                                type=\"button\"\n                                onClick={handleSelectFileClick}\n                                disabled={isUploading}\n                                style={{\n                                    padding: \"8px 16px\",\n                                    backgroundColor: isUploading ? \"#ccc\" : \"#0078d4\",\n                                    color: isUploading ? \"#666\" : \"white\",\n                                    border: \"none\",\n                                    borderRadius: \"4px\",\n                                    cursor: isUploading ? \"not-allowed\" : \"pointer\",\n                                    marginBottom: \"8px\",\n                                    fontWeight: \"bold\"\n                                }}\n                            >\n                                {isUploading ? t(\"uploading\") : t(\"selectFile\")}\n                            </button>\n\n                            {uploadedUrl && (\n                                <div style={{ marginTop: \"8px\", padding: \"8px\", backgroundColor: \"var(--shade-100)\", borderRadius: \"4px\" }}>\n                                    <div style={{ color: \"green\", marginBottom: \"4px\" }}>✓ {uploadedFileName}</div>\n                                </div>\n                            )}\n                        </div>\n                    )}\n\n                    <div style={{ marginBottom: \"8px\" }}>\n                        <label style={{ display: \"block\", marginBottom: \"4px\" }}>\n                            {t(\"altText\")}\n                        </label>\n                        <input\n                            type=\"text\"\n                            value={alt}\n                            onChange={handleAltChange}\n                            style={{\n                                width: \"100%\",\n                                padding: \"6px\",\n                                boxSizing: \"border-box\",\n                                border: \"1px solid var(--shade-300)\",\n                                borderRadius: \"4px\",\n                                backgroundColor: \"var(--shade-50)\",\n                                color: \"var(--shade-700)\"\n                            }}\n                            placeholder={t(\"imageDescription\")}\n                        />\n                    </div>\n\n                    <div style={{ marginBottom: \"8px\" }}>\n                        <label style={{ display: \"block\", marginBottom: \"4px\" }}>\n                            {t(\"title\")}\n                        </label>\n                        <input\n                            type=\"text\"\n                            value={title}\n                            onChange={handleTitleChange}\n                            style={{\n                                width: \"100%\",\n                                padding: \"6px\",\n                                boxSizing: \"border-box\",\n                                border: \"1px solid var(--shade-300)\",\n                                borderRadius: \"4px\",\n                                backgroundColor: \"var(--shade-50)\",\n                                color: \"var(--shade-700)\"\n                            }}\n                            placeholder={t(\"imageTitle\")}\n                        />\n                    </div>\n\n                    <div style={{ display: \"flex\", gap: \"8px\" }}>\n                        <button\n                            type=\"submit\"\n                            disabled={isSubmitDisabled}\n                            style={{\n                                display: \"flex\",\n                                alignItems: \"center\",\n                                padding: \"8px 16px\",\n                                backgroundColor: isSubmitDisabled ? \"#ccc\" : \"#0078d4\",\n                                color: \"white\",\n                                border: \"none\",\n                                borderRadius: \"4px\",\n                                cursor: isSubmitDisabled ? \"not-allowed\" : \"pointer\",\n                                fontWeight: \"bold\"\n                            }}\n                        >\n                            {t(\"register\")}\n                        </button>\n                        <button\n                            type=\"button\"\n                            onClick={handleCancel}\n                            style={{\n                                padding: \"8px 16px\",\n                                backgroundColor: \"var(--shade-100)\",\n                                color: \"var(--shade-700)\",\n                                border: \"1px solid var(--shade-300)\",\n                                borderRadius: \"4px\",\n                                cursor: \"pointer\"\n                            }}\n                        >\n                            {t(\"cancel\")}\n                        </button>\n                    </div>\n                </form>\n            </$FileDialog>\n        </>\n    )\n}\n","import styled from \"@emotion/styled\"\n\nimport { $Panel } from \"../../shared-overlays/styles/$Panel\"\n\nexport const $FileDialog = styled($Panel)`\n  width: 18em;\n  padding: 0;\n  overflow: hidden;\n`\n","import { isHotkey } from \"is-hotkey\"\nimport {\n  ChangeEvent,\n  CSSProperties,\n  KeyboardEvent,\n  useCallback,\n  useMemo,\n  useRef,\n  useState,\n} from \"react\"\nimport { Editor, Range } from \"slate\"\nimport { ReactEditor, useSlateStatic } from \"slate-react\"\n\nimport { positionInside, useAbsoluteReposition } from \"../../../use-reposition\"\n\nimport { CloseMask } from \"../../../shared-overlays/components/CloseMask\"\nimport { t } from \"../../../utils/translations\"\nimport * as Icon from \"../../icons\"\nimport {\n  $AnchorDialog,\n  $AnchorDialogInput,\n  $AnchorDialogInputLine,\n} from \"../../styles\"\nimport { $DialogButton, $DialogHint } from \"../../styles/dialog-shared-styles\"\nimport { DraggableHeader } from \"./DraggableHeader\"\n\nconst isEnter = isHotkey(\"enter\")\n\nexport function AnchorDialog({\n  dest,\n  close,\n}: {\n  dest: HTMLElement\n  close: () => void\n}) {\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLDivElement>(null)\n  const [dragOffset, setDragOffset] = useState({ x: 0, y: 0 })\n\n  const handleDrag = useCallback((deltaX: number, deltaY: number) => {\n    setDragOffset(prev => ({ x: prev.x + deltaX, y: prev.y + deltaY }))\n  }, [])\n\n  const baseStyle = useAbsoluteReposition(\n    { src: ref, dest },\n    ({ src, dest }, viewport) => {\n      if (!src || !dest) return { left: 0, top: 0 }\n      return positionInside(\n        src,\n        viewport,\n        {\n          left: dest.left - 12,\n          top: dest.top + dest.height,\n        },\n        { margin: 16 }\n      )\n    }\n  )\n\n  const style = {\n    ...baseStyle,\n    left: (baseStyle.left as number) + dragOffset.x,\n    top: (baseStyle.top as number) + dragOffset.y,\n  } as CSSProperties\n\n  // Get selected text as initial value for link text\n  const initialText = useMemo(() => {\n    const { selection } = editor\n    if (selection && !Range.isCollapsed(selection)) {\n      return Editor.string(editor, selection)\n    }\n    return \"\"\n  }, [])\n\n  const [url, setUrl] = useState(\"\")\n  const [text, setText] = useState(initialText)\n  const [title, setTitle] = useState(initialText)\n  const [titleManuallyEdited, setTitleManuallyEdited] = useState(false)\n\n  const insertLink = () => {\n    const linkText = text.trim() || url\n    const linkTitle = title.trim() || undefined\n    editor.anchor.insertLink(url, linkText, { select: true, title: linkTitle })\n    ReactEditor.focus(editor)\n    close()\n  }\n\n  const onChangeUrl = useCallback(\n    (e: ChangeEvent<HTMLInputElement>) => {\n      setUrl(e.currentTarget.value)\n    },\n    [setUrl]\n  )\n\n  const onChangeText = useCallback(\n    (e: ChangeEvent<HTMLInputElement>) => {\n      const newText = e.currentTarget.value\n      setText(newText)\n      // Sync title with text if title hasn't been manually edited\n      if (!titleManuallyEdited) {\n        setTitle(newText)\n      }\n    },\n    [setText, setTitle, titleManuallyEdited]\n  )\n\n  const onChangeTitle = useCallback(\n    (e: ChangeEvent<HTMLInputElement>) => {\n      setTitle(e.currentTarget.value)\n      setTitleManuallyEdited(true)\n    },\n    [setTitle]\n  )\n\n  const onKeyDown = (e: KeyboardEvent<HTMLInputElement>) => {\n    if (!isEnter(e)) return\n    e.preventDefault()\n    e.stopPropagation()\n    insertLink()\n  }\n\n  return (\n    <>\n      <CloseMask close={close} />\n      <$AnchorDialog ref={ref} style={style}>\n        <DraggableHeader onDrag={handleDrag} />\n        <div style={{ padding: \"0.75em\" }}>\n          <$AnchorDialogInputLine>\n            <$AnchorDialogInput\n              type=\"text\"\n              value={url}\n              autoFocus\n              placeholder={t(\"linkUrl\")}\n              onChange={onChangeUrl}\n              onKeyDown={onKeyDown}\n            />\n          </$AnchorDialogInputLine>\n          <$AnchorDialogInputLine style={{ marginTop: \"0.5em\" }}>\n            <$AnchorDialogInput\n              type=\"text\"\n              value={text}\n              placeholder={t(\"linkText\")}\n              onChange={onChangeText}\n              onKeyDown={onKeyDown}\n            />\n          </$AnchorDialogInputLine>\n          <$AnchorDialogInputLine style={{ marginTop: \"0.5em\" }}>\n            <$AnchorDialogInput\n              type=\"text\"\n              value={title}\n              placeholder={t(\"tooltipText\")}\n              onChange={onChangeTitle}\n              onKeyDown={onKeyDown}\n            />\n            <$DialogButton onClick={insertLink}>\n              <Icon.Link />\n              <Icon.LinkPlus />\n            </$DialogButton>\n            <$DialogButton onClick={close} style={{ marginLeft: \"0.25em\", background: \"var(--shade-400)\" }}>\n              <Icon.Close />\n            </$DialogButton>\n          </$AnchorDialogInputLine>\n          <$DialogHint>{t(\"tooltipHint\")}</$DialogHint>\n        </div>\n      </$AnchorDialog>\n    </>\n  )\n}\n","import styled from \"@emotion/styled\"\n\nexport const $DialogButton = styled(\"div\")`\n  /* Center vertically and horizontally */\n  display: flex;\n  align-items: center;\n  justify-content: center;\n  cursor: pointer;\n  /* font-size: 1.25em; */\n  padding: 0.25em 0.75em;\n  text-align: center;\n  color: var(--blue-100);\n  color: white;\n  background: var(--blue-500);\n  transition: all 100ms;\n  &:hover {\n    color: var(--blue-50);\n    background: var(--blue-600);\n    outline: 2px solid var(--blue-200);\n  }\n  border-radius: 0.25em;\n  svg {\n    color: var(--blue-200);\n    font-size: 1.25em;\n    stroke-width: 2px;\n  }\n`\n\nexport const $DialogHint = styled(\"div\")`\n  font-size: 0.875em;\n  margin-top: 0.5em;\n  color: var(--shade-500);\n  line-height: 1.375;\n`\n","import { MenuItemData } from \"../../shared-overlays\"\n\nimport { TableDialog } from \"../components\"\nimport { ImageUrlDialog } from \"../components/dialog/image-url-dialog\"\nimport { AnchorDialog } from \"../components/dialog/anchor-dialog\"\nimport * as Icon from \"../icons\"\nimport { t } from \"../../utils/translations\"\n\nexport const dialogItems: MenuItemData[] = [\n  {\n    icon: Icon.Link,\n    title: t(\"insertLink\"),\n    more: true,\n    hotkey: \"mod+k\",\n    Component: AnchorDialog,\n  },\n  {\n    icon: Icon.Image,\n    title: t(\"insertImageFromUrl\"),\n    more: true,\n    Component: ImageUrlDialog,\n  },\n  {\n    icon: Icon.Table,\n    title: t(\"insertTable\"),\n    more: true,\n    Component: TableDialog,\n  },\n  {\n    icon: Icon.HorizontalRule,\n    title: t(\"horizontalRule\"),\n    hotkey: \"super+-\",\n    action: (editor) => editor.horizontalRule.insertHorizontalRule(),\n  },\n]\n\nexport const expandedDialogItems: MenuItemData[] = dialogItems\n\nexport const compactDialogItems: MenuItemData[] = dialogItems\n\nexport const smallDialogItems: MenuItemData[] = [\n  {\n    icon: Icon.Plus,\n    title: t(\"insert\"),\n    more: true,\n    children: dialogItems,\n  },\n]\n","import { Editor } from \"slate\"\nimport { MenuItemData } from \"../../shared-overlays\"\n\nimport * as Icon from \"../icons\"\nimport { t } from \"../../utils/translations\"\n\nfunction getMarks(editor: Editor) {\n  const marks = Editor.marks(editor)\n  return {\n    bold: marks?.bold || false,\n    italic: marks?.italic || false,\n    strike: marks?.strike || false,\n    code: marks?.code || false,\n    underline: marks?.underline || false,\n    highlight: marks?.highlight || false,\n  }\n}\n\nconst primaryMarkItems: MenuItemData[] = [\n  {\n    icon: Icon.Bold,\n    title: t(\"bold\"),\n    hotkey: \"mod+b\",\n    action: (editor) => editor.marksPlugin.toggleBold(),\n    active: (editor) => getMarks(editor).bold,\n  },\n  {\n    icon: Icon.Italic,\n    title: t(\"italic\"),\n    hotkey: \"mod+i\",\n    action: (editor) => editor.marksPlugin.toggleItalic(),\n    active: (editor) => getMarks(editor).italic,\n  },\n  {\n    icon: Icon.Strikethrough,\n    title: t(\"strike\"),\n    hotkey: \"super+k\",\n    action: (editor) => editor.marksPlugin.toggleStrike(),\n    active: (editor) => getMarks(editor).strike,\n  },\n  {\n    icon: Icon.Code,\n    title: t(\"inlineCode\"),\n    hotkey: \"mod+j\",\n    action: (editor) => editor.inlineCode.toggleInlineCode(),\n    active: (editor) => getMarks(editor).code,\n  },\n  {\n    icon: Icon.Underline,\n    title: t(\"underline\"),\n    hotkey: \"mod+u\",\n    action: (editor) => editor.marksPlugin.toggleUnderline(),\n    active: (editor) => getMarks(editor).underline,\n  },\n  {\n    icon: Icon.Highlight,\n    title: t(\"highlight\"),\n    hotkey: \"mod+h\",\n    action: (editor) => editor.marksPlugin.toggleHighlight(),\n    active: (editor) => getMarks(editor).highlight,\n    show: (editor) => !editor.wysimark.disableHighlight,\n  },\n]\n\nexport const expandedMarkItems: MenuItemData[] = primaryMarkItems\nexport const compactMarkItems: MenuItemData[] = [\n  {\n    icon: Icon.Bold,\n    title: t(\"format\"),\n    more: true,\n    children: primaryMarkItems,\n  },\n]\n","import { MenuItemData } from \"../../shared-overlays\"\n\nimport * as Icon from \"../icons\"\nimport { t } from \"../../utils/translations\"\nimport { listDepthItems } from \"./block-items\"\n\nexport const listItems: MenuItemData[] = [\n  {\n    icon: Icon.BulletList,\n    title: t(\"bulletList\"),\n    hotkey: \"super+8\",\n    action: (editor) => editor.list.convertUnorderedList(true),\n  },\n  {\n    icon: Icon.ListNumbers,\n    title: t(\"numberedList\"),\n    hotkey: \"super+7\",\n    action: (editor) => editor.list.convertOrderedList(true),\n  },\n  {\n    icon: Icon.ListCheck,\n    title: t(\"checkList\"),\n    hotkey: \"super+9\",\n    action: (editor) => editor.list.convertTaskList(true),\n    show: (editor) => !editor.wysimark.disableTaskList,\n  },\n]\n\nexport const expandedListItems: MenuItemData[] = [...listItems, \"divider\", ...listDepthItems]\n\nexport const compactListItems: MenuItemData[] = [\n  {\n    icon: Icon.ListNumbers,\n    title: t(\"list\"),\n    more: true,\n    children: [...listItems, \"divider\", ...listDepthItems],\n  },\n]\n","import { MenuItemData } from \"../../shared-overlays\"\nimport { Editor, Path, Transforms } from \"slate\"\nimport { findElementUp } from \"../../sink\"\nimport * as Icon from \"../icons\"\nimport { t } from \"../../utils/translations\"\n\nconst quoteItemsList: MenuItemData[] = [\n  {\n    icon: Icon.Quote,\n    title: t(\"quote\"),\n    hotkey: \"super+.\",\n    action: (editor) => {\n      if (editor.blockQuotePlugin.isActive()) {\n        editor.blockQuotePlugin.outdent()\n      } else {\n        editor.blockQuotePlugin.indent()\n      }\n    },\n    active: (editor) => editor.blockQuotePlugin.isActive(),\n  },\n  {\n    icon: Icon.DoubleQuote,\n    title: t(\"increaseQuoteDepth\"),\n    action: (editor) => editor.blockQuotePlugin.increaseDepth(),\n    active: (editor) => editor.blockQuotePlugin.canIncreaseDepth(),\n  },\n  {\n    icon: Icon.CodeBlock,\n    title: t(\"codeBlock\"),\n    action: (editor) => {\n      const { selection } = editor;\n      const codeBlockEntry = findElementUp(editor, \"code-block\");\n\n      // Case 1: If a code block is already active, convert it to a paragraph\n      if (codeBlockEntry) {\n        const [, path] = codeBlockEntry;\n\n        // Extract text content from the code block\n        const textContent = Editor.string(editor, path);\n\n        // Remove the code block\n        Transforms.removeNodes(editor, { at: path });\n\n        // Insert a paragraph with the extracted text\n        Transforms.insertNodes(\n          editor,\n          {\n            type: \"paragraph\",\n            children: [{ text: textContent }]\n          },\n          { at: path }\n        );\n        return;\n      }\n\n      // Case 2: If text is selected, convert it to a code block\n      if (selection && !Path.equals(selection.anchor.path, selection.focus.path)) {\n        // Handle multi-paragraph selection\n        editor.codeBlock.createCodeBlock({ language: \"text\" });\n        return;\n      }\n\n      if (selection && selection.anchor.offset !== selection.focus.offset) {\n        // Get the selected text\n        const selectedText = Editor.string(editor, selection);\n\n        // Delete the selected text\n        Transforms.delete(editor);\n\n        // Insert a code block with the selected text\n        Transforms.insertNodes(\n          editor,\n          {\n            type: \"code-block\",\n            language: \"text\",\n            children: [\n              {\n                type: \"code-block-line\",\n                children: [{ text: selectedText }]\n              }\n            ]\n          }\n        );\n        return;\n      }\n\n      // Case 3: Default case - create a new empty code block\n      editor.codeBlock.createCodeBlock({ language: \"text\" });\n    },\n    active: (editor) => !!findElementUp(editor, \"code-block\"),\n    show: (editor) => !editor.wysimark.disableCodeBlock,\n  },\n]\n\nexport const expandedQuoteItems: MenuItemData[] = quoteItemsList\n\nexport const compactQuoteItems: MenuItemData[] = [\n  {\n    icon: Icon.Quote,\n    title: t(\"quote\"),\n    more: true,\n    children: quoteItemsList,\n  },\n]\n\n// For backward compatibility\nexport const quoteItems = expandedQuoteItems\n","import { MenuItemData } from \"../../shared-overlays\"\n\nimport { expandedBlockItems, compactBlockItems } from \"./block-items\"\nimport { compactDialogItems, expandedDialogItems, smallDialogItems } from \"./dialogItems\"\nimport { compactMarkItems, expandedMarkItems } from \"./mark-items\"\nimport { expandedListItems, compactListItems } from \"./list-items\"\nimport { expandedQuoteItems, compactQuoteItems } from \"./quote-items\"\n\n/**\n * A collection of `Item` objects that describe either\n *\n * - A Button in the toolbar\n * - A Menu Item in a drop down of the toolbar\n *\n * An `Item` is described in the same way whether it is a button or a menu\n * item making them interchangeable.\n */\n\nexport const largeItems: MenuItemData[] = [\n  ...expandedBlockItems,\n  \"divider\",\n  ...expandedListItems,\n  \"divider\",\n  ...expandedMarkItems,\n  \"divider\",\n  ...expandedDialogItems,\n  \"divider\",\n  ...expandedQuoteItems,\n]\n\nexport const mediumItems: MenuItemData[] = [\n  ...compactBlockItems,\n  \"divider\",\n  ...expandedListItems,\n  \"divider\",\n  ...expandedMarkItems,\n  \"divider\",\n  ...compactDialogItems,\n  \"divider\",\n  ...expandedQuoteItems,\n]\n\nexport const smallItems: MenuItemData[] = [\n  ...compactBlockItems,\n  \"divider\",\n  ...compactListItems,\n  \"divider\",\n  ...compactMarkItems,\n  \"divider\",\n  ...smallDialogItems,\n  \"divider\",\n  ...compactQuoteItems,\n]\n\nexport const initialItems: MenuItemData[] = smallItems\n\nexport const items = mediumItems\n\nexport const itemSets: MenuItemData[][] = [largeItems, mediumItems, smallItems]\n","import { clsx } from \"clsx\"\nimport { MouseEvent, useCallback, useRef } from \"react\"\nimport { ReactEditor, useSlate, useSlateStatic } from \"slate-react\"\n\nimport { formatHotkey, Menu, MenuItemData } from \"../../../shared-overlays\"\nimport { useLayer } from \"../../../use-layer\"\nimport { useTooltip } from \"../../../use-tooltip\"\nimport { r } from \"../../../utils/translations\"\n\nimport * as Icon from \"../../icons\"\nimport { $ToolbarButton } from \"../../styles\"\n\nexport function ToolbarButton({\n  item,\n}: {\n  item: Exclude<MenuItemData, \"divider\">\n}) {\n  const staticEditor = useSlateStatic()\n  const editor = useSlate()  // エディタの状態変更を検知\n  const isActive = item.active ? item.active(editor) : false\n  const ref = useRef<HTMLDivElement>(null)\n  const tooltip = useTooltip({\n    title: item.title,\n    hotkey: () => (item.hotkey ? formatHotkey(item.hotkey) : undefined),\n  })\n  const menuLayer = useLayer(\"menu\")\n\n  const openMenu = useCallback(() => {\n    const dest = ref.current\n    const items = item.children\n    const Component = item.Component\n    if (!dest) return\n    if (items) {\n      menuLayer.open(() => (\n        <Menu dest={dest} items={items} close={menuLayer.close} />\n      ))\n    } else if (Component) {\n      menuLayer.open(() => <Component dest={dest} close={menuLayer.close} />)\n    }\n  }, [item])\n\n  const onClick = useCallback(() => {\n    if (item.action) {\n      item.action(staticEditor)\n      ReactEditor.focus(staticEditor)\n      return\n    }\n    if (menuLayer.layer) {\n      menuLayer.close()\n    } else {\n      openMenu()\n    }\n  }, [menuLayer.layer, item])\n\n  /**\n   * On hover\n   */\n  const onMouseEnter = useCallback(\n    (e: MouseEvent<HTMLElement>) => {\n      tooltip.onMouseEnter(e)\n      /**\n       * If any `menu` is already open, then we open up the currently hovered\n       * `menu` automatically. This replicates behavior in menus in windowing\n       * systems.\n       */\n      if (menuLayer.layer) openMenu()\n    },\n    [menuLayer.layer, openMenu, tooltip.onMouseEnter]\n  )\n\n  return (\n    <$ToolbarButton\n      data-item-type=\"button\"\n      ref={ref}\n      onMouseEnter={onMouseEnter}\n      onMouseLeave={tooltip.onMouseLeave}\n      onClick={onClick}\n      className={clsx({\n        \"--active\": isActive && !r(item?.title)?.includes('Depth'),\n        \"--more\": item.more,\n        \"--disabled\": !isActive && r(item?.title)?.includes('Depth')\n      })}\n    >\n      <item.icon />\n      {item.more ? <Icon.More /> : null}\n    </$ToolbarButton>\n  )\n}\n","import { createPlugin, TypedPlugin } from \"../sink\"\n\nimport { renderEditable } from \"./render-editable\"\n\nexport type ToolbarEditor = {\n  toolbar: {\n    height?: string | number\n    minHeight?: string | number\n    maxHeight?: string | number\n    showUploadButtons?: boolean\n  }\n}\n\nexport type ToolbarOptions = {\n  toolbar: {\n    height?: string | number\n    minHeight?: string | number\n    maxHeight?: string | number\n    showUploadButtons?: boolean\n  }\n}\n\nexport type ToolbarPluginCustomTypes = {\n  Name: \"toolbar\"\n  Editor: ToolbarEditor\n  Options: ToolbarOptions\n}\n\nexport const ToolbarPlugin = createPlugin<ToolbarPluginCustomTypes>(\n  (editor, options) => {\n    editor.toolbar = {\n      height: options.toolbar?.height,\n      minHeight: options.toolbar?.minHeight,\n      maxHeight: options.toolbar?.maxHeight,\n      showUploadButtons: options.toolbar?.showUploadButtons ?? true,\n    }\n    return {\n      name: \"toolbar\",\n      editor: {},\n      renderEditable,\n      editableProps: {},\n    }\n  }\n) as TypedPlugin<ToolbarPluginCustomTypes>\n","import { Editor, Element, Node, Path, Transforms } from \"slate\"\n\nimport { createPlugin, TypedPlugin } from \"../sink\"\n\ntype TrailingBlockPluginCustomType = {\n  Name: \"trailing-block\"\n  Editor: { allowTrailingBlock: true }\n}\n\nexport const TrailingBlockPlugin = createPlugin<TrailingBlockPluginCustomType>(\n  (editor) => {\n    editor.allowTrailingBlock = true\n    return {\n      name: \"trailing-block\",\n      editor: {\n        normalizeNode: (entry) => {\n          if (!Editor.isEditor(entry[0])) return false\n          const lastPath = [editor.children.length - 1]\n          /**\n           * We expect the last node of the Editor to be an `Element` because\n           * the children of an `Editor` are `Element` objects.\n           */\n          const lastElement = Node.child(\n            editor,\n            editor.children.length - 1\n          ) as Element\n          /**\n           * We need to add a trailing block when it is not easy for us to\n           * start typing at the end of the document. This happens in these\n           * conditions:\n           *\n           * - The last Element is a `void` block that we can't type into\n           * - The last Element is an Element that contains child elements\n           *   like a `table` or a nested `list`.\n           */\n          if (\n            Editor.hasBlocks(editor, lastElement) ||\n            Editor.isVoid(editor, lastElement)\n          ) {\n            Transforms.insertNodes(\n              editor,\n              { type: \"paragraph\", children: [{ text: \"\" }] },\n              {\n                at: Path.next(lastPath),\n              }\n            )\n          }\n          return true\n        },\n      },\n    }\n  }\n) as TypedPlugin<TrailingBlockPluginCustomType>\n","import { Editor, Transforms } from \"slate\"\n\nimport { curryOne } from \"../../sink\"\n\nimport { parse, escapeUrlSlashes } from \"../../convert\"\n\nfunction pasteMarkdown(editor: Editor, markdown: string) {\n  // Escape forward slashes in URLs before parsing\n  const escapedMarkdown = escapeUrlSlashes(markdown);\n  const fragment = parse(escapedMarkdown)\n  Transforms.insertNodes(editor, fragment)\n}\n\nexport function createPasteMarkdownMethods(editor: Editor) {\n  return {\n    pasteMarkdown: curryOne(pasteMarkdown, editor),\n  }\n}\n","import { createPlugin, stopEvent, TypedPlugin } from \"../sink\"\n\nimport { createPasteMarkdownMethods } from \"./methods\"\n\ntype PasteMarkdownMethods = ReturnType<typeof createPasteMarkdownMethods>\n\nexport type PasteMarkdownEditor = {\n  pasteMarkdown: PasteMarkdownMethods\n}\n\nexport type PasteMarkdownPluginCustomTypes = {\n  Name: \"paste-markdown\"\n  Editor: PasteMarkdownEditor\n}\n\nexport const PasteMarkdownPlugin = createPlugin<PasteMarkdownPluginCustomTypes>(\n  (editor) => {\n    editor.pasteMarkdown = createPasteMarkdownMethods(editor)\n    return {\n      name: \"paste-markdown\",\n      editor: {},\n      editableProps: {\n        onPaste(e) {\n          const { types } = e.clipboardData\n          if (types.length !== 1 || types[0] !== \"text/plain\") {\n            return false\n          }\n          const markdown = e.clipboardData.getData(\"text/plain\")\n          editor.pasteMarkdown.pasteMarkdown(markdown)\n          stopEvent(e)\n          return true\n        },\n      },\n    }\n  }\n) as TypedPlugin<PasteMarkdownPluginCustomTypes>\n","import { RenderPlaceholderProps } from \"slate-react\"\n\nimport { createPlugin, TypedPlugin } from \"../sink\"\n\nexport type PlaceholderEditor = {\n  placeholder: Record<string, never>\n}\n\nexport type PlaceholderPluginCustomTypes = {\n  Name: \"placeholder\"\n  Editor: PlaceholderEditor\n}\n\n/**\n * To have the placeholder work properly, it cannot have `width: 100%` and\n * `max-width: 100%` set or it creates horizontal scrollbars.\n *\n * The default `renderPlaceholder` adds these styles so we override them.\n */\nfunction renderPlaceholder(props: RenderPlaceholderProps) {\n  const nextAttributes: RenderPlaceholderProps[\"attributes\"] = {\n    ...props.attributes,\n    style: {\n      ...props.attributes.style,\n      width: undefined,\n      maxWidth: undefined,\n    },\n  }\n  return <span {...nextAttributes}>{props.children}</span>\n}\n\nexport const PlaceholderPlugin = createPlugin<PlaceholderPluginCustomTypes>(\n  (editor, _options, { createPolicy }) => {\n    editor.placeholder = {}\n    return createPolicy({\n      name: \"placeholder\",\n      editableProps: {\n        renderPlaceholder,\n      },\n    })\n  }\n) as TypedPlugin<PlaceholderPluginCustomTypes>\n","import { BaseEditor, BaseText } from \"slate\"\nimport { HistoryEditor } from \"slate-history\"\nimport { ReactEditor } from \"slate-react\"\n\nimport { AnchorPlugin } from \"../anchor-plugin\"\nimport { AtomicDeletePlugin } from \"../atomic-delete-plugin\"\nimport { ImagePlugin } from \"../image-plugin\"\nimport { BlockQuotePlugin } from \"../block-quote-plugin\"\nimport { CodeBlockPlugin } from \"../code-block-plugin\"\nimport { HtmlBlockPlugin } from \"../html-block-plugin\"\nimport { CollapsibleParagraphPlugin } from \"../collapsible-paragraph-plugin\"\nimport { ConvertElementPlugin } from \"../convert-element-plugin\"\nimport { HeadingPlugin } from \"../heading-plugin\"\nimport { HorizontalRulePlugin } from \"../horizontal-rule-plugin\"\nimport { InlineCodePlugin } from \"../inline-code-plugin\"\nimport { ListPlugin } from \"../list-plugin\"\nimport { MarksPlugin } from \"../marks-plugin\"\nimport { NormalizeAfterDeletePlugin } from \"../normalize-after-delete-plugin\"\nimport { ExtractCustomTypes } from \"../sink\"\nimport { TablePlugin } from \"../table-plugin\"\nimport { ThemePlugin } from \"../theme-plugin\"\nimport { ToolbarPlugin } from \"../toolbar-plugin\"\nimport { TrailingBlockPlugin } from \"../trailing-block-plugin\"\nimport { PasteMarkdownPlugin } from \"../paste-markdown-plugin\"\nimport { PlaceholderPlugin } from \"../placeholder-plugin\"\nimport { WysimarkEditor } from \"./types\"\n\nexport const plugins = [\n  PasteMarkdownPlugin,\n  ConvertElementPlugin,\n  AnchorPlugin,\n  HeadingPlugin,\n  MarksPlugin,\n  InlineCodePlugin,\n  BlockQuotePlugin,\n  CodeBlockPlugin,\n  HtmlBlockPlugin,\n  TablePlugin,\n  HorizontalRulePlugin,\n  TrailingBlockPlugin,\n  ListPlugin,\n  AtomicDeletePlugin,\n  NormalizeAfterDeletePlugin,\n  CollapsibleParagraphPlugin,\n  ThemePlugin,\n  ToolbarPlugin,\n  ImagePlugin,\n  PlaceholderPlugin,\n]\n\nexport type PluginTypes = ExtractCustomTypes<typeof plugins>\n\ntype CustomEditor = PluginTypes[\"Editor\"]\ntype CustomElement = PluginTypes[\"Element\"]\ntype CustomText = PluginTypes[\"Text\"]\n\nexport type OptionsType = PluginTypes[\"Options\"]\nexport type Element = CustomElement\nexport type Text = CustomText\n\ndeclare module \"slate\" {\n  interface CustomTypes {\n    Editor: BaseEditor &\n      ReactEditor &\n      HistoryEditor &\n      CustomEditor &\n      WysimarkEditor\n    Element: CustomElement\n    Text: BaseText & CustomText\n  }\n}\n","import { createSink } from \"../sink\"\n\nimport { plugins, PluginTypes } from \"./plugins\"\n\nconst Sink = createSink<PluginTypes>(plugins)\n\nconst { withSink, SinkEditable } = Sink\nexport { SinkEditable, withSink }\n","import { useState } from \"react\"\nimport { createEditor, Editor, Transforms } from \"slate\"\nimport { withHistory } from \"slate-history\"\nimport { ReactEditor, withReact } from \"slate-react\"\n\nimport { parse, serialize, escapeUrlSlashes } from \"../convert\"\nimport { Element } from \"./plugins\"\nimport { withSink } from \"./SinkEditable\"\nimport { WysimarkEditor } from \"./types\"\n\nexport type UseEditorOptions = {\n  authToken?: string\n  height?: string | number\n  minHeight?: string | number\n  maxHeight?: string | number\n  /**\n   * Disable raw Markdown editing mode.\n   * When true, the raw mode toggle button will be hidden from the toolbar.\n   * Defaults to true (raw mode is disabled by default).\n   */\n  disableRawMode?: boolean\n  /**\n   * Disable task list (checklist) functionality.\n   * When true, the task list button will be hidden from the toolbar.\n   */\n  disableTaskList?: boolean\n  /**\n   * Disable code block functionality.\n   * When true, the code block button will be hidden from the toolbar.\n   */\n  disableCodeBlock?: boolean\n  /**\n   * Disable highlight mark functionality.\n   * When true, the highlight button will be hidden from the toolbar.\n   * Defaults to true (highlight is disabled by default).\n   */\n  disableHighlight?: boolean\n}\n\nexport function useEditor({\n  authToken,\n  height,\n  minHeight,\n  maxHeight,\n  disableRawMode,\n  disableTaskList,\n  disableCodeBlock,\n  disableHighlight,\n}: UseEditorOptions = {}): Editor & ReactEditor & WysimarkEditor {\n  const [editor] = useState(() => {\n    const editor = createEditor()\n    const nextEditor = withSink(withReact(withHistory(editor)), {\n      toolbar: {\n        height,\n        minHeight,\n        maxHeight,\n        /**\n         * If `authToken` is provided then show upload buttons.\n         */\n        showUploadButtons: !!authToken,\n      },\n      image: {}\n    })\n    nextEditor.convertElement.addConvertElementType(\"paragraph\")\n    editor.wysimark = {\n      // Disable raw mode (defaults to true)\n      disableRawMode: disableRawMode ?? true,\n      // Disable task list if specified\n      disableTaskList,\n      // Disable code block if specified\n      disableCodeBlock,\n      // Disable highlight (defaults to true)\n      disableHighlight: disableHighlight ?? true,\n    }\n    editor.getMarkdown = () => {\n      return serialize(editor.children as Element[])\n    }\n    editor.setMarkdown = (markdown: string) => {\n      // Escape forward slashes in URLs before parsing\n      const escapedMarkdown = escapeUrlSlashes(markdown);\n      const documentValue = parse(escapedMarkdown)\n      editor.children = documentValue\n      editor.selection = null\n      Transforms.select(editor, Editor.start(editor, [0]))\n    }\n    return nextEditor\n  })\n\n  return editor\n}\n"],"mappings":";;;AAGA;AAAA,EACE;AAAA,EAEA,eAAAA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,EACA,YAAAC;AAAA,OACK;AACP,SAAS,kBAAkB;;;ACX3B,OAAOC,eAAc;AACrB,SAAS,eAAAC,eAAa,UAAAC,UAAQ,YAAAC,kBAAgB;AAC9C,SAAqB,UAAAC,UAAiB,cAAAC,oBAAkB;AACxD,SAAS,eAAAC,eAA8B,SAAAC,cAAa;;;ACFpD,OAAO,iBAAiB;AACxB,SAAS,eAAe;;;ACIjB,SAAS,KAAK;AAAC;;;ACoCf,SAAS,uBAAuB;AACrC,SAAO;AAAA,IACL,OAAO;AAAA,MACL,OAAO;AAAA,MACP,WAAW;AAAA,MACX,aAAa;AAAA,MACb,UAAU;AAAA,IACZ;AAAA,IACA,MAAM;AAAA,MACJ,UAAU;AAAA,MACV,OAAO;AAAA,MACP,WAAW;AAAA,MACX,aAAa;AAAA,MACb,U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cAAY,UAAU;AAEtB;AAAA,IACE;AAAA,IACA,MAAM;AACJ,aAAO;AAAA,QACL,cAAc;AACZ,iBAAO,YAAY;AAAA,QACrB;AAAA,QACA,YAAYC,WAAkB;AAC5B,sBAAY,UAAUA;AACtB,sBAAYA,SAAQ;AAAA,QACtB;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,aAAa,WAAW;AAAA,EAC3B;AAEA,QAAM,mBAAmBC;AAAA,IACvB,CAACD,cAAqB;AAOpB,kBAAY,UAAUA;AACtB,kBAAYA,SAAQ;AACpB,iBAAWA,SAAQ;AAAA,IACrB;AAAA,IACA,CAAC,MAAM;AAAA,EACT;AAEA,SACE,gBAAAE;AAAA,IAACC;AAAA,IAAA;AAAA,MACC;AAAA,MACA,OAAO;AAAA,MACP,WAAW,aAAa;AAAA,MACxB,UAAU;AAAA,MACV;AAAA;AAAA,EACF;AAEJ;AAKO,SAAS,eACd,kBACA,SACU;AACV,QAAM,uBAAuB,UAAoC;AAEjE,QAAM,OAAO,WAAW,gBAAgB;AAExC,OAAK;AAAA,IACH,gBAAAD;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA,mBAAmB;AAAA;AAAA,IACrB;AAAA,EACF;AAEA,SAAO;AAAA,IACL,UAAU;AACR,UAAI;AACF,aAAK,QAAQ;AAAA,MACf,QAAQ;AAAA,MAER;AAAA,IACF;AAAA,IACA,cAAc;AACZ,aAAO,qBAAqB,SAAS,YAAY,KAAK;AAAA,IAKxD;AAAA,IACA,YAAY,UAAkB;AAC5B,2BAAqB,SAAS,YAAY,QAAQ;AAAA,IACpD;AAAA,EACF;AACF;","names":["useCallback","useRef","useState","throttle","useCallback","useRef","useState","Editor","Transforms","ReactEditor","Slate","key","block","SlateText","SlateText","SlateText","SlateText","SlateText","Element","Element","SlateText","SlateText","SlateText","indent","key","plugins","plugins","plugins","key","plugins","renderElement","plugins","plugins","jsx","plugins","plugins","plugins","plugins","withSink","Element","ReactEditor","Editor","Element","Editor","jsx","Element","Element","Editor","Editor","Editor","Editor","Editor","Editor","SlateElement","Range","Transforms","Range","SlateElement","Editor","Transforms","isHotkey","isHotkey","Editor","Transforms","Editor","Editor","Transforms","Editor","Element","Path","Transforms","Element","Editor","Transforms","Path","Editor","Transforms","Editor","Transforms","Editor","Transforms","Editor","Node","Transforms","Transforms","Node","Editor","Editor","Element","Range","Text","Transforms","Transforms","Transforms","Element","Transforms","useEffect","useRef","jsx","layers","styled","styled","useCallback","useRef","useState","useSlateStatic","useRef","styled","jsx","useRef","key","useRef","useSlateStatic","key","useEffect","useMemo","useState","counter","useEffect","styled","styled","styled","styled","styled","styled","styled","styled","styled","styled","styled","ReactEditor","jsx","jsxs","ReactEditor","Fragment","jsx","jsxs","useSlateStatic","useRef","dest","useCallback","styled","jsx","jsxs","styled","jsx","styled","jsx","useCallback","styled","useCallback","useRef","useState","Node","useSlateStatic","styled","useRef","useCallback","styled","jsx","e","jsx","jsxs","styled","useRef","useState","useCallback","destAnchor","destStartEdge","useSlateStatic","Node","href","text","title","jsx","jsx","jsxs","$AnchorDialog","styled","parseUrl","useSlateStatic","useRef","useState","useCallback","destAnchor","destStartEdge","removeLink","jsx","jsxs","useRef","useEffect","jsx","Editor","Transforms","Element","Path","Path","Element","Editor","Transforms","Transforms","ReactEditor","Editor","Transforms","ReactEditor","Transforms","Editor","ReactEditor","normalizeNode","useSlateStatic","styled","clsx","useState","useSelected","styled","clsx","useCallback","useEffect","useRef","Transforms","ReactEditor","useSlateStatic","useEffect","useEffect","styled","ReactEditor","Fragment","jsx","jsxs","ReactEditor","useSlateStatic","useRef","useCallback","e","size","Transforms","useEffect","clsx","styled","jsxs","styled","styled","clsx","useCallback","Transforms","ReactEditor","useSlateStatic","jsx","useSlateStatic","useCallback","ReactEditor","Transforms","clsx","jsx","useCallback","useSlateStatic","jsx","jsxs","jsxs","jsx","Editor","Transforms","ReactEditor","ReactEditor","Editor","Transforms","jsx","useSlateStatic","useCallback","useCallback","useSlateStatic","Editor","Element","Text","Transforms","ReactEditor","ReactEditor","Editor","Transforms","Element","Text","jsx","useSlateStatic","useCallback","jsx","jsxs","jsx","jsxs","jsx","jsxs","useSelected","useState","clsx","jsx","jsxs","useSlateStatic","useSlateStatic","styled","jsx","jsxs","useSlateStatic","jsx","createOnDrop","ReactEditor","Transforms","normalizeNode","Editor","Element","Transforms","styled","jsx","Element","Transforms","Editor","Editor","Element","Transforms","Element","Node","node","offset","Element","Transforms","Element","Transforms","Element","Node","Transforms","normalizeNode","useCallback","useRef","useSelected","jsx","styled","jsx","jsxs","useRef","useSelected","useCallback","useSelected","jsx","useSelected","jsx","renderElement","Fragment","jsx","Editor","Transforms","normalizeNode","Element","renderElement","Transforms","styled","jsx","jsxs","jsx","Transforms","Element","Element","Transforms","Element","Transforms","Element","Transforms","Element","Transforms","normalizeNode","Element","clsx","useSelected","styled","Node","jsx","useSelected","clsx","jsx","insertBreak","normalizeNode","Editor","Element","Node","Range","Transforms","Editor","Node","Element","Transforms","isCollapsed","Range","Editor","Path","Range","Transforms","Range","Editor","Path","Transforms","Editor","Editor","styled","jsx","useSelected","styled","jsx","jsxs","useSelected","Editor","Element","Path","Transforms","Element","Editor","Transforms","Path","jsx","styled","jsx","jsxs","Editor","Transforms","MAX_DEPTH","Editor","Transforms","insertBreak","Editor","Transforms","Editor","Editor","Transforms","Transforms","insertBreak","Element","Transforms","Element","Transforms","normalizeNode","clsx","useEffect","ReactEditor","useSlateStatic","styled","styled","jsx","useSlateStatic","useEffect","ReactEditor","clsx","useCallback","useSlateStatic","jsx","jsxs","jsx","jsxs","useSlateStatic","useCallback","jsx","jsxs","jsx","renderElement","normalizeNode","Transforms","renderElement","Editor","clsx","Editor","Range","Editor","Text","Transforms","key","Editor","Point","Range","styled","jsx","removeMarks","Range","Editor","clsx","Editor","Point","Editor","Point","Element","Editor","Path","Transforms","Editor","Path","Editor","Path","range","Editor","Path","Transforms","Transforms","Editor","Transforms","t","Editor","Transforms","Transforms","t","Transforms","Editor","Element","Path","Transforms","createRow","insertRootElement","Element","Editor","Transforms","Path","Path","t","Path","ReactEditor","t","Editor","Transforms","Transforms","t","t","Editor","Transforms","rowIndex","Editor","Transforms","t","Editor","Transforms","Transforms","t","Transforms","Path","Transforms","t","Path","Transforms","t","Transforms","Transforms","Editor","Transforms","useEffect","ReactEditor","useSelected","useSlateStatic","styled","styled","styled","createContext","jsx","useSlateStatic","useSelected","useEffect","ReactEditor","useContext","useSelected","useCallback","useRef","useState","useSlateStatic","jsx","Fragment","jsx","jsxs","useSlateStatic","useRef","useState","useCallback","useState","useSlateStatic","Fragment","jsx","jsxs","useSlateStatic","useState","styled","jsx","jsx","jsxs","useContext","useSelected","jsx","jsx","jsx","renderElement","Element","renderElement","css","Fragment","jsx","jsxs","Editable","clsx","useCallback","useRef","Editor","Transforms","ReactEditor","useSlateStatic","clsx","useCallback","useRef","useState","ReactEditor","useSlateStatic","styled","styled","Fragment","jsx","jsxs","createRange","useState","useSlateStatic","useRef","dest","useCallback","createTable","ReactEditor","clsx","useEffect","useRef","useState","useSlateStatic","jsx","jsxs","jsx","jsxs","jsx","jsx","jsxs","jsx","Table","jsxs","CodeBlock","jsx","jsxs","jsx","jsx","jsxs","HorizontalRule","useState","useRef","useEffect","useCallback","useSlateStatic","styled","styled","Fragment","jsx","jsxs","useSlateStatic","useRef","useState","useCallback","useEffect","dest","isHotkey","useCallback","useMemo","useRef","useState","Editor","Range","ReactEditor","useSlateStatic","styled","Fragment","jsx","jsxs","isHotkey","AnchorDialog","useSlateStatic","useRef","useState","useCallback","dest","useMemo","Range","Editor","insertLink","ReactEditor","AnchorDialog","Table","HorizontalRule","Editor","Editor","Editor","Path","Transforms","CodeBlock","Editor","Transforms","Path","clsx","useCallback","useRef","ReactEditor","useSlate","useSlateStatic","jsx","jsxs","useSlateStatic","useSlate","useRef","useCallback","ReactEditor","clsx","jsx","useSlateStatic","useRef","useState","useEffect","jsx","jsxs","Editable","useRef","useSlateStatic","useCallback","Transforms","Editor","ReactEditor","clsx","Editor","Node","Path","Transforms","Editor","Node","Transforms","Path","Transforms","Transforms","jsx","SinkEditable","useState","Editor","Transforms","useState","editor","Transforms","Editor","jsx","jsxs","jsx","Editable","useState","useRef","useCallback","throttle","Transforms","Editor","ReactEditor","jsxs","Slate","SinkEditable","jsx","useState","useRef","markdown","useCallback","jsx","Editable"]}