@payloadcms/richtext-lexical 3.58.0 → 3.59.0-internal.56a1b3b
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-U4WLAHNW.js → Field-2MCIQXRP.js} +2 -2
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/chunk-K47TNP5J.js +2 -0
- package/dist/exports/client/chunk-K47TNP5J.js.map +7 -0
- package/dist/exports/client/chunk-TLQLXR6Q.js +12 -0
- package/dist/exports/client/chunk-TLQLXR6Q.js.map +7 -0
- package/dist/exports/client/componentInline-AGFSKAY4.js +2 -0
- package/dist/exports/client/index.d.ts +3 -0
- package/dist/exports/client/index.d.ts.map +1 -1
- package/dist/exports/client/index.js +35 -10
- package/dist/exports/client/index.js.map +4 -4
- package/dist/features/blocks/client/component/BlockContent.d.ts +52 -27
- package/dist/features/blocks/client/component/BlockContent.d.ts.map +1 -1
- package/dist/features/blocks/client/component/BlockContent.js +45 -51
- package/dist/features/blocks/client/component/BlockContent.js.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts +2 -9
- package/dist/features/blocks/client/component/components/BlockCollapsible.d.ts.map +1 -1
- package/dist/features/blocks/client/component/components/BlockCollapsible.js +7 -25
- package/dist/features/blocks/client/component/components/BlockCollapsible.js.map +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +62 -50
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.d.ts.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +0 -1
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/index.d.ts.map +1 -1
- package/dist/features/blocks/client/index.js +5 -0
- package/dist/features/blocks/client/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts +6 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +24 -0
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts +6 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js +20 -0
- package/dist/features/blocks/client/markdown/getMarkdownToLexical.js.map +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts +12 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js +348 -0
- package/dist/features/blocks/client/markdown/markdownTransformer.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts +5 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js +149 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Block.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts +53 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js +84 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Code.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts +4 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js +17 -0
- package/dist/features/blocks/premade/CodeBlock/Component/Collapse/index.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts +4 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js +26 -0
- package/dist/features/blocks/premade/CodeBlock/Component/FloatingCollapse/index.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts +7 -0
- package/dist/features/blocks/premade/CodeBlock/converter.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converter.js +46 -0
- package/dist/features/blocks/premade/CodeBlock/converter.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts +2 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.js +4 -0
- package/dist/features/blocks/premade/CodeBlock/converterClient.js.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/index.d.ts +7 -0
- package/dist/features/blocks/premade/CodeBlock/index.d.ts.map +1 -0
- package/dist/features/blocks/premade/CodeBlock/index.js +52 -0
- package/dist/features/blocks/premade/CodeBlock/index.js.map +1 -0
- package/dist/features/blocks/server/index.js +1 -1
- package/dist/features/blocks/server/index.js.map +1 -1
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts +6 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js +27 -0
- package/dist/features/blocks/server/markdown/getLexicalToMarkdown.js.map +1 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts +7 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js +22 -0
- package/dist/features/blocks/server/markdown/getMarkdownToLexical.js.map +1 -0
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.d.ts.map +1 -0
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts +15 -0
- package/dist/features/blocks/server/markdown/markdownTransformer.d.ts.map +1 -0
- package/dist/features/blocks/server/{markdownTransformer.js → markdown/markdownTransformer.js} +6 -48
- package/dist/features/blocks/server/markdown/markdownTransformer.js.map +1 -0
- package/dist/field/bundled.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.d.ts.map +1 -1
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js +5 -5
- package/dist/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.js.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.d.ts.map +1 -1
- package/dist/lexical/ui/icons/CodeBlock/index.js +10 -15
- package/dist/lexical/ui/icons/CodeBlock/index.js.map +1 -1
- package/dist/lexical/ui/icons/Collapse/index.d.ts +3 -0
- package/dist/lexical/ui/icons/Collapse/index.d.ts.map +1 -0
- package/dist/lexical/ui/icons/Collapse/index.js +18 -0
- package/dist/lexical/ui/icons/Collapse/index.js.map +1 -0
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js +2 -2
- package/dist/utilities/jsx/collectTopLevelJSXInLines.js.map +1 -1
- package/package.json +7 -7
- package/dist/exports/client/chunk-3BY5IZJD.js +0 -2
- package/dist/exports/client/chunk-3BY5IZJD.js.map +0 -7
- package/dist/exports/client/chunk-YCH4JNUH.js +0 -12
- package/dist/exports/client/chunk-YCH4JNUH.js.map +0 -7
- package/dist/exports/client/componentInline-7TPI7ZBC.js +0 -2
- package/dist/features/blocks/client/markdownTransformer.d.ts +0 -17
- package/dist/features/blocks/client/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/client/markdownTransformer.js +0 -144
- package/dist/features/blocks/client/markdownTransformer.js.map +0 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.d.ts.map +0 -1
- package/dist/features/blocks/server/linesFromMatchToContentAndPropsString.js.map +0 -1
- package/dist/features/blocks/server/markdownTransformer.d.ts +0 -22
- package/dist/features/blocks/server/markdownTransformer.d.ts.map +0 -1
- package/dist/features/blocks/server/markdownTransformer.js.map +0 -1
- /package/dist/exports/client/{Field-U4WLAHNW.js.map → Field-2MCIQXRP.js.map} +0 -0
- /package/dist/exports/client/{componentInline-7TPI7ZBC.js.map → componentInline-AGFSKAY4.js.map} +0 -0
- /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.d.ts → markdown/linesFromMatchToContentAndPropsString.d.ts} +0 -0
- /package/dist/features/blocks/server/{linesFromMatchToContentAndPropsString.js → markdown/linesFromMatchToContentAndPropsString.js} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LexicalMenu.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_LOW","createCommand","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","CAN_USE_DOM","baseClass","scrollIntoViewIfNeeded","target","typeaheadContainerNode","document","getElementById","typeaheadRect","getBoundingClientRect","top","height","window","innerHeight","scrollIntoView","block","getFullMatchOffset","documentText","entryText","offset","triggerOffset","i","length","substring","$splitNodeContainingQuery","match","selection","isCollapsed","anchor","type","anchorNode","getNode","isSimpleText","selectionOffset","textContent","getTextContent","slice","characterOffset","replaceableString","queryOffset","matchingString","startOffset","newNode","splitText","getScrollParent","element","includeHidden","style","getComputedStyle","excludeStaticParent","position","overflowRegex","body","parent1","parentElement","test","overflow","overflowY","overflowX","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","targetElementRef","onReposition","onVisibilityChange","$","editor","t0","t1","current","rootElement","getRootElement","rootScrollParent","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","disconnect","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groups","menuRenderFn","shouldSplitNodeWithQuery","selectedItemKey","setSelectedItemKey","updateSelectedItem","item","rootElem","setAttribute","key","setSelectedItemKeyToFirstMatchingItem","allItems","flatMap","group","items","firstMatchingItem","selectItemAndCleanUp","selectedItem","update","textNodeContainingQuery","remove","setTimeout","read","clone","onSelect","queryString","removeAttribute","registerCommand","ref","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedItem","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","setContainerDivAttributes","containerDiv","className","display","useMenuAnchorRef","anchorElem","setResolution","Symbol","for","createElement","parent","undefined","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","right","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","isConnected","append","positionMenu","t2","t3","rootElement_0","containerDiv_0","t4"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { JSX, ReactPortal, RefObject } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n createCommand,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport type { MenuTextMatch } from '../useMenuTriggerMatch.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem, SlashMenuItemInternal } from './types.js'\n\nimport { CAN_USE_DOM } from '../../../utils/canUseDOM.js'\n\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: RefObject<HTMLElement | null>,\n itemProps: {\n groups: Array<SlashMenuGroupInternal>\n selectedItemKey: null | string\n selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void\n setSelectedItemKey: (itemKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | null | ReactPortal\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) {\n return\n }\n\n const typeaheadRect = typeaheadContainerNode.getBoundingClientRect()\n\n if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n if (typeaheadRect.top < 0) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n target.scrollIntoView({ block: 'nearest' })\n}\n\n/**\n * Walk backwards along user input and forward through entity title to try\n * and replace more of the user's text with entity.\n */\nfunction getFullMatchOffset(documentText: string, entryText: string, offset: number) {\n let triggerOffset = offset\n for (let i = triggerOffset; i <= entryText.length; i++) {\n if (documentText.substring(documentText.length - i) === entryText.substring(0, i)) {\n triggerOffset = i\n }\n }\n return triggerOffset\n}\n\n/**\n * Split Lexical TextNode and return a new TextNode only containing matched text.\n * Common use cases include: removing the node, replacing with a new node.\n */\nfunction $splitNodeContainingQuery(match: MenuTextMatch): TextNode | undefined {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n const characterOffset = match.replaceableString.length\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return\n }\n let newNode\n if (startOffset === 0) {\n ;[newNode] = anchorNode.splitText(selectionOffset)\n } else {\n ;[, newNode] = anchorNode.splitText(startOffset, selectionOffset)\n }\n\n return newNode\n}\n\n// Got from https://stackoverflow.com/a/42543908/2013580\nexport function getScrollParent(\n element: HTMLElement,\n includeHidden: boolean,\n): HTMLBodyElement | HTMLElement {\n let style = getComputedStyle(element)\n const excludeStaticParent = style.position === 'absolute'\n const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/\n if (style.position === 'fixed') {\n return document.body\n }\n for (let parent: HTMLElement | null = element; (parent = parent.parentElement); ) {\n style = getComputedStyle(parent)\n if (excludeStaticParent && style.position === 'static') {\n continue\n }\n if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {\n return parent\n }\n }\n return document.body\n}\n\nfunction isTriggerVisibleInNearestScrollContainer(\n targetElement: HTMLElement,\n containerElement: HTMLElement,\n): boolean {\n const tRect = targetElement.getBoundingClientRect()\n const cRect = containerElement.getBoundingClientRect()\n return tRect.top > cRect.top && tRect.top < cRect.bottom\n}\n\n// Reposition the menu on scroll, window resize, and element resize.\nexport function useDynamicPositioning(\n resolution: MenuResolution | null,\n targetElementRef: RefObject<HTMLElement | null>,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\n const targetElement = targetElementRef.current\n if (targetElement != null && resolution != null) {\n const rootElement = editor.getRootElement()\n const rootScrollParent =\n rootElement != null ? getScrollParent(rootElement, false) : document.body\n let ticking = false\n let previousIsInView = isTriggerVisibleInNearestScrollContainer(\n targetElement,\n rootScrollParent,\n )\n const handleScroll = function () {\n if (!ticking) {\n window.requestAnimationFrame(function () {\n onReposition()\n ticking = false\n })\n ticking = true\n }\n const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent)\n if (isInView !== previousIsInView) {\n previousIsInView = isInView\n if (onVisibilityChange != null) {\n onVisibilityChange(isInView)\n }\n }\n }\n const resizeObserver = new ResizeObserver(onReposition)\n window.addEventListener('resize', onReposition)\n document.addEventListener('scroll', handleScroll, {\n capture: true,\n passive: true,\n })\n resizeObserver.observe(targetElement)\n return () => {\n resizeObserver.disconnect()\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [editor, onVisibilityChange, onReposition, resolution, targetElementRef])\n}\n\nexport const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{\n index: number\n item: SlashMenuItemInternal\n}> = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND')\n\nexport function LexicalMenu({\n anchorElementRef,\n close,\n editor,\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n groups,\n menuRenderFn,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: RefObject<HTMLElement | null>\n close: () => void\n editor: LexicalEditor\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n resolution: MenuResolution\n shouldSplitNodeWithQuery?: boolean\n}): JSX.Element | null {\n const [selectedItemKey, setSelectedItemKey] = useState<null | string>(null)\n\n const matchingString = (resolution.match && resolution.match.matchingString) || ''\n\n const updateSelectedItem = useCallback(\n (item: SlashMenuItem) => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${item.key}`)\n setSelectedItemKey(item.key)\n }\n },\n [editor],\n )\n\n const setSelectedItemKeyToFirstMatchingItem = useCallback(() => {\n // set selected item to the first of the matching ones\n if (groups !== null && matchingString != null) {\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n const allItems = groups.flatMap((group) => group.items)\n\n if (allItems.length) {\n const firstMatchingItem = allItems[0]!\n updateSelectedItem(firstMatchingItem)\n }\n }\n }, [groups, updateSelectedItem, matchingString])\n\n useEffect(() => {\n setSelectedItemKeyToFirstMatchingItem()\n }, [matchingString, setSelectedItemKeyToFirstMatchingItem])\n\n const selectItemAndCleanUp = useCallback(\n (selectedItem: SlashMenuItem) => {\n close()\n\n editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n if (textNodeContainingQuery) {\n textNodeContainingQuery.remove()\n }\n })\n\n setTimeout(() => {\n // Needed in Firefox. See https://github.com/payloadcms/payload/issues/10724\n let selection: BaseSelection | undefined\n editor.read(() => {\n selection = $getSelection()?.clone()\n })\n editor.update(() => {\n if (selection) {\n $setSelection(selection)\n }\n })\n\n selectedItem.onSelect({\n editor,\n queryString: resolution.match ? resolution.match.matchingString : '',\n })\n }, 0)\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, close],\n )\n\n useEffect(() => {\n return () => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.removeAttribute('aria-activedescendant')\n }\n }\n }, [editor])\n\n useLayoutEffect(() => {\n if (groups === null) {\n setSelectedItemKey(null)\n } else if (selectedItemKey === null) {\n setSelectedItemKeyToFirstMatchingItem()\n }\n }, [groups, selectedItemKey, updateSelectedItem, setSelectedItemKeyToFirstMatchingItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,\n ({ item }) => {\n if (item.ref && item.ref.current != null) {\n scrollIntoViewIfNeeded(item.ref.current)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateSelectedItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_DOWN_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== allItems.length - 1 ? selectedIndex + 1 : 0\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {\n index: newSelectedIndex,\n item: newSelectedItem,\n })\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_UP_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allItems.length - 1\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n scrollIntoViewIfNeeded(newSelectedItem.ref.current)\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ESCAPE_COMMAND,\n (payload) => {\n const event = payload\n event.preventDefault()\n event.stopImmediatePropagation()\n close()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (payload) => {\n const event = payload\n\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event: KeyboardEvent | null) => {\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n if (event !== null) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem])\n\n const listItemProps = useMemo(\n () => ({\n groups,\n selectedItemKey,\n selectItemAndCleanUp,\n setSelectedItemKey,\n }),\n [selectItemAndCleanUp, selectedItemKey, groups],\n )\n\n return menuRenderFn(\n anchorElementRef,\n listItemProps,\n resolution.match ? resolution.match.matchingString : '',\n )\n}\n\nfunction setContainerDivAttributes(containerDiv: HTMLElement, className?: string) {\n if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n}\n\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): RefObject<HTMLElement | null> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement | null>(\n CAN_USE_DOM ? document.createElement('div') : null,\n )\n const positionMenu = useCallback(() => {\n if (anchorElementRef.current === null || parent === undefined) {\n return\n }\n const rootElement = editor.getRootElement()\n const containerDiv = anchorElementRef.current\n\n const VERTICAL_OFFSET = 32\n\n const menuEle = containerDiv.firstChild as Element\n if (rootElement !== null && resolution !== null) {\n const { height, width } = resolution.getRect()\n let { left, top } = resolution.getRect()\n\n const rawTop = top\n top -= anchorElem.getBoundingClientRect().top + window.scrollY\n left -= anchorElem.getBoundingClientRect().left + window.scrollX\n containerDiv.style.left = `${left + window.scrollX}px`\n containerDiv.style.height = `${height}px`\n containerDiv.style.width = `${width}px`\n if (menuEle !== null) {\n const menuRect = menuEle.getBoundingClientRect()\n const menuHeight = menuRect.height\n const menuWidth = menuRect.width\n\n const rootElementRect = rootElement.getBoundingClientRect()\n\n if (left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`\n }\n\n const wouldGoOffBottomOfScreen = rawTop + menuHeight + VERTICAL_OFFSET > window.innerHeight\n //const wouldGoOffBottomOfContainer = top + menuHeight > rootElementRect.bottom\n const wouldGoOffTopOfScreen = rawTop < 0\n\n // Position slash menu above the cursor instead of below (default) if it would otherwise go off the bottom of the screen.\n if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {\n const margin = 24\n containerDiv.style.top = `${\n top + VERTICAL_OFFSET - menuHeight + window.scrollY - (height + margin)\n }px`\n } else {\n containerDiv.style.top = `${top + window.scrollY + VERTICAL_OFFSET}px`\n }\n }\n\n if (!containerDiv.isConnected) {\n setContainerDivAttributes(containerDiv, className)\n anchorElem.append(containerDiv)\n }\n containerDiv.setAttribute('id', 'slash-menu')\n anchorElementRef.current = containerDiv\n rootElement.setAttribute('aria-controls', 'slash-menu')\n }\n }, [editor, resolution, className, anchorElem])\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (resolution !== null) {\n positionMenu()\n return () => {\n if (rootElement !== null) {\n rootElement.removeAttribute('aria-controls')\n }\n\n const containerDiv = anchorElementRef.current\n if (containerDiv !== null && containerDiv.isConnected) {\n containerDiv.remove()\n containerDiv.removeAttribute('id')\n }\n }\n }\n }, [editor, positionMenu, resolution])\n\n const onVisibilityChange = useCallback(\n (isInView: boolean) => {\n if (resolution !== null) {\n if (!isInView) {\n setResolution(null)\n }\n }\n },\n [resolution, setResolution],\n )\n\n useDynamicPositioning(resolution, anchorElementRef, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,oBAAoB,EACpBC,aAAa,EACbC,sBAAsB,EACtBC,oBAA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,CAAA,MAAAgG,EAAA;IAAAhG,CAAA,OAAAiG,EAAA;EAAA;IAAAD,EAAA,GAAAhG,CAAA;IAAAiG,EAAA,GAAAjG,CAAA;EAAA;EAhBrC1E,SAAA,CAAU0K,EAgBV,EAAGC,EAAkC;EAAA,IAAAG,EAAA;EAAA,IAAApG,CAAA,SAAAJ,UAAA,IAAAI,CAAA,SAAAwE,aAAA;IAGnC4B,EAAA,GAAAxF,QAAA;MAAA,IACMhB,UAAA,SAAe;QAAA,KACZgB,QAAA;UACH4D,aAAA,KAAc;QAAA;MAAA;IAAA;IAGpBxE,CAAA,OAAAJ,UAAA;IAAAI,CAAA,OAAAwE,aAAA;IAAAxE,CAAA,OAAAoG,EAAA;EAAA;IAAAA,EAAA,GAAApG,CAAA;EAAA;EAPF,MAAAD,kBAAA,GAA2BqG,EAQE;EAG7BzG,qBAAA,CAAsBC,UAAA,EAAY2B,gBAAA,EAAkBwE,YAAA,EAAchG,kBAAA;EAAA,OAE3DwB,gBAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"LexicalMenu.js","names":["c","_c","useLexicalComposerContext","mergeRegister","$getSelection","$isRangeSelection","$setSelection","COMMAND_PRIORITY_LOW","COMMAND_PRIORITY_NORMAL","createCommand","KEY_ARROW_DOWN_COMMAND","KEY_ARROW_UP_COMMAND","KEY_ENTER_COMMAND","KEY_ESCAPE_COMMAND","KEY_TAB_COMMAND","useCallback","useEffect","useLayoutEffect","useMemo","useRef","useState","CAN_USE_DOM","baseClass","scrollIntoViewIfNeeded","target","typeaheadContainerNode","document","getElementById","typeaheadRect","getBoundingClientRect","top","height","window","innerHeight","scrollIntoView","block","getFullMatchOffset","documentText","entryText","offset","triggerOffset","i","length","substring","$splitNodeContainingQuery","match","selection","isCollapsed","anchor","type","anchorNode","getNode","isSimpleText","selectionOffset","textContent","getTextContent","slice","characterOffset","replaceableString","queryOffset","matchingString","startOffset","newNode","splitText","getScrollParent","element","includeHidden","style","getComputedStyle","excludeStaticParent","position","overflowRegex","body","parent1","parentElement","test","overflow","overflowY","overflowX","isTriggerVisibleInNearestScrollContainer","targetElement","containerElement","tRect","cRect","bottom","useDynamicPositioning","resolution","targetElementRef","onReposition","onVisibilityChange","$","editor","t0","t1","current","rootElement","getRootElement","rootScrollParent","ticking","previousIsInView","handleScroll","requestAnimationFrame","isInView","resizeObserver","ResizeObserver","addEventListener","capture","passive","observe","disconnect","removeEventListener","SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND","LexicalMenu","anchorElementRef","close","groups","menuRenderFn","shouldSplitNodeWithQuery","selectedItemKey","setSelectedItemKey","updateSelectedItem","item","rootElem","setAttribute","key","setSelectedItemKeyToFirstMatchingItem","allItems","flatMap","group","items","firstMatchingItem","selectItemAndCleanUp","selectedItem","update","textNodeContainingQuery","remove","setTimeout","read","clone","onSelect","queryString","removeAttribute","registerCommand","ref","payload","event","selectedIndex","findIndex","newSelectedIndex","newSelectedItem","dispatchCommand","index","preventDefault","stopImmediatePropagation","find","listItemProps","setContainerDivAttributes","containerDiv","className","display","useMenuAnchorRef","anchorElem","setResolution","Symbol","for","createElement","parent","undefined","menuEle","firstChild","width","getRect","left","rawTop","scrollY","scrollX","menuRect","menuHeight","menuWidth","rootElementRect","right","wouldGoOffBottomOfScreen","wouldGoOffTopOfScreen","isConnected","append","positionMenu","t2","t3","rootElement_0","containerDiv_0","t4"],"sources":["../../../../../src/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/LexicalMenu.tsx"],"sourcesContent":["'use client'\nimport type { BaseSelection, LexicalCommand, LexicalEditor, TextNode } from 'lexical'\nimport type { JSX, ReactPortal, RefObject } from 'react'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { mergeRegister } from '@lexical/utils'\nimport {\n $getSelection,\n $isRangeSelection,\n $setSelection,\n COMMAND_PRIORITY_LOW,\n COMMAND_PRIORITY_NORMAL,\n createCommand,\n KEY_ARROW_DOWN_COMMAND,\n KEY_ARROW_UP_COMMAND,\n KEY_ENTER_COMMAND,\n KEY_ESCAPE_COMMAND,\n KEY_TAB_COMMAND,\n} from 'lexical'\nimport { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'\n\nimport type { MenuTextMatch } from '../useMenuTriggerMatch.js'\nimport type { SlashMenuGroupInternal, SlashMenuItem, SlashMenuItemInternal } from './types.js'\n\nimport { CAN_USE_DOM } from '../../../utils/canUseDOM.js'\n\nexport type MenuResolution = {\n getRect: () => DOMRect\n match?: MenuTextMatch\n}\n\nconst baseClass = 'slash-menu-popup'\n\nexport type MenuRenderFn = (\n anchorElementRef: RefObject<HTMLElement | null>,\n itemProps: {\n groups: Array<SlashMenuGroupInternal>\n selectedItemKey: null | string\n selectItemAndCleanUp: (selectedItem: SlashMenuItem) => void\n setSelectedItemKey: (itemKey: string) => void\n },\n matchingString: null | string,\n) => JSX.Element | null | ReactPortal\n\nconst scrollIntoViewIfNeeded = (target: HTMLElement) => {\n const typeaheadContainerNode = document.getElementById('slash-menu')\n if (!typeaheadContainerNode) {\n return\n }\n\n const typeaheadRect = typeaheadContainerNode.getBoundingClientRect()\n\n if (typeaheadRect.top + typeaheadRect.height > window.innerHeight) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n if (typeaheadRect.top < 0) {\n typeaheadContainerNode.scrollIntoView({\n block: 'center',\n })\n }\n\n target.scrollIntoView({ block: 'nearest' })\n}\n\n/**\n * Walk backwards along user input and forward through entity title to try\n * and replace more of the user's text with entity.\n */\nfunction getFullMatchOffset(documentText: string, entryText: string, offset: number) {\n let triggerOffset = offset\n for (let i = triggerOffset; i <= entryText.length; i++) {\n if (documentText.substring(documentText.length - i) === entryText.substring(0, i)) {\n triggerOffset = i\n }\n }\n return triggerOffset\n}\n\n/**\n * Split Lexical TextNode and return a new TextNode only containing matched text.\n * Common use cases include: removing the node, replacing with a new node.\n */\nfunction $splitNodeContainingQuery(match: MenuTextMatch): TextNode | undefined {\n const selection = $getSelection()\n if (!$isRangeSelection(selection) || !selection.isCollapsed()) {\n return\n }\n const anchor = selection.anchor\n if (anchor.type !== 'text') {\n return\n }\n const anchorNode = anchor.getNode()\n if (!anchorNode.isSimpleText()) {\n return\n }\n const selectionOffset = anchor.offset\n const textContent = anchorNode.getTextContent().slice(0, selectionOffset)\n const characterOffset = match.replaceableString.length\n const queryOffset = getFullMatchOffset(textContent, match.matchingString, characterOffset)\n const startOffset = selectionOffset - queryOffset\n if (startOffset < 0) {\n return\n }\n let newNode\n if (startOffset === 0) {\n ;[newNode] = anchorNode.splitText(selectionOffset)\n } else {\n ;[, newNode] = anchorNode.splitText(startOffset, selectionOffset)\n }\n\n return newNode\n}\n\n// Got from https://stackoverflow.com/a/42543908/2013580\nexport function getScrollParent(\n element: HTMLElement,\n includeHidden: boolean,\n): HTMLBodyElement | HTMLElement {\n let style = getComputedStyle(element)\n const excludeStaticParent = style.position === 'absolute'\n const overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/\n if (style.position === 'fixed') {\n return document.body\n }\n for (let parent: HTMLElement | null = element; (parent = parent.parentElement); ) {\n style = getComputedStyle(parent)\n if (excludeStaticParent && style.position === 'static') {\n continue\n }\n if (overflowRegex.test(style.overflow + style.overflowY + style.overflowX)) {\n return parent\n }\n }\n return document.body\n}\n\nfunction isTriggerVisibleInNearestScrollContainer(\n targetElement: HTMLElement,\n containerElement: HTMLElement,\n): boolean {\n const tRect = targetElement.getBoundingClientRect()\n const cRect = containerElement.getBoundingClientRect()\n return tRect.top > cRect.top && tRect.top < cRect.bottom\n}\n\n// Reposition the menu on scroll, window resize, and element resize.\nexport function useDynamicPositioning(\n resolution: MenuResolution | null,\n targetElementRef: RefObject<HTMLElement | null>,\n onReposition: () => void,\n onVisibilityChange?: (isInView: boolean) => void,\n) {\n const [editor] = useLexicalComposerContext()\n useEffect(() => {\n const targetElement = targetElementRef.current\n if (targetElement != null && resolution != null) {\n const rootElement = editor.getRootElement()\n const rootScrollParent =\n rootElement != null ? getScrollParent(rootElement, false) : document.body\n let ticking = false\n let previousIsInView = isTriggerVisibleInNearestScrollContainer(\n targetElement,\n rootScrollParent,\n )\n const handleScroll = function () {\n if (!ticking) {\n window.requestAnimationFrame(function () {\n onReposition()\n ticking = false\n })\n ticking = true\n }\n const isInView = isTriggerVisibleInNearestScrollContainer(targetElement, rootScrollParent)\n if (isInView !== previousIsInView) {\n previousIsInView = isInView\n if (onVisibilityChange != null) {\n onVisibilityChange(isInView)\n }\n }\n }\n const resizeObserver = new ResizeObserver(onReposition)\n window.addEventListener('resize', onReposition)\n document.addEventListener('scroll', handleScroll, {\n capture: true,\n passive: true,\n })\n resizeObserver.observe(targetElement)\n return () => {\n resizeObserver.disconnect()\n window.removeEventListener('resize', onReposition)\n document.removeEventListener('scroll', handleScroll, true)\n }\n }\n }, [editor, onVisibilityChange, onReposition, resolution, targetElementRef])\n}\n\nexport const SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND: LexicalCommand<{\n index: number\n item: SlashMenuItemInternal\n}> = createCommand('SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND')\n\nexport function LexicalMenu({\n anchorElementRef,\n close,\n editor,\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n groups,\n menuRenderFn,\n resolution,\n shouldSplitNodeWithQuery = false,\n}: {\n anchorElementRef: RefObject<HTMLElement | null>\n close: () => void\n editor: LexicalEditor\n groups: Array<SlashMenuGroupInternal>\n menuRenderFn: MenuRenderFn\n resolution: MenuResolution\n shouldSplitNodeWithQuery?: boolean\n}): JSX.Element | null {\n const [selectedItemKey, setSelectedItemKey] = useState<null | string>(null)\n\n const matchingString = (resolution.match && resolution.match.matchingString) || ''\n\n const updateSelectedItem = useCallback(\n (item: SlashMenuItem) => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.setAttribute('aria-activedescendant', `${baseClass}__item-${item.key}`)\n setSelectedItemKey(item.key)\n }\n },\n [editor],\n )\n\n const setSelectedItemKeyToFirstMatchingItem = useCallback(() => {\n // set selected item to the first of the matching ones\n if (groups !== null && matchingString != null) {\n // groups filtering is already handled in SlashMenu/index.tsx. Thus, groups always contains the matching items.\n const allItems = groups.flatMap((group) => group.items)\n\n if (allItems.length) {\n const firstMatchingItem = allItems[0]!\n updateSelectedItem(firstMatchingItem)\n }\n }\n }, [groups, updateSelectedItem, matchingString])\n\n useEffect(() => {\n setSelectedItemKeyToFirstMatchingItem()\n }, [matchingString, setSelectedItemKeyToFirstMatchingItem])\n\n const selectItemAndCleanUp = useCallback(\n (selectedItem: SlashMenuItem) => {\n close()\n\n editor.update(() => {\n const textNodeContainingQuery =\n resolution.match != null && shouldSplitNodeWithQuery\n ? $splitNodeContainingQuery(resolution.match)\n : null\n\n if (textNodeContainingQuery) {\n textNodeContainingQuery.remove()\n }\n })\n\n setTimeout(() => {\n // Needed in Firefox. See https://github.com/payloadcms/payload/issues/10724\n let selection: BaseSelection | undefined\n editor.read(() => {\n selection = $getSelection()?.clone()\n })\n editor.update(() => {\n if (selection) {\n $setSelection(selection)\n }\n })\n\n selectedItem.onSelect({\n editor,\n queryString: resolution.match ? resolution.match.matchingString : '',\n })\n }, 0)\n },\n [editor, shouldSplitNodeWithQuery, resolution.match, close],\n )\n\n useEffect(() => {\n return () => {\n const rootElem = editor.getRootElement()\n if (rootElem !== null) {\n rootElem.removeAttribute('aria-activedescendant')\n }\n }\n }, [editor])\n\n useLayoutEffect(() => {\n if (groups === null) {\n setSelectedItemKey(null)\n } else if (selectedItemKey === null) {\n setSelectedItemKeyToFirstMatchingItem()\n }\n }, [groups, selectedItemKey, updateSelectedItem, setSelectedItemKeyToFirstMatchingItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand(\n SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND,\n ({ item }) => {\n if (item.ref && item.ref.current != null) {\n scrollIntoViewIfNeeded(item.ref.current)\n return true\n }\n\n return false\n },\n COMMAND_PRIORITY_LOW,\n ),\n )\n }, [editor, updateSelectedItem])\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_DOWN_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== allItems.length - 1 ? selectedIndex + 1 : 0\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n editor.dispatchCommand(SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND, {\n index: newSelectedIndex,\n item: newSelectedItem,\n })\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ARROW_UP_COMMAND,\n (payload) => {\n const event = payload\n if (groups !== null && groups.length && selectedItemKey !== null) {\n const allItems = groups.flatMap((group) => group.items)\n const selectedIndex = allItems.findIndex((item) => item.key === selectedItemKey)\n\n const newSelectedIndex = selectedIndex !== 0 ? selectedIndex - 1 : allItems.length - 1\n\n const newSelectedItem = allItems[newSelectedIndex]\n if (!newSelectedItem) {\n return false\n }\n\n updateSelectedItem(newSelectedItem)\n if (newSelectedItem.ref != null && newSelectedItem.ref.current) {\n scrollIntoViewIfNeeded(newSelectedItem.ref.current)\n }\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_ESCAPE_COMMAND,\n (payload) => {\n const event = payload\n event.preventDefault()\n event.stopImmediatePropagation()\n close()\n return true\n },\n COMMAND_PRIORITY_LOW,\n ),\n editor.registerCommand<KeyboardEvent>(\n KEY_TAB_COMMAND,\n (payload) => {\n const event = payload\n\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n event.preventDefault()\n event.stopImmediatePropagation()\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand(\n KEY_ENTER_COMMAND,\n (event: KeyboardEvent | null) => {\n if (groups === null || selectedItemKey === null) {\n return false\n }\n const allItems = groups.flatMap((group) => group.items)\n const selectedItem = allItems.find((item) => item.key === selectedItemKey)\n if (!selectedItem) {\n return false\n }\n\n if (event !== null) {\n event.preventDefault()\n event.stopImmediatePropagation()\n }\n selectItemAndCleanUp(selectedItem)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n )\n }, [selectItemAndCleanUp, close, editor, groups, selectedItemKey, updateSelectedItem])\n\n const listItemProps = useMemo(\n () => ({\n groups,\n selectedItemKey,\n selectItemAndCleanUp,\n setSelectedItemKey,\n }),\n [selectItemAndCleanUp, selectedItemKey, groups],\n )\n\n return menuRenderFn(\n anchorElementRef,\n listItemProps,\n resolution.match ? resolution.match.matchingString : '',\n )\n}\n\nfunction setContainerDivAttributes(containerDiv: HTMLElement, className?: string) {\n if (className != null) {\n containerDiv.className = className\n }\n containerDiv.setAttribute('aria-label', 'Slash menu')\n containerDiv.setAttribute('role', 'listbox')\n containerDiv.style.display = 'block'\n containerDiv.style.position = 'absolute'\n}\n\nexport function useMenuAnchorRef(\n anchorElem: HTMLElement,\n resolution: MenuResolution | null,\n setResolution: (r: MenuResolution | null) => void,\n className?: string,\n): RefObject<HTMLElement | null> {\n const [editor] = useLexicalComposerContext()\n const anchorElementRef = useRef<HTMLElement | null>(\n CAN_USE_DOM ? document.createElement('div') : null,\n )\n const positionMenu = useCallback(() => {\n if (anchorElementRef.current === null || parent === undefined) {\n return\n }\n const rootElement = editor.getRootElement()\n const containerDiv = anchorElementRef.current\n\n const VERTICAL_OFFSET = 32\n\n const menuEle = containerDiv.firstChild as Element\n if (rootElement !== null && resolution !== null) {\n const { height, width } = resolution.getRect()\n let { left, top } = resolution.getRect()\n\n const rawTop = top\n top -= anchorElem.getBoundingClientRect().top + window.scrollY\n left -= anchorElem.getBoundingClientRect().left + window.scrollX\n containerDiv.style.left = `${left + window.scrollX}px`\n containerDiv.style.height = `${height}px`\n containerDiv.style.width = `${width}px`\n if (menuEle !== null) {\n const menuRect = menuEle.getBoundingClientRect()\n const menuHeight = menuRect.height\n const menuWidth = menuRect.width\n\n const rootElementRect = rootElement.getBoundingClientRect()\n\n if (left + menuWidth > rootElementRect.right) {\n containerDiv.style.left = `${rootElementRect.right - menuWidth + window.scrollX}px`\n }\n\n const wouldGoOffBottomOfScreen = rawTop + menuHeight + VERTICAL_OFFSET > window.innerHeight\n //const wouldGoOffBottomOfContainer = top + menuHeight > rootElementRect.bottom\n const wouldGoOffTopOfScreen = rawTop < 0\n\n // Position slash menu above the cursor instead of below (default) if it would otherwise go off the bottom of the screen.\n if (wouldGoOffBottomOfScreen && !wouldGoOffTopOfScreen) {\n const margin = 24\n containerDiv.style.top = `${\n top + VERTICAL_OFFSET - menuHeight + window.scrollY - (height + margin)\n }px`\n } else {\n containerDiv.style.top = `${top + window.scrollY + VERTICAL_OFFSET}px`\n }\n }\n\n if (!containerDiv.isConnected) {\n setContainerDivAttributes(containerDiv, className)\n anchorElem.append(containerDiv)\n }\n containerDiv.setAttribute('id', 'slash-menu')\n anchorElementRef.current = containerDiv\n rootElement.setAttribute('aria-controls', 'slash-menu')\n }\n }, [editor, resolution, className, anchorElem])\n\n useEffect(() => {\n const rootElement = editor.getRootElement()\n if (resolution !== null) {\n positionMenu()\n return () => {\n if (rootElement !== null) {\n rootElement.removeAttribute('aria-controls')\n }\n\n const containerDiv = anchorElementRef.current\n if (containerDiv !== null && containerDiv.isConnected) {\n containerDiv.remove()\n containerDiv.removeAttribute('id')\n }\n }\n }\n }, [editor, positionMenu, resolution])\n\n const onVisibilityChange = useCallback(\n (isInView: boolean) => {\n if (resolution !== null) {\n if (!isInView) {\n setResolution(null)\n }\n }\n },\n [resolution, setResolution],\n )\n\n useDynamicPositioning(resolution, anchorElementRef, positionMenu, onVisibilityChange)\n\n return anchorElementRef\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AAIA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,aAAa,QAAQ;AAC9B,SACEC,aAAa,EACbC,iBAAiB,EACjBC,aAAa,EACbC,oBAAoB,EACpBC,uBAAuB,EACvBC,aAAa,EACbC,sBAAsB,EACtBC,oBAAoB,EACpBC,iBAAiB,EACjBC,kBAAkB,EAClBC,eAAe,QACV;AACP,SAASC,WAAW,EAAEC,SAAS,EAAEC,eAAe,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAKnF,SAASC,WAAW,QAAQ;AAO5B,MAAMC,SAAA,GAAY;AAalB,MAAMC,sBAAA,GAA0BC,MAAA;EAC9B,MAAMC,sBAAA,GAAyBC,QAAA,CAASC,cAAc,CAAC;EACvD,IAAI,CAACF,sBAAA,EAAwB;IAC3B;EACF;EAEA,MAAMG,aAAA,GAAgBH,sBAAA,CAAuBI,qBAAqB;EAElE,IAAID,aAAA,CAAcE,GAAG,GAAGF,aAAA,CAAcG,MAAM,GAAGC,MAAA,CAAOC,WAAW,EAAE;IACjER,sBAAA,CAAuBS,cAAc,CAAC;MACpCC,KAAA,EAAO;IACT;EACF;EAEA,IAAIP,aAAA,CAAcE,GAAG,GAAG,GAAG;IACzBL,sBAAA,CAAuBS,cAAc,CAAC;MACpCC,KAAA,EAAO;IACT;EACF;EAEAX,MAAA,CAAOU,cAAc,CAAC;IAAEC,KAAA,EAAO;EAAU;AAC3C;AAEA;;;;AAIA,SAASC,mBAAmBC,YAAoB,EAAEC,SAAiB,EAAEC,MAAc;EACjF,IAAIC,aAAA,GAAgBD,MAAA;EACpB,KAAK,IAAIE,CAAA,GAAID,aAAA,EAAeC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,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAQjC,CAAA"}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { jsx as _jsx
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
4
|
import React from 'react';
|
|
5
|
-
export const CodeBlockIcon = () => /*#__PURE__*/
|
|
6
|
-
"aria-hidden": "true",
|
|
7
|
-
className: "icon",
|
|
5
|
+
export const CodeBlockIcon = () => /*#__PURE__*/_jsx("svg", {
|
|
8
6
|
fill: "none",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
width: "20",
|
|
7
|
+
height: "12",
|
|
8
|
+
viewBox: "0 0 15 12",
|
|
9
|
+
width: "15",
|
|
13
10
|
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
-
children:
|
|
15
|
-
d: "
|
|
16
|
-
stroke: "currentColor"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
stroke: "currentColor"
|
|
20
|
-
})]
|
|
11
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
12
|
+
d: "M11.3738 8.62598L14.0404 5.95931L11.3738 3.29264M3.37376 3.29264L0.707092 5.95931L3.37376 8.62598M9.04043 0.625977L5.70709 11.2926",
|
|
13
|
+
stroke: "currentColor",
|
|
14
|
+
strokeLinecap: "square"
|
|
15
|
+
})
|
|
21
16
|
});
|
|
22
17
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["React","CodeBlockIcon","
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","CodeBlockIcon","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap"],"sources":["../../../../../src/lexical/ui/icons/CodeBlock/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CodeBlockIcon: React.FC = () => (\n <svg fill=\"none\" height=\"12\" viewBox=\"0 0 15 12\" width=\"15\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M11.3738 8.62598L14.0404 5.95931L11.3738 3.29264M3.37376 3.29264L0.707092 5.95931L3.37376 8.62598M9.04043 0.625977L5.70709 11.2926\"\n stroke=\"currentColor\"\n strokeLinecap=\"square\"\n />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,aAAA,GAA0BA,CAAA,kBACrCC,IAAA,CAAC;EAAIC,IAAA,EAAK;EAAOC,MAAA,EAAO;EAAKC,OAAA,EAAQ;EAAYC,KAAA,EAAM;EAAKC,KAAA,EAAM;YAChE,aAAAL,IAAA,CAAC;IACCM,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/Collapse/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAShC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
export const CollapseIcon = () => /*#__PURE__*/_jsx("svg", {
|
|
6
|
+
fill: "none",
|
|
7
|
+
height: "15",
|
|
8
|
+
viewBox: "0 0 15 15",
|
|
9
|
+
width: "15",
|
|
10
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
11
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
12
|
+
d: "M7.16667 13.8333V9.83333M7.16667 9.83333L9.16667 11.8333M7.16667 9.83333L5.16667 11.8333M7.16667 4.5V0.5M7.16667 4.5L9.16667 2.5M7.16667 4.5L5.16667 2.5M1.83333 7.16667H0.5M5.83333 7.16667H4.5M9.83333 7.16667H8.5M13.8333 7.16667H12.5",
|
|
13
|
+
stroke: "currentColor",
|
|
14
|
+
strokeLinecap: "round",
|
|
15
|
+
strokeLinejoin: "round"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","CollapseIcon","_jsx","fill","height","viewBox","width","xmlns","d","stroke","strokeLinecap","strokeLinejoin"],"sources":["../../../../../src/lexical/ui/icons/Collapse/index.tsx"],"sourcesContent":["'use client'\nimport React from 'react'\n\nexport const CollapseIcon: React.FC = () => (\n <svg fill=\"none\" height=\"15\" viewBox=\"0 0 15 15\" width=\"15\" xmlns=\"http://www.w3.org/2000/svg\">\n <path\n d=\"M7.16667 13.8333V9.83333M7.16667 9.83333L9.16667 11.8333M7.16667 9.83333L5.16667 11.8333M7.16667 4.5V0.5M7.16667 4.5L9.16667 2.5M7.16667 4.5L5.16667 2.5M1.83333 7.16667H0.5M5.83333 7.16667H4.5M9.83333 7.16667H8.5M13.8333 7.16667H12.5\"\n stroke=\"currentColor\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n)\n"],"mappings":"AAAA;;;AACA,OAAOA,KAAA,MAAW;AAElB,OAAO,MAAMC,YAAA,GAAyBA,CAAA,kBACpCC,IAAA,CAAC;EAAIC,IAAA,EAAK;EAAOC,MAAA,EAAO;EAAKC,OAAA,EAAQ;EAAYC,KAAA,EAAM;EAAKC,KAAA,EAAM;YAChE,aAAAL,IAAA,CAAC;IACCM,CAAA,EAAE;IACFC,MAAA,EAAO;IACPC,aAAA,EAAc;IACdC,cAAA,EAAe","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js';
|
|
2
|
-
import { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js';
|
|
1
|
+
import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js';
|
|
2
|
+
import { createTagRegexes } from '../../features/blocks/server/markdown/markdownTransformer.js';
|
|
3
3
|
/**
|
|
4
4
|
* Helpful utility for parsing out all matching top-level JSX tags in a given string.
|
|
5
5
|
* This will collect them in a list, that contains the content of the JSX tag and the props string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const line = lines[i]!\n const startMatch = line.match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,IAAA,GAAOP,KAAK,CAACM,CAAA,CAAE;IACrB,MAAME,UAAA,GAAaD,IAAA,CAAKE,KAAK,CAACN,KAAA,CAAMO,WAAW;IAC/C,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGhB,qCAAA,CAAsC;MACnFiB,aAAA,EAAe;MACfd,KAAA;MACAe,cAAA,EAAgBZ,KAAA,CAAMa,SAAS;MAC/BC,cAAA,EAAgBX,CAAA;MAChBE;IACF;IAEAN,KAAA,CAAMgB,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAP,CAAA,GAAIM,YAAA;IACJ;EACF;EAEA,OAAOV,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"collectTopLevelJSXInLines.js","names":["linesFromStartToContentAndPropsString","createTagRegexes","collectTopLevelJSXInLines","lines","jsxToMatch","finds","regex","linesLength","length","i","line","startMatch","match","regExpStart","content","endLineIndex","propsString","isEndOptional","regexpEndRegex","regExpEnd","startLineIndex","push"],"sources":["../../../src/utilities/jsx/collectTopLevelJSXInLines.ts"],"sourcesContent":["import { linesFromStartToContentAndPropsString } from '../../features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js'\nimport { createTagRegexes } from '../../features/blocks/server/markdown/markdownTransformer.js'\n\n/**\n * Helpful utility for parsing out all matching top-level JSX tags in a given string.\n * This will collect them in a list, that contains the content of the JSX tag and the props string.\n *\n * While this is not used within payload, this can be used for certain payload blocks that need to\n * be serializable and deserializable to and from JSX.\n *\n * @example:\n *\n * Say you have Steps block that contains a steps array. Its JSX representation may look like this:\n *\n * <Steps>\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n * </Steps>\n *\n * In this case, the Steps block would have the following content as its children string:\n * <Step title=\"Step1\">\n * <h1>Step 1</h1>\n * </Step>\n * <Step title=\"Step2\">\n * <h1>Step 2</h1>\n * </Step>\n *\n * It could then use this function to collect all the top-level JSX tags (= the steps):\n *\n * collectTopLevelJSXInLines(children.split('\\n'), 'Step')\n *\n * This will return:\n *\n * [\n * {\n * content: '<h1>Step 1</h1>',\n * propsString: 'title=\"Step1\"',\n * },\n * {\n * content: '<h1>Step 2</h1>',\n * propsString: 'title=\"Step2\"',\n * },\n * ]\n *\n * You can then map this data to construct the data for this blocks array field.\n */\nexport function collectTopLevelJSXInLines(\n lines: Array<string>,\n jsxToMatch: string,\n): {\n content: string\n propsString: string\n}[] {\n const finds: {\n content: string\n propsString: string\n }[] = []\n const regex = createTagRegexes(jsxToMatch)\n\n const linesLength = lines.length\n\n for (let i = 0; i < linesLength; i++) {\n const line = lines[i]!\n const startMatch = line.match(regex.regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n const { content, endLineIndex, propsString } = linesFromStartToContentAndPropsString({\n isEndOptional: false,\n lines,\n regexpEndRegex: regex.regExpEnd,\n startLineIndex: i,\n startMatch,\n })\n\n finds.push({\n content,\n propsString,\n })\n\n i = endLineIndex\n continue\n }\n\n return finds\n}\n"],"mappings":"AAAA,SAASA,qCAAqC,QAAQ;AACtD,SAASC,gBAAgB,QAAQ;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,OAAO,SAASC,0BACdC,KAAoB,EACpBC,UAAkB;EAKlB,MAAMC,KAAA,GAGA,EAAE;EACR,MAAMC,KAAA,GAAQL,gBAAA,CAAiBG,UAAA;EAE/B,MAAMG,WAAA,GAAcJ,KAAA,CAAMK,MAAM;EAEhC,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIF,WAAA,EAAaE,CAAA,IAAK;IACpC,MAAMC,IAAA,GAAOP,KAAK,CAACM,CAAA,CAAE;IACrB,MAAME,UAAA,GAAaD,IAAA,CAAKE,KAAK,CAACN,KAAA,CAAMO,WAAW;IAC/C,IAAI,CAACF,UAAA,EAAY;MACf,UAAS;IACX;IAEA,MAAM;MAAEG,OAAO;MAAEC,YAAY;MAAEC;IAAW,CAAE,GAAGhB,qCAAA,CAAsC;MACnFiB,aAAA,EAAe;MACfd,KAAA;MACAe,cAAA,EAAgBZ,KAAA,CAAMa,SAAS;MAC/BC,cAAA,EAAgBX,CAAA;MAChBE;IACF;IAEAN,KAAA,CAAMgB,IAAI,CAAC;MACTP,OAAA;MACAE;IACF;IAEAP,CAAA,GAAIM,YAAA;IACJ;EACF;EAEA,OAAOV,KAAA;AACT","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.59.0-internal.56a1b3b",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -373,8 +373,8 @@
|
|
|
373
373
|
"react-error-boundary": "4.1.2",
|
|
374
374
|
"ts-essentials": "10.0.3",
|
|
375
375
|
"uuid": "10.0.0",
|
|
376
|
-
"@payloadcms/translations": "3.
|
|
377
|
-
"@payloadcms/ui": "3.
|
|
376
|
+
"@payloadcms/translations": "3.59.0-internal.56a1b3b",
|
|
377
|
+
"@payloadcms/ui": "3.59.0-internal.56a1b3b"
|
|
378
378
|
},
|
|
379
379
|
"devDependencies": {
|
|
380
380
|
"@babel/cli": "7.27.2",
|
|
@@ -394,15 +394,15 @@
|
|
|
394
394
|
"esbuild-sass-plugin": "3.3.1",
|
|
395
395
|
"swc-plugin-transform-remove-imports": "4.0.4",
|
|
396
396
|
"@payloadcms/eslint-config": "3.28.0",
|
|
397
|
-
"payload": "3.
|
|
397
|
+
"payload": "3.59.0-internal.56a1b3b"
|
|
398
398
|
},
|
|
399
399
|
"peerDependencies": {
|
|
400
400
|
"@faceless-ui/modal": "3.0.0",
|
|
401
401
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
402
402
|
"react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
403
403
|
"react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
|
|
404
|
-
"@payloadcms/next": "3.
|
|
405
|
-
"payload": "3.
|
|
404
|
+
"@payloadcms/next": "3.59.0-internal.56a1b3b",
|
|
405
|
+
"payload": "3.59.0-internal.56a1b3b"
|
|
406
406
|
},
|
|
407
407
|
"engines": {
|
|
408
408
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -421,7 +421,7 @@
|
|
|
421
421
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
422
422
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
423
423
|
"build:without_reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm copyfiles && pnpm build:types && pnpm build:swc && pnpm build:esbuild && pnpm build:esbuild:postproces && rm -rf dist/exports/client && mv dist/exports/client_unoptimized dist/exports/client",
|
|
424
|
-
"clean": "rimraf -g {dist,*.tsbuildinfo}",
|
|
424
|
+
"clean": "rimraf -g {dist,*.tsbuildinfo,esbuild}",
|
|
425
425
|
"copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
|
|
426
426
|
"lint": "eslint .",
|
|
427
427
|
"lint:fix": "eslint . --fix"
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as ie}from"./chunk-INBEEENE.js";import{b as se}from"./chunk-BZZVLW4U.js";import{jsx as r,jsxs as p,Fragment as we}from"react/jsx-runtime";import O,{createContext as Ie,useCallback as A,useEffect as v,useMemo as N,useRef as x}from"react";import{useLexicalComposerContext as ve}from"@lexical/react/LexicalComposerContext";import{getTranslation as ce}from"@payloadcms/translations";import{Button as ae,Drawer as Ne,EditDepthProvider as Oe,Form as Te,formatDrawerSlug as $e,FormSubmit as Pe,RenderFields as Re,ShimmerEffect as Ee,useConfig as Le,useDocumentForm as je,useDocumentInfo as Me,useEditDepth as Ae,useServerFunctions as Je,useTranslation as Ke}from"@payloadcms/ui";import{abortAndIgnore as J}from"@payloadcms/ui/shared";import{$getNodeByKey as K}from"lexical";import{deepCopyObjectSimpleWithoutReactComponents as z,reduceFieldsToValues as ze}from"payload/shared";import{v4 as He}from"uuid";import{jsx as Ce}from"react/jsx-runtime";import _e from"bson-objectid";import ye from"react";import Be from"bson-objectid";import{DecoratorNode as xe}from"lexical";var B=class extends xe{__cacheBuster;__fields;constructor({cacheBuster:e,fields:t,key:l}){super(l),this.__fields=t,this.__cacheBuster=e||0}static clone(e){return new this({cacheBuster:e.__cacheBuster,fields:e.__fields,key:e.__key})}static getType(){return"inlineBlock"}static importDOM(){return{}}static importJSON(e){return Se(e.fields)}static isInline(){return!1}canIndent(){return!0}createDOM(){let e=document.createElement("span");return e.classList.add("inline-block-container"),e}decorate(e,t){return null}exportDOM(){let e=document.createElement("span");e.classList.add("inline-block-container");let t=document.createTextNode(this.getTextContent());return e.append(t),{element:e}}exportJSON(){return{type:"inlineBlock",fields:this.getFields(),version:1}}getCacheBuster(){return this.getLatest().__cacheBuster}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}isInline(){return!0}setFields(e,t){let l=this.getWritable();l.__fields=e,t||l.__cacheBuster++}updateDOM(){return!1}};function Se(s){return new B({fields:{...s,id:s?.id||new Be.default().toHexString()}})}var Fe=ye.lazy(()=>import("./componentInline-7TPI7ZBC.js").then(s=>({default:s.InlineBlockComponent}))),I=class extends B{static clone(e){return super.clone(e)}static getType(){return super.getType()}static importJSON(e){return De(e.fields)}decorate(e,t){return Ce(Fe,{cacheBuster:this.getCacheBuster(),formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function De(s){return new I({fields:{...s,id:s?.id||new _e.default().toHexString()}})}function M(s){return s instanceof I}var f="inline-block",ue=Ie({initialState:!1}),ft=()=>O.use(ue),pt=s=>{let{cacheBuster:e,formData:t,nodeKey:l}=s,[d]=ve(),{i18n:T,t:m}=Ke(),{createdInlineBlock:H,fieldProps:{featureClientSchemaMap:de,initialLexicalFormState:me,permissions:Ve,readOnly:S,schemaPath:V},setCreatedInlineBlock:W,uuid:fe}=se(),{fields:C}=je(),{getFormState:_}=Je(),pe=Ae(),q=x(!1),[c,$]=O.useState(()=>me?.[t.id]?.formState),G=x(!1),Q=x(e);v(()=>{G.current?(Q.current!==e&&$(!1),Q.current=e):G.current=!0},[e]);let[P,U]=O.useState(c?._components?.customComponents?.BlockLabel),[X,Y]=O.useState(c?._components?.customComponents?.Block),Z=$e({slug:`lexical-inlineBlocks-create-${fe}-${t.id}`,depth:pe}),{toggleDrawer:b}=ie(Z,!0),be=x(null),{id:y,collectionSlug:F,getDocPreferences:D,globalSlug:w}=Me(),{config:ke}=Le(),he=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${t.blockType}`,k=de.blocks?.[he]?.[0],a=k.blockReferences?typeof k?.blockReferences?.[0]=="string"?ke.blocksMap[k?.blockReferences?.[0]]:k?.blockReferences?.[0]:k?.blocks?.[0],ee=a?.fields??[];v(()=>{!q.current&&H?.getKey()===l&&(ee.length>2&&b(),W?.(void 0),q.current=!0)},[ee.length,H,l,W,b]);let te=A(()=>{d.update(()=>{K(l)?.remove()})},[d,l]),h=a?.labels?.singular?ce(a?.labels.singular,T):a?.slug,R=x(new AbortController),g=`${V}.lexical_internal_feature.blocks.lexical_inline_blocks.${a?.slug}.fields`;v(()=>{let n=new AbortController;return t&&!c&&(async()=>{let{state:o}=await _({id:y,collectionSlug:F,data:t,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),globalSlug:w,initialBlockData:t,initialBlockFormState:t,operation:"update",renderAllFields:!0,schemaPath:g,signal:n.signal});if(o){let u=ze(z(o),!0);d.update(()=>{let j=K(l);if(j&&M(j)){let le=u;le.blockType=t.blockType,j.setFields(le,!0)}}),$(o),U(o._components?.customComponents?.BlockLabel),Y(o._components?.customComponents?.Block)}})(),()=>{J(n)}},[_,d,l,g,y,t,c,F,w,D,C]);let ne=A(async({formState:n,submit:i})=>{J(R.current);let o=new AbortController;R.current=o;let{state:u}=await _({id:y,collectionSlug:F,docPermissions:{fields:!0},docPreferences:await D(),documentFormState:z(C),formState:n,globalSlug:w,initialBlockFormState:n,operation:"update",renderAllFields:!!i,schemaPath:g,signal:o.signal});return u?(i&&(U(u._components?.customComponents?.BlockLabel),Y(u._components?.customComponents?.Block)),u):n},[_,y,F,D,C,w,g]);v(()=>{let n=(i,o)=>Object.keys(o).some(u=>o[u]&&i[u]!==o[u].value);return()=>{c&&n(t,c)&&$(!1),J(R.current)}},[t,c]);let ge=A((n,i)=>{i.blockType=t.blockType,d.update(()=>{let o=K(l);o&&M(o)&&o.setFields(i,!0)})},[d,l,t]),E=N(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${f}__removeButton`,disabled:S,icon:"x",onClick:n=>{n.preventDefault(),te()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:remove",{label:h})}),[h,S,te,m]),oe=N(()=>()=>r(ae,{buttonStyle:"icon-label",className:`${f}__editButton`,disabled:S,el:"button",icon:"edit",onClick:()=>{b()},round:!0,size:"small",tooltip:m("lexical:blocks:inlineBlocks:edit",{label:h})}),[h,S,m,b]),L=N(()=>({children:n,className:i})=>r("div",{className:[f,f+"-"+t.blockType,i].filter(Boolean).join(" "),ref:be,children:n}),[t.blockType]),re=N(()=>P?()=>P:()=>r("div",{children:a?.labels?ce(a?.labels.singular,T):""}),[P,a?.labels,T]);return a?p(Te,{beforeSubmit:[async({formState:n})=>await ne({formState:n,submit:!0})],disableValidationOnSubmit:!0,el:"div",fields:a?.fields,initialState:c||{},onChange:[ne],onSubmit:(n,i)=>{ge(n,i),b()},uuid:He(),children:[r(Oe,{children:r(Ne,{className:"",slug:Z,title:m(`lexical:blocks:inlineBlocks:${t?.id?"edit":"create"}`,{label:h??m("lexical:blocks:inlineBlocks:label")}),children:c?p(we,{children:[r(Re,{fields:a?.fields,forceRender:!0,parentIndexPath:"",parentPath:"",parentSchemaPath:g,permissions:!0,readOnly:!1}),r(Pe,{programmaticSubmit:!0,children:m("fields:saveChanges")})]}):null})}),X?r(ue,{value:{EditButton:oe,initialState:c,InlineBlockContainer:L,Label:re,nodeKey:l,RemoveButton:E},children:X}):p(L,{children:[c?r(re,{}):r(Ee,{height:"15px",width:"40px"}),d.isEditable()?p("div",{className:`${f}__actions`,children:[r(oe,{}),r(E,{})]}):null]})]}):p(L,{className:`${f}-not-found`,children:[p("span",{children:["Error: Block '",t.blockType,"' not found"]}),d.isEditable()?r("div",{className:`${f}__actions`,children:r(E,{})}):null]})};export{ft as a,pt as b,I as c,De as d,M as e};
|
|
2
|
-
//# sourceMappingURL=chunk-3BY5IZJD.js.map
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/features/blocks/client/componentInline/index.tsx", "../../../src/features/blocks/client/nodes/InlineBlocksNode.tsx", "../../../src/features/blocks/server/nodes/InlineBlocksNode.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\n\nimport './index.scss'\n\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport { v4 as uuid } from 'uuid'\n\nimport type { InlineBlockFields } from '../../server/nodes/InlineBlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isInlineBlockNode } from '../nodes/InlineBlocksNode.js'\n\ntype Props = {\n /**\n * Can be modified by the node in order to trigger the re-fetch of the initial state based on the\n * formData. This is useful when node.setFields() is explicitly called from outside of the form - in\n * this case, the new field state is likely not reflected in the form state, so we need to re-fetch\n */\n readonly cacheBuster: number\n readonly formData: InlineBlockFields\n readonly nodeKey: string\n}\n\ntype InlineBlockComponentContextType = {\n EditButton?: React.FC\n initialState: false | FormState | undefined\n InlineBlockContainer?: React.FC<{ children: React.ReactNode }>\n Label?: React.FC\n nodeKey?: string\n RemoveButton?: React.FC\n}\n\nconst InlineBlockComponentContext = createContext<InlineBlockComponentContextType>({\n initialState: false,\n})\n\nexport const useInlineBlockComponentContext = () => React.use(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n setCreatedInlineBlock,\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { fields: parentDocumentFields } = useDocumentForm()\n\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n const firstTimeDrawer = useRef(false)\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n () => initialLexicalFormState?.[formData.id]?.formState,\n )\n\n const hasMounted = useRef(false)\n const prevCacheBuster = useRef(cacheBuster)\n useEffect(() => {\n if (hasMounted.current) {\n if (prevCacheBuster.current !== cacheBuster) {\n setInitialState(false)\n }\n prevCacheBuster.current = cacheBuster\n } else {\n hasMounted.current = true\n }\n }, [cacheBuster])\n\n const [CustomLabel, setCustomLabel] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.BlockLabel,\n )\n\n const [CustomBlock, setCustomBlock] = React.useState<React.ReactNode | undefined>(\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n initialState?.['_components']?.customComponents?.Block,\n )\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-inlineBlocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { config } = useConfig()\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${formData.blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient = clientSchemaMap?.[\n componentMapRenderedBlockPath\n ]?.[0] as BlocksFieldClient\n\n const clientBlock: ClientBlock | undefined = blocksField.blockReferences\n ? typeof blocksField?.blockReferences?.[0] === 'string'\n ? config.blocksMap[blocksField?.blockReferences?.[0]]\n : blocksField?.blockReferences?.[0]\n : blocksField?.blocks?.[0]\n\n const clientBlockFields = clientBlock?.fields ?? []\n\n // Open drawer on \"mount\"\n useEffect(() => {\n if (!firstTimeDrawer.current && createdInlineBlock?.getKey() === nodeKey) {\n // > 2 because they always have \"id\" and \"blockName\" fields\n if (clientBlockFields.length > 2) {\n toggleDrawer()\n }\n setCreatedInlineBlock?.(undefined)\n firstTimeDrawer.current = true\n }\n }, [clientBlockFields.length, createdInlineBlock, nodeKey, setCreatedInlineBlock, toggleDrawer])\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const blockDisplayName = clientBlock?.labels?.singular\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock?.slug\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_inline_blocks.${clientBlock?.slug}.fields`\n\n // Initial state for newly created blocks\n useEffect(() => {\n const abortController = new AbortController()\n\n const awaitInitialState = async () => {\n /*\n * This will only run if a new block is created. For all existing blocks that are loaded when the document is loaded, or when the form is saved,\n * this is not run, as the lexical field RSC will fetch the state server-side and pass it to the client. That way, we avoid unnecessary client-side\n * requests. Though for newly created blocks, we need to fetch the state client-side, as the server doesn't know about the block yet.\n */\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: formData,\n docPermissions: { fields: true },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: formData,\n initialBlockFormState: formData,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n const newFormStateData: InlineBlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as InlineBlockFields\n\n // Things like default values may come back from the server => update the node with the new data\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = formData.blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n editor,\n nodeKey,\n schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n /**\n * HANDLE ONCHANGE\n */\n const onChange = useCallback(\n async ({ formState: prevFormState, submit }: { formState: FormState; submit?: boolean }) => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n\n const controller = new AbortController()\n onChangeAbortControllerRef.current = controller\n\n const { state } = await getFormState({\n id,\n collectionSlug,\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n formState: prevFormState,\n globalSlug,\n initialBlockFormState: prevFormState,\n operation: 'update',\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n if (submit) {\n setCustomLabel(state['_components']?.customComponents?.BlockLabel)\n setCustomBlock(state['_components']?.customComponents?.Block)\n }\n\n return state\n },\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n // cleanup effect\n useEffect(() => {\n const isStateOutOfSync = (formData: InlineBlockFields, initialState: FormState) => {\n return Object.keys(initialState).some(\n (key) => initialState[key] && formData[key] !== initialState[key].value,\n )\n }\n\n return () => {\n // If the component is unmounted (either via removeInlineBlock or via lexical itself) and the form state got changed before,\n // we need to reset the initial state to force a re-fetch of the initial state when it gets mounted again (e.g. via lexical history undo).\n // Otherwise it would use an outdated initial state.\n if (initialState && isStateOutOfSync(formData, initialState)) {\n setInitialState(false)\n }\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [formData, initialState])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState, newData: Data) => {\n newData.blockType = formData.blockType\n\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData as InlineBlockFields, true)\n }\n })\n },\n [editor, nodeKey, formData],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeInlineBlock()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:remove', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={readOnly}\n el=\"button\"\n icon=\"edit\"\n onClick={() => {\n toggleDrawer()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [blockDisplayName, readOnly, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[baseClass, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => (\n <div>{clientBlock?.labels ? getTranslation(clientBlock?.labels.singular, i18n) : ''}</div>\n )\n }\n }, [CustomLabel, clientBlock?.labels, i18n])\n\n if (!clientBlock) {\n return (\n <InlineBlockContainer className={`${baseClass}-not-found`}>\n <span>Error: Block '{formData.blockType}' not found</span>\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )\n }\n\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer\n return await onChange({ formState, submit: true })\n },\n ]}\n disableValidationOnSubmit\n el=\"div\"\n fields={clientBlock?.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState, data) => {\n onFormSubmit(formState, data)\n toggleDrawer()\n }}\n uuid={uuid()}\n >\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${formData?.id ? 'edit' : 'create'}`, {\n label: blockDisplayName ?? t('lexical:blocks:inlineBlocks:label'),\n })}\n >\n {initialState ? (\n <>\n <RenderFields\n fields={clientBlock?.fields}\n forceRender\n parentIndexPath=\"\"\n parentPath=\"\" // See Blocks feature path for details as for why this is empty\n parentSchemaPath={schemaFieldsPath}\n permissions={true}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext>\n ) : (\n <InlineBlockContainer>\n {initialState ? <Label /> : <ShimmerEffect height=\"15px\" width=\"40px\" />}\n {editor.isEditable() ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n", "'use client'\nimport type { EditorConfig, LexicalEditor, LexicalNode } from 'lexical'\n\nimport ObjectID from 'bson-objectid'\nimport React, { type JSX } from 'react'\n\nimport type {\n InlineBlockFields,\n SerializedInlineBlockNode,\n} from '../../server/nodes/InlineBlocksNode.js'\n\nimport { ServerInlineBlockNode } from '../../server/nodes/InlineBlocksNode.js'\n\nconst InlineBlockComponent = React.lazy(() =>\n import('../componentInline/index.js').then((module) => ({\n default: module.InlineBlockComponent,\n })),\n)\n\nexport class InlineBlockNode extends ServerInlineBlockNode {\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return super.clone(node)\n }\n\n static override getType(): string {\n return super.getType()\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): InlineBlockNode {\n const node = $createInlineBlockNode(serializedNode.fields)\n return node\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element {\n return (\n <InlineBlockComponent\n cacheBuster={this.getCacheBuster()}\n formData={this.getFields()}\n nodeKey={this.getKey()}\n />\n )\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return super.exportJSON()\n }\n}\n\nexport function $createInlineBlockNode(fields: Exclude<InlineBlockFields, 'id'>): InlineBlockNode {\n return new InlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isInlineBlockNode(\n node: InlineBlockNode | LexicalNode | null | undefined,\n): node is InlineBlockNode {\n return node instanceof InlineBlockNode\n}\n", "import type {\n DOMConversionMap,\n DOMExportOutput,\n EditorConfig,\n LexicalEditor,\n LexicalNode,\n NodeKey,\n SerializedLexicalNode,\n Spread,\n} from 'lexical'\nimport type { JsonObject } from 'payload'\nimport type React from 'react'\nimport type { JSX } from 'react'\n\nimport ObjectID from 'bson-objectid'\nimport { DecoratorNode } from 'lexical'\n\nexport type InlineBlockFields<TInlineBlockFields extends JsonObject = JsonObject> = {\n blockType: string\n id: string\n} & TInlineBlockFields\n\nexport type SerializedInlineBlockNode<TBlockFields extends JsonObject = JsonObject> = Spread<\n {\n children?: never // required so that our typed editor state doesn't automatically add children\n fields: InlineBlockFields<TBlockFields>\n type: 'inlineBlock'\n },\n SerializedLexicalNode\n>\n\nexport class ServerInlineBlockNode extends DecoratorNode<null | React.ReactElement> {\n __cacheBuster: number\n __fields: InlineBlockFields\n\n constructor({\n cacheBuster,\n fields,\n key,\n }: {\n cacheBuster?: number\n fields: InlineBlockFields\n key?: NodeKey\n }) {\n super(key)\n this.__fields = fields\n this.__cacheBuster = cacheBuster || 0\n }\n\n static override clone(node: ServerInlineBlockNode): ServerInlineBlockNode {\n return new this({\n cacheBuster: node.__cacheBuster,\n fields: node.__fields,\n key: node.__key,\n })\n }\n\n static override getType(): string {\n return 'inlineBlock'\n }\n\n static override importDOM(): DOMConversionMap<HTMLDivElement> | null {\n return {}\n }\n\n static override importJSON(serializedNode: SerializedInlineBlockNode): ServerInlineBlockNode {\n const node = $createServerInlineBlockNode(serializedNode.fields)\n return node\n }\n\n static isInline(): false {\n return false\n }\n\n canIndent() {\n return true\n }\n override createDOM() {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n return element\n }\n\n override decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element | null {\n return null\n }\n\n override exportDOM(): DOMExportOutput {\n const element = document.createElement('span')\n element.classList.add('inline-block-container')\n\n const text = document.createTextNode(this.getTextContent())\n element.append(text)\n return { element }\n }\n\n override exportJSON(): SerializedInlineBlockNode {\n return {\n type: 'inlineBlock',\n fields: this.getFields(),\n version: 1,\n }\n }\n\n getCacheBuster(): number {\n return this.getLatest().__cacheBuster\n }\n\n getFields(): InlineBlockFields {\n return this.getLatest().__fields\n }\n\n override getTextContent(): string {\n return `Block Field`\n }\n\n override isInline() {\n return true\n }\n\n setFields(fields: InlineBlockFields, preventFormStateUpdate?: boolean): void {\n const writable = this.getWritable()\n writable.__fields = fields\n if (!preventFormStateUpdate) {\n writable.__cacheBuster++\n }\n }\n\n override updateDOM(): boolean {\n return false\n }\n}\n\nexport function $createServerInlineBlockNode(\n fields: Exclude<InlineBlockFields, 'id'>,\n): ServerInlineBlockNode {\n return new ServerInlineBlockNode({\n fields: {\n ...fields,\n id: fields?.id || new ObjectID.default().toHexString(),\n },\n })\n}\n\nexport function $isServerInlineBlockNode(\n node: LexicalNode | null | ServerInlineBlockNode | undefined,\n): node is ServerInlineBlockNode {\n return node instanceof ServerInlineBlockNode\n}\n"],
|
|
5
|
-
"mappings": "mJAEA,OAAOA,GAASC,iBAAAA,GAAeC,eAAAA,EAAaC,aAAAA,EAAWC,WAAAA,EAASC,UAAAA,MAAc,QAK9E,OAASC,6BAAAA,OAAiC,wCAC1C,OAASC,kBAAAA,OAAsB,2BAC/B,OACEC,UAAAA,GACAC,UAAAA,GACAC,qBAAAA,GACAC,QAAAA,GACAC,oBAAAA,GACAC,cAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,sBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,kBAAAA,MAAsB,wBAC/B,OAASC,iBAAAA,MAAqB,UAI9B,OAASC,8CAAAA,EAA4CC,wBAAAA,OAA4B,iBACjF,OAASC,MAAMC,OAAY,gDC5B3B,OAAOC,OAAc,gBACrB,OAAOC,OAAyB,QCUhC,OAAOC,OAAc,gBACrB,OAASC,iBAAAA,OAAqB,UAgBvB,IAAMC,EAAN,cAAoCD,EAAA,CACzCE,cACAC,SAEAC,YAAY,CACVC,YAAAA,EACAC,OAAAA,EACAC,IAAAA,CAAG,EAKF,CACD,MAAMA,CAAA,E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EAAA,WACEpI,EAAeqH,EAACqB,GAAA,CAAA,CAAA,EAAWrB,EAACsC,GAAA,CAAcC,OAAO,OAAOC,MAAM,SAC9DpJ,EAAOqJ,WAAU,EAChBnB,EAAC,MAAA,CAAInB,UAAW,GAAG3H,CAAA,sBACjBwH,EAACa,GAAA,CAAA,CAAA,EACDb,EAACF,EAAA,CAAA,CAAA,CAAA,IAED,IAAA,OA3ERwB,EAACP,EAAA,CAAqBZ,UAAW,GAAG3H,CAAA,uBAClC8I,EAAC,OAAA,WAAK,iBAAepI,EAASwD,UAAU,aAAA,IACvCtD,EAAOqJ,WAAU,EAChBzC,EAAC,MAAA,CAAIG,UAAW,GAAG3H,CAAA,qBACjBwH,EAACF,EAAA,CAAA,CAAA,IAED,IAAA,GA0EZ",
|
|
6
|
-
"names": ["React", "createContext", "useCallback", "useEffect", "useMemo", "useRef", "useLexicalComposerContext", "getTranslation", "Button", "Drawer", "EditDepthProvider", "Form", "formatDrawerSlug", "FormSubmit", "RenderFields", "ShimmerEffect", "useConfig", "useDocumentForm", "useDocumentInfo", "useEditDepth", "useServerFunctions", "useTranslation", "abortAndIgnore", "$getNodeByKey", "deepCopyObjectSimpleWithoutReactComponents", "reduceFieldsToValues", "v4", "uuid", "ObjectID", "React", "ObjectID", "DecoratorNode", "ServerInlineBlockNode", "__cacheBuster", "__fields", "constructor", "cacheBuster", "fields", "key", "clone", "node", "__key", "getType", "importDOM", "importJSON", "serializedNode", "$createServerInlineBlockNode", "isInline", "canIndent", "createDOM", "element", "document", "createElement", "classList", "add", "decorate", "editor", "config", "exportDOM", "text", "createTextNode", "getTextContent", "append", "exportJSON", "type", "getFields", "version", "getCacheBuster", "getLatest", "setFields", "preventFormStateUpdate", "writable", "getWritable", "updateDOM", "id", "default", "toHexString", "InlineBlockComponent", "React", "lazy", "then", "module", "default", "InlineBlockNode", "ServerInlineBlockNode", "clone", "node", "getType", "importJSON", "serializedNode", "$createInlineBlockNode", "fields", "decorate", "editor", "config", "_jsx", "cacheBuster", "getCacheBuster", "formData", "getFields", "nodeKey", "getKey", "exportJSON", "id", "ObjectID", "toHexString", "$isInlineBlockNode", "baseClass", "InlineBlockComponentContext", "createContext", "initialState", "useInlineBlockComponentContext", "React", "use", "InlineBlockComponent", "props", "cacheBuster", "formData", "nodeKey", "editor", "useLexicalComposerContext", "i18n", "t", "useTranslation", "createdInlineBlock", "fieldProps", "featureClientSchemaMap", "initialLexicalFormState", "permissions", "readOnly", "schemaPath", "setCreatedInlineBlock", "uuid", "uuidFromContext", "useEditorConfigContext", "fields", "parentDocumentFields", "useDocumentForm", "getFormState", "useServerFunctions", "editDepth", "useEditDepth", "firstTimeDrawer", "useRef", "setInitialState", "useState", "id", "formState", "hasMounted", "prevCacheBuster", "useEffect", "current", "CustomLabel", "setCustomLabel", "customComponents", "BlockLabel", "CustomBlock", "setCustomBlock", "Block", "drawerSlug", "formatDrawerSlug", "slug", "depth", "toggleDrawer", "useLexicalDrawer", "inlineBlockElemElemRef", "collectionSlug", "getDocPreferences", "globalSlug", "useDocumentInfo", "config", "useConfig", "componentMapRenderedBlockPath", "blockType", "blocksField", "clientBlock", "blockReferences", "blocksMap", "blocks", "clientBlockFields", "getKey", "length", "undefined", "removeInlineBlock", "useCallback", "update", "$getNodeByKey", "remove", "blockDisplayName", "labels", "singular", "getTranslation", "onChangeAbortControllerRef", "AbortController", "schemaFieldsPath", "abortController", "state", "data", "docPermissions", "docPreferences", "documentFormState", "deepCopyObjectSimpleWithoutReactComponents", "initialBlockData", "initialBlockFormState", "operation", "renderAllFields", "signal", "newFormStateData", "reduceFieldsToValues", "node", "$isInlineBlockNode", "newData", "setFields", "abortAndIgnore", "onChange", "prevFormState", "submit", "controller", "isStateOutOfSync", "Object", "keys", "some", "key", "value", "onFormSubmit", "RemoveButton", "useMemo", "_jsx", "Button", "buttonStyle", "className", "disabled", "icon", "onClick", "e", "preventDefault", "round", "size", "tooltip", "label", "EditButton", "el", "InlineBlockContainer", "children", "filter", "Boolean", "join", "ref", "Label", "_jsxs", "Form", "beforeSubmit", "disableValidationOnSubmit", "onSubmit", "EditDepthProvider", "Drawer", "title", "_Fragment", "RenderFields", "forceRender", "parentIndexPath", "parentPath", "parentSchemaPath", "FormSubmit", "programmaticSubmit", "ShimmerEffect", "height", "width", "isEditable"]
|
|
7
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
var nt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";import{c as ce}from"react/compiler-runtime";import{useRef as ae}from"react";function Un(n){let t=ce(2),e=n===void 0?500:n,o=ae(void 0),r;return t[0]!==e?(r=s=>new Promise(i=>{let a=()=>{s(),i()};"requestIdleCallback"in window?("cancelIdleCallback"in window&&o.current!==void 0&&cancelIdleCallback(o.current),o.current=requestIdleCallback(a,{timeout:e})):le().then(a)}),t[0]=e,t[1]=r):r=t[1],r}function le(){return new Promise(n=>{setTimeout(n,100),requestAnimationFrame(()=>{setTimeout(n,0)})})}var G=class{_x;_y;constructor(t,e){this._x=t,this._y=e}calcDeltaXTo({x:t}){return this.x-t}calcDeltaYTo({y:t}){return this.y-t}calcDistanceTo(t){return Math.sqrt(Math.pow(this.calcDeltaXTo(t),2)+Math.pow(this.calcDeltaYTo(t),2))}calcHorizontalDistanceTo(t){return Math.abs(this.calcDeltaXTo(t))}calcVerticalDistance(t){return Math.abs(this.calcDeltaYTo(t))}equals({x:t,y:e}){return this.x===t&&this.y===e}get x(){return this._x}get y(){return this._y}};function ot(n){return n instanceof G}import{jsx as ye}from"react/jsx-runtime";import{useLexicalComposerContext as be}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as ke}from"@lexical/utils";import{$getSelection as Y,$isRangeSelection as W,$isTextNode as Ae,COMMAND_PRIORITY_LOW as Oe,createCommand as Me,getDOMSelection as Le}from"lexical";import{useCallback as mt,useEffect as gt,useState as $e}from"react";import*as X from"react";import{c as at}from"react/compiler-runtime";import{useLexicalComposerContext as lt}from"@lexical/react/LexicalComposerContext.js";import{mergeRegister as rt}from"@lexical/utils";import{$getSelection as ft,$isRangeSelection as fe,$setSelection as ue,COMMAND_PRIORITY_LOW as N,createCommand as de,KEY_ARROW_DOWN_COMMAND as me,KEY_ARROW_UP_COMMAND as ge,KEY_ENTER_COMMAND as pe,KEY_ESCAPE_COMMAND as he,KEY_TAB_COMMAND as xe}from"lexical";import{useCallback as z,useEffect as y,useLayoutEffect as Ee,useMemo as _e,useRef as Te,useState as Se}from"react";var we="slash-menu-popup",it=n=>{let t=document.getElementById("slash-menu");if(!t)return;let e=t.getBoundingClientRect();e.top+e.height>window.innerHeight&&t.scrollIntoView({block:"center"}),e.top<0&&t.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Re(n,t,e){let o=e;for(let r=o;r<=t.length;r++)n.substring(n.length-r)===t.substring(0,r)&&(o=r);return o}function Ce(n){let t=ft();if(!fe(t)||!t.isCollapsed())return;let e=t.anchor;if(e.type!=="text")return;let o=e.getNode();if(!o.isSimpleText())return;let r=e.offset,c=o.getTextContent().slice(0,r),s=n.replaceableString.length,i=Re(c,n.matchingString,s),a=r-i;if(a<0)return;let l;return a===0?[l]=o.splitText(r):[,l]=o.splitText(a,r),l}function Fe(n,t){let e=getComputedStyle(n),o=e.position==="absolute",r=t?/(auto|scroll|hidden)/:/(auto|scroll)/;if(e.position==="fixed")return document.body;for(let c=n;c=c.parentElement;)if(e=getComputedStyle(c),!(o&&e.position==="static")&&r.test(e.overflow+e.overflowY+e.overflowX))return c;return document.body}function st(n,t){let e=n.getBoundingClientRect(),o=t.getBoundingClientRect();return e.top>o.top&&e.top<o.bottom}function Ie(n,t,e,o){let r=at(7),[c]=lt(),s,i;r[0]!==c||r[1]!==e||r[2]!==o||r[3]!==n||r[4]!==t?(s=()=>{let a=t.current;if(a!=null&&n!=null){let l=c.getRootElement(),u=l!=null?Fe(l,!1):document.body,g=!1,m=st(a,u),p=function(){g||(window.requestAnimationFrame(function(){e(),g=!1}),g=!0);let d=st(a,u);d!==m&&(m=d,o?.(d))},f=new ResizeObserver(e);return window.addEventListener("resize",e),document.addEventListener("scroll",p,{capture:!0,passive:!0}),f.observe(a),()=>{f.disconnect(),window.removeEventListener("resize",e),document.removeEventListener("scroll",p,!0)}}},i=[c,o,e,n,t],r[0]=c,r[1]=e,r[2]=o,r[3]=n,r[4]=t,r[5]=s,r[6]=i):(s=r[5],i=r[6]),y(s,i)}var ct=de("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function ut({anchorElementRef:n,close:t,editor:e,groups:o,menuRenderFn:r,resolution:c,shouldSplitNodeWithQuery:s=!1}){let[i,a]=Se(null),l=c.match&&c.match.matchingString||"",u=z(f=>{let d=e.getRootElement();d!==null&&(d.setAttribute("aria-activedescendant",`${we}__item-${f.key}`),a(f.key))},[e]),g=z(()=>{if(o!==null&&l!=null){let f=o.flatMap(d=>d.items);if(f.length){let d=f[0];u(d)}}},[o,u,l]);y(()=>{g()},[l,g]);let m=z(f=>{t(),e.update(()=>{let d=c.match!=null&&s?Ce(c.match):null;d&&d.remove()}),setTimeout(()=>{let d;e.read(()=>{d=ft()?.clone()}),e.update(()=>{d&&ue(d)}),f.onSelect({editor:e,queryString:c.match?c.match.matchingString:""})},0)},[e,s,c.match,t]);y(()=>()=>{let f=e.getRootElement();f!==null&&f.removeAttribute("aria-activedescendant")},[e]),Ee(()=>{o===null?a(null):i===null&&g()},[o,i,u,g]),y(()=>rt(e.registerCommand(ct,({item:f})=>f.ref&&f.ref.current!=null?(it(f.ref.current),!0):!1,N)),[e,u]),y(()=>rt(e.registerCommand(me,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==h.length-1?x+1:0,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&e.dispatchCommand(ct,{index:E,item:_}),d.preventDefault(),d.stopImmediatePropagation()}return!0},N),e.registerCommand(ge,f=>{let d=f;if(o!==null&&o.length&&i!==null){let h=o.flatMap(T=>T.items),x=h.findIndex(T=>T.key===i),E=x!==0?x-1:h.length-1,_=h[E];if(!_)return!1;u(_),_.ref!=null&&_.ref.current&&it(_.ref.current),d.preventDefault(),d.stopImmediatePropagation()}return!0},N),e.registerCommand(he,f=>{let d=f;return d.preventDefault(),d.stopImmediatePropagation(),t(),!0},N),e.registerCommand(xe,f=>{let d=f;if(o===null||i===null)return!1;let x=o.flatMap(E=>E.items).find(E=>E.key===i);return x?(d.preventDefault(),d.stopImmediatePropagation(),m(x),!0):!1},N),e.registerCommand(pe,f=>{if(o===null||i===null)return!1;let h=o.flatMap(x=>x.items).find(x=>x.key===i);return h?(f!==null&&(f.preventDefault(),f.stopImmediatePropagation()),m(h),!0):!1},N)),[m,t,e,o,i,u]);let p=_e(()=>({groups:o,selectedItemKey:i,selectItemAndCleanUp:m,setSelectedItemKey:a}),[m,i,o]);return r(n,p,c.match?c.match.matchingString:"")}function Ne(n,t){t!=null&&(n.className=t),n.setAttribute("aria-label","Slash menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function dt(n,t,e,o){let r=at(14),[c]=lt(),s;r[0]===Symbol.for("react.memo_cache_sentinel")?(s=nt?document.createElement("div"):null,r[0]=s):s=r[0];let i=Te(s),a;r[1]!==n||r[2]!==o||r[3]!==c||r[4]!==t?(a=()=>{if(i.current===null||parent===void 0)return;let f=c.getRootElement(),d=i.current,h=d.firstChild;if(f!==null&&t!==null){let{height:x,width:E}=t.getRect(),{left:_,top:T}=t.getRect(),I=T;if(T=T-(n.getBoundingClientRect().top+window.scrollY),_=_-(n.getBoundingClientRect().left+window.scrollX),d.style.left=`${_+window.scrollX}px`,d.style.height=`${x}px`,d.style.width=`${E}px`,h!==null){let S=h.getBoundingClientRect(),$=S.height,C=S.width,et=f.getBoundingClientRect();_+C>et.right&&(d.style.left=`${et.right-C+window.scrollX}px`);let ie=I+$+32>window.innerHeight,se=I<0;ie&&!se?d.style.top=`${T+32-$+window.scrollY-(x+24)}px`:d.style.top=`${T+window.scrollY+32}px`}d.isConnected||(Ne(d,o),n.append(d)),d.setAttribute("id","slash-menu"),i.current=d,f.setAttribute("aria-controls","slash-menu")}},r[1]=n,r[2]=o,r[3]=c,r[4]=t,r[5]=a):a=r[5];let l=a,u,g;r[6]!==c||r[7]!==l||r[8]!==t?(u=()=>{let f=c.getRootElement();if(t!==null)return l(),()=>{f!==null&&f.removeAttribute("aria-controls");let d=i.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},g=[c,l,t],r[6]=c,r[7]=l,r[8]=t,r[9]=u,r[10]=g):(u=r[9],g=r[10]),y(u,g);let m;return r[11]!==t||r[12]!==e?(m=f=>{t!==null&&(f||e(null))},r[11]=t,r[12]=e,r[13]=m):m=r[13],Ie(t,i,l,m),i}var ro=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function De(n){let t=n.anchor;if(t.type!=="text")return null;let e=t.getNode();if(!e.isSimpleText())return null;let o=t.offset;return e.getTextContent().slice(0,o)}function pt(n,t,e){let o=Le(e);if(o===null||!o.isCollapsed)return!1;let r=o.anchorNode,c=n,s=o.anchorOffset;if(r==null||s==null)return!1;try{t.setStart(r,c),t.setEnd(r,s>1?s:1)}catch{return!1}return!0}function Be(n){let t;return n.getEditorState().read(()=>{let e=Y();W(e)&&(t=De(e))}),t}function ht(n,t){return t!==0?!1:n.getEditorState().read(()=>{let e=Y();if(W(e)){let c=e.anchor.getNode().getPreviousSibling();return Ae(c)&&c.isTextEntity()}return!1})}function xt(n){X.startTransition?X.startTransition(n):n()}var Pe=Me("ENABLE_SLASH_MENU_COMMAND");function io({anchorClassName:n,anchorElem:t,groups:e,menuRenderFn:o,onClose:r,onOpen:c,onQueryChange:s,triggerFn:i}){let[a]=be(),[l,u]=$e(null),g=dt(t,l,u,n),m=mt(()=>{u(null),r!=null&&l!==null&&r()},[r,l]),p=mt(f=>{u(f),c!=null&&l===null&&c(f)},[c,l]);return gt(()=>ke(a.registerCommand(Pe,({node:f})=>(a.getEditorState().read(()=>{let d={leadOffset:0,matchingString:"",replaceableString:""};if(!ht(a,d.leadOffset)&&f!==null){let h=a._window??window,x=h.document.createRange();pt(d.leadOffset,x,h)!==null&&xt(()=>p({getRect:()=>x.getBoundingClientRect(),match:d}));return}}),!0),Oe)),[a,p]),gt(()=>{let f=()=>{a.getEditorState().read(()=>{let h=a._window??window,x=h.document.createRange(),E=Y(),_=Be(a);if(!W(E)||!E.isCollapsed()||_===void 0||x===null){m();return}let T=i({editor:a,query:_});if(s(T?T.matchingString:null),T!==null&&!ht(a,T.leadOffset)&&pt(T.leadOffset,x,h)!==null){xt(()=>p({getRect:()=>x.getBoundingClientRect(),match:T}));return}m()})},d=a.registerUpdateListener(f);return()=>{d()}},[a,i,s,l,m,p]),g.current===null||l===null||a===null?null:ye(ut,{anchorElementRef:g,close:m,editor:a,groups:e,menuRenderFn:o,resolution:l,shouldSplitNodeWithQuery:!0})}var Et=class n{_bottom;_left;_right;_top;constructor(t,e,o,r){let[c,s]=e<=r?[e,r]:[r,e],[i,a]=t<=o?[t,o]:[o,t];this._top=c,this._right=a,this._left=i,this._bottom=s}static fromDOM(t){let{height:e,left:o,top:r,width:c}=t.getBoundingClientRect();return n.fromLWTH(o,c,r,e)}static fromDOMRect(t){let{height:e,left:o,top:r,width:c}=t;return n.fromLWTH(o,c,r,e)}static fromLTRB(t,e,o,r){return new n(t,e,o,r)}static fromLWTH(t,e,o,r){return new n(t,o,t+e,o+r)}static fromPoints(t,e){let{x:o,y:r}=t,{x:c,y:s}=e;return n.fromLTRB(o,r,c,s)}contains(t){if(ot(t)){let{x:s,y:i}=t,a=i<this._top,l=i>this._bottom,u=s<this._left,g=s>this._right;return{reason:{isOnBottomSide:l,isOnLeftSide:u,isOnRightSide:g,isOnTopSide:a},result:!a&&!l&&!u&&!g}}let{bottom:e,left:o,right:r,top:c}=t;return c>=this._top&&c<=this._bottom&&e>=this._top&&e<=this._bottom&&o>=this._left&&o<=this._right&&r>=this._left&&r<=this._right}distanceFromPoint(t){let e=this.contains(t);if(e.result)return{distance:0,isOnBottomSide:e.reason.isOnBottomSide,isOnLeftSide:e.reason.isOnLeftSide,isOnRightSide:e.reason.isOnRightSide,isOnTopSide:e.reason.isOnTopSide};let o=0,r=0;return t.x<this._left?o=this._left-t.x:t.x>this._right&&(o=t.x-this._right),t.y<this._top?r=this._top-t.y:t.y>this._bottom&&(r=t.y-this._bottom),{distance:Math.sqrt(o*o+r*r),isOnBottomSide:t.y>this._bottom,isOnLeftSide:t.x<this._left,isOnRightSide:t.x>this._right,isOnTopSide:t.y<this._top}}equals({bottom:t,left:e,right:o,top:r}){return r===this._top&&t===this._bottom&&e===this._left&&o===this._right}generateNewRect({bottom:t=this.bottom,left:e=this.left,right:o=this.right,top:r=this.top}){return new n(e,r,o,t)}intersectsWith(t){let{height:e,left:o,top:r,width:c}=t,{height:s,left:i,top:a,width:l}=this,u=o+c>=i+l?o+c:i+l,g=r+e>=a+s?r+e:a+s,m=o<=i?o:i,p=r<=a?r:a;return u-m<=c+l&&g-p<=e+s}get bottom(){return this._bottom}get height(){return Math.abs(this._bottom-this._top)}get left(){return this._left}get right(){return this._right}get top(){return this._top}get width(){return Math.abs(this._left-this._right)}};function lo({editorConfig:n}){return ve({nodes:n.features.nodes})}function ve({nodes:n}){return n.map(t=>"node"in t?t.node:t)}import{$getRoot as qe,$isDecoratorNode as Rt,$isElementNode as P,$isLineBreakNode as Qe,$isTextNode as v}from"lexical";import{$isListItemNode as He,$isListNode as _t}from"@lexical/list";import{$isHeadingNode as Ke,$isQuoteNode as Ue}from"@lexical/rich-text";import{$isParagraphNode as Ge,$isTextNode as ze}from"lexical";var w={markdownFormatKind:null,regEx:/(?:)/,regExForAutoFormatting:/(?:)/,requiresParagraphStart:!1},R={...w,requiresParagraphStart:!0},po={...R,export:b(1),markdownFormatKind:"paragraphH1",regEx:/^# /,regExForAutoFormatting:/^# /},ho={...R,export:b(2),markdownFormatKind:"paragraphH2",regEx:/^## /,regExForAutoFormatting:/^## /},xo={...R,export:b(3),markdownFormatKind:"paragraphH3",regEx:/^### /,regExForAutoFormatting:/^### /},Eo={...R,export:b(4),markdownFormatKind:"paragraphH4",regEx:/^#### /,regExForAutoFormatting:/^#### /},_o={...R,export:b(5),markdownFormatKind:"paragraphH5",regEx:/^##### /,regExForAutoFormatting:/^##### /},To={...R,export:b(6),markdownFormatKind:"paragraphH6",regEx:/^###### /,regExForAutoFormatting:/^###### /},So={...R,export:Ye,markdownFormatKind:"paragraphBlockQuote",regEx:/^> /,regExForAutoFormatting:/^> /},wo={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})- /,regExForAutoFormatting:/^(\s{0,10})- /},Ro={...R,export:q,markdownFormatKind:"paragraphUnorderedList",regEx:/^(\s{0,10})\* /,regExForAutoFormatting:/^(\s{0,10})\* /},Co={...R,export:q,markdownFormatKind:"paragraphOrderedList",regEx:/^(\s{0,10})(\d+)\.\s/,regExForAutoFormatting:/^(\s{0,10})(\d+)\.\s/},Fo={...R,markdownFormatKind:"horizontalRule",regEx:/^\*\*\*$/,regExForAutoFormatting:/^\*\*\* /},Io={...R,markdownFormatKind:"horizontalRule",regEx:/^---$/,regExForAutoFormatting:/^--- /},No={...w,exportFormat:"code",exportTag:"`",markdownFormatKind:"code",regEx:/(`)(\s*)([^`]*)(\s*)(`)()/,regExForAutoFormatting:/(`)(\s*\b)([^`]*)(\b\s*)(`)(\s)$/},yo={...w,exportFormat:"bold",exportTag:"**",markdownFormatKind:"bold",regEx:/(\*\*)(\s*)([^*]*)(\s*)(\*\*)()/,regExForAutoFormatting:/(\*\*)(\s*\b)([^*]*)(\b\s*)(\*\*)(\s)$/},bo={...w,exportFormat:"italic",exportTag:"*",markdownFormatKind:"italic",regEx:/(\*)(\s*)([^*]*)(\s*)(\*)()/,regExForAutoFormatting:/(\*)(\s*\b)([^*]*)(\b\s*)(\*)(\s)$/},ko={...w,exportFormat:"bold",exportTag:"_",markdownFormatKind:"bold",regEx:/(__)(\s*)([^_]*)(\s*)(__)()/,regExForAutoFormatting:/(__)(\s*)([^_]*)(\s*)(__)(\s)$/},Ao={...w,exportFormat:"italic",exportTag:"_",markdownFormatKind:"italic",regEx:/(_)()([^_]*)()(_)()/,regExForAutoFormatting:/(_)()([^_]*)()(_)(\s)$/},Oo={...w,exportFormat:"underline",exportTag:"<u>",exportTagClose:"</u>",markdownFormatKind:"underline",regEx:/(<u>)(\s*)([^<]*)(\s*)(<\/u>)()/,regExForAutoFormatting:/(<u>)(\s*\b)([^<]*)(\b\s*)(<\/u>)(\s)$/},Mo={...w,exportFormat:"strikethrough",exportTag:"~~",markdownFormatKind:"strikethrough",regEx:/(~~)(\s*)([^~]*)(\s*)(~~)()/,regExForAutoFormatting:/(~~)(\s*\b)([^~]*)(\b\s*)(~~)(\s)$/},Lo={...w,markdownFormatKind:"strikethrough_italic_bold",regEx:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)()/,regExForAutoFormatting:/(~~_\*\*)(\s*\b)([^*_~]+)(\b\s*)(\*\*_~~)(\s)$/},$o={...w,markdownFormatKind:"italic_bold",regEx:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)/,regExForAutoFormatting:/(_\*\*)(\s*\b)([^*_]+)(\b\s*)(\*\*_)(\s)$/},Do={...w,markdownFormatKind:"strikethrough_italic",regEx:/(~~_)(\s*)([^_~]+)(\s*)(_~~)/,regExForAutoFormatting:/(~~_)(\s*)([^_~]+)(\s*)(_~~)(\s)$/},Bo={...w,markdownFormatKind:"strikethrough_bold",regEx:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)/,regExForAutoFormatting:/(~~\*\*)(\s*\b)([^*~]+)(\b\s*)(\*\*~~)(\s)$/},Po={...w,markdownFormatKind:"link",regEx:/(\[)([^\]]*)(\]\()([^)]*)(\)*)()/,regExForAutoFormatting:/(\[)([^\]]*)(\]\()([^)]*)(\)*)(\s)$/};function b(n){return(t,e)=>Ke(t)&&t.getTag()==="h"+n?"#".repeat(n)+" "+e(t):null}function q(n,t){return _t(n)?Tt(n,t,0):null}var Xe=4;function Tt(n,t,e){let o=[],r=n.getChildren(),c=0;for(let s of r)if(He(s)){if(s.getChildrenSize()===1){let l=s.getFirstChild();if(_t(l)){o.push(Tt(l,t,e+1));continue}}let i=" ".repeat(e*Xe),a=n.getListType()==="bullet"?"- ":`${n.getStart()+c}. `;o.push(i+a+t(s)),c++}return o.join(`
|
|
2
|
-
`)}function Ye(n,t){return Ue(n)?"> "+t(n):null}function D(n,t){let e={};for(let o of n){let r=t(o);r&&(e[r]?e[r].push(o):e[r]=[o])}return e}function k(n){let t=D(n,e=>e.type);return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}var A=/[!-/:-@[-`{-~\s]/,We=/^\s{0,3}$/;function L(n){if(!Ge(n))return!1;let t=n.getFirstChild();return t==null||n.getChildrenSize()===1&&ze(t)&&We.test(t.getTextContent())}function Ct(n,t=!1){let e=k(n),o=[...e.multilineElement,...e.element],r=!t,c=e.textFormat.filter(s=>s.format.length===1).sort((s,i)=>s.format.includes("code")&&!i.format.includes("code")?1:!s.format.includes("code")&&i.format.includes("code")?-1:0);return s=>{let i=[],a=(s||qe()).getChildren();return a.forEach((l,u)=>{let g=je(l,o,c,e.textMatch);g!=null&&i.push(r&&u>0&&!L(l)&&!L(a[u-1])?`
|
|
3
|
-
`.concat(g):g)}),i.join(`
|
|
4
|
-
`)}}function je(n,t,e,o){for(let r of t){if(!r.export)continue;let c=r.export(n,s=>H(s,e,o));if(c!=null)return c}return P(n)?H(n,e,o):Rt(n)?n.getTextContent():null}function H(n,t,e,o,r){let c=[],s=n.getChildren();o||(o=[]),r||(r=[]);t:for(let i of s){for(let a of e){if(!a.export)continue;let l=a.export(i,u=>H(u,t,e,o,[...r,...o]),(u,g)=>St(u,g,t,o,r));if(l!=null){c.push(l);continue t}}Qe(i)?c.push(`
|
|
5
|
-
`):v(i)?c.push(St(i,i.getTextContent(),t,o,r)):P(i)?c.push(H(i,t,e,o,r)):Rt(i)&&c.push(i.getTextContent())}return c.join("")}function St(n,t,e,o,r){let c=t.trim(),s=c;n.hasFormat("code")||(s=s.replace(/([*_`~\\])/g,"\\$1"));let i="",a="",l="",u=wt(n,!0),g=wt(n,!1),m=new Set;for(let p of e){let f=p.format[0],d=p.tag;B(n,f)&&!m.has(f)&&(m.add(f),(!B(u,f)||!o.find(h=>h.tag===d))&&(o.push({format:f,tag:d}),i+=d))}for(let p=0;p<o.length;p++){let f=o[p],d=B(n,f.format),h=B(g,f.format);if(d&&h)continue;let x=[...o];for(;x.length>p;){let E=x.pop();r&&E&&r.find(_=>_.tag===E.tag)||(E&&typeof E.tag=="string"&&(d?h||(l+=E.tag):a+=E.tag),o.pop())}break}return s=i+s+l,a+t.replace(c,()=>s)}function wt(n,t){let e=t?n.getPreviousSibling():n.getNextSibling();if(!e){let o=n.getParentOrThrow();o.isInline()&&(e=t?o.getPreviousSibling():o.getNextSibling())}for(;e;){if(P(e)){if(!e.isInline())break;let o=t?e.getLastDescendant():e.getFirstDescendant();if(v(o))return o;e=t?e.getPreviousSibling():e.getNextSibling()}if(v(e))return e;if(!P(e))return null}return null}function B(n,t){return v(n)&&n.hasFormat(t)}import{$isListItemNode as Ze,$isListNode as bt}from"@lexical/list";import{$isQuoteNode as Je}from"@lexical/rich-text";import{$findMatchingParent as tn}from"@lexical/utils";import{$createLineBreakNode as en,$createParagraphNode as nn,$createTextNode as on,$getRoot as rn,$getSelection as sn,$isParagraphNode as cn}from"lexical";import{$isTextNode as O}from"lexical";function Ft(n,t){let e=n.getTextContent(),o=Ve(e,t);if(!o)return null;let r=o.index||0,c=r+o[0].length,s=t.transformersByTag[o[1]];return{endIndex:c,match:o,startIndex:r,transformer:s}}function Ve(n,t){let e=n.match(t.openTagsRegExp);if(e==null)return null;for(let o of e){let r=o.replace(/^\s/,""),c=t.fullMatchRegExpByTag[r];if(c==null)continue;let s=n.match(c),i=t.transformersByTag[r];if(s!=null&&i!=null){if(i.intraword!==!1)return s;let{index:a=0}=s,l=n[a-1],u=n[a+s[0].length];if((!l||A.test(l))&&(!u||A.test(u)))return s}}return null}function It(n,t,e,o,r){let c=n.getTextContent(),s,i,a;if(r[0]===c?a=n:t===0?[a,s]=n.splitText(e):[i,a,s]=n.splitText(t,e),a.setTextContent(r[2]),o)for(let l of o.format)a.hasFormat(l)||a.toggleFormat(l);return{nodeAfter:s,nodeBefore:i,transformedNode:a}}function Nt(n,t){let e=n,o,r,c,s;for(let i of t){if(!i.replace||!i.importRegExp)continue;let a=e.getTextContent().match(i.importRegExp);if(!a)continue;let l=a.index||0,u=i.getEndIndex?i.getEndIndex(e,a):l+a[0].length;u!==!1&&(o===void 0||r===void 0||l<o&&u>r)&&(o=l,r=u,c=i,s=a)}return o===void 0||r===void 0||c===void 0||s===void 0?null:{endIndex:r,match:s,startIndex:o,transformer:c}}function yt(n,t,e,o,r){let c,s,i;if(t===0?[i,c]=n.splitText(e):[s,i,c]=n.splitText(t,e),!o.replace)return null;let a=i?o.replace(i,r):void 0;return{nodeAfter:c,nodeBefore:s,transformedNode:a||void 0}}function F(n,t,e){let o=Ft(n,t),r=Nt(n,e);if(o&&r&&(o.startIndex<=r.startIndex&&o.endIndex>=r.endIndex?r=null:o=null),o){let i=It(n,o.startIndex,o.endIndex,o.transformer,o.match);i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}else if(r){let i=yt(n,r.startIndex,r.endIndex,r.transformer,r.match);if(!i)return;i.nodeAfter&&O(i.nodeAfter)&&!i.nodeAfter.hasFormat("code")&&F(i.nodeAfter,t,e),i.nodeBefore&&O(i.nodeBefore)&&!i.nodeBefore.hasFormat("code")&&F(i.nodeBefore,t,e),i.transformedNode&&O(i.transformedNode)&&!i.transformedNode.hasFormat("code")&&F(i.transformedNode,t,e)}let s=n.getTextContent().replace(/\\([*_`~])/g,"$1");n.setTextContent(s)}function kt(n,t=!1){let e=k(n),o=fn(e.textFormat);return(r,c)=>{let s=r.split(`
|
|
6
|
-
`),i=s.length,a=c||rn();a.clear();for(let u=0;u<i;u++){let g=s[u],[m,p]=an(s,u,e.multilineElement,a);if(m){u=p;continue}ln(g,a,e.element,o,e.textMatch)}let l=a.getChildren();for(let u of l)!t&&L(u)&&a.getChildrenSize()>1&&u.remove();sn()!==null&&a.selectStart()}}function an(n,t,e,o){for(let r of e){let{handleImportAfterStartMatch:c,regExpEnd:s,regExpStart:i,replace:a}=r,l=n[t]?.match(i);if(!l)continue;if(c){let f=c({lines:n,rootNode:o,startLineIndex:t,startMatch:l,transformer:r});if(f===null)continue;if(f)return f}let u=typeof s=="object"&&"regExp"in s?s.regExp:s,g=s&&typeof s=="object"&&"optional"in s?s.optional:!s,m=t,p=n.length;for(;m<p;){let f=u?n[m]?.match(u):null;if(!f&&(!g||g&&m<p-1)){m++;continue}if(f&&t===m&&f.index===l.index){m++;continue}let d=[];if(f&&t===m)d.push(n[t].slice(l[0].length,-f[0].length));else for(let h=t;h<=m;h++){let x=n[h];if(h===t){let E=x.slice(l[0].length);d.push(E)}else if(h===m&&f){let E=x.slice(0,-f[0].length);d.push(E)}else d.push(x)}if(a(o,null,l,f,d,!0)!==!1)return[!0,m];break}}return[!1,t]}function ln(n,t,e,o,r){let c=on(n),s=nn();s.append(c),t.append(s);for(let{regExp:i,replace:a}of e){let l=n.match(i);if(l&&(c.setTextContent(n.slice(l[0].length)),a(s,[c],l,!0)!==!1))break}if(F(c,o,r),s.isAttached()&&n.length>0){let i=s.getPreviousSibling();if(cn(i)||Je(i)||bt(i)){let a=i;if(bt(i)){let l=i.getLastDescendant();l==null?a=null:a=tn(l,Ze)}a!=null&&a.getTextContentSize()>0&&(a.splice(a.getChildrenSize(),0,[en(),...s.getChildren()]),s.remove())}}}function fn(n){let t={},e={},o=[],r="(?<![\\\\])";for(let c of n){let{tag:s}=c;t[s]=c;let i=s.replace(/([*^+])/g,"\\$1");o.push(i),s.length===1?e[s]=new RegExp(`(?<![\\\\${i}])(${i})((\\\\${i})?.*?[^${i}\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?![\\\\${i}])`):e[s]=new RegExp(`(?<!\\\\)(${i})((\\\\${i})?.*?[^\\s](\\\\${i})?)((?<!\\\\)|(?<=\\\\\\\\))(${i})(?!\\\\)`)}return{fullMatchRegExpByTag:e,openTagsRegExp:new RegExp(`${r}(${o.join("|")})`,"g"),transformersByTag:t}}import{$createRangeSelection as un,$getSelection as Q,$isLineBreakNode as dn,$isRangeSelection as j,$isRootOrShadowRoot as Ot,$isTextNode as Mt,$setSelection as mn}from"lexical";function gn(n,t,e,o){let r=n.getParent();if(!Ot(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExp:s,replace:i}of o){let a=c.match(s);if(a&&a[0].length===(a[0].endsWith(" ")?e:e-1)){let l=t.getNextSiblings(),[u,g]=t.splitText(e);u?.remove();let m=g?[g,...l]:l;if(i(n,m,a,!1)!==!1)return!0}}return!1}function pn(n,t,e,o){let r=n.getParent();if(!Ot(r)||n.getFirstChild()!==t)return!1;let c=t.getTextContent();if(c[e-1]!==" ")return!1;for(let{regExpEnd:s,regExpStart:i,replace:a}of o){if(s&&!("optional"in s)||s&&"optional"in s&&!s.optional)continue;let l=c.match(i);if(l&&l[0].length===(l[0].endsWith(" ")?e:e-1)){let u=t.getNextSiblings(),[g,m]=t.splitText(e);g?.remove();let p=m?[m,...u]:u;if(a(n,p,l,null,null,!1)!==!1)return!0}}return!1}function hn(n,t,e){let o=n.getTextContent(),r=o[t-1],c=e[r];if(c==null)return!1;t<o.length&&(o=o.slice(0,t));for(let s of c){if(!s.replace||!s.regExp)continue;let i=o.match(s.regExp);if(i===null)continue;let a=i.index||0,l=a+i[0].length,u;return a===0?[u]=n.splitText(l):[,u]=n.splitText(a,l),u&&(u.selectNext(0,0),s.replace(u,i)),!0}return!1}function xn(n,t,e){let o=n.getTextContent(),r=t-1,c=o[r],s=e[c];if(!s)return!1;for(let i of s){let{tag:a}=i,l=a.length,u=r-l+1;if(l>1&&!Lt(o,u,a,0,l)||o[u-1]===" ")continue;let g=o[r+1];if(i.intraword===!1&&g&&!A.test(g))continue;let m=n,p=m,f=At(o,u,a),d=p;for(;f<0&&(d=d.getPreviousSibling())&&!dn(d);)if(Mt(d)){let C=d.getTextContent();p=d,f=At(C,C.length,a)}if(f<0||p===m&&f+l===u)continue;let h=p.getTextContent();if(f>0&&h[f-1]===c)continue;let x=h[f-1];if(i.intraword===!1&&x&&!A.test(x))continue;let E=m.getTextContent(),_=E.slice(0,u)+E.slice(r+1);m.setTextContent(_);let T=p===m?_:h;p.setTextContent(T.slice(0,f)+T.slice(f+l));let I=Q(),S=un();mn(S);let $=r-l*(p===m?2:1)+1;S.anchor.set(p.__key,f,"text"),S.focus.set(m.__key,$,"text");for(let C of i.format)S.hasFormat(C)||S.formatText(C);S.anchor.set(S.focus.key,S.focus.offset,S.focus.type);for(let C of i.format)S.hasFormat(C)&&S.toggleFormat(C);return j(I)&&(S.format=I.format),!0}return!1}function At(n,t,e){let o=e.length;for(let r=t;r>=o;r--){let c=r-o;if(Lt(n,c,e,0,o)&&n[c+o]!==" ")return c}return-1}function Lt(n,t,e,o,r){for(let c=0;c<r;c++)if(n[t+c]!==e[o+c])return!1;return!0}function sr(n,t=K){let e=k(t),o=D(e.textFormat,({tag:s})=>s[s.length-1]),r=D(e.textMatch,({trigger:s})=>s);for(let s of t){let i=s.type;if(i==="element"||i==="text-match"||i==="multiline-element"){let a=s.dependencies;for(let l of a)if(!n.hasNode(l))throw new Error("MarkdownShortcuts: missing dependency %s for transformer. Ensure node dependency is included in editor initial config."+l.getType())}}let c=(s,i,a)=>{gn(s,i,a,e.element)||pn(s,i,a,e.multilineElement)||hn(i,a,r)||xn(i,a,o)};return n.registerUpdateListener(({dirtyLeaves:s,editorState:i,prevEditorState:a,tags:l})=>{if(l.has("collaboration")||l.has("historic")||n.isComposing())return;let u=i.read(Q),g=a.read(Q);if(!j(g)||!j(u)||!u.isCollapsed()||u.is(g))return;let m=u.anchor.key,p=u.anchor.offset,f=i._nodeMap.get(m);!Mt(f)||!s.has(m)||p!==1&&p>g.anchor.offset+1||n.update(()=>{if(f.hasFormat("code"))return;let d=f.getParent();d!==null&&c(d,f,u.anchor.offset)})})}import{$createListItemNode as En,$createListNode as _n,$isListItemNode as Tn,$isListNode as M,ListItemNode as Z,ListNode as J}from"@lexical/list";import{$createHeadingNode as Sn,$createQuoteNode as wn,$isHeadingNode as Rn,$isQuoteNode as $t,HeadingNode as Cn,QuoteNode as Fn}from"@lexical/rich-text";import{$createLineBreakNode as In}from"lexical";var Dt=/^[\t ]*$/,Ht=/^(\s*)(\d+)\.\s/,Kt=/^(\s*)[-*+]\s/,Ut=/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,V=/^(#{1,6})\s/,Gt=/^>\s/,Nn=/^[ \t]*(\\`\\`\\`|```)(\w+)?/,Bt=/[ \t]*(\\`\\`\\`|```)$/,yn=/^[ \t]*```[^`]+(?:(?:`{1,2}|`{4,})[^`]+)*```(?:[^`]|$)/,bn=/^\|(.+)\|\s?$/,kn=/^(\| ?:?-*:? ?)+\|\s?$/,Pt=/^[ \t]*<[a-z_][\w-]*(?:\s[^<>]*)?\/?>/i,vt=/^[ \t]*<\/[a-z_][\w-]*\s*>/i,An=n=>(t,e,o)=>{let r=n(o);r.append(...e),t.replace(r),r.select(0,0)},zt=4;function On(n){let t=n.match(/\t/g),e=n.match(/ /g),o=0;return t&&(o+=t.length),e&&(o+=Math.floor(e.length/zt)),o}var tt=n=>(t,e,o)=>{let r=t.getPreviousSibling(),c=t.getNextSibling(),s=En(n==="check"?o[3]==="x":void 0);if(M(c)&&c.getListType()===n){let a=c.getFirstChild();a!==null?a.insertBefore(s):c.append(s),t.remove()}else if(M(r)&&r.getListType()===n)r.append(s),t.remove();else{let a=_n(n,n==="number"?Number(o[2]):void 0);a.append(s),t.replace(a)}s.append(...e),s.select(0,0);let i=On(o[1]);i&&s.setIndent(i)},U=(n,t,e)=>{let o=[],r=n.getChildren(),c=0;for(let s of r)if(Tn(s)){if(s.getChildrenSize()===1){let u=s.getFirstChild();if(M(u)){o.push(U(u,t,e+1));continue}}let i=" ".repeat(e*zt),a=n.getListType(),l=a==="number"?`${n.getStart()+c}. `:a==="check"?`- [${s.getChecked()?"x":" "}] `:"- ";o.push(i+l+t(s)),c++}return o.join(`
|
|
7
|
-
`)},Xt={type:"element",dependencies:[Cn],export:(n,t)=>{if(!Rn(n))return null;let e=Number(n.getTag().slice(1));return"#".repeat(e)+" "+t(n)},regExp:V,replace:An(n=>{let t="h"+n[1].length;return Sn(t)})},Yt={type:"element",dependencies:[Fn],export:(n,t)=>{if(!$t(n))return null;let e=t(n).split(`
|
|
8
|
-
`),o=[];for(let r of e)o.push("> "+r);return o.join(`
|
|
9
|
-
`)},regExp:Gt,replace:(n,t,e,o)=>{if(o){let c=n.getPreviousSibling();if($t(c)){c.splice(c.getChildrenSize(),0,[In(),...t]),c.select(0,0),n.remove();return}}let r=wn();r.append(...t),n.replace(r),r.select(0,0)}},Wt={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Kt,replace:tt("bullet")},Mn={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Ut,replace:tt("check")},qt={type:"element",dependencies:[J,Z],export:(n,t)=>M(n)?U(n,t,0):null,regExp:Ht,replace:tt("number")},Qt={type:"text-format",format:["code"],tag:"`"},jt={type:"text-format",format:["highlight"],tag:"=="},Vt={type:"text-format",format:["bold","italic"],tag:"***"},Zt={type:"text-format",format:["bold","italic"],intraword:!1,tag:"___"},Jt={type:"text-format",format:["bold"],tag:"**"},te={type:"text-format",format:["bold"],intraword:!1,tag:"__"},ee={type:"text-format",format:["strikethrough"],tag:"~~"},ne={type:"text-format",format:["italic"],tag:"*"},oe={type:"text-format",format:["italic"],intraword:!1,tag:"_"};function re(n,t){let e=n.split(`
|
|
10
|
-
`),o=!1,r=[],c=0;for(let s=0;s<e.length;s++){let i=e[s],a=r[r.length-1];if(yn.test(i)){r.push(i);continue}if(Bt.test(i)){c===0&&(o=!0),c===1&&(o=!1),c>0&&c--,r.push(i);continue}if(Nn.test(i)){o=!0,c++,r.push(i);continue}if(o){r.push(i);continue}Dt.test(i)||Dt.test(a)||!a||V.test(a)||V.test(i)||Gt.test(i)||Ht.test(i)||Kt.test(i)||Ut.test(i)||bn.test(i)||kn.test(i)||!t||Pt.test(i)||vt.test(i)||Pt.test(a)||vt.test(a)||Bt.test(a)?r.push(i):r[r.length-1]=a+" "+i.trim()}return r.join(`
|
|
11
|
-
`)}var Ln=[Xt,Yt,Wt,qt],$n=[],Dn=[Qt,Vt,Zt,Jt,te,jt,ne,oe,ee],Bn=[],K=[...Ln,...$n,...Dn,...Bn];function pr(n,t=K,e,o=!1,r=!0){let c=o?n:re(n,r);return kt(t,o)(c,e)}function hr(n=K,t,e=!1){return Ct(n,e)(t)}export{nt as a,Un as b,sr as c,pr as d,hr as e,G as f,ot as g,ro as h,Pe as i,io as j,Et as k,lo as l};
|
|
12
|
-
//# sourceMappingURL=chunk-YCH4JNUH.js.map
|