@payloadcms/richtext-lexical 4.0.0-beta.2 → 4.0.0-beta.4
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/exports/client/Field-334JNLRF.js +2 -0
- package/dist/exports/client/Field-334JNLRF.js.map +7 -0
- package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js → RelationshipComponent-TVK6I4W4.js} +2 -2
- package/dist/exports/client/chunk-BEKGION5.js +2 -0
- package/dist/exports/client/chunk-BEKGION5.js.map +7 -0
- package/dist/exports/client/{chunk-WSAPGI3Z.js → chunk-EA5BHQ2T.js} +1 -1
- package/dist/exports/client/{chunk-WSAPGI3Z.js.map → chunk-EA5BHQ2T.js.map} +1 -1
- package/dist/exports/client/chunk-FAJJXXCW.js +2 -0
- package/dist/exports/client/{chunk-3LRZDIIG.js.map → chunk-FAJJXXCW.js.map} +2 -2
- package/dist/exports/client/{chunk-5VIL27GI.js → chunk-IYBYNEKX.js} +1 -1
- package/dist/exports/client/{chunk-5VIL27GI.js.map → chunk-IYBYNEKX.js.map} +1 -1
- package/dist/exports/client/chunk-SE5IITBK.js +2 -0
- package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
- package/dist/exports/client/{component-6DQLENIE.js → component-QENB4QTS.js} +2 -2
- package/dist/exports/client/componentInline-AU7IBNY7.js +2 -0
- package/dist/exports/client/index.js +27 -27
- package/dist/exports/client/index.js.map +3 -3
- package/dist/features/align/client/index.js.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +38 -16
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockContainer.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockEditButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockLabel.js.map +1 -1
- package/dist/features/blocks/client/componentInline/components/InlineBlockRemoveButton.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +5 -11
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/getCachedFormStateIfDataMatches.js.map +1 -1
- package/dist/features/blocks/client/plugin/index.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +121 -78
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -1
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +142 -87
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.d.ts.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/types.js.map +1 -1
- package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
- package/dist/features/debug/testRecorder/client/plugin/index.js.map +1 -1
- package/dist/features/debug/treeView/client/plugin/index.js.map +1 -1
- package/dist/features/heading/client/index.js.map +1 -1
- package/dist/features/horizontalRule/client/plugin/index.js.map +1 -1
- package/dist/features/indent/client/index.d.ts.map +1 -1
- package/dist/features/indent/client/index.js +0 -2
- package/dist/features/indent/client/index.js.map +1 -1
- package/dist/features/indent/server/i18n.d.ts.map +1 -1
- package/dist/features/indent/server/i18n.js.map +1 -1
- package/dist/features/link/client/plugins/autoLink/index.js.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js +10 -2
- package/dist/features/link/client/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/features/link/client/plugins/link/index.js.map +1 -1
- package/dist/features/link/markdownTransformer.js +2 -2
- package/dist/features/link/markdownTransformer.js.map +1 -1
- package/dist/features/link/server/baseFields.js.map +1 -1
- package/dist/features/lists/shared/schema.d.ts.map +1 -1
- package/dist/features/lists/shared/schema.js.map +1 -1
- package/dist/features/relationship/client/drawer/index.js.map +1 -1
- package/dist/features/relationship/client/plugins/index.js.map +1 -1
- package/dist/features/relationship/client/utils/useEnabledRelationships.js.map +1 -1
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.css +1 -1
- package/dist/features/table/client/plugins/TableActionMenuPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js +6 -6
- package/dist/features/table/client/plugins/TableCellResizerPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TableHoverActionsPlugin/index.js.map +1 -1
- package/dist/features/table/client/plugins/TablePlugin/index.js +54 -18
- package/dist/features/table/client/plugins/TablePlugin/index.js.map +1 -1
- package/dist/features/table/client/utils/useDebounce.js.map +1 -1
- package/dist/features/textState/defaultColors.js +1 -1
- package/dist/features/textState/defaultColors.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.js.map +1 -1
- package/dist/features/toolbars/fixed/client/Toolbar/index.js +126 -70
- package/dist/features/toolbars/fixed/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/inline/client/Toolbar/index.js +67 -35
- package/dist/features/toolbars/inline/client/Toolbar/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarButton/index.js +26 -2
- package/dist/features/toolbars/shared/ToolbarButton/index.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js +137 -72
- package/dist/features/toolbars/shared/ToolbarDropdown/DropDown.js.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.d.ts.map +1 -1
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js +22 -6
- package/dist/features/toolbars/shared/ToolbarDropdown/index.js.map +1 -1
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js +100 -70
- package/dist/features/toolbars/shared/useToolbarKeyboardNavigation.js.map +1 -1
- package/dist/features/upload/client/drawer/index.js.map +1 -1
- package/dist/features/upload/client/plugin/index.js.map +1 -1
- package/dist/field/RenderLexical/index.js.map +1 -1
- package/dist/field/ViewSelector.js +12 -4
- package/dist/field/ViewSelector.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/dist/field/index.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +44 -0
- package/dist/i18n.js.map +1 -1
- package/dist/lexical/LexicalEditor.js.map +1 -1
- package/dist/lexical/plugins/ClipboardPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/DecoratorPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/InsertParagraphAtEnd/index.js.map +1 -1
- package/dist/lexical/plugins/MarkdownShortcut/index.js.map +1 -1
- package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +234 -87
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/useMenuTriggerMatch.js.map +1 -1
- package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/AddBlockHandlePlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.css +16 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js +126 -38
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/index.js.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts +7 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.d.ts.map +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js +15 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/moveBlock.js.map +1 -0
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.d.ts.map +1 -1
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js +9 -12
- package/dist/lexical/plugins/handles/DraggableBlockPlugin/useKeyboardReordering.js.map +1 -1
- package/dist/lexical/ui/ContentEditable.js.map +1 -1
- package/dist/lexical/utils/nodeFormat.d.ts.map +1 -1
- package/dist/lexical/utils/nodeFormat.js +0 -2
- package/dist/lexical/utils/nodeFormat.js.map +1 -1
- package/dist/lexical/utils/url.d.ts.map +1 -1
- package/dist/lexical/utils/url.js +1 -1
- package/dist/lexical/utils/url.js.map +1 -1
- package/dist/populateGraphQL/populate.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/buildEditorState.d.ts.map +1 -1
- package/dist/utilities/buildEditorState.js.map +1 -1
- package/dist/utilities/fieldsDrawer/Drawer.js +36 -36
- package/dist/utilities/fieldsDrawer/Drawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.d.ts.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +6 -9
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useDrawerSubmit.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDocumentDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalDrawer.js.map +1 -1
- package/dist/utilities/fieldsDrawer/useLexicalListDrawer.js.map +1 -1
- package/dist/utilities/initLexicalFeatures.d.ts.map +1 -1
- package/dist/utilities/initLexicalFeatures.js +38 -4
- package/dist/utilities/initLexicalFeatures.js.map +1 -1
- package/dist/utilities/useLexicalFeature.js +15 -6
- package/dist/utilities/useLexicalFeature.js.map +1 -1
- package/dist/utilities/useRunDeprioritized.js.map +1 -1
- package/package.json +32 -35
- package/dist/exports/client/Field-W2ABOM7M.js +0 -2
- package/dist/exports/client/Field-W2ABOM7M.js.map +0 -7
- package/dist/exports/client/chunk-3LRZDIIG.js +0 -2
- package/dist/exports/client/chunk-E6LSRRP2.js +0 -2
- package/dist/exports/client/chunk-E6LSRRP2.js.map +0 -7
- package/dist/exports/client/chunk-ZQX5HXUL.js +0 -2
- package/dist/exports/client/chunk-ZQX5HXUL.js.map +0 -7
- package/dist/exports/client/componentInline-HNE5G4TE.js +0 -2
- /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
- /package/dist/exports/client/{component-6DQLENIE.js.map → component-QENB4QTS.js.map} +0 -0
- /package/dist/exports/client/{componentInline-HNE5G4TE.js.map → componentInline-AU7IBNY7.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$onUpdate","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_","activeEditor","hasSelectedDecorator","Boolean","$getSelectedDecorator","read","decorator_0","document","querySelector","classList","remove","decorator","getElementByKey","getKey","add","_temp5","_temp7","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","element","$selectDecorator","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp6","nextBlock","findLaterSiblingBlock","nextBlockElement","node","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp4","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $onUpdate,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_, activeEditor) => {\n // Nested editors reconcile independently and update their own highlight.\n if (activeEditor !== editor) {\n return false\n }\n const hasSelectedDecorator = Boolean($getSelectedDecorator())\n $onUpdate(() => {\n activeEditor.read('latest', () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n activeEditor\n .getElementByKey(decorator.getKey())\n ?.classList.add('decorator-selected')\n }\n })\n })\n return hasSelectedDecorator\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node) ? node : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,mBAAmB,EAAEC,aAAa,QAAQ;AACnD,SACEC,oBAAoB,EACpBC,UAAU,EACVC,0BAA0B,EAC1BC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,EAChBC,iBAAiB,EACjBC,mBAAmB,EACnBC,WAAW,EACXC,SAAS,EACTC,aAAa,EACbC,aAAa,EACbC,oBAAoB,EACpBC,sBAAsB,EACtBC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,EAClBC,wBAAwB,QACnB;AACP,SAASC,SAAS,QAAQ;AAE1B,OAAO;AAEP;AACA;AACA,OAAO,SAAAC,gBAAA;EAAA,MAAAC,CAAA,GAAA1B,EAAA;EACL,OAAA2B,MAAA,IAAiB1B,yBAAA;EAEjB,MAAA2B,SAAA,GAAAC,MAAA;EAUA,IAAAC,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAL,CAAA,QAAAC,MAAA;IAEUG,EAAA,GAAAA,CAAA,KACD3B,aAAA,CACLwB,MAAA,CAAAK,eAAA,CAAAf,aAAA,EAAAgB,MAAA,EAAAf,oBAsBE,GAEFS,MAAA,CAAAK,eAAA,CAAAV,kBAAA,EAA2CM,SAAA,EAAAV,oBAAW,GACtDS,MAAA,CAAAK,eAAA,CAAAX,qBAAA,EAA8CO,SAAA,EAAAV,oBAAW,GACzDS,MAAA,CAAAK,eAAA,CAAAT,wBAAA,GAAAW,CAAA,EAAAC,YAAA;MAAA,IAIQA,YAAA,KAAiBR,MAAA;QAAA;MAAA;MAGrB,MAAAS,oBAAA,GAA6BC,OAAA,CAAQC,qBAAA;MACrCvB,SAAA;QACEoB,YAAA,CAAAI,IAAA,CAAkB;UAChB,MAAAC,WAAA,GAAkBF,qB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A,CAAkBkD,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQzD,cAAc;EAClC;EACA,OAAO;AACT;AAEA,SAASmC,sBAAsBd,IAAiB;EAC9C,IAAIoC,OAAA,GAAUpC,IAAA,CAAKK,kBAAkB;EACrC,OAAO+B,OAAA,KAAY,MAAM;IACvB,IAAIlD,iBAAA,CAAkBkD,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQ/B,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$findMatchingParent","mergeRegister","$createNodeSelection","$getEditor","$getNearestNodeFromDOMNode","$getSelection","$isDecoratorNode","$isElementNode","$isLineBreakNode","$isNodeSelection","$isRangeSelection","$isRootOrShadowRoot","$isTextNode","$onUpdate","$setSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","SELECTION_CHANGE_COMMAND","useEffect","DecoratorPlugin","$","editor","$onDelete","_temp2","t0","t1","registerCommand","_temp3","_","activeEditor","hasSelectedDecorator","Boolean","$getSelectedDecorator","read","decorator_0","document","querySelector","classList","remove","decorator","getElementByKey","getKey","add","_temp5","_temp7","event_2","selection_1","selection","event","preventDefault","nextSibling","getNodes","getNextSibling","element_0","element","$selectDecorator","firstDescendant","getFirstDescendant","block_0","INTERNAL_$isBlock","block","selectEnd","lastPoint","isBackward","anchor","focus","lastNode","getNode","lastSelectedBlock","_temp6","nextBlock","findLaterSiblingBlock","nextBlockElement","node","node_1","event_1","selection_0","prevSibling","getPreviousSibling","lastDescendant","getLastDescendant","selectStart","firstPoint","firstNode","firstSelectedBlock","_temp4","prevBlock","findFirstSiblingBlock","prevBlockElement","node_0","event_0","$getDecoratorByMouseEvent","target","isInteractive","HTMLElement","isContentEditable","closest","forEach","_temp","undefined","nodes","length","scrollIntoView","behavior","isInline","firstChild","getFirstChild","isLeafElement","canBeEmpty","current"],"sources":["../../../../src/lexical/plugins/DecoratorPlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type { DecoratorNode, ElementNode, LexicalNode } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $findMatchingParent, mergeRegister } from '@lexical/utils'\nimport {\n $createNodeSelection,\n $getEditor,\n $getNearestNodeFromDOMNode,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isLineBreakNode,\n $isNodeSelection,\n $isRangeSelection,\n $isRootOrShadowRoot,\n $isTextNode,\n $onUpdate,\n $setSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n SELECTION_CHANGE_COMMAND,\n} from 'lexical'\nimport { useEffect } from 'react'\n\nimport './index.css'\n\n// TODO: This should ideally be fixed in Lexical. See\n// https://github.com/facebook/lexical/pull/7072\nexport function DecoratorPlugin() {\n const [editor] = useLexicalComposerContext()\n\n const $onDelete = (event: KeyboardEvent) => {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return false\n }\n event.preventDefault()\n selection.getNodes().forEach((node) => {\n node.remove()\n })\n return true\n }\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n CLICK_COMMAND,\n (event) => {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const decorator = $getDecoratorByMouseEvent(event)\n if (!decorator) {\n return true\n }\n const { target } = event\n const isInteractive =\n !(target instanceof HTMLElement) ||\n target.isContentEditable ||\n target.closest(\n 'button, textarea, input, .react-select, .code-editor, .no-select-decorator, [role=\"button\"]',\n )\n if (isInteractive) {\n $setSelection(null)\n } else {\n $selectDecorator(decorator)\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(\n SELECTION_CHANGE_COMMAND,\n (_, activeEditor) => {\n // Nested editors reconcile independently and update their own highlight.\n if (activeEditor !== editor) {\n return false\n }\n const hasSelectedDecorator = Boolean($getSelectedDecorator())\n $onUpdate(() => {\n activeEditor.read('latest', () => {\n const decorator = $getSelectedDecorator()\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n if (decorator) {\n activeEditor\n .getElementByKey(decorator.getKey())\n ?.classList.add('decorator-selected')\n }\n })\n })\n return hasSelectedDecorator\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_UP_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n const prevSibling = selection.getNodes()[0]?.getPreviousSibling()\n if ($isDecoratorNode(prevSibling)) {\n const element = $getEditor().getElementByKey(prevSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: prevSibling })\n event.preventDefault()\n return true\n }\n return false\n }\n if (!$isElementNode(prevSibling)) {\n return false\n }\n const lastDescendant = prevSibling.getLastDescendant() ?? prevSibling\n if (!lastDescendant) {\n return false\n }\n const block = $findMatchingParent(lastDescendant, INTERNAL_$isBlock)\n block?.selectStart()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get first selected block\n const firstPoint = selection.isBackward() ? selection.anchor : selection.focus\n const firstNode = firstPoint.getNode()\n const firstSelectedBlock = $findMatchingParent(firstNode, (node) => {\n return findFirstSiblingBlock(node) !== null\n })\n const prevBlock = firstSelectedBlock?.getPreviousSibling()\n if (!firstSelectedBlock || prevBlock !== findFirstSiblingBlock(firstSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(prevBlock)) {\n const prevBlockElement = $getEditor().getElementByKey(prevBlock.getKey())\n if (prevBlockElement) {\n $selectDecorator({ element: prevBlockElement, node: prevBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ARROW_DOWN_COMMAND,\n (event) => {\n // CASE 1: Node selection\n const selection = $getSelection()\n if ($isNodeSelection(selection)) {\n event.preventDefault()\n const nextSibling = selection.getNodes()[0]?.getNextSibling()\n if ($isDecoratorNode(nextSibling)) {\n const element = $getEditor().getElementByKey(nextSibling.getKey())\n if (element) {\n $selectDecorator({ element, node: nextSibling })\n }\n return true\n }\n if (!$isElementNode(nextSibling)) {\n return true\n }\n const firstDescendant = nextSibling.getFirstDescendant() ?? nextSibling\n if (!firstDescendant) {\n return true\n }\n const block = $findMatchingParent(firstDescendant, INTERNAL_$isBlock)\n block?.selectEnd()\n event.preventDefault()\n return true\n }\n if (!$isRangeSelection(selection)) {\n return false\n }\n\n // CASE 2: Range selection\n // Get last selected block\n const lastPoint = selection.isBackward() ? selection.anchor : selection.focus\n const lastNode = lastPoint.getNode()\n const lastSelectedBlock = $findMatchingParent(lastNode, (node) => {\n return findLaterSiblingBlock(node) !== null\n })\n const nextBlock = lastSelectedBlock?.getNextSibling()\n if (!lastSelectedBlock || nextBlock !== findLaterSiblingBlock(lastSelectedBlock)) {\n return false\n }\n\n if ($isDecoratorNode(nextBlock)) {\n const nextBlockElement = $getEditor().getElementByKey(nextBlock.getKey())\n if (nextBlockElement) {\n $selectDecorator({ element: nextBlockElement, node: nextBlock })\n event.preventDefault()\n return true\n }\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor])\n\n return null\n}\n\nfunction $getDecoratorByMouseEvent(\n event: MouseEvent,\n): { element: HTMLElement; node: DecoratorNode<unknown> } | undefined {\n if (!(event.target instanceof HTMLElement)) {\n return undefined\n }\n const element = event.target.closest('[data-lexical-decorator=\"true\"]')\n if (!(element instanceof HTMLElement)) {\n return undefined\n }\n const node = $getNearestNodeFromDOMNode(element)\n return $isDecoratorNode(node) ? { element, node } : undefined\n}\n\nfunction $getSelectedDecorator() {\n const selection = $getSelection()\n if (!$isNodeSelection(selection)) {\n return undefined\n }\n const nodes = selection.getNodes()\n if (nodes.length !== 1) {\n return undefined\n }\n const node = nodes[0]\n return $isDecoratorNode(node) ? node : undefined\n}\n\nfunction $selectDecorator({\n element,\n node,\n}: {\n element: HTMLElement\n node: DecoratorNode<unknown>\n}) {\n document.querySelector('.decorator-selected')?.classList.remove('decorator-selected')\n const selection = $createNodeSelection()\n selection.add(node.getKey())\n $setSelection(selection)\n element.scrollIntoView({ behavior: 'smooth', block: 'nearest' })\n element.classList.add('decorator-selected')\n}\n\n/**\n * Copied from https://github.com/facebook/lexical/blob/main/packages/lexical/src/LexicalUtils.ts\n *\n * This function returns true for a DecoratorNode that is not inline OR\n * an ElementNode that is:\n * - not a root or shadow root\n * - not inline\n * - can't be empty\n * - has no children or an inline first child\n */\nexport function INTERNAL_$isBlock(node: LexicalNode): node is DecoratorNode<unknown> | ElementNode {\n if ($isDecoratorNode(node) && !node.isInline()) {\n return true\n }\n if (!$isElementNode(node) || $isRootOrShadowRoot(node)) {\n return false\n }\n\n const firstChild = node.getFirstChild()\n const isLeafElement =\n firstChild === null ||\n $isLineBreakNode(firstChild) ||\n $isTextNode(firstChild) ||\n firstChild.isInline()\n\n return !node.isInline() && node.canBeEmpty() !== false && isLeafElement\n}\n\nfunction findLaterSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getNextSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getNextSibling()\n }\n return null\n}\n\nfunction findFirstSiblingBlock(node: LexicalNode): LexicalNode | null {\n let current = node.getPreviousSibling()\n while (current !== null) {\n if (INTERNAL_$isBlock(current)) {\n return current\n }\n current = current.getPreviousSibling()\n }\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EA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9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQzD,cAAc;EAClC;EACA,OAAO;AACT;AAEA,SAASmC,sBAAsBd,IAAiB;EAC9C,IAAIoC,OAAA,GAAUpC,IAAA,CAAKK,kBAAkB;EACrC,OAAO+B,OAAA,KAAY,MAAM;IACvB,IAAIlD,iBAAA,CAAkBkD,OAAA,GAAU;MAC9B,OAAOA,OAAA;IACT;IACAA,OAAA,GAAUA,OAAA,CAAQ/B,kBAAkB;EACtC;EACA,OAAO;AACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useTranslation","$createParagraphNode","$getRoot","React","useEditorConfigContext","AddIcon","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","t","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","type","children","size","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useTranslation } from '@payloadcms/ui'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.css'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { AddIcon } from '../../ui/icons/Add/index.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n const { t } = useTranslation<{}, string>()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n <button\n aria-label={t('lexical:general:insertParagraph')}\n className={baseClass}\n onClick={onClick}\n type=\"button\"\n >\n <span className={`${baseClass}-inside`}>\n <AddIcon size={16} />\n </span>\n </button>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAC/C,OAAOC,KAAA,MAAW;AAElB,OAAO;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,OAAO,QAAQ;AACxB,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,0BAAA,GAAuCA,CAAA;EAAA,MAAAC,CAAA,GAAAV,EAAA;EAClD,OAAAW,MAAA,IAAiBV,yBAAA;EACjB;IAAAW;EAAA,IAAyBN,sBAAA;EACzB;IAAAO;EAAA,IAAcX,cAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useTranslation","$createParagraphNode","$getRoot","React","useEditorConfigContext","AddIcon","baseClass","InsertParagraphAtEndPlugin","$","editor","editorConfig","t","admin","hideInsertParagraphAtEnd","t0","update","_temp","onClick","t1","_jsx","className","type","children","size","paragraphNode","append","select"],"sources":["../../../../src/lexical/plugins/InsertParagraphAtEnd/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useTranslation } from '@payloadcms/ui'\nimport { $createParagraphNode, $getRoot } from 'lexical'\nimport React from 'react'\n\nimport './index.css'\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { AddIcon } from '../../ui/icons/Add/index.js'\nconst baseClass = 'insert-paragraph-at-end'\n\nexport const InsertParagraphAtEndPlugin: React.FC = () => {\n const [editor] = useLexicalComposerContext()\n const { editorConfig } = useEditorConfigContext()\n const { t } = useTranslation<{}, string>()\n\n if (editorConfig?.admin?.hideInsertParagraphAtEnd) {\n return null\n }\n\n const onClick = () => {\n editor.update(() => {\n const paragraphNode = $createParagraphNode()\n $getRoot().append(paragraphNode)\n paragraphNode.select()\n })\n }\n\n return (\n <button\n aria-label={t('lexical:general:insertParagraph')}\n className={baseClass}\n onClick={onClick}\n type=\"button\"\n >\n <span className={`${baseClass}-inside`}>\n <AddIcon size={16} />\n </span>\n </button>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAC/C,OAAOC,KAAA,MAAW;AAElB,OAAO;AACP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,OAAO,QAAQ;AACxB,MAAMC,SAAA,GAAY;AAElB,OAAO,MAAMC,0BAAA,GAAuCA,CAAA;EAAA,MAAAC,CAAA,GAAAV,EAAA;EAClD,OAAAW,MAAA,IAAiBV,yBAAA;EACjB;IAAAW;EAAA,IAAyBN,sBAAA;EACzB;IAAAO;EAAA,IAAcX,cAAA;EAEd,IAAIU,YAAA,EAAAE,KAAqB,EAAAC,wBAAA;IAAA,OAChB;EAAA;EACT,IAAAC,EAAA;EAAA,IAAAN,CAAA,QAAAC,MAAA;IAEgBK,EAAA,GAAAA,CAAA;MACdL,MAAA,CAAAM,MAAa,CAACC,KAId;IAAA,CACF;IAAAR,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAM,EAAA;EAAA;IAAAA,EAAA,GAAAN,CAAA;EAAA;EANA,MAAAS,OAAA,GAAgBH,EAMhB;EAAA,IAAAI,EAAA;EAAA,IAAAV,CAAA,QAAAS,OAAA,IAAAT,CAAA,QAAAG,CAAA;IAGEO,EAAA,GAAAC,IAAA,CAAC;MAAA,cACaR,CAAA,CAAE;MAAAS,SAAA,EACHd,SAAA;MAAAW,OAAA;MAAAI,IAAA,EAEN;MAAAC,QAAA,EAELH,IAAA,CAAC;QAAAC,SAAA,EAAgB,GAAGd,SAAA,SAAkB;QAAAgB,QAAA,EACpCH,IAAA,CAACd,OAAA;UAAAkB,IAAA,EAAc;;;;;;;;;;SAPnBL,E;CAWJ;AA7BoD,SAAAF,MAAA;EAW9C,MAAAQ,aAAA,GAAsBvB,oBAAA;EACtBC,QAAA,GAAAuB,MAAiB,CAACD,aAAA;EAClBA,aAAA,CAAAE,MAAoB;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","registerMarkdownShortcuts","useLexicalComposerContext","React","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { registerMarkdownShortcuts } from '@lexical/markdown'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBN,yBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPR,yBAAA,CAA0BO,MAAA,EAAQD,YAAA,CAAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","registerMarkdownShortcuts","useLexicalComposerContext","React","useEditorConfigContext","MarkdownShortcutPlugin","$","editorConfig","editor","t0","t1","features","markdownTransformers","useEffect"],"sources":["../../../../src/lexical/plugins/MarkdownShortcut/index.tsx"],"sourcesContent":["'use client'\n\nimport { registerMarkdownShortcuts } from '@lexical/markdown'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport * as React from 'react'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\n\nexport const MarkdownShortcutPlugin: React.FC = () => {\n const { editorConfig } = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n React.useEffect(() => {\n return registerMarkdownShortcuts(editor, editorConfig.features.markdownTransformers ?? [])\n }, [editor, editorConfig.features.markdownTransformers])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,yBAAyB,QAAQ;AAC1C,YAAYC,KAAA,MAAW;AAEvB,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,sBAAA,GAAmCA,CAAA;EAAA,MAAAC,CAAA,GAAAN,EAAA;EAC9C;IAAAO;EAAA,IAAyBH,sBAAA;EACzB,OAAAI,MAAA,IAAiBN,yBAAA;EAAA,IAAAO,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAE,MAAA,IAAAF,CAAA,QAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAEDH,EAAA,GAAAA,CAAA,KACPR,yBAAA,CAA0BO,MAAA,EAAQD,YAAA,CAAAI,QAAqB,CAAAC,oBAA2B,IAAhD,EAAgD,CAC3F;IAAGF,EAAA,IAACF,MAAA,EAAQD,YAAA,CAAAI,QAAqB,CAAAC,oBAAqB,CAAC;IAAAN,CAAA,MAAAE,MAAA;IAAAF,CAAA,MAAAC,YAAA,CAAAI,QAAA,CAAAC,oBAAA;IAAAN,CAAA,MAAAG,EAAA;IAAAH,CAAA,MAAAI,EAAA;EAAA;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAFvDH,KAAA,CAAAU,SAAe,CAACJ,EAEhB,EAAGC,EAAoD;EAAA,OAEhD;AAAA,CACT","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getRoot","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","refreshBlockDecorators","editor","update","walk","node","type","getType","markDirty","getChildren","child","NodeViewOverridePlugin","$","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getRoot, type LexicalNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\n// `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,\n// so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.\n// Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.\nfunction refreshBlockDecorators(editor: ReturnType<typeof useLexicalComposerContext>[0]): void {\n editor.update(() => {\n const walk = (node: LexicalNode): void => {\n const type = node.getType()\n if (type === 'block' || type === 'inlineBlock') {\n node.markDirty()\n }\n if ('getChildren' in node && typeof node.getChildren === 'function') {\n for (const child of node.getChildren() as LexicalNode[]) {\n walk(child)\n }\n }\n }\n walk($getRoot())\n })\n}\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n\n refreshBlockDecorators(editor)\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAA0B;AAC3C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D;AACA;AACA;AACA,SAASC,uBAAuBC,MAAuD;EACrFA,MAAA,CAAOC,MAAM,CAAC;IACZ,MAAMC,IAAA,GAAQC,IAAA;MACZ,MAAMC,IAAA,GAAOD,IAAA,CAAKE,OAAO;MACzB,IAAID,IAAA,KAAS,WAAWA,IAAA,KAAS,eAAe;QAC9CD,IAAA,CAAKG,SAAS;MAChB;MACA,IAAI,iBAAiBH,IAAA,IAAQ,OAAOA,IAAA,CAAKI,WAAW,KAAK,YAAY;QACnE,KAAK,MAAMC,KAAA,IAASL,IAAA,CAAKI,WAAW,IAAqB;UACvDL,IAAA,CAAKM,KAAA;QACP;MACF;IACF;IACAN,IAAA,CAAKR,QAAA;EACP;AACF;AAEA,OAAO,SAAAe,uBAAA;EAAA,MAAAC,CAAA,GAAAlB,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EACjB;IAAAkB,WAAA;IAAAC;EAAA,IAA+BhB,eAAA;EAAA,IAAAiB,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAJ,CAAA,QAAAC,WAAA,IAAAD,CAAA,QAAAV,MAAA,IAAAU,CAAA,QAAAE,KAAA;IAErBC,EAAA,GAAAA,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","$getRoot","useEffect","useRichTextView","clearEditorNodeViews","registerEditorNodeViews","refreshBlockDecorators","editor","update","walk","node","type","getType","markDirty","getChildren","child","NodeViewOverridePlugin","$","currentView","views","t0","t1","default","nodes"],"sources":["../../../../src/lexical/plugins/NodeViewOverridePlugin/index.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { $getRoot, type LexicalNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { useRichTextView } from '../../../field/RichTextViewProvider.js'\nimport { clearEditorNodeViews, registerEditorNodeViews } from '../../nodes/index.js'\n\n// `LexicalComposer` re-mounts with a new `editor` whenever `currentView` changes,\n// so decorator nodes run their initial `decorate()` before this effect registers the view's overrides.\n// Mark existing block decorators dirty after registering so they re-decorate with the resolved custom `Block` component.\nfunction refreshBlockDecorators(editor: ReturnType<typeof useLexicalComposerContext>[0]): void {\n editor.update(() => {\n const walk = (node: LexicalNode): void => {\n const type = node.getType()\n if (type === 'block' || type === 'inlineBlock') {\n node.markDirty()\n }\n if ('getChildren' in node && typeof node.getChildren === 'function') {\n for (const child of node.getChildren() as LexicalNode[]) {\n walk(child)\n }\n }\n }\n walk($getRoot())\n })\n}\n\nexport function NodeViewOverridePlugin(): null {\n const [editor] = useLexicalComposerContext()\n const { currentView, views } = useRichTextView()\n\n useEffect(() => {\n if (!views) {\n return\n }\n\n if (currentView === 'default') {\n if (views.default) {\n registerEditorNodeViews(editor, views.default?.nodes)\n } else {\n clearEditorNodeViews(editor)\n }\n } else if (views[currentView]) {\n clearEditorNodeViews(editor)\n registerEditorNodeViews(editor, views[currentView]?.nodes)\n }\n\n refreshBlockDecorators(editor)\n }, [editor, views, currentView])\n\n return null\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,QAAQ,QAA0B;AAC3C,SAASC,SAAS,QAAQ;AAE1B,SAASC,eAAe,QAAQ;AAChC,SAASC,oBAAoB,EAAEC,uBAAuB,QAAQ;AAE9D;AACA;AACA;AACA,SAASC,uBAAuBC,MAAuD;EACrFA,MAAA,CAAOC,MAAM,CAAC;IACZ,MAAMC,IAAA,GAAQC,IAAA;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;IAAAD,EAAA,GAAAH,CAAA;IAAAI,EAAA,GAAAJ,CAAA;EAAA;EAjB/Bf,SAAA,CAAUkB,EAiBV,EAAGC,EAA4B;EAAA,OAExB;AAAA","ignoreList":[]}
|
|
@@ -137,95 +137,182 @@ export function useDynamicPositioning(resolution, targetElementRef, onReposition
|
|
|
137
137
|
useEffect(t0, t1);
|
|
138
138
|
}
|
|
139
139
|
export const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND');
|
|
140
|
-
export function LexicalMenu({
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
export function LexicalMenu(t0) {
|
|
141
|
+
const $ = _c(50);
|
|
142
|
+
const {
|
|
143
|
+
anchorElementRef,
|
|
144
|
+
close,
|
|
145
|
+
editor,
|
|
146
|
+
groups,
|
|
147
|
+
menuRenderFn,
|
|
148
|
+
resolution,
|
|
149
|
+
shouldSplitNodeWithQuery: t1
|
|
150
|
+
} = t0;
|
|
151
|
+
const shouldSplitNodeWithQuery = t1 === undefined ? false : t1;
|
|
150
152
|
const [selectedItemKey, setSelectedItemKey] = useState(null);
|
|
151
|
-
const matchingString = resolution.match && resolution.match.matchingString ||
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
rootElem.
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
const setSelectedItemKeyToFirstMatchingItem = useCallback(() => {
|
|
160
|
-
// set selected item to the first of the matching ones
|
|
161
|
-
if (groups !== null && matchingString != null) {
|
|
162
|
-
// groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.
|
|
163
|
-
const allItems = groups.flatMap(group => group.items);
|
|
164
|
-
if (allItems.length) {
|
|
165
|
-
const firstMatchingItem = allItems[0];
|
|
166
|
-
updateSelectedItem(firstMatchingItem);
|
|
153
|
+
const matchingString = resolution.match && resolution.match.matchingString || "";
|
|
154
|
+
let t2;
|
|
155
|
+
if ($[0] !== editor) {
|
|
156
|
+
t2 = item => {
|
|
157
|
+
const rootElem = editor.getRootElement();
|
|
158
|
+
if (rootElem !== null) {
|
|
159
|
+
rootElem.setAttribute("aria-activedescendant", `${baseClass}__item-${item.key}`);
|
|
160
|
+
setSelectedItemKey(item.key);
|
|
167
161
|
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
162
|
+
};
|
|
163
|
+
$[0] = editor;
|
|
164
|
+
$[1] = t2;
|
|
165
|
+
} else {
|
|
166
|
+
t2 = $[1];
|
|
167
|
+
}
|
|
168
|
+
const updateSelectedItem = t2;
|
|
169
|
+
let t3;
|
|
170
|
+
if ($[2] !== groups || $[3] !== matchingString || $[4] !== updateSelectedItem) {
|
|
171
|
+
t3 = () => {
|
|
172
|
+
if (groups !== null && matchingString != null) {
|
|
173
|
+
const allItems = groups.flatMap(_temp);
|
|
174
|
+
if (allItems.length) {
|
|
175
|
+
const firstMatchingItem = allItems[0];
|
|
176
|
+
updateSelectedItem(firstMatchingItem);
|
|
177
|
+
}
|
|
179
178
|
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
179
|
+
};
|
|
180
|
+
$[2] = groups;
|
|
181
|
+
$[3] = matchingString;
|
|
182
|
+
$[4] = updateSelectedItem;
|
|
183
|
+
$[5] = t3;
|
|
184
|
+
} else {
|
|
185
|
+
t3 = $[5];
|
|
186
|
+
}
|
|
187
|
+
const setSelectedItemKeyToFirstMatchingItem = t3;
|
|
188
|
+
let t4;
|
|
189
|
+
if ($[6] !== setSelectedItemKeyToFirstMatchingItem) {
|
|
190
|
+
t4 = () => {
|
|
191
|
+
setSelectedItemKeyToFirstMatchingItem();
|
|
192
|
+
};
|
|
193
|
+
$[6] = setSelectedItemKeyToFirstMatchingItem;
|
|
194
|
+
$[7] = t4;
|
|
195
|
+
} else {
|
|
196
|
+
t4 = $[7];
|
|
197
|
+
}
|
|
198
|
+
let t5;
|
|
199
|
+
if ($[8] !== matchingString || $[9] !== setSelectedItemKeyToFirstMatchingItem) {
|
|
200
|
+
t5 = [matchingString, setSelectedItemKeyToFirstMatchingItem];
|
|
201
|
+
$[8] = matchingString;
|
|
202
|
+
$[9] = setSelectedItemKeyToFirstMatchingItem;
|
|
203
|
+
$[10] = t5;
|
|
204
|
+
} else {
|
|
205
|
+
t5 = $[10];
|
|
206
|
+
}
|
|
207
|
+
useEffect(t4, t5);
|
|
208
|
+
let t6;
|
|
209
|
+
if ($[11] !== close || $[12] !== editor || $[13] !== resolution.match || $[14] !== shouldSplitNodeWithQuery) {
|
|
210
|
+
t6 = selectedItem => {
|
|
211
|
+
close();
|
|
187
212
|
editor.update(() => {
|
|
188
|
-
|
|
189
|
-
|
|
213
|
+
const textNodeContainingQuery = resolution.match != null && shouldSplitNodeWithQuery ? $splitNodeContainingQuery(resolution.match) : null;
|
|
214
|
+
if (textNodeContainingQuery) {
|
|
215
|
+
textNodeContainingQuery.remove();
|
|
190
216
|
}
|
|
191
217
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
let selection;
|
|
220
|
+
editor.read(() => {
|
|
221
|
+
selection = $getSelection()?.clone();
|
|
222
|
+
});
|
|
223
|
+
editor.update(() => {
|
|
224
|
+
if (selection) {
|
|
225
|
+
$setSelection(selection);
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
selectedItem.onSelect({
|
|
229
|
+
editor,
|
|
230
|
+
queryString: resolution.match ? resolution.match.matchingString : ""
|
|
231
|
+
});
|
|
232
|
+
}, 0);
|
|
233
|
+
};
|
|
234
|
+
$[11] = close;
|
|
235
|
+
$[12] = editor;
|
|
236
|
+
$[13] = resolution.match;
|
|
237
|
+
$[14] = shouldSplitNodeWithQuery;
|
|
238
|
+
$[15] = t6;
|
|
239
|
+
} else {
|
|
240
|
+
t6 = $[15];
|
|
241
|
+
}
|
|
242
|
+
const selectItemAndCleanUp = t6;
|
|
243
|
+
let t7;
|
|
244
|
+
let t8;
|
|
245
|
+
if ($[16] !== editor) {
|
|
246
|
+
t7 = () => () => {
|
|
200
247
|
const rootElem_0 = editor.getRootElement();
|
|
201
248
|
if (rootElem_0 !== null) {
|
|
202
|
-
rootElem_0.removeAttribute(
|
|
249
|
+
rootElem_0.removeAttribute("aria-activedescendant");
|
|
203
250
|
}
|
|
204
251
|
};
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
}
|
|
213
|
-
useEffect(
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
252
|
+
t8 = [editor];
|
|
253
|
+
$[16] = editor;
|
|
254
|
+
$[17] = t7;
|
|
255
|
+
$[18] = t8;
|
|
256
|
+
} else {
|
|
257
|
+
t7 = $[17];
|
|
258
|
+
t8 = $[18];
|
|
259
|
+
}
|
|
260
|
+
useEffect(t7, t8);
|
|
261
|
+
let t9;
|
|
262
|
+
if ($[19] !== groups || $[20] !== selectedItemKey || $[21] !== setSelectedItemKeyToFirstMatchingItem) {
|
|
263
|
+
t9 = () => {
|
|
264
|
+
if (groups === null) {
|
|
265
|
+
setSelectedItemKey(null);
|
|
266
|
+
} else {
|
|
267
|
+
if (selectedItemKey === null) {
|
|
268
|
+
setSelectedItemKeyToFirstMatchingItem();
|
|
269
|
+
}
|
|
220
270
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
271
|
+
};
|
|
272
|
+
$[19] = groups;
|
|
273
|
+
$[20] = selectedItemKey;
|
|
274
|
+
$[21] = setSelectedItemKeyToFirstMatchingItem;
|
|
275
|
+
$[22] = t9;
|
|
276
|
+
} else {
|
|
277
|
+
t9 = $[22];
|
|
278
|
+
}
|
|
279
|
+
let t10;
|
|
280
|
+
if ($[23] !== groups || $[24] !== selectedItemKey || $[25] !== setSelectedItemKeyToFirstMatchingItem || $[26] !== updateSelectedItem) {
|
|
281
|
+
t10 = [groups, selectedItemKey, updateSelectedItem, setSelectedItemKeyToFirstMatchingItem];
|
|
282
|
+
$[23] = groups;
|
|
283
|
+
$[24] = selectedItemKey;
|
|
284
|
+
$[25] = setSelectedItemKeyToFirstMatchingItem;
|
|
285
|
+
$[26] = updateSelectedItem;
|
|
286
|
+
$[27] = t10;
|
|
287
|
+
} else {
|
|
288
|
+
t10 = $[27];
|
|
289
|
+
}
|
|
290
|
+
useLayoutEffect(t9, t10);
|
|
291
|
+
let t11;
|
|
292
|
+
if ($[28] !== editor) {
|
|
293
|
+
t11 = () => mergeRegister(editor.registerCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, _temp2, COMMAND_PRIORITY_LOW));
|
|
294
|
+
$[28] = editor;
|
|
295
|
+
$[29] = t11;
|
|
296
|
+
} else {
|
|
297
|
+
t11 = $[29];
|
|
298
|
+
}
|
|
299
|
+
let t12;
|
|
300
|
+
if ($[30] !== editor || $[31] !== updateSelectedItem) {
|
|
301
|
+
t12 = [editor, updateSelectedItem];
|
|
302
|
+
$[30] = editor;
|
|
303
|
+
$[31] = updateSelectedItem;
|
|
304
|
+
$[32] = t12;
|
|
305
|
+
} else {
|
|
306
|
+
t12 = $[32];
|
|
307
|
+
}
|
|
308
|
+
useEffect(t11, t12);
|
|
309
|
+
let t13;
|
|
310
|
+
let t14;
|
|
311
|
+
if ($[33] !== close || $[34] !== editor || $[35] !== groups || $[36] !== selectItemAndCleanUp || $[37] !== selectedItemKey || $[38] !== updateSelectedItem) {
|
|
312
|
+
t13 = () => mergeRegister(editor.registerCommand(KEY_ARROW_DOWN_COMMAND, payload => {
|
|
226
313
|
const event = payload;
|
|
227
314
|
if (groups !== null && groups.length && selectedItemKey !== null) {
|
|
228
|
-
const allItems_0 = groups.flatMap(
|
|
315
|
+
const allItems_0 = groups.flatMap(_temp3);
|
|
229
316
|
const selectedIndex = allItems_0.findIndex(item_1 => item_1.key === selectedItemKey);
|
|
230
317
|
const newSelectedIndex = selectedIndex !== allItems_0.length - 1 ? selectedIndex + 1 : 0;
|
|
231
318
|
const newSelectedItem = allItems_0[newSelectedIndex];
|
|
@@ -246,7 +333,7 @@ export function LexicalMenu({
|
|
|
246
333
|
}, COMMAND_PRIORITY_NORMAL), editor.registerCommand(KEY_ARROW_UP_COMMAND, payload_0 => {
|
|
247
334
|
const event_0 = payload_0;
|
|
248
335
|
if (groups !== null && groups.length && selectedItemKey !== null) {
|
|
249
|
-
const allItems_1 = groups.flatMap(
|
|
336
|
+
const allItems_1 = groups.flatMap(_temp4);
|
|
250
337
|
const selectedIndex_0 = allItems_1.findIndex(item_2 => item_2.key === selectedItemKey);
|
|
251
338
|
const newSelectedIndex_0 = selectedIndex_0 !== 0 ? selectedIndex_0 - 1 : allItems_1.length - 1;
|
|
252
339
|
const newSelectedItem_0 = allItems_1[newSelectedIndex_0];
|
|
@@ -272,7 +359,7 @@ export function LexicalMenu({
|
|
|
272
359
|
if (groups === null || selectedItemKey === null) {
|
|
273
360
|
return false;
|
|
274
361
|
}
|
|
275
|
-
const allItems_2 = groups.flatMap(
|
|
362
|
+
const allItems_2 = groups.flatMap(_temp5);
|
|
276
363
|
const selectedItem_0 = allItems_2.find(item_3 => item_3.key === selectedItemKey);
|
|
277
364
|
if (!selectedItem_0) {
|
|
278
365
|
return false;
|
|
@@ -285,7 +372,7 @@ export function LexicalMenu({
|
|
|
285
372
|
if (groups === null || selectedItemKey === null) {
|
|
286
373
|
return false;
|
|
287
374
|
}
|
|
288
|
-
const allItems_3 = groups.flatMap(
|
|
375
|
+
const allItems_3 = groups.flatMap(_temp6);
|
|
289
376
|
const selectedItem_1 = allItems_3.find(item_4 => item_4.key === selectedItemKey);
|
|
290
377
|
if (!selectedItem_1) {
|
|
291
378
|
return false;
|
|
@@ -297,14 +384,74 @@ export function LexicalMenu({
|
|
|
297
384
|
selectItemAndCleanUp(selectedItem_1);
|
|
298
385
|
return true;
|
|
299
386
|
}, COMMAND_PRIORITY_NORMAL));
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
selectItemAndCleanUp
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
387
|
+
t14 = [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem];
|
|
388
|
+
$[33] = close;
|
|
389
|
+
$[34] = editor;
|
|
390
|
+
$[35] = groups;
|
|
391
|
+
$[36] = selectItemAndCleanUp;
|
|
392
|
+
$[37] = selectedItemKey;
|
|
393
|
+
$[38] = updateSelectedItem;
|
|
394
|
+
$[39] = t13;
|
|
395
|
+
$[40] = t14;
|
|
396
|
+
} else {
|
|
397
|
+
t13 = $[39];
|
|
398
|
+
t14 = $[40];
|
|
399
|
+
}
|
|
400
|
+
useEffect(t13, t14);
|
|
401
|
+
let t15;
|
|
402
|
+
if ($[41] !== groups || $[42] !== selectItemAndCleanUp || $[43] !== selectedItemKey) {
|
|
403
|
+
t15 = {
|
|
404
|
+
groups,
|
|
405
|
+
selectedItemKey,
|
|
406
|
+
selectItemAndCleanUp,
|
|
407
|
+
setSelectedItemKey
|
|
408
|
+
};
|
|
409
|
+
$[41] = groups;
|
|
410
|
+
$[42] = selectItemAndCleanUp;
|
|
411
|
+
$[43] = selectedItemKey;
|
|
412
|
+
$[44] = t15;
|
|
413
|
+
} else {
|
|
414
|
+
t15 = $[44];
|
|
415
|
+
}
|
|
416
|
+
const listItemProps = t15;
|
|
417
|
+
const t16 = resolution.match ? resolution.match.matchingString : "";
|
|
418
|
+
let t17;
|
|
419
|
+
if ($[45] !== anchorElementRef || $[46] !== listItemProps || $[47] !== menuRenderFn || $[48] !== t16) {
|
|
420
|
+
t17 = menuRenderFn(anchorElementRef, listItemProps, t16);
|
|
421
|
+
$[45] = anchorElementRef;
|
|
422
|
+
$[46] = listItemProps;
|
|
423
|
+
$[47] = menuRenderFn;
|
|
424
|
+
$[48] = t16;
|
|
425
|
+
$[49] = t17;
|
|
426
|
+
} else {
|
|
427
|
+
t17 = $[49];
|
|
428
|
+
}
|
|
429
|
+
return t17;
|
|
430
|
+
}
|
|
431
|
+
function _temp6(group_3) {
|
|
432
|
+
return group_3.items;
|
|
433
|
+
}
|
|
434
|
+
function _temp5(group_2) {
|
|
435
|
+
return group_2.items;
|
|
436
|
+
}
|
|
437
|
+
function _temp4(group_1) {
|
|
438
|
+
return group_1.items;
|
|
439
|
+
}
|
|
440
|
+
function _temp3(group_0) {
|
|
441
|
+
return group_0.items;
|
|
442
|
+
}
|
|
443
|
+
function _temp2(t0) {
|
|
444
|
+
const {
|
|
445
|
+
item: item_0
|
|
446
|
+
} = t0;
|
|
447
|
+
if (item_0.ref && item_0.ref.current != null) {
|
|
448
|
+
scrollIntoViewIfNeeded(item_0.ref.current);
|
|
449
|
+
return true;
|
|
450
|
+
}
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
function _temp(group) {
|
|
454
|
+
return group.items;
|
|
308
455
|
}
|
|
309
456
|
function setContainerDivAttributes(containerDiv, className) {
|
|
310
457
|
if (className != null) {
|