@payloadcms/richtext-lexical 3.2.2-canary.6fb5cd8 → 3.2.2-canary.a11698b

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.
Files changed (45) hide show
  1. package/dist/exports/client/Field-JP7H7AZE.js +2 -0
  2. package/dist/exports/client/Field-JP7H7AZE.js.map +7 -0
  3. package/dist/exports/client/{chunk-RAIJNT4Z.js → chunk-WHL7AV5U.js} +2 -2
  4. package/dist/exports/client/{chunk-RAIJNT4Z.js.map → chunk-WHL7AV5U.js.map} +3 -3
  5. package/dist/exports/client/componentInline-GXYBWVCR.js +2 -0
  6. package/dist/exports/client/index.js +11 -11
  7. package/dist/exports/client/index.js.map +4 -4
  8. package/dist/exports/react/components/RichText/converter/converters/list.d.ts.map +1 -1
  9. package/dist/exports/react/components/RichText/converter/converters/list.js +1 -6
  10. package/dist/exports/react/components/RichText/converter/converters/list.js.map +1 -1
  11. package/dist/exports/react/components/RichText/converter/converters/text.d.ts.map +1 -1
  12. package/dist/exports/react/components/RichText/converter/converters/text.js +1 -4
  13. package/dist/exports/react/components/RichText/converter/converters/text.js.map +1 -1
  14. package/dist/exports/react/components/RichText/converter/defaultConverters.d.ts +2 -1
  15. package/dist/exports/react/components/RichText/converter/defaultConverters.d.ts.map +1 -1
  16. package/dist/exports/react/components/RichText/converter/defaultConverters.js.map +1 -1
  17. package/dist/exports/react/components/RichText/converter/index.js +1 -1
  18. package/dist/exports/react/components/RichText/converter/index.js.map +1 -1
  19. package/dist/exports/react/components/RichText/converter/types.d.ts +10 -6
  20. package/dist/exports/react/components/RichText/converter/types.d.ts.map +1 -1
  21. package/dist/exports/react/components/RichText/converter/types.js.map +1 -1
  22. package/dist/exports/react/components/RichText/index.css +4 -0
  23. package/dist/exports/react/components/RichText/index.d.ts +2 -1
  24. package/dist/exports/react/components/RichText/index.d.ts.map +1 -1
  25. package/dist/exports/react/components/RichText/index.js +2 -1
  26. package/dist/exports/react/components/RichText/index.js.map +1 -1
  27. package/dist/features/blocks/client/component/index.js +1 -0
  28. package/dist/features/blocks/client/component/index.js.map +1 -1
  29. package/dist/features/blocks/client/componentInline/index.js +1 -0
  30. package/dist/features/blocks/client/componentInline/index.js.map +1 -1
  31. package/dist/features/indent/client/index.d.ts.map +1 -1
  32. package/dist/features/indent/client/index.js +5 -0
  33. package/dist/features/indent/client/index.js.map +1 -1
  34. package/dist/features/indent/client/plugins/index.d.ts +3 -0
  35. package/dist/features/indent/client/plugins/index.d.ts.map +1 -0
  36. package/dist/features/indent/client/plugins/index.js +73 -0
  37. package/dist/features/indent/client/plugins/index.js.map +1 -0
  38. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  39. package/dist/lexical/LexicalEditor.js +2 -2
  40. package/dist/lexical/LexicalEditor.js.map +1 -1
  41. package/package.json +7 -7
  42. package/dist/exports/client/Field-4JYUMYYH.js +0 -2
  43. package/dist/exports/client/Field-4JYUMYYH.js.map +0 -7
  44. package/dist/exports/client/componentInline-PJ7YLXB5.js +0 -2
  45. /package/dist/exports/client/{componentInline-PJ7YLXB5.js.map → componentInline-GXYBWVCR.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","getFormState","editDepth","setInitialState","useState","id","formState","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","collectionSlug","getDocPreferences","globalSlug","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","onChange","prevFormState","submit","controller","onFormSubmit","newData","setFields","RemoveButton","_jsx","buttonStyle","className","disabled","icon","e","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","Provider","value","height","width","isEditable"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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 fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\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={permissions}\n readOnly={false}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\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"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,MAAMC,SAAA,GAAY;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAg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,WAAA,gBACC6D,IAAA,CAACzF,2BAAA,CAA4BsH,QAAQ;MACnCC,KAAA,EAAO;QACLpB,UAAA;QACAlG,YAAA;QACAoG,oBAAA;QACAM,KAAA;QACApG,OAAA;QACAiF;MACF;gBAEC5D;sBAGHgF,KAAA,CAACP,oBAAA;iBACEpG,YAAA,gBAAewF,IAAA,CAACkB,KAAA,qBAAWlB,IAAA,CAAC5G,aAAA;QAAc2I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DjH,MAAA,CAAOkH,UAAU,kBAChBd,KAAA,CAAC;QAAIjB,SAAA,EAAW,GAAG1H,SAAA,WAAoB;gCACrCwH,IAAA,CAACU,UAAA,O,aACDV,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["React","createContext","useCallback","useEffect","useMemo","useRef","baseClass","useLexicalComposerContext","useLexicalNodeSelection","mergeRegister","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","$getSelection","$isNodeSelection","CLICK_COMMAND","COMMAND_PRIORITY_LOW","KEY_BACKSPACE_COMMAND","KEY_DELETE_COMMAND","reduceFieldsToValues","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","useContext","InlineBlockComponent","props","formData","nodeKey","editor","i18n","t","fieldProps","featureClientSchemaMap","initialLexicalFormState","permissions","readOnly","schemaPath","uuidFromContext","getFormState","editDepth","setInitialState","useState","id","formState","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","isSelected","setSelected","clearSelection","collectionSlug","getDocPreferences","globalSlug","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blocks","removeInlineBlock","update","remove","$onDelete","event","deleteSelection","preventDefault","getNodes","forEach","node","onClick","payload","target","current","contains","shiftKey","registerCommand","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","fields","docPreferences","operation","renderAllFields","signal","onChange","prevFormState","submit","controller","onFormSubmit","newData","setFields","RemoveButton","_jsx","buttonStyle","className","disabled","icon","e","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","programmaticSubmit","Provider","value","height","width","isEditable"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\nconst baseClass = 'inline-block'\n\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalNodeSelection } from '@lexical/react/useLexicalNodeSelection'\nimport { mergeRegister } from '@lexical/utils'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Drawer,\n EditDepthProvider,\n Form,\n formatDrawerSlug,\n FormSubmit,\n RenderFields,\n ShimmerEffect,\n useDocumentInfo,\n useEditDepth,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport {\n $getNodeByKey,\n $getSelection,\n $isNodeSelection,\n CLICK_COMMAND,\n COMMAND_PRIORITY_LOW,\n KEY_BACKSPACE_COMMAND,\n KEY_DELETE_COMMAND,\n} from 'lexical'\nimport { reduceFieldsToValues } from 'payload/shared'\n\nimport './index.scss'\n\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 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.useContext(InlineBlockComponentContext)\n\nexport const InlineBlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const [editor] = useLexicalComposerContext()\n const { i18n, t } = useTranslation<object, string>()\n const {\n fieldProps: {\n featureClientSchemaMap,\n initialLexicalFormState,\n permissions,\n readOnly,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n const { getFormState } = useServerFunctions()\n const editDepth = useEditDepth()\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(\n initialLexicalFormState?.[formData.id]?.formState,\n )\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,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug, true)\n\n const inlineBlockElemElemRef = useRef<HTMLDivElement | null>(null)\n const [isSelected, setSelected, clearSelection] = useLexicalNodeSelection(nodeKey)\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\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 = blocksField.blocks[0]\n\n const removeInlineBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n const $onDelete = useCallback(\n (event: KeyboardEvent) => {\n const deleteSelection = $getSelection()\n if (isSelected && $isNodeSelection(deleteSelection)) {\n event.preventDefault()\n editor.update(() => {\n deleteSelection.getNodes().forEach((node) => {\n if ($isInlineBlockNode(node)) {\n node.remove()\n }\n })\n })\n }\n return false\n },\n [editor, isSelected],\n )\n const onClick = useCallback(\n (payload: MouseEvent) => {\n const event = payload\n // Check if inlineBlockElemElemRef.target or anything WITHIN inlineBlockElemElemRef.target was clicked\n if (\n event.target === inlineBlockElemElemRef.current ||\n inlineBlockElemElemRef.current?.contains(event.target as Node)\n ) {\n if (event.shiftKey) {\n setSelected(!isSelected)\n } else {\n if (!isSelected) {\n clearSelection()\n setSelected(true)\n }\n }\n return true\n }\n\n return false\n },\n [isSelected, setSelected, clearSelection],\n )\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(CLICK_COMMAND, onClick, COMMAND_PRIORITY_LOW),\n\n editor.registerCommand(KEY_DELETE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n editor.registerCommand(KEY_BACKSPACE_COMMAND, $onDelete, COMMAND_PRIORITY_LOW),\n )\n }, [clearSelection, editor, isSelected, nodeKey, $onDelete, setSelected, onClick])\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 globalSlug,\n operation: 'update',\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\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 schemaFieldsPath,\n id,\n formData,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\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 formState: prevFormState,\n globalSlug,\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 [getFormState, id, collectionSlug, getDocPreferences, globalSlug, schemaFieldsPath],\n )\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n /**\n * HANDLE FORM SUBMIT\n */\n const onFormSubmit = useCallback(\n (formState: FormState) => {\n const newData: any = reduceFieldsToValues(formState)\n newData.blockType = formData.blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isInlineBlockNode(node)) {\n node.setFields(newData)\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 }: { children: React.ReactNode }) => (\n <div\n className={[\n baseClass,\n baseClass + '-' + formData.blockType,\n isSelected && `${baseClass}--selected`,\n ]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [formData.blockType, isSelected],\n )\n\n const Label = useMemo(() => {\n if (CustomLabel) {\n return () => CustomLabel\n } else {\n return () => <div>{getTranslation(clientBlock.labels!.singular, i18n)}</div>\n }\n }, [CustomLabel, clientBlock.labels, i18n])\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 fields={clientBlock.fields}\n initialState={initialState || {}}\n onChange={[onChange]}\n onSubmit={(formState) => {\n onFormSubmit(formState)\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={permissions}\n readOnly={false}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n {CustomBlock ? (\n <InlineBlockComponentContext.Provider\n value={{\n EditButton,\n initialState,\n InlineBlockContainer,\n Label,\n nodeKey,\n RemoveButton,\n }}\n >\n {CustomBlock}\n </InlineBlockComponentContext.Provider>\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"],"mappings":"AAAA;;;AAEA,OAAOA,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,MAAMC,SAAA,GAAY;AAIlB,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,uBAAuB,QAAQ;AACxC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SACEC,aAAa,EACbC,aAAa,EACbC,gBAAgB,EAChBC,aAAa,EACbC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,Q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gBAAewF,IAAA,CAACkB,KAAA,qBAAWlB,IAAA,CAAC5G,aAAA;QAAc4I,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DlH,MAAA,CAAOmH,UAAU,kBAChBf,KAAA,CAAC;QAAIjB,SAAA,EAAW,GAAG1H,SAAA,WAAoB;gCACrCwH,IAAA,CAACU,UAAA,O,aACDV,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/indent/client/index.tsx"],"names":[],"mappings":"AAwDA,eAAO,MAAM,mBAAmB,oFAO9B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/features/indent/client/index.tsx"],"names":[],"mappings":"AAyDA,eAAO,MAAM,mBAAmB,oFAa9B,CAAA"}
@@ -4,6 +4,7 @@ import { INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical';
4
4
  import { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js';
5
5
  import { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js';
6
6
  import { createClientFeature } from '../../../utilities/createClientFeature.js';
7
+ import { IndentPlugin } from './plugins/index.js';
7
8
  import { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js';
8
9
  const toolbarGroups = [toolbarIndentGroupWithItems([{
9
10
  ChildComponent: IndentDecreaseIcon,
@@ -52,6 +53,10 @@ const toolbarGroups = [toolbarIndentGroupWithItems([{
52
53
  order: 2
53
54
  }])];
54
55
  export const IndentFeatureClient = createClientFeature({
56
+ plugins: [{
57
+ Component: IndentPlugin,
58
+ position: 'normal'
59
+ }],
55
60
  toolbarFixed: {
56
61
  groups: toolbarGroups
57
62
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","toolbarIndentGroupWithItems","toolbarGroups","ChildComponent","isActive","isEnabled","selection","getNodes","length","node","parent","getParentOrThrow","__indent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","IndentFeatureClient","toolbarFixed","groups","toolbarInline"],"sources":["../../../../src/features/indent/client/index.tsx"],"sourcesContent":["'use client'\n\nimport { INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js'\nimport { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarIndentGroupWithItems([\n {\n ChildComponent: IndentDecreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n if (!selection || !selection?.getNodes()?.length) {\n return false\n }\n for (const node of selection.getNodes()) {\n const parent = node.getParentOrThrow()\n // If at least one node is indented, this should be active\n if (\n ('__indent' in node && (node.__indent as number) > 0) ||\n ('__indent' in parent && parent.__indent > 0)\n ) {\n return true\n }\n }\n return false\n },\n key: 'indentDecrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:decreaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined)\n },\n order: 1,\n },\n {\n ChildComponent: IndentIncreaseIcon,\n isActive: () => false,\n key: 'indentIncrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:increaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined)\n },\n order: 2,\n },\n ]),\n]\n\nexport const IndentFeatureClient = createClientFeature({\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n})\n"],"mappings":"AAAA;;AAEA,SA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AAMC,mBAAA,GAAsBtB,mBAAA,CAAoB;EACrDuB,YAAA,EAAc;IACZC,MAAA,EAAQtB;EACV;EACAuB,aAAA,EAAe;IACbD,MAAA,EAAQtB;EACV;AACF","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["INDENT_CONTENT_COMMAND","OUTDENT_CONTENT_COMMAND","IndentDecreaseIcon","IndentIncreaseIcon","createClientFeature","IndentPlugin","toolbarIndentGroupWithItems","toolbarGroups","ChildComponent","isActive","isEnabled","selection","getNodes","length","node","parent","getParentOrThrow","__indent","key","label","i18n","t","onSelect","editor","dispatchCommand","undefined","order","IndentFeatureClient","plugins","Component","position","toolbarFixed","groups","toolbarInline"],"sources":["../../../../src/features/indent/client/index.tsx"],"sourcesContent":["'use client'\n\nimport { INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND } from 'lexical'\n\nimport type { ToolbarGroup } from '../../toolbars/types.js'\n\nimport { IndentDecreaseIcon } from '../../../lexical/ui/icons/IndentDecrease/index.js'\nimport { IndentIncreaseIcon } from '../../../lexical/ui/icons/IndentIncrease/index.js'\nimport { createClientFeature } from '../../../utilities/createClientFeature.js'\nimport { IndentPlugin } from './plugins/index.js'\nimport { toolbarIndentGroupWithItems } from './toolbarIndentGroup.js'\n\nconst toolbarGroups: ToolbarGroup[] = [\n toolbarIndentGroupWithItems([\n {\n ChildComponent: IndentDecreaseIcon,\n isActive: () => false,\n isEnabled: ({ selection }) => {\n if (!selection || !selection?.getNodes()?.length) {\n return false\n }\n for (const node of selection.getNodes()) {\n const parent = node.getParentOrThrow()\n // If at least one node is indented, this should be active\n if (\n ('__indent' in node && (node.__indent as number) > 0) ||\n ('__indent' in parent && parent.__indent > 0)\n ) {\n return true\n }\n }\n return false\n },\n key: 'indentDecrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:decreaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined)\n },\n order: 1,\n },\n {\n ChildComponent: IndentIncreaseIcon,\n isActive: () => false,\n key: 'indentIncrease',\n label: ({ i18n }) => {\n return i18n.t('lexical:indent:increaseLabel')\n },\n onSelect: ({ editor }) => {\n editor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined)\n },\n order: 2,\n },\n ]),\n]\n\nexport const IndentFeatureClient = createClientFeature({\n plugins: [\n {\n Component: IndentPlugin,\n position: 'normal',\n },\n ],\n toolbarFixed: {\n groups: toolbarGroups,\n },\n toolbarInline: {\n groups: toolbarGroups,\n },\n})\n"],"mappings":"AAAA;;AAEA,SAASA,sBAAsB,EAAEC,uBAAuB,QAAQ;AAIhE,SAASC,kBAAkB,QAAQ;AACnC,SAASC,kBAAkB,QAAQ;AACnC,SAASC,mBAAmB,QAAQ;AACpC,SAASC,YAAY,QAAQ;AAC7B,SAASC,2BAA2B,QAAQ;AAE5C,MAAMC,aAAA,GAAgC,CACpCD,2BAAA,CAA4B,CAC1B;EACEE,cAAA,EAAgBN,kBAAA;EAChBO,QAAA,EAAUA,CAAA,KAAM;EAChBC,SAAA,EAAWA,CAAC;IAAEC;EAAS,CAAE;IACvB,IAAI,CAACA,SAAA,IAAa,CAACA,SAAA,EAAWC,QAAA,IAAYC,MAAA,EAAQ;MAChD,OAAO;IACT;IACA,KAAK,MAAMC,IAAA,IAAQH,SAAA,CAAUC,QAAQ,IAAI;MACvC,MAAMG,MAAA,GAASD,IAAA,CAAKE,gBAAgB;MACpC;MACA,IACE,UAAC,IAAcF,IAAA,IAAQA,IAAC,CAAKG,QAAQ,GAAc,KAClD,cAAcF,MAAA,IAAUA,MAAA,CAAOE,QAAQ,GAAG,GAC3C;QACA,OAAO;MACT;IACF;IACA,OAAO;EACT;EACAC,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAACvB,uBAAA,EAAyBwB,SAAA;EAClD;EACAC,KAAA,EAAO;AACT,GACA;EACElB,cAAA,EAAgBL,kBAAA;EAChBM,QAAA,EAAUA,CAAA,KAAM;EAChBS,GAAA,EAAK;EACLC,KAAA,EAAOA,CAAC;IAAEC;EAAI,CAAE;IACd,OAAOA,IAAA,CAAKC,CAAC,CAAC;EAChB;EACAC,QAAA,EAAUA,CAAC;IAAEC;EAAM,CAAE;IACnBA,MAAA,CAAOC,eAAe,CAACxB,sBAAA,EAAwByB,SAAA;EACjD;EACAC,KAAA,EAAO;AACT,EACD,EACF;AAED,OAAO,MAAMC,mBAAA,GAAsBvB,mBAAA,CAAoB;EACrDwB,OAAA,EAAS,CACP;IACEC,SAAA,EAAWxB,YAAA;IACXyB,QAAA,EAAU;EACZ,EACD;EACDC,YAAA,EAAc;IACZC,MAAA,EAAQzB;EACV;EACA0B,aAAA,EAAe;IACbD,MAAA,EAAQzB;EACV;AACF","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { PluginComponent } from '../../../typesClient.js';
2
+ export declare const IndentPlugin: PluginComponent<undefined>;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/indent/client/plugins/index.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAE9D,eAAO,MAAM,YAAY,EAAE,eAAe,CAAC,SAAS,CAkDnD,CAAA"}
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { jsx as _jsx } from "react/jsx-runtime";
5
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js';
6
+ import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin';
7
+ import { mergeRegister } from '@lexical/utils';
8
+ import { COMMAND_PRIORITY_NORMAL, FOCUS_COMMAND, KEY_ESCAPE_COMMAND } from 'lexical';
9
+ import { useEffect, useState } from 'react';
10
+ export const IndentPlugin = () => {
11
+ const $ = _c(8);
12
+ const [editor] = useLexicalComposerContext();
13
+ const [firefoxFlag, setFirefoxFlag] = useState(false);
14
+ let t0;
15
+ let t1;
16
+ if ($[0] !== editor) {
17
+ t0 = () => mergeRegister(editor.registerCommand(FOCUS_COMMAND, () => {
18
+ setFirefoxFlag(false);
19
+ return true;
20
+ }, COMMAND_PRIORITY_NORMAL), editor.registerCommand(KEY_ESCAPE_COMMAND, () => {
21
+ setFirefoxFlag(true);
22
+ editor.getRootElement()?.blur();
23
+ return true;
24
+ }, COMMAND_PRIORITY_NORMAL));
25
+ t1 = [editor, setFirefoxFlag];
26
+ $[0] = editor;
27
+ $[1] = t0;
28
+ $[2] = t1;
29
+ } else {
30
+ t0 = $[1];
31
+ t1 = $[2];
32
+ }
33
+ useEffect(t0, t1);
34
+ let t2;
35
+ let t3;
36
+ if ($[3] !== firefoxFlag || $[4] !== editor) {
37
+ t2 = () => {
38
+ if (!firefoxFlag) {
39
+ return;
40
+ }
41
+ const handleKeyDown = e => {
42
+ if (!["Escape", "Shift"].includes(e.key)) {
43
+ setFirefoxFlag(false);
44
+ }
45
+ if (e.shiftKey && e.key === "Tab") {
46
+ editor.getRootElement()?.parentElement?.focus();
47
+ }
48
+ };
49
+ document.addEventListener("keydown", handleKeyDown);
50
+ return () => {
51
+ document.removeEventListener("keydown", handleKeyDown);
52
+ };
53
+ };
54
+ t3 = [editor, firefoxFlag];
55
+ $[3] = firefoxFlag;
56
+ $[4] = editor;
57
+ $[5] = t2;
58
+ $[6] = t3;
59
+ } else {
60
+ t2 = $[5];
61
+ t3 = $[6];
62
+ }
63
+ useEffect(t2, t3);
64
+ let t4;
65
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
66
+ t4 = _jsx(TabIndentationPlugin, {});
67
+ $[7] = t4;
68
+ } else {
69
+ t4 = $[7];
70
+ }
71
+ return t4;
72
+ };
73
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","TabIndentationPlugin","mergeRegister","COMMAND_PRIORITY_NORMAL","FOCUS_COMMAND","KEY_ESCAPE_COMMAND","useEffect","useState","IndentPlugin","$","editor","firefoxFlag","setFirefoxFlag","t0","t1","registerCommand","getRootElement","blur","t2","t3","handleKeyDown","e","includes","key","shiftKey","parentElement","focus","document","addEventListener","removeEventListener","t4","Symbol","for","_jsx"],"sources":["../../../../../src/features/indent/client/plugins/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin'\nimport { mergeRegister } from '@lexical/utils'\nimport { COMMAND_PRIORITY_NORMAL, FOCUS_COMMAND, KEY_ESCAPE_COMMAND } from 'lexical'\nimport { useEffect, useState } from 'react'\n\nimport type { PluginComponent } from '../../../typesClient.js'\n\nexport const IndentPlugin: PluginComponent<undefined> = () => {\n const [editor] = useLexicalComposerContext()\n\n const [firefoxFlag, setFirefoxFlag] = useState<boolean>(false)\n\n useEffect(() => {\n return mergeRegister(\n editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n setFirefoxFlag(false)\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n editor.registerCommand(\n KEY_ESCAPE_COMMAND,\n () => {\n setFirefoxFlag(true)\n editor.getRootElement()?.blur()\n return true\n },\n COMMAND_PRIORITY_NORMAL,\n ),\n )\n }, [editor, setFirefoxFlag])\n\n useEffect(() => {\n if (!firefoxFlag) {\n return\n }\n\n const handleKeyDown = (e: KeyboardEvent) => {\n if (!['Escape', 'Shift'].includes(e.key)) {\n setFirefoxFlag(false)\n }\n // Pressing Shift+Tab after blurring refocuses the editor in Firefox\n // we focus parent to allow exiting the editor\n if (e.shiftKey && e.key === 'Tab') {\n editor.getRootElement()?.parentElement?.focus()\n }\n }\n\n document.addEventListener('keydown', handleK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,GAAG,UAAU,CAAC,CA6K5D,CAAA"}
1
+ {"version":3,"file":"LexicalEditor.d.ts","sourceRoot":"","sources":["../../src/lexical/LexicalEditor.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAIhE,OAAO,sBAAsB,CAAA;AAQ7B,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAClC;IACE,kBAAkB,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAA;CAC3D,GAAG,IAAI,CAAC,oBAAoB,EAAE,cAAc,GAAG,UAAU,CAAC,CA2K5D,CAAA"}
@@ -7,7 +7,6 @@ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js';
7
7
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js';
8
8
  import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js';
9
9
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js';
10
- import { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js';
11
10
  import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
12
11
  import * as React from 'react';
13
12
  import { useEffect, useState } from 'react';
@@ -165,6 +164,7 @@ export const LexicalEditor = props => {
165
164
  children: _jsx("div", {
166
165
  className: "editor",
167
166
  ref: onRef,
167
+ tabIndex: -1,
168
168
  children: _jsx(LexicalContentEditable, {})
169
169
  })
170
170
  }),
@@ -176,7 +176,7 @@ export const LexicalEditor = props => {
176
176
  onChange: t6
177
177
  }), t7, editor.isEditable() && _jsxs(React.Fragment, {
178
178
  children: [_jsx(HistoryPlugin, {}), editorConfig?.features?.markdownTransformers?.length > 0 && _jsx(MarkdownShortcutPlugin, {})]
179
- }), _jsx(TabIndentationPlugin, {}), editorConfig.features.plugins?.map(_temp3), editorConfig.features.plugins?.map(_temp4)]
179
+ }), editorConfig.features.plugins?.map(_temp3), editorConfig.features.plugins?.map(_temp4)]
180
180
  }), editorConfig.features.plugins?.map(_temp5)]
