@payloadcms/richtext-lexical 3.67.0 → 3.68.0-canary.0
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/features/blocks/client/component/index.js +1 -3
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/features/blocks/client/componentInline/index.js +1 -3
- package/dist/features/blocks/client/componentInline/index.js.map +1 -1
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js +1 -2
- package/dist/features/blocks/client/markdown/getLexicalToMarkdown.js.map +1 -1
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js +3 -6
- package/dist/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/async/converters/link.js +1 -2
- package/dist/features/converters/lexicalToHtml/async/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js +1 -2
- package/dist/features/converters/lexicalToHtml/sync/converters/link.js.map +1 -1
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js +1 -2
- package/dist/features/converters/lexicalToJSX/converter/converters/link.js.map +1 -1
- package/dist/field/Diff/converters/link.js +1 -2
- package/dist/field/Diff/converters/link.js.map +1 -1
- package/dist/lexical/config/client/EditorConfigProvider.js +1 -2
- package/dist/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/packages/@lexical/markdown/MarkdownImport.js +3 -6
- package/dist/packages/@lexical/markdown/MarkdownImport.js.map +1 -1
- package/dist/utilities/fieldsDrawer/DrawerContent.js +1 -3
- package/dist/utilities/fieldsDrawer/DrawerContent.js.map +1 -1
- package/dist/utilities/useRunDeprioritized.js +1 -2
- package/dist/utilities/useRunDeprioritized.js.map +1 -1
- package/package.json +9 -7
|
@@ -362,9 +362,7 @@ export const BlockComponent = props => {
|
|
|
362
362
|
fields: clientBlock?.fields ?? [],
|
|
363
363
|
forceRender: true,
|
|
364
364
|
parentIndexPath: "",
|
|
365
|
-
parentPath: ""
|
|
366
|
-
,
|
|
367
|
-
|
|
365
|
+
parentPath: "",
|
|
368
366
|
parentSchemaPath: schemaFieldsPath,
|
|
369
367
|
permissions: true,
|
|
370
368
|
readOnly: !isEditable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","undefined","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","children","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","filter","Boolean","join","collapsibleStyle","header","_jsxs","pillStyle","admin","path","count","withMessage","_Fragment","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { type BlockCollapsibleWithErrorProps, BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.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 className: string\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\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 ?? undefined,\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 ?? undefined,\n )\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 operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\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 && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = 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 { i18n, t } = useTranslation<object, string>()\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: newFormState } = 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 readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = 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 onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof CustomLabel !== 'undefined' ? (\n CustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div className={`${baseClass}__block-actions`}>\n {typeof Actions !== 'undefined' ? (\n Actions\n ) : (\n <>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && isEditable ? <RemoveButton /> : null}\n </>\n )}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? '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={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n blockType,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\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cA;;;EAItB,GAAG,CACDC,gBAAA,EACAyB,WAAA,EACAvG,WAAA,EACA3B,SAAA,EACAwG,YAAA,EACAf,UAAA,EACAxH,SAAA,EACA6B,MAAA,EACAV,UAAA,EACAO,YAAA,EACA2D,WAAA,EAAavE,MAAA;EACb;EACAoB,YAAA,EACAhC,OAAA,EACAyF,QAAA,EACAxF,SAAA,CACD;EAED,IAAI,CAACkF,WAAA,EAAa;IAChB,oBACEoC,IAAA,CAACe,gBAAA;MAAiBI,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAS,KAAA,CAAC;QAAIxJ,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzB+B,SAAA,EAAU;;;EAIjC;EAEA,OAAO6B,KAAA;AACT","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Collapsible","Drawer","EditDepthProvider","ErrorPill","Form","formatDrawerSlug","FormSubmit","Pill","RenderFields","SectionTitle","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useFormSubmitted","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isBlockNode","BlockContent","removeEmptyArrayValues","BlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","submitted","id","collectionSlug","globalSlug","fieldProps","featureClientSchemaMap","field","parentLexicalRichTextField","initialLexicalFormState","schemaPath","uuidFromContext","fields","parentDocumentFields","onChangeAbortControllerRef","AbortController","editDepth","errorCount","setErrorCount","useState","config","drawerSlug","slug","depth","toggleDrawer","getDocPreferences","setDocFieldPreferences","editor","isEditable","blockType","getFormState","schemaFieldsPath","initialState","setInitialState","cachedFormState","formState","mergedState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","blockName","passesCondition","valid","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","undefined","CustomBlock","setCustomBlock","Block","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","newFormStateData","update","node","newData","setFields","_components","isCollapsed","setIsCollapsed","collapsed","componentMapRenderedBlockPath","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","i18n","t","onChange","prevFormState","submit","controller","newFormState","initialBlockFormState","setTimeout","rowErrorCount","formField","values","removeBlock","remove","blockDisplayName","labels","singular","onCollapsedChange","changedCollapsed","then","currentDocPreferences","currentFieldPreferences","name","collapsedArray","newCollapsed","length","includes","push","splice","indexOf","hello","EditButton","_jsx","buttonStyle","disabled","el","icon","onClick","e","preventDefault","stopPropagation","onMouseDown","round","size","tooltip","label","RemoveButton","BlockCollapsible","Actions","children","collapsibleProps","disableBlockName","editButton","fieldHasErrors","Label","CustomPill","removeButton","filter","Boolean","join","collapsibleStyle","header","_jsxs","pillStyle","admin","path","count","withMessage","_Fragment","onToggle","incomingCollapsedState","blockID","BlockDrawer","title","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","beforeSubmit","onSubmit","formSchema"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n Drawer,\n EditDepthProvider,\n ErrorPill,\n Form,\n formatDrawerSlug,\n FormSubmit,\n Pill,\n RenderFields,\n SectionTitle,\n useConfig,\n useDocumentForm,\n useDocumentInfo,\n useEditDepth,\n useFormSubmitted,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { $getNodeByKey } from 'lexical'\nimport {\n type BlocksFieldClient,\n type ClientBlock,\n type CollapsedPreferences,\n type FormState,\n} from 'payload'\nimport { deepCopyObjectSimpleWithoutReactComponents, reduceFieldsToValues } from 'payload/shared'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { useEditorConfigContext } from '../../../../lexical/config/client/EditorConfigProvider.js'\nimport './index.scss'\nimport { useLexicalDrawer } from '../../../../utilities/fieldsDrawer/useLexicalDrawer.js'\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { type BlockCollapsibleWithErrorProps, BlockContent } from './BlockContent.js'\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.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 className: string\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { cacheBuster, className: baseClass, formData, nodeKey } = props\n const submitted = useFormSubmitted()\n const { id, collectionSlug, globalSlug } = useDocumentInfo()\n const {\n fieldProps: {\n featureClientSchemaMap,\n field: parentLexicalRichTextField,\n initialLexicalFormState,\n schemaPath,\n },\n uuid: uuidFromContext,\n } = useEditorConfigContext()\n\n const { fields: parentDocumentFields } = useDocumentForm()\n const onChangeAbortControllerRef = useRef(new AbortController())\n const editDepth = useEditDepth()\n const [errorCount, setErrorCount] = React.useState(0)\n\n const { config } = useConfig()\n\n const drawerSlug = formatDrawerSlug({\n slug: `lexical-blocks-create-${uuidFromContext}-${formData.id}`,\n depth: editDepth,\n })\n const { toggleDrawer } = useLexicalDrawer(drawerSlug)\n\n // Used for saving collapsed to preferences (and gettin' it from there again)\n // Remember, these preferences are scoped to the whole document, not just this form. This\n // is important to consider for the data path used in setDocFieldPreferences\n const { getDocPreferences, setDocFieldPreferences } = useDocumentInfo()\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n\n const blockType = formData.blockType\n\n const { getFormState } = useServerFunctions()\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}.fields`\n\n const [initialState, setInitialState] = React.useState<false | FormState | undefined>(() => {\n // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n const mergedState = Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\n\n // Manually add blockName, as it's not part of cachedFormState\n mergedState.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return mergedState\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 ?? undefined,\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 ?? undefined,\n )\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 operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: abortController.signal,\n })\n\n if (state) {\n state.blockName = {\n initialValue: formData.blockName,\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n deepCopyObjectSimpleWithoutReactComponents(state),\n true,\n ) as BlockFields\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 && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n\n node.setFields(newData, true)\n }\n })\n\n setInitialState(state)\n setCustomLabel(state._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(state._components?.customComponents?.Block ?? undefined)\n }\n }\n\n if (formData && !initialState) {\n void awaitInitialState()\n }\n\n return () => {\n abortAndIgnore(abortController)\n }\n }, [\n getFormState,\n schemaFieldsPath,\n isEditable,\n id,\n formData,\n editor,\n nodeKey,\n initialState,\n collectionSlug,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n blockType,\n ])\n\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(\n initialLexicalFormState?.[formData.id]?.collapsed ?? false,\n )\n\n const componentMapRenderedBlockPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.${blockType}`\n\n const clientSchemaMap = featureClientSchemaMap['blocks']\n\n const blocksField: BlocksFieldClient | undefined = 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 { i18n, t } = useTranslation<object, string>()\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: newFormState } = 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 readOnly: !isEditable,\n renderAllFields: submit ? true : false,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!newFormState) {\n return prevFormState\n }\n\n if (prevFormState.blockName) {\n newFormState.blockName = prevFormState.blockName\n }\n\n const newFormStateData: BlockFields = reduceFieldsToValues(\n removeEmptyArrayValues({\n fields: deepCopyObjectSimpleWithoutReactComponents(newFormState),\n }),\n true,\n ) as BlockFields\n\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n const newData = newFormStateData\n newData.blockType = blockType\n node.setFields(newData, true)\n }\n })\n }, 0)\n\n if (submit) {\n setCustomLabel(newFormState._components?.customComponents?.BlockLabel ?? undefined)\n setCustomBlock(newFormState._components?.customComponents?.Block ?? undefined)\n\n let rowErrorCount = 0\n for (const formField of Object.values(newFormState)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n\n return newFormState\n },\n\n [\n getFormState,\n id,\n collectionSlug,\n getDocPreferences,\n globalSlug,\n schemaFieldsPath,\n blockType,\n parentDocumentFields,\n isEditable,\n editor,\n nodeKey,\n ],\n )\n\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n const removeBlock = 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 onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences =\n currentDocPreferences?.fields?.[parentLexicalRichTextField.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n const newCollapsed: CollapsedPreferences =\n collapsedArray && collapsedArray?.length ? collapsedArray : []\n\n if (changedCollapsed) {\n if (!newCollapsed.includes(formData.id)) {\n newCollapsed.push(formData.id)\n }\n } else {\n if (newCollapsed.includes(formData.id)) {\n newCollapsed.splice(newCollapsed.indexOf(formData.id), 1)\n }\n }\n\n setDocFieldPreferences(parentLexicalRichTextField.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, parentLexicalRichTextField.name, setDocFieldPreferences, formData.id],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\n el=\"button\"\n icon=\"edit\"\n onClick={(e) => {\n e.preventDefault()\n e.stopPropagation()\n toggleDrawer()\n return false\n }}\n onMouseDown={(e) => {\n // Needed to preserve lexical selection for toggleDrawer lexical selection restore.\n // I believe this is needed due to this button (usually) being inside of a collapsible.\n e.preventDefault()\n }}\n round\n size=\"small\"\n tooltip={t('lexical:blocks:inlineBlocks:edit', { label: blockDisplayName })}\n />\n ),\n [baseClass, isEditable, t, blockDisplayName, toggleDrawer],\n )\n\n const RemoveButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={!isEditable}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n ),\n [baseClass, isEditable, removeBlock],\n )\n\n const BlockCollapsible = useMemo(\n () =>\n ({\n Actions,\n children,\n className,\n collapsibleProps,\n disableBlockName,\n editButton,\n errorCount,\n fieldHasErrors,\n Label,\n Pill: CustomPill,\n removeButton,\n }: BlockCollapsibleWithErrorProps) => {\n return (\n <div className={`${baseClass}__container ${baseClass}-${blockType}`}>\n <Collapsible\n className={[\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n <div className={`${baseClass}__block-header`}>\n {typeof Label !== 'undefined' ? (\n Label\n ) : typeof CustomLabel !== 'undefined' ? (\n CustomLabel\n ) : (\n <div className={`${baseClass}__block-label`}>\n {typeof CustomPill !== 'undefined' ? (\n CustomPill\n ) : (\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${blockType}`}\n pillStyle=\"white\"\n size=\"small\"\n >\n {blockDisplayName ?? blockType}\n </Pill>\n )}\n {!disableBlockName && !clientBlock?.admin?.disableBlockName && (\n <SectionTitle path=\"blockName\" readOnly={!isEditable} />\n )}\n\n {fieldHasErrors && (\n <ErrorPill count={errorCount ?? 0} i18n={i18n} withMessage />\n )}\n </div>\n )}\n\n <div className={`${baseClass}__block-actions`}>\n {typeof Actions !== 'undefined' ? (\n Actions\n ) : (\n <>\n {(CustomBlock && editButton !== false) || (!CustomBlock && editButton) ? (\n <EditButton />\n ) : null}\n {removeButton !== false && isEditable ? <RemoveButton /> : null}\n </>\n )}\n </div>\n </div>\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n {...(collapsibleProps || {})}\n >\n {children}\n </Collapsible>\n </div>\n )\n },\n [\n CustomBlock,\n CustomLabel,\n EditButton,\n RemoveButton,\n blockDisplayName,\n baseClass,\n clientBlock?.admin?.disableBlockName,\n blockType,\n i18n,\n isCollapsed,\n onCollapsedChange,\n isEditable,\n ],\n )\n\n const blockID = formData?.id\n\n const BlockDrawer = useMemo(\n () => () => (\n <EditDepthProvider>\n <Drawer\n className={''}\n slug={drawerSlug}\n title={t(`lexical:blocks:inlineBlocks:${blockID ? '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={!isEditable}\n />\n <FormSubmit programmaticSubmit={true}>{t('fields:saveChanges')}</FormSubmit>\n </>\n ) : null}\n </Drawer>\n </EditDepthProvider>\n ),\n [\n initialState,\n drawerSlug,\n blockID,\n blockDisplayName,\n t,\n isEditable,\n clientBlock?.fields,\n schemaFieldsPath,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n ],\n )\n\n // Memoized Form JSX\n const Block = useMemo(() => {\n if (!initialState) {\n return null\n }\n return (\n <Form\n beforeSubmit={[\n async ({ formState }) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n return await onChange({ formState, submit: true })\n },\n ]}\n el=\"div\"\n fields={clientBlock?.fields ?? []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={(formState, newData) => {\n // This is only called when form is submitted from drawer - usually only the case if the block has a custom Block component\n newData.blockType = blockType\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n node.setFields(newData as BlockFields, true)\n }\n })\n toggleDrawer()\n }}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n BlockDrawer={BlockDrawer}\n Collapsible={BlockCollapsible}\n CustomBlock={CustomBlock}\n EditButton={EditButton}\n errorCount={errorCount}\n formSchema={clientBlock?.fields ?? []}\n initialState={initialState}\n nodeKey={nodeKey}\n RemoveButton={RemoveButton}\n />\n </Form>\n )\n }, [\n BlockCollapsible,\n BlockDrawer,\n CustomBlock,\n blockType,\n RemoveButton,\n EditButton,\n baseClass,\n editor,\n errorCount,\n toggleDrawer,\n clientBlock?.fields,\n // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n initialState,\n nodeKey,\n onChange,\n submitted,\n ])\n\n if (!clientBlock) {\n return (\n <BlockCollapsible disableBlockName={true} fieldHasErrors={true}>\n <div className={`${baseClass}-not-found`}>\n Error: Block '{blockType}' not found in the config but exists in the lexical data\n </div>\n </BlockCollapsible>\n )\n }\n\n return Block\n}\n"],"mappings":"AAAA;;;AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,WAAW,EACXC,MAAM,EACNC,iBAAiB,EACjBC,SAAS,EACTC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,IAAI,EACJC,YAAY,EACZC,YAAY,EACZC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAO9B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC/D,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,YAAY,QAAQ;AAC7B,SAA8CC,YAAY,QAAQ;AAClE,SAASC,sBAAsB,QAAQ;AAcvC,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,WAAW;IAAEC,SAAA,EAAWC,SAAS;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGL,KAAA;EACjE,MAAMM,SAAA,GAAY1B,gBAAA;EAClB,MAAM;IA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gBAEN,aAAAmI,IAAA,CAAC/H,YAAA;QACCM,SAAA,EAAWA,SAAA;QACXiK,WAAA,EAAaA,WAAA;QACbtM,WAAA,EAAa6K,gBAAA;QACb9E,WAAA,EAAaA,WAAA;QACb8D,UAAA,EAAYA,UAAA;QACZrG,UAAA,EAAYA,UAAA;QACZwJ,UAAA,EAAYtF,WAAA,EAAavE,MAAA,IAAU,EAAE;QACrCoB,YAAA,EAAcA,YAAA;QACdhC,OAAA,EAASA,OAAA;QACTqI,YAAA,EAAcA;;;EAItB,GAAG,CACDC,gBAAA,EACAyB,WAAA,EACAvG,WAAA,EACA3B,SAAA,EACAwG,YAAA,EACAf,UAAA,EACAxH,SAAA,EACA6B,MAAA,EACAV,UAAA,EACAO,YAAA,EACA2D,WAAA,EAAavE,MAAA;EACb;EACAoB,YAAA,EACAhC,OAAA,EACAyF,QAAA,EACAxF,SAAA,CACD;EAED,IAAI,CAACkF,WAAA,EAAa;IAChB,oBACEoC,IAAA,CAACe,gBAAA;MAAiBI,gBAAA,EAAkB;MAAME,cAAA,EAAgB;gBACxD,aAAAS,KAAA,CAAC;QAAIxJ,SAAA,EAAW,GAAGC,SAAA,YAAqB;mBAAE,kBACzB+B,SAAA,EAAU;;;EAIjC;EAEA,OAAO6B,KAAA;AACT","ignoreList":[]}
|
|
@@ -328,9 +328,7 @@ export const InlineBlockComponent = props => {
|
|
|
328
328
|
fields: clientBlock?.fields,
|
|
329
329
|
forceRender: true,
|
|
330
330
|
parentIndexPath: "",
|
|
331
|
-
parentPath: ""
|
|
332
|
-
,
|
|
333
|
-
|
|
331
|
+
parentPath: "",
|
|
334
332
|
parentSchemaPath: schemaFieldsPath,
|
|
335
333
|
permissions: true,
|
|
336
334
|
readOnly: !isEditable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","editor","isEditable","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","cachedFormState","id","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","readOnly","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","isStateOutOfSync","keys","some","key","onFormSubmit","RemoveButton","_jsx","buttonStyle","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\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 className: string\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, className: baseClass, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\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 // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\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 readOnly: !isEditable,\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 isEditable,\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 readOnly: !isEditable,\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 isEditable,\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={!isEditable}\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 [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\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 [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, 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 {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={!isEditable}\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 {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAI9B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAuBnC,MAAMC,2BAAA,gBAA8BV,aAAA,CAA+C;EACjFW,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,8BAAA,GAAiCA,CAAA,KAAMb,KAAA,CAAMc,GAAG,CAACH,2BAAA;AAE9D,OAAO,MAAMI,oBAAA,GAAyCC,KAAA;EACpD,MAAM;IAAEC,WAAW;IAAEC,SAAA,EAAWC,SAAS;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGL,KAAA;EAEjE,MAAM,CAACM,MAAA,CAAO,GAAG3C,yBAAA;EACjB,MAAM4C,UAAA,GAAa3C,kBAAA;EACnB,MAAM;IAAE4C,IAAI;IAAEC;EAAC,CAAE,GAAG9B,cAAA;EACpB,MAAM;IACJ+B,kBAAkB;IAClBC,UAAA,EAAY;MAAEC,sBAAsB;MAAEC,uBAAuB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H,KAAA,CAAC;QAAIxH,SAAA,EAAW,GAAGC,SAAA,WAAoB;gCACrCmG,IAAA,CAACW,UAAA,O,aACDX,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["useLexicalComposerContext","useLexicalEditable","getTranslation","Button","Drawer","EditDepthProvider","Form","formatDrawerSlug","FormSubmit","RenderFields","ShimmerEffect","useConfig","useDocumentForm","useDocumentInfo","useEditDepth","useServerFunctions","useTranslation","abortAndIgnore","$getNodeByKey","deepCopyObjectSimpleWithoutReactComponents","reduceFieldsToValues","React","createContext","useCallback","useEffect","useMemo","useRef","v4","uuid","useEditorConfigContext","useLexicalDrawer","$isInlineBlockNode","InlineBlockComponentContext","initialState","useInlineBlockComponentContext","use","InlineBlockComponent","props","cacheBuster","className","baseClass","formData","nodeKey","editor","isEditable","i18n","t","createdInlineBlock","fieldProps","featureClientSchemaMap","initialLexicalFormState","schemaPath","setCreatedInlineBlock","uuidFromContext","fields","parentDocumentFields","getFormState","editDepth","firstTimeDrawer","setInitialState","useState","cachedFormState","id","formState","Object","fromEntries","entries","map","fieldName","fieldState","initialValue","value","hasMounted","prevCacheBuster","current","CustomLabel","setCustomLabel","customComponents","BlockLabel","CustomBlock","setCustomBlock","Block","drawerSlug","slug","depth","toggleDrawer","inlineBlockElemElemRef","collectionSlug","getDocPreferences","globalSlug","config","componentMapRenderedBlockPath","blockType","clientSchemaMap","blocksField","clientBlock","blockReferences","blocksMap","blocks","clientBlockFields","getKey","length","undefined","removeInlineBlock","update","remove","blockDisplayName","labels","singular","onChangeAbortControllerRef","AbortController","schemaFieldsPath","abortController","awaitInitialState","state","data","docPermissions","docPreferences","documentFormState","initialBlockData","initialBlockFormState","operation","readOnly","renderAllFields","signal","newFormStateData","node","newData","setFields","onChange","prevFormState","submit","controller","isStateOutOfSync","keys","some","key","onFormSubmit","RemoveButton","_jsx","buttonStyle","disabled","icon","onClick","e","preventDefault","round","size","tooltip","label","EditButton","el","InlineBlockContainer","children","filter","Boolean","join","ref","Label","_jsxs","beforeSubmit","disableValidationOnSubmit","onSubmit","title","_Fragment","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions","programmaticSubmit","height","width"],"sources":["../../../../../src/features/blocks/client/componentInline/index.tsx"],"sourcesContent":["'use client'\n\nimport type { BlocksFieldClient, ClientBlock, Data, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\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 React, { createContext, useCallback, useEffect, useMemo, useRef } from 'react'\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 className: string\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, className: baseClass, formData, nodeKey } = props\n\n const [editor] = useLexicalComposerContext()\n const isEditable = useLexicalEditable()\n const { i18n, t } = useTranslation<object, string>()\n const {\n createdInlineBlock,\n fieldProps: { featureClientSchemaMap, initialLexicalFormState, schemaPath },\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 // Initial form state that was calculated server-side. May have stale values\n const cachedFormState = initialLexicalFormState?.[formData.id]?.formState\n if (!cachedFormState) {\n return false\n }\n\n // Merge current formData values into the cached form state\n // This ensures that when the component remounts (e.g., due to view changes), we don't lose user edits\n return Object.fromEntries(\n Object.entries(cachedFormState).map(([fieldName, fieldState]) => [\n fieldName,\n fieldName in formData\n ? {\n ...fieldState,\n initialValue: formData[fieldName],\n value: formData[fieldName],\n }\n : fieldState,\n ]),\n )\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 readOnly: !isEditable,\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 isEditable,\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 readOnly: !isEditable,\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 isEditable,\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={!isEditable}\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 [baseClass, blockDisplayName, isEditable, removeInlineBlock, t],\n )\n\n const EditButton = useMemo(\n () => () => (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__editButton`}\n disabled={!isEditable}\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 [baseClass, blockDisplayName, isEditable, t, toggleDrawer],\n )\n\n const InlineBlockContainer = useMemo(\n () =>\n ({ children, className }: { children: React.ReactNode; className?: string }) => (\n <div\n className={[`${baseClass}__container`, baseClass + '-' + formData.blockType, className]\n .filter(Boolean)\n .join(' ')}\n ref={inlineBlockElemElemRef}\n >\n {children}\n </div>\n ),\n [baseClass, 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 {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={!isEditable}\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 {isEditable ? (\n <div className={`${baseClass}__actions`}>\n <EditButton />\n <RemoveButton />\n </div>\n ) : null}\n </InlineBlockContainer>\n )}\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAIA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,kBAAkB,QAAQ;AACnC,SAASC,cAAc,QAAQ;AAC/B,SACEC,MAAM,EACNC,MAAM,EACNC,iBAAiB,EACjBC,IAAI,EACJC,gBAAgB,EAChBC,UAAU,EACVC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,eAAe,EACfC,YAAY,EACZC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,aAAa,QAAQ;AAI9B,SAASC,0CAA0C,EAAEC,oBAAoB,QAAQ;AACjF,OAAOC,KAAA,IAASC,aAAa,EAAEC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ;AAC9E,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,QAAQ;AACjC,SAASC,kBAAkB,QAAQ;AAuBnC,MAAMC,2BAAA,gBAA8BV,aAAA,CAA+C;EACjFW,YAAA,EAAc;AAChB;AAEA,OAAO,MAAMC,8BAAA,GAAiCA,CAAA,KAAMb,KAAA,CAAMc,GAAG,CAACH,2BAAA;AAE9D,OAAO,MAAMI,oBAAA,GAAyCC,KAAA;EACpD,MAAM;IAAEC,WAAW;IAAEC,SAAA,EAAWC,SAAS;IA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EAAO;QACL+E,UAAA;QACArH,YAAA;QACAuH,oBAAA;QACAM,KAAA;QACApH,OAAA;QACAgG;MACF;gBAEC3D;sBAGHgF,KAAA,CAACP,oBAAA;iBACEvH,YAAA,gBAAe0G,IAAA,CAACmB,KAAA,qBAAWnB,IAAA,CAACjI,aAAA;QAAciK,MAAA,EAAO;QAAOC,KAAA,EAAM;UAC9DhI,UAAA,gBACCmH,KAAA,CAAC;QAAIxH,SAAA,EAAW,GAAGC,SAAA,WAAoB;gCACrCmG,IAAA,CAACW,UAAA,O,aACDX,IAAA,CAACD,YAAA;WAED;;;AAKd","ignoreList":[]}
|
|
@@ -8,8 +8,7 @@ export function getLexicalToMarkdown(allNodes, allTransformers) {
|
|
|
8
8
|
nodes: allNodes
|
|
9
9
|
});
|
|
10
10
|
try {
|
|
11
|
-
headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState)) // This should commit the editor state immediately
|
|
12
|
-
;
|
|
11
|
+
headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState)); // This should commit the editor state immediately
|
|
13
12
|
} catch (e) {
|
|
14
13
|
console.error('getLexicalToMarkdown: ERROR parsing editor state', e);
|
|
15
14
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getLexicalToMarkdown.js","names":["createHeadlessEditor","$convertToMarkdownString","getLexicalToMarkdown","allNodes","allTransformers","lexicalToMarkdown","editorState","headlessEditor","nodes","setEditorState","parseEditorState","e","console","error","markdown","getEditorState","read"],"sources":["../../../../../src/features/blocks/client/markdown/getLexicalToMarkdown.ts"],"sourcesContent":["import type { Klass, LexicalNode, LexicalNodeReplacement } from 'lexical'\n\nimport { createHeadlessEditor } from '@lexical/headless'\n\nimport {\n $convertToMarkdownString,\n type Transformer,\n} from '../../../../packages/@lexical/markdown/index.js'\n\nexport function getLexicalToMarkdown(\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>,\n allTransformers: Transformer[],\n): (args: { editorState: Record<string, any> }) => string {\n const lexicalToMarkdown = ({ editorState }: { editorState: Record<string, any> }): string => {\n const headlessEditor = createHeadlessEditor({\n nodes: allNodes,\n })\n\n try {\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState as any)) // This should commit the editor state immediately\n } catch (e) {\n console.error('getLexicalToMarkdown: ERROR parsing editor state', e)\n }\n\n let markdown: string = ''\n headlessEditor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(allTransformers)\n })\n\n return markdown\n }\n return lexicalToMarkdown\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AAErC,SACEC,wBAAwB,QAEnB;AAEP,OAAO,SAASC,qBACdC,QAA4D,EAC5DC,eAA8B;EAE9B,MAAMC,iBAAA,GAAoBA,CAAC;IAAEC;EAAW,CAAwC;IAC9E,MAAMC,cAAA,GAAiBP,oBAAA,CAAqB;MAC1CQ,KAAA,EAAOL;IACT;IAEA,IAAI;MACFI,cAAA,CAAeE,cAAc,CAACF,cAAA,CAAeG,gBAAgB,CAACJ,WAAA,
|
|
1
|
+
{"version":3,"file":"getLexicalToMarkdown.js","names":["createHeadlessEditor","$convertToMarkdownString","getLexicalToMarkdown","allNodes","allTransformers","lexicalToMarkdown","editorState","headlessEditor","nodes","setEditorState","parseEditorState","e","console","error","markdown","getEditorState","read"],"sources":["../../../../../src/features/blocks/client/markdown/getLexicalToMarkdown.ts"],"sourcesContent":["import type { Klass, LexicalNode, LexicalNodeReplacement } from 'lexical'\n\nimport { createHeadlessEditor } from '@lexical/headless'\n\nimport {\n $convertToMarkdownString,\n type Transformer,\n} from '../../../../packages/@lexical/markdown/index.js'\n\nexport function getLexicalToMarkdown(\n allNodes: Array<Klass<LexicalNode> | LexicalNodeReplacement>,\n allTransformers: Transformer[],\n): (args: { editorState: Record<string, any> }) => string {\n const lexicalToMarkdown = ({ editorState }: { editorState: Record<string, any> }): string => {\n const headlessEditor = createHeadlessEditor({\n nodes: allNodes,\n })\n\n try {\n headlessEditor.setEditorState(headlessEditor.parseEditorState(editorState as any)) // This should commit the editor state immediately\n } catch (e) {\n console.error('getLexicalToMarkdown: ERROR parsing editor state', e)\n }\n\n let markdown: string = ''\n headlessEditor.getEditorState().read(() => {\n markdown = $convertToMarkdownString(allTransformers)\n })\n\n return markdown\n }\n return lexicalToMarkdown\n}\n"],"mappings":"AAEA,SAASA,oBAAoB,QAAQ;AAErC,SACEC,wBAAwB,QAEnB;AAEP,OAAO,SAASC,qBACdC,QAA4D,EAC5DC,eAA8B;EAE9B,MAAMC,iBAAA,GAAoBA,CAAC;IAAEC;EAAW,CAAwC;IAC9E,MAAMC,cAAA,GAAiBP,oBAAA,CAAqB;MAC1CQ,KAAA,EAAOL;IACT;IAEA,IAAI;MACFI,cAAA,CAAeE,cAAc,CAACF,cAAA,CAAeG,gBAAgB,CAACJ,WAAA,IAAqB;IACrF,EAAE,OAAOK,CAAA,EAAG;MACVC,OAAA,CAAQC,KAAK,CAAC,oDAAoDF,CAAA;IACpE;IAEA,IAAIG,QAAA,GAAmB;IACvBP,cAAA,CAAeQ,cAAc,GAAGC,IAAI,CAAC;MACnCF,QAAA,GAAWb,wBAAA,CAAyBG,eAAA;IACtC;IAEA,OAAOU,QAAA;EACT;EACA,OAAOT,iBAAA;AACT","ignoreList":[]}
|
|
@@ -33,8 +33,7 @@ export function linesFromStartToContentAndPropsString({
|
|
|
33
33
|
}
|
|
34
34
|
let charIndex = 0;
|
|
35
35
|
if (lineIndex === 0) {
|
|
36
|
-
charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved // We need to also loop over the ">" in something like "<InlineCode>" in order to later set isWithinContent to true
|
|
37
|
-
;
|
|
36
|
+
charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved; // We need to also loop over the ">" in something like "<InlineCode>" in order to later set isWithinContent to true
|
|
38
37
|
}
|
|
39
38
|
while (charIndex < line.length) {
|
|
40
39
|
const char = line[charIndex];
|
|
@@ -69,8 +68,7 @@ export function linesFromStartToContentAndPropsString({
|
|
|
69
68
|
contentSubTagStartAmount--;
|
|
70
69
|
if (contentSubTagStartAmount < 0) {
|
|
71
70
|
if (content[content.length - 1] === '\n') {
|
|
72
|
-
content = content.slice(0, -1) // Remove the last newline
|
|
73
|
-
;
|
|
71
|
+
content = content.slice(0, -1); // Remove the last newline
|
|
74
72
|
}
|
|
75
73
|
endLineIndex = lineIndex;
|
|
76
74
|
// Calculate endlineLastCharIndex by finding ">" in line
|
|
@@ -86,8 +84,7 @@ export function linesFromStartToContentAndPropsString({
|
|
|
86
84
|
contentSubTagStartAmount--;
|
|
87
85
|
if (contentSubTagStartAmount < 0) {
|
|
88
86
|
if (content[content.length - 1] === '\n') {
|
|
89
|
-
content = content.slice(0, -1) // Remove the last newline
|
|
90
|
-
;
|
|
87
|
+
content = content.slice(0, -1); // Remove the last newline
|
|
91
88
|
}
|
|
92
89
|
endLineIndex = lineIndex;
|
|
93
90
|
endlineLastCharIndex = charIndex + 2;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linesFromMatchToContentAndPropsString.js","names":["linesFromStartToContentAndPropsString","isEndOptional","lines","regexpEndRegex","startLineIndex","startMatch","trimChildren","propsString","content","linesCopy","slice","isWithinContent","contentSubTagStartAmount","bracketCount","quoteChar","isSelfClosing","isWithinCodeBlockAmount","beforeStartLine","index","endlineLastCharIndex","endLineIndex","mainLoop","lineIndex","lineCopy","entries","line","trim","amountOfBeginningSpacesRemoved","i","length","charIndex","char","nextChar","match","undefined","Error","join","JSON","stringify","afterEndLine"],"sources":["../../../../../src/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.ts"],"sourcesContent":["export function linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren,\n}: {\n isEndOptional?: boolean\n lines: string[]\n regexpEndRegex?: RegExp\n startLineIndex: number\n startMatch: RegExpMatchArray\n trimChildren?: boolean\n}): {\n /**\n * The matched string after the end match, in the same line as the end match. Useful for inline matches.\n */\n afterEndLine: string\n /**\n * The matched string before the start match, in the same line as the start match. Useful for inline matches.\n */\n beforeStartLine: string\n content: string\n endLineIndex: number\n endlineLastCharIndex: number\n propsString: string\n} {\n let propsString = ''\n let content = ''\n const linesCopy = lines.slice(startLineIndex)\n\n let isWithinContent = false // If false => is within prop\n let contentSubTagStartAmount = 0\n\n let bracketCount = 0\n let quoteChar: null | string = null\n let isSelfClosing = false\n let isWithinCodeBlockAmount = 0\n\n const beforeStartLine = linesCopy[0]!.slice(0, startMatch.index)\n let endlineLastCharIndex = 0\n\n let endLineIndex = startLineIndex\n\n mainLoop: for (const [lineIndex, lineCopy] of linesCopy.entries()) {\n const line = trimChildren ? lineCopy.trim() : lineCopy\n let amountOfBeginningSpacesRemoved = 0\n if (trimChildren) {\n for (let i = 0; i < lineCopy.length; i++) {\n if (lineCopy[i] === ' ') {\n amountOfBeginningSpacesRemoved++\n } else {\n break\n }\n }\n }\n\n let charIndex = 0\n\n if (lineIndex === 0) {\n charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved // We need to also loop over the \">\" in something like \"<InlineCode>\" in order to later set isWithinContent to true\n }\n\n while (charIndex < line.length) {\n const char = line[charIndex]\n const nextChar = line[charIndex + 1]\n\n if (!isWithinContent) {\n if (char === '{' && !quoteChar) {\n bracketCount++\n } else if (char === '}' && !quoteChar) {\n bracketCount--\n } else if ((char === '\"' || char === \"'\") && !quoteChar) {\n quoteChar = char\n } else if (char === quoteChar) {\n quoteChar = null\n }\n\n if (char === '/' && nextChar === '>' && bracketCount === 0 && !quoteChar) {\n isSelfClosing = true\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n\n break mainLoop\n } else if (char === '>' && bracketCount === 0 && !quoteChar) {\n isWithinContent = true\n charIndex++\n continue\n }\n\n propsString += char\n } else {\n if (char === '`') {\n isWithinCodeBlockAmount++\n }\n\n if (isWithinCodeBlockAmount % 2 === 0) {\n if (char === '<' && nextChar === '/') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n // Calculate endlineLastCharIndex by finding \">\" in line\n for (let i = charIndex; i < line.length; i++) {\n if (line[i] === '>') {\n endlineLastCharIndex = i + 1\n\n break\n }\n }\n break mainLoop\n }\n } else if (char === '/' && nextChar === '>') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n break mainLoop\n }\n } else if (char === '<' && nextChar !== '/') {\n contentSubTagStartAmount++\n }\n }\n\n content += char\n }\n\n charIndex++\n }\n\n if (isWithinContent) {\n if (content?.length > 0 && lineIndex > 0) {\n content += '\\n'\n }\n } else {\n propsString += '\\n'\n }\n\n if (regexpEndRegex && contentSubTagStartAmount < 0) {\n // If 0 and in same line where it got lowered to 0 then this is not the match we are looking for\n const match = line.match(regexpEndRegex)\n if (match?.index !== undefined) {\n endLineIndex = lineIndex\n endlineLastCharIndex = match.index + match[0].length - 1\n break\n }\n }\n\n if (lineIndex === linesCopy.length - 1 && !isEndOptional && !isSelfClosing) {\n throw new Error(\n 'End match not found for lines ' +\n lines.join('\\n') +\n '\\n\\n. Start match: ' +\n JSON.stringify(startMatch),\n )\n }\n }\n\n const afterEndLine = linesCopy[endLineIndex]!.trim().slice(endlineLastCharIndex)\n\n return {\n afterEndLine,\n beforeStartLine,\n content,\n endLineIndex: startLineIndex + endLineIndex,\n endlineLastCharIndex,\n propsString,\n }\n}\n"],"mappings":"AAAA,OAAO,SAASA,sCAAsC;EACpDC,aAAa;EACbC,KAAK;EACLC,cAAc;EACdC,cAAc;EACdC,UAAU;EACVC;AAAY,CAQb;EAcC,IAAIC,WAAA,GAAc;EAClB,IAAIC,OAAA,GAAU;EACd,MAAMC,SAAA,GAAYP,KAAA,CAAMQ,KAAK,CAACN,cAAA;EAE9B,IAAIO,eAAA,GAAkB,MAAM;EAAA;EAC5B,IAAIC,wBAAA,GAA2B;EAE/B,IAAIC,YAAA,GAAe;EACnB,IAAIC,SAAA,GAA2B;EAC/B,IAAIC,aAAA,GAAgB;EACpB,IAAIC,uBAAA,GAA0B;EAE9B,MAAMC,eAAA,GAAkBR,SAAS,CAAC,EAAE,CAAEC,KAAK,CAAC,GAAGL,UAAA,CAAWa,KAAK;EAC/D,IAAIC,oBAAA,GAAuB;EAE3B,IAAIC,YAAA,GAAehB,cAAA;EAEnBiB,QAAA,EAAU,KAAK,MAAM,CAACC,SAAA,EAAWC,QAAA,CAAS,IAAId,SAAA,CAAUe,OAAO,IAAI;IACjE,MAAMC,IAAA,GAAOnB,YAAA,GAAeiB,QAAA,CAASG,IAAI,KAAKH,QAAA;IAC9C,IAAII,8BAAA,GAAiC;IACrC,IAAIrB,YAAA,EAAc;MAChB,KAAK,IAAIsB,CAAA,GAAI,GAAGA,CAAA,GAAIL,QAAA,CAASM,MAAM,EAAED,CAAA,IAAK;QACxC,IAAIL,QAAQ,CAACK,CAAA,CAAE,KAAK,KAAK;UACvBD,8BAAA;QACF,OAAO;UACL;QACF;MACF;IACF;IAEA,IAAIG,SAAA,GAAY;IAEhB,IAAIR,SAAA,KAAc,GAAG;MACnBQ,SAAA,GAAY,CAACzB,UAAA,CAAWa,KAAK,IAAI,KAAKb,UAAU,CAAC,EAAE,CAACwB,MAAM,GAAGF,8BAAA,
|
|
1
|
+
{"version":3,"file":"linesFromMatchToContentAndPropsString.js","names":["linesFromStartToContentAndPropsString","isEndOptional","lines","regexpEndRegex","startLineIndex","startMatch","trimChildren","propsString","content","linesCopy","slice","isWithinContent","contentSubTagStartAmount","bracketCount","quoteChar","isSelfClosing","isWithinCodeBlockAmount","beforeStartLine","index","endlineLastCharIndex","endLineIndex","mainLoop","lineIndex","lineCopy","entries","line","trim","amountOfBeginningSpacesRemoved","i","length","charIndex","char","nextChar","match","undefined","Error","join","JSON","stringify","afterEndLine"],"sources":["../../../../../src/features/blocks/server/markdown/linesFromMatchToContentAndPropsString.ts"],"sourcesContent":["export function linesFromStartToContentAndPropsString({\n isEndOptional,\n lines,\n regexpEndRegex,\n startLineIndex,\n startMatch,\n trimChildren,\n}: {\n isEndOptional?: boolean\n lines: string[]\n regexpEndRegex?: RegExp\n startLineIndex: number\n startMatch: RegExpMatchArray\n trimChildren?: boolean\n}): {\n /**\n * The matched string after the end match, in the same line as the end match. Useful for inline matches.\n */\n afterEndLine: string\n /**\n * The matched string before the start match, in the same line as the start match. Useful for inline matches.\n */\n beforeStartLine: string\n content: string\n endLineIndex: number\n endlineLastCharIndex: number\n propsString: string\n} {\n let propsString = ''\n let content = ''\n const linesCopy = lines.slice(startLineIndex)\n\n let isWithinContent = false // If false => is within prop\n let contentSubTagStartAmount = 0\n\n let bracketCount = 0\n let quoteChar: null | string = null\n let isSelfClosing = false\n let isWithinCodeBlockAmount = 0\n\n const beforeStartLine = linesCopy[0]!.slice(0, startMatch.index)\n let endlineLastCharIndex = 0\n\n let endLineIndex = startLineIndex\n\n mainLoop: for (const [lineIndex, lineCopy] of linesCopy.entries()) {\n const line = trimChildren ? lineCopy.trim() : lineCopy\n let amountOfBeginningSpacesRemoved = 0\n if (trimChildren) {\n for (let i = 0; i < lineCopy.length; i++) {\n if (lineCopy[i] === ' ') {\n amountOfBeginningSpacesRemoved++\n } else {\n break\n }\n }\n }\n\n let charIndex = 0\n\n if (lineIndex === 0) {\n charIndex = (startMatch.index ?? 0) + startMatch[0].length - amountOfBeginningSpacesRemoved // We need to also loop over the \">\" in something like \"<InlineCode>\" in order to later set isWithinContent to true\n }\n\n while (charIndex < line.length) {\n const char = line[charIndex]\n const nextChar = line[charIndex + 1]\n\n if (!isWithinContent) {\n if (char === '{' && !quoteChar) {\n bracketCount++\n } else if (char === '}' && !quoteChar) {\n bracketCount--\n } else if ((char === '\"' || char === \"'\") && !quoteChar) {\n quoteChar = char\n } else if (char === quoteChar) {\n quoteChar = null\n }\n\n if (char === '/' && nextChar === '>' && bracketCount === 0 && !quoteChar) {\n isSelfClosing = true\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n\n break mainLoop\n } else if (char === '>' && bracketCount === 0 && !quoteChar) {\n isWithinContent = true\n charIndex++\n continue\n }\n\n propsString += char\n } else {\n if (char === '`') {\n isWithinCodeBlockAmount++\n }\n\n if (isWithinCodeBlockAmount % 2 === 0) {\n if (char === '<' && nextChar === '/') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n // Calculate endlineLastCharIndex by finding \">\" in line\n for (let i = charIndex; i < line.length; i++) {\n if (line[i] === '>') {\n endlineLastCharIndex = i + 1\n\n break\n }\n }\n break mainLoop\n }\n } else if (char === '/' && nextChar === '>') {\n contentSubTagStartAmount--\n\n if (contentSubTagStartAmount < 0) {\n if (content[content.length - 1] === '\\n') {\n content = content.slice(0, -1) // Remove the last newline\n }\n endLineIndex = lineIndex\n endlineLastCharIndex = charIndex + 2\n break mainLoop\n }\n } else if (char === '<' && nextChar !== '/') {\n contentSubTagStartAmount++\n }\n }\n\n content += char\n }\n\n charIndex++\n }\n\n if (isWithinContent) {\n if (content?.length > 0 && lineIndex > 0) {\n content += '\\n'\n }\n } else {\n propsString += '\\n'\n }\n\n if (regexpEndRegex && contentSubTagStartAmount < 0) {\n // If 0 and in same line where it got lowered to 0 then this is not the match we are looking for\n const match = line.match(regexpEndRegex)\n if (match?.index !== undefined) {\n endLineIndex = lineIndex\n endlineLastCharIndex = match.index + match[0].length - 1\n break\n }\n }\n\n if (lineIndex === linesCopy.length - 1 && !isEndOptional && !isSelfClosing) {\n throw new Error(\n 'End match not found for lines ' +\n lines.join('\\n') +\n '\\n\\n. Start match: ' +\n JSON.stringify(startMatch),\n )\n }\n }\n\n const afterEndLine = linesCopy[endLineIndex]!.trim().slice(endlineLastCharIndex)\n\n return {\n afterEndLine,\n beforeStartLine,\n content,\n endLineIndex: startLineIndex + endLineIndex,\n endlineLastCharIndex,\n propsString,\n }\n}\n"],"mappings":"AAAA,OAAO,SAASA,sCAAsC;EACpDC,aAAa;EACbC,KAAK;EACLC,cAAc;EACdC,cAAc;EACdC,UAAU;EACVC;AAAY,CAQb;EAcC,IAAIC,WAAA,GAAc;EAClB,IAAIC,OAAA,GAAU;EACd,MAAMC,SAAA,GAAYP,KAAA,CAAMQ,KAAK,CAACN,cAAA;EAE9B,IAAIO,eAAA,GAAkB,MAAM;EAAA;EAC5B,IAAIC,wBAAA,GAA2B;EAE/B,IAAIC,YAAA,GAAe;EACnB,IAAIC,SAAA,GAA2B;EAC/B,IAAIC,aAAA,GAAgB;EACpB,IAAIC,uBAAA,GAA0B;EAE9B,MAAMC,eAAA,GAAkBR,SAAS,CAAC,EAAE,CAAEC,KAAK,CAAC,GAAGL,UAAA,CAAWa,KAAK;EAC/D,IAAIC,oBAAA,GAAuB;EAE3B,IAAIC,YAAA,GAAehB,cAAA;EAEnBiB,QAAA,EAAU,KAAK,MAAM,CAACC,SAAA,EAAWC,QAAA,CAAS,IAAId,SAAA,CAAUe,OAAO,IAAI;IACjE,MAAMC,IAAA,GAAOnB,YAAA,GAAeiB,QAAA,CAASG,IAAI,KAAKH,QAAA;IAC9C,IAAII,8BAAA,GAAiC;IACrC,IAAIrB,YAAA,EAAc;MAChB,KAAK,IAAIsB,CAAA,GAAI,GAAGA,CAAA,GAAIL,QAAA,CAASM,MAAM,EAAED,CAAA,IAAK;QACxC,IAAIL,QAAQ,CAACK,CAAA,CAAE,KAAK,KAAK;UACvBD,8BAAA;QACF,OAAO;UACL;QACF;MACF;IACF;IAEA,IAAIG,SAAA,GAAY;IAEhB,IAAIR,SAAA,KAAc,GAAG;MACnBQ,SAAA,GAAY,CAACzB,UAAA,CAAWa,KAAK,IAAI,KAAKb,UAAU,CAAC,EAAE,CAACwB,MAAM,GAAGF,8BAAA,EAA+B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AA,EAAe;MAC1E,MAAM,IAAIoB,KAAA,CACR,mCACEjC,KAAA,CAAMkC,IAAI,CAAC,QACX,wBACAC,IAAA,CAAKC,SAAS,CAACjC,UAAA;IAErB;EACF;EAEA,MAAMkC,YAAA,GAAe9B,SAAS,CAACW,YAAA,CAAa,CAAEM,IAAI,GAAGhB,KAAK,CAACS,oBAAA;EAE3D,OAAO;IACLoB,YAAA;IACAtB,eAAA;IACAT,OAAA;IACAY,YAAA,EAAchB,cAAA,GAAiBgB,YAAA;IAC/BD,oBAAA;IACAZ;EACF;AACF","ignoreList":[]}
|
|
@@ -29,8 +29,7 @@ export const LinkHTMLConverterAsync = ({
|
|
|
29
29
|
});
|
|
30
30
|
} else {
|
|
31
31
|
console.error('Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided');
|
|
32
|
-
href = '#' // fallback
|
|
33
|
-
;
|
|
32
|
+
href = '#'; // fallback
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
35
|
return `<a${providedStyleTag} href="${href}"${node.fields.newTab ? ' rel="noopener noreferrer" target="_blank"' : ''}>${children}</a>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["LinkHTMLConverterAsync","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","fields","url","newTab","link","populate","href","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToHtml/async/converters/link.ts"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { HTMLConvertersAsync, HTMLPopulateFn } from '../types.js'\n\nexport const LinkHTMLConverterAsync: (args: {\n internalDocToHref?: (args: {\n linkNode: SerializedLinkNode\n populate?: HTMLPopulateFn\n }) => Promise<string> | string\n}) => HTMLConvertersAsync<SerializedAutoLinkNode | SerializedLinkNode> = ({\n internalDocToHref,\n}) => ({\n autolink: async ({ node, nodesToHTML, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n return `<a${providedStyleTag} href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n link: async ({ node, nodesToHTML, populate, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = await internalDocToHref({ linkNode: node, populate })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return `<a${providedStyleTag} href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n})\n"],"mappings":"AAGA,OAAO,MAAMA,sBAAA,GAK4DA,CAAC;EACxEC;AAAiB,CAClB,MAAM;EACLC,QAAA,EAAU,MAAAA,CAAO;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IACtD,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP,OAAO,KAAKH,gBAAA,UAA0BF,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAIP,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACnJ;EACAM,IAAA,EAAM,MAAAA,CAAO;IAAET,IAAI;IAAEC,WAAW;IAAES,QAAQ;IAAER;EAAgB,CAAE;IAC5D,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP,IAAIM,IAAA,GAAeX,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAI;IACtC,IAAIP,IAAA,CAAKM,MAAM,CAACM,QAAQ,KAAK,YAAY;MACvC,IAAId,iBAAA,EAAmB;QACrBa,IAAA,GAAO,MAAMb,iBAAA,CAAkB;UAAEe,QAAA,EAAUb,IAAA;UAAMU;QAAS;MAC5D,OAAO;QACLI,OAAA,CAAQC,KAAK,CACX;QAEFJ,IAAA,GAAO,
|
|
1
|
+
{"version":3,"file":"link.js","names":["LinkHTMLConverterAsync","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","fields","url","newTab","link","populate","href","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToHtml/async/converters/link.ts"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { HTMLConvertersAsync, HTMLPopulateFn } from '../types.js'\n\nexport const LinkHTMLConverterAsync: (args: {\n internalDocToHref?: (args: {\n linkNode: SerializedLinkNode\n populate?: HTMLPopulateFn\n }) => Promise<string> | string\n}) => HTMLConvertersAsync<SerializedAutoLinkNode | SerializedLinkNode> = ({\n internalDocToHref,\n}) => ({\n autolink: async ({ node, nodesToHTML, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n return `<a${providedStyleTag} href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n link: async ({ node, nodesToHTML, populate, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = await internalDocToHref({ linkNode: node, populate })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return `<a${providedStyleTag} href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n})\n"],"mappings":"AAGA,OAAO,MAAMA,sBAAA,GAK4DA,CAAC;EACxEC;AAAiB,CAClB,MAAM;EACLC,QAAA,EAAU,MAAAA,CAAO;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IACtD,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP,OAAO,KAAKH,gBAAA,UAA0BF,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAIP,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACnJ;EACAM,IAAA,EAAM,MAAAA,CAAO;IAAET,IAAI;IAAEC,WAAW;IAAES,QAAQ;IAAER;EAAgB,CAAE;IAC5D,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP,IAAIM,IAAA,GAAeX,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAI;IACtC,IAAIP,IAAA,CAAKM,MAAM,CAACM,QAAQ,KAAK,YAAY;MACvC,IAAId,iBAAA,EAAmB;QACrBa,IAAA,GAAO,MAAMb,iBAAA,CAAkB;UAAEe,QAAA,EAAUb,IAAA;UAAMU;QAAS;MAC5D,OAAO;QACLI,OAAA,CAAQC,KAAK,CACX;QAEFJ,IAAA,GAAO,KAAI;MACb;IACF;IAEA,OAAO,KAAKT,gBAAA,UAA0BS,IAAA,IAAQX,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACxI;AACF","ignoreList":[]}
|
|
@@ -27,8 +27,7 @@ export const LinkHTMLConverter = ({
|
|
|
27
27
|
});
|
|
28
28
|
} else {
|
|
29
29
|
console.error('Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided');
|
|
30
|
-
href = '#' // fallback
|
|
31
|
-
;
|
|
30
|
+
href = '#'; // fallback
|
|
32
31
|
}
|
|
33
32
|
}
|
|
34
33
|
return `<a${providedStyleTag} href="${href}"${node.fields.newTab ? ' rel="noopener noreferrer" target="_blank"' : ''}>${children}</a>`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["LinkHTMLConverter","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","fields","url","newTab","link","href","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/link.ts"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { HTMLConverters } from '../types.js'\n\nexport const LinkHTMLConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => HTMLConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToHTML, providedStyleTag }) => {\n const children = nodesToHTML({\n nodes: node.children,\n }).join('')\n\n return `<a${providedStyleTag} href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n link: ({ node, nodesToHTML, providedStyleTag }) => {\n const children = nodesToHTML({\n nodes: node.children,\n }).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return `<a${providedStyleTag} href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n})\n"],"mappings":"AAGA,OAAO,MAAMA,iBAAA,GAEuDA,CAAC;EAAEC;AAAiB,CAAE,MAAM;EAC9FC,QAAA,EAAUA,CAAC;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IAChD,MAAMC,QAAA,GAAWF,WAAA,CAAY;MAC3BG,KAAA,EAAOJ,IAAA,CAAKG;IACd,GAAGE,IAAI,CAAC;IAER,OAAO,KAAKH,gBAAA,UAA0BF,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAIP,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACnJ;EACAM,IAAA,EAAMA,CAAC;IAAET,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IAC5C,MAAMC,QAAA,GAAWF,WAAA,CAAY;MAC3BG,KAAA,EAAOJ,IAAA,CAAKG;IACd,GAAGE,IAAI,CAAC;IAER,IAAIK,IAAA,GAAeV,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAI;IACtC,IAAIP,IAAA,CAAKM,MAAM,CAACK,QAAQ,KAAK,YAAY;MACvC,IAAIb,iBAAA,EAAmB;QACrBY,IAAA,GAAOZ,iBAAA,CAAkB;UAAEc,QAAA,EAAUZ;QAAK;MAC5C,OAAO;QACLa,OAAA,CAAQC,KAAK,CACX;QAEFJ,IAAA,GAAO,
|
|
1
|
+
{"version":3,"file":"link.js","names":["LinkHTMLConverter","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","fields","url","newTab","link","href","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToHtml/sync/converters/link.ts"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { HTMLConverters } from '../types.js'\n\nexport const LinkHTMLConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => HTMLConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToHTML, providedStyleTag }) => {\n const children = nodesToHTML({\n nodes: node.children,\n }).join('')\n\n return `<a${providedStyleTag} href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n link: ({ node, nodesToHTML, providedStyleTag }) => {\n const children = nodesToHTML({\n nodes: node.children,\n }).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return `<a${providedStyleTag} href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>${children}</a>`\n },\n})\n"],"mappings":"AAGA,OAAO,MAAMA,iBAAA,GAEuDA,CAAC;EAAEC;AAAiB,CAAE,MAAM;EAC9FC,QAAA,EAAUA,CAAC;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IAChD,MAAMC,QAAA,GAAWF,WAAA,CAAY;MAC3BG,KAAA,EAAOJ,IAAA,CAAKG;IACd,GAAGE,IAAI,CAAC;IAER,OAAO,KAAKH,gBAAA,UAA0BF,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAIP,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACnJ;EACAM,IAAA,EAAMA,CAAC;IAAET,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IAC5C,MAAMC,QAAA,GAAWF,WAAA,CAAY;MAC3BG,KAAA,EAAOJ,IAAA,CAAKG;IACd,GAAGE,IAAI,CAAC;IAER,IAAIK,IAAA,GAAeV,IAAA,CAAKM,MAAM,CAACC,GAAG,IAAI;IACtC,IAAIP,IAAA,CAAKM,MAAM,CAACK,QAAQ,KAAK,YAAY;MACvC,IAAIb,iBAAA,EAAmB;QACrBY,IAAA,GAAOZ,iBAAA,CAAkB;UAAEc,QAAA,EAAUZ;QAAK;MAC5C,OAAO;QACLa,OAAA,CAAQC,KAAK,CACX;QAEFJ,IAAA,GAAO,KAAI;MACb;IACF;IAEA,OAAO,KAAKR,gBAAA,UAA0BQ,IAAA,IAAQV,IAAA,CAAKM,MAAM,CAACE,MAAM,GAAG,+CAA+C,MAAML,QAAA,MAAc;EACxI;AACF","ignoreList":[]}
|
|
@@ -35,8 +35,7 @@ export const LinkJSXConverter = ({
|
|
|
35
35
|
});
|
|
36
36
|
} else {
|
|
37
37
|
console.error('Lexical => JSX converter: Link converter: found internal link, but internalDocToHref is not provided');
|
|
38
|
-
href = '#' // fallback
|
|
39
|
-
;
|
|
38
|
+
href = '#'; // fallback
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
return /*#__PURE__*/_jsx("a", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["LinkJSXConverter","internalDocToHref","autolink","node","nodesToJSX","children","nodes","rel","fields","newTab","undefined","target","_jsx","href","url","link","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/link.tsx"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinkJSXConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => JSXConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n return (\n <a href={node.fields.url} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n link: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => JSX converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return (\n <a href={href} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n})\n"],"mappings":";AAGA,OAAO,MAAMA,gBAAA,GAEsDA,CAAC;EAAEC;AAAiB,CAAE,MAAM;EAC7FC,QAAA,EAAUA,CAAC;IAAEC,IAAI;IAAEC;EAAU,CAAE;IAC7B,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAME,GAAA,GAA0BJ,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC,SAAA;IAC7E,MAAMC,MAAA,GAA6BR,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC,SAAA;IAEnE,oBACEE,IAAA,CAAC;MAAEC,IAAA,EAAMV,IAAA,CAAKK,MAAM,CAACM,GAAG;MAAQP,GAAA;MAAKI,MAAA;gBAClCN;;EAGP;EACAU,IAAA,EAAMA,CAAC;IAAEZ,IAAI;IAAEC;EAAU,CAAE;IACzB,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAME,GAAA,GAA0BJ,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC,SAAA;IAC7E,MAAMC,MAAA,GAA6BR,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC,SAAA;IAEnE,IAAIG,IAAA,GAAeV,IAAA,CAAKK,MAAM,CAACM,GAAG,IAAI;IACtC,IAAIX,IAAA,CAAKK,MAAM,CAACQ,QAAQ,KAAK,YAAY;MACvC,IAAIf,iBAAA,EAAmB;QACrBY,IAAA,GAAOZ,iBAAA,CAAkB;UAAEgB,QAAA,EAAUd;QAAK;MAC5C,OAAO;QACLe,OAAA,CAAQC,KAAK,CACX;QAEFN,IAAA,GAAO,
|
|
1
|
+
{"version":3,"file":"link.js","names":["LinkJSXConverter","internalDocToHref","autolink","node","nodesToJSX","children","nodes","rel","fields","newTab","undefined","target","_jsx","href","url","link","linkType","linkNode","console","error"],"sources":["../../../../../../src/features/converters/lexicalToJSX/converter/converters/link.tsx"],"sourcesContent":["import type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../../../nodeTypes.js'\nimport type { JSXConverters } from '../types.js'\n\nexport const LinkJSXConverter: (args: {\n internalDocToHref?: (args: { linkNode: SerializedLinkNode }) => string\n}) => JSXConverters<SerializedAutoLinkNode | SerializedLinkNode> = ({ internalDocToHref }) => ({\n autolink: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n return (\n <a href={node.fields.url} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n link: ({ node, nodesToJSX }) => {\n const children = nodesToJSX({\n nodes: node.children,\n })\n\n const rel: string | undefined = node.fields.newTab ? 'noopener noreferrer' : undefined\n const target: string | undefined = node.fields.newTab ? '_blank' : undefined\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = internalDocToHref({ linkNode: node })\n } else {\n console.error(\n 'Lexical => JSX converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n return (\n <a href={href} {...{ rel, target }}>\n {children}\n </a>\n )\n },\n})\n"],"mappings":";AAGA,OAAO,MAAMA,gBAAA,GAEsDA,CAAC;EAAEC;AAAiB,CAAE,MAAM;EAC7FC,QAAA,EAAUA,CAAC;IAAEC,IAAI;IAAEC;EAAU,CAAE;IAC7B,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAME,GAAA,GAA0BJ,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC,SAAA;IAC7E,MAAMC,MAAA,GAA6BR,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC,SAAA;IAEnE,oBACEE,IAAA,CAAC;MAAEC,IAAA,EAAMV,IAAA,CAAKK,MAAM,CAACM,GAAG;MAAQP,GAAA;MAAKI,MAAA;gBAClCN;;EAGP;EACAU,IAAA,EAAMA,CAAC;IAAEZ,IAAI;IAAEC;EAAU,CAAE;IACzB,MAAMC,QAAA,GAAWD,UAAA,CAAW;MAC1BE,KAAA,EAAOH,IAAA,CAAKE;IACd;IAEA,MAAME,GAAA,GAA0BJ,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,wBAAwBC,SAAA;IAC7E,MAAMC,MAAA,GAA6BR,IAAA,CAAKK,MAAM,CAACC,MAAM,GAAG,WAAWC,SAAA;IAEnE,IAAIG,IAAA,GAAeV,IAAA,CAAKK,MAAM,CAACM,GAAG,IAAI;IACtC,IAAIX,IAAA,CAAKK,MAAM,CAACQ,QAAQ,KAAK,YAAY;MACvC,IAAIf,iBAAA,EAAmB;QACrBY,IAAA,GAAOZ,iBAAA,CAAkB;UAAEgB,QAAA,EAAUd;QAAK;MAC5C,OAAO;QACLe,OAAA,CAAQC,KAAK,CACX;QAEFN,IAAA,GAAO,KAAI;MACb;IACF;IAEA,oBACED,IAAA,CAAC;MAAEC,IAAA,EAAMA,IAAA;MAAYN,GAAA;MAAKI,MAAA;gBACvBN;;EAGP;AACF","ignoreList":[]}
|
|
@@ -34,8 +34,7 @@ export const LinkDiffHTMLConverterAsync = ({
|
|
|
34
34
|
});
|
|
35
35
|
} else {
|
|
36
36
|
console.error('Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided');
|
|
37
|
-
href = '#' // fallback
|
|
38
|
-
;
|
|
37
|
+
href = '#'; // fallback
|
|
39
38
|
}
|
|
40
39
|
}
|
|
41
40
|
// hash fields to ensure they are diffed if they change
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"link.js","names":["createHash","LinkDiffHTMLConverterAsync","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","nodeFieldsHash","update","JSON","stringify","fields","digest","url","newTab","link","populate","href","linkType","linkNode","console","error"],"sources":["../../../../src/field/Diff/converters/link.ts"],"sourcesContent":["import { createHash } from 'crypto'\n\nimport type {\n HTMLConvertersAsync,\n HTMLPopulateFn,\n} from '../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../nodeTypes.js'\n\nexport const LinkDiffHTMLConverterAsync: (args: {\n internalDocToHref?: (args: {\n linkNode: SerializedLinkNode\n populate?: HTMLPopulateFn\n }) => Promise<string> | string\n}) => HTMLConvertersAsync<SerializedAutoLinkNode | SerializedLinkNode> = ({\n internalDocToHref,\n}) => ({\n autolink: async ({ node, nodesToHTML, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256').update(JSON.stringify(node.fields)).digest('hex')\n\n return `<a${providedStyleTag} data-fields-hash=\"${nodeFieldsHash}\" data-enable-match=\"true\" href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>\n ${children}\n </a>`\n },\n link: async ({ node, nodesToHTML, populate, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = await internalDocToHref({ linkNode: node, populate })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256')\n .update(JSON.stringify(node.fields ?? {}))\n .digest('hex')\n\n return `<a${providedStyleTag} data-fields-hash=\"${nodeFieldsHash}\" data-enable-match=\"true\" href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>\n ${children}\n </a>`\n },\n})\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAQ3B,OAAO,MAAMC,0BAAA,GAK4DA,CAAC;EACxEC;AAAiB,CAClB,MAAM;EACLC,QAAA,EAAU,MAAAA,CAAO;IAAEC,IAAI;IAAEC,WAAW;IAAEC;EAAgB,CAAE;IACtD,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP;IACA,MAAMC,cAAA,GAAiBV,UAAA,CAAW,UAAUW,MAAM,CAACC,IAAA,CAAKC,SAAS,CAACT,IAAA,CAAKU,MAAM,GAAGC,MAAM,CAAC;IAEvF,OAAO,KAAKT,gBAAA,sBAAsCI,cAAA,oCAAkDN,IAAA,CAAKU,MAAM,CAACE,GAAG,IAAIZ,IAAA,CAAKU,MAAM,CAACG,MAAM,GAAG,+CAA+C;UACrLV,QAAA;WACC;EACT;EACAW,IAAA,EAAM,MAAAA,CAAO;IAAEd,IAAI;IAAEC,WAAW;IAAEc,QAAQ;IAAEb;EAAgB,CAAE;IAC5D,MAAMC,QAAA,GAAW,CACf,MAAMF,WAAA,CAAY;MAChBG,KAAA,EAAOJ,IAAA,CAAKG;IACd,EAAC,EACDE,IAAI,CAAC;IAEP,IAAIW,IAAA,GAAehB,IAAA,CAAKU,MAAM,CAACE,GAAG,IAAI;IACtC,IAAIZ,IAAA,CAAKU,MAAM,CAACO,QAAQ,KAAK,YAAY;MACvC,IAAInB,iBAAA,EAAmB;QACrBkB,IAAA,GAAO,MAAMlB,iBAAA,CAAkB;UAAEoB,QAAA,EAAUlB,IAAA;UAAMe;QAAS;MAC5D,OAAO;QACLI,OAAA,CAAQC,KAAK,CACX;QAEFJ,IAAA,GAAO,
|
|
1
|
+
{"version":3,"file":"link.js","names":["createHash","LinkDiffHTMLConverterAsync","internalDocToHref","autolink","node","nodesToHTML","providedStyleTag","children","nodes","join","nodeFieldsHash","update","JSON","stringify","fields","digest","url","newTab","link","populate","href","linkType","linkNode","console","error"],"sources":["../../../../src/field/Diff/converters/link.ts"],"sourcesContent":["import { createHash } from 'crypto'\n\nimport type {\n HTMLConvertersAsync,\n HTMLPopulateFn,\n} from '../../../features/converters/lexicalToHtml/async/types.js'\nimport type { SerializedAutoLinkNode, SerializedLinkNode } from '../../../nodeTypes.js'\n\nexport const LinkDiffHTMLConverterAsync: (args: {\n internalDocToHref?: (args: {\n linkNode: SerializedLinkNode\n populate?: HTMLPopulateFn\n }) => Promise<string> | string\n}) => HTMLConvertersAsync<SerializedAutoLinkNode | SerializedLinkNode> = ({\n internalDocToHref,\n}) => ({\n autolink: async ({ node, nodesToHTML, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256').update(JSON.stringify(node.fields)).digest('hex')\n\n return `<a${providedStyleTag} data-fields-hash=\"${nodeFieldsHash}\" data-enable-match=\"true\" href=\"${node.fields.url}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>\n ${children}\n </a>`\n },\n link: async ({ node, nodesToHTML, populate, providedStyleTag }) => {\n const children = (\n await nodesToHTML({\n nodes: node.children,\n })\n ).join('')\n\n let href: string = node.fields.url ?? ''\n if (node.fields.linkType === 'internal') {\n if (internalDocToHref) {\n href = await internalDocToHref({ linkNode: node, populate })\n } else {\n console.error(\n 'Lexical => HTML converter: Link converter: found internal link, but internalDocToHref is not provided',\n )\n href = '#' // fallback\n }\n }\n\n // hash fields to ensure they are diffed if they change\n const nodeFieldsHash = createHash('sha256')\n .update(JSON.stringify(node.fields ?? {}))\n .digest('hex')\n\n return `<a${providedStyleTag} data-fields-hash=\"${nodeFieldsHash}\" data-enable-match=\"true\" href=\"${href}\"${node.fields.newTab ? ' rel=\"noopener noreferrer\" target=\"_blank\"' : ''}>\n ${children}\n </a>`\n },\n})\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ;AAQ3B,OAAO,MAAMC,0BAAA,GAK4DA,CAAC;EACxEC;AAAiB,CAClB,MAAM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ACG,MAAM,GAAG,+CAA+C;UAC1KV,QAAA;WACC;EACT;AACF","ignoreList":[]}
|
|
@@ -33,8 +33,7 @@ export const EditorConfigProvider = ({
|
|
|
33
33
|
const editorContext_1 = useMemo(() => ({
|
|
34
34
|
blurEditor: editorContext => {
|
|
35
35
|
//setFocusedEditor(null) // Clear focused editor
|
|
36
|
-
focusHistory.current.clear() // Reset focus history when focus is lost
|
|
37
|
-
;
|
|
36
|
+
focusHistory.current.clear(); // Reset focus history when focus is lost
|
|
38
37
|
},
|
|
39
38
|
childrenEditors,
|
|
40
39
|
createdInlineBlock,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","useEditDepth","React","createContext","use","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","fieldProps","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","createdInlineBlock","setCreatedInlineBlock","editDepth","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","parentEditor","registerChild","childUUID","childEditorContext","newMap","set","unregisterChild","delete","_jsx","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { MarkRequired } from 'ts-essentials'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { createContext, use, useMemo, useRef, useState } from 'react'\n\nimport type { InlineBlockNode } from '../../../features/blocks/client/nodes/InlineBlocksNode.js'\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n createdInlineBlock?: InlineBlockNode\n editDepth: number\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n fieldProps: MarkRequired<LexicalRichTextFieldProps, 'path' | 'schemaPath'>\n focusedEditor: EditorConfigContextType | null\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n setCreatedInlineBlock?: React.Dispatch<React.SetStateAction<InlineBlockNode | undefined>>\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\n// @ts-expect-error: TODO: Fix this\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n fieldProps: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n fieldProps,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n\n fieldProps: LexicalRichTextFieldProps\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(() => generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n const [createdInlineBlock, setCreatedInlineBlock] = useState<InlineBlockNode>()\n\n const editDepth = useEditDepth()\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n createdInlineBlock,\n editDepth,\n editor,\n editorConfig,\n editorContainerRef,\n fieldProps,\n focusedEditor,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n setCreatedInlineBlock,\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n createdInlineBlock,\n setCreatedInlineBlock,\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n editDepth,\n fieldProps,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context value={editorContext}>{children}</Context>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = use(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"mappings":"AAAA;;;AAKA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,YAAY,QAAQ;AAC7B,YAAYC,KAAA,MAAW;AACvB,SAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAM9D;AACA,SAASC,kBAAA;EACP,OAAOC,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,IAAA,CAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAsBA;AACA,MAAMC,OAAA,gBAAkDV,aAAA,CAAc;EACpEW,YAAA,EAAc;EACdC,UAAA,EAAY;EACZC,IAAA,EAAM;AACR;AAEA,OAAO,MAAMC,oBAAA,GAAuBA,CAAC;EACnCC,QAAQ;EACRJ,YAAY;EACZK,kBAAkB;EAClBJ,UAAU;EACVK;AAAa,CAQd;EACC,MAAM,CAACC,MAAA,CAAO,GAAGrB,yBAAA;EACjB;EACA,MAAM,CAACgB,IAAA,CAAK,GAAGT,QAAA,CAAS,MAAMC,iBAAA;EAE9B,MAAMc,eAAA,GAAkBhB,MAAA,CAA6C,IAAIiB,GAAA;EACzE,MAAM,CAACC,aAAA,EAAeC,gBAAA,CAAiB,GAAGlB,QAAA,CAAyC;EACnF,MAAMmB,YAAA,GAAepB,MAAA,CAAoB,IAAIqB,GAAA;EAC7C,MAAM,CAACC,kBAAA,EAAoBC,qBAAA,CAAsB,GAAGtB,QAAA;EAEpD,MAAMuB,SAAA,GAAY7B,YAAA;EAElB,MAAM8B,eAAA,GAAgB1B,OAAA,CACpB,OACG;IACC2B,UAAA,EAAaD,aAAA;MACX;MACAL,YAAA,CAAaO,OAAO,CAACC,KAAK,
|
|
1
|
+
{"version":3,"file":"EditorConfigProvider.js","names":["useLexicalComposerContext","useEditDepth","React","createContext","use","useMemo","useRef","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","fieldProps","uuid","EditorConfigProvider","children","editorContainerRef","parentContext","editor","childrenEditors","Map","focusedEditor","setFocusedEditor","focusHistory","Set","createdInlineBlock","setCreatedInlineBlock","editDepth","editorContext","blurEditor","current","clear","focusEditor","editorUUID","has","add","forEach","childEditor","parentEditor","registerChild","childUUID","childEditorContext","newMap","set","unregisterChild","delete","_jsx","value","useEditorConfigContext","context","undefined","Error"],"sources":["../../../../src/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { LexicalEditor } from 'lexical'\nimport type { MarkRequired } from 'ts-essentials'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { useEditDepth } from '@payloadcms/ui'\nimport * as React from 'react'\nimport { createContext, use, useMemo, useRef, useState } from 'react'\n\nimport type { InlineBlockNode } from '../../../features/blocks/client/nodes/InlineBlocksNode.js'\nimport type { LexicalRichTextFieldProps } from '../../../types.js'\nimport type { SanitizedClientEditorConfig } from '../types.js'\n\n// Should always produce a 20 character pseudo-random string\nfunction generateQuickGuid(): string {\n return Math.random().toString(36).substring(2, 12) + Math.random().toString(36).substring(2, 12)\n}\n\nexport interface EditorConfigContextType {\n // Editor focus handling\n blurEditor: (editorContext: EditorConfigContextType) => void\n childrenEditors: React.RefObject<Map<string, EditorConfigContextType>>\n createdInlineBlock?: InlineBlockNode\n editDepth: number\n editor: LexicalEditor\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement>\n fieldProps: MarkRequired<LexicalRichTextFieldProps, 'path' | 'schemaPath'>\n focusedEditor: EditorConfigContextType | null\n // Editor focus handling\n focusEditor: (editorContext: EditorConfigContextType) => void\n parentEditor: EditorConfigContextType\n registerChild: (uuid: string, editorContext: EditorConfigContextType) => void\n setCreatedInlineBlock?: React.Dispatch<React.SetStateAction<InlineBlockNode | undefined>>\n unregisterChild?: (uuid: string) => void\n uuid: string\n}\n\n// @ts-expect-error: TODO: Fix this\nconst Context: React.Context<EditorConfigContextType> = createContext({\n editorConfig: null,\n fieldProps: null,\n uuid: null,\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n editorContainerRef,\n fieldProps,\n parentContext,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n editorContainerRef: React.RefObject<HTMLDivElement | null>\n\n fieldProps: LexicalRichTextFieldProps\n parentContext?: EditorConfigContextType\n}): React.ReactNode => {\n const [editor] = useLexicalComposerContext()\n // State to store the UUID\n const [uuid] = useState(() => generateQuickGuid())\n\n const childrenEditors = useRef<Map<string, EditorConfigContextType>>(new Map())\n const [focusedEditor, setFocusedEditor] = useState<EditorConfigContextType | null>(null)\n const focusHistory = useRef<Set<string>>(new Set())\n const [createdInlineBlock, setCreatedInlineBlock] = useState<InlineBlockNode>()\n\n const editDepth = useEditDepth()\n\n const editorContext = useMemo(\n () =>\n ({\n blurEditor: (editorContext: EditorConfigContextType) => {\n //setFocusedEditor(null) // Clear focused editor\n focusHistory.current.clear() // Reset focus history when focus is lost\n },\n childrenEditors,\n createdInlineBlock,\n editDepth,\n editor,\n editorConfig,\n editorContainerRef,\n fieldProps,\n focusedEditor,\n focusEditor: (editorContext: EditorConfigContextType) => {\n const editorUUID = editorContext.uuid\n\n // Avoid recursion by checking if this editor is already focused in this cycle\n if (focusHistory.current.has(editorUUID)) {\n return\n }\n\n // Add this editor to the history to prevent future recursions in this cycle\n focusHistory.current.add(editorUUID)\n setFocusedEditor(editorContext)\n\n // Propagate focus event to parent and children, ensuring they do not refocus this editor\n if (parentContext?.uuid) {\n parentContext.focusEditor(editorContext)\n }\n childrenEditors.current.forEach((childEditor) => {\n childEditor.focusEditor(editorContext)\n })\n\n focusHistory.current.clear()\n },\n parentEditor: parentContext,\n registerChild: (childUUID, childEditorContext) => {\n if (!childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.set(childUUID, childEditorContext)\n childrenEditors.current = newMap\n }\n },\n setCreatedInlineBlock,\n unregisterChild: (childUUID) => {\n if (childrenEditors.current.has(childUUID)) {\n const newMap = new Map(childrenEditors.current)\n newMap.delete(childUUID)\n childrenEditors.current = newMap\n }\n },\n\n uuid,\n }) as EditorConfigContextType,\n [\n createdInlineBlock,\n setCreatedInlineBlock,\n editor,\n childrenEditors,\n editorConfig,\n editorContainerRef,\n editDepth,\n fieldProps,\n focusedEditor,\n parentContext,\n uuid,\n ],\n )\n\n return <Context value={editorContext}>{children}</Context>\n}\n\nexport const useEditorConfigContext = (): EditorConfigContextType => {\n const context = use(Context)\n if (context === undefined) {\n throw new Error('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;EAGH,oBAAOiC,IAAA,CAACpC,OAAA;IAAQqC,KAAA,EAAOnB,eAAA;cAAgBb;;AACzC;AAEA,OAAO,MAAMiC,sBAAA,GAAyBA,CAAA;EACpC,MAAMC,OAAA,GAAUhD,GAAA,CAAIS,OAAA;EACpB,IAAIuC,OAAA,KAAYC,SAAA,EAAW;IACzB,MAAM,IAAIC,KAAA,CAAM;EAClB;EACA,OAAOF,OAAA;AACT","ignoreList":[]}
|
|
@@ -29,8 +29,7 @@ export function createMarkdownImport(transformers, shouldPreserveNewLines = fals
|
|
|
29
29
|
// There could be other sub-markdown elements (both multiline and normal ones) matching within this matched multiline element's children.
|
|
30
30
|
// However, it would be the responsibility of the matched multiline transformer to decide how it wants to handle them.
|
|
31
31
|
// We cannot handle those, as there is no way for us to know how to maintain the correct order of generated lexical nodes for possible children.
|
|
32
|
-
i = shiftedIndex // Next loop will start from the line after the last line of the multiline element
|
|
33
|
-
;
|
|
32
|
+
i = shiftedIndex; // Next loop will start from the line after the last line of the multiline element
|
|
34
33
|
continue;
|
|
35
34
|
}
|
|
36
35
|
$importBlocks(lineText, root, byType.element, textFormatTransformersIndex, byType.textMatch);
|
|
@@ -109,12 +108,10 @@ function $importMultiline(lines, startLineIndex, multilineElementTransformers, r
|
|
|
109
108
|
const line = lines[i];
|
|
110
109
|
if (i === startLineIndex) {
|
|
111
110
|
const text = line.slice(startMatch[0].length);
|
|
112
|
-
linesInBetween.push(text) // Also include empty text
|
|
113
|
-
;
|
|
111
|
+
linesInBetween.push(text); // Also include empty text
|
|
114
112
|
} else if (i === endLineIndex && endMatch) {
|
|
115
113
|
const text = line.slice(0, -endMatch[0].length);
|
|
116
|
-
linesInBetween.push(text) // Also include empty text
|
|
117
|
-
;
|
|
114
|
+
linesInBetween.push(text); // Also include empty text
|
|
118
115
|
} else {
|
|
119
116
|
linesInBetween.push(line);
|
|
120
117
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownImport.js","names":["$isListItemNode","$isListNode","$isQuoteNode","$findMatchingParent","$createLineBreakNode","$createParagraphNode","$createTextNode","$getRoot","$getSelection","$isParagraphNode","importTextTransformers","isEmptyParagraph","transformersByType","createMarkdownImport","transformers","shouldPreserveNewLines","byType","textFormatTransformersIndex","createTextFormatTransformersIndex","textFormat","markdownString","node","lines","split","linesLength","length","root","clear","i","lineText","imported","shiftedIndex","$importMultiline","multilineElement","$importBlocks","element","textMatch","children","getChildren","child","getChildrenSize","remove","selectStart","startLineIndex","multilineElementTransformers","rootNode","transformer","handleImportAfterStartMatch","regExpEnd","regExpStart","replace","startMatch","match","result","regexpEndRegex","regExp","isEndOptional","optional","endLineIndex","endMatch","index","linesInBetween","push","slice","line","text","elementTransformers","textMatchTransformers","textNode","elementNode","append","setTextContent","isAttached","previousNode","getPreviousSibling","targetNode","lastDescendant","getLastDescendant","getTextContentSize","splice","textTransformers","transformersByTag","fullMatchRegExpByTag","openTagsRegExp","escapeRegExp","tag","tagRegExp","RegExp","join"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownImport.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ListItemNode } from '@lexical/list'\nimport type { ElementNode } from 'lexical'\n\nimport { $isListItemNode, $isListNode } from '@lexical/list'\nimport { $isQuoteNode } from '@lexical/rich-text'\nimport { $findMatchingParent } from '@lexical/utils'\nimport {\n $createLineBreakNode,\n $createParagraphNode,\n $createTextNode,\n $getRoot,\n $getSelection,\n $isParagraphNode,\n} from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { importTextTransformers } from './importTextTransformers.js'\nimport { isEmptyParagraph, transformersByType } from './utils.js'\n\nexport type TextFormatTransformersIndex = Readonly<{\n fullMatchRegExpByTag: Readonly<Record<string, RegExp>>\n openTagsRegExp: RegExp\n transformersByTag: Readonly<Record<string, TextFormatTransformer>>\n}>\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n */\nexport function createMarkdownImport(\n transformers: Array<Transformer>,\n shouldPreserveNewLines = false,\n): (markdownString: string, node?: ElementNode) => void {\n const byType = transformersByType(transformers)\n const textFormatTransformersIndex = createTextFormatTransformersIndex(byType.textFormat)\n\n return (markdownString, node) => {\n const lines = markdownString.split('\\n')\n const linesLength = lines.length\n const root = node || $getRoot()\n root.clear()\n\n for (let i = 0; i < linesLength; i++) {\n const lineText = lines[i]!\n\n const [imported, shiftedIndex] = $importMultiline(lines, i, byType.multilineElement, root)\n\n if (imported) {\n // If a multiline markdown element was imported, we don't want to process the lines that were part of it anymore.\n // There could be other sub-markdown elements (both multiline and normal ones) matching within this matched multiline element's children.\n // However, it would be the responsibility of the matched multiline transformer to decide how it wants to handle them.\n // We cannot handle those, as there is no way for us to know how to maintain the correct order of generated lexical nodes for possible children.\n i = shiftedIndex // Next loop will start from the line after the last line of the multiline element\n continue\n }\n\n $importBlocks(lineText, root, byType.element, textFormatTransformersIndex, byType.textMatch)\n }\n\n // By default, removing empty paragraphs as md does not really\n // allow empty lines and uses them as delimiter.\n // If you need empty lines set shouldPreserveNewLines = true.\n const children = root.getChildren()\n for (const child of children) {\n if (!shouldPreserveNewLines && isEmptyParagraph(child) && root.getChildrenSize() > 1) {\n child.remove()\n }\n }\n\n if ($getSelection() !== null) {\n root.selectStart()\n }\n }\n}\n\n/**\n *\n * @returns first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed.\n */\nfunction $importMultiline(\n lines: Array<string>,\n startLineIndex: number,\n multilineElementTransformers: Array<MultilineElementTransformer>,\n rootNode: ElementNode,\n): [boolean, number] {\n for (const transformer of multilineElementTransformers) {\n const { handleImportAfterStartMatch, regExpEnd, regExpStart, replace } = transformer\n\n const startMatch = lines[startLineIndex]?.match(regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n if (handleImportAfterStartMatch) {\n const result = handleImportAfterStartMatch({\n lines,\n rootNode,\n startLineIndex,\n startMatch,\n transformer,\n })\n if (result === null) {\n continue\n } else if (result) {\n return result\n }\n }\n\n const regexpEndRegex: RegExp | undefined =\n typeof regExpEnd === 'object' && 'regExp' in regExpEnd ? regExpEnd.regExp : regExpEnd\n\n const isEndOptional =\n regExpEnd && typeof regExpEnd === 'object' && 'optional' in regExpEnd\n ? regExpEnd.optional\n : !regExpEnd\n\n let endLineIndex = startLineIndex\n const linesLength = lines.length\n\n // check every single line for the closing match. It could also be on the same line as the opening match.\n while (endLineIndex < linesLength) {\n const endMatch = regexpEndRegex ? lines[endLineIndex]?.match(regexpEndRegex) : null\n if (!endMatch) {\n if (\n !isEndOptional ||\n (isEndOptional && endLineIndex < linesLength - 1) // Optional end, but didn't reach the end of the document yet => continue searching for potential closing match\n ) {\n endLineIndex++\n continue // Search next line for closing match\n }\n }\n\n // Now, check if the closing match matched is the same as the opening match.\n // If it is, we need to continue searching for the actual closing match.\n if (endMatch && startLineIndex === endLineIndex && endMatch.index === startMatch.index) {\n endLineIndex++\n continue // Search next line for closing match\n }\n\n // At this point, we have found the closing match. Next: calculate the lines in between open and closing match\n // This should not include the matches themselves, and be split up by lines\n const linesInBetween: string[] = []\n\n if (endMatch && startLineIndex === endLineIndex) {\n linesInBetween.push(lines[startLineIndex]!.slice(startMatch[0].length, -endMatch[0].length))\n } else {\n for (let i = startLineIndex; i <= endLineIndex; i++) {\n const line = lines[i]!\n if (i === startLineIndex) {\n const text = line.slice(startMatch[0].length)\n linesInBetween.push(text) // Also include empty text\n } else if (i === endLineIndex && endMatch) {\n const text = line.slice(0, -endMatch[0].length)\n linesInBetween.push(text) // Also include empty text\n } else {\n linesInBetween.push(line)\n }\n }\n }\n\n if (replace(rootNode, null, startMatch, endMatch!, linesInBetween, true) !== false) {\n // Return here. This $importMultiline function is run line by line and should only process a single multiline element at a time.\n return [true, endLineIndex]\n }\n\n // The replace function returned false, despite finding the matching open and close tags => this transformer does not want to handle it.\n // Thus, we continue letting the remaining transformers handle the passed lines of text from the beginning\n break\n }\n }\n\n // No multiline transformer handled this line successfully\n return [false, startLineIndex]\n}\n\nfunction $importBlocks(\n lineText: string,\n rootNode: ElementNode,\n elementTransformers: Array<ElementTransformer>,\n textFormatTransformersIndex: TextFormatTransformersIndex,\n textMatchTransformers: Array<TextMatchTransformer>,\n) {\n const textNode = $createTextNode(lineText)\n const elementNode = $createParagraphNode()\n elementNode.append(textNode)\n rootNode.append(elementNode)\n\n for (const { regExp, replace } of elementTransformers) {\n const match = lineText.match(regExp)\n\n if (match) {\n textNode.setTextContent(lineText.slice(match[0].length))\n if (replace(elementNode, [textNode], match, true) !== false) {\n break\n }\n }\n }\n\n importTextTransformers(textNode, textFormatTransformersIndex, textMatchTransformers)\n\n // If no transformer found and we left with original paragraph node\n // can check if its content can be appended to the previous node\n // if it's a paragraph, quote or list\n if (elementNode.isAttached() && lineText.length > 0) {\n const previousNode = elementNode.getPreviousSibling()\n if ($isParagraphNode(previousNode) || $isQuoteNode(previousNode) || $isListNode(previousNode)) {\n let targetNode: ListItemNode | null | typeof previousNode = previousNode\n\n if ($isListNode(previousNode)) {\n const lastDescendant = previousNode.getLastDescendant()\n if (lastDescendant == null) {\n targetNode = null\n } else {\n targetNode = $findMatchingParent(lastDescendant, $isListItemNode)\n }\n }\n\n if (targetNode != null && targetNode.getTextContentSize() > 0) {\n targetNode.splice(targetNode.getChildrenSize(), 0, [\n $createLineBreakNode(),\n ...elementNode.getChildren(),\n ])\n elementNode.remove()\n }\n }\n }\n}\n\nfunction createTextFormatTransformersIndex(\n textTransformers: Array<TextFormatTransformer>,\n): TextFormatTransformersIndex {\n const transformersByTag: Record<string, TextFormatTransformer> = {}\n const fullMatchRegExpByTag: Record<string, RegExp> = {}\n const openTagsRegExp: string[] = []\n const escapeRegExp = `(?<![\\\\\\\\])`\n\n for (const transformer of textTransformers) {\n const { tag } = transformer\n transformersByTag[tag] = transformer\n const tagRegExp = tag.replace(/([*^+])/g, '\\\\$1')\n openTagsRegExp.push(tagRegExp)\n\n // Single-char tag (e.g. \"*\"),\n if (tag.length === 1) {\n fullMatchRegExpByTag[tag] = new RegExp(\n `(?<![\\\\\\\\${tagRegExp}])(${tagRegExp})((\\\\\\\\${tagRegExp})?.*?[^${tagRegExp}\\\\s](\\\\\\\\${tagRegExp})?)((?<!\\\\\\\\)|(?<=\\\\\\\\\\\\\\\\))(${tagRegExp})(?![\\\\\\\\${tagRegExp}])`,\n )\n } else {\n // Multi‐char tags (e.g. \"**\")\n fullMatchRegExpByTag[tag] = new RegExp(\n `(?<!\\\\\\\\)(${tagRegExp})((\\\\\\\\${tagRegExp})?.*?[^\\\\s](\\\\\\\\${tagRegExp})?)((?<!\\\\\\\\)|(?<=\\\\\\\\\\\\\\\\))(${tagRegExp})(?!\\\\\\\\)`,\n )\n }\n }\n\n return {\n // Reg exp to find open tag + content + close tag\n fullMatchRegExpByTag,\n\n // Regexp to locate *any* potential opening tag (longest first).\n // eslint-disable-next-line regexp/no-useless-character-class, regexp/no-empty-capturing-group, regexp/no-empty-group\n openTagsRegExp: new RegExp(`${escapeRegExp}(${openTagsRegExp.join('|')})`, 'g'),\n transformersByTag,\n }\n}\n"],"mappings":"AAAA;;;;;;GAWA,SAASA,eAAe,EAAEC,WAAW,QAAQ;AAC7C,SAASC,YAAY,QAAQ;AAC7B,SAASC,mBAAmB,QAAQ;AACpC,SACEC,oBAAoB,EACpBC,oBAAoB,EACpBC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,QACX;AAUP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAQrD;;;AAGA,OAAO,SAASC,qBACdC,YAAgC,EAChCC,sBAAA,GAAyB,KAAK;EAE9B,MAAMC,MAAA,GAASJ,kBAAA,CAAmBE,YAAA;EAClC,MAAMG,2BAAA,GAA8BC,iCAAA,CAAkCF,MAAA,CAA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D,MAAMC,cAAA,GAA2B,EAAE;EACnC,MAAMC,YAAA,GAAe,aAAa;EAElC,KAAK,MAAMtC,WAAA,IAAekC,gBAAA,EAAkB;IAC1C,MAAM;MAAEK;IAAG,CAAE,GAAGvC,WAAA;IAChBmC,iBAAiB,CAACI,GAAA,CAAI,GAAGvC,WAAA;IACzB,MAAMwC,SAAA,GAAYD,GAAA,CAAInC,OAAO,CAAC,YAAY;IAC1CiC,cAAA,CAAerB,IAAI,CAACwB,SAAA;IAEpB;IACA,IAAID,GAAA,CAAI5D,MAAM,KAAK,GAAG;MACpByD,oBAAoB,CAACG,GAAA,CAAI,GAAG,IAAIE,MAAA,CAC9B,YAAYD,SAAA,MAAeA,SAAA,UAAmBA,SAAA,UAAmBA,SAAA,YAAqBA,SAAA,gCAAyCA,SAAA,YAAqBA,SAAA,IAAa;IAErK,OAAO;MACL;MACAJ,oBAAoB,CAACG,GAAA,CAAI,GAAG,IAAIE,MAAA,CAC9B,aAAaD,SAAA,UAAmBA,SAAA,mBAA4BA,SAAA,gCAAyCA,SAAA,WAAoB;IAE7H;EACF;EAEA,OAAO;IACL;IACAJ,oBAAA;IAEA;IACA;IACAC,cAAA,EAAgB,IAAII,MAAA,CAAO,GAAGH,YAAA,IAAgBD,cAAA,CAAeK,IAAI,CAAC,OAAO,EAAE;IAC3EP;EACF;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"MarkdownImport.js","names":["$isListItemNode","$isListNode","$isQuoteNode","$findMatchingParent","$createLineBreakNode","$createParagraphNode","$createTextNode","$getRoot","$getSelection","$isParagraphNode","importTextTransformers","isEmptyParagraph","transformersByType","createMarkdownImport","transformers","shouldPreserveNewLines","byType","textFormatTransformersIndex","createTextFormatTransformersIndex","textFormat","markdownString","node","lines","split","linesLength","length","root","clear","i","lineText","imported","shiftedIndex","$importMultiline","multilineElement","$importBlocks","element","textMatch","children","getChildren","child","getChildrenSize","remove","selectStart","startLineIndex","multilineElementTransformers","rootNode","transformer","handleImportAfterStartMatch","regExpEnd","regExpStart","replace","startMatch","match","result","regexpEndRegex","regExp","isEndOptional","optional","endLineIndex","endMatch","index","linesInBetween","push","slice","line","text","elementTransformers","textMatchTransformers","textNode","elementNode","append","setTextContent","isAttached","previousNode","getPreviousSibling","targetNode","lastDescendant","getLastDescendant","getTextContentSize","splice","textTransformers","transformersByTag","fullMatchRegExpByTag","openTagsRegExp","escapeRegExp","tag","tagRegExp","RegExp","join"],"sources":["../../../../src/packages/@lexical/markdown/MarkdownImport.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { ListItemNode } from '@lexical/list'\nimport type { ElementNode } from 'lexical'\n\nimport { $isListItemNode, $isListNode } from '@lexical/list'\nimport { $isQuoteNode } from '@lexical/rich-text'\nimport { $findMatchingParent } from '@lexical/utils'\nimport {\n $createLineBreakNode,\n $createParagraphNode,\n $createTextNode,\n $getRoot,\n $getSelection,\n $isParagraphNode,\n} from 'lexical'\n\nimport type {\n ElementTransformer,\n MultilineElementTransformer,\n TextFormatTransformer,\n TextMatchTransformer,\n Transformer,\n} from './MarkdownTransformers.js'\n\nimport { importTextTransformers } from './importTextTransformers.js'\nimport { isEmptyParagraph, transformersByType } from './utils.js'\n\nexport type TextFormatTransformersIndex = Readonly<{\n fullMatchRegExpByTag: Readonly<Record<string, RegExp>>\n openTagsRegExp: RegExp\n transformersByTag: Readonly<Record<string, TextFormatTransformer>>\n}>\n\n/**\n * Renders markdown from a string. The selection is moved to the start after the operation.\n */\nexport function createMarkdownImport(\n transformers: Array<Transformer>,\n shouldPreserveNewLines = false,\n): (markdownString: string, node?: ElementNode) => void {\n const byType = transformersByType(transformers)\n const textFormatTransformersIndex = createTextFormatTransformersIndex(byType.textFormat)\n\n return (markdownString, node) => {\n const lines = markdownString.split('\\n')\n const linesLength = lines.length\n const root = node || $getRoot()\n root.clear()\n\n for (let i = 0; i < linesLength; i++) {\n const lineText = lines[i]!\n\n const [imported, shiftedIndex] = $importMultiline(lines, i, byType.multilineElement, root)\n\n if (imported) {\n // If a multiline markdown element was imported, we don't want to process the lines that were part of it anymore.\n // There could be other sub-markdown elements (both multiline and normal ones) matching within this matched multiline element's children.\n // However, it would be the responsibility of the matched multiline transformer to decide how it wants to handle them.\n // We cannot handle those, as there is no way for us to know how to maintain the correct order of generated lexical nodes for possible children.\n i = shiftedIndex // Next loop will start from the line after the last line of the multiline element\n continue\n }\n\n $importBlocks(lineText, root, byType.element, textFormatTransformersIndex, byType.textMatch)\n }\n\n // By default, removing empty paragraphs as md does not really\n // allow empty lines and uses them as delimiter.\n // If you need empty lines set shouldPreserveNewLines = true.\n const children = root.getChildren()\n for (const child of children) {\n if (!shouldPreserveNewLines && isEmptyParagraph(child) && root.getChildrenSize() > 1) {\n child.remove()\n }\n }\n\n if ($getSelection() !== null) {\n root.selectStart()\n }\n }\n}\n\n/**\n *\n * @returns first element of the returned tuple is a boolean indicating if a multiline element was imported. The second element is the index of the last line that was processed.\n */\nfunction $importMultiline(\n lines: Array<string>,\n startLineIndex: number,\n multilineElementTransformers: Array<MultilineElementTransformer>,\n rootNode: ElementNode,\n): [boolean, number] {\n for (const transformer of multilineElementTransformers) {\n const { handleImportAfterStartMatch, regExpEnd, regExpStart, replace } = transformer\n\n const startMatch = lines[startLineIndex]?.match(regExpStart)\n if (!startMatch) {\n continue // Try next transformer\n }\n\n if (handleImportAfterStartMatch) {\n const result = handleImportAfterStartMatch({\n lines,\n rootNode,\n startLineIndex,\n startMatch,\n transformer,\n })\n if (result === null) {\n continue\n } else if (result) {\n return result\n }\n }\n\n const regexpEndRegex: RegExp | undefined =\n typeof regExpEnd === 'object' && 'regExp' in regExpEnd ? regExpEnd.regExp : regExpEnd\n\n const isEndOptional =\n regExpEnd && typeof regExpEnd === 'object' && 'optional' in regExpEnd\n ? regExpEnd.optional\n : !regExpEnd\n\n let endLineIndex = startLineIndex\n const linesLength = lines.length\n\n // check every single line for the closing match. It could also be on the same line as the opening match.\n while (endLineIndex < linesLength) {\n const endMatch = regexpEndRegex ? lines[endLineIndex]?.match(regexpEndRegex) : null\n if (!endMatch) {\n if (\n !isEndOptional ||\n (isEndOptional && endLineIndex < linesLength - 1) // Optional end, but didn't reach the end of the document yet => continue searching for potential closing match\n ) {\n endLineIndex++\n continue // Search next line for closing match\n }\n }\n\n // Now, check if the closing match matched is the same as the opening match.\n // If it is, we need to continue searching for the actual closing match.\n if (endMatch && startLineIndex === endLineIndex && endMatch.index === startMatch.index) {\n endLineIndex++\n continue // Search next line for closing match\n }\n\n // At this point, we have found the closing match. Next: calculate the lines in between open and closing match\n // This should not include the matches themselves, and be split up by lines\n const linesInBetween: string[] = []\n\n if (endMatch && startLineIndex === endLineIndex) {\n linesInBetween.push(lines[startLineIndex]!.slice(startMatch[0].length, -endMatch[0].length))\n } else {\n for (let i = startLineIndex; i <= endLineIndex; i++) {\n const line = lines[i]!\n if (i === startLineIndex) {\n const text = line.slice(startMatch[0].length)\n linesInBetween.push(text) // Also include empty text\n } else if (i === endLineIndex && endMatch) {\n const text = line.slice(0, -endMatch[0].length)\n linesInBetween.push(text) // Also include empty text\n } else {\n linesInBetween.push(line)\n }\n }\n }\n\n if (replace(rootNode, null, startMatch, endMatch!, linesInBetween, true) !== false) {\n // Return here. This $importMultiline function is run line by line and should only process a single multiline element at a time.\n return [true, endLineIndex]\n }\n\n // The replace function returned false, despite finding the matching open and close tags => this transformer does not want to handle it.\n // Thus, we continue letting the remaining transformers handle the passed lines of text from the beginning\n break\n }\n }\n\n // No multiline transformer handled this line successfully\n return [false, startLineIndex]\n}\n\nfunction $importBlocks(\n lineText: string,\n rootNode: ElementNode,\n elementTransformers: Array<ElementTransformer>,\n textFormatTransformersIndex: TextFormatTransformersIndex,\n textMatchTransformers: Array<TextMatchTransformer>,\n) {\n const textNode = $createTextNode(lineText)\n const elementNode = $createParagraphNode()\n elementNode.append(textNode)\n rootNode.append(elementNode)\n\n for (const { regExp, replace } of elementTransformers) {\n const match = lineText.match(regExp)\n\n if (match) {\n textNode.setTextContent(lineText.slice(match[0].length))\n if (replace(elementNode, [textNode], match, true) !== false) {\n break\n }\n }\n }\n\n importTextTransformers(textNode, textFormatTransformersIndex, textMatchTransformers)\n\n // If no transformer found and we left with original paragraph node\n // can check if its content can be appended to the previous node\n // if it's a paragraph, quote or list\n if (elementNode.isAttached() && lineText.length > 0) {\n const previousNode = elementNode.getPreviousSibling()\n if ($isParagraphNode(previousNode) || $isQuoteNode(previousNode) || $isListNode(previousNode)) {\n let targetNode: ListItemNode | null | typeof previousNode = previousNode\n\n if ($isListNode(previousNode)) {\n const lastDescendant = previousNode.getLastDescendant()\n if (lastDescendant == null) {\n targetNode = null\n } else {\n targetNode = $findMatchingParent(lastDescendant, $isListItemNode)\n }\n }\n\n if (targetNode != null && targetNode.getTextContentSize() > 0) {\n targetNode.splice(targetNode.getChildrenSize(), 0, [\n $createLineBreakNode(),\n ...elementNode.getChildren(),\n ])\n elementNode.remove()\n }\n }\n }\n}\n\nfunction createTextFormatTransformersIndex(\n textTransformers: Array<TextFormatTransformer>,\n): TextFormatTransformersIndex {\n const transformersByTag: Record<string, TextFormatTransformer> = {}\n const fullMatchRegExpByTag: Record<string, RegExp> = {}\n const openTagsRegExp: string[] = []\n const escapeRegExp = `(?<![\\\\\\\\])`\n\n for (const transformer of textTransformers) {\n const { tag } = transformer\n transformersByTag[tag] = transformer\n const tagRegExp = tag.replace(/([*^+])/g, '\\\\$1')\n openTagsRegExp.push(tagRegExp)\n\n // Single-char tag (e.g. \"*\"),\n if (tag.length === 1) {\n fullMatchRegExpByTag[tag] = new RegExp(\n `(?<![\\\\\\\\${tagRegExp}])(${tagRegExp})((\\\\\\\\${tagRegExp})?.*?[^${tagRegExp}\\\\s](\\\\\\\\${tagRegExp})?)((?<!\\\\\\\\)|(?<=\\\\\\\\\\\\\\\\))(${tagRegExp})(?![\\\\\\\\${tagRegExp}])`,\n )\n } else {\n // Multi‐char tags (e.g. \"**\")\n fullMatchRegExpByTag[tag] = new RegExp(\n `(?<!\\\\\\\\)(${tagRegExp})((\\\\\\\\${tagRegExp})?.*?[^\\\\s](\\\\\\\\${tagRegExp})?)((?<!\\\\\\\\)|(?<=\\\\\\\\\\\\\\\\))(${tagRegExp})(?!\\\\\\\\)`,\n )\n }\n }\n\n return {\n // Reg exp to find open tag + content + close tag\n fullMatchRegExpByTag,\n\n // Regexp to locate *any* potential opening tag (longest first).\n // eslint-disable-next-line regexp/no-useless-character-class, regexp/no-empty-capturing-group, regexp/no-empty-group\n openTagsRegExp: new RegExp(`${escapeRegExp}(${openTagsRegExp.join('|')})`, 'g'),\n transformersByTag,\n }\n}\n"],"mappings":"AAAA;;;;;;GAWA,SAASA,eAAe,EAAEC,WAAW,QAAQ;AAC7C,SAASC,YAAY,QAAQ;AAC7B,SAASC,mBAAmB,QAAQ;AACpC,SACEC,oBAAoB,EACpBC,oBAAoB,EACpBC,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,QACX;AAUP,SAASC,sBAAsB,QAAQ;AACvC,SAASC,gBAAgB,EAAEC,kBAAkB,QAAQ;AAQrD;;;AAGA,OAAO,SAASC,qBACdC,YAAgC,EAChCC,sBAAA,GAAyB,KAAK;EAE9B,MAAMC,MAAA,GAASJ,kBAAA,CAAmBE,YAAA;EAClC,MAAMG,2BAAA,GAA8BC,iCAAA,CAAkCF,MAAA,CAAOG,UAAU;EAEvF,OAAO,CAACC,cAAA,EAAgBC,IAAA;IACtB,MAAMC,KAAA,GAAQF,cAAA,CAAeG,KAAK,CAAC;IACnC,MAAMC,WAAA,GAAcF,KAAA,CAAMG,MAAM;IAChC,MAAMC,IAAA,GAAOL,IAAA,IAAQd,QAAA;IACrBmB,IAAA,CAAKC,KAAK;IAEV,KAAK,IAAIC,CAAA,GAAI,GAAGA,CAAA,GAAIJ,WAAA,EAAaI,CAAA,IAAK;MACpC,MAAMC,QAAA,GAAWP,KAAK,CAACM,CAAA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ByD,oBAAoB,CAACG,GAAA,CAAI,GAAG,IAAIE,MAAA,CAC9B,YAAYD,SAAA,MAAeA,SAAA,UAAmBA,SAAA,UAAmBA,SAAA,YAAqBA,SAAA,gCAAyCA,SAAA,YAAqBA,SAAA,IAAa;IAErK,OAAO;MACL;MACAJ,oBAAoB,CAACG,GAAA,CAAI,GAAG,IAAIE,MAAA,CAC9B,aAAaD,SAAA,UAAmBA,SAAA,mBAA4BA,SAAA,gCAAyCA,SAAA,WAAoB;IAE7H;EACF;EAEA,OAAO;IACL;IACAJ,oBAAA;IAEA;IACA;IACAC,cAAA,EAAgB,IAAII,MAAA,CAAO,GAAGH,YAAA,IAAgBD,cAAA,CAAeK,IAAI,CAAC,OAAO,EAAE;IAC3EP;EACF;AACF","ignoreList":[]}
|
|
@@ -122,9 +122,7 @@ export const DrawerContent = ({
|
|
|
122
122
|
fields: Array.isArray(fields) ? fields : [],
|
|
123
123
|
forceRender: true,
|
|
124
124
|
parentIndexPath: "",
|
|
125
|
-
parentPath: ""
|
|
126
|
-
,
|
|
127
|
-
|
|
125
|
+
parentPath: "",
|
|
128
126
|
parentSchemaPath: schemaFieldsPath,
|
|
129
127
|
permissions: true,
|
|
130
128
|
readOnly: !isEditable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DrawerContent.js","names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\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 readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? 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={!isE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AA;MAC9DsB,SAAA,EAAWC,aAAA;MACXzB,UAAA;MACA2B,qBAAA,EAAuBF,aAAA;MACvBN,SAAA,EAAW;MACXC,QAAA,EAAU,CAACjB,UAAA;MACXT,UAAA,EAAYiB,gBAAA;MACZW,MAAA,EAAQV,YAAA,CAAWU;IACrB;IAEA,IAAI,CAACR,OAAA,EAAO;MACV,OAAOW,aAAA;IACT;IAEA,OAAOX,OAAA;EACT,GACA,CACEJ,YAAA,EACAb,EAAA,EACAM,UAAA,EACAL,cAAA,EACAC,iBAAA,EACAG,oBAAA,EACAF,UAAA,EACAW,gBAAA,CACD;EAGH;EACA7B,SAAA,CAAU;IACR,OAAO;MACLJ,cAAA,CAAe0B,0BAAA,CAA2BsB,OAAO;IACnD;EACF,GAAG,EAAE;EAEL,IAAIpB,YAAA,KAAiB,OAAO;IAC1B,OAAO;EACT;EAEA,oBACEsB,KAAA,CAACzD,IAAA;IACC0D,YAAA,EAAc,CAACN,QAAA,CAAS;IACxBO,yBAAyB;IACzB7B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;IAC3CK,YAAA,EAAcA,YAAA;IACdiB,QAAA,EAAU,CAACA,QAAA,CAAS;IACpBU,QAAA,EAAUzC,kBAAA;IACVN,IAAA,EAAMA,IAAA;4BAENgD,IAAA,CAAC7D,YAAA;MACC4B,MAAA,EAAQ8B,KAAA,CAAMC,OAAO,CAAC/B,MAAA,IAAUA,MAAA,GAAS,EAAE;MAC3CkC,WAAW;MACXC,eAAA,EAAgB;MAChBC,UAAA,EAAW
|
|
1
|
+
{"version":3,"file":"DrawerContent.js","names":["useLexicalEditable","Form","FormSubmit","RenderFields","useDocumentForm","useDocumentInfo","useServerFunctions","useTranslation","abortAndIgnore","deepCopyObjectSimpleWithoutReactComponents","React","useCallback","useEffect","useRef","useState","v4","uuid","useEditorConfigContext","DrawerContent","data","featureKey","fieldMapOverride","handleDrawerSubmit","schemaFieldsPathOverride","schemaPath","schemaPathSuffix","t","id","collectionSlug","getDocPreferences","globalSlug","fields","parentDocumentFields","isEditable","onChangeAbortControllerRef","AbortController","initialState","setInitialState","fieldProps","featureClientSchemaMap","getFormState","schemaFieldsPath","controller","awaitInitialState","state","docPermissions","docPreferences","documentFormState","initialBlockData","operation","readOnly","renderAllFields","signal","onChange","formState","prevFormState","current","initialBlockFormState","_jsxs","beforeSubmit","disableValidationOnSubmit","Array","isArray","onSubmit","_jsx","forceRender","parentIndexPath","parentPath","parentSchemaPath","permissions"],"sources":["../../../src/utilities/fieldsDrawer/DrawerContent.tsx"],"sourcesContent":["'use client'\nimport type { FormState } from 'payload'\n\nimport { useLexicalEditable } from '@lexical/react/useLexicalEditable'\nimport {\n Form,\n FormSubmit,\n RenderFields,\n useDocumentForm,\n useDocumentInfo,\n useServerFunctions,\n useTranslation,\n} from '@payloadcms/ui'\nimport { abortAndIgnore } from '@payloadcms/ui/shared'\nimport { deepCopyObjectSimpleWithoutReactComponents } from 'payload/shared'\nimport React, { useCallback, useEffect, useRef, useState } from 'react'\nimport { v4 as uuid } from 'uuid'\n\nimport type { FieldsDrawerProps } from './Drawer.js'\n\nimport { useEditorConfigContext } from '../../lexical/config/client/EditorConfigProvider.js'\n\nexport const DrawerContent: React.FC<Omit<FieldsDrawerProps, 'drawerSlug' | 'drawerTitle'>> = ({\n data,\n featureKey,\n fieldMapOverride,\n handleDrawerSubmit,\n schemaFieldsPathOverride,\n schemaPath,\n schemaPathSuffix,\n}) => {\n const { t } = useTranslation()\n const { id, collectionSlug, getDocPreferences, globalSlug } = useDocumentInfo()\n const { fields: parentDocumentFields } = useDocumentForm()\n const isEditable = useLexicalEditable()\n\n const onChangeAbortControllerRef = useRef(new AbortController())\n\n const [initialState, setInitialState] = useState<false | FormState | undefined>(false)\n\n const {\n fieldProps: { featureClientSchemaMap },\n } = useEditorConfigContext()\n\n const { getFormState } = useServerFunctions()\n\n const schemaFieldsPath =\n schemaFieldsPathOverride ??\n `${schemaPath}.lexical_internal_feature.${featureKey}${schemaPathSuffix ? `.${schemaPathSuffix}` : ''}`\n\n const fields: any = fieldMapOverride ?? featureClientSchemaMap[featureKey]?.[schemaFieldsPath] // Field Schema\n\n useEffect(() => {\n const controller = new AbortController()\n\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n id,\n collectionSlug,\n data: data ?? {},\n docPermissions: {\n fields: true,\n },\n docPreferences: await getDocPreferences(),\n documentFormState: deepCopyObjectSimpleWithoutReactComponents(parentDocumentFields),\n globalSlug,\n initialBlockData: data,\n operation: 'update',\n readOnly: !isEditable,\n renderAllFields: true,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n setInitialState(state)\n }\n\n void awaitInitialState()\n\n return () => {\n abortAndIgnore(controller)\n }\n }, [\n schemaFieldsPath,\n id,\n data,\n getFormState,\n collectionSlug,\n isEditable,\n globalSlug,\n getDocPreferences,\n parentDocumentFields,\n ])\n\n const onChange = useCallback(\n async ({ formState: prevFormState }: { formState: FormState }) => {\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 readOnly: !isEditable,\n schemaPath: schemaFieldsPath,\n signal: controller.signal,\n })\n\n if (!state) {\n return prevFormState\n }\n\n return state\n },\n [\n getFormState,\n id,\n isEditable,\n collectionSlug,\n getDocPreferences,\n parentDocumentFields,\n globalSlug,\n schemaFieldsPath,\n ],\n )\n\n // cleanup effect\n useEffect(() => {\n return () => {\n abortAndIgnore(onChangeAbortControllerRef.current)\n }\n }, [])\n\n if (initialState === false) {\n return null\n }\n\n return (\n <Form\n beforeSubmit={[onChange]}\n disableValidationOnSubmit\n fields={Array.isArray(fields) ? fields : []}\n initialState={initialState}\n onChange={[onChange]}\n onSubmit={handleDrawerSubmit}\n uuid={uuid()}\n >\n <RenderFields\n fields={Array.isArray(fields) ? 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={!isEditable}\n />\n <FormSubmit>{t('fields:saveChanges')}</FormSubmit>\n </Form>\n )\n}\n"],"mappings":"AAAA;;;AAGA,SAASA,kBAAkB,QAAQ;AACnC,SACEC,IAAI,EACJC,UAAU,EACVC,YAAY,EACZC,eAAe,EACfC,eAAe,EACfC,kBAAkB,EAClBC,cAAc,QACT;AACP,SAASC,cAAc,QAAQ;AAC/B,SAASC,0CAA0C,QAAQ;AAC3D,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ;AAChE,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AAEvC,OAAO,MAAMC,aAAA,GAAiFA,CAAC;EAC7FC,IAAI;EACJC,UAAU;EACVC,gBAAgB;EAChBC,kBAAkB;EAClBC,wBAAwB;EACxBC,UAAU;EACVC;AAAgB,CACjB;EACC,MAAM;IAAEC;EAAC,CAAE,GAAGnB,cAAA;EACd,MAAM;IAAEoB,EAAE;IAAEC,cAAc;IAAEC,iBAAiB;IAAEC;EAAU,CAAE,GAAGzB,eAAA;EAC9D,MAAM;IAAE0B,MAAA,EAAQC;EAAoB,CAAE,GAAG5B,eAAA;EACzC,MAAM6B,UAAA,GAAajC,kBAAA;EAEnB,MAAMkC,0BAAA,GAA6BrB,MAAA,CAAO,IAAIsB,eAAA;EAE9C,MAAM,CAACC,YAAA,EAAcC,eAAA,CAAgB,GAAGvB,QAAA,CAAwC;EAEhF,MAAM;IACJwB,UAAA,EAAY;MAAEC;IAAsB;EAAE,CACvC,GAAGtB,sBAAA;EAEJ,MAAM;IAAEuB;EAAY,CAAE,GAAGlC,kBA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AA,EAAa;MACbnB,QAAA,EAAU,CAACjB;qBAEb+B,IAAA,CAAC9D,UAAA;gBAAYwB,CAAA,CAAE;;;AAGrB","ignoreList":[]}
|
|
@@ -59,8 +59,7 @@ export function useRunDeprioritized(t0) {
|
|
|
59
59
|
function interactionResponse() {
|
|
60
60
|
// Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src
|
|
61
61
|
return new Promise(resolve => {
|
|
62
|
-
setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.
|
|
63
|
-
;
|
|
62
|
+
setTimeout(resolve, 100); // Fallback for the case where the animation frame never fires.
|
|
64
63
|
requestAnimationFrame(() => {
|
|
65
64
|
setTimeout(resolve, 0);
|
|
66
65
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAAG,SAAA,SAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAAK,SAAe;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,QAAAC,OAAA,CAAAC,OAAA;MAEI,MAAAC,IAAA,GAAAA,CAAA;QACEH,EAAA;QACAE,OAAA;MAAA;MACF,IAEI,yBAAAE,MAAyB;QAAA,IAEvB,wBAAAA,MAAwB,IAAUN,aAAA,CAAAO,OAAA,KAAAR,SAA0B;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA;UAAAP;QAAA,CAAgB;MAAA;QAGvDY,mBAAA,GAAAC,IAAA,CAA2BN,IAAA;MAAA;IAAA;IAGtCR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,
|
|
1
|
+
{"version":3,"file":"useRunDeprioritized.js","names":["c","_c","useCallback","useRef","useRunDeprioritized","t0","$","timeout","undefined","idleHandleRef","t1","fn","Promise","resolve","exec","window","current","cancelIdleCallback","requestIdleCallback","interactionResponse","then","runDeprioritized","setTimeout","requestAnimationFrame"],"sources":["../../src/utilities/useRunDeprioritized.ts"],"sourcesContent":["'use client'\nimport { useCallback, useRef } from 'react'\n\n/**\n * Simple hook that lets you run any callback once the main thread is idle\n * (via `requestIdleCallback`) or when that API is missing (Safari) - after the\n * next animation frame (`interactionResponse`).\n *\n * This will help you to avoid blocking the main thread with heavy work.\n *\n * The latest invocation wins: if a new run is queued before the previous one\n * executes, the previous task is cancelled.\n *\n * Usage:\n * ```ts\n * const runDeprioritized = useRunDeprioritized();\n *\n * const onEditorChange = (state: EditorState) => {\n * runDeprioritized(() => {\n * // heavy work here …\n * });\n * };\n * ```\n *\n * @param timeout Optional timeout (ms) for `requestIdleCallback`; defaults to 500 ms.\n * @returns A `runDeprioritized(fn)` helper.\n */\n\nexport function useRunDeprioritized(timeout = 500) {\n const idleHandleRef = useRef<number>(undefined)\n\n /**\n * Schedule `fn` and resolve when it has executed.\n */\n const runDeprioritized = useCallback(\n (fn: () => void): Promise<void> => {\n return new Promise<void>((resolve) => {\n const exec = () => {\n fn()\n resolve()\n }\n\n if ('requestIdleCallback' in window) {\n // Cancel any previously queued task so only the latest runs.\n if ('cancelIdleCallback' in window && idleHandleRef.current !== undefined) {\n // Cancel earlier scheduled value updates,\n // so that a CPU-limited event loop isn't flooded with n callbacks for n keystrokes into the rich text field,\n // but that there's only ever the latest one state update\n // dispatch task, to be executed with the next idle time,\n // or the deadline of 500ms.\n cancelIdleCallback(idleHandleRef.current)\n }\n // Schedule the state update to happen the next time the browser has sufficient resources,\n // or the latest after 500ms.\n idleHandleRef.current = requestIdleCallback(exec, { timeout })\n } else {\n // Safari fallback: rAF + setTimeout shim.\n void interactionResponse().then(exec)\n }\n })\n },\n [timeout],\n )\n\n return runDeprioritized\n}\n\nfunction interactionResponse(): Promise<unknown> {\n // Taken from https://github.com/vercel-labs/await-interaction-response/tree/main/packages/await-interaction-response/src\n\n return new Promise((resolve) => {\n setTimeout(resolve, 100) // Fallback for the case where the animation frame never fires.\n requestAnimationFrame(() => {\n setTimeout(resolve, 0)\n })\n })\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;AACA,SAASC,WAAW,EAAEC,MAAM,QAAQ;AAEpC;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,OAAO,SAAAC,oBAAAC,EAAA;EAAA,MAAAC,CAAA,GAAAL,EAAA;EAA6B,MAAAM,OAAA,GAAAF,EAAa,KAAAG,SAAA,SAAbH,EAAa;EAC/C,MAAAI,aAAA,GAAsBN,MAAA,CAAAK,SAAe;EAAA,IAAAE,EAAA;EAAA,IAAAJ,CAAA,QAAAC,OAAA;IAMnCG,EAAA,GAAAC,EAAA,QAAAC,OAAA,CAAAC,OAAA;MAEI,MAAAC,IAAA,GAAAA,CAAA;QACEH,EAAA;QACAE,OAAA;MAAA;MACF,IAEI,yBAAAE,MAAyB;QAAA,IAEvB,wBAAAA,MAAwB,IAAUN,aAAA,CAAAO,OAAA,KAAAR,SAA0B;UAM9DS,kBAAA,CAAmBR,aAAA,CAAAO,OAAqB;QAAA;QAI1CP,aAAA,CAAAO,OAAA,GAAwBE,mBAAA,CAAoBJ,IAAA;UAAAP;QAAA,CAAgB;MAAA;QAGvDY,mBAAA,GAAAC,IAAA,CAA2BN,IAAA;MAAA;IAAA;IAGtCR,CAAA,MAAAC,OAAA;IAAAD,CAAA,MAAAI,EAAA;EAAA;IAAAA,EAAA,GAAAJ,CAAA;EAAA;EA1BF,MAAAe,gBAAA,GAAyBX,EA2Bd;EAAA,OAGJW,gBAAA;AAAA;AAGT,SAASF,oBAAA;EACP;EAEA,OAAO,IAAIP,OAAA,CAASC,OAAA;IAClBS,UAAA,CAAWT,OAAA,EAAS,MAAK;IACzBU,qBAAA,CAAsB;MACpBD,UAAA,CAAWT,OAAA,EAAS;IACtB;EACF;AACF","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.68.0-canary.0",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -374,8 +374,8 @@
|
|
|
374
374
|
"react-error-boundary": "4.1.2",
|
|
375
375
|
"ts-essentials": "10.0.3",
|
|
376
376
|
"uuid": "10.0.0",
|
|
377
|
-
"@payloadcms/
|
|
378
|
-
"@payloadcms/
|
|
377
|
+
"@payloadcms/translations": "3.68.0-canary.0",
|
|
378
|
+
"@payloadcms/ui": "3.68.0-canary.0"
|
|
379
379
|
},
|
|
380
380
|
"devDependencies": {
|
|
381
381
|
"@babel/cli": "7.27.2",
|
|
@@ -393,17 +393,17 @@
|
|
|
393
393
|
"babel-plugin-transform-remove-imports": "^1.8.0",
|
|
394
394
|
"esbuild": "0.25.5",
|
|
395
395
|
"esbuild-sass-plugin": "3.3.1",
|
|
396
|
-
"swc-plugin-transform-remove-imports": "
|
|
396
|
+
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
397
397
|
"@payloadcms/eslint-config": "3.28.0",
|
|
398
|
-
"payload": "3.
|
|
398
|
+
"payload": "3.68.0-canary.0"
|
|
399
399
|
},
|
|
400
400
|
"peerDependencies": {
|
|
401
401
|
"@faceless-ui/modal": "3.0.0",
|
|
402
402
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
403
403
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
404
404
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
405
|
-
"@payloadcms/next": "3.
|
|
406
|
-
"payload": "3.
|
|
405
|
+
"@payloadcms/next": "3.68.0-canary.0",
|
|
406
|
+
"payload": "3.68.0-canary.0"
|
|
407
407
|
},
|
|
408
408
|
"engines": {
|
|
409
409
|
"node": "^18.20.2 || >=20.9.0"
|
|
@@ -416,10 +416,12 @@
|
|
|
416
416
|
"build:babel": "rm -rf dist_optimized && babel dist --out-dir dist_optimized --source-maps --extensions .ts,.js,.tsx,.jsx,.cjs,.mjs && rm -rf dist && mv dist_optimized dist",
|
|
417
417
|
"build:bundle-for-analysis": "rm -rf dist esbuild && rm -rf tsconfig.tsbuildinfo && pnpm build:swc && pnpm build:babel && pnpm copyfiles && pnpm build:esbuild esbuild --no-split",
|
|
418
418
|
"build:clean": "find . \\( -type d \\( -name build -o -name dist -o -name .cache \\) -o -type f -name tsconfig.tsbuildinfo \\) -exec rm -rf {} + && pnpm build",
|
|
419
|
+
"build:debug": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:swc:debug && pnpm copyfiles && pnpm build:types",
|
|
419
420
|
"build:esbuild": "node bundle.js",
|
|
420
421
|
"build:esbuild:postprocess": "rm -rf dist/exports/client && mv dist/exports/client_optimized dist/exports/client",
|
|
421
422
|
"build:reactcompiler": "rm -rf dist && rm -rf tsconfig.tsbuildinfo && pnpm build:swc && pnpm build:babel && pnpm copyfiles && pnpm build:esbuild && pnpm build:esbuild:postprocess && pnpm build:types",
|
|
422
423
|
"build:swc": "swc ./src -d ./dist --config-file .swcrc --strip-leading-paths",
|
|
424
|
+
"build:swc:debug": "swc ./src -d ./dist --config-file .swcrc-debug --strip-leading-paths",
|
|
423
425
|
"build:types": "tsc --emitDeclarationOnly --outDir dist",
|
|
424
426
|
"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",
|
|
425
427
|
"clean": "rimraf -g {dist,*.tsbuildinfo,esbuild}",
|