{"version":3,"sources":["jsdelivr-header.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/objectWithoutPropertiesLoose.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/objectWithoutProperties.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/typeof.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/toPrimitive.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/toPropertyKey.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/defineProperty.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/arrayWithHoles.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/iterableToArrayLimit.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/arrayLikeToArray.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/unsupportedIterableToArray.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/nonIterableRest.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/slicedToArray.js","/npm/slate-react@0.147.7/src/hooks/use-slate-static.tsx","/npm/slate-react@0.147.7/src/plugin/react-editor.ts","/npm/slate-react@0.147.7/src/hooks/android-input-manager/android-input-manager.ts","/npm/slate-react@0.147.7/src/hooks/use-is-mounted.tsx","/npm/slate-react@0.147.7/src/hooks/use-isomorphic-layout-effect.ts","/npm/slate-react@0.147.7/src/hooks/use-mutation-observer.ts","/npm/slate-react@0.147.7/src/hooks/android-input-manager/use-android-input-manager.ts","/npm/slate-react@0.147.7/src/components/string.tsx","/npm/slate-react@0.147.7/src/utils/text-parent.ts","/npm/slate-react@0.147.7/src/components/leaf.tsx","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/arrayWithoutHoles.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/iterableToArray.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/nonIterableSpread.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/toConsumableArray.js","/npm/slate-react@0.147.7/src/hooks/use-generic-selector.tsx","/npm/slate-react@0.147.7/src/hooks/use-decorations.ts","/npm/slate-react@0.147.7/src/components/text.tsx","/npm/slate-react@0.147.7/src/components/element.tsx","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/classCallCheck.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/createClass.js","/npm/slate-react@0.147.7/src/chunking/chunk-tree-helper.ts","/npm/slate-react@0.147.7/src/chunking/children-helper.ts","/npm/slate-react@0.147.7/src/chunking/reconcile-children.ts","/npm/slate-react@0.147.7/src/chunking/get-chunk-tree-for-node.ts","/npm/slate-react@0.147.7/src/components/chunk-tree.tsx","/npm/slate-react@0.147.7/src/hooks/use-element.ts","/npm/slate-react@0.147.7/src/hooks/use-children.tsx","/npm/slate-react@0.147.7/src/hooks/use-read-only.ts","/npm/slate-react@0.147.7/src/hooks/use-slate-selector.tsx","/npm/slate-react@0.147.7/src/hooks/use-slate.tsx","/npm/slate-react@0.147.7/src/hooks/use-track-user-input.ts","/npm/slate-react@0.147.7/src/components/restore-dom/restore-dom-manager.ts","/npm/slate-react@0.147.7/src/hooks/use-composition-dom.ts","/npm/slate-react@0.147.7/src/hooks/use-native-format-dom.ts","/npm/slate-react@0.147.7/src/utils/trailing-newline.ts","/npm/slate-react@0.147.7/src/utils/character-move.ts","/npm/slate-react@0.147.7/src/utils/misplaced-composition.ts","/npm/slate-react@0.147.7/src/utils/move-range.ts","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/assertThisInitialized.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/possibleConstructorReturn.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/getPrototypeOf.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/setPrototypeOf.js","/.yarn/berry/cache/@babel-runtime-npm-7.29.7-423e8cd4b6-10.zip/node_modules/@babel/runtime/helpers/inherits.js","/npm/slate-react@0.147.7/src/components/restore-dom/restore-dom.tsx","/npm/slate-react@0.147.7/src/hooks/use-composing.ts","/npm/slate-react@0.147.7/src/components/editable.tsx","/npm/slate-react@0.147.7/src/hooks/use-focused.ts","/npm/slate-react@0.147.7/src/utils/environment.ts","/npm/slate-react@0.147.7/src/components/slate.tsx","/npm/slate-react@0.147.7/src/hooks/use-editor.tsx","/npm/slate-react@0.147.7/src/hooks/use-selected.ts","/npm/slate-react@0.147.7/src/hooks/use-slate-selection.tsx","/npm/slate-react@0.147.7/src/plugin/with-react.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,8kBCGA,EAAA,QATA,SAAuC,EAAG,GACxC,GAAI,MAAQ,EAAG,MAAO,GACtB,IAAI,EAAI,GACR,IAAK,IAAI,KAAK,EAAG,GAAI,GAAG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ArC,KAGF,GAAuB,cAAnB,EAAU,KAAsB,CAClC,IAAM,EAAS,WAAK,OAAO,EAAG,EAAU,MAGxC,KAFmB,EAAE,aAAa,GAEpB,CACZ,IAAM,EAAO,WAAK,IAAI,EAAG,EAAU,MAC7B,EAAY,oBAAoB,EAAG,GACnC,EAAM,YAAY,QAAQ,EAAG,GACnC,EAAU,cAAc,IAAI,EAC9B,CACF,CAEA,EAAM,EACR,EAEO,CACT,E","file":"/npm/slate-react@0.147.7/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.51.2.\n * Original file: /npm/slate-react@0.147.7/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","function _objectWithoutPropertiesLoose(r, e) {\n  if (null == r) return {};\n  var t = {};\n  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n    if (-1 !== e.indexOf(n)) continue;\n    t[n] = r[n];\n  }\n  return t;\n}\nmodule.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var objectWithoutPropertiesLoose = require(\"./objectWithoutPropertiesLoose.js\");\nfunction _objectWithoutProperties(e, t) {\n  if (null == e) return {};\n  var o,\n    r,\n    i = objectWithoutPropertiesLoose(e, t);\n  if (Object.getOwnPropertySymbols) {\n    var n = Object.getOwnPropertySymbols(e);\n    for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);\n  }\n  return i;\n}\nmodule.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _typeof(o) {\n  \"@babel/helpers - typeof\";\n\n  return module.exports = _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) {\n    return typeof o;\n  } : function (o) {\n    return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o;\n  }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports, _typeof(o);\n}\nmodule.exports = _typeof, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nfunction toPrimitive(t, r) {\n  if (\"object\" != _typeof(t) || !t) return t;\n  var e = t[Symbol.toPrimitive];\n  if (void 0 !== e) {\n    var i = e.call(t, r || \"default\");\n    if (\"object\" != _typeof(i)) return i;\n    throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n  }\n  return (\"string\" === r ? String : Number)(t);\n}\nmodule.exports = toPrimitive, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nvar toPrimitive = require(\"./toPrimitive.js\");\nfunction toPropertyKey(t) {\n  var i = toPrimitive(t, \"string\");\n  return \"symbol\" == _typeof(i) ? i : i + \"\";\n}\nmodule.exports = toPropertyKey, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var toPropertyKey = require(\"./toPropertyKey.js\");\nfunction _defineProperty(e, r, t) {\n  return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {\n    value: t,\n    enumerable: !0,\n    configurable: !0,\n    writable: !0\n  }) : e[r] = t, e;\n}\nmodule.exports = _defineProperty, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _arrayWithHoles(r) {\n  if (Array.isArray(r)) return r;\n}\nmodule.exports = _arrayWithHoles, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _iterableToArrayLimit(r, l) {\n  var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n  if (null != t) {\n    var e,\n      n,\n      i,\n      u,\n      a = [],\n      f = !0,\n      o = !1;\n    try {\n      if (i = (t = t.call(r)).next, 0 === l) {\n        if (Object(t) !== t) return;\n        f = !1;\n      } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n    } catch (r) {\n      o = !0, n = r;\n    } finally {\n      try {\n        if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return;\n      } finally {\n        if (o) throw n;\n      }\n    }\n    return a;\n  }\n}\nmodule.exports = _iterableToArrayLimit, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _arrayLikeToArray(r, a) {\n  (null == a || a > r.length) && (a = r.length);\n  for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n  return n;\n}\nmodule.exports = _arrayLikeToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\nfunction _unsupportedIterableToArray(r, a) {\n  if (r) {\n    if (\"string\" == typeof r) return arrayLikeToArray(r, a);\n    var t = {}.toString.call(r).slice(8, -1);\n    return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? arrayLikeToArray(r, a) : void 0;\n  }\n}\nmodule.exports = _unsupportedIterableToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _nonIterableRest() {\n  throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nmodule.exports = _nonIterableRest, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayWithHoles = require(\"./arrayWithHoles.js\");\nvar iterableToArrayLimit = require(\"./iterableToArrayLimit.js\");\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\nvar nonIterableRest = require(\"./nonIterableRest.js\");\nfunction _slicedToArray(r, e) {\n  return arrayWithHoles(r) || iterableToArrayLimit(r, e) || unsupportedIterableToArray(r, e) || nonIterableRest();\n}\nmodule.exports = _slicedToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import { createContext, useContext } from 'react'\nimport { Editor } from 'slate'\nimport { ReactEditor } from '../plugin/react-editor'\n\n/**\n * A React context for sharing the editor object.\n */\n\nexport const EditorContext = createContext<ReactEditor | null>(null)\n\n/**\n * Get the current editor object from the React context.\n */\n\nexport const useSlateStatic = (): Editor => {\n  const editor = useContext(EditorContext)\n\n  if (!editor) {\n    throw new Error(\n      `The \\`useSlateStatic\\` hook must be used inside the <Slate> component's context.`\n    )\n  }\n\n  return editor\n}\n","import { Ancestor } from 'slate'\nimport { DOMEditor, type DOMEditorInterface } from 'slate-dom'\n\n/**\n * A React and DOM-specific version of the `Editor` interface.\n */\n\nexport interface ReactEditor extends DOMEditor {\n  /**\n   * Determines the chunk size used by the children chunking optimization. If\n   * null is returned (which is the default), the chunking optimization is\n   * disabled.\n   */\n  getChunkSize: (node: Ancestor) => number | null\n}\n\nexport interface ReactEditorInterface extends DOMEditorInterface {}\n\n// eslint-disable-next-line no-redeclare\nexport const ReactEditor: ReactEditorInterface = DOMEditor\n","import { DebouncedFunc } from 'lodash'\n// Default import: the UMD build resolves react-dom through its CommonJS entry,\n// whose named exports rollup cannot discover statically.\nimport ReactDOM from 'react-dom'\nimport { Editor, Location, Node, Path, Point, Range, Transforms } from 'slate'\nimport { ReactEditor } from '../../plugin/react-editor'\nimport {\n  applyStringDiff,\n  mergeStringDiffs,\n  normalizePoint,\n  normalizeRange,\n  normalizeStringDiff,\n  StringDiff,\n  targetRange,\n  TextDiff,\n  verifyDiffState,\n} from 'slate-dom'\nimport {\n  isDOMSelection,\n  isDOMNode,\n  isTrackedMutation,\n  IS_FIREFOX,\n} from 'slate-dom'\nimport {\n  EDITOR_TO_FORCE_RENDER,\n  EDITOR_TO_PENDING_ACTION,\n  EDITOR_TO_PENDING_DIFFS,\n  EDITOR_TO_PENDING_INSERTION_MARKS,\n  EDITOR_TO_PENDING_SELECTION,\n  EDITOR_TO_PLACEHOLDER_ELEMENT,\n  EDITOR_TO_USER_MARKS,\n  IS_COMPOSING,\n  IS_NODE_MAP_DIRTY,\n} from 'slate-dom'\n\nexport type Action = { at?: Point | Range; run: () => void }\n\n// https://github.com/facebook/draft-js/blob/main/src/component/handlers/composition/DraftEditorCompositionHandler.js#L41\n// When using keyboard English association function, conpositionEnd triggered too fast, resulting in after `insertText` still maintain association state.\nconst RESOLVE_DELAY = 25\n\n// Time with no user interaction before the current user action is considered as done.\nconst FLUSH_DELAY = 200\n\n// Time with no composition input after which a composition that never ended is\n// treated as stale. Long enough that pausing mid-word does not cut a live\n// composition short.\nconst COMPOSITION_IDLE_TIMEOUT = 5000\n\n// How often a deferred flush re-checks whether the composition is still live.\n// Only bounds how quickly the value catches up with a composition that ended\n// without firing `compositionend`; one that ends normally flushes immediately.\nconst COMPOSITION_RECHECK_DELAY = 50\n\n// Replace with `const debug = console.log` to debug\nconst debug = (..._: unknown[]) => {}\n\n// Type guard to check if a value is a DataTransfer\nconst isDataTransfer = (value: any): value is DataTransfer =>\n  value?.constructor.name === 'DataTransfer'\n\nconst wordEndingAt = (\n  editor: Editor,\n  point: Point,\n  replacement: string\n): Range | null => {\n  const start = Editor.before(editor, point, { unit: 'word' })\n  if (!start || !Path.equals(start.path, point.path)) {\n    return null\n  }\n  const typed = Editor.string(editor, { anchor: start, focus: point })\n  return !/\\s/.test(typed) &&\n    replacement[0]?.toLowerCase() === typed[0].toLowerCase()\n    ? { anchor: start, focus: point }\n    : null\n}\n\nexport type CreateAndroidInputManagerOptions = {\n  editor: ReactEditor\n\n  scheduleOnDOMSelectionChange: DebouncedFunc<() => void>\n  onDOMSelectionChange: DebouncedFunc<() => void>\n}\n\nexport const EDITOR_TO_FLUSH_DEFERRED_DIFFS = new WeakMap<Editor, () => void>()\n\nexport type AndroidInputManager = {\n  flush: () => void\n  flushDeferredDiffs: () => void\n  scheduleFlush: () => void\n\n  hasPendingDiffs: () => boolean\n  hasPendingAction: () => boolean\n  hasPendingChanges: () => boolean\n  isFlushing: () => boolean | 'action'\n\n  handleUserSelect: (range: Range | null) => void\n  handleCompositionEnd: (event: React.CompositionEvent<HTMLDivElement>) => void\n  handleCompositionStart: (\n    event: React.CompositionEvent<HTMLDivElement>\n  ) => void\n  handleDOMBeforeInput: (event: InputEvent) => void\n  handleKeyDown: (event: React.KeyboardEvent<HTMLDivElement>) => void\n\n  handleDomMutations: (mutations: MutationRecord[]) => void\n  handleInput: () => void\n}\n\nexport function createAndroidInputManager({\n  editor,\n  scheduleOnDOMSelectionChange,\n  onDOMSelectionChange,\n}: CreateAndroidInputManagerOptions): AndroidInputManager {\n  let flushing: 'action' | boolean = false\n  let flushingDeferredDiffs = false\n  let compositionEndTimeoutId: ReturnType<typeof setTimeout> | null = null\n  let flushTimeoutId: ReturnType<typeof setTimeout> | null = null\n  let actionTimeoutId: ReturnType<typeof setTimeout> | null = null\n  let lastCompositionActivity = 0\n  let lastInsertText = 0\n  let compositionCleared = false\n  let hasUnrenderedMutations = false\n\n  let idCounter = 0\n  let insertPositionHint: StringDiff | null | false = false\n\n  const applyPendingSelection = () => {\n    const pendingSelection = EDITOR_TO_PENDING_SELECTION.get(editor)\n    EDITOR_TO_PENDING_SELECTION.delete(editor)\n\n    if (pendingSelection) {\n      const { selection } = editor\n      const normalized = normalizeRange(editor, pendingSelection)\n\n      debug('apply pending selection', pendingSelection, normalized)\n\n      if (normalized && (!selection || !Range.equals(normalized, selection))) {\n        Transforms.select(editor, normalized)\n      }\n    }\n  }\n\n  const performAction = () => {\n    const { children } = editor\n    runPendingAction()\n\n    if (hasUnrenderedMutations && editor.children === children) {\n      EDITOR_TO_FORCE_RENDER.get(editor)?.()\n    }\n    hasUnrenderedMutations = false\n  }\n\n  const runPendingAction = () => {\n    const action = EDITOR_TO_PENDING_ACTION.get(editor)\n    EDITOR_TO_PENDING_ACTION.delete(editor)\n    if (!action) {\n      return\n    }\n\n    if (action.at) {\n      const target = Location.isPoint(action.at)\n        ? normalizePoint(editor, action.at)\n        : normalizeRange(editor, action.at)\n\n      if (!target) {\n        return\n      }\n\n      const targetRange = Editor.range(editor, target)\n      if (!editor.selection || !Range.equals(editor.selection, targetRange)) {\n        Transforms.select(editor, target)\n      }\n    }\n\n    action.run()\n  }\n\n  // `compositionend` is not fired reliably in every browser, which Slate\n  // already works around on keydown. Deferring flushes on a composition that\n  // never ends would strand the typed text outside the value, so a composition\n  // that has gone quiet, or that has lost focus, no longer holds flushes back.\n  const isCompositionLive = () => {\n    if (!IS_COMPOSING.get(editor) || compositionCleared) {\n      return false\n    }\n\n    try {\n      const editable = ReactEditor.toDOMNode(editor, editor)\n      const { activeElement } = ReactEditor.getWindow(editor).document\n\n      if (activeElement !== editable && !editable.contains(activeElement)) {\n        return false\n      }\n    } catch {\n      // Fall back to the idle check below if the editable can't be resolved.\n    }\n\n    return Date.now() - lastCompositionActivity < COMPOSITION_IDLE_TIMEOUT\n  }\n\n  // A leaf that Slate models as empty renders as a zero-width string, which on\n  // Android is a `<br>` rather than a text node. When the IME composes the\n  // first character into such a leaf, the browser creates a text node for the\n  // composition. Applying the pending diffs re-renders that leaf as a text\n  // leaf, which unmounts the zero-width span and takes the text node the IME is\n  // composing in with it, silently cancelling the composition.\n  const hasPendingDiffsInEmptyLeaf = () =>\n    !!EDITOR_TO_PENDING_DIFFS.get(editor)?.some(({ path }) => {\n      try {\n        return Node.leaf(editor, path).text.length === 0\n      } catch {\n        // The path may no longer resolve if the editor changed underneath us.\n        return false\n      }\n    })\n\n  const hasPendingDiffsInNewLeaf = () =>\n    hasPendingDiffsInEmptyLeaf() ||\n    (hasPendingDiffs() &&\n      EDITOR_TO_PENDING_INSERTION_MARKS.get(editor) !== undefined)\n\n  const flush = () => {\n    if (flushTimeoutId) {\n      clearTimeout(flushTimeoutId)\n      flushTimeoutId = null\n    }\n\n    if (actionTimeoutId) {\n      clearTimeout(actionTimeoutId)\n      actionTimeoutId = null\n    }\n\n    // Defer flushing until the composition ends, so that the re-render that\n    // would replace the composing text node cannot happen mid-composition.\n    // Composing into a leaf that already has text is unaffected: applying the\n    // diff there only updates `textContent`, so the value still updates on\n    // every `compositionupdate`.\n    if (\n      !flushingDeferredDiffs &&\n      isCompositionLive() &&\n      hasPendingDiffsInNewLeaf()\n    ) {\n      debug('deferring flush during composition in new leaf')\n      flushTimeoutId = setTimeout(flush, COMPOSITION_RECHECK_DELAY)\n      return\n    }\n\n    if (!hasPendingDiffs() && !hasPendingAction()) {\n      applyPendingSelection()\n      return\n    }\n\n    if (!flushing) {\n      flushing = true\n      setTimeout(() => (flushing = false))\n    }\n\n    if (hasPendingAction()) {\n      flushing = 'action'\n    }\n\n    const selectionRef =\n      editor.selection &&\n      Editor.rangeRef(editor, editor.selection, { affinity: 'forward' })\n    EDITOR_TO_USER_MARKS.set(editor, editor.marks)\n\n    debug(\n      'flush',\n      EDITOR_TO_PENDING_ACTION.get(editor),\n      EDITOR_TO_PENDING_DIFFS.get(editor)\n    )\n\n    let scheduleSelectionChange = hasPendingDiffs()\n\n    let diff: TextDiff | undefined\n    while ((diff = EDITOR_TO_PENDING_DIFFS.get(editor)?.[0])) {\n      const pendingMarks = EDITOR_TO_PENDING_INSERTION_MARKS.get(editor)\n\n      if (pendingMarks !== undefined) {\n        EDITOR_TO_PENDING_INSERTION_MARKS.delete(editor)\n        editor.marks = pendingMarks\n      }\n\n      if (pendingMarks && insertPositionHint === false) {\n        insertPositionHint = null\n        debug('insert after mark placeholder')\n      }\n\n      const range = targetRange(diff)\n      if (!editor.selection || !Range.equals(editor.selection, range)) {\n        Transforms.select(editor, range)\n      }\n\n      if (diff.diff.text) {\n        Editor.insertText(editor, diff.diff.text)\n      } else {\n        Editor.deleteFragment(editor)\n      }\n\n      // Remove diff only after we have applied it to account for it when transforming\n      // pending ranges.\n      EDITOR_TO_PENDING_DIFFS.set(\n        editor,\n        EDITOR_TO_PENDING_DIFFS.get(editor)?.filter(\n          ({ id }) => id !== diff!.id\n        )!\n      )\n\n      if (!verifyDiffState(editor, diff)) {\n        debug('invalid diff state')\n        scheduleSelectionChange = false\n        EDITOR_TO_PENDING_ACTION.delete(editor)\n        EDITOR_TO_USER_MARKS.delete(editor)\n        flushing = 'action'\n\n        // Ensure we don't restore the pending user (dom) selection\n        // since the document and dom state do not match.\n        EDITOR_TO_PENDING_SELECTION.delete(editor)\n        scheduleOnDOMSelectionChange.cancel()\n        onDOMSelectionChange.cancel()\n        selectionRef?.unref()\n      }\n    }\n\n    const selection = selectionRef?.unref()\n    if (\n      selection &&\n      !EDITOR_TO_PENDING_SELECTION.get(editor) &&\n      (!editor.selection || !Range.equals(selection, editor.selection))\n    ) {\n      Transforms.select(editor, selection)\n    }\n\n    if (hasPendingAction()) {\n      performAction()\n      return\n    }\n\n    // COMPAT: The selectionChange event is fired after the action is performed,\n    // so we have to manually schedule it to ensure we don't 'throw away' the selection\n    // while rendering if we have pending changes.\n    if (scheduleSelectionChange) {\n      debug('scheduleOnDOMSelectionChange pending changes')\n      scheduleOnDOMSelectionChange()\n    }\n\n    scheduleOnDOMSelectionChange.flush()\n    onDOMSelectionChange.flush()\n\n    applyPendingSelection()\n\n    const userMarks = EDITOR_TO_USER_MARKS.get(editor)\n    EDITOR_TO_USER_MARKS.delete(editor)\n    if (userMarks !== undefined && userMarks !== editor.marks) {\n      editor.marks = userMarks\n      editor.onChange()\n    }\n  }\n\n  const flushDeferredDiffs = () => {\n    if (flushing || !isCompositionLive() || !hasPendingDiffsInNewLeaf()) {\n      return\n    }\n\n    debug('flushing deferred diffs before a structural change')\n    flushingDeferredDiffs = true\n    try {\n      flush()\n    } finally {\n      flushingDeferredDiffs = false\n    }\n  }\n\n  const handleCompositionEnd = (\n    _event: React.CompositionEvent<HTMLDivElement>\n  ) => {\n    if (compositionEndTimeoutId) {\n      clearTimeout(compositionEndTimeoutId)\n    }\n\n    // Diffs deferred by `flush` have to be applied synchronously here. IMEs\n    // that compose one syllable at a time (Hangul, kana) start the next\n    // composition in the same tick as this event, so an asynchronous render\n    // would replace the text node that composition has already started in.\n    if (hasPendingDiffsInNewLeaf() && !flushing) {\n      ReactDOM.flushSync(() => {\n        IS_COMPOSING.set(editor, false)\n        flush()\n      })\n      updatePlaceholderVisibility()\n      return\n    }\n\n    compositionEndTimeoutId = setTimeout(() => {\n      IS_COMPOSING.set(editor, false)\n      flush()\n\n      if (compositionCleared) {\n        // A cancelled composition can take the empty leaf's text node with\n        // it. A forced render lets RestoreDOM put the leaf's DOM back, so the\n        // next composition starts from a clean state instead of a bare <br>.\n        EDITOR_TO_FORCE_RENDER.get(editor)?.()\n      }\n\n      updatePlaceholderVisibility()\n    }, RESOLVE_DELAY)\n  }\n\n  const handleCompositionStart = (\n    _event: React.CompositionEvent<HTMLDivElement>\n  ) => {\n    debug('composition start')\n\n    IS_COMPOSING.set(editor, true)\n    lastCompositionActivity = Date.now()\n    compositionCleared = false\n\n    if (compositionEndTimeoutId) {\n      clearTimeout(compositionEndTimeoutId)\n      compositionEndTimeoutId = null\n    }\n  }\n\n  const updatePlaceholderVisibility = (forceHide = false) => {\n    const placeholderElement = EDITOR_TO_PLACEHOLDER_ELEMENT.get(editor)\n    if (!placeholderElement) {\n      return\n    }\n\n    if (hasPendingDiffs() || forceHide) {\n      placeholderElement.style.display = 'none'\n      return\n    }\n\n    placeholderElement.style.removeProperty('display')\n  }\n\n  const storeDiff = (path: Path, diff: StringDiff) => {\n    debug('storeDiff', path, diff)\n\n    const pendingDiffs = EDITOR_TO_PENDING_DIFFS.get(editor) ?? []\n    EDITOR_TO_PENDING_DIFFS.set(editor, pendingDiffs)\n\n    const target = Node.leaf(editor, path)\n    const idx = pendingDiffs.findIndex(change => Path.equals(change.path, path))\n    if (idx < 0) {\n      const normalized = normalizeStringDiff(target.text, diff)\n      if (normalized) {\n        pendingDiffs.push({ path, diff, id: idCounter++ })\n      }\n\n      updatePlaceholderVisibility()\n      return\n    }\n\n    const merged = mergeStringDiffs(target.text, pendingDiffs[idx].diff, diff)\n    if (!merged) {\n      pendingDiffs.splice(idx, 1)\n      updatePlaceholderVisibility()\n      return\n    }\n\n    pendingDiffs[idx] = {\n      ...pendingDiffs[idx],\n      diff: merged,\n    }\n  }\n\n  const scheduleAction = (\n    run: () => void,\n    { at }: { at?: Point | Range } = {}\n  ): void => {\n    insertPositionHint = false\n    debug('scheduleAction', { at, run })\n\n    EDITOR_TO_PENDING_SELECTION.delete(editor)\n    scheduleOnDOMSelectionChange.cancel()\n    onDOMSelectionChange.cancel()\n\n    if (hasPendingAction()) {\n      flush()\n    }\n\n    if (actionTimeoutId) {\n      clearTimeout(actionTimeoutId)\n    }\n\n    EDITOR_TO_PENDING_ACTION.set(editor, { at, run })\n\n    // COMPAT: When deleting before a non-contenteditable element chrome only fires a beforeinput,\n    // (no input) and doesn't perform any dom mutations. Without a flush timeout we would never flush\n    // in this case and thus never actually perform the action.\n    actionTimeoutId = setTimeout(flush)\n  }\n\n  const handleDOMBeforeInput = (event: InputEvent): void => {\n    if (flushTimeoutId) {\n      clearTimeout(flushTimeoutId)\n      flushTimeoutId = null\n    }\n\n    const isNodeMapDirty = IS_NODE_MAP_DIRTY.get(editor)\n    const { inputType: type } = event\n    const continuesFirefoxInsert =\n      IS_FIREFOX &&\n      type === 'insertText' &&\n      Date.now() - lastInsertText < RESOLVE_DELAY\n\n    if (type === 'insertText') {\n      lastInsertText = Date.now()\n    }\n\n    if (type === 'insertCompositionText' || type === 'deleteCompositionText') {\n      lastCompositionActivity = Date.now()\n\n      if (event.data) {\n        compositionCleared = false\n      } else {\n        // The IME threw away what it was composing. The deferred text never\n        // reached the value, so the value is already in the desired state -\n        // drop the deferral instead of applying and re-deleting it, which\n        // would churn the DOM mid-composition and can make Android close the\n        // keyboard.\n        compositionCleared = true\n        const deferredDiffs = EDITOR_TO_PENDING_DIFFS.get(editor)\n\n        if (deferredDiffs?.length) {\n          const allInEmptyLeaves = deferredDiffs.every(({ path }) => {\n            try {\n              return Node.leaf(editor, path).text.length === 0\n            } catch {\n              return false\n            }\n          })\n\n          if (allInEmptyLeaves) {\n            EDITOR_TO_PENDING_DIFFS.set(editor, [])\n            EDITOR_TO_PENDING_SELECTION.delete(editor)\n          }\n        }\n      }\n    }\n\n    let targetRange: Range | null = null\n    const data: DataTransfer | string | undefined =\n      (event as any).dataTransfer || event.data || undefined\n\n    if (\n      insertPositionHint !== false &&\n      type !== 'insertText' &&\n      type !== 'insertCompositionText'\n    ) {\n      insertPositionHint = false\n    }\n\n    let [nativeTargetRange] = (event as any).getTargetRanges()\n    const targetOutsideEditor =\n      !!nativeTargetRange &&\n      !ReactEditor.hasDOMNode(editor, nativeTargetRange.startContainer)\n    if (nativeTargetRange && !isNodeMapDirty) {\n      targetRange = ReactEditor.toSlateRange(editor, nativeTargetRange, {\n        exactMatch: false,\n        suppressThrow: true,\n      })\n    }\n\n    // COMPAT: SelectionChange event is fired after the action is performed, so we\n    // have to manually get the selection here to ensure it's up-to-date.\n    const window = ReactEditor.getWindow(editor)\n    const domSelection = window.getSelection()\n    if (!targetRange && domSelection && !isNodeMapDirty) {\n      nativeTargetRange = domSelection\n      targetRange = ReactEditor.toSlateRange(editor, domSelection, {\n        exactMatch: false,\n        suppressThrow: true,\n      })\n    }\n\n    targetRange = targetRange ?? editor.selection\n    if (!targetRange) {\n      return\n    }\n\n    // By default, the input manager tries to store text diffs so that we can\n    // defer flushing them at a later point in time. We don't want to flush\n    // for every input event as this can be expensive. However, there are some\n    // scenarios where we cannot safely store the text diff and must instead\n    // schedule an action to let Slate normalize the editor state.\n    let canStoreDiff = true\n\n    if (type.startsWith('delete')) {\n      const direction = type.endsWith('Backward') ? 'backward' : 'forward'\n      let [start, end] = Range.edges(targetRange)\n      let [leaf, path] = Editor.leaf(editor, start.path)\n\n      if (Range.isExpanded(targetRange)) {\n        if (leaf.text.length === start.offset && end.offset === 0) {\n          const next = Editor.next(editor, {\n            at: start.path,\n            match: Node.isText,\n          })\n          if (next && Path.equals(next[1], end.path)) {\n            // when deleting a linebreak, targetRange will span across the break (ie start in the node before and end in the node after)\n            // if the node before is empty, this will look like a hanging range and get unhung later--which will take the break we want to remove out of the range\n            // so to avoid this we collapse the target range to default to single character deletion\n            if (direction === 'backward') {\n              targetRange = { anchor: end, focus: end }\n              start = end\n              ;[leaf, path] = next\n            } else {\n              targetRange = { anchor: start, focus: start }\n              end = start\n            }\n          }\n        }\n      }\n\n      const diff = {\n        text: '',\n        start: start.offset,\n        end: end.offset,\n      }\n      const pendingDiffs = EDITOR_TO_PENDING_DIFFS.get(editor)\n      const relevantPendingDiffs = pendingDiffs?.find(change =>\n        Path.equals(change.path, path)\n      )\n      const diffs = relevantPendingDiffs\n        ? [relevantPendingDiffs.diff, diff]\n        : [diff]\n      const text = applyStringDiff(leaf.text, ...diffs)\n\n      if (text.length === 0) {\n        // Text leaf will be removed, so we need to schedule an\n        // action to remove it so that Slate can normalize instead\n        // of storing as a diff\n        canStoreDiff = false\n      }\n\n      if (Range.isExpanded(targetRange)) {\n        if (\n          canStoreDiff &&\n          Path.equals(targetRange.anchor.path, targetRange.focus.path)\n        ) {\n          const point = { path: targetRange.anchor.path, offset: start.offset }\n          const range = Editor.range(editor, point, point)\n          handleUserSelect(range)\n\n          storeDiff(targetRange.anchor.path, {\n            text: '',\n            end: end.offset,\n            start: start.offset,\n          })\n          if (type === 'deleteContentBackward') {\n            scheduleFlush()\n          }\n          return\n        }\n\n        return scheduleAction(\n          () => Editor.deleteFragment(editor, { direction }),\n          { at: targetRange }\n        )\n      }\n    }\n\n    switch (type) {\n      case 'deleteByComposition':\n      case 'deleteByCut':\n      case 'deleteByDrag': {\n        return scheduleAction(() => Editor.deleteFragment(editor), {\n          at: targetRange,\n        })\n      }\n\n      case 'deleteContent':\n      case 'deleteContentForward': {\n        const { anchor } = targetRange\n        if (canStoreDiff && Range.isCollapsed(targetRange)) {\n          const targetNode = Node.leaf(editor, anchor.path)\n\n          if (anchor.offset < targetNode.text.length) {\n            return storeDiff(anchor.path, {\n              text: '',\n              start: anchor.offset,\n              end: anchor.offset + 1,\n            })\n          }\n        }\n\n        return scheduleAction(() => Editor.deleteForward(editor), {\n          at: targetRange,\n        })\n      }\n\n      case 'deleteContentBackward': {\n        const { anchor } = targetRange\n\n        // If we have a mismatch between the native and slate selection being collapsed\n        // we are most likely deleting a zero-width placeholder and thus should perform it\n        // as an action to ensure correct behavior (mostly happens with mark placeholders)\n        const nativeCollapsed = isDOMSelection(nativeTargetRange)\n          ? nativeTargetRange.isCollapsed\n          : !!nativeTargetRange?.collapsed\n\n        if (\n          canStoreDiff &&\n          nativeCollapsed &&\n          Range.isCollapsed(targetRange) &&\n          anchor.offset > 0\n        ) {\n          storeDiff(anchor.path, {\n            text: '',\n            start: anchor.offset - 1,\n            end: anchor.offset,\n          })\n          scheduleFlush()\n          return\n        }\n\n        return scheduleAction(() => Editor.deleteBackward(editor), {\n          at: targetRange,\n        })\n      }\n\n      case 'deleteEntireSoftLine': {\n        return scheduleAction(\n          () => {\n            Editor.deleteBackward(editor, { unit: 'line' })\n            Editor.deleteForward(editor, { unit: 'line' })\n          },\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteHardLineBackward': {\n        return scheduleAction(\n          () => Editor.deleteBackward(editor, { unit: 'block' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteSoftLineBackward': {\n        return scheduleAction(\n          () => Editor.deleteBackward(editor, { unit: 'line' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteHardLineForward': {\n        return scheduleAction(\n          () => Editor.deleteForward(editor, { unit: 'block' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteSoftLineForward': {\n        return scheduleAction(\n          () => Editor.deleteForward(editor, { unit: 'line' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteWordBackward': {\n        return scheduleAction(\n          () => Editor.deleteBackward(editor, { unit: 'word' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'deleteWordForward': {\n        return scheduleAction(\n          () => Editor.deleteForward(editor, { unit: 'word' }),\n          { at: targetRange }\n        )\n      }\n\n      case 'insertLineBreak': {\n        return scheduleAction(() => Editor.insertSoftBreak(editor), {\n          at: targetRange,\n        })\n      }\n\n      case 'insertParagraph': {\n        return scheduleAction(() => Editor.insertBreak(editor), {\n          at: targetRange,\n        })\n      }\n      case 'insertCompositionText':\n      case 'deleteCompositionText':\n      case 'insertFromComposition':\n      case 'insertFromDrop':\n      case 'insertFromPaste':\n      case 'insertFromYank':\n      case 'insertReplacementText':\n      case 'insertText': {\n        if (isDataTransfer(data)) {\n          return scheduleAction(() => ReactEditor.insertData(editor, data), {\n            at: targetRange,\n          })\n        }\n\n        let text = data ?? ''\n\n        // COMPAT: If we are writing inside a placeholder, the ime inserts the text inside\n        // the placeholder itself and thus includes the zero-width space inside edit events.\n        if (EDITOR_TO_PENDING_INSERTION_MARKS.get(editor)) {\n          text = text.replace('\\uFEFF', '')\n        }\n\n        if (\n          continuesFirefoxInsert &&\n          editor.selection &&\n          !Range.equals(targetRange, editor.selection)\n        ) {\n          event.preventDefault()\n          return scheduleAction(() => Editor.insertText(editor, text))\n        }\n\n        if (targetOutsideEditor && Range.isCollapsed(targetRange)) {\n          event.preventDefault()\n          return scheduleAction(() => Editor.insertText(editor, text), {\n            at: wordEndingAt(editor, targetRange.anchor, text) ?? targetRange,\n          })\n        }\n\n        // Pastes from the Android clipboard will generate `insertText` events.\n        // If the copied text contains any newlines, Android will append an\n        // extra newline to the end of the copied text.\n        if (type === 'insertText' && /.*\\n.*\\n$/.test(text)) {\n          text = text.slice(0, -1)\n        }\n\n        // If the text includes a newline, split it at newlines and paste each component\n        // string, with soft breaks in between each.\n        if (text.includes('\\n')) {\n          return scheduleAction(\n            () => {\n              const parts = text.split('\\n')\n              parts.forEach((line, i) => {\n                if (line) {\n                  Editor.insertText(editor, line)\n                }\n                if (i !== parts.length - 1) {\n                  Editor.insertSoftBreak(editor)\n                }\n              })\n            },\n            {\n              at: targetRange,\n            }\n          )\n        }\n\n        if (\n          type === 'insertText' &&\n          !ReactEditor.isComposing(editor) &&\n          Range.isCollapsed(targetRange) &&\n          typeof Editor.insertionPoint === 'function' &&\n          !Point.equals(\n            Editor.insertionPoint(editor, targetRange.anchor),\n            targetRange.anchor\n          )\n        ) {\n          const node = isDOMSelection(nativeTargetRange)\n            ? nativeTargetRange.anchorNode\n            : nativeTargetRange?.startContainer\n          const snapshot =\n            isDOMNode(node) && node.nodeType === 3\n              ? { node, text: node.textContent }\n              : null\n          event.preventDefault()\n          return scheduleAction(\n            () => {\n              if (\n                snapshot &&\n                snapshot.node.isConnected &&\n                snapshot.node.textContent !== snapshot.text\n              ) {\n                snapshot.node.textContent = snapshot.text\n              }\n              Editor.insertText(editor, text)\n            },\n            {\n              at: targetRange,\n            }\n          )\n        }\n\n        if (Path.equals(targetRange.anchor.path, targetRange.focus.path)) {\n          const [start, end] = Range.edges(targetRange)\n\n          const diff = {\n            start: start.offset,\n            end: end.offset,\n            text,\n          }\n\n          // COMPAT: Swiftkey has a weird bug where the target range of the 2nd word\n          // inserted after a mark placeholder is inserted with an anchor offset off by 1.\n          // So writing 'some text' will result in 'some ttext'. Luckily all 'normal' insert\n          // text events are fired with the correct target ranges, only the final 'insertComposition'\n          // isn't, so we can adjust the target range start offset if we are confident this is the\n          // swiftkey insert causing the issue.\n          if (text && insertPositionHint && type === 'insertCompositionText') {\n            const hintPosition =\n              insertPositionHint.start + insertPositionHint.text.search(/\\S|$/)\n            const diffPosition = diff.start + diff.text.search(/\\S|$/)\n\n            if (\n              diffPosition === hintPosition + 1 &&\n              diff.end ===\n                insertPositionHint.start + insertPositionHint.text.length\n            ) {\n              debug('adjusting swiftKey insert position using hint')\n              diff.start -= 1\n              insertPositionHint = null\n              scheduleFlush()\n            } else {\n              insertPositionHint = false\n            }\n          } else if (type === 'insertText') {\n            if (insertPositionHint === null) {\n              insertPositionHint = diff\n            } else if (\n              insertPositionHint &&\n              Range.isCollapsed(targetRange) &&\n              insertPositionHint.end + insertPositionHint.text.length ===\n                start.offset\n            ) {\n              insertPositionHint = {\n                ...insertPositionHint,\n                text: insertPositionHint.text + text,\n              }\n            } else {\n              insertPositionHint = false\n            }\n          } else {\n            insertPositionHint = false\n          }\n\n          if (canStoreDiff) {\n            const currentSelection = editor.selection\n            storeDiff(start.path, diff)\n\n            if (currentSelection) {\n              const newPoint = {\n                path: start.path,\n                offset: start.offset + text.length,\n              }\n\n              scheduleAction(() => {}, { at: newPoint })\n            }\n            return\n          }\n        }\n\n        return scheduleAction(() => Editor.insertText(editor, text), {\n          at: targetRange,\n        })\n      }\n    }\n  }\n\n  const hasPendingAction = () => {\n    return !!EDITOR_TO_PENDING_ACTION.get(editor)\n  }\n\n  const hasPendingDiffs = () => {\n    return !!EDITOR_TO_PENDING_DIFFS.get(editor)?.length\n  }\n\n  const hasPendingChanges = () => {\n    return hasPendingAction() || hasPendingDiffs()\n  }\n\n  const isFlushing = () => {\n    return flushing\n  }\n\n  const handleUserSelect = (range: Range | null) => {\n    EDITOR_TO_PENDING_SELECTION.set(editor, range)\n\n    if (flushTimeoutId) {\n      clearTimeout(flushTimeoutId)\n      flushTimeoutId = null\n    }\n\n    const { selection } = editor\n    if (!range) {\n      return\n    }\n\n    const pathChanged =\n      !selection || !Path.equals(selection.anchor.path, range.anchor.path)\n    const parentPathChanged =\n      !selection ||\n      !Path.equals(\n        selection.anchor.path.slice(0, -1),\n        range.anchor.path.slice(0, -1)\n      )\n\n    if ((pathChanged && insertPositionHint) || parentPathChanged) {\n      insertPositionHint = false\n    }\n\n    if (pathChanged || hasPendingDiffs()) {\n      flushTimeoutId = setTimeout(flush, FLUSH_DELAY)\n    }\n  }\n\n  const handleInput = () => {\n    if (hasPendingAction() || !hasPendingDiffs()) {\n      debug('flush input')\n      flush()\n    }\n  }\n\n  const handleKeyDown = (_: React.KeyboardEvent) => {\n    // COMPAT: Swiftkey closes the keyboard when typing inside a empty node\n    // directly next to a non-contenteditable element (= the placeholder).\n    // The only event fired soon enough for us to allow hiding the placeholder\n    // without swiftkey picking it up is the keydown event, so we have to hide it\n    // here. See https://github.com/ianstormtaylor/slate/pull/4988#issuecomment-1201050535\n    if (!hasPendingDiffs()) {\n      updatePlaceholderVisibility(true)\n      setTimeout(updatePlaceholderVisibility)\n    }\n  }\n\n  const scheduleFlush = () => {\n    if (!hasPendingAction()) {\n      if (actionTimeoutId) {\n        clearTimeout(actionTimeoutId)\n      }\n      actionTimeoutId = setTimeout(flush)\n    }\n  }\n\n  const handleDomMutations = (mutations: MutationRecord[]) => {\n    if (hasPendingDiffs()) {\n      return\n    }\n\n    if (\n      !mutations.some(mutation =>\n        isTrackedMutation(editor, mutation, mutations)\n      )\n    ) {\n      return\n    }\n\n    if (hasPendingAction()) {\n      hasUnrenderedMutations = true\n      return\n    }\n\n    // Cause a re-render to restore the dom state if we encounter tracked mutations without\n    // a corresponding pending action.\n    EDITOR_TO_FORCE_RENDER.get(editor)?.()\n  }\n\n  return {\n    flush,\n    flushDeferredDiffs,\n    scheduleFlush,\n\n    hasPendingDiffs,\n    hasPendingAction,\n    hasPendingChanges,\n\n    isFlushing,\n\n    handleUserSelect,\n    handleCompositionEnd,\n    handleCompositionStart,\n    handleDOMBeforeInput,\n    handleKeyDown,\n\n    handleDomMutations,\n    handleInput,\n  }\n}\n","import { useEffect, useRef } from 'react'\n\nexport function useIsMounted() {\n  const isMountedRef = useRef(false)\n\n  useEffect(() => {\n    isMountedRef.current = true\n    return () => {\n      isMountedRef.current = false\n    }\n  }, [])\n\n  return isMountedRef.current\n}\n","import { useLayoutEffect, useEffect } from 'react'\nimport { CAN_USE_DOM } from 'slate-dom'\n\n/**\n * Prevent warning on SSR by falling back to useEffect when DOM isn't available\n */\n\nexport const useIsomorphicLayoutEffect = CAN_USE_DOM\n  ? useLayoutEffect\n  : useEffect\n","import { RefObject, useEffect, useState } from 'react'\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect'\n\nexport function useMutationObserver(\n  node: RefObject<HTMLElement | null>,\n  callback: MutationCallback,\n  options: MutationObserverInit\n) {\n  const [mutationObserver] = useState(() => new MutationObserver(callback))\n\n  useIsomorphicLayoutEffect(() => {\n    // Discard mutations caused during render phase. This works due to react calling\n    // useLayoutEffect synchronously after the render phase before the next tick.\n    mutationObserver.takeRecords()\n  })\n\n  useEffect(() => {\n    if (!node.current) {\n      throw new Error('Failed to attach MutationObserver, `node` is undefined')\n    }\n\n    mutationObserver.observe(node.current, options)\n    return () => mutationObserver.disconnect()\n  }, [mutationObserver, node, options])\n}\n","import { RefObject, useState } from 'react'\nimport { useSlateStatic } from '../use-slate-static'\nimport { IS_ANDROID } from 'slate-dom'\nimport { EDITOR_TO_SCHEDULE_FLUSH } from 'slate-dom'\nimport {\n  createAndroidInputManager,\n  CreateAndroidInputManagerOptions,\n  EDITOR_TO_FLUSH_DEFERRED_DIFFS,\n} from './android-input-manager'\nimport { useIsMounted } from '../use-is-mounted'\nimport { useMutationObserver } from '../use-mutation-observer'\n\ntype UseAndroidInputManagerOptions = {\n  node: RefObject<HTMLElement | null>\n} & Omit<\n  CreateAndroidInputManagerOptions,\n  'editor' | 'onUserInput' | 'receivedUserInput'\n>\n\nconst MUTATION_OBSERVER_CONFIG: MutationObserverInit = {\n  subtree: true,\n  childList: true,\n  characterData: true,\n}\n\nexport const useAndroidInputManager = !IS_ANDROID\n  ? () => null\n  : ({ node, ...options }: UseAndroidInputManagerOptions) => {\n      if (!IS_ANDROID) {\n        return null\n      }\n\n      const editor = useSlateStatic()\n      const isMounted = useIsMounted()\n\n      const [inputManager] = useState(() =>\n        createAndroidInputManager({\n          editor,\n          ...options,\n        })\n      )\n\n      useMutationObserver(\n        node,\n        inputManager.handleDomMutations,\n        MUTATION_OBSERVER_CONFIG\n      )\n\n      EDITOR_TO_SCHEDULE_FLUSH.set(editor, inputManager.scheduleFlush)\n      EDITOR_TO_FLUSH_DEFERRED_DIFFS.set(\n        editor,\n        inputManager.flushDeferredDiffs\n      )\n      if (isMounted) {\n        inputManager.flush()\n      }\n\n      return inputManager\n    }\n","import React, { forwardRef, memo, useRef, useState } from 'react'\nimport { Editor, Text, Path, Element, Node } from 'slate'\n\nimport { ReactEditor, useSlateStatic } from '..'\nimport { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\nimport { IS_ANDROID, IS_COMPOSING, IS_FIREFOX, DOMText } from 'slate-dom'\nimport { MARK_PLACEHOLDER_SYMBOL } from 'slate-dom'\n\n/**\n * Leaf content strings.\n */\n\nconst String = (props: {\n  isLast: boolean\n  leaf: Text\n  parent: Element\n  text: Text\n}) => {\n  const { isLast, leaf, parent, text } = props\n  const editor = useSlateStatic()\n  const path = ReactEditor.findPath(editor, text)\n  const parentPath = Path.parent(path)\n  const isMarkPlaceholder = Boolean(leaf[MARK_PLACEHOLDER_SYMBOL])\n\n  // COMPAT: Render text inside void nodes with a zero-width space.\n  // So the node can contain selection but the text is not visible.\n  if (editor.isVoid(parent)) {\n    return <ZeroWidthString length={Node.string(parent).length} />\n  }\n\n  // COMPAT: If this is the last text node in an empty block, render a zero-\n  // width space that will convert into a line break when copying and pasting\n  // to support expected plain text.\n  if (\n    leaf.text === '' &&\n    parent.children[parent.children.length - 1] === text &&\n    !editor.isInline(parent) &&\n    Editor.string(editor, parentPath) === ''\n  ) {\n    return <ZeroWidthString isLineBreak isMarkPlaceholder={isMarkPlaceholder} />\n  }\n\n  // COMPAT: If the text is empty, it's because it's on the edge of an inline\n  // node, so we render a zero-width space so that the selection can be\n  // inserted next to it still.\n  if (leaf.text === '') {\n    return <ZeroWidthString isMarkPlaceholder={isMarkPlaceholder} />\n  }\n\n  // COMPAT: Browsers will collapse trailing new lines at the end of blocks,\n  // so we need to add an extra trailing new lines to prevent that.\n  if (isLast && leaf.text.slice(-1) === '\\n') {\n    return <TextString isTrailing text={leaf.text} />\n  }\n\n  return <TextString text={leaf.text} />\n}\n\n/**\n * Leaf strings with text in them.\n */\nconst TextString = (props: { text: string; isTrailing?: boolean }) => {\n  const { text, isTrailing = false } = props\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLSpanElement>(null)\n  const getTextContent = () => {\n    return `${text ?? ''}${isTrailing ? '\\n' : ''}`\n  }\n  const [initialText] = useState(getTextContent)\n\n  // This is the actual text rendering boundary where we interface with the DOM\n  // The text is not rendered as part of the virtual DOM, as since we handle basic character insertions natively,\n  // updating the DOM is not a one way dataflow anymore. What we need here is not reconciliation and diffing\n  // with previous version of the virtual DOM, but rather diffing with the actual DOM element, and replace the DOM <span> content\n  // exactly if and only if its current content does not match our current virtual DOM.\n  // Otherwise the DOM TextNode would always be replaced by React as the user types, which interferes with native text features,\n  // eg makes native spellcheck opt out from checking the text node.\n\n  // useLayoutEffect: updating our span before browser paint\n  useIsomorphicLayoutEffect(() => {\n    // null coalescing text to make sure we're not outputing \"null\" as a string in the extreme case it is nullish at runtime\n    const textWithTrailing = getTextContent()\n\n    if (ref.current && ref.current.textContent !== textWithTrailing) {\n      // On Android the DOM intentionally runs ahead of the value while the IME\n      // composes, since input is buffered as pending diffs. Writing\n      // `textContent` here would replace the text node the composition lives in\n      // and cancel it; the pending diffs reconcile this span when the\n      // composition ends.\n      if (IS_ANDROID && IS_COMPOSING.get(editor)) {\n        const composingNode =\n          ReactEditor.getWindow(editor).getSelection()?.anchorNode\n\n        if (composingNode && ref.current.contains(composingNode)) {\n          return\n        }\n      }\n\n      ref.current.textContent = textWithTrailing\n    }\n\n    if (IS_FIREFOX) {\n      ref.current?.toggleAttribute('data-slate-trailing', isTrailing)\n    }\n\n    const textNode = ref.current?.firstChild\n    if (\n      IS_FIREFOX &&\n      isTrailing &&\n      ref.current?.childNodes.length === 1 &&\n      textNode?.nodeType === 3\n    ) {\n      ;(textNode as DOMText).splitText(text.length)\n    }\n\n    // intentionally not specifying dependencies, so that this effect runs on every render\n    // as this effectively replaces \"specifying the text in the virtual DOM under the <span> below\" on each render\n  })\n\n  // We intentionally render a memoized <span> that only receives the initial text content when the component is mounted.\n  // We defer to the layout effect above to update the `textContent` of the span element when needed.\n  return <MemoizedText ref={ref}>{initialText}</MemoizedText>\n}\n\nconst MemoizedText = memo(\n  forwardRef<HTMLSpanElement, { children: string }>((props, ref) => {\n    return (\n      <span data-slate-string ref={ref}>\n        {props.children}\n      </span>\n    )\n  })\n)\n\n/**\n * Leaf strings without text, render as zero-width strings.\n */\n\nexport const ZeroWidthString = (props: {\n  length?: number\n  isLineBreak?: boolean\n  isMarkPlaceholder?: boolean\n}) => {\n  const { length = 0, isLineBreak = false, isMarkPlaceholder = false } = props\n\n  const attributes: {\n    'data-slate-zero-width': string\n    'data-slate-length': number\n    'data-slate-mark-placeholder'?: boolean\n  } = {\n    'data-slate-zero-width': isLineBreak ? 'n' : 'z',\n    'data-slate-length': length,\n  }\n\n  if (isMarkPlaceholder) {\n    attributes['data-slate-mark-placeholder'] = true\n  }\n\n  // FIXME: Inserting the \\uFEFF on iOS breaks capitalization at the start of an\n  // empty editor (https://github.com/ianstormtaylor/slate/issues/5199).\n  //\n  // However, not inserting the \\uFEFF on iOS causes the editor to crash when\n  // inserting any text using an IME at the start of a block. This appears to\n  // be because accepting an IME suggestion when at the start of a block (no\n  // preceding \\uFEFF) removes one or more DOM elements that `toSlateRange`\n  // depends on. (https://github.com/ianstormtaylor/slate/issues/5703)\n  // A leaf with no text node at all forces the IME to create one when the\n  // first character is composed there, and no re-render can then touch the\n  // leaf without cancelling the composition. Rendering the zero-width space on\n  // Android too gives the composition a React-owned text node to live in; the\n  // wrapper keeps its data-slate-zero-width attributes, so selection mapping\n  // is unchanged.\n  return (\n    <span {...attributes}>\n      {'\\uFEFF'}\n      {isLineBreak ? <br /> : null}\n    </span>\n  )\n}\n\nexport default String\n","import { Element, Node, Text } from 'slate'\n\nconst hasSameProperties = (prev: Element, next: Element) => {\n  const prevKeys = Object.keys(prev).filter(key => key !== 'children')\n  const nextKeys = Object.keys(next).filter(key => key !== 'children')\n\n  return (\n    prevKeys.length === nextKeys.length &&\n    prevKeys.every(\n      key =>\n        key in next && prev[key as keyof Element] === next[key as keyof Element]\n    )\n  )\n}\n\nconst isLastChild = (parent: Element, text: Text) =>\n  parent.children[parent.children.length - 1] === text\n\nexport const isTextParentEquivalent = (\n  prevParent: Element,\n  nextParent: Element,\n  prevText: Text,\n  nextText: Text\n) => {\n  if (prevParent === nextParent) {\n    return true\n  }\n\n  return (\n    hasSameProperties(prevParent, nextParent) &&\n    isLastChild(prevParent, prevText) === isLastChild(nextParent, nextText) &&\n    (nextText.text !== '' ||\n      (Node.string(prevParent) === '') === (Node.string(nextParent) === ''))\n  )\n}\n","import React, {\n  useRef,\n  useCallback,\n  MutableRefObject,\n  useState,\n  useEffect,\n} from 'react'\nimport { JSX } from 'react'\nimport { Element, LeafPosition, Text } from 'slate'\nimport { ResizeObserver as ResizeObserverPolyfill } from '@juggle/resize-observer'\nimport String from './string'\nimport { isTextParentEquivalent } from '../utils/text-parent'\nimport { PLACEHOLDER_SYMBOL, EDITOR_TO_PLACEHOLDER_ELEMENT } from 'slate-dom'\nimport { RenderLeafProps, RenderPlaceholderProps } from './editable'\nimport { useSlateStatic } from '../hooks/use-slate-static'\nimport { IS_WEBKIT, IS_ANDROID } from 'slate-dom'\n\n// Delay the placeholder on Android to prevent the keyboard from closing.\n// (https://github.com/ianstormtaylor/slate/pull/5368)\nconst PLACEHOLDER_DELAY = IS_ANDROID ? 300 : 0\n\nfunction disconnectPlaceholderResizeObserver(\n  placeholderResizeObserver: MutableRefObject<ResizeObserver | null>,\n  releaseObserver: boolean\n) {\n  if (placeholderResizeObserver.current) {\n    placeholderResizeObserver.current.disconnect()\n    if (releaseObserver) {\n      placeholderResizeObserver.current = null\n    }\n  }\n}\n\ntype TimerId = ReturnType<typeof setTimeout> | null\n\nfunction clearTimeoutRef(timeoutRef: MutableRefObject<TimerId>) {\n  if (timeoutRef.current) {\n    clearTimeout(timeoutRef.current)\n    timeoutRef.current = null\n  }\n}\n\nconst defaultRenderLeaf = (props: RenderLeafProps) => <DefaultLeaf {...props} />\n\n/**\n * Individual leaves in a text node with unique formatting.\n */\nconst Leaf = (props: {\n  isLast: boolean\n  leaf: Text\n  parent: Element\n  renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element\n  renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n  text: Text\n  leafPosition?: LeafPosition\n}) => {\n  const {\n    leaf,\n    isLast,\n    text,\n    parent,\n    renderPlaceholder,\n    renderLeaf = defaultRenderLeaf,\n    leafPosition,\n  } = props\n\n  const editor = useSlateStatic()\n  const placeholderResizeObserver = useRef<ResizeObserver | null>(null)\n  const placeholderRef = useRef<HTMLElement | null>(null)\n  const [showPlaceholder, setShowPlaceholder] = useState(false)\n  const showPlaceholderTimeoutRef = useRef<TimerId>(null)\n\n  const callbackPlaceholderRef = useCallback(\n    (placeholderEl: HTMLElement | null) => {\n      disconnectPlaceholderResizeObserver(\n        placeholderResizeObserver,\n        placeholderEl == null\n      )\n\n      if (placeholderEl == null) {\n        EDITOR_TO_PLACEHOLDER_ELEMENT.delete(editor)\n        leaf.onPlaceholderResize?.(null)\n      } else {\n        EDITOR_TO_PLACEHOLDER_ELEMENT.set(editor, placeholderEl)\n\n        if (!placeholderResizeObserver.current) {\n          // Create a new observer and observe the placeholder element.\n          const ResizeObserver = window.ResizeObserver || ResizeObserverPolyfill\n          placeholderResizeObserver.current = new ResizeObserver(() => {\n            leaf.onPlaceholderResize?.(placeholderEl)\n          })\n        }\n        placeholderResizeObserver.current.observe(placeholderEl)\n        placeholderRef.current = placeholderEl\n      }\n    },\n    [placeholderRef, leaf, editor]\n  )\n\n  let children = (\n    <String isLast={isLast} leaf={leaf} parent={parent} text={text} />\n  )\n\n  const leafIsPlaceholder = Boolean(leaf[PLACEHOLDER_SYMBOL])\n  useEffect(() => {\n    if (leafIsPlaceholder) {\n      if (!showPlaceholderTimeoutRef.current) {\n        // Delay the placeholder, so it will not render in a selection\n        showPlaceholderTimeoutRef.current = setTimeout(() => {\n          setShowPlaceholder(true)\n          showPlaceholderTimeoutRef.current = null\n        }, PLACEHOLDER_DELAY)\n      }\n    } else {\n      clearTimeoutRef(showPlaceholderTimeoutRef)\n      setShowPlaceholder(false)\n    }\n    return () => clearTimeoutRef(showPlaceholderTimeoutRef)\n  }, [leafIsPlaceholder, setShowPlaceholder])\n\n  if (leafIsPlaceholder && showPlaceholder) {\n    const placeholderProps: RenderPlaceholderProps = {\n      children: leaf.placeholder,\n      attributes: {\n        'data-slate-placeholder': true,\n        'aria-hidden': true,\n        style: {\n          position: 'absolute',\n          top: 0,\n          pointerEvents: 'none',\n          width: '100%',\n          maxWidth: '100%',\n          display: 'block',\n          opacity: '0.333',\n          userSelect: 'none',\n          WebkitUserSelect: 'none',\n          textDecoration: 'none',\n          // Fixes https://github.com/udecode/plate/issues/2315\n          WebkitUserModify: IS_WEBKIT ? 'inherit' : undefined,\n        },\n        contentEditable: false,\n        ref: callbackPlaceholderRef,\n      },\n    }\n\n    children = (\n      <React.Fragment>\n        {children}\n        {renderPlaceholder(placeholderProps)}\n      </React.Fragment>\n    )\n  }\n\n  // COMPAT: Having the `data-` attributes on these leaf elements ensures that\n  // in certain misbehaving browsers they aren't weirdly cloned/destroyed by\n  // contenteditable behaviors. (2019/05/08)\n  const attributes: {\n    'data-slate-leaf': true\n  } = {\n    'data-slate-leaf': true,\n  }\n\n  return renderLeaf({\n    attributes,\n    children,\n    leaf,\n    text,\n    leafPosition,\n  })\n}\n\nconst MemoizedLeaf = React.memo(Leaf, (prev, next) => {\n  return (\n    isTextParentEquivalent(prev.parent, next.parent, prev.text, next.text) &&\n    next.isLast === prev.isLast &&\n    next.renderLeaf === prev.renderLeaf &&\n    next.renderPlaceholder === prev.renderPlaceholder &&\n    next.text === prev.text &&\n    Text.equals(next.leaf, prev.leaf) &&\n    next.leaf[PLACEHOLDER_SYMBOL] === prev.leaf[PLACEHOLDER_SYMBOL]\n  )\n})\n\nexport const DefaultLeaf = (props: RenderLeafProps) => {\n  const { attributes, children } = props\n  return <span {...attributes}>{children}</span>\n}\n\nexport default MemoizedLeaf\n","var arrayLikeToArray = require(\"./arrayLikeToArray.js\");\nfunction _arrayWithoutHoles(r) {\n  if (Array.isArray(r)) return arrayLikeToArray(r);\n}\nmodule.exports = _arrayWithoutHoles, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _iterableToArray(r) {\n  if (\"undefined\" != typeof Symbol && null != r[Symbol.iterator] || null != r[\"@@iterator\"]) return Array.from(r);\n}\nmodule.exports = _iterableToArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _nonIterableSpread() {\n  throw new TypeError(\"Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nmodule.exports = _nonIterableSpread, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var arrayWithoutHoles = require(\"./arrayWithoutHoles.js\");\nvar iterableToArray = require(\"./iterableToArray.js\");\nvar unsupportedIterableToArray = require(\"./unsupportedIterableToArray.js\");\nvar nonIterableSpread = require(\"./nonIterableSpread.js\");\nfunction _toConsumableArray(r) {\n  return arrayWithoutHoles(r) || iterableToArray(r) || unsupportedIterableToArray(r) || nonIterableSpread();\n}\nmodule.exports = _toConsumableArray, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import { useCallback, useReducer, useRef } from 'react'\n\n/**\n * Create a selector that updates when an `update` function is called, and\n * which only causes the component to render when the result of `selector`\n * differs from the previous result according to `equalityFn`.\n *\n * If `selector` is memoized using `useCallback`, then it will only be called\n * when it changes or when `update` is called. Otherwise, `selector` will be\n * called every time the component renders.\n *\n * @example\n * const [state, update] = useGenericSelector(selector, equalityFn)\n *\n * useIsomorphicLayoutEffect(() => {\n *   return addEventListener(update)\n * }, [addEventListener, update])\n *\n * return state\n */\n\nexport function useGenericSelector<T>(\n  selector: () => T,\n  equalityFn: (a: T | null, b: T) => boolean\n): [state: T, update: () => void] {\n  const [, forceRender] = useReducer(s => s + 1, 0)\n\n  const latestSubscriptionCallbackError = useRef<Error | undefined>(undefined)\n  const latestSelector = useRef<() => T>(() => null as any)\n  const latestSelectedState = useRef<T | null>(null)\n  let selectedState: T\n\n  try {\n    if (\n      selector !== latestSelector.current ||\n      latestSubscriptionCallbackError.current\n    ) {\n      const selectorResult = selector()\n\n      if (equalityFn(latestSelectedState.current, selectorResult)) {\n        selectedState = latestSelectedState.current as T\n      } else {\n        selectedState = selectorResult\n      }\n    } else {\n      selectedState = latestSelectedState.current as T\n    }\n  } catch (err) {\n    if (latestSubscriptionCallbackError.current && isError(err)) {\n      err.message += `\\nThe error may be correlated with this previous error:\\n${latestSubscriptionCallbackError.current.stack}\\n\\n`\n    }\n\n    throw err\n  }\n\n  latestSelector.current = selector\n  latestSelectedState.current = selectedState\n  latestSubscriptionCallbackError.current = undefined\n\n  const update = useCallback(() => {\n    try {\n      const newSelectedState = latestSelector.current()\n\n      if (equalityFn(latestSelectedState.current, newSelectedState)) {\n        return\n      }\n\n      latestSelectedState.current = newSelectedState\n    } catch (err) {\n      // we ignore all errors here, since when the component\n      // is re-rendered, the selectors are called again, and\n      // will throw again, if neither props nor store state\n      // changed\n      if (err instanceof Error) {\n        latestSubscriptionCallbackError.current = err\n      } else {\n        latestSubscriptionCallbackError.current = new Error(String(err))\n      }\n    }\n\n    forceRender()\n\n    // don't rerender on equalityFn change since we want to be able to define it inline\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [])\n\n  return [selectedState, update]\n}\n\nfunction isError(error: any): error is Error {\n  return error instanceof Error\n}\n","import {\n  createContext,\n  useCallback,\n  useContext,\n  useMemo,\n  useReducer,\n  useRef,\n} from 'react'\nimport {\n  DecoratedRange,\n  Descendant,\n  Editor,\n  Node,\n  NodeEntry,\n  Range,\n} from 'slate'\nimport { isTextDecorationsEqual, isElementDecorationsEqual } from 'slate-dom'\nimport { useSlateStatic } from './use-slate-static'\nimport { ReactEditor } from '../plugin/react-editor'\nimport { useGenericSelector } from './use-generic-selector'\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect'\n\ntype Callback = () => void\n\n/**\n * A React context for sharing the `decorate` prop of the editable and\n * subscribing to changes on this prop.\n */\n\nexport const DecorateContext = createContext<{\n  decorate: (entry: NodeEntry) => DecoratedRange[]\n  addEventListener: (callback: Callback) => () => void\n}>({} as any)\n\nexport const useDecorations = (\n  node: Descendant,\n  parentDecorations: DecoratedRange[]\n): DecoratedRange[] => {\n  const editor = useSlateStatic()\n  const { decorate, addEventListener } = useContext(DecorateContext)\n\n  // Not memoized since we want nodes to be decorated on each render\n  const selector = () => {\n    const path = ReactEditor.findPath(editor, node)\n    const decorations = decorate([node, path])\n\n    if (Node.isText(node)) {\n      const range = Editor.range(editor, path)\n      return decorations.flatMap(decoration => {\n        const intersection = Range.intersection(decoration, range)\n        return intersection ? [intersection] : []\n      })\n    }\n\n    return decorations\n  }\n\n  const equalityFn = Node.isText(node)\n    ? isTextDecorationsEqual\n    : isElementDecorationsEqual\n\n  const [decorations, update] = useGenericSelector(selector, equalityFn)\n\n  useIsomorphicLayoutEffect(() => {\n    const unsubscribe = addEventListener(update)\n    update()\n    return unsubscribe\n  }, [addEventListener, update])\n\n  return useMemo(\n    () => [...decorations, ...parentDecorations],\n    [decorations, parentDecorations]\n  )\n}\n\nexport const useDecorateContext = (\n  decorateProp: (entry: NodeEntry) => DecoratedRange[]\n) => {\n  const [, forceUpdate] = useReducer(s => s + 1, 0)\n  const eventListeners = useRef(new Set<Callback>())\n  const hasMounted = useRef(false)\n\n  const latestDecorate = useRef(decorateProp)\n\n  useIsomorphicLayoutEffect(() => {\n    latestDecorate.current = decorateProp\n    eventListeners.current.forEach(listener => listener())\n\n    // Skip the forced re-render on the initial mount: there is no committed\n    // DOM to restore the selection against yet, and forcing an extra render\n    // here breaks contenteditable input in Firefox. Only later decoration\n    // changes need to re-render Editable in the same batch as the text\n    // components notified above, so its selection-restoration layout effect\n    // runs after the decoration-induced DOM changes are committed. Without\n    // that, the text components restructure the DOM in a separate pass where\n    // Editable's layout effect never fires, potentially leaving the caret at\n    // a wrong position.\n    if (!hasMounted.current) {\n      hasMounted.current = true\n      return\n    }\n\n    forceUpdate()\n  }, [decorateProp])\n\n  const decorate = useCallback(\n    (entry: NodeEntry) => latestDecorate.current(entry),\n    []\n  )\n\n  const addEventListener = useCallback((callback: Callback) => {\n    eventListeners.current.add(callback)\n\n    return () => {\n      eventListeners.current.delete(callback)\n    }\n  }, [])\n\n  return useMemo(\n    () => ({ decorate, addEventListener }),\n    [decorate, addEventListener]\n  )\n}\n","import React, { useCallback, useRef } from 'react'\nimport { Element, Text as SlateText, DecoratedRange } from 'slate'\nimport { ReactEditor, useSlateStatic } from '..'\nimport { isTextDecorationsEqual } from 'slate-dom'\nimport {\n  EDITOR_TO_KEY_TO_ELEMENT,\n  ELEMENT_TO_NODE,\n  NODE_TO_ELEMENT,\n} from 'slate-dom'\nimport {\n  RenderLeafProps,\n  RenderPlaceholderProps,\n  RenderTextProps,\n} from './editable'\nimport Leaf from './leaf'\nimport { isTextParentEquivalent } from '../utils/text-parent'\nimport { useDecorations } from '../hooks/use-decorations'\n\nconst defaultRenderText = (props: RenderTextProps) => <DefaultText {...props} />\n\n/**\n * Text.\n */\n\nconst Text = (props: {\n  decorations: DecoratedRange[]\n  isLast: boolean\n  parent: Element\n  renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element\n  renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n  renderText?: (props: RenderTextProps) => React.JSX.Element\n  text: SlateText\n}) => {\n  const {\n    decorations: parentDecorations,\n    isLast,\n    parent,\n    renderPlaceholder,\n    renderLeaf,\n    renderText = defaultRenderText,\n    text,\n  } = props\n\n  const editor = useSlateStatic()\n  const ref = useRef<HTMLSpanElement | null>(null)\n  const decorations = useDecorations(text, parentDecorations)\n  const decoratedLeaves = SlateText.decorations(text, decorations)\n  const key = ReactEditor.findKey(editor, text)\n  const children = []\n\n  for (let i = 0; i < decoratedLeaves.length; i++) {\n    const { leaf, position } = decoratedLeaves[i]\n\n    children.push(\n      <Leaf\n        isLast={isLast && i === decoratedLeaves.length - 1}\n        key={`${key.id}-${i}`}\n        renderPlaceholder={renderPlaceholder}\n        leaf={leaf}\n        leafPosition={position}\n        text={text}\n        parent={parent}\n        renderLeaf={renderLeaf}\n      />\n    )\n  }\n\n  // Update element-related weak maps with the DOM element ref.\n  const callbackRef = useCallback(\n    (span: HTMLSpanElement | null) => {\n      const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor)\n      if (span) {\n        KEY_TO_ELEMENT?.set(key, span)\n        NODE_TO_ELEMENT.set(text, span)\n        ELEMENT_TO_NODE.set(span, text)\n      } else {\n        KEY_TO_ELEMENT?.delete(key)\n        NODE_TO_ELEMENT.delete(text)\n        if (ref.current) {\n          ELEMENT_TO_NODE.delete(ref.current)\n        }\n      }\n      ref.current = span\n    },\n    [ref, editor, key, text]\n  )\n\n  const attributes: {\n    'data-slate-node': 'text'\n    ref: any\n  } = {\n    'data-slate-node': 'text',\n    ref: callbackRef,\n  }\n\n  return renderText({\n    text,\n    children,\n    attributes,\n  })\n}\n\nconst MemoizedText = React.memo(Text, (prev, next) => {\n  return (\n    isTextParentEquivalent(prev.parent, next.parent, prev.text, next.text) &&\n    next.isLast === prev.isLast &&\n    next.renderText === prev.renderText &&\n    next.renderLeaf === prev.renderLeaf &&\n    next.renderPlaceholder === prev.renderPlaceholder &&\n    next.text === prev.text &&\n    isTextDecorationsEqual(next.decorations, prev.decorations)\n  )\n})\n\nexport const DefaultText = (props: RenderTextProps) => {\n  const { attributes, children } = props\n  return <span {...attributes}>{children}</span>\n}\n\nexport default MemoizedText\n","import getDirection from 'direction'\nimport React, { useCallback } from 'react'\nimport { JSX } from 'react'\nimport { Editor, Element as SlateElement, Node, DecoratedRange } from 'slate'\nimport { ReactEditor, useReadOnly, useSlateStatic } from '..'\nimport useChildren from '../hooks/use-children'\nimport { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\nimport { isElementDecorationsEqual } from 'slate-dom'\nimport {\n  EDITOR_TO_KEY_TO_ELEMENT,\n  ELEMENT_TO_NODE,\n  NODE_TO_ELEMENT,\n  NODE_TO_INDEX,\n  NODE_TO_PARENT,\n} from 'slate-dom'\nimport {\n  RenderChunkProps,\n  RenderElementProps,\n  RenderLeafProps,\n  RenderPlaceholderProps,\n  RenderTextProps,\n} from './editable'\n\nimport Text from './text'\nimport { useDecorations } from '../hooks/use-decorations'\n\nconst findSiblingDirection = (siblings: Iterable<Node>) => {\n  for (const sibling of siblings) {\n    const dir = getDirection(Node.string(sibling))\n\n    if (dir !== 'neutral') {\n      return dir\n    }\n  }\n}\n\nconst getEmptyBlockDirection = (element: SlateElement) => {\n  const parent = NODE_TO_PARENT.get(element)\n  const index = NODE_TO_INDEX.get(element)\n\n  if (!parent || index === undefined) {\n    return\n  }\n\n  const before = parent.children.slice(0, index).reverse()\n  const after = parent.children.slice(index + 1)\n  return findSiblingDirection(before) ?? findSiblingDirection(after)\n}\n\nconst getMountedChildren = (editor: Editor, element: SlateElement): Node[] =>\n  Editor.isVoid(editor, element)\n    ? [Node.texts(element).next().value![0]]\n    : element.children\n\nconst findUnmountedChild = (editor: Editor, element: SlateElement) =>\n  getMountedChildren(editor, element).findIndex(\n    child => !NODE_TO_ELEMENT.has(child)\n  )\n\nconst defaultRenderElement = (props: RenderElementProps) => (\n  <DefaultElement {...props} />\n)\n\n/**\n * Element.\n */\n\nconst Element = (props: {\n  decorations: DecoratedRange[]\n  element: SlateElement\n  renderElement?: (props: RenderElementProps) => React.JSX.Element\n  renderChunk?: (props: RenderChunkProps) => React.JSX.Element\n  renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element\n  renderText?: (props: RenderTextProps) => React.JSX.Element\n  renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n}) => {\n  const {\n    decorations: parentDecorations,\n    element,\n    renderElement = defaultRenderElement,\n    renderChunk,\n    renderPlaceholder,\n    renderLeaf,\n    renderText,\n  } = props\n  const editor = useSlateStatic()\n  const readOnly = useReadOnly()\n  const isInline = editor.isInline(element)\n  const decorations = useDecorations(element, parentDecorations)\n  const key = ReactEditor.findKey(editor, element)\n  const ref = useCallback(\n    (ref: HTMLElement | null) => {\n      // Update element-related weak maps with the DOM element ref.\n      const KEY_TO_ELEMENT = EDITOR_TO_KEY_TO_ELEMENT.get(editor)\n      if (ref) {\n        KEY_TO_ELEMENT?.set(key, ref)\n        NODE_TO_ELEMENT.set(element, ref)\n        ELEMENT_TO_NODE.set(ref, element)\n      } else {\n        KEY_TO_ELEMENT?.delete(key)\n        NODE_TO_ELEMENT.delete(element)\n      }\n    },\n    [editor, key, element]\n  )\n  useIsomorphicLayoutEffect(() => {\n    const index = findUnmountedChild(editor, element)\n\n    if (index !== -1) {\n      const type = (element as { type?: unknown }).type\n      const path = ReactEditor.findPath(editor, element)\n      editor.onDOMError(\n        new Error(\n          `renderElement didn't render the children of the ${\n            typeof type === 'string' ? `\"${type}\" ` : ''\n          }element at path ${JSON.stringify(\n            path\n          )}: child ${index} has no DOM node. Render the \\`children\\` prop inside the element.`\n        )\n      )\n    }\n  }, [editor, element])\n\n  let children: React.ReactNode = useChildren({\n    decorations,\n    node: element,\n    renderElement,\n    renderChunk,\n    renderPlaceholder,\n    renderLeaf,\n    renderText,\n  })\n\n  // Attributes that the developer must mix into the element in their\n  // custom node renderer component.\n  const attributes: {\n    'data-slate-node': 'element'\n    'data-slate-void'?: true\n    'data-slate-inline'?: true\n    contentEditable?: false\n    dir?: 'rtl'\n    ref: any\n  } = {\n    'data-slate-node': 'element',\n    ref,\n  }\n\n  if (isInline) {\n    attributes['data-slate-inline'] = true\n  }\n\n  // If it's a block node with inline children, add the proper `dir` attribute\n  // for text direction.\n  if (!isInline && Editor.hasInlines(editor, element)) {\n    const text = Node.string(element)\n    const dir =\n      text === '' ? getEmptyBlockDirection(element) : getDirection(text)\n\n    if (dir === 'rtl') {\n      attributes.dir = dir\n    }\n  }\n\n  // If it's a void node, wrap the children in extra void-specific elements.\n  if (Editor.isVoid(editor, element)) {\n    attributes['data-slate-void'] = true\n\n    if (!readOnly && isInline) {\n      attributes.contentEditable = false\n    }\n\n    const Tag = isInline ? 'span' : 'div'\n    const [[text]] = Node.texts(element)\n\n    children = (\n      <Tag\n        data-slate-spacer\n        style={{\n          height: '0',\n          color: 'transparent',\n          outline: 'none',\n          position: 'absolute',\n          userSelect: 'none',\n          WebkitUserSelect: 'none',\n        }}\n      >\n        <Text\n          renderPlaceholder={renderPlaceholder}\n          decorations={[]}\n          isLast={false}\n          parent={element}\n          text={text}\n        />\n      </Tag>\n    )\n\n    NODE_TO_INDEX.set(text, 0)\n    NODE_TO_PARENT.set(text, element)\n  }\n\n  return renderElement({ attributes, children, element })\n}\n\nconst MemoizedElement = React.memo(Element, (prev, next) => {\n  return (\n    prev.element === next.element &&\n    prev.renderElement === next.renderElement &&\n    prev.renderChunk === next.renderChunk &&\n    prev.renderText === next.renderText &&\n    prev.renderLeaf === next.renderLeaf &&\n    prev.renderPlaceholder === next.renderPlaceholder &&\n    isElementDecorationsEqual(prev.decorations, next.decorations)\n  )\n})\n\n/**\n * The default element renderer.\n */\n\nexport const DefaultElement = (props: RenderElementProps) => {\n  const { attributes, children, element } = props\n  const editor = useSlateStatic()\n  const Tag = editor.isInline(element) ? 'span' : 'div'\n  return (\n    <Tag {...attributes} style={{ position: 'relative' }}>\n      {children}\n    </Tag>\n  )\n}\n\nexport default MemoizedElement\n","function _classCallCheck(a, n) {\n  if (!(a instanceof n)) throw new TypeError(\"Cannot call a class as a function\");\n}\nmodule.exports = _classCallCheck, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var toPropertyKey = require(\"./toPropertyKey.js\");\nfunction _defineProperties(e, r) {\n  for (var t = 0; t < r.length; t++) {\n    var o = r[t];\n    o.enumerable = o.enumerable || !1, o.configurable = !0, \"value\" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);\n  }\n}\nfunction _createClass(e, r, t) {\n  return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, \"prototype\", {\n    writable: !1\n  }), e;\n}\nmodule.exports = _createClass, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import { Path } from 'slate'\nimport { Key } from 'slate-dom'\nimport {\n  Chunk,\n  ChunkTree,\n  ChunkLeaf,\n  ChunkDescendant,\n  ChunkAncestor,\n} from './types'\n\ntype SavedPointer =\n  | 'start'\n  | {\n      chunk: ChunkAncestor\n      node: ChunkDescendant\n    }\n\nexport interface ChunkTreeHelperOptions {\n  chunkSize: number\n  debug?: boolean\n}\n\n/**\n * Traverse and modify a chunk tree\n */\nexport class ChunkTreeHelper {\n  /**\n   * The root of the chunk tree\n   */\n  private root: ChunkTree\n\n  /**\n   * The ideal size of a chunk\n   */\n  private chunkSize: number\n\n  /**\n   * Whether debug mode is enabled\n   *\n   * If enabled, the pointer state will be checked for internal consistency\n   * after each mutating operation.\n   */\n  private debug: boolean\n\n  /**\n   * Whether the traversal has reached the end of the chunk tree\n   *\n   * When this is true, the pointerChunk and pointerIndex point to the last\n   * top-level node in the chunk tree, although pointerNode returns null.\n   */\n  private reachedEnd: boolean\n\n  /**\n   * The chunk containing the current node\n   */\n  private pointerChunk: ChunkAncestor\n\n  /**\n   * The index of the current node within pointerChunk\n   *\n   * Can be -1 to indicate that the pointer is before the start of the tree.\n   */\n  private pointerIndex: number\n\n  /**\n   * Similar to a Slate path; tracks the path of pointerChunk relative to the\n   * root.\n   *\n   * Used to move the pointer from the current chunk to the parent chunk more\n   * efficiently.\n   */\n  private pointerIndexStack: number[]\n\n  /**\n   * Indexing the current chunk's children has a slight time cost, which adds up\n   * when traversing very large trees, so the current node is cached.\n   *\n   * A value of undefined means that the current node is not cached. This\n   * property must be set to undefined whenever the pointer is moved, unless\n   * the pointer is guaranteed to point to the same node that it did previously.\n   */\n  private cachedPointerNode: ChunkDescendant | null | undefined\n\n  constructor(\n    chunkTree: ChunkTree,\n    { chunkSize, debug }: ChunkTreeHelperOptions\n  ) {\n    this.root = chunkTree\n    this.chunkSize = chunkSize\n    // istanbul ignore next\n    this.debug = debug ?? false\n    this.pointerChunk = chunkTree\n    this.pointerIndex = -1\n    this.pointerIndexStack = []\n    this.reachedEnd = false\n    this.validateState()\n  }\n\n  /**\n   * Move the pointer to the next leaf in the chunk tree\n   */\n  public readLeaf(): ChunkLeaf | null {\n    // istanbul ignore next\n    if (this.reachedEnd) return null\n\n    // Get the next sibling or aunt node\n    while (true) {\n      if (this.pointerIndex + 1 < this.pointerSiblings.length) {\n        this.pointerIndex++\n        this.cachedPointerNode = undefined\n        break\n      } else if (this.pointerChunk.type === 'root') {\n        this.reachedEnd = true\n        return null\n      } else {\n        this.exitChunk()\n      }\n    }\n\n    this.validateState()\n\n    // If the next sibling or aunt is a chunk, descend into it\n    this.enterChunkUntilLeaf(false)\n\n    return this.pointerNode as ChunkLeaf\n  }\n\n  /**\n   * Move the pointer to the previous leaf in the chunk tree\n   */\n  public returnToPreviousLeaf() {\n    // If we were at the end of the tree, descend into the end of the last\n    // chunk in the tree\n    if (this.reachedEnd) {\n      this.reachedEnd = false\n      this.enterChunkUntilLeaf(true)\n      return\n    }\n\n    // Get the previous sibling or aunt node\n    while (true) {\n      if (this.pointerIndex >= 1) {\n        this.pointerIndex--\n        this.cachedPointerNode = undefined\n        break\n      } else if (this.pointerChunk.type === 'root') {\n        this.pointerIndex = -1\n        return\n      } else {\n        this.exitChunk()\n      }\n    }\n\n    this.validateState()\n\n    // If the previous sibling or aunt is a chunk, descend into it\n    this.enterChunkUntilLeaf(true)\n  }\n\n  /**\n   * Insert leaves before the current leaf, leaving the pointer unchanged\n   */\n  public insertBefore(leaves: ChunkLeaf[]) {\n    this.returnToPreviousLeaf()\n    this.insertAfter(leaves)\n    this.readLeaf()\n  }\n\n  /**\n   * Insert leaves after the current leaf, leaving the pointer on the last\n   * inserted leaf\n   *\n   * The insertion algorithm first checks for any chunk we're currently at the\n   * end of that can receive additional leaves. Next, it tries to insert leaves\n   * at the starts of any subsequent chunks.\n   *\n   * Any remaining leaves are passed to rawInsertAfter to be chunked and\n   * inserted at the highest possible level.\n   */\n  public insertAfter(leaves: ChunkLeaf[]) {\n    // istanbul ignore next\n    if (leaves.length === 0) return\n\n    let beforeDepth = 0\n    let afterDepth = 0\n\n    // While at the end of a chunk, insert any leaves that will fit, and then\n    // exit the chunk\n    while (\n      this.pointerChunk.type === 'chunk' &&\n      this.pointerIndex === this.pointerSiblings.length - 1\n    ) {\n      const remainingCapacity = this.chunkSize - this.pointerSiblings.length\n      const toInsertCount = Math.min(remainingCapacity, leaves.length)\n\n      if (toInsertCount > 0) {\n        const leavesToInsert = leaves.splice(0, toInsertCount)\n        this.rawInsertAfter(leavesToInsert, beforeDepth)\n      }\n\n      this.exitChunk()\n      beforeDepth++\n    }\n\n    if (leaves.length === 0) return\n\n    // Save the pointer so that we can come back here after inserting leaves\n    // into the starts of subsequent blocks\n    const rawInsertPointer = this.savePointer()\n\n    // If leaves are inserted into the start of a subsequent block, then we\n    // eventually need to restore the pointer to the last such inserted leaf\n    let finalPointer: SavedPointer | null = null\n\n    // Move the pointer into the chunk containing the next leaf, if it exists\n    if (this.readLeaf()) {\n      // While at the start of a chunk, insert any leaves that will fit, and\n      // then exit the chunk\n      while (this.pointerChunk.type === 'chunk' && this.pointerIndex === 0) {\n        const remainingCapacity = this.chunkSize - this.pointerSiblings.length\n        const toInsertCount = Math.min(remainingCapacity, leaves.length)\n\n        if (toInsertCount > 0) {\n          const leavesToInsert = leaves.splice(-toInsertCount, toInsertCount)\n\n          // Insert the leaves at the start of the chunk\n          this.pointerIndex = -1\n          this.cachedPointerNode = undefined\n          this.rawInsertAfter(leavesToInsert, afterDepth)\n\n          // If this is the first batch of insertions at the start of a\n          // subsequent chunk, set the final pointer to the last inserted leaf\n          if (!finalPointer) {\n            finalPointer = this.savePointer()\n          }\n        }\n\n        this.exitChunk()\n        afterDepth++\n      }\n    }\n\n    this.restorePointer(rawInsertPointer)\n\n    // If there are leaves left to insert, insert them between the end of the\n    // previous chunk and the start of the first subsequent chunk, or wherever\n    // the pointer ended up after the first batch of insertions\n    const minDepth = Math.max(beforeDepth, afterDepth)\n    this.rawInsertAfter(leaves, minDepth)\n\n    if (finalPointer) {\n      this.restorePointer(finalPointer)\n    }\n\n    this.validateState()\n  }\n\n  /**\n   * Remove the current node and decrement the pointer, deleting any ancestor\n   * chunk that becomes empty as a result\n   */\n  public remove() {\n    this.pointerSiblings.splice(this.pointerIndex--, 1)\n    this.cachedPointerNode = undefined\n\n    if (\n      this.pointerSiblings.length === 0 &&\n      this.pointerChunk.type === 'chunk'\n    ) {\n      this.exitChunk()\n      this.remove()\n    } else {\n      this.invalidateChunk()\n    }\n\n    this.validateState()\n  }\n\n  /**\n   * Add the current chunk and all ancestor chunks to the list of modified\n   * chunks\n   */\n  public invalidateChunk() {\n    for (let c = this.pointerChunk; c.type === 'chunk'; c = c.parent) {\n      this.root.modifiedChunks.add(c)\n    }\n  }\n\n  /**\n   * Whether the pointer is at the start of the tree\n   */\n  private get atStart() {\n    return this.pointerChunk.type === 'root' && this.pointerIndex === -1\n  }\n\n  /**\n   * The siblings of the current node\n   */\n  private get pointerSiblings(): ChunkDescendant[] {\n    return this.pointerChunk.children\n  }\n\n  /**\n   * Get the current node (uncached)\n   *\n   * If the pointer is at the start or end of the document, returns null.\n   *\n   * Usually, the current node is a chunk leaf, although it can be a chunk\n   * while insertions are in progress.\n   */\n  private getPointerNode(): ChunkDescendant | null {\n    if (this.reachedEnd || this.pointerIndex === -1) {\n      return null\n    }\n\n    return this.pointerSiblings[this.pointerIndex]\n  }\n\n  /**\n   * Cached getter for the current node\n   */\n  private get pointerNode(): ChunkDescendant | null {\n    if (this.cachedPointerNode !== undefined) return this.cachedPointerNode\n    const pointerNode = this.getPointerNode()\n    this.cachedPointerNode = pointerNode\n    return pointerNode\n  }\n\n  /**\n   * Get the path of a chunk relative to the root, returning null if the chunk\n   * is not connected to the root\n   */\n  private getChunkPath(chunk: ChunkAncestor): number[] | null {\n    const path: number[] = []\n\n    for (let c = chunk; c.type === 'chunk'; c = c.parent) {\n      const index = c.parent.children.indexOf(c)\n\n      // istanbul ignore next\n      if (index === -1) {\n        return null\n      }\n\n      path.unshift(index)\n    }\n\n    return path\n  }\n\n  /**\n   * Save the current pointer to be restored later\n   */\n  private savePointer(): SavedPointer {\n    if (this.atStart) return 'start'\n\n    // istanbul ignore next\n    if (!this.pointerNode) {\n      throw new Error('Cannot save pointer when pointerNode is null')\n    }\n\n    return {\n      chunk: this.pointerChunk,\n      node: this.pointerNode,\n    }\n  }\n\n  /**\n   * Restore the pointer to a previous state\n   */\n  private restorePointer(savedPointer: SavedPointer) {\n    if (savedPointer === 'start') {\n      this.pointerChunk = this.root\n      this.pointerIndex = -1\n      this.pointerIndexStack = []\n      this.reachedEnd = false\n      this.cachedPointerNode = undefined\n      return\n    }\n\n    // Since nodes may have been inserted or removed prior to the saved\n    // pointer since it was saved, the index and index stack must be\n    // recomputed. This is slow, but this is fine since restoring a pointer is\n    // not a frequent operation.\n\n    const { chunk, node } = savedPointer\n    const index = chunk.children.indexOf(node)\n\n    // istanbul ignore next\n    if (index === -1) {\n      throw new Error(\n        'Cannot restore point because saved node is no longer in saved chunk'\n      )\n    }\n\n    const indexStack = this.getChunkPath(chunk)\n\n    // istanbul ignore next\n    if (!indexStack) {\n      throw new Error(\n        'Cannot restore point because saved chunk is no longer connected to root'\n      )\n    }\n\n    this.pointerChunk = chunk\n    this.pointerIndex = index\n    this.pointerIndexStack = indexStack\n    this.reachedEnd = false\n    this.cachedPointerNode = node\n    this.validateState()\n  }\n\n  /**\n   * Assuming the current node is a chunk, move the pointer into that chunk\n   *\n   * @param end If true, place the pointer on the last node of the chunk.\n   * Otherwise, place the pointer on the first node.\n   */\n  private enterChunk(end: boolean) {\n    // istanbul ignore next\n    if (this.pointerNode?.type !== 'chunk') {\n      throw new Error('Cannot enter non-chunk')\n    }\n\n    this.pointerIndexStack.push(this.pointerIndex)\n    this.pointerChunk = this.pointerNode\n    this.pointerIndex = end ? this.pointerSiblings.length - 1 : 0\n    this.cachedPointerNode = undefined\n    this.validateState()\n\n    // istanbul ignore next\n    if (this.pointerChunk.children.length === 0) {\n      throw new Error('Cannot enter empty chunk')\n    }\n  }\n\n  /**\n   * Assuming the current node is a chunk, move the pointer into that chunk\n   * repeatedly until the current node is a leaf\n   *\n   * @param end If true, place the pointer on the last node of the chunk.\n   * Otherwise, place the pointer on the first node.\n   */\n  private enterChunkUntilLeaf(end: boolean) {\n    while (this.pointerNode?.type === 'chunk') {\n      this.enterChunk(end)\n    }\n  }\n\n  /**\n   * Move the pointer to the parent chunk\n   */\n  private exitChunk() {\n    // istanbul ignore next\n    if (this.pointerChunk.type === 'root') {\n      throw new Error('Cannot exit root')\n    }\n\n    const previousPointerChunk = this.pointerChunk\n    this.pointerChunk = previousPointerChunk.parent\n    this.pointerIndex = this.pointerIndexStack.pop()!\n    this.cachedPointerNode = undefined\n    this.validateState()\n  }\n\n  /**\n   * Insert leaves immediately after the current node, leaving the pointer on\n   * the last inserted leaf\n   *\n   * Leaves are chunked according to the number of nodes already in the parent\n   * plus the number of nodes being inserted, or the minimum depth if larger\n   */\n  private rawInsertAfter(leaves: ChunkLeaf[], minDepth: number) {\n    if (leaves.length === 0) return\n\n    const groupIntoChunks = (\n      leaves: ChunkLeaf[],\n      parent: ChunkAncestor,\n      perChunk: number\n    ): ChunkDescendant[] => {\n      if (perChunk === 1) return leaves\n      const chunks: Chunk[] = []\n\n      for (let i = 0; i < this.chunkSize; i++) {\n        const chunkNodes = leaves.slice(i * perChunk, (i + 1) * perChunk)\n        if (chunkNodes.length === 0) break\n\n        const chunk: Chunk = {\n          type: 'chunk',\n          key: new Key(),\n          parent,\n          children: [],\n        }\n\n        chunk.children = groupIntoChunks(\n          chunkNodes,\n          chunk,\n          perChunk / this.chunkSize\n        )\n        chunks.push(chunk)\n      }\n\n      return chunks\n    }\n\n    // Determine the chunking depth based on the number of existing nodes in\n    // the chunk and the number of nodes being inserted\n    const newTotal = this.pointerSiblings.length + leaves.length\n    let depthForTotal = 0\n\n    for (let i = this.chunkSize; i < newTotal; i *= this.chunkSize) {\n      depthForTotal++\n    }\n\n    // A depth of 0 means no chunking\n    const depth = Math.max(depthForTotal, minDepth)\n    const perTopLevelChunk = Math.pow(this.chunkSize, depth)\n\n    const chunks = groupIntoChunks(leaves, this.pointerChunk, perTopLevelChunk)\n    this.pointerSiblings.splice(this.pointerIndex + 1, 0, ...chunks)\n    this.pointerIndex += chunks.length\n    this.cachedPointerNode = undefined\n    this.invalidateChunk()\n    this.validateState()\n  }\n\n  /**\n   * If debug mode is enabled, ensure that the state is internally consistent\n   */\n  // istanbul ignore next\n  private validateState() {\n    if (!this.debug) return\n\n    const validateDescendant = (node: ChunkDescendant) => {\n      if (node.type === 'chunk') {\n        const { parent, children } = node\n\n        if (!parent.children.includes(node)) {\n          throw new Error(\n            `Debug: Chunk ${node.key.id} has an incorrect parent property`\n          )\n        }\n\n        children.forEach(validateDescendant)\n      }\n    }\n\n    this.root.children.forEach(validateDescendant)\n\n    if (\n      this.cachedPointerNode !== undefined &&\n      this.cachedPointerNode !== this.getPointerNode()\n    ) {\n      throw new Error(\n        'Debug: The cached pointer is incorrect and has not been invalidated'\n      )\n    }\n\n    const actualIndexStack = this.getChunkPath(this.pointerChunk)\n\n    if (!actualIndexStack) {\n      throw new Error('Debug: The pointer chunk is not connected to the root')\n    }\n\n    if (!Path.equals(this.pointerIndexStack, actualIndexStack)) {\n      throw new Error(\n        `Debug: The cached index stack [${this.pointerIndexStack.join(\n          ', '\n        )}] does not match the path of the pointer chunk [${actualIndexStack.join(\n          ', '\n        )}]`\n      )\n    }\n  }\n}\n","import { Editor, Descendant } from 'slate'\nimport { Key } from 'slate-dom'\nimport { ChunkLeaf } from './types'\nimport { ReactEditor } from '../plugin/react-editor'\n\n/**\n * Traverse an array of children, providing helpers useful for reconciling the\n * children array with a chunk tree\n */\nexport class ChildrenHelper {\n  private editor: Editor\n  private children: Descendant[]\n\n  /**\n   * Sparse array of Slate node keys, each index corresponding to an index in\n   * the children array\n   *\n   * Fetching the key for a Slate node is expensive, so we cache them here.\n   */\n  private cachedKeys: Array<Key | undefined>\n\n  /**\n   * The index of the next node to be read in the children array\n   */\n  public pointerIndex: number\n\n  constructor(editor: Editor, children: Descendant[]) {\n    this.editor = editor\n    this.children = children\n    this.cachedKeys = new Array(children.length)\n    this.pointerIndex = 0\n  }\n\n  /**\n   * Read a given number of nodes, advancing the pointer by that amount\n   */\n  public read(n: number): Descendant[] {\n    // PERF: If only one child was requested (the most common case), use array\n    // indexing instead of slice\n    if (n === 1) {\n      return [this.children[this.pointerIndex++]]\n    }\n\n    const slicedChildren = this.remaining(n)\n    this.pointerIndex += n\n\n    return slicedChildren\n  }\n\n  /**\n   * Get the remaining children without advancing the pointer\n   *\n   * @param [maxChildren] Limit the number of children returned.\n   */\n  public remaining(maxChildren?: number): Descendant[] {\n    if (maxChildren === undefined) {\n      return this.children.slice(this.pointerIndex)\n    }\n\n    return this.children.slice(\n      this.pointerIndex,\n      this.pointerIndex + maxChildren\n    )\n  }\n\n  /**\n   * Whether all children have been read\n   */\n  public get reachedEnd() {\n    return this.pointerIndex >= this.children.length\n  }\n\n  /**\n   * Determine whether a node with a given key appears in the unread part of the\n   * children array, and return its index relative to the current pointer if so\n   *\n   * Searching for the node object itself using indexOf is most efficient, but\n   * will fail to locate nodes that have been modified. In this case, nodes\n   * should be identified by their keys instead.\n   *\n   * Searching an array of keys using indexOf is very inefficient since fetching\n   * the keys for all children in advance is very slow. Insead, if the node\n   * search fails to return a value, fetch the keys of each remaining child one\n   * by one and compare it to the known key.\n   */\n  public lookAhead(node: Descendant, key: Key) {\n    const elementResult = this.children.indexOf(node, this.pointerIndex)\n    if (elementResult > -1) return elementResult - this.pointerIndex\n\n    for (let i = this.pointerIndex; i < this.children.length; i++) {\n      const candidateNode = this.children[i]\n      const candidateKey = this.findKey(candidateNode, i)\n      if (candidateKey === key) return i - this.pointerIndex\n    }\n\n    return -1\n  }\n\n  /**\n   * Convert an array of Slate nodes to an array of chunk leaves, each\n   * containing the node and its key\n   */\n  public toChunkLeaves(nodes: Descendant[], startIndex: number): ChunkLeaf[] {\n    return nodes.map((node, i) => ({\n      type: 'leaf',\n      node,\n      key: this.findKey(node, startIndex + i),\n      index: startIndex + i,\n    }))\n  }\n\n  /**\n   * Get the key for a Slate node, cached using the node's index\n   */\n  private findKey(node: Descendant, index: number): Key {\n    const cachedKey = this.cachedKeys[index]\n    if (cachedKey) return cachedKey\n    const key = ReactEditor.findKey(this.editor, node)\n    this.cachedKeys[index] = key\n    return key\n  }\n}\n","import { Editor, Descendant } from 'slate'\nimport { ChunkTree, ChunkLeaf } from './types'\nimport { ChunkTreeHelper, ChunkTreeHelperOptions } from './chunk-tree-helper'\nimport { ChildrenHelper } from './children-helper'\n\nexport interface ReconcileOptions extends ChunkTreeHelperOptions {\n  chunkTree: ChunkTree\n  children: Descendant[]\n  chunkSize: number\n  rerenderChildren?: number[]\n  onInsert?: (node: Descendant, index: number) => void\n  onUpdate?: (node: Descendant, index: number) => void\n  onIndexChange?: (node: Descendant, index: number) => void\n  debug?: boolean\n}\n\n/**\n * Update the chunk tree to match the children array, inserting, removing and\n * updating differing nodes\n */\nexport const reconcileChildren = (\n  editor: Editor,\n  {\n    chunkTree,\n    children,\n    chunkSize,\n    rerenderChildren = [],\n    onInsert,\n    onUpdate,\n    onIndexChange,\n    debug,\n  }: ReconcileOptions\n) => {\n  const chunkTreeHelper = new ChunkTreeHelper(chunkTree, { chunkSize, debug })\n  const childrenHelper = new ChildrenHelper(editor, children)\n\n  let treeLeaf: ChunkLeaf | null\n\n  // Read leaves from the tree one by one, each one representing a single Slate\n  // node. Each leaf from the tree is compared to the current node in the\n  // children array to determine whether nodes have been inserted, removed or\n  // updated.\n  while ((treeLeaf = chunkTreeHelper.readLeaf())) {\n    // Check where the tree node appears in the children array. In the most\n    // common case (where no insertions or removals have occurred), this will be\n    // 0. If the node has been removed, this will be -1. If new nodes have been\n    // inserted before the node, or if the node has been moved to a later\n    // position in the same children array, this will be a positive number.\n    const lookAhead = childrenHelper.lookAhead(treeLeaf.node, treeLeaf.key)\n\n    // If the node was moved, we want to remove it and insert it later, rather\n    // then re-inserting all intermediate nodes before it.\n    const wasMoved = lookAhead > 0 && chunkTree.movedNodeKeys.has(treeLeaf.key)\n\n    // If the tree leaf was moved or removed, remove it\n    if (lookAhead === -1 || wasMoved) {\n      chunkTreeHelper.remove()\n      continue\n    }\n\n    // Get the matching Slate node and any nodes that may have been inserted\n    // prior to it. Insert these into the chunk tree.\n    const insertedChildrenStartIndex = childrenHelper.pointerIndex\n    const insertedChildren = childrenHelper.read(lookAhead + 1)\n    const matchingChild = insertedChildren.pop()!\n\n    if (insertedChildren.length) {\n      const leavesToInsert = childrenHelper.toChunkLeaves(\n        insertedChildren,\n        insertedChildrenStartIndex\n      )\n\n      chunkTreeHelper.insertBefore(leavesToInsert)\n\n      insertedChildren.forEach((node, relativeIndex) => {\n        onInsert?.(node, insertedChildrenStartIndex + relativeIndex)\n      })\n    }\n\n    const matchingChildIndex = childrenHelper.pointerIndex - 1\n\n    // Make sure the chunk tree contains the most recent version of the Slate\n    // node\n    if (treeLeaf.node !== matchingChild) {\n      treeLeaf.node = matchingChild\n      chunkTreeHelper.invalidateChunk()\n      onUpdate?.(matchingChild, matchingChildIndex)\n    }\n\n    // Update the index if it has changed\n    if (treeLeaf.index !== matchingChildIndex) {\n      treeLeaf.index = matchingChildIndex\n      onIndexChange?.(matchingChild, matchingChildIndex)\n    }\n\n    // Manually invalidate chunks containing specific children that we want to\n    // re-render\n    if (rerenderChildren.includes(matchingChildIndex)) {\n      chunkTreeHelper.invalidateChunk()\n    }\n  }\n\n  // If there are still Slate nodes remaining from the children array that were\n  // not matched to nodes in the tree, insert them at the end of the tree\n  if (!childrenHelper.reachedEnd) {\n    const remainingChildren = childrenHelper.remaining()\n\n    const leavesToInsert = childrenHelper.toChunkLeaves(\n      remainingChildren,\n      childrenHelper.pointerIndex\n    )\n\n    // Move the pointer back to the final leaf in the tree, or the start of the\n    // tree if the tree is currently empty\n    chunkTreeHelper.returnToPreviousLeaf()\n\n    chunkTreeHelper.insertAfter(leavesToInsert)\n\n    remainingChildren.forEach((node, relativeIndex) => {\n      onInsert?.(node, childrenHelper.pointerIndex + relativeIndex)\n    })\n  }\n\n  chunkTree.movedNodeKeys.clear()\n}\n","import { Ancestor, Editor } from 'slate'\nimport { Key } from 'slate-dom'\nimport { ChunkTree } from './types'\nimport { ReconcileOptions, reconcileChildren } from './reconcile-children'\nimport { ReactEditor } from '../plugin/react-editor'\n\nexport const KEY_TO_CHUNK_TREE = new WeakMap<Key, ChunkTree>()\n\n/**\n * Get or create the chunk tree for a Slate node\n *\n * If the reconcile option is provided, the chunk tree will be updated to\n * match the current children of the node. The children are chunked\n * automatically using the given chunk size.\n */\nexport const getChunkTreeForNode = (\n  editor: Editor,\n  node: Ancestor,\n  // istanbul ignore next\n  options: {\n    reconcile?: Omit<ReconcileOptions, 'chunkTree' | 'children'> | false\n  } = {}\n) => {\n  const key = ReactEditor.findKey(editor, node)\n  let chunkTree = KEY_TO_CHUNK_TREE.get(key)\n\n  if (!chunkTree) {\n    chunkTree = {\n      type: 'root',\n      movedNodeKeys: new Set(),\n      modifiedChunks: new Set(),\n      children: [],\n    }\n\n    KEY_TO_CHUNK_TREE.set(key, chunkTree)\n  }\n\n  if (options.reconcile) {\n    reconcileChildren(editor, {\n      chunkTree,\n      children: node.children,\n      ...options.reconcile,\n    })\n  }\n\n  return chunkTree\n}\n","import React, { ComponentProps, Fragment, useEffect } from 'react'\nimport { Element } from 'slate'\nimport { Key } from 'slate-dom'\nimport { RenderChunkProps } from './editable'\nimport {\n  Chunk as TChunk,\n  ChunkAncestor as TChunkAncestor,\n  ChunkTree as TChunkTree,\n} from '../chunking'\n\nconst defaultRenderChunk = ({ children }: RenderChunkProps) => children\n\nconst ChunkAncestor = <C extends TChunkAncestor>(props: {\n  root: TChunkTree\n  ancestor: C\n  renderElement: (node: Element, index: number, key: Key) => React.JSX.Element\n  renderChunk?: (props: RenderChunkProps) => React.JSX.Element\n}) => {\n  const {\n    root,\n    ancestor,\n    renderElement,\n    renderChunk = defaultRenderChunk,\n  } = props\n\n  return ancestor.children.map(chunkNode => {\n    if (chunkNode.type === 'chunk') {\n      const key = chunkNode.key.id\n\n      const renderedChunk = renderChunk({\n        highest: ancestor === root,\n        lowest: chunkNode.children.some(c => c.type === 'leaf'),\n        attributes: { 'data-slate-chunk': true },\n        children: (\n          <MemoizedChunk\n            root={root}\n            ancestor={chunkNode}\n            renderElement={renderElement}\n            renderChunk={renderChunk}\n          />\n        ),\n      })\n\n      return <Fragment key={key}>{renderedChunk}</Fragment>\n    }\n\n    // Only blocks containing no inlines are chunked\n    const element = chunkNode.node as Element\n\n    return renderElement(element, chunkNode.index, chunkNode.key)\n  })\n}\n\nconst ChunkTree = (props: ComponentProps<typeof ChunkAncestor<TChunkTree>>) => {\n  // Clear the set of modified chunks only when React finishes rendering. The\n  // timing of this is important in strict mode because if the chunks are\n  // cleared during rendering (such as in reconcileChildren), strict mode's\n  // second render won't include them.\n  useEffect(() => {\n    props.root.modifiedChunks.clear()\n  })\n\n  return <ChunkAncestor {...props} />\n}\n\nconst MemoizedChunk = React.memo(\n  ChunkAncestor<TChunk>,\n  (prev, next) =>\n    prev.root === next.root &&\n    prev.renderElement === next.renderElement &&\n    prev.renderChunk === next.renderChunk &&\n    !next.root.modifiedChunks.has(next.ancestor)\n)\n\nexport default ChunkTree\n","import { createContext, useContext } from 'react'\nimport { Element } from 'slate'\n\nexport const ElementContext = createContext<Element | null>(null)\n\n/**\n * Get the current element.\n */\n\nexport const useElement = (): Element => {\n  const context = useContext(ElementContext)\n\n  if (!context) {\n    throw new Error(\n      'The `useElement` hook must be used inside `renderElement`.'\n    )\n  }\n\n  return context\n}\n\n/**\n * Get the current element, or return null if not inside `renderElement`.\n */\nexport const useElementIf = () => useContext(ElementContext)\n","import React, { useCallback, useRef } from 'react'\nimport { Ancestor, Editor, Element, DecoratedRange, Text, Node } from 'slate'\nimport { Key, isElementDecorationsEqual } from 'slate-dom'\nimport {\n  RenderChunkProps,\n  RenderElementProps,\n  RenderLeafProps,\n  RenderPlaceholderProps,\n  RenderTextProps,\n} from '../components/editable'\n\nimport ElementComponent from '../components/element'\nimport TextComponent from '../components/text'\nimport { ReactEditor } from '../plugin/react-editor'\nimport {\n  IS_NODE_MAP_DIRTY,\n  NODE_TO_INDEX,\n  NODE_TO_PARENT,\n  splitDecorationsByChild,\n} from 'slate-dom'\nimport { useSlateStatic } from './use-slate-static'\nimport { getChunkTreeForNode } from '../chunking'\nimport ChunkTree from '../components/chunk-tree'\nimport { ElementContext } from './use-element'\n\n/**\n * Children.\n */\n\nconst useChildren = (props: {\n  decorations: DecoratedRange[]\n  node: Ancestor\n  renderElement?: (props: RenderElementProps) => React.JSX.Element\n  renderChunk?: (props: RenderChunkProps) => React.JSX.Element\n  renderPlaceholder: (props: RenderPlaceholderProps) => React.JSX.Element\n  renderText?: (props: RenderTextProps) => React.JSX.Element\n  renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n}) => {\n  const {\n    decorations,\n    node,\n    renderElement,\n    renderChunk,\n    renderPlaceholder,\n    renderText,\n    renderLeaf,\n  } = props\n  const editor = useSlateStatic()\n  IS_NODE_MAP_DIRTY.set(editor as ReactEditor, false)\n\n  const isBlock = Node.isElement(node) && !editor.isInline(node)\n  const isLeafBlock = isBlock && Editor.hasInlines(editor, node)\n  const chunkSize = isLeafBlock ? null : editor.getChunkSize(node)\n  const chunking = !!chunkSize\n\n  const { decorationsByChild, childrenToRedecorate } = useDecorationsByChild(\n    editor,\n    node,\n    decorations\n  )\n\n  // Update the index and parent of each child.\n  // PERF: If chunking is enabled, this is done while traversing the chunk tree\n  // instead to eliminate unnecessary weak map operations.\n  if (!chunking) {\n    node.children.forEach((n, i) => {\n      NODE_TO_INDEX.set(n, i)\n      NODE_TO_PARENT.set(n, node)\n    })\n  }\n\n  const renderElementComponent = useCallback(\n    (n: Element, i: number, cachedKey?: Key) => {\n      const key = cachedKey ?? ReactEditor.findKey(editor, n)\n\n      return (\n        <ElementContext.Provider key={`provider-${key.id}`} value={n}>\n          <ElementComponent\n            decorations={decorationsByChild[i]}\n            element={n}\n            key={key.id}\n            renderElement={renderElement}\n            renderChunk={renderChunk}\n            renderPlaceholder={renderPlaceholder}\n            renderLeaf={renderLeaf}\n            renderText={renderText}\n          />\n        </ElementContext.Provider>\n      )\n    },\n    [\n      editor,\n      decorationsByChild,\n      renderElement,\n      renderChunk,\n      renderPlaceholder,\n      renderLeaf,\n      renderText,\n    ]\n  )\n\n  const renderTextComponent = (n: Text, i: number) => {\n    const key = ReactEditor.findKey(editor, n)\n\n    return (\n      <TextComponent\n        decorations={decorationsByChild[i]}\n        key={key.id}\n        isLast={i === node.children.length - 1}\n        parent={node}\n        renderPlaceholder={renderPlaceholder}\n        renderLeaf={renderLeaf}\n        renderText={renderText}\n        text={n}\n      />\n    )\n  }\n\n  if (!chunking) {\n    return node.children.map((n, i) =>\n      Node.isText(n) ? renderTextComponent(n, i) : renderElementComponent(n, i)\n    )\n  }\n\n  const chunkTree = getChunkTreeForNode(editor, node, {\n    reconcile: {\n      chunkSize,\n      rerenderChildren: childrenToRedecorate,\n      onInsert: (n, i) => {\n        NODE_TO_INDEX.set(n, i)\n        NODE_TO_PARENT.set(n, node)\n      },\n      onUpdate: (n, i) => {\n        NODE_TO_INDEX.set(n, i)\n        NODE_TO_PARENT.set(n, node)\n      },\n      onIndexChange: (n, i) => {\n        NODE_TO_INDEX.set(n, i)\n      },\n    },\n  })\n\n  return (\n    <ChunkTree\n      root={chunkTree}\n      ancestor={chunkTree}\n      renderElement={renderElementComponent}\n      renderChunk={renderChunk}\n    />\n  )\n}\n\nconst useDecorationsByChild = (\n  editor: Editor,\n  node: Ancestor,\n  decorations: DecoratedRange[]\n) => {\n  const decorationsByChild = splitDecorationsByChild(editor, node, decorations)\n\n  // The value we return is a mutable array of `DecoratedRange[]` arrays. This\n  // lets us avoid passing an immutable array of decorations for each child into\n  // `ChunkTree` using props. Each `DecoratedRange[]` is only updated if the\n  // decorations at that index have changed, which speeds up the equality check\n  // for the `decorations` prop in the memoized `Element` and `Text` components.\n  const mutableDecorationsByChild = useRef(decorationsByChild).current\n\n  // Track the list of child indices whose decorations have changed, so that we\n  // can tell the chunk tree to re-render these children.\n  const childrenToRedecorate: number[] = []\n\n  // Resize the mutable array to match the latest result\n  mutableDecorationsByChild.length = decorationsByChild.length\n\n  for (let i = 0; i < decorationsByChild.length; i++) {\n    const decorations = decorationsByChild[i]\n\n    const previousDecorations: DecoratedRange[] | null =\n      mutableDecorationsByChild[i] ?? null\n\n    if (!isElementDecorationsEqual(previousDecorations, decorations)) {\n      mutableDecorationsByChild[i] = decorations\n      childrenToRedecorate.push(i)\n    }\n  }\n\n  return { decorationsByChild: mutableDecorationsByChild, childrenToRedecorate }\n}\n\nexport default useChildren\n","import { createContext, useContext } from 'react'\n\n/**\n * A React context for sharing the `readOnly` state of the editor.\n */\n\nexport const ReadOnlyContext = createContext(false)\n\n/**\n * Get the current `readOnly` state of the editor.\n */\n\nexport const useReadOnly = (): boolean => {\n  return useContext(ReadOnlyContext)\n}\n","import { createContext, useCallback, useContext, useMemo, useRef } from 'react'\nimport { Editor } from 'slate'\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect'\nimport { useSlateStatic } from './use-slate-static'\nimport { useGenericSelector } from './use-generic-selector'\n\ntype Callback = () => void\n\nexport interface SlateSelectorOptions {\n  /**\n   * If true, defer calling the selector function until after `Editable` has\n   * finished rendering. This ensures that `ReactEditor.findPath` won't return\n   * an outdated path if called inside the selector.\n   */\n  deferred?: boolean\n}\n\n/**\n * A React context for sharing the editor selector context in a way to control\n * re-renders.\n */\n\nexport const SlateSelectorContext = createContext<{\n  addEventListener: (\n    callback: Callback,\n    options?: SlateSelectorOptions\n  ) => () => void\n  flushDeferred: () => void\n}>({} as any)\n\nconst refEquality = (a: any, b: any) => a === b\n\n/**\n * Use redux style selectors to prevent re-rendering on every keystroke.\n *\n * Bear in mind re-rendering can only prevented if the returned value is a value\n * type or for reference types (e.g. objects and arrays) add a custom equality\n * function.\n *\n * If `selector` is memoized using `useCallback`, then it will only be called\n * when it or the editor state changes. Otherwise, `selector` will be called\n * every time the component renders.\n *\n * @example\n * const isSelectionActive = useSlateSelector(editor => Boolean(editor.selection))\n */\n\nexport function useSlateSelector<T>(\n  selector: (editor: Editor) => T,\n  equalityFn: (a: T | null, b: T) => boolean = refEquality,\n  { deferred }: SlateSelectorOptions = {}\n): T {\n  const context = useContext(SlateSelectorContext)\n  if (!context) {\n    throw new Error(\n      `The \\`useSlateSelector\\` hook must be used inside the <Slate> component's context.`\n    )\n  }\n  const { addEventListener } = context\n\n  const editor = useSlateStatic()\n  const genericSelector = useCallback(\n    () => selector(editor),\n    [editor, selector]\n  )\n  const [selectedState, update] = useGenericSelector(\n    genericSelector,\n    equalityFn\n  )\n\n  useIsomorphicLayoutEffect(() => {\n    const unsubscribe = addEventListener(update, { deferred })\n    update()\n    return unsubscribe\n  }, [addEventListener, update, deferred])\n\n  return selectedState\n}\n\n/**\n * Create selector context with editor updating on every editor change\n */\nexport function useSelectorContext() {\n  const eventListeners = useRef(new Set<Callback>())\n  const deferredEventListeners = useRef(new Set<Callback>())\n\n  const onChange = useCallback(() => {\n    eventListeners.current.forEach(listener => listener())\n  }, [])\n\n  const flushDeferred = useCallback(() => {\n    deferredEventListeners.current.forEach(listener => listener())\n    deferredEventListeners.current.clear()\n  }, [])\n\n  const addEventListener = useCallback(\n    (\n      callbackProp: Callback,\n      { deferred = false }: SlateSelectorOptions = {}\n    ) => {\n      const callback = deferred\n        ? () => deferredEventListeners.current.add(callbackProp)\n        : callbackProp\n\n      eventListeners.current.add(callback)\n\n      return () => {\n        eventListeners.current.delete(callback)\n        if (deferred) {\n          deferredEventListeners.current.delete(callbackProp)\n        }\n      }\n    },\n    []\n  )\n\n  const selectorContext = useMemo(\n    () => ({\n      addEventListener,\n      flushDeferred,\n    }),\n    [addEventListener, flushDeferred]\n  )\n\n  return { selectorContext, onChange }\n}\n\nexport function useFlushDeferredSelectorsOnRender() {\n  const { flushDeferred } = useContext(SlateSelectorContext)\n  useIsomorphicLayoutEffect(flushDeferred)\n}\n","import { MutableRefObject, useContext, useMemo, useReducer } from 'react'\nimport { Editor } from 'slate'\nimport { SlateSelectorContext } from './use-slate-selector'\nimport { useSlateStatic } from './use-slate-static'\nimport { useIsomorphicLayoutEffect } from './use-isomorphic-layout-effect'\n\n/**\n * Get the current editor object and re-render whenever it changes.\n */\n\nexport const useSlate = (): Editor => {\n  const { addEventListener } = useContext(SlateSelectorContext)\n  const [, forceRender] = useReducer(s => s + 1, 0)\n\n  if (!addEventListener) {\n    throw new Error(\n      `The \\`useSlate\\` hook must be used inside the <Slate> component's context.`\n    )\n  }\n\n  useIsomorphicLayoutEffect(\n    () => addEventListener(forceRender),\n    [addEventListener]\n  )\n\n  return useSlateStatic()\n}\n\nconst EDITOR_TO_V = new WeakMap<Editor, MutableRefObject<number>>()\n\nconst getEditorVersionRef = (editor: Editor): MutableRefObject<number> => {\n  let v = EDITOR_TO_V.get(editor)\n\n  if (v) {\n    return v\n  }\n\n  v = { current: 0 }\n  EDITOR_TO_V.set(editor, v)\n\n  // Register the `onChange` handler exactly once per editor\n  const { onChange } = editor\n\n  editor.onChange = options => {\n    v!.current++\n    onChange(options)\n  }\n\n  return v\n}\n\n/**\n * Get the current editor object and its version, which increments on every\n * change.\n *\n * @deprecated The `v` counter is no longer used except for this hook, and may\n * be removed in a future version.\n */\n\nexport const useSlateWithV = (): { editor: Editor; v: number } => {\n  const editor = useSlate()\n  const vRef = useMemo(() => getEditorVersionRef(editor), [editor])\n  return { editor, v: vRef.current }\n}\n","import { useCallback, useEffect, useRef } from 'react'\nimport { ReactEditor } from '../plugin/react-editor'\nimport { useSlateStatic } from './use-slate-static'\n\nexport function useTrackUserInput() {\n  const editor = useSlateStatic()\n\n  const receivedUserInput = useRef<boolean>(false)\n  const animationFrameIdRef = useRef<number>(0)\n\n  const onUserInput = useCallback(() => {\n    if (receivedUserInput.current) {\n      return\n    }\n\n    receivedUserInput.current = true\n\n    const window = ReactEditor.getWindow(editor)\n    window.cancelAnimationFrame(animationFrameIdRef.current)\n\n    animationFrameIdRef.current = window.requestAnimationFrame(() => {\n      receivedUserInput.current = false\n    })\n  }, [editor])\n\n  useEffect(() => () => cancelAnimationFrame(animationFrameIdRef.current), [])\n\n  return {\n    receivedUserInput,\n    onUserInput,\n  }\n}\n","import { RefObject } from 'react'\nimport { ReactEditor } from '../../plugin/react-editor'\nimport { isDOMElement, isTrackedMutation } from 'slate-dom'\n\nexport type RestoreDOMManager = {\n  registerMutations: (mutations: MutationRecord[]) => void\n  restoreDOM: () => void\n  clear: () => void\n}\n\nconst isPlaceholderNode = (node: Node) =>\n  isDOMElement(node) && node.hasAttribute('data-slate-placeholder')\n\nconst changesOnlyPlaceholders = ({\n  addedNodes,\n  removedNodes,\n}: MutationRecord) => {\n  const nodes = [...Array.from(addedNodes), ...Array.from(removedNodes)]\n  return nodes.length > 0 && nodes.every(isPlaceholderNode)\n}\n\nexport const createRestoreDomManager = (\n  editor: ReactEditor,\n  receivedUserInput: RefObject<boolean>\n): RestoreDOMManager => {\n  let bufferedMutations: MutationRecord[] = []\n\n  const clear = () => {\n    bufferedMutations = []\n  }\n\n  const registerMutations = (mutations: MutationRecord[]) => {\n    if (!receivedUserInput.current) {\n      return\n    }\n\n    const trackedMutations = mutations.filter(\n      mutation =>\n        !changesOnlyPlaceholders(mutation) &&\n        isTrackedMutation(editor, mutation, mutations)\n    )\n\n    bufferedMutations.push(...trackedMutations)\n  }\n\n  function restoreDOM() {\n    if (bufferedMutations.length > 0) {\n      bufferedMutations.reverse().forEach(mutation => {\n        if (mutation.type === 'characterData') {\n          // We don't want to restore the DOM for characterData mutations\n          // because this interrupts the composition.\n          return\n        }\n\n        mutation.removedNodes.forEach(node => {\n          mutation.target.insertBefore(node, mutation.nextSibling)\n        })\n\n        mutation.addedNodes.forEach(node => {\n          mutation.target.removeChild(node)\n        })\n      })\n\n      // Clear buffered mutations to ensure we don't undo them twice\n      clear()\n    }\n  }\n\n  return {\n    registerMutations,\n    restoreDOM,\n    clear,\n  }\n}\n","import { useEffect, useMemo } from 'react'\nimport { ReactEditor } from '../plugin/react-editor'\nimport { createRestoreDomManager } from '../components/restore-dom/restore-dom-manager'\n\nexport const useCompositionDOM = (editor: ReactEditor) => {\n  const compositionDOM = useMemo(() => {\n    const manager = createRestoreDomManager(editor, { current: true })\n    let observer: MutationObserver | null = null\n\n    const clear = () => {\n      observer?.disconnect()\n      observer = null\n      manager.clear()\n    }\n\n    const observe = () => {\n      observer ??= new MutationObserver(manager.registerMutations)\n      observer.observe(ReactEditor.toDOMNode(editor, editor), {\n        childList: true,\n        subtree: true,\n      })\n    }\n\n    const track = (text: string | null) => {\n      if (!observer && !text?.includes('\\n')) return\n      observe()\n    }\n\n    const pause = () => {\n      if (!observer) return\n      manager.registerMutations(observer.takeRecords())\n      observer.disconnect()\n    }\n\n    const restore = () => {\n      pause()\n      manager.restoreDOM()\n    }\n\n    return { observe, track, pause, restore, clear }\n  }, [editor])\n\n  useEffect(() => () => compositionDOM.clear(), [compositionDOM])\n\n  return compositionDOM\n}\n","import { useEffect, useMemo } from 'react'\nimport { isDOMElement } from 'slate-dom'\nimport { ReactEditor } from '../plugin/react-editor'\n\nconst revertMutation = (mutation: MutationRecord) => {\n  const { target } = mutation\n\n  if (mutation.type === 'characterData') {\n    target.nodeValue = mutation.oldValue\n  } else if (mutation.type === 'attributes' && isDOMElement(target)) {\n    const name = mutation.attributeName!\n    if (mutation.oldValue === null) {\n      target.removeAttribute(name)\n    } else {\n      target.setAttribute(name, mutation.oldValue)\n    }\n  } else {\n    mutation.addedNodes.forEach(node => node.parentNode?.removeChild(node))\n    mutation.removedNodes.forEach(node =>\n      target.insertBefore(node, mutation.nextSibling)\n    )\n  }\n}\n\nexport const useNativeFormatDOM = (editor: ReactEditor) => {\n  const nativeFormatDOM = useMemo(() => {\n    let delivered: MutationRecord[] = []\n    let observer: MutationObserver | null = null\n\n    const deliver = (mutations: MutationRecord[]) => {\n      if (delivered.length === 0) {\n        setTimeout(() => {\n          delivered = []\n        })\n      }\n      delivered.push(...mutations)\n    }\n\n    const observe = () => {\n      observer ??= new MutationObserver(deliver)\n      observer.observe(ReactEditor.toDOMNode(editor, editor), {\n        attributes: true,\n        attributeOldValue: true,\n        characterData: true,\n        characterDataOldValue: true,\n        childList: true,\n        subtree: true,\n      })\n    }\n\n    const disconnect = () => {\n      observer?.disconnect()\n      delivered = []\n    }\n\n    const revert = () => {\n      const mutations = [...delivered, ...(observer?.takeRecords() ?? [])]\n      delivered = []\n      mutations.reverse().forEach(revertMutation)\n    }\n\n    return { observe, disconnect, revert }\n  }, [editor])\n\n  useEffect(() => {\n    nativeFormatDOM.observe()\n    return nativeFormatDOM.disconnect\n  }, [nativeFormatDOM])\n\n  return nativeFormatDOM\n}\n","import { Editor, Node, Point } from 'slate'\nimport { ReactEditor } from '../plugin/react-editor'\n\nconst caretTop = (editor: ReactEditor, point: Point) => {\n  const range = ReactEditor.resolveDOMRange(editor, {\n    anchor: point,\n    focus: point,\n  })\n\n  if (!range) {\n    return null\n  }\n\n  const [rect] = Array.from(range.getClientRects())\n  return (rect ?? range.getBoundingClientRect()).top\n}\n\nexport const getPointAboveTrailingNewline = (\n  editor: ReactEditor,\n  point: Point\n): Point | null => {\n  const block = Editor.above(editor, {\n    at: point,\n    match: n => Node.isElement(n) && Editor.isBlock(editor, n),\n  })\n\n  if (!block) {\n    return null\n  }\n\n  const blockStart = Editor.start(editor, block[1])\n  const before = Editor.before(editor, blockStart)\n\n  if (!before || !Editor.leaf(editor, before)[0].text.endsWith('\\n')) {\n    return null\n  }\n\n  if (Point.equals(point, blockStart)) {\n    return before\n  }\n\n  const pointTop = caretTop(editor, point)\n  const blockStartTop = caretTop(editor, blockStart)\n\n  if (pointTop === null || blockStartTop === null) {\n    return null\n  }\n\n  return Math.abs(pointTop - blockStartTop) > 2 ? null : before\n}\n","import { Editor, Node, Path, Point } from 'slate'\n\nexport const getCharacterMoveUnit = (\n  editor: Editor,\n  point: Point,\n  reverse: boolean\n): 'character' | 'offset' => {\n  const inline = Editor.above(editor, {\n    at: point,\n    match: node => Node.isElement(node) && editor.isInline(node),\n  })\n\n  if (\n    !inline ||\n    editor.isVoid(inline[0]) ||\n    editor.isElementReadOnly(inline[0]) ||\n    !(reverse\n      ? Editor.isStart(editor, point, inline[1])\n      : Editor.isEnd(editor, point, inline[1]))\n  ) {\n    return 'character'\n  }\n\n  if (reverse && !Path.hasPrevious(inline[1])) {\n    return 'character'\n  }\n\n  const siblingPath = reverse ? Path.previous(inline[1]) : Path.next(inline[1])\n\n  if (!Editor.hasPath(editor, siblingPath)) {\n    return 'character'\n  }\n\n  const sibling = Node.get(editor, siblingPath)\n  return Node.isText(sibling) && sibling.text === '' ? 'offset' : 'character'\n}\n","import { Editor, Path, Range } from 'slate'\nimport { DOMNode, DOMText, getSelection, isDOMNode } from 'slate-dom'\nimport { ReactEditor } from '../plugin/react-editor'\n\nconst isTextNode = (node: DOMNode | null | undefined): node is DOMText =>\n  isDOMNode(node) && node.nodeType === node.TEXT_NODE\n\nexport const removeStrayComposition = (editor: ReactEditor, data: string) => {\n  const { selection } = editor\n  if (!selection || !Range.isCollapsed(selection)) return\n\n  const domSelection = getSelection(\n    ReactEditor.findDocumentOrShadowRoot(editor)\n  )\n  const node = domSelection?.anchorNode\n  if (!domSelection || !isTextNode(node)) return\n\n  const end = domSelection.anchorOffset\n  const start = end - data.length\n  if (start < 0 || node.data.slice(start, end) !== data) return\n  if (!ReactEditor.hasDOMNode(editor, node, { editable: true })) return\n\n  const leafPath = ReactEditor.findPath(\n    editor,\n    ReactEditor.toSlateNode(editor, node)\n  )\n  const insertsIntoLeaf =\n    Path.equals(leafPath, selection.anchor.path) &&\n    !Editor.void(editor, { at: selection })\n  if (insertsIntoLeaf) return\n\n  node.deleteData(start, data.length)\n}\n","import { Editor, Node, Path, Point, Range, Transforms } from 'slate'\n\nconst blockPathAt = (editor: Editor, point: Point): Path | undefined =>\n  Editor.above(editor, {\n    at: point,\n    match: n => Node.isElement(n) && Editor.isBlock(editor, n),\n  })?.[1]\n\nexport const getWholeTopLevelBlockPaths = (\n  editor: Editor,\n  range: Range\n): Path[] | null => {\n  const [start, end] = Range.edges(range)\n  const startBlock = blockPathAt(editor, start)\n  const endBlock = blockPathAt(editor, end)\n\n  if (\n    !startBlock ||\n    !endBlock ||\n    startBlock.length !== 1 ||\n    endBlock.length !== 1 ||\n    startBlock[0] >= endBlock[0] ||\n    !Editor.isStart(editor, start, startBlock) ||\n    !Editor.isStart(editor, end, endBlock)\n  ) {\n    return null\n  }\n\n  return Array.from({ length: endBlock[0] - startBlock[0] }, (_, offset) => [\n    startBlock[0] + offset,\n  ])\n}\n\nexport const getMovableRange = (editor: Editor, range: Range): Range =>\n  getWholeTopLevelBlockPaths(editor, range)\n    ? range\n    : Editor.unhangRange(editor, range)\n\nexport const deleteMovedRange = (editor: Editor, range: Range) => {\n  if (Range.isCollapsed(range)) {\n    const voidEntry = Editor.void(editor, { at: range })\n\n    if (voidEntry) {\n      Transforms.removeNodes(editor, { at: voidEntry[1], voids: true })\n    }\n\n    return\n  }\n\n  const blockPaths = getWholeTopLevelBlockPaths(editor, range)\n\n  if (!blockPaths) {\n    Transforms.select(editor, range)\n    Editor.deleteFragment(editor)\n    return\n  }\n\n  const followingBlockRef = Editor.pathRef(\n    editor,\n    Path.next(blockPaths[blockPaths.length - 1])\n  )\n\n  Editor.withoutNormalizing(editor, () => {\n    for (const path of [...blockPaths].reverse()) {\n      Transforms.removeNodes(editor, { at: path })\n    }\n  })\n\n  const followingBlock = followingBlockRef.unref()\n\n  if (followingBlock) {\n    Transforms.select(editor, Editor.start(editor, followingBlock))\n  }\n}\n","function _assertThisInitialized(e) {\n  if (void 0 === e) throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n  return e;\n}\nmodule.exports = _assertThisInitialized, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var _typeof = require(\"./typeof.js\")[\"default\"];\nvar assertThisInitialized = require(\"./assertThisInitialized.js\");\nfunction _possibleConstructorReturn(t, e) {\n  if (e && (\"object\" == _typeof(e) || \"function\" == typeof e)) return e;\n  if (void 0 !== e) throw new TypeError(\"Derived constructors may only return object or undefined\");\n  return assertThisInitialized(t);\n}\nmodule.exports = _possibleConstructorReturn, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _getPrototypeOf(t) {\n  return module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) {\n    return t.__proto__ || Object.getPrototypeOf(t);\n  }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports, _getPrototypeOf(t);\n}\nmodule.exports = _getPrototypeOf, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","function _setPrototypeOf(t, e) {\n  return module.exports = _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) {\n    return t.__proto__ = e, t;\n  }, module.exports.__esModule = true, module.exports[\"default\"] = module.exports, _setPrototypeOf(t, e);\n}\nmodule.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","var setPrototypeOf = require(\"./setPrototypeOf.js\");\nfunction _inherits(t, e) {\n  if (\"function\" != typeof e && null !== e) throw new TypeError(\"Super expression must either be null or a function\");\n  t.prototype = Object.create(e && e.prototype, {\n    constructor: {\n      value: t,\n      writable: !0,\n      configurable: !0\n    }\n  }), Object.defineProperty(t, \"prototype\", {\n    writable: !1\n  }), e && setPrototypeOf(t, e);\n}\nmodule.exports = _inherits, module.exports.__esModule = true, module.exports[\"default\"] = module.exports;","import React, {\n  Component,\n  ComponentType,\n  ContextType,\n  ReactNode,\n  RefObject,\n} from 'react'\nimport { EditorContext } from '../../hooks/use-slate-static'\nimport { IS_ANDROID } from 'slate-dom'\nimport {\n  createRestoreDomManager,\n  RestoreDOMManager,\n} from './restore-dom-manager'\n\nconst MUTATION_OBSERVER_CONFIG: MutationObserverInit = {\n  subtree: true,\n  childList: true,\n  characterData: true,\n  characterDataOldValue: true,\n}\n\ntype RestoreDOMProps = {\n  children?: ReactNode\n  receivedUserInput: RefObject<boolean>\n  node: RefObject<HTMLDivElement | null>\n}\n\n// We have to use a class component here since we rely on `getSnapshotBeforeUpdate` which has no FC equivalent\n// to run code synchronously immediately before react commits the component update to the DOM.\nclass RestoreDOMComponent extends Component<RestoreDOMProps> {\n  static contextType = EditorContext\n  context: ContextType<typeof EditorContext> = null\n\n  private manager: RestoreDOMManager | null = null\n  private mutationObserver: MutationObserver | null = null\n\n  observe() {\n    const { node } = this.props\n    if (!node.current) {\n      throw new Error('Failed to attach MutationObserver, `node` is undefined')\n    }\n\n    this.mutationObserver?.observe(node.current, MUTATION_OBSERVER_CONFIG)\n  }\n\n  componentDidMount() {\n    const { receivedUserInput } = this.props\n    const editor = this.context!\n\n    this.manager = createRestoreDomManager(editor, receivedUserInput)\n    this.mutationObserver = new MutationObserver(this.manager.registerMutations)\n\n    this.observe()\n  }\n\n  getSnapshotBeforeUpdate() {\n    const pendingMutations = this.mutationObserver?.takeRecords()\n    if (pendingMutations?.length) {\n      this.manager?.registerMutations(pendingMutations)\n    }\n\n    this.mutationObserver?.disconnect()\n    this.manager?.restoreDOM()\n\n    return null\n  }\n\n  componentDidUpdate() {\n    this.manager?.clear()\n    this.observe()\n  }\n\n  componentWillUnmount() {\n    this.mutationObserver?.disconnect()\n  }\n\n  render() {\n    return this.props.children\n  }\n}\n\nexport const RestoreDOM: ComponentType<RestoreDOMProps> = IS_ANDROID\n  ? RestoreDOMComponent\n  : ({ children }) => <>{children}</>\n","import { createContext, useContext } from 'react'\nimport { ReactEditor } from '../plugin/react-editor'\n\nexport const EDITOR_TO_COMPOSING = new WeakMap<ReactEditor, boolean>()\n\n/**\n * A React context for sharing the `composing` state of the editor.\n */\n\nexport const ComposingContext = createContext(false)\n\n/**\n * Get the current `composing` state of the editor.\n */\n\nexport const useComposing = (): boolean => {\n  return useContext(ComposingContext)\n}\n","import getDirection from 'direction'\nimport debounce from 'lodash/debounce'\nimport throttle from 'lodash/throttle'\nimport React, {\n  useCallback,\n  useEffect,\n  useMemo,\n  useReducer,\n  useRef,\n  useState,\n  forwardRef,\n  ForwardedRef,\n} from 'react'\nimport { JSX } from 'react'\nimport scrollIntoView from 'scroll-into-view-if-needed'\nimport {\n  Editor,\n  Element,\n  Node,\n  NodeEntry,\n  Path,\n  Point,\n  Range,\n  Text,\n  Transforms,\n  DecoratedRange,\n  LeafPosition,\n} from 'slate'\nimport { useAndroidInputManager } from '../hooks/android-input-manager/use-android-input-manager'\nimport useChildren from '../hooks/use-children'\nimport { DecorateContext, useDecorateContext } from '../hooks/use-decorations'\nimport { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\nimport { ReadOnlyContext } from '../hooks/use-read-only'\nimport { useSlate } from '../hooks/use-slate'\nimport { useTrackUserInput } from '../hooks/use-track-user-input'\nimport { useCompositionDOM } from '../hooks/use-composition-dom'\nimport { useNativeFormatDOM } from '../hooks/use-native-format-dom'\nimport { getPointAboveTrailingNewline } from '../utils/trailing-newline'\nimport { getCharacterMoveUnit } from '../utils/character-move'\nimport { removeStrayComposition } from '../utils/misplaced-composition'\nimport { ReactEditor } from '../plugin/react-editor'\nimport { deleteMovedRange, getMovableRange } from '../utils/move-range'\nimport { TRIPLE_CLICK } from 'slate-dom'\nimport {\n  containsShadowAware,\n  DOMElement,\n  DOMRange,\n  DOMText,\n  getActiveElement,\n  getDefaultView,\n  getSelection,\n  isDOMElement,\n  isDOMNode,\n  isPlainTextOnlyPaste,\n} from 'slate-dom'\nimport {\n  CAN_USE_DOM,\n  HAS_BEFORE_INPUT_SUPPORT,\n  IS_ANDROID,\n  IS_CHROME,\n  IS_FIREFOX,\n  IS_FIREFOX_LEGACY,\n  IS_IOS,\n  IS_WEBKIT,\n  IS_UC_MOBILE,\n  IS_WECHATBROWSER,\n} from 'slate-dom'\nimport { Hotkeys } from 'slate-dom'\nimport {\n  IS_NODE_MAP_DIRTY,\n  EDITOR_TO_ELEMENT,\n  EDITOR_TO_FORCE_RENDER,\n  EDITOR_TO_PENDING_INSERTION_MARKS,\n  EDITOR_TO_USER_MARKS,\n  EDITOR_TO_USER_SELECTION,\n  EDITOR_TO_WINDOW,\n  ELEMENT_TO_NODE,\n  IS_COMPOSING,\n  IS_FOCUSED,\n  IS_READ_ONLY,\n  MARK_PLACEHOLDER_SYMBOL,\n  NODE_TO_ELEMENT,\n  PLACEHOLDER_SYMBOL,\n} from 'slate-dom'\nimport { RestoreDOM } from './restore-dom/restore-dom'\nimport { AndroidInputManager } from '../hooks/android-input-manager/android-input-manager'\nimport { ComposingContext, EDITOR_TO_COMPOSING } from '../hooks/use-composing'\nimport { useFlushDeferredSelectorsOnRender } from '../hooks/use-slate-selector'\n\ntype DeferredOperation = () => void\n\nconst isTextDOMNode = (node: unknown): node is DOMText =>\n  isDOMNode(node) && node.nodeType === 3\n\nconst isSameCaretPosition = (editor: Editor, a: Range, b: Range) => {\n  if (!Range.isCollapsed(a) || !Range.isCollapsed(b)) {\n    return false\n  }\n\n  const [first, second] = Path.isBefore(a.anchor.path, b.anchor.path)\n    ? [a.anchor, b.anchor]\n    : [b.anchor, a.anchor]\n\n  if (second.offset !== 0 || !Path.equals(Path.next(first.path), second.path)) {\n    return false\n  }\n\n  const node = Node.get(editor, first.path)\n  return Node.isText(node) && first.offset === node.text.length\n}\n\nconst Children = (props: Parameters<typeof useChildren>[0]) => (\n  <React.Fragment>{useChildren(props)}</React.Fragment>\n)\n\n/**\n * `RenderElementProps` are passed to the `renderElement` handler.\n */\n\nexport interface RenderElementProps {\n  children: any\n  element: Element\n  attributes: {\n    'data-slate-node': 'element'\n    'data-slate-inline'?: true\n    'data-slate-void'?: true\n    dir?: 'rtl'\n    ref: any\n  }\n}\n\n/**\n * `RenderChunkProps` are passed to the `renderChunk` handler\n */\nexport interface RenderChunkProps {\n  highest: boolean\n  lowest: boolean\n  children: any\n  attributes: {\n    'data-slate-chunk': true\n  }\n}\n\n/**\n * `RenderLeafProps` are passed to the `renderLeaf` handler.\n */\n\nexport interface RenderLeafProps {\n  children: any\n  /**\n   * The leaf node with any applied decorations.\n   * If no decorations are applied, it will be identical to the `text` property.\n   */\n  leaf: Text\n  text: Text\n  attributes: {\n    'data-slate-leaf': true\n  }\n  /**\n   * The position of the leaf within the Text node, only present when the text node is split by decorations.\n   */\n  leafPosition?: LeafPosition\n}\n\n/**\n * `RenderTextProps` are passed to the `renderText` handler.\n */\nexport interface RenderTextProps {\n  text: Text\n  children: any\n  attributes: {\n    'data-slate-node': 'text'\n    ref: any\n  }\n}\n\n/**\n * `EditableProps` are passed to the `<Editable>` component.\n */\n\nexport type EditableProps = {\n  decorate?: ((entry: NodeEntry) => DecoratedRange[]) | undefined\n  onDOMBeforeInput?: ((event: InputEvent) => void) | undefined\n  placeholder?: string | undefined\n  readOnly?: boolean | undefined\n  role?: string | undefined\n  style?: React.CSSProperties | undefined\n  renderElement?: ((props: RenderElementProps) => React.JSX.Element) | undefined\n  renderChunk?: ((props: RenderChunkProps) => React.JSX.Element) | undefined\n  renderLeaf?: ((props: RenderLeafProps) => React.JSX.Element) | undefined\n  renderText?: ((props: RenderTextProps) => React.JSX.Element) | undefined\n  renderPlaceholder?:\n    | ((props: RenderPlaceholderProps) => React.JSX.Element)\n    | undefined\n  scrollSelectionIntoView?:\n    | ((editor: ReactEditor, domRange: DOMRange) => void)\n    | undefined\n  as?: React.ElementType | undefined\n  disableDefaultStyles?: boolean | undefined\n} & React.HTMLAttributes<HTMLDivElement>\n\n/**\n * Editable.\n */\n\nexport const Editable = forwardRef(\n  (props: EditableProps, forwardedRef: ForwardedRef<HTMLDivElement>) => {\n    const defaultRenderPlaceholder = useCallback(\n      (props: RenderPlaceholderProps) => <DefaultPlaceholder {...props} />,\n      []\n    )\n    const {\n      autoFocus,\n      decorate = defaultDecorate,\n      onDOMBeforeInput: propsOnDOMBeforeInput,\n      placeholder,\n      readOnly = false,\n      renderElement,\n      renderChunk,\n      renderLeaf,\n      renderText,\n      renderPlaceholder = defaultRenderPlaceholder,\n      scrollSelectionIntoView = defaultScrollSelectionIntoView,\n      style: userStyle = {},\n      as: Component = 'div',\n      disableDefaultStyles = false,\n      ...attributes\n    } = props\n    const editor = useSlate()\n    // Rerender editor when composition status changed\n    const [isComposing, setIsComposing] = useState(false)\n    const setComposing = useCallback(\n      (composing: boolean) => {\n        setIsComposing(composing)\n        IS_COMPOSING.set(editor, composing)\n      },\n      [editor]\n    )\n    useIsomorphicLayoutEffect(() => {\n      EDITOR_TO_COMPOSING.set(editor, isComposing)\n      return () => {\n        EDITOR_TO_COMPOSING.delete(editor)\n      }\n    }, [editor, isComposing])\n    const ref = useRef<HTMLDivElement | null>(null)\n    const previousChildren = useRef(editor.children)\n    const previousSelection = useRef(editor.selection)\n    const pendingInputScroll = useRef(false)\n    const pendingNavigationScroll = useRef(false)\n    const deferredOperations = useRef<DeferredOperation[]>([])\n    const lastNativeInsertion = useRef<{\n      point: Point\n      text: string\n      domNode: DOMText\n      domOffset: number\n      domText: string\n      char: string\n    } | null>(null)\n    const [placeholderHeight, setPlaceholderHeight] = useState<\n      number | undefined\n    >()\n    const processing = useRef(false)\n    const compositionDOM = useCompositionDOM(editor)\n    const nativeFormatDOM = useNativeFormatDOM(editor)\n    const deleteOnCompositionEndRef = useRef(false)\n\n    const { onUserInput, receivedUserInput } = useTrackUserInput()\n\n    const [, forceRender] = useReducer(s => s + 1, 0)\n    EDITOR_TO_FORCE_RENDER.set(editor, forceRender)\n\n    // Update internal state on each render.\n    IS_READ_ONLY.set(editor, readOnly)\n\n    // Keep track of some state for the event handler logic.\n    const state = useMemo(\n      () => ({\n        isBlurring: false,\n        isDraggingInternally: false,\n        isTabbing: false,\n        pendingSelection: null as {\n          range: Range\n          basedOn: Range | null\n        } | null,\n        isUpdatingSelection: false,\n        latestElement: null as DOMElement | null,\n        hasMarkPlaceholder: false,\n      }),\n      []\n    )\n\n    // The autoFocus TextareaHTMLAttribute doesn't do anything on a div, so it\n    // needs to be manually focused.\n    //\n    // If this stops working in Firefox, make sure nothing is causing this\n    // component to re-render during the initial mount. If the DOM selection is\n    // set by `useIsomorphicLayoutEffect` before `onDOMSelectionChange` updates\n    // `editor.selection`, the DOM selection can be removed accidentally.\n    useEffect(() => {\n      if (!ref.current || !autoFocus) {\n        return\n      }\n\n      if (editor.children.length > 0) {\n        ReactEditor.focus(editor)\n      } else {\n        ref.current.focus()\n      }\n    }, [autoFocus, editor])\n\n    /**\n     * The AndroidInputManager object has a cyclical dependency on onDOMSelectionChange\n     *\n     * It is defined as a reference to simplify hook dependencies and clarify that\n     * it needs to be initialized.\n     */\n    const androidInputManagerRef = useRef<\n      AndroidInputManager | null | undefined\n    >(undefined)\n\n    // Listen on the native `selectionchange` event to be able to update any time\n    // the selection changes. This is required because React's `onSelect` is leaky\n    // and non-standard so it doesn't fire until after a selection has been\n    // released. This causes issues in situations where another change happens\n    // while a selection is being dragged.\n    const onDOMSelectionChange = useMemo(\n      () =>\n        throttle(() => {\n          if (IS_NODE_MAP_DIRTY.get(editor)) {\n            onDOMSelectionChange()\n            return\n          }\n\n          state.pendingSelection = null\n\n          const el = ReactEditor.toDOMNode(editor, editor)\n          const root = el.getRootNode()\n\n          if (!processing.current && IS_WEBKIT && root instanceof ShadowRoot) {\n            processing.current = true\n\n            const active = getActiveElement()\n\n            if (active) {\n              document.execCommand('indent')\n            } else {\n              Transforms.deselect(editor)\n            }\n\n            processing.current = false\n            return\n          }\n\n          const androidInputManager = androidInputManagerRef.current\n          if (\n            (IS_ANDROID || !ReactEditor.isComposing(editor)) &&\n            (!state.isUpdatingSelection || androidInputManager?.isFlushing()) &&\n            !state.isDraggingInternally\n          ) {\n            const root = ReactEditor.findDocumentOrShadowRoot(editor)\n            const { activeElement } = root\n            const el = ReactEditor.toDOMNode(editor, editor)\n            const domSelection = getSelection(root)\n\n            if (activeElement === el) {\n              state.latestElement = activeElement\n              IS_FOCUSED.set(editor, true)\n            } else {\n              IS_FOCUSED.delete(editor)\n            }\n\n            if (!domSelection) {\n              return Transforms.deselect(editor)\n            }\n\n            const { anchorNode, focusNode } = domSelection\n\n            const anchorNodeSelectable =\n              ReactEditor.hasEditableTarget(editor, anchorNode) ||\n              ReactEditor.isTargetInsideNonReadonlyVoid(editor, anchorNode)\n\n            const focusNodeInEditor = ReactEditor.hasTarget(editor, focusNode)\n            const isFocusInEditor =\n              isDOMNode(activeElement) && el.contains(activeElement)\n\n            if (\n              anchorNodeSelectable &&\n              focusNodeInEditor &&\n              (readOnly || isFocusInEditor || state.isBlurring)\n            ) {\n              const range = ReactEditor.toSlateRange(editor, domSelection, {\n                exactMatch: false,\n                suppressThrow: true,\n              })\n\n              if (range) {\n                if (\n                  !ReactEditor.isComposing(editor) &&\n                  !androidInputManager?.hasPendingChanges() &&\n                  !androidInputManager?.isFlushing()\n                ) {\n                  const isCaretOutsideText =\n                    domSelection.isCollapsed && !isInSlateText(anchorNode)\n\n                  if (\n                    isCaretOutsideText &&\n                    editor.selection &&\n                    Range.equals(range, editor.selection)\n                  ) {\n                    restoreDomSelection(editor, domSelection, state)\n                  } else {\n                    Transforms.select(editor, range)\n                  }\n                } else {\n                  androidInputManager?.handleUserSelect(range)\n                }\n              }\n            }\n\n            // Deselect the editor if the dom selection is not selectable in readonly mode\n            if (readOnly && (!anchorNodeSelectable || !focusNodeInEditor)) {\n              Transforms.deselect(editor)\n            }\n          }\n        }, 100),\n      [editor, readOnly, state]\n    )\n\n    const scheduleOnDOMSelectionChange = useMemo(\n      () => debounce(onDOMSelectionChange, 0),\n      [onDOMSelectionChange]\n    )\n\n    const flushDOMSelectionChange = useCallback(() => {\n      const root = ReactEditor.toDOMNode(editor, editor).getRootNode()\n      scheduleOnDOMSelectionChange.flush()\n      if (!(IS_WEBKIT && root instanceof ShadowRoot)) {\n        onDOMSelectionChange()\n      }\n      onDOMSelectionChange.flush()\n    }, [editor, onDOMSelectionChange, scheduleOnDOMSelectionChange])\n\n    androidInputManagerRef.current = useAndroidInputManager({\n      node: ref,\n      onDOMSelectionChange,\n      scheduleOnDOMSelectionChange,\n    })\n\n    useIsomorphicLayoutEffect(() => {\n      // Update element-related weak maps with the DOM element ref.\n      let window\n      if (ref.current && (window = getDefaultView(ref.current))) {\n        EDITOR_TO_WINDOW.set(editor, window)\n        EDITOR_TO_ELEMENT.set(editor, ref.current)\n        NODE_TO_ELEMENT.set(editor, ref.current)\n        ELEMENT_TO_NODE.set(ref.current, editor)\n      } else {\n        NODE_TO_ELEMENT.delete(editor)\n      }\n\n      // Make sure the DOM selection state is in sync.\n      const { selection } = editor\n      const scrollForInput = pendingInputScroll.current\n      pendingInputScroll.current = false\n      const scrollForNavigation = pendingNavigationScroll.current\n      pendingNavigationScroll.current = false\n      const selectionChangedByInput =\n        ((scrollForInput && previousChildren.current !== editor.children) ||\n          scrollForNavigation) &&\n        !!selection &&\n        (!previousSelection.current ||\n          !Range.equals(previousSelection.current, selection))\n      previousChildren.current = editor.children\n      previousSelection.current = selection\n      const root = ReactEditor.findDocumentOrShadowRoot(editor)\n      const domSelection = getSelection(root)\n\n      if (\n        !domSelection ||\n        !ReactEditor.isFocused(editor) ||\n        androidInputManagerRef.current?.hasPendingAction()\n      ) {\n        return\n      }\n\n      const setDomSelection = (forceChange?: boolean) => {\n        const hasDomSelection = domSelection.type !== 'None'\n\n        // If the DOM selection is properly unset, we're done.\n        if (!selection && !hasDomSelection) {\n          return\n        }\n\n        // Get anchorNode and focusNode\n        const focusNode = domSelection.focusNode\n        let anchorNode\n\n        // COMPAT: In firefox the normal selection way does not work\n        // (https://github.com/ianstormtaylor/slate/pull/5486#issue-1820720223)\n        if (IS_FIREFOX && domSelection.rangeCount > 1) {\n          const firstRange = domSelection.getRangeAt(0)\n          const lastRange = domSelection.getRangeAt(domSelection.rangeCount - 1)\n\n          // Right to left\n          if (firstRange.startContainer === focusNode) {\n            anchorNode = lastRange.endContainer\n          } else {\n            // Left to right\n            anchorNode = firstRange.startContainer\n          }\n        } else {\n          anchorNode = domSelection.anchorNode\n        }\n\n        // verify that the dom selection is in the editor\n        const editorElement = EDITOR_TO_ELEMENT.get(editor)!\n        let hasDomSelectionInEditor = false\n        if (\n          containsShadowAware(editorElement, anchorNode) &&\n          containsShadowAware(editorElement, focusNode)\n        ) {\n          hasDomSelectionInEditor = true\n        }\n\n        // If the DOM selection is in the editor and the editor selection is already correct, we're done.\n        if (\n          hasDomSelection &&\n          hasDomSelectionInEditor &&\n          selection &&\n          !forceChange\n        ) {\n          const slateRange = ReactEditor.toSlateRange(editor, domSelection, {\n            exactMatch: true,\n\n            // domSelection is not necessarily a valid Slate range\n            // (e.g. when clicking on contentEditable:false element)\n            suppressThrow: true,\n          })\n\n          if (\n            slateRange &&\n            Range.equals(slateRange, selection) &&\n            (!state.hasMarkPlaceholder ||\n              anchorNode?.parentElement?.hasAttribute(\n                'data-slate-mark-placeholder'\n              ))\n          ) {\n            if (selectionChangedByInput) {\n              scrollSelectionIntoView(editor, domSelection.getRangeAt(0))\n            }\n            return\n          }\n        }\n\n        // when <Editable/> is being controlled through external value\n        // then its children might just change - DOM responds to it on its own\n        // but Slate's value is not being updated through any operation\n        // and thus it doesn't transform selection on its own\n        if (selection && !ReactEditor.hasRange(editor, selection)) {\n          editor.selection = ReactEditor.resolveSlateRange(editor, domSelection)\n          return\n        }\n\n        const pending = state.pendingSelection\n        state.pendingSelection = null\n\n        if (\n          pending &&\n          !forceChange &&\n          pending.basedOn === selection &&\n          !(selection && Range.equals(pending.range, selection))\n        ) {\n          Transforms.select(editor, pending.range)\n          return\n        }\n\n        // Otherwise the DOM selection is out of sync, so update it.\n        state.isUpdatingSelection = true\n\n        const newDomRange =\n          selection && ReactEditor.resolveDOMRange(editor, selection)\n\n        if (newDomRange) {\n          if (ReactEditor.isComposing(editor) && !IS_ANDROID) {\n            if (domSelection.rangeCount > 0) {\n              domSelection.collapseToEnd()\n            }\n          } else if (Range.isBackward(selection!)) {\n            domSelection.setBaseAndExtent(\n              newDomRange.endContainer,\n              newDomRange.endOffset,\n              newDomRange.startContainer,\n              newDomRange.startOffset\n            )\n          } else {\n            domSelection.setBaseAndExtent(\n              newDomRange.startContainer,\n              newDomRange.startOffset,\n              newDomRange.endContainer,\n              newDomRange.endOffset\n            )\n          }\n          scrollSelectionIntoView(editor, newDomRange)\n        } else {\n          domSelection.removeAllRanges()\n        }\n\n        return newDomRange\n      }\n\n      // In firefox if there is more then 1 range and we call setDomSelection we remove the ability to select more cells in a table\n      if (domSelection.rangeCount <= 1) {\n        setDomSelection()\n      }\n\n      const ensureSelection =\n        androidInputManagerRef.current?.isFlushing() === 'action'\n\n      if (!IS_ANDROID || !ensureSelection) {\n        setTimeout(() => {\n          state.isUpdatingSelection = false\n        })\n        return\n      }\n\n      let timeoutId: ReturnType<typeof setTimeout> | null = null\n      const animationFrameId = requestAnimationFrame(() => {\n        if (ensureSelection) {\n          const ensureDomSelection = (forceChange?: boolean) => {\n            const el = EDITOR_TO_ELEMENT.get(editor)\n\n            if (!el) {\n              return\n            }\n\n            el.focus()\n            setDomSelection(forceChange)\n          }\n\n          // Compat: Android IMEs try to force their selection by manually re-applying it even after we set it.\n          // This essentially would make setting the slate selection during an update meaningless, so we force it\n          // again here. We can't only do it in the setTimeout after the animation frame since that would cause a\n          // visible flicker.\n          ensureDomSelection()\n\n          timeoutId = setTimeout(() => {\n            // COMPAT: While setting the selection in an animation frame visually correctly sets the selection,\n            // it doesn't update GBoards spellchecker state. We have to manually trigger a selection change after\n            // the animation frame to ensure it displays the correct state.\n            ensureDomSelection(true)\n            state.isUpdatingSelection = false\n          })\n        }\n      })\n\n      return () => {\n        cancelAnimationFrame(animationFrameId)\n        if (timeoutId) {\n          clearTimeout(timeoutId)\n        }\n      }\n    })\n\n    // Listen on the native `beforeinput` event to get real \"Level 2\" events. This\n    // is required because React's `beforeinput` is fake and never really attaches\n    // to the real event sadly. (2019/11/01)\n    // https://github.com/facebook/react/issues/11211\n    const onDOMBeforeInput = useCallback(\n      (event: InputEvent) => {\n        if (readOnly) {\n          isDOMEventHandled(event, propsOnDOMBeforeInput)\n          return\n        }\n\n        if (!ReactEditor.hasEditableTarget(editor, event.target)) {\n          return\n        }\n\n        handleNativeHistoryEvents(editor, event)\n        const el = ReactEditor.toDOMNode(editor, editor)\n        const root = el.getRootNode()\n\n        if (processing?.current && IS_WEBKIT && root instanceof ShadowRoot) {\n          const ranges = event.getTargetRanges()\n          const range = ranges[0]\n\n          const newRange = new window.Range()\n\n          newRange.setStart(range.startContainer, range.startOffset)\n          newRange.setEnd(range.endContainer, range.endOffset)\n\n          // Unresolvable ranges would throw out of the handler (#3556); suppress and skip the move.\n          const slateRange = ReactEditor.toSlateRange(editor, newRange, {\n            exactMatch: false,\n            suppressThrow: true,\n          })\n\n          if (slateRange) {\n            Transforms.select(editor, slateRange)\n          }\n\n          event.preventDefault()\n          event.stopImmediatePropagation()\n          return\n        }\n        onUserInput()\n        pendingInputScroll.current = true\n\n        if (!isDOMEventHandled(event, propsOnDOMBeforeInput)) {\n          // COMPAT: BeforeInput events aren't cancelable on android, so we have to handle them differently using the android input manager.\n          if (androidInputManagerRef.current) {\n            return androidInputManagerRef.current.handleDOMBeforeInput(event)\n          }\n\n          // Some IMEs/Chrome extensions like e.g. Grammarly set the selection immediately before\n          // triggering a `beforeinput` expecting the change to be applied to the immediately before\n          // set selection.\n          flushDOMSelectionChange()\n\n          const { selection } = editor\n          const { inputType: type } = event\n          const data = (event as any).dataTransfer || event.data || undefined\n\n          const isCompositionChange =\n            type === 'insertCompositionText' || type === 'deleteCompositionText'\n\n          // COMPAT: use composition change events as a hint to where we should insert\n          // composition text if we aren't composing to work around https://github.com/ianstormtaylor/slate/issues/5038\n          if (isCompositionChange && ReactEditor.isComposing(editor)) {\n            if (IS_CHROME || deleteOnCompositionEndRef.current) {\n              compositionDOM.track(event.data)\n            }\n            return\n          }\n\n          let native = false\n          let nativePoint: [DOMText, number] | null = null\n          if (\n            type === 'insertText' &&\n            selection &&\n            Range.isCollapsed(selection) &&\n            // Only use native character insertion for single characters a-z or space for now.\n            // Long-press events (hold a + press 4 = ä) to choose a special character otherwise\n            // causes duplicate inserts.\n            event.data &&\n            event.data.length === 1 &&\n            /[a-z ]/i.test(event.data) &&\n            // Chrome has issues correctly editing the start of nodes: https://bugs.chromium.org/p/chromium/issues/detail?id=1249405\n            // When there is an inline element, e.g. a link, and you select\n            // right after it (the start of the next node).\n            selection.anchor.offset !== 0\n          ) {\n            native = true\n\n            // Skip native if there are marks, as\n            // `insertText` will insert a node, not just text.\n            if (\n              editor.marks ||\n              (typeof Editor.insertionPoint === 'function' &&\n                !Point.equals(\n                  Editor.insertionPoint(editor, selection.anchor),\n                  selection.anchor\n                ))\n            ) {\n              native = false\n            }\n\n            const domSelection = getSelection(\n              ReactEditor.findDocumentOrShadowRoot(editor)\n            )\n            const domAnchor = domSelection?.anchorNode\n\n            if (!isInSlateText(domAnchor)) {\n              native = false\n            }\n\n            // If the NODE_MAP is dirty, we can't trust the selection anchor (eg ReactEditor.toDOMPoint)\n            if (!IS_NODE_MAP_DIRTY.get(editor)) {\n              // Chrome also has issues correctly editing the end of anchor elements: https://bugs.chromium.org/p/chromium/issues/detail?id=1259100\n              // Therefore we don't allow native events to insert text at the end of anchor nodes.\n              const { anchor } = selection\n\n              const domPoint = ReactEditor.resolveDOMPoint(editor, anchor)\n\n              if (!domPoint) {\n                native = false\n              } else {\n                const [node, offset] = domPoint\n                const anchorNode = node.parentElement?.closest('a')\n\n                const window = ReactEditor.getWindow(editor)\n\n                if (\n                  native &&\n                  anchorNode &&\n                  ReactEditor.hasDOMNode(editor, anchorNode)\n                ) {\n                  // Find the last text node inside the anchor.\n                  const lastText = window?.document\n                    .createTreeWalker(anchorNode, NodeFilter.SHOW_TEXT)\n                    .lastChild() as DOMText | null\n\n                  if (\n                    lastText === node &&\n                    lastText.textContent?.length === offset\n                  ) {\n                    native = false\n                  }\n                }\n\n                // Chrome has issues with the presence of tab characters inside elements with whiteSpace = 'pre'\n                // causing abnormal insert behavior: https://bugs.chromium.org/p/chromium/issues/detail?id=1219139\n                if (\n                  native &&\n                  node.parentElement &&\n                  window?.getComputedStyle(node.parentElement)?.whiteSpace ===\n                    'pre'\n                ) {\n                  const block = Editor.above(editor, {\n                    at: anchor.path,\n                    match: n => Node.isElement(n) && Editor.isBlock(editor, n),\n                  })\n\n                  if (block && Node.string(block[0]).includes('\\t')) {\n                    native = false\n                  }\n                }\n\n                if (native && isTextDOMNode(node)) {\n                  nativePoint =\n                    domSelection?.isCollapsed && isTextDOMNode(domAnchor)\n                      ? [domAnchor, domSelection.anchorOffset]\n                      : [node, offset]\n                }\n              }\n            }\n          }\n          // COMPAT: For the deleting forward/backward input types we don't want\n          // to change the selection because it is the range that will be deleted,\n          // and those commands determine that for themselves.\n          // If the NODE_MAP is dirty, we can't trust the selection anchor (eg ReactEditor.toDOMPoint via ReactEditor.toSlateRange)\n          if (\n            (!type.startsWith('delete') || type.startsWith('deleteBy')) &&\n            !IS_NODE_MAP_DIRTY.get(editor)\n          ) {\n            const [targetRange] = event.getTargetRanges()\n\n            if (targetRange) {\n              // Unresolvable ranges would throw out of the handler (#3556); suppress and fall back to synthetic handling.\n              const range = ReactEditor.toSlateRange(editor, targetRange, {\n                exactMatch: false,\n                suppressThrow: true,\n              })\n\n              if (!range) {\n                native = false\n              } else if (!selection || !Range.equals(selection, range)) {\n                native = false\n\n                const selectionRef =\n                  !isCompositionChange &&\n                  editor.selection &&\n                  !isSameCaretPosition(editor, editor.selection, range) &&\n                  Editor.rangeRef(editor, editor.selection)\n\n                Transforms.select(editor, range)\n\n                if (selectionRef) {\n                  EDITOR_TO_USER_SELECTION.set(editor, selectionRef)\n                }\n              }\n\n              if (native && isTextDOMNode(targetRange.startContainer)) {\n                nativePoint = [\n                  targetRange.startContainer,\n                  targetRange.startOffset,\n                ]\n              }\n            }\n          }\n\n          // Composition change types occur while a user is composing text and can't be\n          // cancelled. Let them through and wait for the composition to end.\n          if (isCompositionChange) {\n            return\n          }\n\n          if (!native) {\n            lastNativeInsertion.current = null\n            event.preventDefault()\n          }\n\n          // COMPAT: If the selection is expanded, even if the command seems like\n          // a delete forward/backward command it should delete the selection.\n          if (\n            selection &&\n            Range.isExpanded(selection) &&\n            type.startsWith('delete')\n          ) {\n            const direction = type.endsWith('Backward') ? 'backward' : 'forward'\n            Editor.deleteFragment(editor, { direction })\n            return\n          }\n\n          switch (type) {\n            case 'deleteByComposition':\n            case 'deleteByCut':\n            case 'deleteByDrag': {\n              Editor.deleteFragment(editor)\n              break\n            }\n\n            case 'deleteContent':\n            case 'deleteContentForward': {\n              Editor.deleteForward(editor)\n              break\n            }\n\n            case 'deleteContentBackward': {\n              Editor.deleteBackward(editor)\n              break\n            }\n\n            case 'deleteEntireSoftLine': {\n              Editor.deleteBackward(editor, { unit: 'line' })\n              Editor.deleteForward(editor, { unit: 'line' })\n              break\n            }\n\n            case 'deleteHardLineBackward': {\n              Editor.deleteBackward(editor, { unit: 'block' })\n              break\n            }\n\n            case 'deleteSoftLineBackward': {\n              Editor.deleteBackward(editor, { unit: 'line' })\n              break\n            }\n\n            case 'deleteHardLineForward': {\n              Editor.deleteForward(editor, { unit: 'block' })\n              break\n            }\n\n            case 'deleteSoftLineForward': {\n              Editor.deleteForward(editor, { unit: 'line' })\n              break\n            }\n\n            case 'deleteWordBackward': {\n              Editor.deleteBackward(editor, { unit: 'word' })\n              break\n            }\n\n            case 'deleteWordForward': {\n              Editor.deleteForward(editor, { unit: 'word' })\n              break\n            }\n\n            case 'insertLineBreak':\n              Editor.insertSoftBreak(editor)\n              break\n\n            case 'insertParagraph': {\n              Editor.insertBreak(editor)\n              break\n            }\n\n            case 'insertFromComposition':\n            case 'insertFromDrop':\n            case 'insertFromPaste':\n            case 'insertFromYank':\n            case 'insertReplacementText':\n            case 'insertText': {\n              if (type === 'insertFromComposition') {\n                // COMPAT: in Safari, `compositionend` is dispatched after the\n                // `beforeinput` for \"insertFromComposition\". But if we wait for it\n                // then we will abort because we're still composing and the selection\n                // won't be updated properly.\n                // https://www.w3.org/TR/input-events-2/\n                if (ReactEditor.isComposing(editor)) {\n                  setComposing(false)\n                }\n              }\n\n              // use a weak comparison instead of 'instanceof' to allow\n              // programmatic access of paste events coming from external windows\n              // like cypress where cy.window does not work realibly\n              if (data?.constructor.name === 'DataTransfer') {\n                ReactEditor.insertData(editor, data)\n              } else if (typeof data === 'string') {\n                // Only insertText operations use the native functionality, for now.\n                // Potentially expand to single character deletes, as well.\n                if (native) {\n                  lastNativeInsertion.current = null\n                  if (nativePoint && selection) {\n                    const [node] = Editor.leaf(editor, selection.anchor)\n                    const [domNode, domOffset] = nativePoint\n                    lastNativeInsertion.current = {\n                      point: selection.anchor,\n                      text: node.text,\n                      domNode,\n                      domOffset,\n                      domText: domNode.data,\n                      char: data,\n                    }\n                  }\n                  deferredOperations.current.push(() =>\n                    Editor.insertText(editor, data)\n                  )\n                } else {\n                  Editor.insertText(editor, data)\n                }\n              }\n\n              break\n            }\n          }\n\n          // Restore the actual user section if nothing manually set it.\n          const toRestore = EDITOR_TO_USER_SELECTION.get(editor)?.unref()\n          EDITOR_TO_USER_SELECTION.delete(editor)\n\n          if (\n            toRestore &&\n            (!editor.selection || !Range.equals(editor.selection, toRestore))\n          ) {\n            Transforms.select(editor, toRestore)\n          }\n        }\n      },\n      [\n        editor,\n        onUserInput,\n        propsOnDOMBeforeInput,\n        compositionDOM,\n        flushDOMSelectionChange,\n        readOnly,\n        setComposing,\n      ]\n    )\n\n    const callbackRef = useCallback(\n      (node: HTMLDivElement | null) => {\n        if (node == null) {\n          onDOMSelectionChange.cancel()\n          scheduleOnDOMSelectionChange.cancel()\n\n          EDITOR_TO_ELEMENT.delete(editor)\n          NODE_TO_ELEMENT.delete(editor)\n\n          if (ref.current && HAS_BEFORE_INPUT_SUPPORT) {\n            // @ts-ignore The `beforeinput` event isn't recognized.\n            ref.current.removeEventListener('beforeinput', onDOMBeforeInput)\n          }\n        } else {\n          // Attach a native DOM event handler for `beforeinput` events, because React's\n          // built-in `onBeforeInput` is actually a leaky polyfill that doesn't expose\n          // real `beforeinput` events sadly... (2019/11/04)\n          // https://github.com/facebook/react/issues/11211\n          if (HAS_BEFORE_INPUT_SUPPORT) {\n            // @ts-ignore The `beforeinput` event isn't recognized.\n            node.addEventListener('beforeinput', onDOMBeforeInput)\n          }\n        }\n\n        ref.current = node\n        if (typeof forwardedRef === 'function') {\n          forwardedRef(node)\n        } else if (forwardedRef) {\n          forwardedRef.current = node\n        }\n      },\n      [\n        onDOMSelectionChange,\n        scheduleOnDOMSelectionChange,\n        editor,\n        onDOMBeforeInput,\n        forwardedRef,\n      ]\n    )\n\n    useIsomorphicLayoutEffect(() => {\n      const window = ReactEditor.getWindow(editor)\n\n      // COMPAT: In Chrome, `selectionchange` events can fire when <input> and\n      // <textarea> elements are appended to the DOM, causing\n      // `editor.selection` to be overwritten in some circumstances.\n      // (2025/01/16) https://issues.chromium.org/issues/389368412\n      const readUnsyncedSelection = () => {\n        const androidInputManager = androidInputManagerRef.current\n\n        if (\n          state.isUpdatingSelection ||\n          state.isDraggingInternally ||\n          ReactEditor.isComposing(editor) ||\n          androidInputManager?.hasPendingChanges() ||\n          androidInputManager?.isFlushing() ||\n          IS_NODE_MAP_DIRTY.get(editor)\n        ) {\n          return null\n        }\n\n        const domSelection = getSelection(\n          ReactEditor.findDocumentOrShadowRoot(editor)\n        )\n\n        if (\n          !domSelection ||\n          !(\n            ReactEditor.hasEditableTarget(editor, domSelection.anchorNode) ||\n            ReactEditor.isTargetInsideNonReadonlyVoid(\n              editor,\n              domSelection.anchorNode\n            )\n          ) ||\n          !ReactEditor.hasTarget(editor, domSelection.focusNode)\n        ) {\n          return null\n        }\n\n        const range = ReactEditor.toSlateRange(editor, domSelection, {\n          exactMatch: false,\n          suppressThrow: true,\n        })\n\n        return range ? { range, basedOn: editor.selection } : null\n      }\n\n      const onSelectionChange = ({ target }: Event) => {\n        const targetElement = target instanceof HTMLElement ? target : null\n        const targetTagName = targetElement?.tagName\n        if (targetTagName === 'INPUT' || targetTagName === 'TEXTAREA') {\n          return\n        }\n        state.pendingSelection = readUnsyncedSelection()\n        scheduleOnDOMSelectionChange()\n      }\n\n      // Attach a native DOM event handler for `selectionchange`, because React's\n      // built-in `onSelect` handler doesn't fire for all selection changes. It's\n      // a leaky polyfill that only fires on keypresses or clicks. Instead, we\n      // want to fire for any change to the selection inside the editor.\n      // (2019/11/04) https://github.com/facebook/react/issues/5785\n      window.document.addEventListener('selectionchange', onSelectionChange)\n\n      const onKeyDown = (event: KeyboardEvent) => {\n        state.isTabbing = event.key === 'Tab'\n      }\n      const clearTabbing = () => {\n        state.isTabbing = false\n      }\n      window.document.addEventListener('keydown', onKeyDown, true)\n      window.document.addEventListener('keyup', clearTabbing, true)\n      window.document.addEventListener('pointerdown', clearTabbing, true)\n\n      // Listen for dragend and drop globally. In Firefox, if a drop handler\n      // initiates an operation that causes the originally dragged element to\n      // unmount, that element will not emit a dragend event. (2024/06/21)\n      const stoppedDragging = () => {\n        state.isDraggingInternally = false\n      }\n      window.document.addEventListener('dragend', stoppedDragging)\n      window.document.addEventListener('drop', stoppedDragging)\n\n      return () => {\n        window.document.removeEventListener(\n          'selectionchange',\n          onSelectionChange\n        )\n        window.document.removeEventListener('keydown', onKeyDown, true)\n        window.document.removeEventListener('keyup', clearTabbing, true)\n        window.document.removeEventListener('pointerdown', clearTabbing, true)\n        window.document.removeEventListener('dragend', stoppedDragging)\n        window.document.removeEventListener('drop', stoppedDragging)\n      }\n    }, [editor, scheduleOnDOMSelectionChange, state])\n\n    const decorations = decorate([editor, []])\n    const decorateContext = useDecorateContext(decorate)\n\n    const showPlaceholder =\n      placeholder &&\n      editor.children.length === 1 &&\n      Array.from(Node.texts(editor)).length === 1 &&\n      Node.string(editor) === '' &&\n      !isComposing\n\n    const placeHolderResizeHandler = useCallback(\n      (placeholderEl: HTMLElement | null) => {\n        if (placeholderEl && showPlaceholder) {\n          setPlaceholderHeight(placeholderEl.getBoundingClientRect()?.height)\n        } else {\n          setPlaceholderHeight(undefined)\n        }\n      },\n      [showPlaceholder]\n    )\n\n    if (showPlaceholder) {\n      const start = Editor.start(editor, [])\n      decorations.push({\n        [PLACEHOLDER_SYMBOL]: true,\n        placeholder,\n        onPlaceholderResize: placeHolderResizeHandler,\n        anchor: start,\n        focus: start,\n      })\n    }\n\n    const { marks } = editor\n    state.hasMarkPlaceholder = false\n\n    if (editor.selection && Range.isCollapsed(editor.selection) && marks) {\n      const { anchor } = editor.selection\n      const leaf = Node.leaf(editor, anchor.path)\n      const { text, ...rest } = leaf\n\n      // While marks isn't a 'complete' text, we can still use loose Text.equals\n      // here which only compares marks anyway.\n      if (!Text.equals(leaf, marks as Text, { loose: true })) {\n        state.hasMarkPlaceholder = true\n\n        const unset = Object.fromEntries(\n          Object.keys(rest).map(mark => [mark, null])\n        )\n\n        decorations.push({\n          [MARK_PLACEHOLDER_SYMBOL]: true,\n          ...unset,\n          ...marks,\n\n          anchor,\n          focus: anchor,\n        })\n      }\n    }\n\n    // Update EDITOR_TO_MARK_PLACEHOLDER_MARKS in setTimeout useEffect to ensure we don't set it\n    // before we receive the composition end event.\n    useEffect(() => {\n      setTimeout(() => {\n        const { selection } = editor\n        if (selection) {\n          const { anchor } = selection\n          const text = Node.leaf(editor, anchor.path)\n\n          // While marks isn't a 'complete' text, we can still use loose Text.equals\n          // here which only compares marks anyway.\n          if (marks && !Text.equals(text, marks as Text, { loose: true })) {\n            EDITOR_TO_PENDING_INSERTION_MARKS.set(editor, marks)\n            return\n          }\n        }\n\n        EDITOR_TO_PENDING_INSERTION_MARKS.delete(editor)\n      })\n    })\n\n    useFlushDeferredSelectorsOnRender()\n\n    return (\n      <ReadOnlyContext.Provider value={readOnly}>\n        <ComposingContext.Provider value={isComposing}>\n          <DecorateContext.Provider value={decorateContext}>\n            <RestoreDOM node={ref} receivedUserInput={receivedUserInput}>\n              <Component\n                role={readOnly ? undefined : 'textbox'}\n                aria-multiline={readOnly ? undefined : true}\n                aria-placeholder={showPlaceholder ? placeholder : undefined}\n                translate=\"no\"\n                {...attributes}\n                // COMPAT: Certain browsers don't support the `beforeinput` event, so we'd\n                // have to use hacks to make these replacement-based features work.\n                // For SSR situations HAS_BEFORE_INPUT_SUPPORT is false and results in prop\n                // mismatch warning app moves to browser. Pass-through consumer props when\n                // not CAN_USE_DOM (SSR) and default to falsy value\n                spellCheck={\n                  HAS_BEFORE_INPUT_SUPPORT || !CAN_USE_DOM\n                    ? attributes.spellCheck\n                    : false\n                }\n                autoCorrect={\n                  HAS_BEFORE_INPUT_SUPPORT || !CAN_USE_DOM\n                    ? attributes.autoCorrect\n                    : 'false'\n                }\n                autoCapitalize={\n                  HAS_BEFORE_INPUT_SUPPORT || !CAN_USE_DOM\n                    ? attributes.autoCapitalize\n                    : 'false'\n                }\n                data-slate-editor\n                data-slate-node=\"value\"\n                // explicitly set this\n                contentEditable={!readOnly}\n                // in some cases, a decoration needs access to the range / selection to decorate a text node,\n                // then you will select the whole text node when you select part the of text\n                // this magic zIndex=\"-1\" will fix it\n                zindex={-1}\n                suppressContentEditableWarning\n                ref={callbackRef}\n                style={{\n                  ...(disableDefaultStyles\n                    ? {}\n                    : {\n                        // Allow positioning relative to the editable element.\n                        position: 'relative',\n                        // Preserve adjacent whitespace and new lines.\n                        whiteSpace: 'pre-wrap',\n                        // Allow words to break if they are too long.\n                        wordWrap: 'break-word',\n                        // Make the minimum height that of the placeholder.\n                        ...(placeholderHeight\n                          ? { minHeight: placeholderHeight }\n                          : {}),\n                      }),\n                  // Allow for passed-in styles to override anything.\n                  ...userStyle,\n                }}\n                onBeforeInput={useCallback(\n                  (event: React.InputEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onBeforeInput)\n                      return\n                    }\n\n                    // COMPAT: Certain browsers don't support the `beforeinput` event, so we\n                    // fall back to React's leaky polyfill instead just for it. It\n                    // only works for the `insertText` input type.\n                    if (\n                      !HAS_BEFORE_INPUT_SUPPORT &&\n                      !isEventHandled(event, attributes.onBeforeInput) &&\n                      ReactEditor.hasSelectableTarget(editor, event.target)\n                    ) {\n                      event.preventDefault()\n                      if (!ReactEditor.isComposing(editor)) {\n                        const text = (event as any).data as string\n                        Editor.insertText(editor, text)\n                      }\n                    }\n                  },\n                  [attributes.onBeforeInput, editor, readOnly]\n                )}\n                onInput={useCallback(\n                  (event: React.InputEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onInput)\n                      return\n                    }\n\n                    if (!ReactEditor.hasEditableTarget(editor, event.target)) {\n                      return\n                    }\n\n                    compositionDOM.pause()\n                    if (isEventHandled(event, attributes.onInput)) {\n                      return\n                    }\n\n                    if (androidInputManagerRef.current) {\n                      androidInputManagerRef.current.handleInput()\n                      return\n                    }\n\n                    if (\n                      (event.nativeEvent as InputEvent).inputType?.startsWith(\n                        'format'\n                      )\n                    ) {\n                      const domSelection = getSelection(\n                        ReactEditor.findDocumentOrShadowRoot(editor)\n                      )\n                      const range =\n                        domSelection &&\n                        ReactEditor.resolveSlateRange(editor, domSelection)\n                      nativeFormatDOM.revert()\n                      if (domSelection && range) {\n                        Transforms.select(editor, range)\n                        restoreDomSelection(editor, domSelection, state)\n                      }\n                      return\n                    }\n\n                    // Flush native operations, as native events will have propogated\n                    // and we can correctly compare DOM text values in components\n                    // to stop rendering, so that browser functions like autocorrect\n                    // and spellcheck work as expected.\n                    for (const op of deferredOperations.current) {\n                      op()\n                    }\n                    deferredOperations.current = []\n\n                    const nativeInsertion = lastNativeInsertion.current\n                    lastNativeInsertion.current = null\n\n                    if (nativeInsertion) {\n                      const { point, text, domNode, domOffset, domText, char } =\n                        nativeInsertion\n                      const node = Node.getIf(editor, point.path)\n                      if (\n                        Text.isText(node) &&\n                        node.text === text &&\n                        domNode.isConnected &&\n                        domNode.data ===\n                          domText.slice(0, domOffset) +\n                            char +\n                            domText.slice(domOffset)\n                      ) {\n                        domNode.deleteData(domOffset, char.length)\n                        if (\n                          editor.selection &&\n                          Range.isCollapsed(editor.selection) &&\n                          Point.equals(editor.selection.anchor, point)\n                        ) {\n                          getSelection(\n                            ReactEditor.findDocumentOrShadowRoot(editor)\n                          )?.collapse(domNode, domOffset)\n                        }\n                      }\n                    }\n\n                    // COMPAT: Since `beforeinput` doesn't fully `preventDefault`,\n                    // there's a chance that content might be placed in the browser's undo stack.\n                    // This means undo can be triggered even when the div is not focused,\n                    // and it only triggers the input event for the node. (2024/10/09)\n                    if (!ReactEditor.isFocused(editor)) {\n                      handleNativeHistoryEvents(\n                        editor,\n                        event.nativeEvent as InputEvent\n                      )\n                    }\n                  },\n                  [\n                    readOnly,\n                    attributes.onInput,\n                    editor,\n                    compositionDOM,\n                    nativeFormatDOM,\n                    state,\n                  ]\n                )}\n                onBlur={useCallback(\n                  (event: React.FocusEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onBlur)\n                      return\n                    }\n\n                    if (\n                      state.isUpdatingSelection ||\n                      !ReactEditor.hasSelectableTarget(editor, event.target) ||\n                      isEventHandled(event, attributes.onBlur)\n                    ) {\n                      return\n                    }\n\n                    // COMPAT: If the current `activeElement` is still the previous\n                    // one, this is due to the window being blurred when the tab\n                    // itself becomes unfocused, so we want to abort early to allow to\n                    // editor to stay focused when the tab becomes focused again.\n                    const root = ReactEditor.findDocumentOrShadowRoot(editor)\n                    if (state.latestElement === root.activeElement) {\n                      return\n                    }\n\n                    const { relatedTarget } = event\n                    const el = ReactEditor.toDOMNode(editor, editor)\n\n                    // COMPAT: The event should be ignored if the focus is returning\n                    // to the editor from an embedded editable element (eg. an <input>\n                    // element inside a void node).\n                    if (relatedTarget === el) {\n                      return\n                    }\n\n                    // COMPAT: The event should be ignored if the focus is moving from\n                    // the editor to inside a void node's spacer element.\n                    if (\n                      isDOMElement(relatedTarget) &&\n                      relatedTarget.hasAttribute('data-slate-spacer')\n                    ) {\n                      return\n                    }\n\n                    // COMPAT: The event should be ignored if the focus is moving to a\n                    // non- editable section of an element that isn't a void node (eg.\n                    // a list item of the check list example).\n                    if (\n                      relatedTarget != null &&\n                      isDOMNode(relatedTarget) &&\n                      ReactEditor.hasDOMNode(editor, relatedTarget)\n                    ) {\n                      const node = ReactEditor.toSlateNode(\n                        editor,\n                        relatedTarget\n                      )\n\n                      if (Node.isElement(node) && !editor.isVoid(node)) {\n                        return\n                      }\n                    }\n\n                    state.isBlurring = true\n                    try {\n                      flushDOMSelectionChange()\n                    } finally {\n                      state.isBlurring = false\n                    }\n\n                    // COMPAT: Safari doesn't always remove the selection even if the content-\n                    // editable element no longer has focus. Refer to:\n                    // https://stackoverflow.com/questions/12353247/force-contenteditable-div-to-stop-accepting-input-after-it-loses-focus-under-web\n                    if (IS_WEBKIT) {\n                      const domSelection = getSelection(root)\n                      domSelection?.removeAllRanges()\n                    }\n\n                    IS_FOCUSED.delete(editor)\n                  },\n                  [\n                    readOnly,\n                    state,\n                    editor,\n                    attributes.onBlur,\n                    flushDOMSelectionChange,\n                  ]\n                )}\n                onClick={useCallback(\n                  (event: React.MouseEvent<HTMLDivElement>) => {\n                    if (ReactEditor.hasTarget(editor, event.target)) {\n                      flushDOMSelectionChange()\n                    }\n\n                    if (\n                      ReactEditor.hasTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onClick) &&\n                      isDOMNode(event.target)\n                    ) {\n                      const node = ReactEditor.toSlateNode(editor, event.target)\n                      let path: Path\n\n                      try {\n                        path = ReactEditor.findPath(editor, node)\n                      } catch {\n                        return\n                      }\n\n                      // At this time, the Slate document may be arbitrarily different,\n                      // because onClick handlers can change the document before we get here.\n                      // Therefore we must check that this path actually exists,\n                      // and that it still refers to the same node.\n                      if (\n                        !Editor.hasPath(editor, path) ||\n                        Node.get(editor, path) !== node\n                      ) {\n                        return\n                      }\n\n                      if (event.detail === TRIPLE_CLICK && path.length >= 1) {\n                        let blockPath = path\n                        if (\n                          !(\n                            Node.isElement(node) && Editor.isBlock(editor, node)\n                          )\n                        ) {\n                          const block = Editor.above(editor, {\n                            match: n =>\n                              Node.isElement(n) && Editor.isBlock(editor, n),\n                            at: path,\n                          })\n\n                          blockPath = block?.[1] ?? path.slice(0, 1)\n                        }\n\n                        const isIsolated = Editor.above(editor, {\n                          at: Editor.start(editor, blockPath),\n                          match: n =>\n                            Node.isElement(n) && !!editor.isIsolated?.(n),\n                        })\n\n                        if (blockPath.length > 1 || isIsolated) {\n                          const range = Editor.range(editor, blockPath)\n                          Transforms.select(editor, range)\n                          return\n                        }\n                      }\n\n                      if (readOnly) {\n                        return\n                      }\n\n                      const start = Editor.start(editor, path)\n                      const end = Editor.end(editor, path)\n                      const startVoid = Editor.void(editor, { at: start })\n                      const endVoid = Editor.void(editor, { at: end })\n                      const selectedVoid =\n                        editor.selection &&\n                        Range.isCollapsed(editor.selection) &&\n                        Editor.void(editor, { at: editor.selection.anchor })\n\n                      if (\n                        event.shiftKey &&\n                        selectedVoid &&\n                        !Path.isAncestor(selectedVoid[1], path) &&\n                        !(\n                          startVoid &&\n                          Path.equals(startVoid[1], selectedVoid[1])\n                        )\n                      ) {\n                        const clicked = ReactEditor.resolveEventRange(\n                          editor,\n                          event\n                        )\n\n                        if (!clicked) {\n                          return\n                        }\n\n                        const voidStart = Editor.start(editor, selectedVoid[1])\n                        const voidEnd = Editor.end(editor, selectedVoid[1])\n                        const anchor = Point.isBefore(clicked.anchor, voidStart)\n                          ? voidEnd\n                          : voidStart\n                        Transforms.select(editor, {\n                          anchor,\n                          focus: clicked.anchor,\n                        })\n                        return\n                      }\n\n                      if (\n                        startVoid &&\n                        endVoid &&\n                        Path.equals(startVoid[1], endVoid[1])\n                      ) {\n                        if (event.shiftKey && editor.selection) {\n                          const { anchor } = editor.selection\n                          const focus = Point.isBefore(anchor, start)\n                            ? end\n                            : start\n                          Transforms.select(editor, { anchor, focus })\n                          return\n                        }\n\n                        const range = Editor.range(editor, start)\n                        Transforms.select(editor, range)\n                      }\n                    }\n                  },\n                  [\n                    editor,\n                    attributes.onClick,\n                    readOnly,\n                    flushDOMSelectionChange,\n                  ]\n                )}\n                onCompositionEnd={useCallback(\n                  (event: React.CompositionEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onCompositionEnd)\n                      return\n                    }\n\n                    if (isDOMEventTargetInput(event)) {\n                      return\n                    }\n                    if (ReactEditor.hasSelectableTarget(editor, event.target)) {\n                      Promise.resolve().then(() => {\n                        setComposing(false)\n                      })\n\n                      androidInputManagerRef.current?.handleCompositionEnd(\n                        event\n                      )\n\n                      const deleteOnCompositionEnd =\n                        deleteOnCompositionEndRef.current\n                      deleteOnCompositionEndRef.current = false\n\n                      if (\n                        isEventHandled(event, attributes.onCompositionEnd) ||\n                        IS_ANDROID\n                      ) {\n                        compositionDOM.clear()\n                        return\n                      }\n\n                      if (deleteOnCompositionEnd && !event.data) {\n                        compositionDOM.restore()\n                        Editor.deleteFragment(editor)\n                      }\n\n                      // COMPAT: In Chrome, `beforeinput` events for compositions\n                      // aren't correct and never fire the \"insertFromComposition\"\n                      // type that we need. So instead, insert whenever a composition\n                      // ends since it will already have been committed to the DOM.\n                      if (\n                        !IS_WEBKIT &&\n                        !IS_FIREFOX_LEGACY &&\n                        !IS_IOS &&\n                        !IS_WECHATBROWSER &&\n                        !IS_UC_MOBILE &&\n                        event.data\n                      ) {\n                        const placeholderMarks =\n                          EDITOR_TO_PENDING_INSERTION_MARKS.get(editor)\n                        EDITOR_TO_PENDING_INSERTION_MARKS.delete(editor)\n\n                        // Ensure we insert text with the marks the user was actually seeing\n                        if (placeholderMarks !== undefined) {\n                          EDITOR_TO_USER_MARKS.set(editor, editor.marks)\n                          editor.marks = placeholderMarks\n                        }\n\n                        compositionDOM.restore()\n                        removeStrayComposition(editor, event.data)\n                        Editor.insertText(editor, event.data)\n\n                        const userMarks = EDITOR_TO_USER_MARKS.get(editor)\n                        EDITOR_TO_USER_MARKS.delete(editor)\n                        if (userMarks !== undefined) {\n                          editor.marks = userMarks\n                        }\n                      }\n                      compositionDOM.clear()\n                    }\n                  },\n                  [\n                    readOnly,\n                    attributes.onCompositionEnd,\n                    editor,\n                    compositionDOM,\n                    setComposing,\n                  ]\n                )}\n                onCompositionUpdate={useCallback(\n                  (event: React.CompositionEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onCompositionUpdate)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasSelectableTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onCompositionUpdate) &&\n                      !isDOMEventTargetInput(event)\n                    ) {\n                      if (!ReactEditor.isComposing(editor)) {\n                        setComposing(true)\n                      }\n                    }\n                  },\n                  [\n                    readOnly,\n                    attributes.onCompositionUpdate,\n                    editor,\n                    setComposing,\n                  ]\n                )}\n                onCompositionStart={useCallback(\n                  (event: React.CompositionEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onCompositionStart)\n                      return\n                    }\n\n                    if (isDOMEventTargetInput(event)) {\n                      return\n                    }\n                    if (ReactEditor.hasSelectableTarget(editor, event.target)) {\n                      androidInputManagerRef.current?.handleCompositionStart(\n                        event\n                      )\n\n                      if (\n                        isEventHandled(event, attributes.onCompositionStart) ||\n                        IS_ANDROID\n                      ) {\n                        return\n                      }\n\n                      compositionDOM.clear()\n                      setIsComposing(true)\n\n                      flushDOMSelectionChange()\n\n                      const { selection } = editor\n                      if (selection && Range.isExpanded(selection)) {\n                        if (IS_FIREFOX && !IS_FIREFOX_LEGACY) {\n                          compositionDOM.observe()\n                          deleteOnCompositionEndRef.current = true\n                          return\n                        }\n\n                        Editor.deleteFragment(editor)\n                        return\n                      }\n                    }\n                  },\n                  [\n                    readOnly,\n                    attributes.onCompositionStart,\n                    editor,\n                    compositionDOM,\n                    flushDOMSelectionChange,\n                  ]\n                )}\n                onCopy={useCallback(\n                  (event: React.ClipboardEvent<HTMLDivElement>) => {\n                    if (\n                      ReactEditor.hasSelectableTarget(editor, event.target) &&\n                      !isDOMEventTargetInput(event)\n                    ) {\n                      flushDOMSelectionChange()\n                    }\n\n                    if (\n                      ReactEditor.hasSelectableTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onCopy) &&\n                      !isDOMEventTargetInput(event)\n                    ) {\n                      event.preventDefault()\n                      ReactEditor.setFragmentData(\n                        editor,\n                        event.clipboardData,\n                        'copy'\n                      )\n                    }\n                  },\n                  [attributes.onCopy, editor, flushDOMSelectionChange]\n                )}\n                onCut={useCallback(\n                  (event: React.ClipboardEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onCut)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasSelectableTarget(editor, event.target) &&\n                      !isDOMEventTargetInput(event)\n                    ) {\n                      flushDOMSelectionChange()\n                    }\n\n                    if (\n                      ReactEditor.hasSelectableTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onCut) &&\n                      !isDOMEventTargetInput(event)\n                    ) {\n                      event.preventDefault()\n                      selectMovableRange(editor)\n                      ReactEditor.setFragmentData(\n                        editor,\n                        event.clipboardData,\n                        'cut'\n                      )\n                      const { selection } = editor\n\n                      if (selection) {\n                        if (Range.isExpanded(selection)) {\n                          deleteMovedRange(editor, selection)\n                        } else {\n                          const node = Node.parent(\n                            editor,\n                            selection.anchor.path\n                          )\n                          if (Editor.isVoid(editor, node)) {\n                            Transforms.delete(editor)\n                          }\n                        }\n                      }\n                    }\n                  },\n                  [readOnly, editor, attributes.onCut, flushDOMSelectionChange]\n                )}\n                onDragOver={useCallback(\n                  (event: React.DragEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onDragOver)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onDragOver)\n                    ) {\n                      // Only when the target is void, call `preventDefault` to signal\n                      // that drops are allowed. Editable content is droppable by\n                      // default, and calling `preventDefault` hides the cursor.\n                      const node = ReactEditor.toSlateNode(editor, event.target)\n\n                      if (Node.isElement(node) && Editor.isVoid(editor, node)) {\n                        event.preventDefault()\n                      }\n                    }\n                  },\n                  [readOnly, attributes.onDragOver, editor]\n                )}\n                onDragStart={useCallback(\n                  (event: React.DragEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onDragStart)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onDragStart)\n                    ) {\n                      const node = ReactEditor.toSlateNode(editor, event.target)\n                      const path = ReactEditor.findPath(editor, node)\n                      const voidMatch =\n                        (Node.isElement(node) && Editor.isVoid(editor, node)) ||\n                        Editor.void(editor, { at: path, voids: true })\n\n                      // If starting a drag on a void node, make sure it is selected\n                      // so that it shows up in the selection's fragment.\n                      if (voidMatch) {\n                        const range = Editor.range(editor, path)\n                        Transforms.select(editor, range)\n                      }\n\n                      selectMovableRange(editor)\n                      state.isDraggingInternally = true\n\n                      ReactEditor.setFragmentData(\n                        editor,\n                        event.dataTransfer,\n                        'drag'\n                      )\n                    }\n                  },\n                  [readOnly, editor, attributes.onDragStart, state]\n                )}\n                onDrop={useCallback(\n                  (event: React.DragEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onDrop)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onDrop)\n                    ) {\n                      event.preventDefault()\n\n                      // Keep a reference to the dragged range before updating selection\n                      const draggedRange = editor.selection\n\n                      // Find the range where the drop happened. It is resolved from\n                      // the drop coordinates, which can point outside of the editor\n                      // even though the event's target is inside it (e.g. when the\n                      // page scrolled during the drag), leaving no range to drop at.\n                      const range = ReactEditor.findEventRange(editor, event, {\n                        suppressThrow: true,\n                      })\n                      const data = event.dataTransfer\n\n                      if (!range && state.isDraggingInternally) {\n                        // The dragged content already sits in the editor, so without\n                        // a target it stays where it is.\n                        return\n                      }\n\n                      if (range) {\n                        Transforms.select(editor, range)\n\n                        if (state.isDraggingInternally && draggedRange) {\n                          if (Range.includes(draggedRange, range.anchor)) {\n                            return\n                          }\n\n                          if (\n                            !Editor.void(editor, { at: range, voids: true })\n                          ) {\n                            const dropRef = Editor.rangeRef(editor, range)\n                            deleteMovedRange(editor, draggedRange)\n                            const dropRange = dropRef.unref()\n\n                            if (dropRange) {\n                              Transforms.select(editor, dropRange)\n                            }\n                          }\n                        }\n                      } else if (\n                        !editor.selection &&\n                        editor.children.length > 0\n                      ) {\n                        // Without a drop position the data goes to the current\n                        // selection, or to the end of the document if there is none.\n                        Transforms.select(editor, Editor.end(editor, []))\n                      }\n\n                      ReactEditor.insertData(editor, data)\n\n                      // When dragging from another source into the editor, it's possible\n                      // that the current editor does not have focus.\n                      if (!ReactEditor.isFocused(editor)) {\n                        ReactEditor.focus(editor)\n                      }\n                    }\n                  },\n                  [readOnly, editor, attributes.onDrop, state]\n                )}\n                onDragEnd={useCallback(\n                  (event: React.DragEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onDragEnd)\n                      return\n                    }\n\n                    if (\n                      state.isDraggingInternally &&\n                      attributes.onDragEnd &&\n                      ReactEditor.hasTarget(editor, event.target)\n                    ) {\n                      attributes.onDragEnd(event)\n                    }\n                  },\n                  [readOnly, state, attributes, editor]\n                )}\n                onFocus={useCallback(\n                  (event: React.FocusEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onFocus)\n                      return\n                    }\n\n                    if (\n                      !state.isUpdatingSelection &&\n                      ReactEditor.hasEditableTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onFocus)\n                    ) {\n                      const el = ReactEditor.toDOMNode(editor, editor)\n                      const root = ReactEditor.findDocumentOrShadowRoot(editor)\n                      state.latestElement = root.activeElement\n\n                      // COMPAT: If the editor has nested editable elements, the focus\n                      // can go to them. In Firefox, this must be prevented because it\n                      // results in issues with keyboard navigation. (2017/03/30)\n                      if (IS_FIREFOX && event.target !== el) {\n                        el.focus()\n                        return\n                      }\n\n                      IS_FOCUSED.set(editor, true)\n\n                      if (state.isTabbing && event.target === el) {\n                        const domSelection = getSelection(root)\n                        if (domSelection && editor.selection) {\n                          state.pendingSelection = null\n                          restoreDomSelection(editor, domSelection, state)\n                        }\n                        state.isTabbing = false\n                      }\n                    }\n                  },\n                  [readOnly, state, editor, attributes.onFocus]\n                )}\n                onKeyDown={useCallback(\n                  (event: React.KeyboardEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onKeyDown)\n                      return\n                    }\n\n                    if (ReactEditor.hasEditableTarget(editor, event.target)) {\n                      androidInputManagerRef.current?.handleKeyDown(event)\n\n                      const { nativeEvent } = event\n\n                      // COMPAT: The composition end event isn't fired reliably in all browsers,\n                      // so we sometimes might end up stuck in a composition state even though we\n                      // aren't composing any more.\n                      if (\n                        ReactEditor.isComposing(editor) &&\n                        (nativeEvent.isComposing === false ||\n                          isDeletingInVoid(editor, nativeEvent))\n                      ) {\n                        setComposing(false)\n                      }\n\n                      if (\n                        isEventHandled(event, attributes.onKeyDown) ||\n                        ReactEditor.isComposing(editor)\n                      ) {\n                        return\n                      }\n\n                      pendingNavigationScroll.current = [\n                        'ArrowUp',\n                        'ArrowDown',\n                        'ArrowLeft',\n                        'ArrowRight',\n                        'Home',\n                        'End',\n                        'PageUp',\n                        'PageDown',\n                      ].includes(nativeEvent.key)\n\n                      const { selection } = editor\n                      const element =\n                        editor.children[\n                          selection !== null ? selection.focus.path[0] : 0\n                        ]\n                      const isRTL = getDirection(Node.string(element)) === 'rtl'\n\n                      // COMPAT: Since we prevent the default behavior on\n                      // `beforeinput` events, the browser doesn't think there's ever\n                      // any history stack to undo or redo, so we have to manage these\n                      // hotkeys ourselves. (2019/11/06)\n                      if (Hotkeys.isRedo(nativeEvent)) {\n                        event.preventDefault()\n                        const maybeHistoryEditor: any = editor\n\n                        if (typeof maybeHistoryEditor.redo === 'function') {\n                          maybeHistoryEditor.redo()\n                        }\n\n                        return\n                      }\n\n                      if (Hotkeys.isUndo(nativeEvent)) {\n                        event.preventDefault()\n                        const maybeHistoryEditor: any = editor\n\n                        if (typeof maybeHistoryEditor.undo === 'function') {\n                          maybeHistoryEditor.undo()\n                        }\n\n                        return\n                      }\n\n                      if (\n                        (IS_CHROME || IS_WEBKIT) &&\n                        nativeEvent.key === 'ArrowUp' &&\n                        !nativeEvent.altKey &&\n                        !nativeEvent.ctrlKey &&\n                        !nativeEvent.metaKey &&\n                        selection &&\n                        (nativeEvent.shiftKey || Range.isCollapsed(selection))\n                      ) {\n                        const above = getPointAboveTrailingNewline(\n                          editor,\n                          selection.focus\n                        )\n\n                        if (above) {\n                          event.preventDefault()\n                          Transforms.select(\n                            editor,\n                            nativeEvent.shiftKey\n                              ? { anchor: selection.anchor, focus: above }\n                              : above\n                          )\n                          return\n                        }\n                      }\n\n                      // COMPAT: Certain browsers don't handle the selection updates\n                      // properly. In Chrome, the selection isn't properly extended.\n                      // And in Firefox, the selection isn't properly collapsed.\n                      // (2017/10/17)\n                      if (Hotkeys.isMoveLineBackward(nativeEvent)) {\n                        event.preventDefault()\n                        Transforms.move(editor, { unit: 'line', reverse: true })\n                        return\n                      }\n\n                      if (Hotkeys.isMoveLineForward(nativeEvent)) {\n                        event.preventDefault()\n                        Transforms.move(editor, { unit: 'line' })\n                        return\n                      }\n\n                      if (Hotkeys.isExtendLineBackward(nativeEvent)) {\n                        event.preventDefault()\n                        Transforms.move(editor, {\n                          unit: 'line',\n                          edge: 'focus',\n                          reverse: true,\n                        })\n                        return\n                      }\n\n                      if (Hotkeys.isExtendLineForward(nativeEvent)) {\n                        event.preventDefault()\n                        Transforms.move(editor, { unit: 'line', edge: 'focus' })\n                        return\n                      }\n\n                      // COMPAT: If a void node is selected, or a zero-width text node\n                      // adjacent to an inline is selected, we need to handle these\n                      // hotkeys manually because browsers won't be able to skip over\n                      // the void node with the zero-width space not being an empty\n                      // string.\n                      if (Hotkeys.isMoveBackward(nativeEvent)) {\n                        event.preventDefault()\n\n                        if (selection && Range.isCollapsed(selection)) {\n                          Transforms.move(editor, {\n                            reverse: !isRTL,\n                            unit: getCharacterMoveUnit(\n                              editor,\n                              selection.focus,\n                              !isRTL\n                            ),\n                          })\n                        } else {\n                          Transforms.collapse(editor, {\n                            edge: isRTL ? 'end' : 'start',\n                          })\n                        }\n\n                        return\n                      }\n\n                      if (Hotkeys.isMoveForward(nativeEvent)) {\n                        event.preventDefault()\n\n                        if (selection && Range.isCollapsed(selection)) {\n                          Transforms.move(editor, {\n                            reverse: isRTL,\n                            unit: getCharacterMoveUnit(\n                              editor,\n                              selection.focus,\n                              isRTL\n                            ),\n                          })\n                        } else {\n                          Transforms.collapse(editor, {\n                            edge: isRTL ? 'start' : 'end',\n                          })\n                        }\n\n                        return\n                      }\n\n                      const wordBackward =\n                        Hotkeys.isMoveWordBackward(nativeEvent)\n                      if (\n                        wordBackward ||\n                        Hotkeys.isMoveWordForward(nativeEvent)\n                      ) {\n                        event.preventDefault()\n                        const root =\n                          ReactEditor.findDocumentOrShadowRoot(editor)\n                        const domSelection = getSelection(root)\n                        if (domSelection?.modify) {\n                          domSelection.modify(\n                            'move',\n                            wordBackward ? 'left' : 'right',\n                            'word'\n                          )\n                          const range = ReactEditor.toSlateRange(\n                            editor,\n                            domSelection,\n                            {\n                              exactMatch: false,\n                              suppressThrow: true,\n                            }\n                          )\n                          if (range) {\n                            Transforms.select(editor, range)\n                            return\n                          }\n                        }\n                        if (selection && Range.isExpanded(selection)) {\n                          Transforms.collapse(editor, { edge: 'focus' })\n                        }\n                        Transforms.move(editor, {\n                          unit: 'word',\n                          reverse: wordBackward ? !isRTL : isRTL,\n                        })\n                        return\n                      }\n\n                      // COMPAT: Certain browsers don't support the `beforeinput` event, so we\n                      // fall back to guessing at the input intention for hotkeys.\n                      // COMPAT: In iOS, some of these hotkeys are handled in the\n                      if (!HAS_BEFORE_INPUT_SUPPORT) {\n                        // We don't have a core behavior for these, but they change the\n                        // DOM if we don't prevent them, so we have to.\n                        if (\n                          Hotkeys.isBold(nativeEvent) ||\n                          Hotkeys.isItalic(nativeEvent) ||\n                          Hotkeys.isTransposeCharacter(nativeEvent)\n                        ) {\n                          event.preventDefault()\n                          return\n                        }\n\n                        if (Hotkeys.isSoftBreak(nativeEvent)) {\n                          event.preventDefault()\n                          Editor.insertSoftBreak(editor)\n                          return\n                        }\n\n                        if (Hotkeys.isSplitBlock(nativeEvent)) {\n                          event.preventDefault()\n                          Editor.insertBreak(editor)\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteBackward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'backward',\n                            })\n                          } else {\n                            Editor.deleteBackward(editor)\n                          }\n\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteForward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'forward',\n                            })\n                          } else {\n                            Editor.deleteForward(editor)\n                          }\n\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteLineBackward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'backward',\n                            })\n                          } else {\n                            Editor.deleteBackward(editor, { unit: 'line' })\n                          }\n\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteLineForward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'forward',\n                            })\n                          } else {\n                            Editor.deleteForward(editor, { unit: 'line' })\n                          }\n\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteWordBackward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'backward',\n                            })\n                          } else {\n                            Editor.deleteBackward(editor, { unit: 'word' })\n                          }\n\n                          return\n                        }\n\n                        if (Hotkeys.isDeleteWordForward(nativeEvent)) {\n                          event.preventDefault()\n\n                          if (selection && Range.isExpanded(selection)) {\n                            Editor.deleteFragment(editor, {\n                              direction: 'forward',\n                            })\n                          } else {\n                            Editor.deleteForward(editor, { unit: 'word' })\n                          }\n\n                          return\n                        }\n                      } else {\n                        if (IS_CHROME || IS_WEBKIT) {\n                          // COMPAT: Chrome and Safari support `beforeinput` event but do not fire\n                          // an event when deleting backwards in a selected void inline node\n                          if (\n                            selection &&\n                            (Hotkeys.isDeleteBackward(nativeEvent) ||\n                              Hotkeys.isDeleteForward(nativeEvent)) &&\n                            Range.isCollapsed(selection)\n                          ) {\n                            const currentNode = Node.parent(\n                              editor,\n                              selection.anchor.path\n                            )\n\n                            if (\n                              Node.isElement(currentNode) &&\n                              Editor.isVoid(editor, currentNode) &&\n                              (Editor.isInline(editor, currentNode) ||\n                                Editor.isBlock(editor, currentNode))\n                            ) {\n                              event.preventDefault()\n\n                              if (Hotkeys.isDeleteForward(nativeEvent)) {\n                                Editor.deleteForward(editor, { unit: 'block' })\n                              } else {\n                                Editor.deleteBackward(editor, { unit: 'block' })\n                              }\n\n                              return\n                            }\n                          }\n                        }\n\n                        if (\n                          IS_WEBKIT &&\n                          selection &&\n                          Range.isCollapsed(selection)\n                        ) {\n                          if (\n                            Hotkeys.isDeleteBackward(nativeEvent) &&\n                            Editor.isStart(editor, selection.anchor, [])\n                          ) {\n                            event.preventDefault()\n                            Editor.deleteBackward(editor)\n                            return\n                          }\n\n                          if (\n                            Hotkeys.isDeleteForward(nativeEvent) &&\n                            Editor.isEnd(editor, selection.anchor, [])\n                          ) {\n                            event.preventDefault()\n                            Editor.deleteForward(editor)\n                            return\n                          }\n                        }\n                      }\n                    }\n                  },\n                  [readOnly, editor, attributes.onKeyDown, setComposing]\n                )}\n                onPaste={useCallback(\n                  (event: React.ClipboardEvent<HTMLDivElement>) => {\n                    if (readOnly) {\n                      isEventHandled(event, attributes.onPaste)\n                      return\n                    }\n\n                    if (\n                      ReactEditor.hasEditableTarget(editor, event.target) &&\n                      !isEventHandled(event, attributes.onPaste)\n                    ) {\n                      // COMPAT: Certain browsers don't support the `beforeinput` event, so we\n                      // fall back to React's `onPaste` here instead.\n                      // COMPAT: Firefox, Chrome and Safari don't emit `beforeinput` events\n                      // when \"paste without formatting\" is used, so fallback. (2020/02/20)\n                      // COMPAT: Safari InputEvents generated by pasting won't include\n                      // application/x-slate-fragment items, so use the\n                      // ClipboardEvent here. (2023/03/15)\n                      if (\n                        !HAS_BEFORE_INPUT_SUPPORT ||\n                        isPlainTextOnlyPaste(event.nativeEvent) ||\n                        IS_WEBKIT\n                      ) {\n                        event.preventDefault()\n                        ReactEditor.insertData(editor, event.clipboardData)\n                      }\n                    }\n                  },\n                  [readOnly, editor, attributes.onPaste]\n                )}\n              >\n                <Children\n                  decorations={decorations}\n                  node={editor}\n                  renderElement={renderElement}\n                  renderChunk={renderChunk}\n                  renderPlaceholder={renderPlaceholder}\n                  renderLeaf={renderLeaf}\n                  renderText={renderText}\n                />\n              </Component>\n            </RestoreDOM>\n          </DecorateContext.Provider>\n        </ComposingContext.Provider>\n      </ReadOnlyContext.Provider>\n    )\n  }\n)\n\n/**\n * The props that get passed to renderPlaceholder\n */\nexport type RenderPlaceholderProps = {\n  children: any\n  attributes: {\n    'data-slate-placeholder': boolean\n    'aria-hidden': boolean\n    dir?: 'rtl'\n    contentEditable: boolean\n    ref: React.RefCallback<any>\n    style: React.CSSProperties\n  }\n}\n\n/**\n * The default placeholder element\n */\n\nconst isDeletingInVoid = (editor: Editor, event: KeyboardEvent) => {\n  const { selection } = editor\n\n  return (\n    !!selection &&\n    Range.isCollapsed(selection) &&\n    (Hotkeys.isDeleteBackward(event) || Hotkeys.isDeleteForward(event)) &&\n    !!Editor.void(editor, { at: selection })\n  )\n}\n\nconst isInSlateText = (node: unknown) =>\n  isDOMNode(node) &&\n  node.nodeType === node.TEXT_NODE &&\n  !!node.parentElement?.closest('[data-slate-string], [data-slate-zero-width]')\n\nconst restoreDomSelection = (\n  editor: ReactEditor,\n  domSelection: Selection,\n  state: { isUpdatingSelection: boolean }\n) => {\n  if (!editor.selection) {\n    return\n  }\n\n  const domRange = ReactEditor.resolveDOMRange(editor, editor.selection)\n\n  if (!domRange) {\n    return\n  }\n\n  const backward = Range.isBackward(editor.selection)\n  state.isUpdatingSelection = true\n  domSelection.setBaseAndExtent(\n    backward ? domRange.endContainer : domRange.startContainer,\n    backward ? domRange.endOffset : domRange.startOffset,\n    backward ? domRange.startContainer : domRange.endContainer,\n    backward ? domRange.startOffset : domRange.endOffset\n  )\n  setTimeout(() => {\n    state.isUpdatingSelection = false\n  })\n}\n\nconst selectMovableRange = (editor: ReactEditor) => {\n  const { selection } = editor\n\n  if (selection && Range.isExpanded(selection)) {\n    const movableRange = getMovableRange(editor, selection)\n\n    if (!Range.equals(movableRange, selection)) {\n      Transforms.select(editor, movableRange)\n    }\n  }\n}\n\nexport const DefaultPlaceholder = ({\n  attributes,\n  children,\n}: RenderPlaceholderProps) => (\n  // COMPAT: Artificially add a line-break to the end on the placeholder element\n  // to prevent Android IMEs to pick up its content in autocorrect and to auto-capitalize the first letter\n  <span {...attributes}>\n    {children}\n    {IS_ANDROID && <br />}\n  </span>\n)\n\n/**\n * A default memoized decorate function.\n */\n\nexport const defaultDecorate: (entry: NodeEntry) => DecoratedRange[] = () => []\n\n/**\n * A default implement to scroll dom range into view.\n */\n\nexport const defaultScrollSelectionIntoView = (\n  editor: ReactEditor,\n  domRange: DOMRange\n) => {\n  // Scroll to the focus point of the selection, in case the selection is expanded\n  const { selection } = editor\n  const isBackward = !!selection && Range.isBackward(selection)\n  const unhung =\n    selection && !isBackward && Range.isExpanded(selection)\n      ? Editor.unhangRange(editor, selection)\n      : selection\n  const domFocusPoint =\n    unhung && selection && !Range.equals(unhung, selection)\n      ? ReactEditor.resolveDOMRange(editor, unhung) ?? domRange.cloneRange()\n      : domRange.cloneRange()\n  domFocusPoint.collapse(isBackward)\n\n  if (domFocusPoint.getBoundingClientRect) {\n    const leafEl = domFocusPoint.startContainer.parentElement!\n\n    // COMPAT: In Chrome, domFocusPoint.getBoundingClientRect() can return zero dimensions for valid ranges (e.g. line breaks).\n    // When this happens, do not scroll like most editors do.\n    const domRect = domFocusPoint.getBoundingClientRect()\n    const isZeroDimensionRect =\n      domRect.width === 0 &&\n      domRect.height === 0 &&\n      domRect.x === 0 &&\n      domRect.y === 0\n\n    if (isZeroDimensionRect) {\n      const leafRect = leafEl.getBoundingClientRect()\n      const leafHasDimensions = leafRect.width > 0 || leafRect.height > 0\n\n      if (leafHasDimensions) {\n        return\n      }\n    }\n\n    // Default behavior: use domFocusPoint's getBoundingClientRect\n    leafEl.getBoundingClientRect =\n      domFocusPoint.getBoundingClientRect.bind(domFocusPoint)\n    scrollIntoView(leafEl, {\n      scrollMode: 'if-needed',\n      block: 'nearest',\n      inline: 'nearest',\n    })\n\n    // @ts-expect-error an unorthodox delete D:\n    delete leafEl.getBoundingClientRect\n  }\n}\n\n/**\n * Check if an event is overrided by a handler.\n */\n\nexport const isEventHandled = <\n  EventType extends React.SyntheticEvent<unknown, unknown>,\n>(\n  event: EventType,\n  handler?: (event: EventType) => void | boolean\n) => {\n  if (!handler) {\n    return false\n  }\n  // The custom event handler may return a boolean to specify whether the event\n  // shall be treated as being handled or not.\n  const shouldTreatEventAsHandled = handler(event)\n\n  if (shouldTreatEventAsHandled != null) {\n    return shouldTreatEventAsHandled\n  }\n\n  return event.isDefaultPrevented() || event.isPropagationStopped()\n}\n\n/**\n * Check if the event's target is an input element\n */\nexport const isDOMEventTargetInput = <\n  EventType extends React.SyntheticEvent<unknown, unknown>,\n>(\n  event: EventType\n) => {\n  return (\n    isDOMNode(event.target) &&\n    (event.target instanceof HTMLInputElement ||\n      event.target instanceof HTMLTextAreaElement)\n  )\n}\n\n/**\n * Check if a DOM event is overrided by a handler.\n */\n\nexport const isDOMEventHandled = <E extends Event>(\n  event: E,\n  handler?: (event: E) => void | boolean\n) => {\n  if (!handler) {\n    return false\n  }\n\n  // The custom event handler may return a boolean to specify whether the event\n  // shall be treated as being handled or not.\n  const shouldTreatEventAsHandled = handler(event)\n\n  if (shouldTreatEventAsHandled != null) {\n    return shouldTreatEventAsHandled\n  }\n\n  return event.defaultPrevented\n}\n\nconst handleNativeHistoryEvents = (editor: Editor, event: InputEvent) => {\n  const maybeHistoryEditor: any = editor\n  if (\n    event.inputType === 'historyUndo' &&\n    typeof maybeHistoryEditor.undo === 'function'\n  ) {\n    maybeHistoryEditor.undo()\n    return\n  }\n  if (\n    event.inputType === 'historyRedo' &&\n    typeof maybeHistoryEditor.redo === 'function'\n  ) {\n    maybeHistoryEditor.redo()\n    return\n  }\n}\n","import { createContext, useContext } from 'react'\n\n/**\n * A React context for sharing the `focused` state of the editor.\n */\n\nexport const FocusedContext = createContext(false)\n\n/**\n * Get the current `focused` state of the editor.\n */\n\nexport const useFocused = (): boolean => {\n  return useContext(FocusedContext)\n}\n","import React from 'react'\n\nexport const REACT_MAJOR_VERSION = parseInt(React.version.split('.')[0], 10)\n","import React, { useCallback, useEffect, useRef, useState } from 'react'\nimport {\n  Descendant,\n  Editor,\n  Node,\n  Operation,\n  Scrubber,\n  Selection,\n  Transforms,\n} from 'slate'\nimport {\n  copyNodeInUse,\n  EDITOR_TO_ON_CHANGE,\n  EDITOR_TO_PENDING_ACTION,\n  EDITOR_TO_PENDING_DIFFS,\n} from 'slate-dom'\nimport { FocusedContext } from '../hooks/use-focused'\nimport { EDITOR_TO_COMPOSING } from '../hooks/use-composing'\nimport { useIsomorphicLayoutEffect } from '../hooks/use-isomorphic-layout-effect'\nimport {\n  useSelectorContext,\n  SlateSelectorContext,\n} from '../hooks/use-slate-selector'\nimport { EditorContext } from '../hooks/use-slate-static'\nimport { ReactEditor } from '../plugin/react-editor'\nimport { REACT_MAJOR_VERSION } from '../utils/environment'\n\n/**\n * A wrapper around the provider to handle `onChange` events, because the editor\n * is a mutable singleton so it won't ever register as \"changed\" otherwise.\n */\n\nexport const Slate = (props: {\n  editor: ReactEditor\n  initialValue?: Descendant[] | undefined\n  value?: Descendant[] | undefined\n  children: React.ReactNode\n  onChange?: ((value: Descendant[]) => void) | undefined\n  onSelectionChange?: ((selection: Selection) => void) | undefined\n  onValueChange?: ((value: Descendant[]) => void) | undefined\n}) => {\n  const {\n    editor,\n    children,\n    onChange,\n    onSelectionChange,\n    onValueChange,\n    initialValue,\n    value: controlledValue,\n    ...rest\n  } = props\n\n  const initializedEditor = useRef<ReactEditor | null>(null)\n  const lastEmittedValue = useRef<Descendant[] | undefined>(undefined)\n  const lastAppliedValue = useRef<Descendant[] | undefined>(undefined)\n  const appliedChildren = useRef<Descendant[] | undefined>(undefined)\n\n  if (controlledValue !== undefined && initialValue !== undefined) {\n    throw new Error('[Slate] value and initialValue cannot be used together.')\n  }\n  if (controlledValue !== undefined && !Node.isNodeList(controlledValue)) {\n    throw new Error(\n      `[Slate] value is invalid! Expected a list of elements but got: ${Scrubber.stringify(\n        controlledValue\n      )}`\n    )\n  }\n\n  if (initializedEditor.current !== editor) {\n    if (!Editor.isEditor(editor)) {\n      throw new Error(\n        `[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}`\n      )\n    }\n\n    if (\n      initialValue === undefined &&\n      controlledValue === undefined &&\n      editor.children.length === 0\n    ) {\n      throw new Error(\n        '[Slate] editor.children is empty and no initialValue was provided. If this is intentional, pass initialValue={[]} to the Slate component.'\n      )\n    }\n\n    const value = initialValue ?? controlledValue ?? editor.children\n\n    if (!Node.isNodeList(value)) {\n      throw new Error(\n        `[Slate] initialValue is invalid! Expected a list of elements but got: ${Scrubber.stringify(\n          value\n        )}`\n      )\n    }\n\n    const copied =\n      initialValue === undefined && controlledValue === undefined\n        ? value\n        : value.map(copyNodeInUse)\n    const children = copied.every((node, i) => node === value[i])\n      ? value\n      : copied\n\n    editor.children =\n      children.length > 0\n        ? children\n        : [{ children: [{ text: '' }] } as Descendant]\n    Object.assign(editor, rest)\n    initializedEditor.current = editor\n    lastEmittedValue.current = undefined\n    lastAppliedValue.current = controlledValue\n  }\n\n  const { selectorContext, onChange: handleSelectorChange } =\n    useSelectorContext()\n\n  const onContextChange = useCallback(() => {\n    const changed = editor.operations.some(op => op.type !== 'set_selection')\n    const external = changed && editor.children === appliedChildren.current\n    appliedChildren.current = undefined\n    if (changed && !external) {\n      lastEmittedValue.current = editor.children\n    }\n    if (onChange) {\n      onChange(editor.children)\n    }\n    if (\n      onSelectionChange &&\n      editor.operations.find(op => op.type === 'set_selection')\n    ) {\n      onSelectionChange(editor.selection)\n    }\n    if (onValueChange && changed && !external) {\n      onValueChange(editor.children)\n    }\n\n    handleSelectorChange()\n  }, [editor, handleSelectorChange, onChange, onSelectionChange, onValueChange])\n\n  const controlled = controlledValue !== undefined\n  const registerOnChange = useCallback(() => {\n    const callback = () => onContextChange()\n    EDITOR_TO_ON_CHANGE.set(editor, callback)\n    return () => {\n      if (EDITOR_TO_ON_CHANGE.get(editor) === callback) {\n        EDITOR_TO_ON_CHANGE.delete(editor)\n      }\n    }\n  }, [editor, onContextChange])\n\n  useEffect(() => {\n    if (!controlled) return registerOnChange()\n  }, [controlled, registerOnChange])\n\n  useIsomorphicLayoutEffect(() => {\n    if (controlled) return registerOnChange()\n  }, [controlled, registerOnChange])\n\n  useIsomorphicLayoutEffect(() => {\n    let frame: number | undefined\n    const apply = () => {\n      if (controlledValue === undefined) return\n      if (controlledValue === lastEmittedValue.current) {\n        lastAppliedValue.current = controlledValue\n        return\n      }\n      if (controlledValue === lastAppliedValue.current) return\n      if (\n        ReactEditor.isComposing(editor) ||\n        EDITOR_TO_COMPOSING.get(editor) ||\n        EDITOR_TO_PENDING_ACTION.get(editor) ||\n        EDITOR_TO_PENDING_DIFFS.get(editor)?.length\n      ) {\n        frame = window.requestAnimationFrame(apply)\n        return\n      }\n      const previous = editor.children\n      lastAppliedValue.current = controlledValue\n      Transforms.setChildren(editor, controlledValue)\n      if (previous !== editor.children) {\n        appliedChildren.current = editor.children\n        handleSelectorChange()\n      }\n    }\n    apply()\n    return () => {\n      if (frame !== undefined) window.cancelAnimationFrame(frame)\n    }\n  }, [editor, controlledValue, handleSelectorChange])\n\n  const [isFocused, setIsFocused] = useState(ReactEditor.isFocused(editor))\n\n  useEffect(() => {\n    setIsFocused(ReactEditor.isFocused(editor))\n  }, [editor])\n\n  useIsomorphicLayoutEffect(() => {\n    const fn = () => setIsFocused(ReactEditor.isFocused(editor))\n    if (REACT_MAJOR_VERSION >= 17) {\n      // In React >= 17 onFocus and onBlur listen to the focusin and focusout events during the bubbling phase.\n      // Therefore in order for <Editable />'s handlers to run first, which is necessary for ReactEditor.isFocused(editor)\n      // to return the correct value, we have to listen to the focusin and focusout events without useCapture here.\n      document.addEventListener('focusin', fn)\n      document.addEventListener('focusout', fn)\n      return () => {\n        document.removeEventListener('focusin', fn)\n        document.removeEventListener('focusout', fn)\n      }\n    } else {\n      document.addEventListener('focus', fn, true)\n      document.addEventListener('blur', fn, true)\n      return () => {\n        document.removeEventListener('focus', fn, true)\n        document.removeEventListener('blur', fn, true)\n      }\n    }\n  }, [editor])\n\n  return (\n    <SlateSelectorContext.Provider value={selectorContext}>\n      <EditorContext.Provider value={editor}>\n        <FocusedContext.Provider value={isFocused}>\n          {children}\n        </FocusedContext.Provider>\n      </EditorContext.Provider>\n    </SlateSelectorContext.Provider>\n  )\n}\n","import { useContext } from 'react'\n\nimport { EditorContext } from './use-slate-static'\n\n/**\n * Get the current editor object from the React context.\n * @deprecated Use useSlateStatic instead.\n */\n\nexport const useEditor = () => {\n  const editor = useContext(EditorContext)\n\n  if (!editor) {\n    throw new Error(\n      `The \\`useEditor\\` hook must be used inside the <Slate> component's context.`\n    )\n  }\n\n  return editor\n}\n","import { useCallback } from 'react'\nimport { Editor, Range } from 'slate'\nimport { useElementIf } from './use-element'\nimport { useSlateSelector } from './use-slate-selector'\nimport { ReactEditor } from '../plugin/react-editor'\n\n/**\n * Get the current `selected` state of an element.\n *\n * Set `suppressThrow` to return `false` instead of throwing when the element\n * can no longer be found in the editor.\n */\n\nexport const useSelected = ({\n  suppressThrow = false,\n}: { suppressThrow?: boolean | undefined } = {}): boolean => {\n  const element = useElementIf()\n\n  // Breaking the rules of hooks is fine here since `!element` will remain true\n  // or false for the entire lifetime of the component this hook is called from.\n  // TODO: Decide if we want to throw an error instead when calling\n  // `useSelected` outside of an element (potentially a breaking change).\n  if (!element) return false\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  const selector = useCallback(\n    (editor: Editor) => {\n      if (!editor.selection) return false\n\n      try {\n        const path = ReactEditor.findPath(editor, element)\n        const range = Editor.range(editor, path)\n        return !!Range.intersection(range, editor.selection)\n      } catch (e) {\n        if (suppressThrow) {\n          return false\n        }\n\n        throw e\n      }\n    },\n    [element, suppressThrow]\n  )\n\n  // eslint-disable-next-line react-hooks/rules-of-hooks\n  return useSlateSelector(selector, undefined, {\n    // Defer the selector until after `Editable` has rendered so that the path\n    // will be accurate.\n    deferred: true,\n  })\n}\n","import { BaseSelection, Range } from 'slate'\n\nimport { useSlateSelector } from './use-slate-selector'\n\n/**\n * Get the current slate selection.\n * Only triggers a rerender when the selection actually changes\n */\nexport const useSlateSelection = () => {\n  return useSlateSelector(editor => editor.selection, isSelectionEqual)\n}\n\nconst isSelectionEqual = (a: BaseSelection, b: BaseSelection) => {\n  if (!a && !b) return true\n  if (!a || !b) return false\n  return Range.equals(a, b)\n}\n","import ReactDOM from 'react-dom'\nimport { BaseEditor, Node, Operation } from 'slate'\nimport { withDOM, IS_ANDROID, EDITOR_TO_PENDING_SELECTION } from 'slate-dom'\nimport { ReactEditor } from './react-editor'\nimport { REACT_MAJOR_VERSION } from '../utils/environment'\nimport { getChunkTreeForNode } from '../chunking'\nimport { EDITOR_TO_FLUSH_DEFERRED_DIFFS } from '../hooks/android-input-manager/android-input-manager'\n\nconst RERENDERING_OPERATIONS = new Set<Operation['type']>([\n  'insert_node',\n  'move_node',\n  'remove_node',\n  'set_node',\n])\n\n/**\n * `withReact` adds React and DOM specific behaviors to the editor.\n *\n * If you are using TypeScript, you must extend Slate's CustomTypes to use\n * this plugin.\n *\n * See https://docs.slatejs.org/concepts/11-typescript to learn how.\n */\nexport const withReact = <T extends BaseEditor>(\n  editor: T,\n  clipboardFormatKey = 'x-slate-fragment'\n): T & ReactEditor => {\n  let e = editor as T & ReactEditor\n\n  e = withDOM(e, clipboardFormatKey)\n\n  const { onChange, apply, insertText } = e\n\n  e.getChunkSize = () => null\n\n  if (IS_ANDROID) {\n    e.insertText = (text, options) => {\n      // COMPAT: Android devices, specifically Samsung devices, experience cursor jumping.\n      // This issue occurs when the ⁠insertText function is called immediately after typing.\n      // The problem arises because typing schedules a selection change.\n      // However, this selection change is only executed after the ⁠insertText function.\n      // As a result, the already obsolete selection is applied, leading to incorrect\n      // final cursor position.\n      EDITOR_TO_PENDING_SELECTION.delete(e)\n\n      return insertText(text, options)\n    }\n  }\n\n  e.onChange = options => {\n    // COMPAT: React < 18 doesn't batch `setState` hook calls, which means\n    // that the children and selection can get out of sync for one render\n    // pass. So we have to use this unstable API to ensure it batches them.\n    // (2019/12/03)\n    // https://github.com/facebook/react/issues/14259#issuecomment-439702367\n    const maybeBatchUpdates =\n      REACT_MAJOR_VERSION < 18\n        ? ReactDOM.unstable_batchedUpdates\n        : (callback: () => void) => callback()\n\n    maybeBatchUpdates(() => {\n      onChange(options)\n    })\n  }\n\n  // On move_node, if the chunking optimization is enabled for the parent of the\n  // node being moved, add the moved node to the movedNodeKeys set of the\n  // parent's chunk tree.\n  e.apply = operation => {\n    if (IS_ANDROID && RERENDERING_OPERATIONS.has(operation.type)) {\n      EDITOR_TO_FLUSH_DEFERRED_DIFFS.get(e)?.()\n    }\n\n    if (operation.type === 'move_node') {\n      const parent = Node.parent(e, operation.path)\n      const chunking = !!e.getChunkSize(parent)\n\n      if (chunking) {\n        const node = Node.get(e, operation.path)\n        const chunkTree = getChunkTreeForNode(e, parent)\n        const key = ReactEditor.findKey(e, node)\n        chunkTree.movedNodeKeys.add(key)\n      }\n    }\n\n    apply(operation)\n  }\n\n  return e\n}\n"]}