181
181
  });
182
182
  $[8] = editorConfig.features;
@@ -1 +1 @@
1
- {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","TabIndentationPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","isSmallWidthViewport","setIsSmallWidthViewport","t3","t4","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","t5","features","t6","editorState","editor_0","tags","has","size","t7","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","plugins","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { TabIndentationPlugin } from '@lexical/react/LexicalTabIndentationPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n\n <TabIndentationPlugin />\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AAC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AA,CAAAC,QAAA,KAAoB;IAAA,OACfN,IAAA,CAAA7D,YAAA;MAAAqE,WAAA,EAA2BH,QAAA,CAAAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"LexicalEditor.js","names":["c","_c","useLexicalComposerContext","LexicalErrorBoundary","HistoryPlugin","OnChangePlugin","RichTextPlugin","BLUR_COMMAND","COMMAND_PRIORITY_LOW","FOCUS_COMMAND","React","useEffect","useState","useEditorConfigContext","EditorPlugin","AddBlockHandlePlugin","DraggableBlockPlugin","MarkdownShortcutPlugin","SlashMenuPlugin","TextPlugin","LexicalContentEditable","LexicalEditor","props","$","editorConfig","editorContainerRef","onChange","editorConfigContext","editor","floatingAnchorElem","setFloatingAnchorElem","t0","Symbol","for","_floatingAnchorElem","onRef","t1","t2","uuid","console","error","parentEditor","registerChild","handleFocus","focusEditor","handleBlur","blurEditor","unregisterFocus","registerCommand","unregisterBlur","unregisterChild","isSmallWidthViewport","setIsSmallWidthViewport","t3","t4","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","t5","features","t6","editorState","editor_0","tags","has","size","t7","_jsxs","Fragment","children","isEditable","_jsx","anchorElem","plugins","map","plugin_1","plugin","position","desktopOnly","clientProps","key","_temp","className","ref","_temp2","contentEditable","tabIndex","ignoreSelectionChange","markdownTransformers","length","_temp3","_temp4","_temp5","plugin_0","plugin_2","plugin_3","plugin_4"],"sources":["../../src/lexical/LexicalEditor.tsx"],"sourcesContent":["'use client'\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary.js'\nimport { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin.js'\nimport { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin.js'\nimport { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin.js'\nimport { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical'\nimport * as React from 'react'\nimport { useEffect, useState } from 'react'\n\nimport type { LexicalProviderProps } from './LexicalProvider.js'\n\nimport { useEditorConfigContext } from './config/client/EditorConfigProvider.js'\nimport { EditorPlugin } from './EditorPlugin.js'\nimport './LexicalEditor.scss'\nimport { AddBlockHandlePlugin } from './plugins/handles/AddBlockHandlePlugin/index.js'\nimport { DraggableBlockPlugin } from './plugins/handles/DraggableBlockPlugin/index.js'\nimport { MarkdownShortcutPlugin } from './plugins/MarkdownShortcut/index.js'\nimport { SlashMenuPlugin } from './plugins/SlashMenu/index.js'\nimport { TextPlugin } from './plugins/TextPlugin/index.js'\nimport { LexicalContentEditable } from './ui/ContentEditable.js'\n\nexport const LexicalEditor: React.FC<\n {\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n } & Pick<LexicalProviderProps, 'editorConfig' | 'onChange'>\n> = (props) => {\n const { editorConfig, editorContainerRef, onChange } = props\n const editorConfigContext = useEditorConfigContext()\n const [editor] = useLexicalComposerContext()\n\n const [floatingAnchorElem, setFloatingAnchorElem] = useState<HTMLDivElement | null>(null)\n const onRef = (_floatingAnchorElem: HTMLDivElement) => {\n if (_floatingAnchorElem !== null) {\n setFloatingAnchorElem(_floatingAnchorElem)\n }\n }\n\n useEffect(() => {\n if (!editorConfigContext?.uuid) {\n console.error('Lexical Editor must be used within an EditorConfigProvider')\n return\n }\n if (editorConfigContext?.parentEditor?.uuid) {\n editorConfigContext.parentEditor?.registerChild(editorConfigContext.uuid, editorConfigContext)\n }\n\n const handleFocus = () => {\n editorConfigContext.focusEditor(editorConfigContext)\n }\n\n const handleBlur = () => {\n editorConfigContext.blurEditor(editorConfigContext)\n }\n\n const unregisterFocus = editor.registerCommand<MouseEvent>(\n FOCUS_COMMAND,\n () => {\n handleFocus()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n const unregisterBlur = editor.registerCommand<MouseEvent>(\n BLUR_COMMAND,\n () => {\n handleBlur()\n return true\n },\n COMMAND_PRIORITY_LOW,\n )\n\n return () => {\n unregisterFocus()\n unregisterBlur()\n editorConfigContext.parentEditor?.unregisterChild?.(editorConfigContext.uuid)\n }\n }, [editor, editorConfigContext])\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n return (\n <React.Fragment>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'aboveContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n <div className=\"editor-container\" ref={editorContainerRef}>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'top') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n <RichTextPlugin\n contentEditable={\n <div className=\"editor-scroller\">\n <div className=\"editor\" ref={onRef} tabIndex={-1}>\n <LexicalContentEditable />\n </div>\n </div>\n }\n ErrorBoundary={LexicalErrorBoundary}\n />\n <TextPlugin features={editorConfig.features} />\n <OnChangePlugin\n // Selection changes can be ignored here, reducing the\n // frequency that the FieldComponent and Payload receive updates.\n // Selection changes are only needed if you are saving selection state\n ignoreSelectionChange\n onChange={(editorState, editor, tags) => {\n // Ignore any onChange event triggered by focus only\n if (!tags.has('focus') || tags.size > 1) {\n if (onChange != null) {\n onChange(editorState, editor, tags)\n }\n }\n }}\n />\n {floatingAnchorElem && (\n <React.Fragment>\n {!isSmallWidthViewport && editor.isEditable() && (\n <React.Fragment>\n <DraggableBlockPlugin anchorElem={floatingAnchorElem} />\n <AddBlockHandlePlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (\n plugin.position === 'floatingAnchorElem' &&\n !(plugin.desktopOnly === true && isSmallWidthViewport)\n ) {\n return (\n <EditorPlugin\n anchorElem={floatingAnchorElem}\n clientProps={plugin.clientProps}\n key={plugin.key}\n plugin={plugin}\n />\n )\n }\n })}\n {editor.isEditable() && (\n <React.Fragment>\n <SlashMenuPlugin anchorElem={floatingAnchorElem} />\n </React.Fragment>\n )}\n </React.Fragment>\n )}\n {editor.isEditable() && (\n <React.Fragment>\n <HistoryPlugin />\n {editorConfig?.features?.markdownTransformers?.length > 0 && <MarkdownShortcutPlugin />}\n </React.Fragment>\n )}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'normal') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'bottom') {\n return (\n <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n )\n }\n })}\n </div>\n {editorConfig.features.plugins?.map((plugin) => {\n if (plugin.position === 'belowContainer') {\n return <EditorPlugin clientProps={plugin.clientProps} key={plugin.key} plugin={plugin} />\n }\n })}\n </React.Fragment>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AACA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,oBAAoB,QAAQ;AACrC,SAASC,aAAa,QAAQ;AAC9B,SAASC,cAAc,QAAQ;AAC/B,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,EAAEC,oBAAoB,EAAEC,aAAa,QAAQ;AAClE,YAAYC,KAAA,MAAW;AACvB,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAIpC,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAE7B,SAASC,oBAAoB,QAAQ;AACrC,SAASC,oBA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AAG,WAAA;MAAAH,MAAA,EAA6CA;IAAA,GAApBA,QAAA,CAAAI,GAAU;EAAA;AAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.2.2-canary.6fb5cd8",
3
+ "version": "3.2.2-canary.a11698b",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -342,11 +342,11 @@
342
342
  "mdast-util-from-markdown": "2.0.2",
343
343
  "mdast-util-mdx-jsx": "3.1.3",
344
344
  "micromark-extension-mdx-jsx": "3.0.1",
345
- "react-error-boundary": "4.1.1",
345
+ "react-error-boundary": "4.1.2",
346
346
  "ts-essentials": "10.0.3",
347
347
  "uuid": "10.0.0",
348
- "@payloadcms/translations": "3.2.2-canary.6fb5cd8",
349
- "@payloadcms/ui": "3.2.2-canary.6fb5cd8"
348
+ "@payloadcms/ui": "3.2.2-canary.a11698b",
349
+ "@payloadcms/translations": "3.2.2-canary.a11698b"
350
350
  },
351
351
  "devDependencies": {
352
352
  "@babel/cli": "^7.24.5",
@@ -367,7 +367,7 @@
367
367
  "eslint-plugin-react-compiler": "19.0.0-beta-a7bf2bd-20241110",
368
368
  "swc-plugin-transform-remove-imports": "1.15.0",
369
369
  "@payloadcms/eslint-config": "3.0.0",
370
- "payload": "3.2.2-canary.6fb5cd8"
370
+ "payload": "3.2.2-canary.a11698b"
371
371
  },
372
372
  "peerDependencies": {
373
373
  "@faceless-ui/modal": "3.0.0-beta.2",
@@ -384,8 +384,8 @@
384
384
  "lexical": "0.20.0",
385
385
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
386
386
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
387
- "@payloadcms/next": "3.2.2-canary.6fb5cd8",
388
- "payload": "3.2.2-canary.6fb5cd8"
387
+ "@payloadcms/next": "3.2.2-canary.a11698b",
388
+ "payload": "3.2.2-canary.a11698b"
389
389
  },
390
390
  "engines": {
391
391
  "node": "^18.20.2 || >=20.9.0"
@@ -1,2 +0,0 @@
1
- "use client";import{c as ue,g as H,h as B,j as fe,k as pe,l as ge,m as he,n as ye}from"./chunk-2L2Z4JHF.js";import{a as de,b as R}from"./chunk-CUIBIFW2.js";import{jsx as ie,jsxs as re}from"react/jsx-runtime";import{FieldLabel as eo,useEditDepth as to,useField as oo,withCondition as no}from"@payloadcms/ui";import{mergeFieldStyles as ro}from"@payloadcms/ui/shared";import{useCallback as Xe,useMemo as io}from"react";import{ErrorBoundary as so}from"react-error-boundary";import{jsx as A}from"react/jsx-runtime";import{LexicalComposer as Xt}from"@lexical/react/LexicalComposer.js";import*as qe from"react";import{useMemo as Zt}from"react";import{c as _t}from"react/compiler-runtime";import{jsx as P,jsxs as q}from"react/jsx-runtime";import{useLexicalComposerContext as $t}from"@lexical/react/LexicalComposerContext.js";import{LexicalErrorBoundary as Ht}from"@lexical/react/LexicalErrorBoundary.js";import{HistoryPlugin as jt}from"@lexical/react/LexicalHistoryPlugin.js";import{OnChangePlugin as zt}from"@lexical/react/LexicalOnChangePlugin.js";import{RichTextPlugin as Kt}from"@lexical/react/LexicalRichTextPlugin.js";import{TabIndentationPlugin as Gt}from"@lexical/react/LexicalTabIndentationPlugin.js";import{BLUR_COMMAND as Wt,COMMAND_PRIORITY_LOW as We,FOCUS_COMMAND as Yt}from"lexical";import*as W from"react";import{useEffect as Ye,useState as Ue}from"react";import{jsx as xe}from"react/jsx-runtime";import"react";var D=({anchorElem:t,clientProps:e,plugin:o})=>o.position==="floatingAnchorElem"&&t?o.Component&&xe(o.Component,{anchorElem:t,clientProps:e}):o.Component&&xe(o.Component,{clientProps:e});import{jsx as le}from"react/jsx-runtime";import{useLexicalComposerContext as it}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as st}from"lexical";import*as Ne from"react";import{useCallback as lt,useEffect as Ce,useRef as at,useState as ct}from"react";import{createPortal as mt}from"react-dom";var j=(t,e,o,n,r=50,m=25)=>{let l=0;if(t&&!t.contains(n)){let{bottom:a,left:u,right:g,top:y}=t.getBoundingClientRect(),s=y+window.scrollY,i=a+window.scrollY;if(o<s-m||o>i+m||e<u-r||e>g+r)return-1;(e<u||e>g)&&(l=e<u?e-u:e-g)}return l};import{$getNodeByKey as Q}from"lexical";function z(t){let e=t.getBoundingClientRect(),o=getComputedStyle(t).getPropertyValue("transform");if(!o||o==="none")return e;let n=o.split(",").pop();return e.y=e.y-Number(n?.replace(")","")),e}function J(t){let e=(u,g)=>u?parseFloat(window.getComputedStyle(u)[g]):0,{marginBottom:o,marginTop:n}=window.getComputedStyle(t),r=e(t.previousElementSibling,"marginBottom"),m=e(t.nextElementSibling,"marginTop"),l=Math.max(parseFloat(n),r);return{marginBottom:Math.max(parseFloat(o),m),marginTop:l}}import{$getRoot as et}from"lexical";function O(t){return t.getEditorState().read(()=>et().getChildrenKeys())}var tt=1,ot=-1,Ee=0,v={props:null,result:null};function nt(t,e,o=20){let n=t.x-e.x,r=t.y-e.y;return n*n+r*r<=o*o}function K(t){let{anchorElem:e,cache_threshold:o=20,editor:n,fuzzy:r=!1,horizontalOffset:m=0,point:{x:l,y:a},startIndex:u=0,useEdgeAsDefault:g=!1}=t;if(o>0&&v.props&&v.result&&v.props.fuzzy===t.fuzzy&&v.props.horizontalOffset===t.horizontalOffset&&v.props.useEdgeAsDefault===t.useEdgeAsDefault&&nt(v.props.point,t.point,o))return v.result;let y=e.getBoundingClientRect(),s=O(n),i={blockElem:null,blockNode:null,distance:1/0,foundAtIndex:-1,isFoundNodeEmptyParagraph:!1};return n.getEditorState().read(()=>{if(g){let[p,h]=[n.getElementByKey(s[0]),n.getElementByKey(s[s.length-1])];if(p&&h){let[f,c]=[z(p),z(h)];if(a<f.top?(i.blockElem=p,i.distance=f.top-a,i.blockNode=Q(s[0]),i.foundAtIndex=0):a>c.bottom&&(i.distance=a-c.bottom,i.blockNode=Q(s[s.length-1]),i.blockElem=h,i.foundAtIndex=s.length-1),i?.blockElem)return{blockElem:null,isFoundNodeEmptyParagraph:!1}}}let d=u,x=Ee;for(;d>=0&&d<s.length;){let p=s[d],h=n.getElementByKey(p);if(h===null)break;let f=new B(l+m,a),c=he.fromDOMRect(z(h)),{marginBottom:E,marginTop:b}=J(h),T=c.generateNewRect({bottom:c.bottom+E,left:y.left,right:y.right,top:c.top-b}),{distance:C,isOnBottomSide:k,isOnTopSide:N}=T.distanceFromPoint(f);if(C===0){i.blockElem=h,i.blockNode=Q(p),i.foundAtIndex=d,i.distance=C,i.blockNode&&i.blockNode.getType()==="paragraph"&&i.blockNode.getTextContent()===""&&(!r&&!t.returnEmptyParagraphs&&(i.blockElem=null,i.blockNode=null),i.isFoundNodeEmptyParagraph=!0);break}else r&&C<i.distance&&(i.blockElem=h,i.blockNode=Q(p),i.distance=C,i.foundAtIndex=d);x===Ee&&(N?x=ot:k?x=tt:x=1/0),d+=x}}),v.props=t,v.result={blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph},{blockElem:i.blockElem,blockNode:i.blockNode,foundAtIndex:i.foundAtIndex,isFoundNodeEmptyParagraph:i.isFoundNodeEmptyParagraph}}function X(t,e){return!!t.closest(`.${e}`)}var rt=["IMG","INPUT","TEXTAREA","SELECT","BUTTON","VIDEO","OBJECT","EMBED","IFRAME","HR"];function be(t){if(!t||rt.includes(t.tagName)||t.offsetHeight===0||t.offsetWidth===0)return!1;let e=window.getComputedStyle(t);return!(e.display==="table-cell"||e.position==="absolute"||e.visibility==="hidden"||e.opacity==="0")}function Z(t,e,o,n=0){if(!t){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}let r=t.getBoundingClientRect(),m=window.getComputedStyle(t),l=e.getBoundingClientRect(),a=o.getBoundingClientRect(),u;if(["lexical-block","lexical-upload","lexical-relationship"].some(s=>t.firstElementChild?.classList.contains(s)))u=r.top+8-a.top;else{let s=be(t)?parseInt(m.lineHeight,10):0;u=r.top+(s-l.height)/2-a.top}let y=n;e.style.opacity="1",e.style.transform=`translate(${y}px, ${u}px)`}var dt="add-block-menu",ee=1/0;function ut(t){return t===0?1/0:ee>=0&&ee<t?ee:Math.floor(t/2)}function ft(t,e,o){let n=e.parentElement,{editorConfig:r}=R(),m=r?.admin?.hideGutter?-24:12,l=at(null),[a,u]=ct(null);Ce(()=>{function y(s){let i=s.target;if(!H(i))return;let d=j(n,s.pageX,s.pageY,i);if(d===-1){u(null);return}if(X(i,dt))return;let x=O(t),{blockElem:p,blockNode:h,foundAtIndex:f}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-d,point:new B(s.x,s.y),returnEmptyParagraphs:!0,startIndex:ut(x.length),useEdgeAsDefault:!1});ee=f,p&&h&&(a?.node!==h||a?.elem!==p)&&u({elem:p,node:h})}return document?.addEventListener("mousemove",y),()=>{document?.removeEventListener("mousemove",y)}},[n,e,t,a]),Ce(()=>{l.current&&a?.node&&Z(a?.elem,l.current,e,m)},[e,a,m]);let g=lt(y=>{let s=a;s?.node&&(t.update(()=>{let i=!0;if((s?.node.getType()!=="paragraph"||s.node.getTextContent()!=="")&&(i=!1),!i){let d=st();s?.node.insertAfter(d),setTimeout(()=>{s={elem:t.getElementByKey(d.getKey()),node:d},u(s)},0)}}),setTimeout(()=>{t.update(()=>{t.focus(),s?.node&&"select"in s.node&&typeof s.node.select=="function"&&s.node.select()})},1),setTimeout(()=>{t.dispatchCommand(pe,{node:s?.node})},2),y.stopPropagation(),y.preventDefault())},[t,a]);return mt(le(Ne.Fragment,{children:le("button",{"aria-label":"Add block",className:"icon add-block-menu",onClick:y=>{g(y)},ref:l,type:"button",children:le("div",{className:o?"icon":""})})}),e)}function Pe(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=it();return ft(n,o,n._editable)}import{jsx as te,jsxs as gt}from"react/jsx-runtime";import{useLexicalComposerContext as ht}from"@lexical/react/LexicalComposerContext.js";import{eventFiles as Re}from"@lexical/rich-text";import{$getNearestNodeFromDOMNode as ke,$getNodeByKey as yt}from"lexical";import*as Be from"react";import{useEffect as ae,useRef as oe,useState as Se}from"react";import{createPortal as xt}from"react-dom";var Te=0,pt=-24;var _=0;function we(t,e,o,n,r,m,l,a,u,g=!1){let{height:y,top:s}=n.getBoundingClientRect(),{top:i,width:d}=l.getBoundingClientRect(),{marginBottom:x,marginTop:p}=J(n),h=s,f=m>=s+y/2+window.scrollY,c=!1;if(r?.elem)if(n!==r?.elem)(f&&r?.elem&&r?.elem===n.nextElementSibling||!f&&r?.elem&&r?.elem===n.previousElementSibling)&&(_++,_<200&&(c=!0));else{_++;let C=r?.boundingBox?.y,k=n.getBoundingClientRect().y;(f===r?.isBelow&&C===k||_<200)&&(c=!1)}if(c)return{isBelow:f,willStayInSamePosition:c};g?h+=y/2:f?h+=y+x/2:h-=p/2;let E=0;g||(f?E=-Te:E=Te);let b=h-i+E,T=pt-e;return o.style.width=`calc(${d}px - ${t})`,o.style.opacity=".8",o.style.transform=`translate(${T}px, calc(${b}px - 2px))`,r?.elem&&(r.elem.style.opacity="",r?.elem===n?f?r.elem.style.marginTop="":r.elem.style.marginBottom="":(r.elem.style.marginBottom="",r.elem.style.marginTop="")),_=0,{isBelow:f,willStayInSamePosition:c}}var Et="draggable-block-menu",ve="application/x-lexical-drag-block",V=1/0;function Me(t){return t===0?1/0:V>=0&&V<t?V:Math.floor(t/2)}function bt(t,e){let{transform:o}=e.style;t.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=o})}function Le(t,e){t&&(t.style.opacity="0"),e&&(e.style.opacity="",e.style.marginBottom="",e.style.marginTop="")}function Ct(t,e,o){let n=e.parentElement,r=oe(null),m=oe(null),l=oe(null),a=oe(!1),[u,g]=Se(null),[y,s]=Se(null),{editorConfig:i}=R(),d=i?.admin?.hideGutter?-44:-8;ae(()=>{function h(f){let c=f.target;if(!H(c))return;let E=j(n,f.pageX,f.pageY,c);if(E===-1){g(null);return}if(X(c,Et))return;let b=O(t),{blockElem:T,foundAtIndex:C,isFoundNodeEmptyParagraph:k}=K({anchorElem:e,cache_threshold:0,editor:t,horizontalOffset:-E,point:new B(f.x,f.y),startIndex:Me(b.length),useEdgeAsDefault:!1,verbose:!1});V=C,!(!T&&!k)&&u!==T&&g(T)}return document?.addEventListener("mousemove",h),()=>{document?.removeEventListener("mousemove",h)}},[n,e,t,u]),ae(()=>{r.current&&Z(u,r.current,e,d)},[e,u,d]),ae(()=>{function h(c){if(!a.current)return!1;let[E]=Re(c);if(E)return!1;let{pageY:b,target:T}=c;if(!H(T))return!1;let C=j(n,c.pageX,c.pageY,T,100,50),k=O(t),{blockElem:N,foundAtIndex:Y,isFoundNodeEmptyParagraph:I}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-C,point:new B(c.x,c.y),startIndex:Me(k.length),useEdgeAsDefault:!0,verbose:!0});V=Y;let L=m.current;if(N===null||L===null)return!1;if(u!==N){let{isBelow:S,willStayInSamePosition:$}=we(i?.admin?.hideGutter?"0px":"3rem",d+(i?.admin?.hideGutter?r?.current?.getBoundingClientRect()?.width??0:-(r?.current?.getBoundingClientRect()?.width??0)),L,N,y,b,e,c,l,I);c.preventDefault(),$||s({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:S})}else y?.elem&&(Le(L,y.elem),s({boundingBox:N.getBoundingClientRect(),elem:N,isBelow:!1}));return!0}function f(c){if(!a.current)return!1;let[E]=Re(c);if(E)return!1;let{dataTransfer:b,pageY:T,target:C}=c,k=b?.getData(ve)||"";return t.update(()=>{let N=yt(k);if(!N||!H(C))return!1;let Y=j(n,c.pageX,c.pageY,C,100,50),{blockElem:I,isFoundNodeEmptyParagraph:L}=K({anchorElem:e,editor:t,fuzzy:!0,horizontalOffset:-Y,point:new B(c.x,c.y),useEdgeAsDefault:!0});if(!I)return!1;let S=ke(I);if(!S)return!1;if(S===N)return!0;let{height:$,top:se}=z(I),U=T>=se+$/2+window.scrollY;L?(S.insertBefore(N),S.remove()):U?S.insertAfter(N):S.insertBefore(N),u!==null&&g(null),document.querySelectorAll(".lexical-block-highlighter").forEach(F=>{F.remove()});let Ze=t.getElementByKey(N.getKey());setTimeout(()=>{let F=Ze?.getBoundingClientRect();if(!F)return;let w=document.createElement("div");w.className="lexical-block-highlighter",w.style.backgroundColor="var(--theme-elevation-1000",w.style.transition="opacity 0.5s ease-in-out",w.style.zIndex="1",w.style.pointerEvents="none",w.style.boxSizing="border-box",w.style.borderRadius="4px",w.style.position="absolute",document.body.appendChild(w),w.style.opacity="0.1",w.style.height=`${F.height+8}px`,w.style.width=`${F.width+8}px`,w.style.top=`${F.top+window.scrollY-4}px`,w.style.left=`${F.left-4}px`,setTimeout(()=>{w.style.opacity="0",setTimeout(()=>{w.remove()},500)},1e3)},120)}),!0}return document.addEventListener("dragover",h),document.addEventListener("drop",f),()=>{document.removeEventListener("dragover",h),document.removeEventListener("drop",f)}},[n,d,e,t,y,u,i?.admin?.hideGutter]);function x(h){let f=h.dataTransfer;if(!f||!u)return;bt(f,u);let c="";t.update(()=>{let E=ke(u);E&&(c=E.getKey())}),a.current=!0,f.setData(ve,c)}function p(){a.current=!1,y?.elem&&Le(m.current,y?.elem)}return xt(gt(Be.Fragment,{children:[te("div",{className:"icon draggable-block-menu",draggable:!0,onDragEnd:p,onDragStart:x,ref:r,children:te("div",{className:o?"icon":""})}),te("div",{className:"draggable-block-target-line",ref:m}),te("div",{className:"debug-highlight",ref:l})]}),e)}function Ae(t){let{anchorElem:e}=t,o=e===void 0?document.body:e,[n]=ht();return Ct(n,o,n._editable)}import{c as Nt}from"react/compiler-runtime";import{useLexicalComposerContext as Pt}from"@lexical/react/LexicalComposerContext";import*as Ie from"react";var Fe=()=>{let t=Nt(4),{editorConfig:e}=R(),[o]=Pt(),n,r;return t[0]!==o||t[1]!==e.features.markdownTransformers?(n=()=>ue(o,e.features.markdownTransformers??[]),r=[o,e.features.markdownTransformers],t[0]=o,t[1]=e.features.markdownTransformers,t[2]=n,t[3]=r):(n=t[2],r=t[3]),Ie.useEffect(n,r),null};import{jsx as G,jsxs as Oe}from"react/jsx-runtime";import{useLexicalComposerContext as wt}from"@lexical/react/LexicalComposerContext.js";import{useTranslation as _e}from"@payloadcms/ui";import{useCallback as Rt,useMemo as kt,useState as St}from"react";import"react";import*as $e from"react-dom";import{c as Tt}from"react/compiler-runtime";import"react";function De(t,e){let o=Tt(4),{maxLength:n,minLength:r}=e,m=n===void 0?75:n,l=r===void 0?1:r,a;return o[0]!==t||o[1]!==m||o[2]!==l?(a=u=>{let{query:g}=u,y="[^"+t+fe+"\\s]",i=new RegExp("(^|\\s|\\()(["+t+"]((?:"+y+"){0,"+m+"}))$").exec(g);if(i!==null){let d=i[1],x=i[3];if(x.length>=l)return{leadOffset:i.index+d.length,matchingString:x,replaceableString:i[2]}}return null},o[0]=t,o[1]=m,o[2]=l,o[3]=a):a=o[3],a}var M="slash-menu-popup";function vt({isSelected:t,item:e,onClick:o,onMouseEnter:n,ref:r}){let{fieldProps:{featureClientSchemaMap:m,schemaPath:l}}=R(),{i18n:a}=_e(),u=`${M}__item ${M}__item-${e.key}`;t&&(u+=` ${M}__item--selected`);let g=e.key;return e.label&&(g=typeof e.label=="function"?e.label({featureClientSchemaMap:m,i18n:a,schemaPath:l}):e.label),g.length>25&&(g=g.substring(0,25)+"..."),Oe("button",{"aria-selected":t,className:u,id:M+"__item-"+e.key,onClick:o,onMouseEnter:n,ref:r,role:"option",tabIndex:-1,type:"button",children:[e?.Icon&&G(e.Icon,{}),G("span",{className:`${M}__item-text`,children:g})]},e.key)}function He({anchorElem:t=document.body}){let[e]=wt(),[o,n]=St(null),{editorConfig:r}=R(),{i18n:m}=_e(),{fieldProps:{featureClientSchemaMap:l,schemaPath:a}}=R(),u=De("/",{minLength:0}),g=Rt(()=>{let s=[];for(let i of r.features.slashMenu.dynamicGroups)if(o){let d=i({editor:e,queryString:o});s=s.concat(d)}return s},[e,o,r?.features]),y=kt(()=>{let s=[];for(let i of r?.features.slashMenu.groups??[])s.push(i);if(o){s=s.map(d=>{let x=d.items.filter(p=>{let h=p.key;return p.label&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),new RegExp(o,"gi").exec(h)?!0:p.keywords!=null?p.keywords.some(f=>new RegExp(o,"gi").exec(f)):!1});return x.length?{...d,items:x}:null}),s=s.filter(d=>d!=null);let i=g();for(let d of i){let x=s.find(p=>p.key===d.key);x?s=s.filter(p=>p.key!==d.key):x={...d,items:[]},x?.items?.length&&(x.items=x.items.concat(x.items)),s.push(x)}}return s},[o,r?.features.slashMenu.groups,g,l,m,a]);return G(ge,{anchorElem:t,groups:y,menuRenderFn:(s,{selectedItemKey:i,selectItemAndCleanUp:d,setSelectedItemKey:x})=>s.current&&y.length?$e.createPortal(G("div",{className:M,children:y.map(p=>{let h=p.key;return p.label&&l&&(h=typeof p.label=="function"?p.label({featureClientSchemaMap:l,i18n:m,schemaPath:a}):p.label),Oe("div",{className:`${M}__group ${M}__group-${p.key}`,children:[G("div",{className:`${M}__group-title`,children:h}),p.items.map((f,c)=>G(vt,{index:c,isSelected:i===f.key,item:f,onClick:()=>{x(f.key),d(f)},onMouseEnter:()=>{x(f.key)},ref:E=>{f.ref={current:E}}},f.key))]},p.key)})}),s.current):null,onQueryChange:n,triggerFn:u})}import{c as Mt}from"react/compiler-runtime";import{useLexicalComposerContext as Lt}from"@lexical/react/LexicalComposerContext";import{TEXT_TYPE_TO_FORMAT as je,TextNode as Bt}from"lexical";import{useEffect as At}from"react";function ze(t){let e=Mt(6),{features:o}=t,[n]=Lt(),r;e[0]!==o.enabledFormats||e[1]!==n?(r=()=>{let l=It(o.enabledFormats);if(l.length!==0)return n.registerNodeTransform(Bt,a=>{l.forEach(u=>{a.hasFormat(u)&&a.toggleFormat(u)})})},e[0]=o.enabledFormats,e[1]=n,e[2]=r):r=e[2];let m;return e[3]!==n||e[4]!==o?(m=[n,o],e[3]=n,e[4]=o,e[5]=m):m=e[5],At(r,m),null}function It(t){delete je.highlight;let e=Object.keys(je),o=new Set(t);return e.filter(n=>!o.has(n))}import{c as Ft}from"react/compiler-runtime";import{jsx as Ke}from"react/jsx-runtime";import{ContentEditable as Dt}from"@lexical/react/LexicalContentEditable.js";import{useTranslation as Ot}from"@payloadcms/ui";import"react";function Ge(t){let e=Ft(3),{className:o}=t,{t:n}=Ot(),r;return e[0]!==n||e[1]!==o?(r=Ke(Dt,{"aria-placeholder":n("lexical:general:placeholder"),className:o??"ContentEditable__root",placeholder:Ke("p",{className:"editor-placeholder",children:n("lexical:general:placeholder")})}),e[0]=n,e[1]=o,e[2]=r):r=e[2],r}var Ve=t=>{let e=_t(22),{editorConfig:o,editorContainerRef:n,onChange:r}=t,m=R(),[l]=$t(),[a,u]=Ue(null),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=c=>{c!==null&&u(c)},e[0]=g):g=e[0];let y=g,s,i;e[1]!==m||e[2]!==l?(s=()=>{if(!m?.uuid){console.error("Lexical Editor must be used within an EditorConfigProvider");return}m?.parentEditor?.uuid&&m.parentEditor?.registerChild(m.uuid,m);let c=()=>{m.focusEditor(m)},E=()=>{m.blurEditor(m)},b=l.registerCommand(Yt,()=>(c(),!0),We),T=l.registerCommand(Wt,()=>(E(),!0),We);return()=>{b(),T(),m.parentEditor?.unregisterChild?.(m.uuid)}},i=[l,m],e[1]=m,e[2]=l,e[3]=s,e[4]=i):(s=e[3],i=e[4]),Ye(s,i);let[d,x]=Ue(!1),p,h;e[5]!==d?(p=()=>{let c=()=>{let E=window.matchMedia("(max-width: 768px)").matches;E!==d&&x(E)};return c(),window.addEventListener("resize",c),()=>{window.removeEventListener("resize",c)}},h=[d],e[5]=d,e[6]=p,e[7]=h):(p=e[6],h=e[7]),Ye(p,h);let f;if(e[8]!==o.features||e[9]!==r||e[10]!==a||e[11]!==d||e[12]!==l||e[13]!==n){let c;e[15]!==r?(c=(b,T,C)=>{(!C.has("focus")||C.size>1)&&r?.(b,T,C)},e[15]=r,e[16]=c):c=e[16];let E;e[17]!==a||e[18]!==d||e[19]!==l||e[20]!==o?(E=a&&q(W.Fragment,{children:[!d&&l.isEditable()&&q(W.Fragment,{children:[P(Ae,{anchorElem:a}),P(Pe,{anchorElem:a})]}),o.features.plugins?.map(b=>{if(b.position==="floatingAnchorElem"&&!(b.desktopOnly===!0&&d))return P(D,{anchorElem:a,clientProps:b.clientProps,plugin:b},b.key)}),l.isEditable()&&P(W.Fragment,{children:P(He,{anchorElem:a})})]}),e[17]=a,e[18]=d,e[19]=l,e[20]=o,e[21]=E):E=e[21],f=q(W.Fragment,{children:[o.features.plugins?.map(Ut),q("div",{className:"editor-container",ref:n,children:[o.features.plugins?.map(Vt),P(Kt,{contentEditable:P("div",{className:"editor-scroller",children:P("div",{className:"editor",ref:y,children:P(Ge,{})})}),ErrorBoundary:Ht}),P(ze,{features:o.features}),P(zt,{ignoreSelectionChange:!0,onChange:c}),E,l.isEditable()&&q(W.Fragment,{children:[P(jt,{}),o?.features?.markdownTransformers?.length>0&&P(Fe,{})]}),P(Gt,{}),o.features.plugins?.map(qt),o.features.plugins?.map(Jt)]}),o.features.plugins?.map(Qt)]}),e[8]=o.features,e[9]=r,e[10]=a,e[11]=d,e[12]=l,e[13]=n,e[14]=f}else f=e[14];return f};function Ut(t){if(t.position==="aboveContainer")return P(D,{clientProps:t.clientProps,plugin:t},t.key)}function Vt(t){if(t.position==="top")return P(D,{clientProps:t.clientProps,plugin:t},t.key)}function qt(t){if(t.position==="normal")return P(D,{clientProps:t.clientProps,plugin:t},t.key)}function Jt(t){if(t.position==="bottom")return P(D,{clientProps:t.clientProps,plugin:t},t.key)}function Qt(t){if(t.position==="belowContainer")return P(D,{clientProps:t.clientProps,plugin:t},t.key)}var Je=({children:t,providers:e})=>{if(!e?.length)return t;let o=e[0];return e.length>1?A(o,{children:A(Je,{providers:e.slice(1),children:t})}):A(o,{children:t})},Qe=t=>{let{composerKey:e,editorConfig:o,fieldProps:n,onChange:r,readOnly:m,value:l}=t,a=R(),u=qe.useRef(null),g=Zt(()=>{if(l&&typeof l!="object")throw new Error("The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: "+JSON.stringify(l));if(l&&Array.isArray(l)&&!("root"in l))throw new Error("You have tried to pass in data from the old Slate editor to the new Lexical editor. The data structure is different, thus you will have to migrate your data. We offer a one-line migration script which migrates all your rich text fields: https://payloadcms.com/docs/lexical/migration#migration-via-migration-script-recommended");if(l&&"jsonContent"in l)throw new Error("You have tried to pass in data from payload-plugin-lexical. The data structure is different, thus you will have to migrate your data. Migration guide: https://payloadcms.com/docs/lexical/migration#migrating-from-payload-plugin-lexical");return{editable:m!==!0,editorState:l!=null?JSON.stringify(l):void 0,namespace:o.lexical.namespace,nodes:ye({editorConfig:o}),onError:y=>{throw y},theme:o.lexical.theme}},[o]);return g?A(Xt,{initialConfig:g,children:A(de,{editorConfig:o,editorContainerRef:u,fieldProps:n,parentContext:a,children:A(Je,{providers:o.features.providers,children:A(Ve,{editorConfig:o,editorContainerRef:u,onChange:r})})})},e+g.editable):A("p",{children:"Loading..."})};import"./bundled.css";var ne="rich-text-lexical",lo=t=>{let{editorConfig:e,field:o,field:{name:n,admin:{className:r,readOnly:m}={},label:l,localized:a,required:u},path:g,readOnly:y,validate:s}=t,i=y||m,d=g??n,x=to(),p=Xe((U,me)=>typeof s=="function"?s(U,{...me,required:u}):!0,[s,u]),{customComponents:{AfterInput:h,BeforeInput:f,Description:c,Error:E,Label:b}={},formInitializing:T,formProcessing:C,initialValue:k,setValue:N,showError:Y,value:I}=oo({path:d,validate:p}),L=i||C||T,S=[ne,"field-type",r,Y&&"error",L&&`${ne}--read-only`,e?.admin?.hideGutter!==!0?`${ne}--show-gutter`:null].filter(Boolean).join(" "),$=`${d}.${x}`,se=Xe(U=>{N(U.toJSON())},[N]),ce=io(()=>ro(o),[o]);return re("div",{className:S,style:ce,children:[E,b||ie(eo,{label:l,localized:a,required:u}),re("div",{className:`${ne}__wrap`,children:[re(so,{fallbackRender:ao,onReset:()=>{},children:[f,ie(Qe,{composerKey:$,editorConfig:e,fieldProps:t,onChange:se,readOnly:L,value:I},JSON.stringify({initialValue:k,path:d})),h]}),c]})]},$)};function ao({error:t}){return re("div",{className:"errorBoundary",role:"alert",children:[ie("p",{children:"Something went wrong:"}),ie("pre",{style:{color:"red"},children:t.message})]})}var Cr=no(lo);export{Cr as RichText};
2
- //# sourceMappingURL=Field-4JYUMYYH.js.map