slate-react 0.126.0 → 0.126.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/string.d.ts.map +1 -1
- package/dist/hooks/android-input-manager/android-input-manager.d.ts.map +1 -1
- package/dist/index.es.js +145 -14
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +139 -14
- package/dist/index.js.map +1 -1
- package/dist/slate-react.js +29673 -29548
- package/dist/slate-react.min.js +1 -1
- package/package.json +1 -1
package/dist/index.es.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.es.js","sources":["../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../src/hooks/use-slate-static.tsx","../src/plugin/react-editor.ts","../src/hooks/android-input-manager/android-input-manager.ts","../src/hooks/use-is-mounted.tsx","../src/hooks/use-isomorphic-layout-effect.ts","../src/hooks/use-mutation-observer.ts","../src/hooks/android-input-manager/use-android-input-manager.ts","../src/components/string.tsx","../src/components/leaf.tsx","../src/hooks/use-generic-selector.tsx","../src/hooks/use-decorations.ts","../src/components/text.tsx","../src/components/element.tsx","../src/chunking/chunk-tree-helper.ts","../src/chunking/children-helper.ts","../src/chunking/reconcile-children.ts","../src/chunking/get-chunk-tree-for-node.ts","../src/components/chunk-tree.tsx","../src/hooks/use-element.ts","../src/hooks/use-children.tsx","../src/hooks/use-read-only.ts","../src/hooks/use-slate-selector.tsx","../src/hooks/use-slate.tsx","../src/hooks/use-track-user-input.ts","../src/components/restore-dom/restore-dom-manager.ts","../src/components/restore-dom/restore-dom.tsx","../src/hooks/use-composing.ts","../src/components/editable.tsx","../src/hooks/use-focused.ts","../src/utils/environment.ts","../src/components/slate.tsx","../src/hooks/use-editor.tsx","../src/hooks/use-selected.ts","../src/hooks/use-slate-selection.tsx","../src/plugin/with-react.ts"],"sourcesContent":["export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n return target;\n}","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose.js\";\nexport default function _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n var target = objectWithoutPropertiesLoose(source, excluded);\n var key, i;\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n return target;\n}","export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _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 }, _typeof(o);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n key = toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","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'\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 { isDOMSelection, isTrackedMutation } 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// 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\nexport type CreateAndroidInputManagerOptions = {\n editor: ReactEditor\n\n scheduleOnDOMSelectionChange: DebouncedFunc<() => void>\n onDOMSelectionChange: DebouncedFunc<() => void>\n}\n\nexport type AndroidInputManager = {\n flush: () => 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 compositionEndTimeoutId: ReturnType<typeof setTimeout> | null = null\n let flushTimeoutId: ReturnType<typeof setTimeout> | null = null\n let actionTimeoutId: ReturnType<typeof setTimeout> | null = null\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 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 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 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) {\n editor.marks = userMarks\n editor.onChange()\n }\n }\n\n const handleCompositionEnd = (\n _event: React.CompositionEvent<HTMLDivElement>\n ) => {\n if (compositionEndTimeoutId) {\n clearTimeout(compositionEndTimeoutId)\n }\n\n compositionEndTimeoutId = setTimeout(() => {\n IS_COMPOSING.set(editor, false)\n flush()\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\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 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 if (IS_NODE_MAP_DIRTY.get(editor)) {\n return\n }\n\n const { inputType: type } = event\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 if (nativeTargetRange) {\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) {\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 return storeDiff(targetRange.anchor.path, {\n text: '',\n end: end.offset,\n start: start.offset,\n })\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 return storeDiff(anchor.path, {\n text: '',\n start: anchor.offset - 1,\n end: anchor.offset,\n })\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 // 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 (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(\n () => {\n Transforms.select(editor, {\n anchor: newPoint,\n focus: newPoint,\n })\n },\n { at: newPoint }\n )\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 actionTimeoutId = setTimeout(flush)\n }\n }\n\n const handleDomMutations = (mutations: MutationRecord[]) => {\n if (hasPendingDiffs() || hasPendingAction()) {\n return\n }\n\n if (\n mutations.some(mutation => isTrackedMutation(editor, mutation, mutations))\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\n return {\n flush,\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>,\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} from './android-input-manager'\nimport { useIsMounted } from '../use-is-mounted'\nimport { useMutationObserver } from '../use-mutation-observer'\n\ntype UseAndroidInputManagerOptions = {\n node: RefObject<HTMLElement>\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 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 } 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 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 ref.current.textContent = textWithTrailing\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 return (\n <span {...attributes}>\n {!IS_ANDROID || !isLineBreak ? '\\uFEFF' : null}\n {isLineBreak ? <br /> : null}\n </span>\n )\n}\n\nexport default String\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 { 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 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 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 next.parent === prev.parent &&\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","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>()\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 { DecoratedRange, Descendant, Node, NodeEntry } 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 return decorate([node, path])\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 { 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 next.parent === prev.parent &&\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 { 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 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 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 = 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 }}\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","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 }\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 { isTrackedMutation } from 'slate-dom'\n\nexport type RestoreDOMManager = {\n registerMutations: (mutations: MutationRecord[]) => void\n restoreDOM: () => void\n clear: () => void\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(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 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>\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'\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 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 { ReactEditor } from '../plugin/react-editor'\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 } from '../hooks/use-composing'\nimport { useFlushDeferredSelectorsOnRender } from '../hooks/use-slate-selector'\n\ntype DeferredOperation = () => void\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[]\n onDOMBeforeInput?: (event: InputEvent) => void\n placeholder?: string\n readOnly?: boolean\n role?: string\n style?: React.CSSProperties\n renderElement?: (props: RenderElementProps) => React.JSX.Element\n renderChunk?: (props: RenderChunkProps) => React.JSX.Element\n renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n renderText?: (props: RenderTextProps) => React.JSX.Element\n renderPlaceholder?: (props: RenderPlaceholderProps) => React.JSX.Element\n scrollSelectionIntoView?: (editor: ReactEditor, domRange: DOMRange) => void\n as?: React.ElementType\n disableDefaultStyles?: boolean\n} & React.TextareaHTMLAttributes<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 ref = useRef<HTMLDivElement | null>(null)\n const deferredOperations = useRef<DeferredOperation[]>([])\n const [placeholderHeight, setPlaceholderHeight] = useState<\n number | undefined\n >()\n const processing = 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 isDraggingInternally: false,\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 ref.current.focus()\n }\n }, [autoFocus])\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 >()\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 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\n if (anchorNodeSelectable && focusNodeInEditor) {\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 Transforms.select(editor, range)\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 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 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 (slateRange && Range.equals(slateRange, selection)) {\n if (!state.hasMarkPlaceholder) {\n return\n }\n\n // Ensure selection is inside the mark placeholder\n if (\n anchorNode?.parentElement?.hasAttribute(\n 'data-slate-mark-placeholder'\n )\n ) {\n return\n }\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.toSlateRange(editor, domSelection, {\n exactMatch: false,\n suppressThrow: true,\n })\n return\n }\n\n // Otherwise the DOM selection is out of sync, so update it.\n state.isUpdatingSelection = true\n\n let newDomRange: DOMRange | null = null\n\n try {\n newDomRange = selection && ReactEditor.toDOMRange(editor, selection)\n } catch (e) {\n // Ignore, dom and state might be out of sync\n }\n\n if (newDomRange) {\n if (ReactEditor.isComposing(editor) && !IS_ANDROID) {\n domSelection.collapseToEnd()\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 try {\n const el = ReactEditor.toDOMNode(editor, editor)\n el.focus()\n\n setDomSelection(forceChange)\n } catch (e) {\n // Ignore, dom and state might be out of sync\n }\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 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\n if (\n !readOnly &&\n ReactEditor.hasEditableTarget(editor, event.target) &&\n !isDOMEventHandled(event, propsOnDOMBeforeInput)\n ) {\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 scheduleOnDOMSelectionChange.flush()\n onDOMSelectionChange.flush()\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 return\n }\n\n let native = false\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 (editor.marks) {\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 [node, offset] = ReactEditor.toDOMPoint(editor, anchor)\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 }\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 as any).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 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 }\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 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 setIsComposing(false)\n IS_COMPOSING.set(editor, 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 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 onDOMSelectionChange,\n onUserInput,\n propsOnDOMBeforeInput,\n readOnly,\n scheduleOnDOMSelectionChange,\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 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 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 // 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('dragend', stoppedDragging)\n window.document.removeEventListener('drop', stoppedDragging)\n }\n }, [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 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.FormEvent<HTMLDivElement>) => {\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 !readOnly &&\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.FormEvent<HTMLDivElement>) => {\n if (isEventHandled(event, attributes.onInput)) {\n return\n }\n\n if (androidInputManagerRef.current) {\n androidInputManagerRef.current.handleInput()\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 // 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 [attributes.onInput, editor]\n )}\n onBlur={useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n readOnly ||\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 // 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.isUpdatingSelection,\n state.latestElement,\n editor,\n attributes.onBlur,\n ]\n )}\n onClick={useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\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 const path = ReactEditor.findPath(editor, node)\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 range = Editor.range(editor, blockPath)\n Transforms.select(editor, range)\n return\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\n if (\n startVoid &&\n endVoid &&\n Path.equals(startVoid[1], endVoid[1])\n ) {\n const range = Editor.range(editor, start)\n Transforms.select(editor, range)\n }\n }\n },\n [editor, attributes.onClick, readOnly]\n )}\n onCompositionEnd={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\n if (isDOMEventTargetInput(event)) {\n return\n }\n if (ReactEditor.hasSelectableTarget(editor, event.target)) {\n if (ReactEditor.isComposing(editor)) {\n Promise.resolve().then(() => {\n setIsComposing(false)\n IS_COMPOSING.set(editor, false)\n })\n }\n\n androidInputManagerRef.current?.handleCompositionEnd(\n event\n )\n\n if (\n isEventHandled(event, attributes.onCompositionEnd) ||\n IS_ANDROID\n ) {\n return\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 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 }\n },\n [attributes.onCompositionEnd, editor]\n )}\n onCompositionUpdate={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\n if (\n ReactEditor.hasSelectableTarget(editor, event.target) &&\n !isEventHandled(event, attributes.onCompositionUpdate) &&\n !isDOMEventTargetInput(event)\n ) {\n if (!ReactEditor.isComposing(editor)) {\n setIsComposing(true)\n IS_COMPOSING.set(editor, true)\n }\n }\n },\n [attributes.onCompositionUpdate, editor]\n )}\n onCompositionStart={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\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 setIsComposing(true)\n\n const { selection } = editor\n if (selection && Range.isExpanded(selection)) {\n Editor.deleteFragment(editor)\n return\n }\n }\n },\n [attributes.onCompositionStart, editor]\n )}\n onCopy={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\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]\n )}\n onCut={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\n ReactEditor.hasSelectableTarget(editor, event.target) &&\n !isEventHandled(event, attributes.onCut) &&\n !isDOMEventTargetInput(event)\n ) {\n event.preventDefault()\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 Editor.deleteFragment(editor)\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]\n )}\n onDragOver={useCallback(\n (event: React.DragEvent<HTMLDivElement>) => {\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 [attributes.onDragOver, editor]\n )}\n onDragStart={useCallback(\n (event: React.DragEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\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 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 (\n !readOnly &&\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\n const range = ReactEditor.findEventRange(editor, event)\n const data = event.dataTransfer\n\n Transforms.select(editor, range)\n\n if (state.isDraggingInternally) {\n if (\n draggedRange &&\n !Range.equals(draggedRange, range) &&\n !Editor.void(editor, { at: range, voids: true })\n ) {\n Transforms.delete(editor, {\n at: draggedRange,\n })\n }\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 (\n !readOnly &&\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 (\n !readOnly &&\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 },\n [readOnly, state, editor, attributes.onFocus]\n )}\n onKeyDown={useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\n ReactEditor.hasEditableTarget(editor, event.target)\n ) {\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 ) {\n IS_COMPOSING.set(editor, false)\n setIsComposing(false)\n }\n\n if (\n isEventHandled(event, attributes.onKeyDown) ||\n ReactEditor.isComposing(editor)\n ) {\n return\n }\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 // 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, { reverse: !isRTL })\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, { reverse: isRTL })\n } else {\n Transforms.collapse(editor, {\n edge: isRTL ? 'start' : 'end',\n })\n }\n\n return\n }\n\n if (Hotkeys.isMoveWordBackward(nativeEvent)) {\n event.preventDefault()\n\n if (selection && Range.isExpanded(selection)) {\n Transforms.collapse(editor, { edge: 'focus' })\n }\n\n Transforms.move(editor, {\n unit: 'word',\n reverse: !isRTL,\n })\n return\n }\n\n if (Hotkeys.isMoveWordForward(nativeEvent)) {\n event.preventDefault()\n\n if (selection && Range.isExpanded(selection)) {\n Transforms.collapse(editor, { edge: 'focus' })\n }\n\n Transforms.move(editor, {\n unit: 'word',\n reverse: 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 Editor.deleteBackward(editor, { unit: 'block' })\n\n return\n }\n }\n }\n }\n }\n },\n [readOnly, editor, attributes.onKeyDown]\n )}\n onPaste={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\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 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\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 isBackward = !!editor.selection && Range.isBackward(editor.selection)\n const domFocusPoint = 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 })\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, useState } from 'react'\nimport { Descendant, Editor, Node, Operation, Scrubber, Selection } from 'slate'\nimport { EDITOR_TO_ON_CHANGE } from 'slate-dom'\nimport { FocusedContext } from '../hooks/use-focused'\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[]\n children: React.ReactNode\n onChange?: (value: Descendant[]) => void\n onSelectionChange?: (selection: Selection) => void\n onValueChange?: (value: Descendant[]) => void\n}) => {\n const {\n editor,\n children,\n onChange,\n onSelectionChange,\n onValueChange,\n initialValue,\n ...rest\n } = props\n\n // Run once on first mount, but before `useEffect` or render\n React.useState(() => {\n if (!Node.isNodeList(initialValue)) {\n throw new Error(\n `[Slate] initialValue is invalid! Expected a list of elements but got: ${Scrubber.stringify(\n initialValue\n )}`\n )\n }\n\n if (!Editor.isEditor(editor)) {\n throw new Error(\n `[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}`\n )\n }\n\n editor.children = initialValue\n Object.assign(editor, rest)\n })\n\n const { selectorContext, onChange: handleSelectorChange } =\n useSelectorContext()\n\n const onContextChange = useCallback(() => {\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 (\n onValueChange &&\n editor.operations.find(op => op.type !== 'set_selection')\n ) {\n onValueChange(editor.children)\n }\n\n handleSelectorChange()\n }, [editor, handleSelectorChange, onChange, onSelectionChange, onValueChange])\n\n useEffect(() => {\n EDITOR_TO_ON_CHANGE.set(editor, onContextChange)\n\n return () => {\n EDITOR_TO_ON_CHANGE.set(editor, () => {})\n }\n }, [editor, onContextChange])\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 } = {}): 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 } 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'\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 (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"],"names":["objectWithoutPropertiesLoose","toPrimitive","toPropertyKey","EditorContext","createContext","useSlateStatic","editor","useContext","Error","ReactEditor","DOMEditor","RESOLVE_DELAY","FLUSH_DELAY","debug","isDataTransfer","value","constructor","name","createAndroidInputManager","_ref","scheduleOnDOMSelectionChange","onDOMSelectionChange","flushing","compositionEndTimeoutId","flushTimeoutId","actionTimeoutId","idCounter","insertPositionHint","applyPendingSelection","pendingSelection","EDITOR_TO_PENDING_SELECTION","get","delete","selection","normalized","normalizeRange","Range","equals","Transforms","select","performAction","action","EDITOR_TO_PENDING_ACTION","at","target","Location","isPoint","normalizePoint","targetRange","Editor","range","run","flush","clearTimeout","hasPendingDiffs","hasPendingAction","setTimeout","selectionRef","rangeRef","affinity","EDITOR_TO_USER_MARKS","set","marks","EDITOR_TO_PENDING_DIFFS","scheduleSelectionChange","diff","_EDITOR_TO_PENDING_DI","_EDITOR_TO_PENDING_DI2","pendingMarks","EDITOR_TO_PENDING_INSERTION_MARKS","undefined","text","insertText","deleteFragment","filter","_ref2","id","verifyDiffState","cancel","unref","userMarks","onChange","handleCompositionEnd","_event","IS_COMPOSING","handleCompositionStart","updatePlaceholderVisibility","forceHide","arguments","length","placeholderElement","EDITOR_TO_PLACEHOLDER_ELEMENT","style","display","removeProperty","storeDiff","path","_EDITOR_TO_PENDING_DI3","pendingDiffs","Node","leaf","idx","findIndex","change","Path","normalizeStringDiff","push","merged","mergeStringDiffs","splice","_objectSpread","scheduleAction","handleDOMBeforeInput","event","_targetRange2","IS_NODE_MAP_DIRTY","inputType","type","data","dataTransfer","nativeTargetRange","getTargetRanges","toSlateRange","exactMatch","suppressThrow","window","getWindow","domSelection","getSelection","canStoreDiff","startsWith","direction","endsWith","start","end","edges","isExpanded","offset","next","match","isText","anchor","focus","relevantPendingDiffs","find","diffs","applyStringDiff","point","handleUserSelect","isCollapsed","targetNode","deleteForward","_nativeTargetRange","nativeCollapsed","isDOMSelection","collapsed","deleteBackward","unit","insertSoftBreak","insertBreak","insertData","replace","test","slice","includes","parts","split","forEach","line","i","hintPosition","search","diffPosition","scheduleFlush","currentSelection","newPoint","_EDITOR_TO_PENDING_DI4","hasPendingChanges","isFlushing","pathChanged","parentPathChanged","handleInput","handleKeyDown","_","handleDomMutations","mutations","some","mutation","isTrackedMutation","_EDITOR_TO_FORCE_REND","EDITOR_TO_FORCE_RENDER","useIsMounted","isMountedRef","useRef","useEffect","current","useIsomorphicLayoutEffect","CAN_USE_DOM","useLayoutEffect","useMutationObserver","node","callback","options","mutationObserver","useState","MutationObserver","takeRecords","observe","disconnect","MUTATION_OBSERVER_CONFIG","subtree","childList","characterData","useAndroidInputManager","IS_ANDROID","_objectWithoutProperties","_excluded","isMounted","inputManager","EDITOR_TO_SCHEDULE_FLUSH","String","props","isLast","parent","findPath","parentPath","isMarkPlaceholder","Boolean","MARK_PLACEHOLDER_SYMBOL","isVoid","React","createElement","ZeroWidthString","string","children","isInline","isLineBreak","TextString","isTrailing","ref","getTextContent","concat","initialText","textWithTrailing","textContent","MemoizedText","memo","forwardRef","attributes","PLACEHOLDER_DELAY","disconnectPlaceholderResizeObserver","placeholderResizeObserver","releaseObserver","clearTimeoutRef","timeoutRef","defaultRenderLeaf","DefaultLeaf","Leaf","renderPlaceholder","renderLeaf","leafPosition","placeholderRef","showPlaceholder","setShowPlaceholder","showPlaceholderTimeoutRef","callbackPlaceholderRef","useCallback","placeholderEl","_leaf$onPlaceholderRe","onPlaceholderResize","call","ResizeObserver","ResizeObserverPolyfill","_leaf$onPlaceholderRe2","leafIsPlaceholder","PLACEHOLDER_SYMBOL","placeholderProps","placeholder","position","top","pointerEvents","width","maxWidth","opacity","userSelect","textDecoration","WebkitUserModify","IS_WEBKIT","contentEditable","Fragment","MemoizedLeaf","prev","Text","useGenericSelector","selector","equalityFn","forceRender","useReducer","s","latestSubscriptionCallbackError","latestSelector","latestSelectedState","selectedState","selectorResult","err","isError","message","stack","update","newSelectedState","error","DecorateContext","useDecorations","parentDecorations","decorate","addEventListener","isTextDecorationsEqual","isElementDecorationsEqual","decorations","unsubscribe","useMemo","useDecorateContext","decorateProp","forceUpdate","eventListeners","Set","hasMounted","latestDecorate","listener","entry","add","defaultRenderText","DefaultText","renderText","decoratedLeaves","SlateText","key","findKey","callbackRef","span","KEY_TO_ELEMENT","EDITOR_TO_KEY_TO_ELEMENT","NODE_TO_ELEMENT","ELEMENT_TO_NODE","defaultRenderElement","DefaultElement","Element","element","renderElement","renderChunk","readOnly","useReadOnly","useChildren","hasInlines","dir","getDirection","Tag","texts","height","color","outline","NODE_TO_INDEX","NODE_TO_PARENT","MemoizedElement","ChunkTreeHelper","chunkTree","chunkSize","_defineProperty","root","pointerChunk","pointerIndex","pointerIndexStack","reachedEnd","validateState","readLeaf","pointerSiblings","cachedPointerNode","exitChunk","enterChunkUntilLeaf","pointerNode","returnToPreviousLeaf","insertBefore","leaves","insertAfter","beforeDepth","afterDepth","remainingCapacity","toInsertCount","Math","min","leavesToInsert","rawInsertAfter","rawInsertPointer","savePointer","finalPointer","restorePointer","minDepth","max","remove","invalidateChunk","c","modifiedChunks","atStart","getPointerNode","getChunkPath","chunk","index","indexOf","unshift","savedPointer","indexStack","enterChunk","_this$pointerNode","_this$pointerNode2","previousPointerChunk","pop","groupIntoChunks","perChunk","chunks","chunkNodes","Key","newTotal","depthForTotal","depth","perTopLevelChunk","pow","validateDescendant","actualIndexStack","join","ChildrenHelper","cachedKeys","Array","read","n","slicedChildren","remaining","maxChildren","lookAhead","elementResult","candidateNode","candidateKey","toChunkLeaves","nodes","startIndex","map","cachedKey","reconcileChildren","rerenderChildren","onInsert","onUpdate","onIndexChange","chunkTreeHelper","childrenHelper","treeLeaf","_loop","wasMoved","movedNodeKeys","has","insertedChildrenStartIndex","insertedChildren","matchingChild","relativeIndex","matchingChildIndex","remainingChildren","clear","KEY_TO_CHUNK_TREE","WeakMap","getChunkTreeForNode","reconcile","defaultRenderChunk","ChunkAncestor","ancestor","chunkNode","renderedChunk","highest","lowest","MemoizedChunk","ChunkTree","ElementContext","useElement","context","useElementIf","isBlock","isElement","isLeafBlock","getChunkSize","chunking","decorationsByChild","childrenToRedecorate","useDecorationsByChild","renderElementComponent","Provider","ElementComponent","renderTextComponent","TextComponent","splitDecorationsByChild","mutableDecorationsByChild","_mutableDecorationsBy","previousDecorations","ReadOnlyContext","SlateSelectorContext","refEquality","a","b","useSlateSelector","deferred","genericSelector","useSelectorContext","deferredEventListeners","flushDeferred","callbackProp","selectorContext","useFlushDeferredSelectorsOnRender","useSlate","EDITOR_TO_V","getEditorVersionRef","v","useSlateWithV","vRef","useTrackUserInput","receivedUserInput","animationFrameIdRef","onUserInput","cancelAnimationFrame","requestAnimationFrame","createRestoreDomManager","bufferedMutations","registerMutations","trackedMutations","restoreDOM","reverse","removedNodes","nextSibling","addedNodes","removeChild","characterDataOldValue","RestoreDOMComponent","Component","_this$mutationObserve","componentDidMount","manager","getSnapshotBeforeUpdate","_this$mutationObserve2","_this$mutationObserve3","_this$manager2","pendingMutations","_this$manager","componentDidUpdate","_this$manager3","componentWillUnmount","_this$mutationObserve4","render","RestoreDOM","ComposingContext","useComposing","Children","Editable","forwardedRef","defaultRenderPlaceholder","DefaultPlaceholder","autoFocus","defaultDecorate","onDOMBeforeInput","propsOnDOMBeforeInput","scrollSelectionIntoView","defaultScrollSelectionIntoView","userStyle","as","disableDefaultStyles","isComposing","setIsComposing","deferredOperations","placeholderHeight","setPlaceholderHeight","processing","IS_READ_ONLY","state","isDraggingInternally","isUpdatingSelection","latestElement","hasMarkPlaceholder","androidInputManagerRef","throttle","el","toDOMNode","getRootNode","ShadowRoot","active","getActiveElement","document","execCommand","deselect","androidInputManager","findDocumentOrShadowRoot","activeElement","IS_FOCUSED","anchorNode","focusNode","anchorNodeSelectable","hasEditableTarget","isTargetInsideNonReadonlyVoid","focusNodeInEditor","hasTarget","debounce","_androidInputManagerR","_androidInputManagerR2","getDefaultView","EDITOR_TO_WINDOW","EDITOR_TO_ELEMENT","isFocused","setDomSelection","forceChange","hasDomSelection","IS_FIREFOX","rangeCount","firstRange","getRangeAt","lastRange","startContainer","endContainer","editorElement","hasDomSelectionInEditor","containsShadowAware","slateRange","_anchorNode","parentElement","hasAttribute","hasRange","newDomRange","toDOMRange","e","collapseToEnd","isBackward","setBaseAndExtent","endOffset","startOffset","removeAllRanges","ensureSelection","timeoutId","animationFrameId","ensureDomSelection","handleNativeHistoryEvents","ranges","newRange","setStart","setEnd","preventDefault","stopImmediatePropagation","isDOMEventHandled","_EDITOR_TO_USER_SELEC","isCompositionChange","native","_node$parentElement","_window$getComputedSt","toDOMPoint","closest","hasDOMNode","_lastText$textContent","lastText","createTreeWalker","NodeFilter","SHOW_TEXT","lastChild","getComputedStyle","whiteSpace","block","above","EDITOR_TO_USER_SELECTION","toRestore","HAS_BEFORE_INPUT_SUPPORT","removeEventListener","onSelectionChange","targetElement","HTMLElement","targetTagName","tagName","stoppedDragging","decorateContext","from","placeHolderResizeHandler","_placeholderEl$getBou","getBoundingClientRect","rest","_excluded2","loose","unset","Object","fromEntries","keys","mark","role","translate","spellCheck","autoCorrect","autoCapitalize","zindex","suppressContentEditableWarning","wordWrap","minHeight","onBeforeInput","isEventHandled","hasSelectableTarget","onInput","op","nativeEvent","onBlur","relatedTarget","isDOMElement","isDOMNode","toSlateNode","onClick","hasPath","detail","TRIPLE_CLICK","blockPath","_block$","startVoid","void","endVoid","onCompositionEnd","isDOMEventTargetInput","_androidInputManagerR3","Promise","resolve","then","IS_FIREFOX_LEGACY","IS_IOS","IS_WECHATBROWSER","IS_UC_MOBILE","placeholderMarks","onCompositionUpdate","onCompositionStart","_androidInputManagerR4","onCopy","setFragmentData","clipboardData","onCut","onDragOver","onDragStart","voidMatch","voids","onDrop","draggedRange","findEventRange","onDragEnd","onFocus","onKeyDown","_androidInputManagerR5","isRTL","Hotkeys","isRedo","maybeHistoryEditor","redo","isUndo","undo","isMoveLineBackward","move","isMoveLineForward","isExtendLineBackward","edge","isExtendLineForward","isMoveBackward","collapse","isMoveForward","isMoveWordBackward","isMoveWordForward","isBold","isItalic","isTransposeCharacter","isSoftBreak","isSplitBlock","isDeleteBackward","isDeleteForward","isDeleteLineBackward","isDeleteLineForward","isDeleteWordBackward","isDeleteWordForward","IS_CHROME","currentNode","onPaste","isPlainTextOnlyPaste","domRange","domFocusPoint","cloneRange","leafEl","domRect","isZeroDimensionRect","x","y","leafRect","leafHasDimensions","bind","scrollIntoView","scrollMode","handler","shouldTreatEventAsHandled","isDefaultPrevented","isPropagationStopped","HTMLInputElement","HTMLTextAreaElement","defaultPrevented","FocusedContext","useFocused","REACT_MAJOR_VERSION","parseInt","version","Slate","onValueChange","initialValue","isNodeList","Scrubber","stringify","isEditor","assign","handleSelectorChange","onContextChange","operations","EDITOR_TO_ON_CHANGE","setIsFocused","fn","useEditor","useSelected","intersection","useSlateSelection","isSelectionEqual","withReact","clipboardFormatKey","withDOM","apply","maybeBatchUpdates","ReactDOM","unstable_batchedUpdates","operation"],"mappings":";;;;;;;;;;;AAAe,SAAS,6BAA6B,CAAC,MAAM,EAAE,QAAQ,EAAE;AACxE,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE,OAAO,EAAE;AAC/B,EAAE,IAAI,MAAM,GAAG,EAAE;AACjB,EAAE,IAAI,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AACtC,EAAE,IAAI,GAAG,EAAE,CAAC;AACZ,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC1C,IAAI,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC;AACvB,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AACpC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;AAC7B,EAAE;AACF,EAAE,OAAO,MAAM;AACf;;ACVe,SAAS,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE;AACnE,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE,OAAO,EAAE;AAC/B,EAAE,IAAI,MAAM,GAAGA,6BAA4B,CAAC,MAAM,EAAE,QAA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C;AACF,EAAA;AAED4a,EAAAA,CAAC,CAACriB,QAAQ,GAAGyH,OAAO,IAAG;AACrB;AACA;AACA;AACA;AACA;AACA,IAAA,IAAMmnB,iBAAiB,GACrB1B,mBAAmB,GAAG,EAAE,GACpB2B,QAAQ,CAACC,uBAAuB,GAC/BtnB,QAAoB,IAAKA,QAAQ,EAAE;AAE1ConB,IAAAA,iBAAiB,CAAC,MAAK;MACrB5uB,QAAQ,CAACyH,OAAO,CAAC;AACnB,IAAA,CAAC,CAAC;EACJ,CAAC;AAED;AACA;AACA;AACA4a,EAAAA,CAAC,CAACsM,KAAK,GAAGI,SAAS,IAAG;AACpB,IAAA,IAAIA,SAAS,CAAC3sB,IAAI,KAAK,WAAW,EAAE;MAClC,IAAM0G,MAAM,GAAG5H,IAAI,CAAC4H,MAAM,CAACuZ,CAAC,EAAE0M,SAAS,CAAChuB,IAAI,CAAC;MAC7C,IAAMsY,QAAQ,GAAG,CAAC,CAACgJ,CAAC,CAACjJ,YAAY,CAACtQ,MAAM,CAAC;AAEzC,MAAA,IAAIuQ,QAAQ,EAAE;QACZ,IAAM9R,IAAI,GAAGrG,IAAI,CAACpE,GAAG,CAACulB,CAAC,EAAE0M,SAAS,CAAChuB,IAAI,CAAC;AACxC,QAAA,IAAM6Q,SAAS,GAAGsG,mBAAmB,CAACmK,CAAC,EAAEvZ,MAAM,CAAC;QAChD,IAAMiH,GAAG,GAAGvU,WAAW,CAACwU,OAAO,CAACqS,CAAC,EAAE9a,IAAI,CAAC;AACxCqK,QAAAA,SAAS,CAAC2F,aAAa,CAAC9H,GAAG,CAACM,GAAG,CAAC;AACjC,MAAA;AACF,IAAA;IAED4e,KAAK,CAACI,SAAS,CAAC;EAClB,CAAC;AAED,EAAA,OAAO1M,CAAC;AACV;;;;","x_google_ignoreList":[0,1,2,3,4,5]}
|
|
1
|
+
{"version":3,"file":"index.es.js","sources":["../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/typeof.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPrimitive.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js","../../../../../../.yarn/berry/cache/@babel-runtime-npm-7.23.2-d013d6cf7e-10.zip/node_modules/@babel/runtime/helpers/esm/defineProperty.js","../src/hooks/use-slate-static.tsx","../src/plugin/react-editor.ts","../src/hooks/android-input-manager/android-input-manager.ts","../src/hooks/use-is-mounted.tsx","../src/hooks/use-isomorphic-layout-effect.ts","../src/hooks/use-mutation-observer.ts","../src/hooks/android-input-manager/use-android-input-manager.ts","../src/components/string.tsx","../src/components/leaf.tsx","../src/hooks/use-generic-selector.tsx","../src/hooks/use-decorations.ts","../src/components/text.tsx","../src/components/element.tsx","../src/chunking/chunk-tree-helper.ts","../src/chunking/children-helper.ts","../src/chunking/reconcile-children.ts","../src/chunking/get-chunk-tree-for-node.ts","../src/components/chunk-tree.tsx","../src/hooks/use-element.ts","../src/hooks/use-children.tsx","../src/hooks/use-read-only.ts","../src/hooks/use-slate-selector.tsx","../src/hooks/use-slate.tsx","../src/hooks/use-track-user-input.ts","../src/components/restore-dom/restore-dom-manager.ts","../src/components/restore-dom/restore-dom.tsx","../src/hooks/use-composing.ts","../src/components/editable.tsx","../src/hooks/use-focused.ts","../src/utils/environment.ts","../src/components/slate.tsx","../src/hooks/use-editor.tsx","../src/hooks/use-selected.ts","../src/hooks/use-slate-selection.tsx","../src/plugin/with-react.ts"],"sourcesContent":["export default function _objectWithoutPropertiesLoose(source, excluded) {\n if (source == null) return {};\n var target = {};\n var sourceKeys = Object.keys(source);\n var key, i;\n for (i = 0; i < sourceKeys.length; i++) {\n key = sourceKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n target[key] = source[key];\n }\n return target;\n}","import objectWithoutPropertiesLoose from \"./objectWithoutPropertiesLoose.js\";\nexport default function _objectWithoutProperties(source, excluded) {\n if (source == null) return {};\n var target = objectWithoutPropertiesLoose(source, excluded);\n var key, i;\n if (Object.getOwnPropertySymbols) {\n var sourceSymbolKeys = Object.getOwnPropertySymbols(source);\n for (i = 0; i < sourceSymbolKeys.length; i++) {\n key = sourceSymbolKeys[i];\n if (excluded.indexOf(key) >= 0) continue;\n if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;\n target[key] = source[key];\n }\n }\n return target;\n}","export default function _typeof(o) {\n \"@babel/helpers - typeof\";\n\n return _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 }, _typeof(o);\n}","import _typeof from \"./typeof.js\";\nexport default function _toPrimitive(input, hint) {\n if (_typeof(input) !== \"object\" || input === null) return input;\n var prim = input[Symbol.toPrimitive];\n if (prim !== undefined) {\n var res = prim.call(input, hint || \"default\");\n if (_typeof(res) !== \"object\") return res;\n throw new TypeError(\"@@toPrimitive must return a primitive value.\");\n }\n return (hint === \"string\" ? String : Number)(input);\n}","import _typeof from \"./typeof.js\";\nimport toPrimitive from \"./toPrimitive.js\";\nexport default function _toPropertyKey(arg) {\n var key = toPrimitive(arg, \"string\");\n return _typeof(key) === \"symbol\" ? key : String(key);\n}","import toPropertyKey from \"./toPropertyKey.js\";\nexport default function _defineProperty(obj, key, value) {\n key = toPropertyKey(key);\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n return obj;\n}","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 { isDOMSelection, isTrackedMutation } 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\nexport type CreateAndroidInputManagerOptions = {\n editor: ReactEditor\n\n scheduleOnDOMSelectionChange: DebouncedFunc<() => void>\n onDOMSelectionChange: DebouncedFunc<() => void>\n}\n\nexport type AndroidInputManager = {\n flush: () => 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 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 compositionCleared = 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 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 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 (isCompositionLive() && hasPendingDiffsInEmptyLeaf()) {\n debug('deferring flush during composition in empty 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) {\n editor.marks = userMarks\n editor.onChange()\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 (hasPendingDiffsInEmptyLeaf() && !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 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 if (IS_NODE_MAP_DIRTY.get(editor)) {\n return\n }\n\n const { inputType: type } = event\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 if (nativeTargetRange) {\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) {\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 return storeDiff(targetRange.anchor.path, {\n text: '',\n end: end.offset,\n start: start.offset,\n })\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 return storeDiff(anchor.path, {\n text: '',\n start: anchor.offset - 1,\n end: anchor.offset,\n })\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 // 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 (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(\n () => {\n Transforms.select(editor, {\n anchor: newPoint,\n focus: newPoint,\n })\n },\n { at: newPoint }\n )\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 actionTimeoutId = setTimeout(flush)\n }\n }\n\n const handleDomMutations = (mutations: MutationRecord[]) => {\n if (hasPendingDiffs() || hasPendingAction()) {\n return\n }\n\n if (\n mutations.some(mutation => isTrackedMutation(editor, mutation, mutations))\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\n return {\n flush,\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>,\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} from './android-input-manager'\nimport { useIsMounted } from '../use-is-mounted'\nimport { useMutationObserver } from '../use-mutation-observer'\n\ntype UseAndroidInputManagerOptions = {\n node: RefObject<HTMLElement>\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 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 } 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 // 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 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 { 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 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 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 next.parent === prev.parent &&\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","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>()\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 { DecoratedRange, Descendant, Node, NodeEntry } 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 return decorate([node, path])\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 { 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 next.parent === prev.parent &&\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 { 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 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 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 = 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 }}\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","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 }\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 { isTrackedMutation } from 'slate-dom'\n\nexport type RestoreDOMManager = {\n registerMutations: (mutations: MutationRecord[]) => void\n restoreDOM: () => void\n clear: () => void\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(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 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>\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'\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 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 { ReactEditor } from '../plugin/react-editor'\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 } from '../hooks/use-composing'\nimport { useFlushDeferredSelectorsOnRender } from '../hooks/use-slate-selector'\n\ntype DeferredOperation = () => void\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[]\n onDOMBeforeInput?: (event: InputEvent) => void\n placeholder?: string\n readOnly?: boolean\n role?: string\n style?: React.CSSProperties\n renderElement?: (props: RenderElementProps) => React.JSX.Element\n renderChunk?: (props: RenderChunkProps) => React.JSX.Element\n renderLeaf?: (props: RenderLeafProps) => React.JSX.Element\n renderText?: (props: RenderTextProps) => React.JSX.Element\n renderPlaceholder?: (props: RenderPlaceholderProps) => React.JSX.Element\n scrollSelectionIntoView?: (editor: ReactEditor, domRange: DOMRange) => void\n as?: React.ElementType\n disableDefaultStyles?: boolean\n} & React.TextareaHTMLAttributes<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 ref = useRef<HTMLDivElement | null>(null)\n const deferredOperations = useRef<DeferredOperation[]>([])\n const [placeholderHeight, setPlaceholderHeight] = useState<\n number | undefined\n >()\n const processing = 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 isDraggingInternally: false,\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 ref.current.focus()\n }\n }, [autoFocus])\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 >()\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 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\n if (anchorNodeSelectable && focusNodeInEditor) {\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 Transforms.select(editor, range)\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 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 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 (slateRange && Range.equals(slateRange, selection)) {\n if (!state.hasMarkPlaceholder) {\n return\n }\n\n // Ensure selection is inside the mark placeholder\n if (\n anchorNode?.parentElement?.hasAttribute(\n 'data-slate-mark-placeholder'\n )\n ) {\n return\n }\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.toSlateRange(editor, domSelection, {\n exactMatch: false,\n suppressThrow: true,\n })\n return\n }\n\n // Otherwise the DOM selection is out of sync, so update it.\n state.isUpdatingSelection = true\n\n let newDomRange: DOMRange | null = null\n\n try {\n newDomRange = selection && ReactEditor.toDOMRange(editor, selection)\n } catch (e) {\n // Ignore, dom and state might be out of sync\n }\n\n if (newDomRange) {\n if (ReactEditor.isComposing(editor) && !IS_ANDROID) {\n domSelection.collapseToEnd()\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 try {\n const el = ReactEditor.toDOMNode(editor, editor)\n el.focus()\n\n setDomSelection(forceChange)\n } catch (e) {\n // Ignore, dom and state might be out of sync\n }\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 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\n if (\n !readOnly &&\n ReactEditor.hasEditableTarget(editor, event.target) &&\n !isDOMEventHandled(event, propsOnDOMBeforeInput)\n ) {\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 scheduleOnDOMSelectionChange.flush()\n onDOMSelectionChange.flush()\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 return\n }\n\n let native = false\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 (editor.marks) {\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 [node, offset] = ReactEditor.toDOMPoint(editor, anchor)\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 }\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 as any).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 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 }\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 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 setIsComposing(false)\n IS_COMPOSING.set(editor, 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 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 onDOMSelectionChange,\n onUserInput,\n propsOnDOMBeforeInput,\n readOnly,\n scheduleOnDOMSelectionChange,\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 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 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 // 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('dragend', stoppedDragging)\n window.document.removeEventListener('drop', stoppedDragging)\n }\n }, [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 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.FormEvent<HTMLDivElement>) => {\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 !readOnly &&\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.FormEvent<HTMLDivElement>) => {\n if (isEventHandled(event, attributes.onInput)) {\n return\n }\n\n if (androidInputManagerRef.current) {\n androidInputManagerRef.current.handleInput()\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 // 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 [attributes.onInput, editor]\n )}\n onBlur={useCallback(\n (event: React.FocusEvent<HTMLDivElement>) => {\n if (\n readOnly ||\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 // 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.isUpdatingSelection,\n state.latestElement,\n editor,\n attributes.onBlur,\n ]\n )}\n onClick={useCallback(\n (event: React.MouseEvent<HTMLDivElement>) => {\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 const path = ReactEditor.findPath(editor, node)\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 range = Editor.range(editor, blockPath)\n Transforms.select(editor, range)\n return\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\n if (\n startVoid &&\n endVoid &&\n Path.equals(startVoid[1], endVoid[1])\n ) {\n const range = Editor.range(editor, start)\n Transforms.select(editor, range)\n }\n }\n },\n [editor, attributes.onClick, readOnly]\n )}\n onCompositionEnd={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\n if (isDOMEventTargetInput(event)) {\n return\n }\n if (ReactEditor.hasSelectableTarget(editor, event.target)) {\n if (ReactEditor.isComposing(editor)) {\n Promise.resolve().then(() => {\n setIsComposing(false)\n IS_COMPOSING.set(editor, false)\n })\n }\n\n androidInputManagerRef.current?.handleCompositionEnd(\n event\n )\n\n if (\n isEventHandled(event, attributes.onCompositionEnd) ||\n IS_ANDROID\n ) {\n return\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 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 }\n },\n [attributes.onCompositionEnd, editor]\n )}\n onCompositionUpdate={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\n if (\n ReactEditor.hasSelectableTarget(editor, event.target) &&\n !isEventHandled(event, attributes.onCompositionUpdate) &&\n !isDOMEventTargetInput(event)\n ) {\n if (!ReactEditor.isComposing(editor)) {\n setIsComposing(true)\n IS_COMPOSING.set(editor, true)\n }\n }\n },\n [attributes.onCompositionUpdate, editor]\n )}\n onCompositionStart={useCallback(\n (event: React.CompositionEvent<HTMLDivElement>) => {\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 setIsComposing(true)\n\n const { selection } = editor\n if (selection && Range.isExpanded(selection)) {\n Editor.deleteFragment(editor)\n return\n }\n }\n },\n [attributes.onCompositionStart, editor]\n )}\n onCopy={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\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]\n )}\n onCut={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\n ReactEditor.hasSelectableTarget(editor, event.target) &&\n !isEventHandled(event, attributes.onCut) &&\n !isDOMEventTargetInput(event)\n ) {\n event.preventDefault()\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 Editor.deleteFragment(editor)\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]\n )}\n onDragOver={useCallback(\n (event: React.DragEvent<HTMLDivElement>) => {\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 [attributes.onDragOver, editor]\n )}\n onDragStart={useCallback(\n (event: React.DragEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\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 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 (\n !readOnly &&\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\n const range = ReactEditor.findEventRange(editor, event)\n const data = event.dataTransfer\n\n Transforms.select(editor, range)\n\n if (state.isDraggingInternally) {\n if (\n draggedRange &&\n !Range.equals(draggedRange, range) &&\n !Editor.void(editor, { at: range, voids: true })\n ) {\n Transforms.delete(editor, {\n at: draggedRange,\n })\n }\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 (\n !readOnly &&\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 (\n !readOnly &&\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 },\n [readOnly, state, editor, attributes.onFocus]\n )}\n onKeyDown={useCallback(\n (event: React.KeyboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\n ReactEditor.hasEditableTarget(editor, event.target)\n ) {\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 ) {\n IS_COMPOSING.set(editor, false)\n setIsComposing(false)\n }\n\n if (\n isEventHandled(event, attributes.onKeyDown) ||\n ReactEditor.isComposing(editor)\n ) {\n return\n }\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 // 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, { reverse: !isRTL })\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, { reverse: isRTL })\n } else {\n Transforms.collapse(editor, {\n edge: isRTL ? 'start' : 'end',\n })\n }\n\n return\n }\n\n if (Hotkeys.isMoveWordBackward(nativeEvent)) {\n event.preventDefault()\n\n if (selection && Range.isExpanded(selection)) {\n Transforms.collapse(editor, { edge: 'focus' })\n }\n\n Transforms.move(editor, {\n unit: 'word',\n reverse: !isRTL,\n })\n return\n }\n\n if (Hotkeys.isMoveWordForward(nativeEvent)) {\n event.preventDefault()\n\n if (selection && Range.isExpanded(selection)) {\n Transforms.collapse(editor, { edge: 'focus' })\n }\n\n Transforms.move(editor, {\n unit: 'word',\n reverse: 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 Editor.deleteBackward(editor, { unit: 'block' })\n\n return\n }\n }\n }\n }\n }\n },\n [readOnly, editor, attributes.onKeyDown]\n )}\n onPaste={useCallback(\n (event: React.ClipboardEvent<HTMLDivElement>) => {\n if (\n !readOnly &&\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 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\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 isBackward = !!editor.selection && Range.isBackward(editor.selection)\n const domFocusPoint = 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 })\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, useState } from 'react'\nimport { Descendant, Editor, Node, Operation, Scrubber, Selection } from 'slate'\nimport { EDITOR_TO_ON_CHANGE } from 'slate-dom'\nimport { FocusedContext } from '../hooks/use-focused'\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[]\n children: React.ReactNode\n onChange?: (value: Descendant[]) => void\n onSelectionChange?: (selection: Selection) => void\n onValueChange?: (value: Descendant[]) => void\n}) => {\n const {\n editor,\n children,\n onChange,\n onSelectionChange,\n onValueChange,\n initialValue,\n ...rest\n } = props\n\n // Run once on first mount, but before `useEffect` or render\n React.useState(() => {\n if (!Node.isNodeList(initialValue)) {\n throw new Error(\n `[Slate] initialValue is invalid! Expected a list of elements but got: ${Scrubber.stringify(\n initialValue\n )}`\n )\n }\n\n if (!Editor.isEditor(editor)) {\n throw new Error(\n `[Slate] editor is invalid! You passed: ${Scrubber.stringify(editor)}`\n )\n }\n\n editor.children = initialValue\n Object.assign(editor, rest)\n })\n\n const { selectorContext, onChange: handleSelectorChange } =\n useSelectorContext()\n\n const onContextChange = useCallback(() => {\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 (\n onValueChange &&\n editor.operations.find(op => op.type !== 'set_selection')\n ) {\n onValueChange(editor.children)\n }\n\n handleSelectorChange()\n }, [editor, handleSelectorChange, onChange, onSelectionChange, onValueChange])\n\n useEffect(() => {\n EDITOR_TO_ON_CHANGE.set(editor, onContextChange)\n\n return () => {\n EDITOR_TO_ON_CHANGE.set(editor, () => {})\n }\n }, [editor, onContextChange])\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 } = {}): 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 } 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'\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 (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"],"names":["objectWithoutPropertiesLoose","toPrimitive","toPropertyKey","EditorContext","createContext","useSlateStatic","editor","useContext","Error","ReactEditor","DOMEditor","RESOLVE_DELAY","FLUSH_DELAY","COMPOSITION_IDLE_TIMEOUT","COMPOSITION_RECHECK_DELAY","debug","isDataTransfer","value","constructor","name","createAndroidInputManager","_ref","scheduleOnDOMSelectionChange","onDOMSelectionChange","flushing","compositionEndTimeoutId","flushTimeoutId","actionTimeoutId","lastCompositionActivity","compositionCleared","idCounter","insertPositionHint","applyPendingSelection","pendingSelection","EDITOR_TO_PENDING_SELECTION","get","delete","selection","normalized","normalizeRange","Range","equals","Transforms","select","performAction","action","EDITOR_TO_PENDING_ACTION","at","target","Location","isPoint","normalizePoint","targetRange","Editor","range","run","isCompositionLive","IS_COMPOSING","editable","toDOMNode","activeElement","getWindow","document","contains","_unused","Date","now","hasPendingDiffsInEmptyLeaf","_EDITOR_TO_PENDING_DI","EDITOR_TO_PENDING_DIFFS","some","_ref2","path","Node","leaf","text","length","_unused2","flush","clearTimeout","setTimeout","hasPendingDiffs","hasPendingAction","selectionRef","rangeRef","affinity","EDITOR_TO_USER_MARKS","set","marks","scheduleSelectionChange","diff","_EDITOR_TO_PENDING_DI2","_EDITOR_TO_PENDING_DI3","pendingMarks","EDITOR_TO_PENDING_INSERTION_MARKS","undefined","insertText","deleteFragment","filter","_ref3","id","verifyDiffState","cancel","unref","userMarks","onChange","handleCompositionEnd","_event","ReactDOM","flushSync","updatePlaceholderVisibility","_EDITOR_TO_FORCE_REND","EDITOR_TO_FORCE_RENDER","handleCompositionStart","forceHide","arguments","placeholderElement","EDITOR_TO_PLACEHOLDER_ELEMENT","style","display","removeProperty","storeDiff","_EDITOR_TO_PENDING_DI4","pendingDiffs","idx","findIndex","change","Path","normalizeStringDiff","push","merged","mergeStringDiffs","splice","_objectSpread","scheduleAction","handleDOMBeforeInput","event","_targetRange2","IS_NODE_MAP_DIRTY","inputType","type","data","deferredDiffs","allInEmptyLeaves","every","_ref4","_unused3","dataTransfer","nativeTargetRange","getTargetRanges","toSlateRange","exactMatch","suppressThrow","window","domSelection","getSelection","canStoreDiff","startsWith","direction","endsWith","start","end","edges","isExpanded","offset","next","match","isText","anchor","focus","relevantPendingDiffs","find","diffs","applyStringDiff","point","handleUserSelect","isCollapsed","targetNode","deleteForward","_nativeTargetRange","nativeCollapsed","isDOMSelection","collapsed","deleteBackward","unit","insertSoftBreak","insertBreak","insertData","replace","test","slice","includes","parts","split","forEach","line","i","hintPosition","search","diffPosition","scheduleFlush","currentSelection","newPoint","_EDITOR_TO_PENDING_DI5","hasPendingChanges","isFlushing","pathChanged","parentPathChanged","handleInput","handleKeyDown","_","handleDomMutations","mutations","mutation","isTrackedMutation","_EDITOR_TO_FORCE_REND2","useIsMounted","isMountedRef","useRef","useEffect","current","useIsomorphicLayoutEffect","CAN_USE_DOM","useLayoutEffect","useMutationObserver","node","callback","options","mutationObserver","useState","MutationObserver","takeRecords","observe","disconnect","MUTATION_OBSERVER_CONFIG","subtree","childList","characterData","useAndroidInputManager","IS_ANDROID","_objectWithoutProperties","_excluded","isMounted","inputManager","EDITOR_TO_SCHEDULE_FLUSH","String","props","isLast","parent","findPath","parentPath","isMarkPlaceholder","Boolean","MARK_PLACEHOLDER_SYMBOL","isVoid","React","createElement","ZeroWidthString","string","children","isInline","isLineBreak","TextString","isTrailing","ref","getTextContent","concat","initialText","textWithTrailing","textContent","_ReactEditor$getWindo","composingNode","anchorNode","MemoizedText","memo","forwardRef","attributes","PLACEHOLDER_DELAY","disconnectPlaceholderResizeObserver","placeholderResizeObserver","releaseObserver","clearTimeoutRef","timeoutRef","defaultRenderLeaf","DefaultLeaf","Leaf","renderPlaceholder","renderLeaf","leafPosition","placeholderRef","showPlaceholder","setShowPlaceholder","showPlaceholderTimeoutRef","callbackPlaceholderRef","useCallback","placeholderEl","_leaf$onPlaceholderRe","onPlaceholderResize","call","ResizeObserver","ResizeObserverPolyfill","_leaf$onPlaceholderRe2","leafIsPlaceholder","PLACEHOLDER_SYMBOL","placeholderProps","placeholder","position","top","pointerEvents","width","maxWidth","opacity","userSelect","textDecoration","WebkitUserModify","IS_WEBKIT","contentEditable","Fragment","MemoizedLeaf","prev","Text","useGenericSelector","selector","equalityFn","forceRender","useReducer","s","latestSubscriptionCallbackError","latestSelector","latestSelectedState","selectedState","selectorResult","err","isError","message","stack","update","newSelectedState","error","DecorateContext","useDecorations","parentDecorations","decorate","addEventListener","isTextDecorationsEqual","isElementDecorationsEqual","decorations","unsubscribe","useMemo","useDecorateContext","decorateProp","forceUpdate","eventListeners","Set","hasMounted","latestDecorate","listener","entry","add","defaultRenderText","DefaultText","renderText","decoratedLeaves","SlateText","key","findKey","callbackRef","span","KEY_TO_ELEMENT","EDITOR_TO_KEY_TO_ELEMENT","NODE_TO_ELEMENT","ELEMENT_TO_NODE","defaultRenderElement","DefaultElement","Element","element","renderElement","renderChunk","readOnly","useReadOnly","useChildren","hasInlines","dir","getDirection","Tag","texts","height","color","outline","NODE_TO_INDEX","NODE_TO_PARENT","MemoizedElement","ChunkTreeHelper","chunkTree","chunkSize","_defineProperty","root","pointerChunk","pointerIndex","pointerIndexStack","reachedEnd","validateState","readLeaf","pointerSiblings","cachedPointerNode","exitChunk","enterChunkUntilLeaf","pointerNode","returnToPreviousLeaf","insertBefore","leaves","insertAfter","beforeDepth","afterDepth","remainingCapacity","toInsertCount","Math","min","leavesToInsert","rawInsertAfter","rawInsertPointer","savePointer","finalPointer","restorePointer","minDepth","max","remove","invalidateChunk","c","modifiedChunks","atStart","getPointerNode","getChunkPath","chunk","index","indexOf","unshift","savedPointer","indexStack","enterChunk","_this$pointerNode","_this$pointerNode2","previousPointerChunk","pop","groupIntoChunks","perChunk","chunks","chunkNodes","Key","newTotal","depthForTotal","depth","perTopLevelChunk","pow","validateDescendant","actualIndexStack","join","ChildrenHelper","cachedKeys","Array","read","n","slicedChildren","remaining","maxChildren","lookAhead","elementResult","candidateNode","candidateKey","toChunkLeaves","nodes","startIndex","map","cachedKey","reconcileChildren","rerenderChildren","onInsert","onUpdate","onIndexChange","chunkTreeHelper","childrenHelper","treeLeaf","_loop","wasMoved","movedNodeKeys","has","insertedChildrenStartIndex","insertedChildren","matchingChild","relativeIndex","matchingChildIndex","remainingChildren","clear","KEY_TO_CHUNK_TREE","WeakMap","getChunkTreeForNode","reconcile","defaultRenderChunk","ChunkAncestor","ancestor","chunkNode","renderedChunk","highest","lowest","MemoizedChunk","ChunkTree","ElementContext","useElement","context","useElementIf","isBlock","isElement","isLeafBlock","getChunkSize","chunking","decorationsByChild","childrenToRedecorate","useDecorationsByChild","renderElementComponent","Provider","ElementComponent","renderTextComponent","TextComponent","splitDecorationsByChild","mutableDecorationsByChild","_mutableDecorationsBy","previousDecorations","ReadOnlyContext","SlateSelectorContext","refEquality","a","b","useSlateSelector","deferred","genericSelector","useSelectorContext","deferredEventListeners","flushDeferred","callbackProp","selectorContext","useFlushDeferredSelectorsOnRender","useSlate","EDITOR_TO_V","getEditorVersionRef","v","useSlateWithV","vRef","useTrackUserInput","receivedUserInput","animationFrameIdRef","onUserInput","cancelAnimationFrame","requestAnimationFrame","createRestoreDomManager","bufferedMutations","registerMutations","trackedMutations","restoreDOM","reverse","removedNodes","nextSibling","addedNodes","removeChild","characterDataOldValue","RestoreDOMComponent","Component","_this$mutationObserve","componentDidMount","manager","getSnapshotBeforeUpdate","_this$mutationObserve2","_this$mutationObserve3","_this$manager2","pendingMutations","_this$manager","componentDidUpdate","_this$manager3","componentWillUnmount","_this$mutationObserve4","render","RestoreDOM","ComposingContext","useComposing","Children","Editable","forwardedRef","defaultRenderPlaceholder","DefaultPlaceholder","autoFocus","defaultDecorate","onDOMBeforeInput","propsOnDOMBeforeInput","scrollSelectionIntoView","defaultScrollSelectionIntoView","userStyle","as","disableDefaultStyles","isComposing","setIsComposing","deferredOperations","placeholderHeight","setPlaceholderHeight","processing","IS_READ_ONLY","state","isDraggingInternally","isUpdatingSelection","latestElement","hasMarkPlaceholder","androidInputManagerRef","throttle","el","getRootNode","ShadowRoot","active","getActiveElement","execCommand","deselect","androidInputManager","findDocumentOrShadowRoot","IS_FOCUSED","focusNode","anchorNodeSelectable","hasEditableTarget","isTargetInsideNonReadonlyVoid","focusNodeInEditor","hasTarget","debounce","_androidInputManagerR","_androidInputManagerR2","getDefaultView","EDITOR_TO_WINDOW","EDITOR_TO_ELEMENT","isFocused","setDomSelection","forceChange","hasDomSelection","IS_FIREFOX","rangeCount","firstRange","getRangeAt","lastRange","startContainer","endContainer","editorElement","hasDomSelectionInEditor","containsShadowAware","slateRange","_anchorNode","parentElement","hasAttribute","hasRange","newDomRange","toDOMRange","e","collapseToEnd","isBackward","setBaseAndExtent","endOffset","startOffset","removeAllRanges","ensureSelection","timeoutId","animationFrameId","ensureDomSelection","handleNativeHistoryEvents","ranges","newRange","setStart","setEnd","preventDefault","stopImmediatePropagation","isDOMEventHandled","_EDITOR_TO_USER_SELEC","isCompositionChange","native","_node$parentElement","_window$getComputedSt","toDOMPoint","closest","hasDOMNode","_lastText$textContent","lastText","createTreeWalker","NodeFilter","SHOW_TEXT","lastChild","getComputedStyle","whiteSpace","block","above","EDITOR_TO_USER_SELECTION","toRestore","HAS_BEFORE_INPUT_SUPPORT","removeEventListener","onSelectionChange","targetElement","HTMLElement","targetTagName","tagName","stoppedDragging","decorateContext","from","placeHolderResizeHandler","_placeholderEl$getBou","getBoundingClientRect","rest","_excluded2","loose","unset","Object","fromEntries","keys","mark","role","translate","spellCheck","autoCorrect","autoCapitalize","zindex","suppressContentEditableWarning","wordWrap","minHeight","onBeforeInput","isEventHandled","hasSelectableTarget","onInput","op","nativeEvent","onBlur","relatedTarget","isDOMElement","isDOMNode","toSlateNode","onClick","hasPath","detail","TRIPLE_CLICK","blockPath","_block$","startVoid","void","endVoid","onCompositionEnd","isDOMEventTargetInput","_androidInputManagerR3","Promise","resolve","then","IS_FIREFOX_LEGACY","IS_IOS","IS_WECHATBROWSER","IS_UC_MOBILE","placeholderMarks","onCompositionUpdate","onCompositionStart","_androidInputManagerR4","onCopy","setFragmentData","clipboardData","onCut","onDragOver","onDragStart","voidMatch","voids","onDrop","draggedRange","findEventRange","onDragEnd","onFocus","onKeyDown","_androidInputManagerR5","isRTL","Hotkeys","isRedo","maybeHistoryEditor","redo","isUndo","undo","isMoveLineBackward","move","isMoveLineForward","isExtendLineBackward","edge","isExtendLineForward","isMoveBackward","collapse","isMoveForward","isMoveWordBackward","isMoveWordForward","isBold","isItalic","isTransposeCharacter","isSoftBreak","isSplitBlock","isDeleteBackward","isDeleteForward","isDeleteLineBackward","isDeleteLineForward","isDeleteWordBackward","isDeleteWordForward","IS_CHROME","currentNode","onPaste","isPlainTextOnlyPaste","domRange","domFocusPoint","cloneRange","leafEl","domRect","isZeroDimensionRect","x","y","leafRect","leafHasDimensions","bind","scrollIntoView","scrollMode","handler","shouldTreatEventAsHandled","isDefaultPrevented","isPropagationStopped","HTMLInputElement","HTMLTextAreaElement","defaultPrevented","FocusedContext","useFocused","REACT_MAJOR_VERSION","parseInt","version","Slate","onValueChange","initialValue","isNodeList","Scrubber","stringify","isEditor","assign","handleSelectorChange","onContextChange","operations","EDITOR_TO_ON_CHANGE","setIsFocused","fn","useEditor","useSelected","intersection","useSlateSelection","isSelectionEqual","withReact","clipboardFormatKey","withDOM","apply","maybeBatchUpdates","unstable_batchedUpdates","operation"],"mappings":";;;;;;;;;;;AAAe,SAAS,6BAA6B,CAAC,MAAM,EAAE,QAAQ,EAAE;AACxE,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE,OAAO,EAAE;AAC/B,EAAE,IAAI,MAAM,GAAG,EAAE;AACjB,EAAE,IAAI,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;AACtC,EAAE,IAAI,GAAG,EAAE,CAAC;AACZ,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC1C,IAAI,GAAG,GAAG,UAAU,CAAC,CAAC,CAAC;AACvB,IAAI,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;AACpC,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;AAC7B,EAAE;AACF,EAAE,OAAO,MAAM;AACf;;ACVe,SAAS,wBAAwB,CAAC,MAAM,EAAE,QAAQ,EAAE;AACnE,EAAE,IAAI,MAAM,IAAI,IAAI,EAAE,OAAO,EAAE;AAC/B,EAAE,IAAI,MAAM,GAAGA,6BAA4B,CAAC,MAAM,EAAE,QAAQ,CAAC;AAC7D,EAAE,IAAI,GAAG,EAAE,CAAC;AACZ,EAAE,IAAI,MAAM,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