@payloadcms/richtext-lexical 4.0.0-beta.3 → 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-VHUGOQ3X.js → chunk-SE5IITBK.js} +2 -2
- package/dist/exports/client/chunk-SE5IITBK.js.map +7 -0
- package/dist/exports/client/{component-ELXHSW52.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 +3 -2
- 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.js +2 -2
- 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/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/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/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/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/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 +5 -3
- 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 +12 -15
- 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-UH7ALTP6.js +0 -2
- package/dist/exports/client/chunk-UH7ALTP6.js.map +0 -7
- package/dist/exports/client/chunk-VHUGOQ3X.js.map +0 -7
- package/dist/exports/client/componentInline-N7HK3HP3.js +0 -2
- /package/dist/exports/client/{RelationshipComponent-YCPAKOL7.js.map → RelationshipComponent-TVK6I4W4.js.map} +0 -0
- /package/dist/exports/client/{component-ELXHSW52.js.map → component-QENB4QTS.js.map} +0 -0
- /package/dist/exports/client/{componentInline-N7HK3HP3.js.map → componentInline-AU7IBNY7.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useCallback","useEffect","useMemo","useRef","useState","React","TableGridPopup","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","children","contextValue","setContextValue","_jsx","value","editor","cellContext","isPopupOpen","setIsPopupOpen","popupPosition","setPopupPosition","selectionRef","anchorElem","setAnchorElem","rootElement","getRootElement","editorWrapper","closest","parentElement","hasNodes","Error","registerCommand","anchor","anchorRect","getBoundingClientRect","pos","getEditorState","read","selection","current","clone","anchorNode","getNode","domElem","getElementByKey","getKey","elemRect","height","left","top","bottom","nativeSelection","window","getSelection","rangeCount","range","getRangeAt","rangeRect","handleClose","handleInsert","cols","rows","focus","update","discrete","skipTransforms","setTimeout","dispatchCommand","columns","String","_jsxs","Fragment","isOpen","onClose","onInsert","position","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"sources":["../../../../../../src/features/table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n BaseSelection,\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { TableGridPopup } from './TableGridPopup/index.js'\nimport './index.css'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const [isPopupOpen, setIsPopupOpen] = useState(false)\n const [popupPosition, setPopupPosition] = useState<{ left: number; top: number } | null>(null)\n const selectionRef = useRef<BaseSelection | null>(null)\n const [anchorElem, setAnchorElem] = useState<HTMLElement | null>(null)\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (rootElement) {\n const editorWrapper: HTMLElement | null =\n (rootElement.closest('.editor') as HTMLElement) ?? null\n setAnchorElem(editorWrapper ?? rootElement.parentElement)\n }\n }, [editor])\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n const anchor = anchorElem\n if (!anchor) {\n return true\n }\n\n const anchorRect = anchor.getBoundingClientRect()\n let pos: { left: number; top: number } | null = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n selectionRef.current = selection.clone()\n\n const anchorNode = selection.anchor.getNode()\n const domElem = editor.getElementByKey(anchorNode.getKey())\n if (domElem) {\n const elemRect = domElem.getBoundingClientRect()\n if (elemRect.height > 0) {\n pos = {\n left: elemRect.left - anchorRect.left,\n top: elemRect.bottom - anchorRect.top + 8,\n }\n }\n }\n }\n })\n\n const nativeSelection = window.getSelection()\n if (nativeSelection && nativeSelection.rangeCount > 0) {\n const range = nativeSelection.getRangeAt(0)\n const rangeRect = range.getBoundingClientRect()\n if (rangeRect.height > 0) {\n pos = {\n left: rangeRect.left - anchorRect.left,\n top: rangeRect.bottom - anchorRect.top + 8,\n }\n }\n }\n\n // Fallback: position at start of editor\n if (!pos) {\n pos = { left: 0, top: 40 }\n }\n\n setPopupPosition(pos)\n setIsPopupOpen(true)\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, anchorElem])\n\n const handleClose = useCallback(() => {\n setIsPopupOpen(false)\n }, [])\n\n const handleInsert = useCallback(\n (cols: number, rows: number) => {\n setIsPopupOpen(false)\n editor.focus()\n editor.update(\n () => {\n if (selectionRef.current) {\n $setSelection(selectionRef.current.clone())\n }\n },\n { discrete: true, skipTransforms: true },\n )\n setTimeout(() => {\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(cols),\n rows: String(rows),\n })\n }, 1)\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <TableGridPopup\n anchorElem={anchorElem}\n editor={editor}\n isOpen={isPopupOpen}\n onClose={handleClose}\n onInsert={handleInsert}\n position={popupPosition}\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;;AAYA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,WAAA,IAAeC,uBAAuB,QAAQ;AACvD,SAASC,oBAAoB,EAAEC,aAAa,EAAEC,SAAS,EAAEC,YAAY,QAAQ;AAC7E,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,uBAAuB,EACvBC,aAAa,QACR;AACP,SAASC,aAAa,EAAEC,GAAG,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AACtF,YAAYC,KAAA,MAAW;AAIvB,SAASC,cAAc,QAAQ;AAC/B,OAAO;AAmBP,OAAO,MAAMC,yBAAA,GAAgDV,aAAA,CAC3D;AAGF,OAAO,MAAMW,WAAA,gBAAcV,aAAA,CAAgC;EACzDW,gBAAA,EAAkB;EAClBC,iBAAA,EAAmB;EACnBC,GAAA,EAAKA,CAAA;IACH;EAAA;AAEJ;AAEA,OAAO,SAASC,aAAa;EAAEC;AAAQ,CAA6B;EAClE,MAAM,CAACC,YAAA,EAAcC,eAAA,CAAgB,GAAGX,QAAA,CAGrC;IACDK,gBAAA,EAAkB;IAClBC,iBAAA,EAAmB;EACrB;EACA,oBACEM,IAAA,CAACR,WAAA;IACCS,KAAA,EAAOf,OAAA,CACL,OAAO;MACLO,gBAAA,EAAkBK,YAAA,CAAaL,gBAAgB;MAC/CC,iBAAA,EAAmBI,YAAA,CAAaJ,iBAAiB;MACjDC,GAAA,EAAKA,CAACF,gBAAA,EAAkBC,iBA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c7D,WAAA,CAAY;IAC9BqB,cAAA,CAAe;EACjB,GAAG,EAAE;EAEL,MAAMyC,YAAA,GAAe9D,WAAA,CACnB,CAAC+D,IAAA,EAAcC,IAAA;IACb3C,cAAA,CAAe;IACfH,MAAA,CAAO+C,KAAK;IACZ/C,MAAA,CAAOgD,MAAM,CACX;MACE,IAAI1C,YAAA,CAAakB,OAAO,EAAE;QACxB/C,aAAA,CAAc6B,YAAA,CAAakB,OAAO,CAACC,KAAK;MAC1C;IACF,GACA;MAAEwB,QAAA,EAAU;MAAMC,cAAA,EAAgB;IAAK;IAEzCC,UAAA,CAAW;MACTnD,MAAA,CAAOoD,eAAe,CAAClF,oBAAA,EAAsB;QAC3CmF,OAAA,EAASC,MAAA,CAAOT,IAAA;QAChBC,IAAA,EAAMQ,MAAA,CAAOR,IAAA;MACf;IACF,GAAG;EACL,GACA,CAAC9C,MAAA,CAAO;EAGV,oBACEuD,KAAA,CAACpE,KAAA,CAAMqE,QAAQ;4BACb1D,IAAA,CAACV,cAAA;MACCmB,UAAA,EAAYA,UAAA;MACZP,MAAA,EAAQA,MAAA;MACRyD,MAAA,EAAQvD,WAAA;MACRwD,OAAA,EAASf,WAAA;MACTgB,QAAA,EAAUf,YAAA;MACVgB,QAAA,EAAUxD;qBAEZN,IAAA,CAAC7B,uBAAA;MACC4F,sBAAA,EAAwB;MACxBC,YAAY;MACZC,mBAAA,EAAqB;;;AAI7B","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TablePlugin","LexicalReactTablePlugin","INSERT_TABLE_COMMAND","TableCellNode","TableNode","TableRowNode","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_EDITOR","createCommand","createContext","use","useCallback","useEffect","useMemo","useRef","useState","React","TableGridPopup","OPEN_TABLE_DRAWER_COMMAND","CellContext","cellEditorConfig","cellEditorPlugins","set","TableContext","t0","$","children","t1","Symbol","for","contextValue","setContextValue","t2","t3","t4","t5","_jsx","value","editor","cellContext","isPopupOpen","setIsPopupOpen","popupPosition","setPopupPosition","selectionRef","anchorElem","setAnchorElem","rootElement","getRootElement","editorWrapper","closest","parentElement","hasNodes","Error","registerCommand","anchor","anchorRect","getBoundingClientRect","pos","getEditorState","read","selection","current","clone","anchorNode","getNode","domElem","getElementByKey","getKey","elemRect","height","left","top","bottom","nativeSelection","window","getSelection","rangeCount","range","getRangeAt","rangeRect","handleClose","handleInsert","cols","rows","focus","update","discrete","skipTransforms","setTimeout","dispatchCommand","columns","String","_jsxs","Fragment","isOpen","onClose","onInsert","position","hasCellBackgroundColor","hasCellMerge","hasHorizontalScroll"],"sources":["../../../../../../src/features/table/client/plugins/TablePlugin/index.tsx"],"sourcesContent":["'use client'\n\nimport type {\n BaseSelection,\n EditorThemeClasses,\n Klass,\n LexicalCommand,\n LexicalEditor,\n LexicalNode,\n} from 'lexical'\nimport type { JSX } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { TablePlugin as LexicalReactTablePlugin } from '@lexical/react/LexicalTablePlugin'\nimport { INSERT_TABLE_COMMAND, TableCellNode, TableNode, TableRowNode } from '@lexical/table'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_EDITOR,\n createCommand,\n} from 'lexical'\nimport { createContext, use, useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport * as React from 'react'\n\nimport type { PluginComponent } from '../../../../typesClient.js'\n\nimport { TableGridPopup } from './TableGridPopup/index.js'\nimport './index.css'\n\nexport type CellContextShape = {\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n set: (\n cellEditorConfig: CellEditorConfig | null,\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null,\n ) => void\n}\n\nexport type CellEditorConfig = Readonly<{\n namespace: string\n nodes?: ReadonlyArray<Klass<LexicalNode>>\n onError: (error: Error, editor: LexicalEditor) => void\n readOnly?: boolean\n theme?: EditorThemeClasses\n}>\n\nexport const OPEN_TABLE_DRAWER_COMMAND: LexicalCommand<{}> = createCommand(\n 'OPEN_EMBED_DRAWER_COMMAND',\n)\n\nexport const CellContext = createContext<CellContextShape>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n set: () => {\n // Empty\n },\n})\n\nexport function TableContext({ children }: { children: JSX.Element }) {\n const [contextValue, setContextValue] = useState<{\n cellEditorConfig: CellEditorConfig | null\n cellEditorPlugins: Array<JSX.Element> | JSX.Element | null\n }>({\n cellEditorConfig: null,\n cellEditorPlugins: null,\n })\n return (\n <CellContext\n value={useMemo(\n () => ({\n cellEditorConfig: contextValue.cellEditorConfig,\n cellEditorPlugins: contextValue.cellEditorPlugins,\n set: (cellEditorConfig, cellEditorPlugins) => {\n setContextValue({ cellEditorConfig, cellEditorPlugins })\n },\n }),\n [contextValue.cellEditorConfig, contextValue.cellEditorPlugins],\n )}\n >\n {children}\n </CellContext>\n )\n}\n\nexport const TablePlugin: PluginComponent = () => {\n const [editor] = useLexicalComposerContext()\n const cellContext = use(CellContext)\n const [isPopupOpen, setIsPopupOpen] = useState(false)\n const [popupPosition, setPopupPosition] = useState<{ left: number; top: number } | null>(null)\n const selectionRef = useRef<BaseSelection | null>(null)\n const [anchorElem, setAnchorElem] = useState<HTMLElement | null>(null)\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (rootElement) {\n const editorWrapper: HTMLElement | null =\n (rootElement.closest('.editor') as HTMLElement) ?? null\n setAnchorElem(editorWrapper ?? rootElement.parentElement)\n }\n }, [editor])\n\n useEffect(() => {\n if (!editor.hasNodes([TableNode, TableRowNode, TableCellNode])) {\n throw new Error(\n 'TablePlugin: TableNode, TableRowNode, or TableCellNode is not registered on editor',\n )\n }\n\n return mergeRegister(\n editor.registerCommand(\n OPEN_TABLE_DRAWER_COMMAND,\n () => {\n const anchor = anchorElem\n if (!anchor) {\n return true\n }\n\n const anchorRect = anchor.getBoundingClientRect()\n let pos: { left: number; top: number } | null = null\n\n editor.getEditorState().read(() => {\n const selection = $getSelection()\n if ($isRangeSelection(selection)) {\n selectionRef.current = selection.clone()\n\n const anchorNode = selection.anchor.getNode()\n const domElem = editor.getElementByKey(anchorNode.getKey())\n if (domElem) {\n const elemRect = domElem.getBoundingClientRect()\n if (elemRect.height > 0) {\n pos = {\n left: elemRect.left - anchorRect.left,\n top: elemRect.bottom - anchorRect.top + 8,\n }\n }\n }\n }\n })\n\n const nativeSelection = window.getSelection()\n if (nativeSelection && nativeSelection.rangeCount > 0) {\n const range = nativeSelection.getRangeAt(0)\n const rangeRect = range.getBoundingClientRect()\n if (rangeRect.height > 0) {\n pos = {\n left: rangeRect.left - anchorRect.left,\n top: rangeRect.bottom - anchorRect.top + 8,\n }\n }\n }\n\n // Fallback: position at start of editor\n if (!pos) {\n pos = { left: 0, top: 40 }\n }\n\n setPopupPosition(pos)\n setIsPopupOpen(true)\n return true\n },\n COMMAND_PRIORITY_EDITOR,\n ),\n )\n }, [cellContext, editor, anchorElem])\n\n const handleClose = useCallback(() => {\n setIsPopupOpen(false)\n }, [])\n\n const handleInsert = useCallback(\n (cols: number, rows: number) => {\n setIsPopupOpen(false)\n editor.focus()\n editor.update(\n () => {\n if (selectionRef.current) {\n $setSelection(selectionRef.current.clone())\n }\n },\n { discrete: true, skipTransforms: true },\n )\n setTimeout(() => {\n editor.dispatchCommand(INSERT_TABLE_COMMAND, {\n columns: String(cols),\n rows: String(rows),\n })\n }, 1)\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <TableGridPopup\n anchorElem={anchorElem}\n editor={editor}\n isOpen={isPopupOpen}\n onClose={handleClose}\n onInsert={handleInsert}\n position={popupPosition}\n />\n <LexicalReactTablePlugin\n hasCellBackgroundColor={false}\n hasCellMerge\n hasHorizontalScroll={true}\n />\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAYA,SAASC,yBAAyB,QAAQ;AAC1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AAqB;;;AAI7B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDebounce.js","names":["c","_c","useCallback","useEffect","useRef","debounce","useDebounce","fn","ms","maxWait","$","debouncedRef","t0","t1","current","cancel","t2","Symbol","for","t3","args","callback"],"sources":["../../../../../src/features/table/client/utils/useDebounce.ts"],"sourcesContent":["'use client'\nimport { useCallback, useEffect, useRef } from 'react'\n\nimport debounce from './debounce.js'\n\n// Define the type for debounced function that includes cancel method\ninterface DebouncedFunction<T extends (...args: any[]) => any> {\n (...args: Parameters<T>): ReturnType<T>\n cancel: () => void\n}\n\nexport function useDebounce<T extends (...args: never[]) => void>(\n fn: T,\n ms: number,\n maxWait?: number,\n) {\n // Update the ref type to include cancel method\n const debouncedRef = useRef<DebouncedFunction<T> | null>(null)\n\n useEffect(() => {\n debouncedRef.current = debounce(fn, ms, { maxWait }) as DebouncedFunction<T>\n\n return () => {\n debouncedRef.current?.cancel()\n }\n }, [fn, ms, maxWait])\n\n const callback = useCallback((...args: Parameters<T>) => {\n if (debouncedRef.current) {\n debouncedRef.current(...args)\n }\n }, [])\n\n return callback\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAE/C,OAAOC,QAAA,MAAc;AAQrB,OAAO,SAAAC,YAAAC,EAAA,EAAAC,EAAA,EAAAC,OAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAML,MAAAU,YAAA,GAAqBP,MAAA,
|
|
1
|
+
{"version":3,"file":"useDebounce.js","names":["c","_c","useCallback","useEffect","useRef","debounce","useDebounce","fn","ms","maxWait","$","debouncedRef","t0","t1","current","cancel","t2","Symbol","for","t3","args","callback"],"sources":["../../../../../src/features/table/client/utils/useDebounce.ts"],"sourcesContent":["'use client'\nimport { useCallback, useEffect, useRef } from 'react'\n\nimport debounce from './debounce.js'\n\n// Define the type for debounced function that includes cancel method\ninterface DebouncedFunction<T extends (...args: any[]) => any> {\n (...args: Parameters<T>): ReturnType<T>\n cancel: () => void\n}\n\nexport function useDebounce<T extends (...args: never[]) => void>(\n fn: T,\n ms: number,\n maxWait?: number,\n) {\n // Update the ref type to include cancel method\n const debouncedRef = useRef<DebouncedFunction<T> | null>(null)\n\n useEffect(() => {\n debouncedRef.current = debounce(fn, ms, { maxWait }) as DebouncedFunction<T>\n\n return () => {\n debouncedRef.current?.cancel()\n }\n }, [fn, ms, maxWait])\n\n const callback = useCallback((...args: Parameters<T>) => {\n if (debouncedRef.current) {\n debouncedRef.current(...args)\n }\n }, [])\n\n return callback\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAQ;AAE/C,OAAOC,QAAA,MAAc;AAQrB,OAAO,SAAAC,YAAAC,EAAA,EAAAC,EAAA,EAAAC,OAAA;EAAA,MAAAC,CAAA,GAAAT,EAAA;EAML,MAAAU,YAAA,GAAqBP,MAAA,CAAoC;EAAA,IAAAQ,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAH,CAAA,QAAAH,EAAA,IAAAG,CAAA,QAAAD,OAAA,IAAAC,CAAA,QAAAF,EAAA;IAE/CI,EAAA,GAAAA,CAAA;MACRD,YAAA,CAAAG,OAAA,GAAuBT,QAAA,CAASE,EAAA,EAAIC,EAAA,EAAI;QAAAC;MAAU,EAA9B;MAAA,OAEb;QACLE,YAAA,CAAAG,OAAsB,EAAAC,MAAA;MAAA,CACxB;IAAA,CACF;IAAGF,EAAA,IAACN,EAAA,EAAIC,EAAA,EAAIC,OAAA,CAAQ;IAAAC,CAAA,MAAAH,EAAA;IAAAG,CAAA,MAAAD,OAAA;IAAAC,CAAA,MAAAF,EAAA;IAAAE,CAAA,MAAAE,EAAA;IAAAF,CAAA,MAAAG,EAAA;EAAA;IAAAD,EAAA,GAAAF,CAAA;IAAAG,EAAA,GAAAH,CAAA;EAAA;EANpBP,SAAA,CAAUS,EAMV,EAAGC,EAAiB;EAAA,IAAAG,EAAA;EAAA,IAAAN,CAAA,QAAAO,MAAA,CAAAC,GAAA;IAESF,EAAA,GAAAA,CAAA,GAAAG,EAAA;MAAC,MAAAC,IAAA,GAAAD,EAAG;MAC/B,IAAIR,YAAA,CAAAG,OAAoB;QACtBH,YAAA,CAAAG,OAAoB,IAAIM,IAAA;MAAA;IAC1B,CACF;IAAAV,CAAA,MAAAM,EAAA;EAAA;IAAAA,EAAA,GAAAN,CAAA;EAAA;EAJA,MAAAW,QAAA,GAAiBL,EAIZ;EAAA,OAEEK,QAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"horizontalWheelScroll.js","names":["c","_c","useEffect","scrollContainerSelector","PIXELS_PER_LINE","getHorizontalScrollDelta","clientWidth","deltaMode","deltaY","isRightToLeft","deltaInPixels","redirectVerticalWheelToHorizontalScroll","event","isPrimarilyVerticalWheelInput","Math","abs","deltaX","target","Element","scrollContainer","closest","canScrollHorizontally","scrollWidth","preventDefault","scrollLeft","getComputedStyle","direction","toolbarsListeningForWheelEvents","useRedirectVerticalWheelToHorizontalScroll","$","t0","Symbol","for","_temp2","document","addEventListener","passive","_temp","removeEventListener"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.ts"],"sourcesContent":["'use client'\nimport { useEffect } from 'react'\n\nconst scrollContainerSelector = '.fixed-toolbar__scroll'\n\n// A single notch on a classic (non-trackpad) wheel mouse reports deltaMode 1 with a\n// deltaY of only 1-3, so it must be scaled up to a pixel value that actually moves the scroll.\nconst PIXELS_PER_LINE = 40\n\nexport function getHorizontalScrollDelta({\n clientWidth,\n deltaMode,\n deltaY,\n isRightToLeft,\n}: {\n clientWidth: number\n deltaMode: number\n deltaY: number\n isRightToLeft: boolean\n}): number {\n const deltaInPixels =\n deltaMode === 1 ? deltaY * PIXELS_PER_LINE : deltaMode === 2 ? deltaY * clientWidth : deltaY\n\n // scrollLeft moves toward the inline-start edge for a given positive delta in RTL,\n // the opposite of LTR, so the delta must be negated to keep the scroll direction consistent.\n return isRightToLeft ? -deltaInPixels : deltaInPixels\n}\n\nfunction redirectVerticalWheelToHorizontalScroll(event: WheelEvent): void {\n const isPrimarilyVerticalWheelInput = Math.abs(event.deltaY) > Math.abs(event.deltaX)\n if (!isPrimarilyVerticalWheelInput) {\n return\n }\n\n const target = event.target\n if (!(target instanceof Element)) {\n return\n }\n\n const scrollContainer = target.closest<HTMLElement>(scrollContainerSelector)\n if (!scrollContainer) {\n return\n }\n\n const canScrollHorizontally = scrollContainer.scrollWidth > scrollContainer.clientWidth\n if (!canScrollHorizontally) {\n return\n }\n\n event.preventDefault()\n scrollContainer.scrollLeft += getHorizontalScrollDelta({\n clientWidth: scrollContainer.clientWidth,\n deltaMode: event.deltaMode,\n deltaY: event.deltaY,\n isRightToLeft: getComputedStyle(scrollContainer).direction === 'rtl',\n })\n}\n\n// A single page can render many fixed toolbars at once (e.g. rich text nested several\n// layers deep inside blocks), so this listener is delegated to `document` and shared\n// across every toolbar instance instead of being attached per instance. A wheel listener\n// that can call preventDefault() must be non-passive, and non-passive listeners make the\n// browser treat their element as a \"non-fast-scrollable region\" that every scroll gesture\n// on the page has to be checked against, even ones nowhere near it. Attaching one instance\n// per toolbar would multiply that bookkeeping by however many toolbars happen to be on the\n// page; a single delegated listener keeps that cost constant no matter how many there are.\nlet toolbarsListeningForWheelEvents = 0\n\nexport function useRedirectVerticalWheelToHorizontalScroll(): void {\n useEffect(() => {\n if (toolbarsListeningForWheelEvents === 0) {\n document.addEventListener('wheel', redirectVerticalWheelToHorizontalScroll, {\n passive: false,\n })\n }\n toolbarsListeningForWheelEvents += 1\n\n return () => {\n toolbarsListeningForWheelEvents -= 1\n if (toolbarsListeningForWheelEvents === 0) {\n document.removeEventListener('wheel', redirectVerticalWheelToHorizontalScroll)\n }\n }\n }, [])\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CA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BAAA,GAAkC;AAEtC,OAAO,SAAAC,2CAAA;EAAA,MAAAC,CAAA,GAAA5B,EAAA;EAAA,IAAA6B,EAAA;EAAA,IAAAD,CAAA,QAAAE,MAAA,CAAAC,GAAA;IAeFF,EAAA;
|
|
1
|
+
{"version":3,"file":"horizontalWheelScroll.js","names":["c","_c","useEffect","scrollContainerSelector","PIXELS_PER_LINE","getHorizontalScrollDelta","clientWidth","deltaMode","deltaY","isRightToLeft","deltaInPixels","redirectVerticalWheelToHorizontalScroll","event","isPrimarilyVerticalWheelInput","Math","abs","deltaX","target","Element","scrollContainer","closest","canScrollHorizontally","scrollWidth","preventDefault","scrollLeft","getComputedStyle","direction","toolbarsListeningForWheelEvents","useRedirectVerticalWheelToHorizontalScroll","$","t0","Symbol","for","_temp2","document","addEventListener","passive","_temp","removeEventListener"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/horizontalWheelScroll.ts"],"sourcesContent":["'use client'\nimport { useEffect } from 'react'\n\nconst scrollContainerSelector = '.fixed-toolbar__scroll'\n\n// A single notch on a classic (non-trackpad) wheel mouse reports deltaMode 1 with a\n// deltaY of only 1-3, so it must be scaled up to a pixel value that actually moves the scroll.\nconst PIXELS_PER_LINE = 40\n\nexport function getHorizontalScrollDelta({\n clientWidth,\n deltaMode,\n deltaY,\n isRightToLeft,\n}: {\n clientWidth: number\n deltaMode: number\n deltaY: number\n isRightToLeft: boolean\n}): number {\n const deltaInPixels =\n deltaMode === 1 ? deltaY * PIXELS_PER_LINE : deltaMode === 2 ? deltaY * clientWidth : deltaY\n\n // scrollLeft moves toward the inline-start edge for a given positive delta in RTL,\n // the opposite of LTR, so the delta must be negated to keep the scroll direction consistent.\n return isRightToLeft ? -deltaInPixels : deltaInPixels\n}\n\nfunction redirectVerticalWheelToHorizontalScroll(event: WheelEvent): void {\n const isPrimarilyVerticalWheelInput = Math.abs(event.deltaY) > Math.abs(event.deltaX)\n if (!isPrimarilyVerticalWheelInput) {\n return\n }\n\n const target = event.target\n if (!(target instanceof Element)) {\n return\n }\n\n const scrollContainer = target.closest<HTMLElement>(scrollContainerSelector)\n if (!scrollContainer) {\n return\n }\n\n const canScrollHorizontally = scrollContainer.scrollWidth > scrollContainer.clientWidth\n if (!canScrollHorizontally) {\n return\n }\n\n event.preventDefault()\n scrollContainer.scrollLeft += getHorizontalScrollDelta({\n clientWidth: scrollContainer.clientWidth,\n deltaMode: event.deltaMode,\n deltaY: event.deltaY,\n isRightToLeft: getComputedStyle(scrollContainer).direction === 'rtl',\n })\n}\n\n// A single page can render many fixed toolbars at once (e.g. rich text nested several\n// layers deep inside blocks), so this listener is delegated to `document` and shared\n// across every toolbar instance instead of being attached per instance. A wheel listener\n// that can call preventDefault() must be non-passive, and non-passive listeners make the\n// browser treat their element as a \"non-fast-scrollable region\" that every scroll gesture\n// on the page has to be checked against, even ones nowhere near it. Attaching one instance\n// per toolbar would multiply that bookkeeping by however many toolbars happen to be on the\n// page; a single delegated listener keeps that cost constant no matter how many there are.\nlet toolbarsListeningForWheelEvents = 0\n\nexport function useRedirectVerticalWheelToHorizontalScroll(): void {\n useEffect(() => {\n if (toolbarsListeningForWheelEvents === 0) {\n document.addEventListener('wheel', redirectVerticalWheelToHorizontalScroll, {\n passive: false,\n })\n }\n toolbarsListeningForWheelEvents += 1\n\n return () => {\n toolbarsListeningForWheelEvents -= 1\n if (toolbarsListeningForWheelEvents === 0) {\n document.removeEventListener('wheel', redirectVerticalWheelToHorizontalScroll)\n }\n }\n }, [])\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,SAAS,QAAQ;AAE1B,MAAMC,uBAAA,GAA0B;AAEhC;AACA;AACA,MAAMC,eAAA,GAAkB;AAExB,OAAO,SAASC,yBAAyB;EACvCC,WAAW;EACXC,SAAS;EACTC,MAAM;EACNC;AAAa,CAMd;EACC,MAAMC,aAAA,GACJH,SAAA,KAAc,IAAIC,MAAA,GAASJ,eAAA,GAAkBG,SAAA,KAAc,IA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AfA,SAAAG,OAAA;EAEH,IAAIN,+BAAA,KAAoC;IACtCO,QAAA,CAAAC,gBAAyB,CAAC,SAASxB,uCAAA,EAAyC;MAAAyB,OAAA,EACjE;IACX;EAAA;EAEFT,+BAAA,GAAAA,+BAAA,GAAmC;EAAA,OAE5BU,KAKP;AAAA;AAdG,SAAAA,MAAA;EAUDV,+BAAA,GAAAA,+BAAA,GAAmC;EACnC,IAAIA,+BAAA,KAAoC;IACtCO,QAAA,CAAAI,mBAA4B,CAAC,SAAS3B,uCAAA;EAAA;AACxC","ignoreList":[]}
|
|
@@ -40,85 +40,141 @@ function ButtonGroupItem({
|
|
|
40
40
|
children: /*#__PURE__*/_jsx(item.ChildComponent, {})
|
|
41
41
|
}, item.key);
|
|
42
42
|
}
|
|
43
|
-
function ToolbarGroupComponent({
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
function ToolbarGroupComponent(t0) {
|
|
44
|
+
const $ = _c(22);
|
|
45
|
+
const {
|
|
46
|
+
anchorElem,
|
|
47
|
+
editor,
|
|
48
|
+
editorConfig,
|
|
49
|
+
group,
|
|
50
|
+
index,
|
|
51
|
+
toolbarStates
|
|
52
|
+
} = t0;
|
|
51
53
|
const {
|
|
52
54
|
i18n
|
|
53
55
|
} = useTranslation();
|
|
54
56
|
const {
|
|
55
|
-
fieldProps:
|
|
56
|
-
featureClientSchemaMap,
|
|
57
|
-
schemaPath
|
|
58
|
-
}
|
|
57
|
+
fieldProps: t1
|
|
59
58
|
} = useEditorConfigContext();
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
const {
|
|
60
|
+
featureClientSchemaMap,
|
|
61
|
+
schemaPath
|
|
62
|
+
} = t1;
|
|
63
|
+
let t2;
|
|
64
|
+
if ($[0] !== group.key || $[1] !== toolbarStates.groupStates) {
|
|
65
|
+
t2 = toolbarStates.groupStates.get(group.key);
|
|
66
|
+
$[0] = group.key;
|
|
67
|
+
$[1] = toolbarStates.groupStates;
|
|
68
|
+
$[2] = t2;
|
|
69
|
+
} else {
|
|
70
|
+
t2 = $[2];
|
|
71
|
+
}
|
|
72
|
+
const groupState = t2;
|
|
73
|
+
groupState?.activeItems;
|
|
74
|
+
let t3;
|
|
75
|
+
bb0: {
|
|
76
|
+
if (group.type !== "dropdown") {
|
|
77
|
+
t3 = undefined;
|
|
78
|
+
break bb0;
|
|
64
79
|
}
|
|
65
80
|
const activeItem = groupState?.activeItems?.[0];
|
|
66
81
|
if (activeItem) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return group.ChildComponent;
|
|
70
|
-
}, [group, groupState?.activeItems]);
|
|
71
|
-
const dropdownLabel = useMemo(() => {
|
|
72
|
-
if (group.type !== 'dropdown') {
|
|
73
|
-
return undefined;
|
|
74
|
-
}
|
|
75
|
-
const activeItems = groupState?.activeItems;
|
|
76
|
-
if (!activeItems?.length) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
if (activeItems.length > 1) {
|
|
80
|
-
return i18n.t('lexical:general:toolbarItemsActive', {
|
|
81
|
-
count: activeItems.length
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
const item = activeItems[0];
|
|
85
|
-
let label = item.key;
|
|
86
|
-
if (item.label) {
|
|
87
|
-
label = typeof item.label === 'function' ? item.label({
|
|
88
|
-
featureClientSchemaMap,
|
|
89
|
-
i18n,
|
|
90
|
-
schemaPath
|
|
91
|
-
}) : item.label;
|
|
92
|
-
}
|
|
93
|
-
if (label.length > 25) {
|
|
94
|
-
label = label.substring(0, 25) + '...';
|
|
82
|
+
t3 = activeItem.ChildComponent;
|
|
83
|
+
break bb0;
|
|
95
84
|
}
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
85
|
+
t3 = group.ChildComponent;
|
|
86
|
+
}
|
|
87
|
+
const DropdownIcon = t3;
|
|
88
|
+
let t4;
|
|
89
|
+
if ($[3] !== featureClientSchemaMap || $[4] !== group.type || $[5] !== groupState?.activeItems || $[6] !== i18n || $[7] !== schemaPath) {
|
|
90
|
+
t4 = () => {
|
|
91
|
+
if (group.type !== "dropdown") {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
const activeItems = groupState?.activeItems;
|
|
95
|
+
if (!activeItems?.length) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (activeItems.length > 1) {
|
|
99
|
+
return i18n.t("lexical:general:toolbarItemsActive", {
|
|
100
|
+
count: activeItems.length
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
const item = activeItems[0];
|
|
104
|
+
let label = item.key;
|
|
105
|
+
if (item.label) {
|
|
106
|
+
label = typeof item.label === "function" ? item.label({
|
|
107
|
+
featureClientSchemaMap,
|
|
108
|
+
i18n,
|
|
109
|
+
schemaPath
|
|
110
|
+
}) : item.label;
|
|
111
|
+
}
|
|
112
|
+
if (label.length > 25) {
|
|
113
|
+
label = label.substring(0, 25) + "...";
|
|
114
|
+
}
|
|
115
|
+
return label;
|
|
116
|
+
};
|
|
117
|
+
$[3] = featureClientSchemaMap;
|
|
118
|
+
$[4] = group.type;
|
|
119
|
+
$[5] = groupState?.activeItems;
|
|
120
|
+
$[6] = i18n;
|
|
121
|
+
$[7] = schemaPath;
|
|
122
|
+
$[8] = t4;
|
|
123
|
+
} else {
|
|
124
|
+
t4 = $[8];
|
|
125
|
+
}
|
|
126
|
+
groupState?.activeItems;
|
|
127
|
+
let t5;
|
|
128
|
+
if ($[9] !== t4) {
|
|
129
|
+
t5 = t4();
|
|
130
|
+
$[9] = t4;
|
|
131
|
+
$[10] = t5;
|
|
132
|
+
} else {
|
|
133
|
+
t5 = $[10];
|
|
134
|
+
}
|
|
135
|
+
const dropdownLabel = t5;
|
|
136
|
+
const t6 = `fixed-toolbar__group fixed-toolbar__group-${group.key}`;
|
|
137
|
+
let t7;
|
|
138
|
+
if ($[11] !== DropdownIcon || $[12] !== anchorElem || $[13] !== dropdownLabel || $[14] !== editor || $[15] !== editorConfig.features.toolbarFixed?.groups.length || $[16] !== group || $[17] !== groupState || $[18] !== index || $[19] !== t6 || $[20] !== toolbarStates.itemStates) {
|
|
139
|
+
t7 = _jsxs("div", {
|
|
140
|
+
className: t6,
|
|
141
|
+
"data-toolbar-group-key": group.key,
|
|
142
|
+
children: [group.type === "dropdown" && group.items.length && groupState ? _jsx(ToolbarDropdown, {
|
|
143
|
+
anchorElem,
|
|
144
|
+
editor,
|
|
145
|
+
group,
|
|
146
|
+
groupState,
|
|
147
|
+
Icon: DropdownIcon,
|
|
148
|
+
itemsContainerClassNames: ["fixed-toolbar__dropdown-items"],
|
|
149
|
+
label: dropdownLabel
|
|
150
|
+
}) : null, group.type === "buttons" && group.items.length ? group.items.map(item_0 => {
|
|
151
|
+
const itemState = toolbarStates.itemStates.get(item_0.key);
|
|
152
|
+
return _jsx(ButtonGroupItem, {
|
|
153
|
+
active: itemState?.active ?? false,
|
|
154
|
+
anchorElem,
|
|
155
|
+
editor,
|
|
156
|
+
enabled: itemState?.enabled ?? true,
|
|
157
|
+
item: item_0
|
|
158
|
+
}, item_0.key);
|
|
159
|
+
}) : null, index < editorConfig.features.toolbarFixed?.groups.length - 1 && _jsx("div", {
|
|
160
|
+
className: "divider"
|
|
161
|
+
})]
|
|
162
|
+
}, group.key);
|
|
163
|
+
$[11] = DropdownIcon;
|
|
164
|
+
$[12] = anchorElem;
|
|
165
|
+
$[13] = dropdownLabel;
|
|
166
|
+
$[14] = editor;
|
|
167
|
+
$[15] = editorConfig.features.toolbarFixed?.groups.length;
|
|
168
|
+
$[16] = group;
|
|
169
|
+
$[17] = groupState;
|
|
170
|
+
$[18] = index;
|
|
171
|
+
$[19] = t6;
|
|
172
|
+
$[20] = toolbarStates.itemStates;
|
|
173
|
+
$[21] = t7;
|
|
174
|
+
} else {
|
|
175
|
+
t7 = $[21];
|
|
176
|
+
}
|
|
177
|
+
return t7;
|
|
122
178
|
}
|
|
123
179
|
function FixedToolbar({
|
|
124
180
|
anchorElem,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","getTranslation","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarKeyboardNavigation","useToolbarStates","useRedirectVerticalWheelToHorizontalScroll","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","editorConfig","group","index","toolbarStates","i18n","fieldProps","featureClientSchemaMap","schemaPath","groupState","groupStates","get","DropdownIcon","type","undefined","activeItem","activeItems","dropdownLabel","length","t","count","label","substring","_jsxs","className","items","Icon","itemsContainerClassNames","map","itemState","itemStates","features","toolbarFixed","groups","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","keyboardNavigationOptions","toolbarRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","field","path","onFocus","event","stopPropagation","ref","role","tabIndex","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","t0","$","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","t1","t2","Symbol","for","bb0","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled: boolean\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n if (activeItem) {\n return activeItem.ChildComponent\n }\n return group.ChildComponent\n }, [group, groupState?.activeItems])\n\n const dropdownLabel = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItems = groupState?.activeItems\n if (!activeItems?.length) {\n return undefined\n }\n if (activeItems.length > 1) {\n return i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length })\n }\n const item = activeItems[0]!\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n return label\n }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath])\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const keyboardNavigationOptions = useMemo(() => ({ toolbarRef: currentToolbarRef }), [])\n const { fieldProps } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n useToolbarKeyboardNavigation(keyboardNavigationOptions)\n\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n useRedirectVerticalWheelToHorizontalScroll()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups)\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n aria-label={\n getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path\n }\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n role=\"toolbar\"\n >\n {isEditable && (\n <div className=\"fixed-toolbar__scroll\" tabIndex={-1}>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n clientProps={clientProps}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AASxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SAASC,4BAA4B,QAAQ;AAC7C,SAASC,gBAAgB,QAAQ;AACjC,SAASC,0CAA0C,QAAQ;AAC3D,OAAO;AAEP,SAASC,gBAAgB;EACvBC,MAAM;EACNC,UAAU;EACVC,MAAM;EACNC,OAAO;EACPC;AAAI,CAOL;EACC,IAAIA,IAAA,CAAKC,SAAS,EAAE;IAClB,OACED,IAAA,EAAMC,SAAA,iBACJC,IAAA,CAACF,IAAA,CAAKC,SAAS;MAACJ,UAAA,EAAYA,UAAA;MAAYC,MAAA,EAAQA,MAAA;MAAQE,IAAA,EAAMA;OAAWA,IAAA,CAAKG,GAAG;EAGvF;EAEA,IAAI,CAACH,IAAA,CAAKI,cAAc,EAAE;IACxB,OAAO;EACT;EAEA,oBACEF,IAAA,CAACZ,aAAA;IAAcM,MAAA,EAAQA,MAAA;IAAQE,MAAA,EAAQA,MAAA;IAAQC,OAAA,EA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AA,GACXT,mBAAA,CAAAU,aAAA,EAAAxF,MAAA,IAA6CqF,aAAA,GAC7CA,aAAA;EAEJ,MAAA7E,YAAA,GAAqBkC,WAAA,CAAA6C,oBAAA,GACjBT,mBAAA,CAAAU,aAAA,EAAAhF,YAAA,IAAmD8E,mBAAA,GACnDA,mBAAA;EAAA,IAAAG,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAN,CAAA,QAAA1C,WAAA,IAAA0C,CAAA,QAAApF,MAAA,IAAAoF,CAAA,QAAA5E,YAAA,IAAA4E,CAAA,QAAAN,mBAAA;IAMOY,EAAA,GAAAC,MAAA,CAAAC,GAAA;IAAAC,GAAA;MAJX,MAAAlD,sBAAA,GAA+BkC,+BAAA,CAAgCC,mBAAA;MAAA,IAE3DpC,WAAA,EAAAS,8BAAA;QAAA,IACER,sBAAA;UACK+C,EAAA;UAAA,MAAAG,GAAA;QAAA;MAAA;MAAA,KAINrF,YAAA,EAAA8B,QAAA,EAAAC,YAAA,EAAAC,MAAA,EAAAf,MAAA;QACIiE,EAAA;QAAA,MAAAG,GAAA;MAAA;MAIPJ,EAAA,GAAArF,IAAA,CAAAqC,YAAA;QAAA1C,UAAA,EAAA+F,QAAA,CAAAC,IAAA;QAAArD,WAAA;QAAA1C,MAAA;QAAAQ,YAAA;QAAAmC;MAAA,C;;;;;;;;;;;;;;;SAAA8C,E;CAQJ","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useLexicalEditable","getTranslation","useScrollInfo","useThrottledEffect","useTranslation","React","useMemo","useEditorConfigContext","ToolbarButton","ToolbarDropdown","useToolbarKeyboardNavigation","useToolbarStates","useRedirectVerticalWheelToHorizontalScroll","ButtonGroupItem","active","anchorElem","editor","enabled","item","Component","_jsx","key","ChildComponent","ToolbarGroupComponent","t0","$","editorConfig","group","index","toolbarStates","i18n","fieldProps","t1","featureClientSchemaMap","schemaPath","t2","groupStates","get","groupState","activeItems","t3","bb0","type","undefined","activeItem","DropdownIcon","t4","length","t","count","label","substring","t5","dropdownLabel","t6","t7","features","toolbarFixed","groups","itemStates","_jsxs","className","children","items","Icon","itemsContainerClassNames","map","item_0","itemState","FixedToolbar","clientProps","parentWithFixedToolbar","currentToolbarRef","useRef","keyboardNavigationOptions","toolbarRef","isEditable","y","parentToolbarElem","disableIfParentHasFixedToolbar","parentEditorElem","editorContainerRef","current","sibling","previousElementSibling","classList","contains","currentToolbarElem","currentRect","getBoundingClientRect","parentRect","overlapping","bottom","top","remove","add","field","path","onFocus","event","stopPropagation","ref","role","tabIndex","i","getParentEditorWithFixedToolbar","editorConfigContext","parentEditor","resolvedFeatureMap","has","FixedToolbarPlugin","currentEditor","currentEditorConfig","applyToFocusedEditor","focusedEditor","Symbol","for","document","body"],"sources":["../../../../../../src/features/toolbars/fixed/client/Toolbar/index.tsx"],"sourcesContent":["'use client'\nimport type { LexicalEditor } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport { useScrollInfo, useThrottledEffect, useTranslation } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { useMemo } from 'react'\n\nimport type { EditorConfigContextType } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport type { SanitizedClientEditorConfig } from '../../../../../lexical/config/types.js'\nimport type { PluginComponent } from '../../../../typesClient.js'\nimport type { ToolbarStates } from '../../../shared/useToolbarStates.js'\nimport type { ToolbarGroup, ToolbarGroupItem } from '../../../types.js'\nimport type { FixedToolbarFeatureProps } from '../../server/index.js'\n\nimport { useEditorConfigContext } from '../../../../../lexical/config/client/EditorConfigProvider.js'\nimport { ToolbarButton } from '../../../shared/ToolbarButton/index.js'\nimport { ToolbarDropdown } from '../../../shared/ToolbarDropdown/index.js'\nimport { useToolbarKeyboardNavigation } from '../../../shared/useToolbarKeyboardNavigation.js'\nimport { useToolbarStates } from '../../../shared/useToolbarStates.js'\nimport { useRedirectVerticalWheelToHorizontalScroll } from './horizontalWheelScroll.js'\nimport './index.css'\n\nfunction ButtonGroupItem({\n active,\n anchorElem,\n editor,\n enabled,\n item,\n}: {\n active: boolean\n anchorElem: HTMLElement\n editor: LexicalEditor\n enabled: boolean\n item: ToolbarGroupItem\n}): React.ReactNode {\n if (item.Component) {\n return (\n item?.Component && (\n <item.Component anchorElem={anchorElem} editor={editor} item={item} key={item.key} />\n )\n )\n }\n\n if (!item.ChildComponent) {\n return null\n }\n\n return (\n <ToolbarButton active={active} editor={editor} enabled={enabled} item={item} key={item.key}>\n <item.ChildComponent />\n </ToolbarButton>\n )\n}\n\nfunction ToolbarGroupComponent({\n anchorElem,\n editor,\n editorConfig,\n group,\n index,\n toolbarStates,\n}: {\n anchorElem: HTMLElement\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n group: ToolbarGroup\n index: number\n toolbarStates: ToolbarStates\n}): React.ReactNode {\n const { i18n } = useTranslation<{}, string>()\n const {\n fieldProps: { featureClientSchemaMap, schemaPath },\n } = useEditorConfigContext()\n\n const groupState = toolbarStates.groupStates.get(group.key)\n\n const DropdownIcon = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItem = groupState?.activeItems?.[0]\n if (activeItem) {\n return activeItem.ChildComponent\n }\n return group.ChildComponent\n }, [group, groupState?.activeItems])\n\n const dropdownLabel = useMemo(() => {\n if (group.type !== 'dropdown') {\n return undefined\n }\n const activeItems = groupState?.activeItems\n if (!activeItems?.length) {\n return undefined\n }\n if (activeItems.length > 1) {\n return i18n.t('lexical:general:toolbarItemsActive', { count: activeItems.length })\n }\n const item = activeItems[0]!\n let label = item.key\n if (item.label) {\n label =\n typeof item.label === 'function'\n ? item.label({ featureClientSchemaMap, i18n, schemaPath })\n : item.label\n }\n if (label.length > 25) {\n label = label.substring(0, 25) + '...'\n }\n return label\n }, [group, groupState?.activeItems, i18n, featureClientSchemaMap, schemaPath])\n\n return (\n <div\n className={`fixed-toolbar__group fixed-toolbar__group-${group.key}`}\n data-toolbar-group-key={group.key}\n key={group.key}\n >\n {group.type === 'dropdown' && group.items.length && groupState ? (\n <ToolbarDropdown\n anchorElem={anchorElem}\n editor={editor}\n group={group}\n groupState={groupState}\n Icon={DropdownIcon}\n itemsContainerClassNames={['fixed-toolbar__dropdown-items']}\n label={dropdownLabel}\n />\n ) : null}\n {group.type === 'buttons' && group.items.length\n ? group.items.map((item) => {\n const itemState = toolbarStates.itemStates.get(item.key)\n return (\n <ButtonGroupItem\n active={itemState?.active ?? false}\n anchorElem={anchorElem}\n editor={editor}\n enabled={itemState?.enabled ?? true}\n item={item}\n key={item.key}\n />\n )\n })\n : null}\n {index < editorConfig.features.toolbarFixed?.groups.length - 1 && <div className=\"divider\" />}\n </div>\n )\n}\n\nfunction FixedToolbar({\n anchorElem,\n clientProps,\n editor,\n editorConfig,\n parentWithFixedToolbar,\n}: {\n anchorElem: HTMLElement\n clientProps?: FixedToolbarFeatureProps\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n parentWithFixedToolbar: EditorConfigContextType | false\n}): React.ReactNode {\n const currentToolbarRef = React.useRef<HTMLDivElement>(null)\n const keyboardNavigationOptions = useMemo(() => ({ toolbarRef: currentToolbarRef }), [])\n const { fieldProps } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n useToolbarKeyboardNavigation(keyboardNavigationOptions)\n\n const isEditable = useLexicalEditable()\n\n const { y } = useScrollInfo()\n\n useRedirectVerticalWheelToHorizontalScroll()\n\n const toolbarStates = useToolbarStates(editor, editorConfig?.features?.toolbarFixed?.groups)\n\n // Memoize the parent toolbar element\n const parentToolbarElem = useMemo(() => {\n if (!parentWithFixedToolbar || clientProps?.disableIfParentHasFixedToolbar) {\n return null\n }\n\n const parentEditorElem = parentWithFixedToolbar.editorContainerRef.current\n let sibling = parentEditorElem.previousElementSibling\n while (sibling) {\n if (sibling.classList.contains('fixed-toolbar')) {\n return sibling\n }\n sibling = sibling.previousElementSibling\n }\n return null\n }, [clientProps?.disableIfParentHasFixedToolbar, parentWithFixedToolbar])\n\n useThrottledEffect(\n () => {\n if (!parentToolbarElem) {\n // this also checks for clientProps?.disableIfParentHasFixedToolbar indirectly, see the parentToolbarElem useMemo\n return\n }\n const currentToolbarElem = currentToolbarRef.current\n if (!currentToolbarElem) {\n return\n }\n\n const currentRect = currentToolbarElem.getBoundingClientRect()\n const parentRect = parentToolbarElem.getBoundingClientRect()\n\n // we only need to check for vertical overlap\n const overlapping = !(\n currentRect.bottom < parentRect.top || currentRect.top > parentRect.bottom\n )\n\n if (overlapping) {\n currentToolbarElem.classList.remove('fixed-toolbar')\n currentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--overlapping')\n parentToolbarElem.classList.remove('fixed-toolbar')\n parentToolbarElem.classList.add('fixed-toolbar', 'fixed-toolbar--hide')\n } else {\n if (!currentToolbarElem.classList.contains('fixed-toolbar--overlapping')) {\n return\n }\n currentToolbarElem.classList.remove('fixed-toolbar--overlapping')\n currentToolbarElem.classList.add('fixed-toolbar')\n parentToolbarElem.classList.remove('fixed-toolbar--hide')\n parentToolbarElem.classList.add('fixed-toolbar')\n }\n },\n 50,\n [currentToolbarRef, parentToolbarElem, y],\n )\n\n return (\n <div\n aria-label={\n getTranslation(fieldProps.field.label || fieldProps.path, i18n) || fieldProps.path\n }\n className=\"fixed-toolbar\"\n onFocus={(event) => {\n // Prevent other focus events being triggered. Otherwise, if this was to be clicked while in a child editor,\n // the parent editor will be focused, and the child editor will lose focus.\n event.stopPropagation()\n }}\n ref={currentToolbarRef}\n role=\"toolbar\"\n >\n {isEditable && (\n <div className=\"fixed-toolbar__scroll\" tabIndex={-1}>\n {editorConfig?.features &&\n editorConfig.features?.toolbarFixed?.groups.map((group, i) => {\n return (\n <ToolbarGroupComponent\n anchorElem={anchorElem}\n editor={editor}\n editorConfig={editorConfig}\n group={group}\n index={i}\n key={group.key}\n toolbarStates={toolbarStates}\n />\n )\n })}\n </div>\n )}\n </div>\n )\n}\n\nconst getParentEditorWithFixedToolbar = (\n editorConfigContext: EditorConfigContextType,\n): EditorConfigContextType | false => {\n if (editorConfigContext.parentEditor?.editorConfig) {\n if (editorConfigContext.parentEditor?.editorConfig.resolvedFeatureMap.has('toolbarFixed')) {\n return editorConfigContext.parentEditor\n } else {\n if (editorConfigContext.parentEditor) {\n return getParentEditorWithFixedToolbar(editorConfigContext.parentEditor)\n }\n }\n }\n return false\n}\n\nexport const FixedToolbarPlugin: PluginComponent<FixedToolbarFeatureProps> = ({ clientProps }) => {\n const [currentEditor] = useLexicalComposerContext()\n const editorConfigContext = useEditorConfigContext()\n const isEditable = useLexicalEditable()\n if (!isEditable) {\n return null\n }\n\n const { editorConfig: currentEditorConfig } = editorConfigContext\n\n const editor = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editor || currentEditor\n : currentEditor\n\n const editorConfig = clientProps.applyToFocusedEditor\n ? editorConfigContext.focusedEditor?.editorConfig || currentEditorConfig\n : currentEditorConfig\n\n const parentWithFixedToolbar = getParentEditorWithFixedToolbar(editorConfigContext)\n\n if (clientProps?.disableIfParentHasFixedToolbar) {\n if (parentWithFixedToolbar) {\n return null\n }\n }\n\n if (!editorConfig?.features?.toolbarFixed?.groups?.length) {\n return null\n }\n\n return (\n <FixedToolbar\n anchorElem={document.body}\n clientProps={clientProps}\n editor={editor}\n editorConfig={editorConfig}\n parentWithFixedToolbar={parentWithFixedToolbar}\n />\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAGA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,EAAEC,kBAAkB,EAAEC,cAAc,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,OAAO,QAAQ;AASxB,SAASC,sBAAsB,QAAQ;AACvC,SAASC,aAAa,QAAQ;AAC9B,SAASC,eAAe,QAAQ;AAChC,SA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AA,GAAqB4C,WAAA,CAAA2C,oBAEjB,GADAP,mBAAA,CAAAQ,aAAmC,EAAAxF,YAAgB,IAAnDsF,mBACA,GAFiBA,mBAEjB;EAAA,IAAAhF,EAAA;EAAA,IAAAG,EAAA;EAAA,IAAAV,CAAA,QAAA6C,WAAA,IAAA7C,CAAA,QAAAT,MAAA,IAAAS,CAAA,QAAAC,YAAA,IAAAD,CAAA,QAAAiF,mBAAA;IAMOvE,EAAA,GAAAgF,MAAA,CAAAC,GAAA;IAAA3E,GAAA;MAJX,MAAA8B,sBAAA,GAA+BkC,+BAAA,CAAgCC,mBAAA;MAE/D,IAAIpC,WAAA,EAAAS,8BAAa;QACf,IAAIR,sBAAA;UACKpC,EAAA;UAAA,MAAAM,GAAA;QAAA;MACT;MAGF,IAAI,CAACf,YAAA,EAAA8B,QAAwB,EAAAC,YAAc,EAAAC,MAAQ,EAAAX,MAAA;QAC1CZ,EAAA;QAAA,MAAAM,GAAA;MAAA;MAIPT,EAAA,GAAAZ,IAAA,CAACiD,YAAA;QAAAtD,UAAA,EACasG,QAAA,CAAAC,IAAa;QAAAhD,WAAA;QAAAtD,MAAA;QAAAU,YAAA;QAAA6C;;;;;;;;;;;;;;;;SAD3BvC,E;CAQJ","ignoreList":[]}
|
|
@@ -44,46 +44,78 @@ function ButtonGroupItem({
|
|
|
44
44
|
children: /*#__PURE__*/_jsx(item.ChildComponent, {})
|
|
45
45
|
}, item.key);
|
|
46
46
|
}
|
|
47
|
-
function ToolbarGroupComponent({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
function ToolbarGroupComponent(t0) {
|
|
48
|
+
const $ = _c(13);
|
|
49
|
+
const {
|
|
50
|
+
anchorElem,
|
|
51
|
+
editor,
|
|
52
|
+
group,
|
|
53
|
+
index,
|
|
54
|
+
toolbarStates
|
|
55
|
+
} = t0;
|
|
54
56
|
const {
|
|
55
57
|
editorConfig
|
|
56
58
|
} = useEditorConfigContext();
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
let t1;
|
|
60
|
+
if ($[0] !== group.key || $[1] !== toolbarStates.groupStates) {
|
|
61
|
+
t1 = toolbarStates.groupStates.get(group.key);
|
|
62
|
+
$[0] = group.key;
|
|
63
|
+
$[1] = toolbarStates.groupStates;
|
|
64
|
+
$[2] = t1;
|
|
65
|
+
} else {
|
|
66
|
+
t1 = $[2];
|
|
67
|
+
}
|
|
68
|
+
const groupState = t1;
|
|
69
|
+
groupState?.activeItems;
|
|
70
|
+
let t2;
|
|
71
|
+
bb0: {
|
|
72
|
+
if (group.type !== "dropdown") {
|
|
73
|
+
t2 = undefined;
|
|
74
|
+
break bb0;
|
|
61
75
|
}
|
|
62
76
|
const activeItem = groupState?.activeItems?.[0];
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
group: group,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
t2 = activeItem?.ChildComponent ?? group.ChildComponent;
|
|
78
|
+
}
|
|
79
|
+
const DropdownIcon = t2;
|
|
80
|
+
const t3 = `inline-toolbar-popup__group inline-toolbar-popup__group-${group.key}`;
|
|
81
|
+
let t4;
|
|
82
|
+
if ($[3] !== DropdownIcon || $[4] !== anchorElem || $[5] !== editor || $[6] !== editorConfig.features.toolbarInline?.groups.length || $[7] !== group || $[8] !== groupState || $[9] !== index || $[10] !== t3 || $[11] !== toolbarStates.itemStates) {
|
|
83
|
+
t4 = _jsxs("div", {
|
|
84
|
+
className: t3,
|
|
85
|
+
"data-toolbar-group-key": group.key,
|
|
86
|
+
children: [group.type === "dropdown" && group.items.length && groupState ? _jsx(ToolbarDropdown, {
|
|
87
|
+
anchorElem,
|
|
88
|
+
editor,
|
|
89
|
+
group,
|
|
90
|
+
groupState,
|
|
91
|
+
Icon: DropdownIcon
|
|
92
|
+
}) : null, group.type === "buttons" && group.items.length ? group.items.map(item => {
|
|
93
|
+
const itemState = toolbarStates.itemStates.get(item.key);
|
|
94
|
+
return _jsx(ButtonGroupItem, {
|
|
95
|
+
active: itemState?.active ?? false,
|
|
96
|
+
anchorElem,
|
|
97
|
+
editor,
|
|
98
|
+
enabled: itemState?.enabled ?? true,
|
|
99
|
+
item
|
|
100
|
+
}, item.key);
|
|
101
|
+
}) : null, index < editorConfig.features.toolbarInline?.groups.length - 1 && _jsx("div", {
|
|
102
|
+
className: "divider"
|
|
103
|
+
})]
|
|
104
|
+
}, group.key);
|
|
105
|
+
$[3] = DropdownIcon;
|
|
106
|
+
$[4] = anchorElem;
|
|
107
|
+
$[5] = editor;
|
|
108
|
+
$[6] = editorConfig.features.toolbarInline?.groups.length;
|
|
109
|
+
$[7] = group;
|
|
110
|
+
$[8] = groupState;
|
|
111
|
+
$[9] = index;
|
|
112
|
+
$[10] = t3;
|
|
113
|
+
$[11] = toolbarStates.itemStates;
|
|
114
|
+
$[12] = t4;
|
|
115
|
+
} else {
|
|
116
|
+
t4 = $[12];
|
|
117
|
+
}
|
|
118
|
+
return t4;
|
|
87
119
|
}
|
|
88
120
|
function InlineToolbar({
|
|
89
121
|
anchorElem,
|