@payloadcms/richtext-lexical 3.0.0-beta.108 → 3.0.0-beta.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/exports/client/bundled.css +1 -1
- package/dist/exports/client/{chunk-HIGLONP6.js → chunk-6LZZDOEO.js} +2 -2
- package/dist/exports/client/component-6Y2K2RNP.js +2 -0
- package/dist/exports/client/component-6Y2K2RNP.js.map +7 -0
- package/dist/exports/client/index.js +1 -1
- package/dist/features/blocks/client/component/index.d.ts.map +1 -1
- package/dist/features/blocks/client/component/index.js +0 -6
- package/dist/features/blocks/client/component/index.js.map +1 -1
- package/dist/field/bundled.css +1 -1
- package/package.json +6 -6
- package/dist/exports/client/component-P34B4EPY.js +0 -2
- package/dist/exports/client/component-P34B4EPY.js.map +0 -7
- /package/dist/exports/client/{chunk-HIGLONP6.js.map → chunk-6LZZDOEO.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as l}from"react/jsx-runtime";import u from"bson-objectid";import a from"react";import{DecoratorBlockNode as i}from"@lexical/react/LexicalDecoratorBlockNode.js";import c from"bson-objectid";import{deepCopyObjectSimple as f}from"payload/shared";var o=class extends i{__fields;constructor({fields:t,format:e,key:s}){super(e,s),this.__fields=t}static clone(t){return new this({fields:t.__fields,format:t.__format,key:t.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(t){t.version===1&&(t={...t,fields:{...t.fields.data},version:2});let e=p(t.fields);return e.setFormat(t.format),e}static isInline(){return!1}decorate(t,e){return null}exportDOM(){let t=document.createElement("div"),e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(t){let e=f(t),s=this.getWritable();s.__fields=e}};function p(r){return new o({fields:{...r,id:r?.id||new c.default().toHexString()}})}var m=a.lazy(()=>import("./component-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{jsx as l}from"react/jsx-runtime";import u from"bson-objectid";import a from"react";import{DecoratorBlockNode as i}from"@lexical/react/LexicalDecoratorBlockNode.js";import c from"bson-objectid";import{deepCopyObjectSimple as f}from"payload/shared";var o=class extends i{__fields;constructor({fields:t,format:e,key:s}){super(e,s),this.__fields=t}static clone(t){return new this({fields:t.__fields,format:t.__format,key:t.__key})}static getType(){return"block"}static importDOM(){return{}}static importJSON(t){t.version===1&&(t={...t,fields:{...t.fields.data},version:2});let e=p(t.fields);return e.setFormat(t.format),e}static isInline(){return!1}decorate(t,e){return null}exportDOM(){let t=document.createElement("div"),e=document.createTextNode(this.getTextContent());return t.append(e),{element:t}}exportJSON(){return{...super.exportJSON(),type:"block",fields:this.getFields(),version:2}}getFields(){return this.getLatest().__fields}getTextContent(){return"Block Field"}setFields(t){let e=f(t),s=this.getWritable();s.__fields=e}};function p(r){return new o({fields:{...r,id:r?.id||new c.default().toHexString()}})}var m=a.lazy(()=>import("./component-6Y2K2RNP.js").then(r=>({default:r.BlockComponent}))),n=class extends o{static clone(t){return super.clone(t)}static getType(){return super.getType()}static importJSON(t){t.version===1&&(t={...t,fields:{...t.fields.data},version:2});let e=d(t.fields);return e.setFormat(t.format),e}decorate(t,e){return l(m,{formData:this.getFields(),nodeKey:this.getKey()})}exportJSON(){return super.exportJSON()}};function d(r){return new n({fields:{...r,id:r?.id||new u.default().toHexString()}})}function v(r){return r instanceof n}export{n as a,d as b,v as c};
|
|
2
|
+
//# sourceMappingURL=chunk-6LZZDOEO.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use client";import{c as w}from"./chunk-6LZZDOEO.js";import{b as T}from"./chunk-GD6LBQBJ.js";import{jsx as f,jsxs as se}from"react/jsx-runtime";import{Collapsible as ie,Form as ne,Pill as ae,RenderComponent as re,SectionTitle as ce,ShimmerEffect as de,useConfig as me,useDocumentInfo as ue,useFieldProps as fe,useFormSubmitted as pe,useTranslation as be}from"@payloadcms/ui";import{useCallback as he,useEffect as ke,useMemo as ye,useState as _e}from"react";import{getTranslation as Ce}from"@payloadcms/translations";import{getFormState as K}from"@payloadcms/ui/shared";import{v4 as ve}from"uuid";import{jsx as y,jsxs as B}from"react/jsx-runtime";import{useLexicalComposerContext as H}from"@lexical/react/LexicalComposerContext.js";import{getTranslation as W}from"@payloadcms/translations";import{Button as z,Collapsible as G,ErrorPill as J,Pill as Q,RenderComponent as X,RenderFields as Y,SectionTitle as Z,useDocumentInfo as ee,useFormSubmitted as oe,useTranslation as te}from"@payloadcms/ui";import{dequal as le}from"dequal/lite";import{$getNodeByKey as U}from"lexical";import A,{useCallback as E}from"react";import{c as V}from"react/compiler-runtime";import{useAllFormFields as D}from"@payloadcms/ui";import{reduceFieldsToValues as M}from"payload/shared";import{useEffect as q}from"react";function j({fields:i}){for(let e in i){let o=i[e];Array.isArray(o.rows)&&"value"in o&&(o.disableFormData=!0)}return i}var O=i=>{let e=V(8),{onChange:o}=i,[l]=D(),d,s;e[0]!==l?(s=j({fields:l}),d=M(s,!0),e[0]=l,e[1]=d,e[2]=s):(d=e[1],s=e[2]);let m=d,t,a;return e[3]!==o||e[4]!==s||e[5]!==m?(t=()=>{o&&o({fullFieldsWithValues:s,newFormData:m})},a=[m,o,s],e[3]=o,e[4]=s,e[5]=m,e[6]=t,e[7]=a):(t=e[6],a=e[7]),q(t,a),null};function L(i){for(let e in i){let o=i[e];Array.isArray(o)&&!o?.length?delete i[e]:o&&typeof o=="object"?L(o):o==null&&delete i[e]}}var I=i=>{let{baseClass:e,clientBlock:o,field:l,formSchema:d,nodeKey:s,schemaPath:m}=i,{formData:t}=i,{i18n:a}=te(),[u]=H(),{getDocPreferences:x,setDocFieldPreferences:P}=ee(),[p,N]=A.useState(()=>{let r=!1;return x().then(c=>{let k=c?.fields[l.name]?.collapsed;k&&k.includes(t.id)&&(r=!0,N(!0))}),r}),F=oe(),[n,S]=A.useState(0),C=F&&n>0,$=[`${e}__row`,C?`${e}__row--has-errors`:`${e}__row--no-errors`].filter(Boolean).join(" "),R=E(({fullFieldsWithValues:r,newFormData:c})=>{if(c.id=t.id,c.blockType=t.blockType,L(c),L(t),le(t,c)||setTimeout(()=>{u.update(()=>{let h=U(s);h&&w(h)&&(t=c,h.setFields(c))})},0),F){let h=0;for(let k of Object.values(r))k?.valid===!1&&h++;S(h)}},[u,s,F,t]),v=E(r=>{x().then(c=>{let k=c?.fields[l.name]?.collapsed,g=k&&k?.length?k:[];r?g.includes(t.id)||g.push(t.id):g.includes(t.id)&&g.splice(g.indexOf(t.id),1),P(l.name,{collapsed:g,hello:"hi"})})},[x,l.name,P,t.id]),b=E(()=>{u.update(()=>{U(s)?.remove()})},[u,s]);return B(A.Fragment,{children:[y(G,{className:$,collapsibleStyle:C?"error":"default",header:o?.admin?.components?.Label?y(X,{clientProps:{blockKind:"lexicalBlock",formData:t},mappedComponent:o.admin.components.Label}):B("div",{className:`${e}__block-header`,children:[B("div",{children:[y(Q,{className:`${e}__block-pill ${e}__block-pill-${t?.blockType}`,pillStyle:"white",children:typeof o?.labels?.singular=="string"?W(o?.labels.singular,a):o.slug}),y(Z,{path:"blockName",readOnly:l?.admin?.readOnly||!1}),C&&y(J,{count:n,i18n:a,withMessage:!0})]}),u.isEditable()&&y(z,{buttonStyle:"icon-label",className:`${e}__removeButton`,disabled:l?.admin?.readOnly,icon:"x",onClick:r=>{r.preventDefault(),b()},round:!0,tooltip:"Remove Block"})]}),isCollapsed:p,onToggle:r=>{v(r),N(r)},children:y(Y,{className:`${e}__fields`,fields:d,forceRender:!0,margins:"small",path:"",readOnly:!1,schemaPath:m})},0),y(O,{onChange:R})]})};var _="lexical-block",Ge=i=>{let{formData:e,nodeKey:o}=i,{config:l}=me(),d=pe(),{id:s}=ue(),{path:m,schemaPath:t}=fe(),{field:a}=T(),[u,x]=_e(!1),{field:{richTextComponentMap:P}}=T(),p=`${t}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${e.blockType}`,n=(P?.get("lexical_internal_feature.blocks.fields.lexical_blocks")[0]).blocks.find(v=>v.slug===e.blockType);ke(()=>{e&&(async()=>{let{state:b}=await K({apiRoute:l.routes.api,body:{id:s,data:e,operation:"update",schemaPath:p},serverURL:l.serverURL});b&&(b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},x(b))})()},[l.routes.api,l.serverURL,p,s]);let S=he(async({formState:v})=>{let{state:b}=await K({apiRoute:l.routes.api,body:{id:s,formState:v,operation:"update",schemaPath:p},serverURL:l.serverURL});return b.blockName={initialValue:"",passesCondition:!0,valid:!0,value:e.blockName},b},[l.routes.api,l.serverURL,s,p,e.blockName]),{i18n:C}=be(),$=[`${_}__row`,`${_}__row--no-errors`].filter(Boolean).join(" "),R=ye(()=>n&&u!==!1?f(ne,{beforeSubmit:[S],fields:n.fields,initialState:u,onChange:[S],submitted:d,uuid:ve(),children:f(I,{baseClass:_,clientBlock:n,field:a,formData:e,formSchema:n.fields,nodeKey:o,path:`${m}.lexical_internal_feature.blocks.${e.blockType}`,schemaPath:p})}):f(ie,{className:$,collapsibleStyle:"default",header:n?.admin?.components?.Label?f(re,{clientProps:{blockKind:"lexicalBlock",formData:e},mappedComponent:n.admin.components.Label}):f("div",{className:`${_}__block-header`,children:se("div",{children:[f(ae,{className:`${_}__block-pill ${_}__block-pill-${e?.blockType}`,pillStyle:"white",children:n&&typeof n.labels?.singular=="string"?Ce(n.labels.singular,C):n?.slug}),f(ce,{path:"blockName",readOnly:a?.admin?.readOnly||!1})]})}),children:f(de,{height:"35vh"})},0),[n,u,S,d,a,o,m,p,$,C]);return f("div",{className:_+" "+_+"-"+e.blockType,children:R})};export{Ge as BlockComponent};
|
|
2
|
+
//# sourceMappingURL=component-6Y2K2RNP.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/features/blocks/client/component/index.tsx", "../../../src/features/blocks/client/component/BlockContent.tsx", "../../../src/features/blocks/client/component/FormSavePlugin.tsx", "../../../src/features/blocks/client/component/removeEmptyArrayValues.ts"],
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\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 { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlocksFieldClient = richTextComponentMap?.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n const { state: formState } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n", "'use client'\nimport type { ClientBlock, ClientField, CollapsedPreferences, FormState } from 'payload'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext.js'\nimport { getTranslation } from '@payloadcms/translations'\nimport {\n Button,\n Collapsible,\n ErrorPill,\n Pill,\n RenderComponent,\n RenderFields,\n SectionTitle,\n useDocumentInfo,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport { dequal } from 'dequal/lite'\nimport { $getNodeByKey } from 'lexical'\nimport React, { useCallback } from 'react'\n\nimport type { LexicalRichTextFieldProps } from '../../../../types.js'\nimport type { BlockFields } from '../../server/nodes/BlocksNode.js'\n\nimport { $isBlockNode } from '../nodes/BlocksNode.js'\nimport { FormSavePlugin } from './FormSavePlugin.js'\n\ntype Props = {\n baseClass: string\n clientBlock: ClientBlock\n field: LexicalRichTextFieldProps['field']\n formData: BlockFields\n formSchema: ClientField[]\n nodeKey: string\n path: string\n schemaPath: string\n}\n\n// Recursively remove all undefined values from even being present in formData, as they will\n// cause isDeepEqual to return false if, for example, formData has a key that fields.data\n// does not have, even if it's undefined.\n// Currently, this happens if a block has another sub-blocks field. Inside formData, that sub-blocks field has an undefined blockName property.\n// Inside of fields.data however, that sub-blocks blockName property does not exist at all.\nfunction removeUndefinedAndNullAndEmptyArraysRecursively(obj: object) {\n for (const key in obj) {\n const value = obj[key]\n if (Array.isArray(value) && !value?.length) {\n delete obj[key]\n } else if (value && typeof value === 'object') {\n removeUndefinedAndNullAndEmptyArraysRecursively(value)\n } else if (value === undefined || value === null) {\n delete obj[key]\n }\n }\n}\n\n/**\n * The actual content of the Block. This should be INSIDE a Form component,\n * scoped to the block. All format operations in here are thus scoped to the block's form, and\n * not the whole document.\n */\nexport const BlockContent: React.FC<Props> = (props) => {\n const { baseClass, clientBlock, field, formSchema, nodeKey, schemaPath } = props\n let { formData } = props\n\n const { i18n } = useTranslation()\n const [editor] = useLexicalComposerContext()\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\n const [isCollapsed, setIsCollapsed] = React.useState<boolean>(() => {\n let initialState = false\n\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.name]\n\n const collapsedArray = currentFieldPreferences?.collapsed\n\n if (collapsedArray && collapsedArray.includes(formData.id)) {\n initialState = true\n setIsCollapsed(true)\n }\n })\n return initialState\n })\n\n const hasSubmitted = useFormSubmitted()\n\n const [errorCount, setErrorCount] = React.useState(0)\n\n const fieldHasErrors = hasSubmitted && errorCount > 0\n\n const classNames = [\n `${baseClass}__row`,\n fieldHasErrors ? `${baseClass}__row--has-errors` : `${baseClass}__row--no-errors`,\n ]\n .filter(Boolean)\n .join(' ')\n\n const onFormChange = useCallback(\n ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: BlockFields\n }) => {\n newFormData.id = formData.id\n newFormData.blockType = formData.blockType\n\n removeUndefinedAndNullAndEmptyArraysRecursively(newFormData)\n removeUndefinedAndNullAndEmptyArraysRecursively(formData)\n\n // Only update if the data has actually changed. Otherwise, we may be triggering an unnecessary value change,\n // which would trigger the \"Leave without saving\" dialog unnecessarily\n if (!dequal(formData, newFormData)) {\n // Running this in the next tick in the meantime fixes this issue: https://github.com/payloadcms/payload/issues/4108\n // I don't know why. When this is called immediately, it might focus out of a nested lexical editor field if an update is made there.\n // My hypothesis is that the nested editor might not have fully finished its update cycle yet. By updating in the next tick, we\n // ensure that the nested editor has finished its update cycle before we update the block node.\n setTimeout(() => {\n editor.update(() => {\n const node = $getNodeByKey(nodeKey)\n if (node && $isBlockNode(node)) {\n formData = newFormData\n node.setFields(newFormData)\n }\n })\n }, 0)\n }\n\n // update error count\n if (hasSubmitted) {\n let rowErrorCount = 0\n for (const formField of Object.values(fullFieldsWithValues)) {\n if (formField?.valid === false) {\n rowErrorCount++\n }\n }\n setErrorCount(rowErrorCount)\n }\n },\n [editor, nodeKey, hasSubmitted, formData],\n )\n\n const onCollapsedChange = useCallback(\n (changedCollapsed: boolean) => {\n void getDocPreferences().then((currentDocPreferences) => {\n const currentFieldPreferences = currentDocPreferences?.fields[field.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(field.name, {\n collapsed: newCollapsed,\n hello: 'hi',\n })\n })\n },\n [getDocPreferences, field.name, setDocFieldPreferences, formData.id],\n )\n\n const removeBlock = useCallback(() => {\n editor.update(() => {\n $getNodeByKey(nodeKey)?.remove()\n })\n }, [editor, nodeKey])\n\n return (\n <React.Fragment>\n <Collapsible\n className={classNames}\n collapsibleStyle={fieldHasErrors ? 'error' : 'default'}\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {typeof clientBlock?.labels?.singular === 'string'\n ? getTranslation(clientBlock?.labels.singular, i18n)\n : clientBlock.slug}\n </Pill>\n <SectionTitle path=\"blockName\" readOnly={field?.admin?.readOnly || false} />\n {fieldHasErrors && <ErrorPill count={errorCount} i18n={i18n} withMessage />}\n </div>\n {editor.isEditable() && (\n <Button\n buttonStyle=\"icon-label\"\n className={`${baseClass}__removeButton`}\n disabled={field?.admin?.readOnly}\n icon=\"x\"\n onClick={(e) => {\n e.preventDefault()\n removeBlock()\n }}\n round\n tooltip=\"Remove Block\"\n />\n )}\n </div>\n )\n }\n isCollapsed={isCollapsed}\n key={0}\n onToggle={(incomingCollapsedState) => {\n onCollapsedChange(incomingCollapsedState)\n setIsCollapsed(incomingCollapsedState)\n }}\n >\n <RenderFields\n className={`${baseClass}__fields`}\n fields={formSchema}\n forceRender\n margins=\"small\"\n path=\"\" // Leaving path empty makes it so field values are not prefixed / scoped by the entire schemaPath. e.g. we can access \"myField\" instead of \"someLexicalField.feature.blocks.someArrayB\" // TODO: Could there be any implications leaving path different than schemaPath?\n readOnly={false}\n schemaPath={schemaPath} // Having the correct schemaPath here allows sub-fields (like array > addRow) to run correct form-state calls and retrieve their needed form state from the server\n />\n </Collapsible>\n\n <FormSavePlugin onChange={onFormChange} />\n </React.Fragment>\n )\n}\n", "'use client'\nimport type { Data, FormState } from 'payload'\nimport type React from 'react'\n\nimport { useAllFormFields } from '@payloadcms/ui'\nimport { reduceFieldsToValues } from 'payload/shared'\nimport { useEffect } from 'react'\n\nimport { removeEmptyArrayValues } from './removeEmptyArrayValues.js'\n\ntype Props = {\n onChange?: ({\n fullFieldsWithValues,\n newFormData,\n }: {\n fullFieldsWithValues: FormState\n newFormData: Data\n }) => void\n}\n\nexport const FormSavePlugin: React.FC<Props> = (props) => {\n const { onChange } = props\n\n const [_fields] = useAllFormFields()\n\n const fields = removeEmptyArrayValues({ fields: _fields })\n\n // Pass in fields, and indicate if you'd like to \"unflatten\" field data.\n // The result below will reflect the data stored in the form at the given time\n const newFormData = reduceFieldsToValues(fields, true)\n\n useEffect(() => {\n if (onChange) {\n onChange({ fullFieldsWithValues: fields, newFormData })\n }\n }, [newFormData, onChange, fields])\n\n return null\n}\n", "'use client'\nimport type { FormState } from 'payload'\n\n/**\n * By default, if an array field is empty, it will be included in the form state with a value of 0.\n * We do not need this behavior here, By setting `disableFormData` to true, we can prevent the field from being included in the form state\n * like that.\n * @param fields form state\n */\nexport function removeEmptyArrayValues({ fields }: { fields: FormState }): FormState {\n for (const key in fields) {\n const field = fields[key]\n if (Array.isArray(field.rows) && 'value' in field) {\n field.disableFormData = true\n }\n }\n return fields\n}\n"],
|
|
5
|
+
"mappings": "gJAEA,OACEA,eAAAA,GACAC,QAAAA,GACAC,QAAAA,GACAC,mBAAAA,GACAC,gBAAAA,GACAC,iBAAAA,GACAC,aAAAA,GACAC,mBAAAA,GACAC,iBAAAA,GACAC,oBAAAA,GACAC,kBAAAA,OACK,iBACP,OAAgBC,eAAAA,GAAaC,aAAAA,GAAWC,WAAAA,GAASC,YAAAA,OAAgB,QAKjE,OAASC,kBAAAA,OAAsB,2BAC/B,OAASC,gBAAAA,MAAoB,wBAC7B,OAASC,MAAMC,OAAY,yDCnB3B,OAASC,6BAAAA,MAAiC,2CAC1C,OAASC,kBAAAA,MAAsB,2BAC/B,OACEC,UAAAA,EACAC,eAAAA,EACAC,aAAAA,EACAC,QAAAA,EACAC,mBAAAA,EACAC,gBAAAA,EACAC,gBAAAA,EACAC,mBAAAA,GACAC,oBAAAA,GACAC,kBAAAA,OACK,iBACP,OAASC,UAAAA,OAAc,cACvB,OAASC,iBAAAA,MAAqB,UAC9B,OAAOC,GAASC,eAAAA,MAAmB,QCnBnC,OAAAC,KAAAC,MAAA,yBAIA,OAASC,oBAAAA,MAAwB,iBACjC,OAASC,wBAAAA,MAA4B,iBACrC,OAASC,aAAAA,MAAiB,QCGnB,SAASC,EAAuB,CAAEC,OAAAA,CAAM,EAAyB,CACtE,QAAWC,KAAOD,EAAQ,CACxB,IAAME,EAAQF,EAAOC,CAAA,EACjBE,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AAc,CAACd,CAAA,EACfe,OAAQpC,EAAYoC,OACpB1C,aAAcA,EACd2B,SAAU,CAACA,CAAA,EACXrC,UAAWA,EACXqD,KAAMA,GAAA,WAENJ,EAACK,EAAA,CACC7D,UAAWA,EACXuB,YAAaA,EACbT,MAAOC,EACPZ,SAAUA,EACV2D,WAAYvC,EAAYoC,OACxBvD,QAASA,EACTO,KAAM,GAAGA,CAAA,oCAAwCR,EAASmB,SAAS,GACnEV,WAAYS,MAIhBmC,EAACO,GAAA,CACCC,UAAWd,EACXe,iBAAiB,UACjBC,OACE3C,GAAa4C,OAAOC,YAAYC,MAC9Bb,EAACc,GAAA,CACCC,YAAa,CAAEC,UAAW,eAAgBrE,SAAAA,CAAS,EACnDsE,gBAAiBlD,EAAY4C,MAAMC,WAAWC,QAGhDb,EAAC,MAAA,CAAIQ,UAAW,GAAGhE,CAAA,0BACjB0E,GAAC,MAAA,WACClB,EAACmB,GAAA,CACCX,UAAW,GAAGhE,CAAA,gBAAyBA,CAAA,gBAAyBG,GAAUmB,SAAA,GAC1EsD,UAAU,iBAETrD,GAAe,OAAOA,EAAYsD,QAAQC,UAAa,SACpDC,GAAexD,EAAYsD,OAAOC,SAAU9B,CAAA,EAC5CzB,GAAaK,OAEnB4B,EAACwB,GAAA,CACCrE,KAAK,YACLsE,SAAUlE,GAA4BoD,OAAOc,UAAY,mBAQnEzB,EAAC0B,GAAA,CAAcC,OAAO,UAFjB,CAAA,EAKR,CACD5D,EACAN,EACA2B,EACArC,EACAQ,EACAX,EACAO,EACAU,EACA6B,EACAF,CAAA,CACD,EAED,OAAOQ,EAAC,MAAA,CAAIQ,UAAWhE,EAAY,IAAMA,EAAY,IAAMG,EAASmB,mBAAYgC,GAClF",
|
|
6
|
+
"names": ["Collapsible", "Form", "Pill", "RenderComponent", "SectionTitle", "ShimmerEffect", "useConfig", "useDocumentInfo", "useFieldProps", "useFormSubmitted", "useTranslation", "useCallback", "useEffect", "useMemo", "useState", "getTranslation", "getFormState", "v4", "uuid", "useLexicalComposerContext", "getTranslation", "Button", "Collapsible", "ErrorPill", "Pill", "RenderComponent", "RenderFields", "SectionTitle", "useDocumentInfo", "useFormSubmitted", "useTranslation", "dequal", "$getNodeByKey", "React", "useCallback", "c", "_c", "useAllFormFields", "reduceFieldsToValues", "useEffect", "removeEmptyArrayValues", "fields", "key", "field", "Array", "isArray", "rows", "disableFormData", "FormSavePlugin", "props", "$", "_c", "onChange", "_fields", "useAllFormFields", "t0", "fields", "removeEmptyArrayValues", "reduceFieldsToValues", "newFormData", "t1", "t2", "fullFieldsWithValues", "useEffect", "removeUndefinedAndNullAndEmptyArraysRecursively", "obj", "key", "value", "Array", "isArray", "length", "BlockContent", "props", "baseClass", "clientBlock", "field", "formSchema", "nodeKey", "schemaPath", "formData", "i18n", "useTranslation", "editor", "useLexicalComposerContext", "getDocPreferences", "setDocFieldPreferences", "useDocumentInfo", "isCollapsed", "setIsCollapsed", "React", "useState", "initialState", "then", "currentDocPreferences", "collapsedArray", "fields", "name", "collapsed", "includes", "id", "hasSubmitted", "useFormSubmitted", "errorCount", "setErrorCount", "fieldHasErrors", "classNames", "filter", "Boolean", "join", "onFormChange", "useCallback", "fullFieldsWithValues", "newFormData", "blockType", "dequal", "setTimeout", "update", "node", "$getNodeByKey", "$isBlockNode", "setFields", "rowErrorCount", "formField", "Object", "values", "valid", "onCollapsedChange", "changedCollapsed", "newCollapsed", "push", "splice", "indexOf", "hello", "removeBlock", "remove", "_jsxs", "Fragment", "_jsx", "Collapsible", "className", "collapsibleStyle", "header", "admin", "components", "Label", "RenderComponent", "clientProps", "blockKind", "mappedComponent", "Pill", "pillStyle", "labels", "singular", "getTranslation", "slug", "SectionTitle", "path", "readOnly", "ErrorPill", "count", "withMessage", "isEditable", "Button", "buttonStyle", "disabled", "icon", "onClick", "e", "preventDefault", "round", "tooltip", "onToggle", "incomingCollapsedState", "RenderFields", "forceRender", "margins", "FormSavePlugin", "onChange", "baseClass", "BlockComponent", "props", "formData", "nodeKey", "config", "useConfig", "submitted", "useFormSubmitted", "id", "useDocumentInfo", "path", "schemaPath", "useFieldProps", "field", "parentLexicalRichTextField", "useEditorConfigContext", "initialState", "setInitialState", "useState", "richTextComponentMap", "schemaFieldsPath", "blockType", "clientBlock", "get", "blocks", "find", "block", "slug", "useEffect", "state", "getFormState", "apiRoute", "routes", "api", "body", "data", "operation", "serverURL", "blockName", "initialValue", "passesCondition", "valid", "value", "onChange", "useCallback", "formState", "prevFormState", "i18n", "useTranslation", "classNames", "filter", "Boolean", "join", "formContent", "useMemo", "_jsx", "Form", "beforeSubmit", "fields", "uuid", "BlockContent", "formSchema", "Collapsible", "className", "collapsibleStyle", "header", "admin", "components", "Label", "RenderComponent", "clientProps", "blockKind", "mappedComponent", "_jsxs", "Pill", "pillStyle", "labels", "singular", "getTranslation", "SectionTitle", "readOnly", "ShimmerEffect", "height"]
|
|
7
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{a as Mt,b as ul,c as dl,d as ml,f as fl,h as pl}from"./chunk-IIWHHN4J.js";import{a as Ne,b as vt,c as cl}from"./chunk-HIGLONP6.js";import{a as ke,b as At,c as Le,d as Oo,e as Po,f as $o}from"./chunk-JYCJEIVA.js";import{a as Ie,b as Ye,c as Xe,d as Je}from"./chunk-YREZUOA6.js";import{a as Re,b as Se,c as ye,d as Ft}from"./chunk-N2PXHNGO.js";import{a as ae,b as qe,c as Me,d as ve,e as Ae,f as Dt}from"./chunk-76MVRKRT.js";import{a as al,b as H}from"./chunk-GD6LBQBJ.js";function G(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{jsx as jo}from"react/jsx-runtime";import{createHeadlessEditor as hl}from"@lexical/headless";import{useConfig as gl,useTableCell as Cl}from"@payloadcms/ui";import{formatAdminURL as xl}from"@payloadcms/ui/shared";import{$getRoot as bl}from"lexical";import Go from"next/link.js";import _l,{useEffect as Tl,useMemo as El}from"react";var Ho={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableSelected:"LexicalEditorTheme__tableSelected",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Fe={namespace:"lexical",theme:Ho};function Qe({unSanitizedEditorConfig:t}){for(let r of t.features)if(!r?.clientFeatureProps?.featureKey||r?.clientFeatureProps?.order===void 0||r?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");t.features=t.features.sort((r,i)=>r.clientFeatureProps.order-i.clientFeatureProps.order);let e=new Map;for(let r of t.features)e.set(r.clientFeatureProps.featureKey,r);let o=new Map,n=0;for(let r of t.features){let i=typeof r.feature=="function"?r.feature({featureProviderMap:e,resolvedFeatures:o,unSanitizedEditorConfig:t}):r.feature;i.key=r.clientFeatureProps.featureKey,i.order=n,o.set(r.clientFeatureProps.featureKey,i),n++}return o}var Bo=t=>{let e={enabledFeatures:[],hooks:{load:[],save:[]},markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.hooks&&(o.hooks?.load?.length&&(e.hooks.load=e.hooks.load.concat(o.hooks.load)),o.hooks?.save?.length&&(e.hooks.save=e.hooks.save.concat(o.hooks.save))),o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.nodes?.length&&(e.nodes=e.nodes.concat(o.nodes)),o.plugins?.length&&o.plugins.forEach((n,r)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:n.Component,key:o.key+r,position:n.position})}),o.toolbarInline?.groups?.length)for(let n of o.toolbarInline.groups){let r=e.toolbarInline.groups.find(i=>i.key===n.key);r?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarInline?.groups.push(r)}if(o.toolbarFixed?.groups?.length)for(let n of o.toolbarFixed.groups){let r=e.toolbarFixed.groups.find(i=>i.key===n.key);r?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarFixed?.groups.push(r)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let n of o.slashMenu.groups){let r=e.slashMenu.groups.find(i=>i.key===n.key);r?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.slashMenu.groups.push(r)}}o.markdownTransformers?.length&&(e.markdownTransformers=e.markdownTransformers.concat(o.markdownTransformers)),e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);return e};function De(t,e,o){return{admin:o,features:Bo(t),lexical:e,resolvedFeatureMap:t}}var wl=Go.default||Go,Nl=t=>{let{admin:e,field:{richTextComponentMap:o},lexicalEditorConfig:n}=t,[r,i]=_l.useState("Loading..."),{cellData:l,cellProps:s,columnIndex:a,customCellContext:c,rowData:u}=Cl(),{config:{routes:{admin:d}}}=gl(),{link:m}=s||{},f="span",p={},g=m!==void 0?m:a===0;g&&(f=wl,p.href=c?.collectionSlug?xl({adminRoute:d,path:`/collections/${c?.collectionSlug}/${u.id}`}):"");let b=El(()=>{let x=o?.get("features"),A=[];for(let E of x)A.push(E.clientFeature(E.clientFeatureProps));let v=n||Fe,T=Qe({unSanitizedEditorConfig:{features:A,lexical:v}});return De(T,v)},[o,n]);return b.admin=e,Tl(()=>{let x=l;if(x==null||!b){i("");return}if(b?.features?.hooks?.load?.length&&b.features.hooks.load.forEach(T=>{x=T({incomingEditorState:x})}),!x||typeof x!="object"){i("");return}if(Array.isArray(x)&&!("root"in x)){i("");return}if("jsonContent"in x){i("");return}let A=hl({namespace:b.lexical.namespace,nodes:Mt({editorConfig:b}),theme:b.lexical.theme});A.setEditorState(A.parseEditorState(x));let v=A.getEditorState().read(()=>bl().getTextContent())||"";i(v)},[l,b]),g?jo(f,{...p,children:r}):jo("span",{children:r})};import{$isElementNode as ie,$isRangeSelection as tt,FORMAT_ELEMENT_COMMAND as ot}from"lexical";import{jsx as Ot,jsxs as kl}from"react/jsx-runtime";import"react";var Uo=()=>kl("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ot("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ot("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ot("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Pt,jsxs as Ll}from"react/jsx-runtime";import"react";var Wo=()=>Ll("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Pt("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as $t,jsxs as Il}from"react/jsx-runtime";import"react";var et=()=>Il("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[$t("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),$t("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),$t("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Ht,jsxs as Rl}from"react/jsx-runtime";import"react";var Vo=()=>Rl("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ht("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var S=t=>o=>{let n={clientFeatureProps:o};if(typeof t=="function")n.feature=({featureProviderMap:r,resolvedFeatures:i,unSanitizedEditorConfig:l})=>{let s=t({featureProviderMap:r,props:o,resolvedFeatures:i,unSanitizedEditorConfig:l});return s.sanitizedClientFeatureProps===null&&(s.sanitizedClientFeatureProps=o),s};else{let r={...t};r.sanitizedClientFeatureProps=o,n.feature=r}return n};var Ko=t=>({type:"dropdown",ChildComponent:et,items:t,key:"align",order:30});var zo=[Ko([{ChildComponent:et,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"left")},order:1},{ChildComponent:Uo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"center")},order:2},{ChildComponent:Vo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"right")},order:3},{ChildComponent:Wo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"justify")},order:4}])],Sl=S({toolbarFixed:{groups:zo},toolbarInline:{groups:zo}});import{$createQuoteNode as er,$isQuoteNode as qo,QuoteNode as Al}from"@lexical/rich-text";import{$setBlocksType as tr}from"@lexical/selection";import{$getSelection as or,$isRangeSelection as Fl}from"lexical";import{jsx as Zo}from"react/jsx-runtime";import"react";var Bt=()=>Zo("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zo("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as Yo}from"react/jsx-runtime";import"react";var Oe=()=>Yo("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Yo("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var W=t=>({type:"dropdown",ChildComponent:Oe,items:t,key:"text",order:25});import{$createQuoteNode as yl,$isQuoteNode as Xo,QuoteNode as Ml}from"@lexical/rich-text";import{$createLineBreakNode as vl}from"lexical";var Jo={type:"element",dependencies:[Ml],export:(t,e)=>{if(!Xo(t))return null;let o=e(t).split(`
|
|
1
|
+
"use client";import{a as Mt,b as ul,c as dl,d as ml,f as fl,h as pl}from"./chunk-IIWHHN4J.js";import{a as Ne,b as vt,c as cl}from"./chunk-6LZZDOEO.js";import{a as ke,b as At,c as Le,d as Oo,e as Po,f as $o}from"./chunk-JYCJEIVA.js";import{a as Ie,b as Ye,c as Xe,d as Je}from"./chunk-YREZUOA6.js";import{a as Re,b as Se,c as ye,d as Ft}from"./chunk-N2PXHNGO.js";import{a as ae,b as qe,c as Me,d as ve,e as Ae,f as Dt}from"./chunk-76MVRKRT.js";import{a as al,b as H}from"./chunk-GD6LBQBJ.js";function G(t){return{items:t,key:"basic",label:({i18n:e})=>e.t("lexical:general:slashMenuBasicGroupLabel")}}import{jsx as jo}from"react/jsx-runtime";import{createHeadlessEditor as hl}from"@lexical/headless";import{useConfig as gl,useTableCell as Cl}from"@payloadcms/ui";import{formatAdminURL as xl}from"@payloadcms/ui/shared";import{$getRoot as bl}from"lexical";import Go from"next/link.js";import _l,{useEffect as Tl,useMemo as El}from"react";var Ho={block:"LexicalEditorTheme__block",blockCursor:"LexicalEditorTheme__blockCursor",characterLimit:"LexicalEditorTheme__characterLimit",code:"LexicalEditorTheme__code",codeHighlight:{atrule:"LexicalEditorTheme__tokenAttr",attr:"LexicalEditorTheme__tokenAttr",boolean:"LexicalEditorTheme__tokenProperty",builtin:"LexicalEditorTheme__tokenSelector",cdata:"LexicalEditorTheme__tokenComment",char:"LexicalEditorTheme__tokenSelector",class:"LexicalEditorTheme__tokenFunction","class-name":"LexicalEditorTheme__tokenFunction",comment:"LexicalEditorTheme__tokenComment",constant:"LexicalEditorTheme__tokenProperty",deleted:"LexicalEditorTheme__tokenProperty",doctype:"LexicalEditorTheme__tokenComment",entity:"LexicalEditorTheme__tokenOperator",function:"LexicalEditorTheme__tokenFunction",important:"LexicalEditorTheme__tokenVariable",inserted:"LexicalEditorTheme__tokenSelector",keyword:"LexicalEditorTheme__tokenAttr",namespace:"LexicalEditorTheme__tokenVariable",number:"LexicalEditorTheme__tokenProperty",operator:"LexicalEditorTheme__tokenOperator",prolog:"LexicalEditorTheme__tokenComment",property:"LexicalEditorTheme__tokenProperty",punctuation:"LexicalEditorTheme__tokenPunctuation",regex:"LexicalEditorTheme__tokenVariable",selector:"LexicalEditorTheme__tokenSelector",string:"LexicalEditorTheme__tokenSelector",symbol:"LexicalEditorTheme__tokenProperty",tag:"LexicalEditorTheme__tokenProperty",url:"LexicalEditorTheme__tokenOperator",variable:"LexicalEditorTheme__tokenVariable"},embedBlock:{base:"LexicalEditorTheme__embedBlock",focus:"LexicalEditorTheme__embedBlockFocus"},hashtag:"LexicalEditorTheme__hashtag",heading:{h1:"LexicalEditorTheme__h1",h2:"LexicalEditorTheme__h2",h3:"LexicalEditorTheme__h3",h4:"LexicalEditorTheme__h4",h5:"LexicalEditorTheme__h5",h6:"LexicalEditorTheme__h6"},hr:"LexicalEditorTheme__hr",indent:"LexicalEditorTheme__indent",inlineImage:"LexicalEditor__inline-image",link:"LexicalEditorTheme__link",list:{checklist:"LexicalEditorTheme__checklist",listitem:"LexicalEditorTheme__listItem",listitemChecked:"LexicalEditorTheme__listItemChecked",listitemUnchecked:"LexicalEditorTheme__listItemUnchecked",nested:{listitem:"LexicalEditorTheme__nestedListItem"},olDepth:["LexicalEditorTheme__ol1","LexicalEditorTheme__ol2","LexicalEditorTheme__ol3","LexicalEditorTheme__ol4","LexicalEditorTheme__ol5"],ul:"LexicalEditorTheme__ul"},ltr:"LexicalEditorTheme__ltr",mark:"LexicalEditorTheme__mark",markOverlap:"LexicalEditorTheme__markOverlap",paragraph:"LexicalEditorTheme__paragraph",quote:"LexicalEditorTheme__quote",relationship:"LexicalEditorTheme__relationship",rtl:"LexicalEditorTheme__rtl",table:"LexicalEditorTheme__table",tableAddColumns:"LexicalEditorTheme__tableAddColumns",tableAddRows:"LexicalEditorTheme__tableAddRows",tableCell:"LexicalEditorTheme__tableCell",tableCellActionButton:"LexicalEditorTheme__tableCellActionButton",tableCellActionButtonContainer:"LexicalEditorTheme__tableCellActionButtonContainer",tableCellEditing:"LexicalEditorTheme__tableCellEditing",tableCellHeader:"LexicalEditorTheme__tableCellHeader",tableCellPrimarySelected:"LexicalEditorTheme__tableCellPrimarySelected",tableCellResizer:"LexicalEditorTheme__tableCellResizer",tableCellSelected:"LexicalEditorTheme__tableCellSelected",tableCellSortedIndicator:"LexicalEditorTheme__tableCellSortedIndicator",tableResizeRuler:"LexicalEditorTheme__tableCellResizeRuler",tableSelected:"LexicalEditorTheme__tableSelected",text:{bold:"LexicalEditorTheme__textBold",code:"LexicalEditorTheme__textCode",italic:"LexicalEditorTheme__textItalic",strikethrough:"LexicalEditorTheme__textStrikethrough",subscript:"LexicalEditorTheme__textSubscript",superscript:"LexicalEditorTheme__textSuperscript",underline:"LexicalEditorTheme__textUnderline",underlineStrikethrough:"LexicalEditorTheme__textUnderlineStrikethrough"},upload:"editor-upload"};var Fe={namespace:"lexical",theme:Ho};function Qe({unSanitizedEditorConfig:t}){for(let r of t.features)if(!r?.clientFeatureProps?.featureKey||r?.clientFeatureProps?.order===void 0||r?.clientFeatureProps?.order===null)throw new Error("A Feature you have installed does not return the client props as clientFeatureProps. Please make sure to always return those props, even if they are null, as other important props like order and featureKey are later on injected.");t.features=t.features.sort((r,i)=>r.clientFeatureProps.order-i.clientFeatureProps.order);let e=new Map;for(let r of t.features)e.set(r.clientFeatureProps.featureKey,r);let o=new Map,n=0;for(let r of t.features){let i=typeof r.feature=="function"?r.feature({featureProviderMap:e,resolvedFeatures:o,unSanitizedEditorConfig:t}):r.feature;i.key=r.clientFeatureProps.featureKey,i.order=n,o.set(r.clientFeatureProps.featureKey,i),n++}return o}var Bo=t=>{let e={enabledFeatures:[],hooks:{load:[],save:[]},markdownTransformers:[],nodes:[],plugins:[],providers:[],slashMenu:{dynamicGroups:[],groups:[]},toolbarFixed:{groups:[]},toolbarInline:{groups:[]}};if(!t?.size)return e;t.forEach(o=>{if(o.hooks&&(o.hooks?.load?.length&&(e.hooks.load=e.hooks.load.concat(o.hooks.load)),o.hooks?.save?.length&&(e.hooks.save=e.hooks.save.concat(o.hooks.save))),o.providers?.length&&(e.providers=e.providers.concat(o.providers)),o.nodes?.length&&(e.nodes=e.nodes.concat(o.nodes)),o.plugins?.length&&o.plugins.forEach((n,r)=>{e.plugins?.push({clientProps:o.sanitizedClientFeatureProps,Component:n.Component,key:o.key+r,position:n.position})}),o.toolbarInline?.groups?.length)for(let n of o.toolbarInline.groups){let r=e.toolbarInline.groups.find(i=>i.key===n.key);r?e.toolbarInline.groups=e.toolbarInline.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarInline?.groups.push(r)}if(o.toolbarFixed?.groups?.length)for(let n of o.toolbarFixed.groups){let r=e.toolbarFixed.groups.find(i=>i.key===n.key);r?e.toolbarFixed.groups=e.toolbarFixed.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.toolbarFixed?.groups.push(r)}if(o.slashMenu?.groups){o.slashMenu.dynamicGroups?.length&&(e.slashMenu.dynamicGroups=e.slashMenu.dynamicGroups.concat(o.slashMenu.dynamicGroups));for(let n of o.slashMenu.groups){let r=e.slashMenu.groups.find(i=>i.key===n.key);r?e.slashMenu.groups=e.slashMenu.groups.filter(i=>i.key!==n.key):r={...n,items:[]},n?.items?.length&&(r.items=r.items.concat(n.items)),e.slashMenu.groups.push(r)}}o.markdownTransformers?.length&&(e.markdownTransformers=e.markdownTransformers.concat(o.markdownTransformers)),e.enabledFeatures.push(o.key)}),e.toolbarInline.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0),e.toolbarFixed.groups.sort((o,n)=>o.order&&n.order?o.order-n.order:o.order?-1:n.order?1:0);for(let o of e.toolbarInline.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);for(let o of e.toolbarFixed.groups)o.items.sort((n,r)=>n.order&&r.order?n.order-r.order:n.order?-1:r.order?1:0);return e};function De(t,e,o){return{admin:o,features:Bo(t),lexical:e,resolvedFeatureMap:t}}var wl=Go.default||Go,Nl=t=>{let{admin:e,field:{richTextComponentMap:o},lexicalEditorConfig:n}=t,[r,i]=_l.useState("Loading..."),{cellData:l,cellProps:s,columnIndex:a,customCellContext:c,rowData:u}=Cl(),{config:{routes:{admin:d}}}=gl(),{link:m}=s||{},f="span",p={},g=m!==void 0?m:a===0;g&&(f=wl,p.href=c?.collectionSlug?xl({adminRoute:d,path:`/collections/${c?.collectionSlug}/${u.id}`}):"");let b=El(()=>{let x=o?.get("features"),A=[];for(let E of x)A.push(E.clientFeature(E.clientFeatureProps));let v=n||Fe,T=Qe({unSanitizedEditorConfig:{features:A,lexical:v}});return De(T,v)},[o,n]);return b.admin=e,Tl(()=>{let x=l;if(x==null||!b){i("");return}if(b?.features?.hooks?.load?.length&&b.features.hooks.load.forEach(T=>{x=T({incomingEditorState:x})}),!x||typeof x!="object"){i("");return}if(Array.isArray(x)&&!("root"in x)){i("");return}if("jsonContent"in x){i("");return}let A=hl({namespace:b.lexical.namespace,nodes:Mt({editorConfig:b}),theme:b.lexical.theme});A.setEditorState(A.parseEditorState(x));let v=A.getEditorState().read(()=>bl().getTextContent())||"";i(v)},[l,b]),g?jo(f,{...p,children:r}):jo("span",{children:r})};import{$isElementNode as ie,$isRangeSelection as tt,FORMAT_ELEMENT_COMMAND as ot}from"lexical";import{jsx as Ot,jsxs as kl}from"react/jsx-runtime";import"react";var Uo=()=>kl("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ot("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ot("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ot("path",{d:"M5 15H15",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Pt,jsxs as Ll}from"react/jsx-runtime";import"react";var Wo=()=>Ll("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Pt("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Pt("path",{d:"M2.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as $t,jsxs as Il}from"react/jsx-runtime";import"react";var et=()=>Il("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[$t("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),$t("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),$t("path",{d:"M2.5 15H12.5",stroke:"currentColor",strokeWidth:"1.5"})]});import{jsx as Ht,jsxs as Rl}from"react/jsx-runtime";import"react";var Vo=()=>Rl("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[Ht("path",{d:"M2.5 5H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M2.5 10H17.5",stroke:"currentColor",strokeWidth:"1.5"}),Ht("path",{d:"M7.5 15H17.5",stroke:"currentColor",strokeWidth:"1.5"})]});var S=t=>o=>{let n={clientFeatureProps:o};if(typeof t=="function")n.feature=({featureProviderMap:r,resolvedFeatures:i,unSanitizedEditorConfig:l})=>{let s=t({featureProviderMap:r,props:o,resolvedFeatures:i,unSanitizedEditorConfig:l});return s.sanitizedClientFeatureProps===null&&(s.sanitizedClientFeatureProps=o),s};else{let r={...t};r.sanitizedClientFeatureProps=o,n.feature=r}return n};var Ko=t=>({type:"dropdown",ChildComponent:et,items:t,key:"align",order:30});var zo=[Ko([{ChildComponent:et,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="left")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="left"))return!1}return!0},key:"alignLeft",label:({i18n:t})=>t.t("lexical:align:alignLeftLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"left")},order:1},{ChildComponent:Uo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="center")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="center"))return!1}return!0},key:"alignCenter",label:({i18n:t})=>t.t("lexical:align:alignCenterLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"center")},order:2},{ChildComponent:Vo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="right")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="right"))return!1}return!0},key:"alignRight",label:({i18n:t})=>t.t("lexical:align:alignRightLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"right")},order:3},{ChildComponent:Wo,isActive:({selection:t})=>{if(!tt(t))return!1;for(let e of t.getNodes()){if(ie(e)&&e.getFormatType()==="justify")continue;let o=e.getParent();if(!(ie(o)&&o.getFormatType()==="justify"))return!1}return!0},key:"alignJustify",label:({i18n:t})=>t.t("lexical:align:alignJustifyLabel"),onSelect:({editor:t})=>{t.dispatchCommand(ot,"justify")},order:4}])],Sl=S({toolbarFixed:{groups:zo},toolbarInline:{groups:zo}});import{$createQuoteNode as er,$isQuoteNode as qo,QuoteNode as Al}from"@lexical/rich-text";import{$setBlocksType as tr}from"@lexical/selection";import{$getSelection as or,$isRangeSelection as Fl}from"lexical";import{jsx as Zo}from"react/jsx-runtime";import"react";var Bt=()=>Zo("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Zo("path",{d:"M13.5353 10.5725C13.5353 9.47709 11.0456 9.99991 11.0456 7.85883C11.0456 6.46464 12.1162 5.61816 13.361 5.61816C14.805 5.61816 16 6.86298 16 8.92937C16 11.2945 14.4564 13.7841 11.1203 14.3816L10.8216 13.1368C12.888 12.4895 13.5353 11.4937 13.5353 10.5725ZM6.71369 10.5725C6.71369 9.47709 4.22407 9.99991 4.22407 7.85883C4.22407 6.46464 5.29461 5.61816 6.53942 5.61816C7.9834 5.61816 9.17842 6.86298 9.17842 8.92937C9.17842 11.2945 7.63485 13.7841 4.29876 14.3816L4 13.1368C6.06639 12.4895 6.71369 11.4937 6.71369 10.5725Z",fill:"currentColor"})});import{jsx as Yo}from"react/jsx-runtime";import"react";var Oe=()=>Yo("svg",{"aria-hidden":"true",className:"icon",fill:"currentColor",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:Yo("path",{d:"M11.708 14.5H7.79785V13.9414H8.01367C9.00391 13.9414 9.15625 13.9033 9.15625 13.6113V6.70508H8.07715C6.82031 6.70508 6.73145 7.08594 6.28711 8.67285H5.80469L5.91895 6.12109H13.5869L13.7012 8.67285H13.2188C12.7744 7.08594 12.6855 6.70508 11.4287 6.70508H10.3496V13.6113C10.3496 13.9033 10.502 13.9414 11.4922 13.9414H11.708V14.5Z",fill:"currentColor"})});var W=t=>({type:"dropdown",ChildComponent:Oe,items:t,key:"text",order:25});import{$createQuoteNode as yl,$isQuoteNode as Xo,QuoteNode as Ml}from"@lexical/rich-text";import{$createLineBreakNode as vl}from"lexical";var Jo={type:"element",dependencies:[Ml],export:(t,e)=>{if(!Xo(t))return null;let o=e(t).split(`
|
|
2
2
|
`),n=[];for(let r of o)n.push("> "+r);return n.join(`
|
|
3
3
|
`)},regExp:/^>\s/,replace:(t,e,o,n)=>{if(n){let i=t.getPreviousSibling();if(Xo(i)){i.splice(i.getChildrenSize(),0,[vl(),...e]),i.select(0,0),t.remove();return}}let r=yl();r.append(...e),t.replace(r),r.select(0,0)}};var Qo=[W([{ChildComponent:Bt,isActive:({selection:t})=>{if(!Fl(t))return!1;for(let e of t.getNodes())if(!qo(e)&&!qo(e.getParent()))return!1;return!0},key:"blockquote",label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=or();tr(e,()=>er())})},order:20}])],Dl=S({markdownTransformers:[Jo],nodes:[Al],slashMenu:{groups:[G([{Icon:Bt,key:"blockquote",keywords:["quote","blockquote"],label:({i18n:t})=>t.t("lexical:blockquote:label"),onSelect:({editor:t})=>{t.update(()=>{let e=or();tr(e,()=>er())})}}])]},toolbarFixed:{groups:Qo},toolbarInline:{groups:Qo}});import{getTranslation as it}from"@payloadcms/translations";import{jsx as jt,jsxs as Ol}from"react/jsx-runtime";import"react";var rt=()=>Ol("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:[jt("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"8",y:"5"}),jt("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"5",y:"11"}),jt("rect",{height:"4",rx:"0.5",stroke:"currentColor",width:"4",x:"11",y:"11"})]});import{jsx as rr}from"react/jsx-runtime";import"react";var nt=()=>rr("svg",{"aria-hidden":"true",className:"icon",fill:"none",focusable:"false",height:"20",viewBox:"0 0 20 20",width:"20",xmlns:"http://www.w3.org/2000/svg",children:rr("path",{clipRule:"evenodd",d:"M5.33333 6.5C5.11232 6.5 4.90036 6.5878 4.74408 6.74408C4.5878 6.90036 4.5 7.11232 4.5 7.33333V12.1667C4.5 12.3877 4.5878 12.5996 4.74408 12.7559C4.90036 12.9122 5.11232 13 5.33333 13H14.6667C14.8877 13 15.0996 12.9122 15.2559 12.7559C15.4122 12.5996 15.5 12.3877 15.5 12.1667V11.6667C15.5 11.3905 15.7239 11.1667 16 11.1667C16.2761 11.1667 16.5 11.3905 16.5 11.6667V12.1667C16.5 12.6529 16.3068 13.1192 15.963 13.463C15.6192 13.8068 15.1529 14 14.6667 14H5.33333C4.8471 14 4.38079 13.8068 4.03697 13.463C3.69315 13.1192 3.5 12.6529 3.5 12.1667V7.33333C3.5 6.8471 3.69315 6.38079 4.03697 6.03697C4.38079 5.69315 4.8471 5.5 5.33333 5.5H10.3333C10.6095 5.5 10.8333 5.72386 10.8333 6C10.8333 6.27614 10.6095 6.5 10.3333 6.5H5.33333ZM13 6.5C12.7239 6.5 12.5 6.27614 12.5 6C12.5 5.72386 12.7239 5.5 13 5.5H16C16.2761 5.5 16.5 5.72386 16.5 6V9C16.5 9.27614 16.2761 9.5 16 9.5C15.7239 9.5 15.5 9.27614 15.5 9V7.20711L13.3536 9.35355C13.1583 9.54882 12.8417 9.54882 12.6464 9.35355C12.4512 9.15829 12.4512 8.84171 12.6464 8.64645L14.7929 6.5H13ZM6.16699 8.33325C6.16699 8.05711 6.39085 7.83325 6.66699 7.83325H11.0003C11.2765 7.83325 11.5003 8.05711 11.5003 8.33325C11.5003 8.60939 11.2765 8.83325 11.0003 8.83325H6.66699C6.39085 8.83325 6.16699 8.60939 6.16699 8.33325ZM6.16699 10.9999C6.16699 10.7238 6.39085 10.4999 6.66699 10.4999H13.3337C13.6098 10.4999 13.8337 10.7238 13.8337 10.9999C13.8337 11.2761 13.6098 11.4999 13.3337 11.4999H6.66699C6.39085 11.4999 6.16699 11.2761 6.16699 10.9999Z",fill:"currentColor",fillRule:"evenodd"})});import{c as Pl}from"react/compiler-runtime";import{jsx as $l}from"react/jsx-runtime";import{useLexicalComposerContext as Hl}from"@lexical/react/LexicalComposerContext.js";import{$insertNodeToNearestRoot as Bl,$wrapNodeInElement as jl,mergeRegister as Gl}from"@lexical/utils";import{getTranslation as Ul}from"@payloadcms/translations";import{formatDrawerSlug as Wl,useEditDepth as Vl,useFieldProps as Kl,useModal as zl,useTranslation as Zl}from"@payloadcms/ui";import{$createParagraphNode as Yl,$getNodeByKey as Xl,$getPreviousSelection as Jl,$getSelection as nr,$insertNodes as ql,$isParagraphNode as ir,$isRangeSelection as lr,$isRootOrShadowRoot as Ql,COMMAND_PRIORITY_EDITOR as Gt}from"lexical";import{useEffect as es,useState as Ut}from"react";var sr=()=>{let t=Pl(25),[e]=Hl(),{closeModal:o,toggleModal:n}=zl(),[r,i]=Ut(null),[l,s]=Ut(""),[a,c]=Ut(null),{i18n:u,t:d}=Zl(),{schemaPath:m}=Kl(),{uuid:f}=H(),p=Vl(),g="lexical-inlineBlocks-create-"+f,b;t[0]!==g||t[1]!==p?(b=Wl({slug:g,depth:p}),t[0]=g,t[1]=p,t[2]=b):b=t[2];let x=b,{field:A}=H(),{richTextComponentMap:v}=A,T,E;if(t[3]!==e||t[4]!==a||t[5]!==n||t[6]!==x?(T=()=>{if(!e.hasNodes([Ne]))throw new Error("BlocksPlugin: BlocksNode not registered on editor");return Gl(e.registerCommand(ke,N=>(e.update(()=>{let C=nr()||Jl();if(lr(C)){let h=vt(N);Bl(h);let{focus:I}=C,k=I.getNode();ir(k)&&k.getTextContentSize()===0&&k.getParentOrThrow().getChildren().filter(w=>ir(w)).length>1&&k.remove()}}),!0),Gt),e.registerCommand(At,N=>{if(a){let h=Xl(a);return!h||!$o(h)?!1:(h.setFields(N),c(null),!0)}let C=Po(N);return ql([C]),Ql(C.getParentOrThrow())&&jl(C,Yl).selectEnd(),!0},Gt),e.registerCommand(Le,N=>{let{fields:C,nodeKey:h}=N;if(i(C??null),c(h??null),s(C?.blockType??""),h)return n(x),!0;let I;return I=null,e.getEditorState().read(()=>{let k=nr();lr(k)&&(I=k)}),I&&n(x),!0},Gt))},E=[e,a,n,x],t[3]=e,t[4]=a,t[5]=n,t[6]=x,t[7]=T,t[8]=E):(T=t[7],E=t[8]),es(T,E),!r)return null;let _=`${m}.lexical_internal_feature.blocks.lexical_inline_blocks.lexical_inline_blocks.${r?.blockType}`,L="lexical_internal_feature.blocks.fields.lexical_inline_blocks",y,R;if(t[9]!==v||t[10]!==r||t[11]!==u||t[12]!==d||t[13]!==o||t[14]!==x||t[15]!==l||t[16]!==e||t[17]!==_){R=Symbol.for("react.early_return_sentinel");e:{let N=v?.has(L)?v.get(L)[0]:null,C=N?N.blocks.find(k=>k.slug===r?.blockType):null;if(!N){R=null;break e}let h=C?.labels?.singular?Ul(C?.labels?.singular,u):C?.slug,I;t[20]!==o||t[21]!==x||t[22]!==l||t[23]!==e?(I=(k,w)=>{o(x),w&&(w.blockType=l,e.dispatchCommand(At,w))},t[20]=o,t[21]=x,t[22]=l,t[23]=e,t[24]=I):I=t[24],y=$l(ae,{data:r,drawerSlug:x,drawerTitle:d(`lexical:blocks:inlineBlocks:${r?.id?"edit":"create"}`,{label:h??d("lexical:blocks:inlineBlocks:label")}),featureKey:"blocks",fieldMapOverride:C?.fields,handleDrawerSubmit:I,schemaFieldsPathOverride:_,schemaPathSuffix:r?.blockType})}t[9]=v,t[10]=r,t[11]=u,t[12]=d,t[13]=o,t[14]=x,t[15]=l,t[16]=e,t[17]=_,t[18]=y,t[19]=R}else y=t[18],R=t[19];return R!==Symbol.for("react.early_return_sentinel")?R:y};var ts=S(({props:t})=>({nodes:[Ne,Oo],plugins:[{Component:sr,position:"normal"}],sanitizedClientFeatureProps:t,slashMenu:{groups:[t.clientBlockSlugs?.length?{items:t.clientBlockSlugs.map(e=>({Icon:rt,key:"block-"+e,keywords:["block","blocks",e],label:({i18n:o,richTextComponentMap:n})=>{if(!n)return e;let l=(n.get("lexical_internal_feature.blocks.fields.lexical_blocks")?.[0]).blocks.find(a=>a.slug===e);return l?.labels?.singular?it(l.labels.singular,o):l?.slug},onSelect:({editor:o})=>{o.dispatchCommand(ke,{blockName:"",blockType:e})}})),key:"blocks",label:({i18n:e})=>e.t("lexical:blocks:label")}:null,t.clientInlineBlockSlugs?.length?{items:t.clientInlineBlockSlugs.map(e=>({Icon:nt,key:"inlineBlocks-"+e,keywords:["inlineBlock","inline block",e],label:({i18n:o,richTextComponentMap:n})=>{if(!n)return e;let l=(n.get("lexical_internal_feature.blocks.fields.lexical_inline_blocks")?.[0]).blocks.find(a=>a.slug===e);return l?.labels?.singular?it(l.labels.singular,o):l?.slug},onSelect:({editor:o})=>{o.dispatchCommand(Le,{fields:{blockName:"",blockType:e}})}})),key:"inlineBlocks",label:({i18n:e})=>e.t("lexical:blocks:inlineBlocks:label")}:null].filter(Boolean)},toolbarFixed:{groups:[t.clientBlockSlugs?.length?{type:"dropdown",ChildComponent:rt,items:t.clientBlockSlugs.map((e,o)=>({ChildComponent:rt,isActive:void 0,key:"block-"+e,label:({i18n:n,richTextComponentMap:r})=>{if(!r)return e;let s=(r.get("lexical_internal_feature.blocks.fields.lexical_blocks")?.[0]).blocks.find(c=>c.slug===e);return s?.labels?.singular?it(s.labels.singular,n):s?.slug},onSelect:({editor:n})=>{n.dispatchCommand(ke,{blockName:"",blockType:e})},order:o})),key:"blocks",order:20}:null,t.clientInlineBlockSlugs?.length?{type:"dropdown",ChildComponent:nt,items:t.clientInlineBlockSlugs.map((e,o)=>({ChildComponent:nt,isActive:void 0,key:"inlineBlock-"+e,label:({i18n:n,richTextComponentMap:r})=>{if(!r)return e;let s=(r.get("lexical_internal_feature.blocks.fields.lexical_inline_blocks")?.[0]).blocks.find(c=>c.slug===e);return s?.labels?.singular?it(s.labels.singular,n):s?.slug},onSelect:({editor:n})=>{n.dispatchCommand(Le,{fields:{blockType:e}})},order:o})),key:"inlineBlocks",order:25}:null].filter(Boolean)}}));import{jsx as ue,jsxs as Kt}from"react/jsx-runtime";import{useLexicalComposerContext as ns}from"@lexical/react/LexicalComposerContext.js";import{$createParagraphNode as is,$createTextNode as ls,$getRoot as ss}from"lexical";import*as mr from"react";import{useCallback as ce,useEffect as Wt,useLayoutEffect as cr,useRef as Vt,useState as lt}from"react";var K=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";var os=K&&"documentMode"in document?document.documentMode:null,ar=K&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),F1=K&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),D1=K&&"InputEvent"in window&&!os?"getTargetRanges"in new window.InputEvent("input"):!1,O1=K&&/Version\/[\d.].*Safari/.test(navigator.userAgent),P1=K&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,$1=K&&/Android/.test(navigator.userAgent),H1=K&&/Win/.test(navigator.platform),rs=K&&/^(?=.*Chrome).*/i.test(navigator.userAgent),B1=K&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!rs;var as=t=>{let e=document.createElement("textarea");e.value=t||"",e.style.position="absolute",e.style.opacity="0",document.body?.appendChild(e),e.focus(),e.select();try{let o=document.execCommand("copy");console.log(o)}catch(o){console.error(o)}document.body?.removeChild(e)},cs=(t,e)=>{let o=document.createElement("a");o.setAttribute("href","data:text/plain;charset=utf-8,"+encodeURIComponent(e||"")),o.setAttribute("download",t),o.style.display="none",document.body?.appendChild(o),o.click(),document.body?.removeChild(o)},us=t=>{let o=((n,r)=>{switch(n){case"click":return` await page.mouse.click(${r.x}, ${r.y});`;case"press":return` await page.keyboard.press('${r}');`;case"keydown":return` await page.keyboard.keydown('${r}');`;case"keyup":return` await page.keyboard.keyup('${r}');`;case"type":return` await page.keyboard.type('${r}');`;case"selectAll":return" await selectAll(page);";case"snapshot":return` await assertHTMLSnapshot(page);
|
|
4
4
|
await assertSelection(page, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAoD,MAAM,OAAO,CAAA;AASxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,cAAc,CAAA;AAErB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/features/blocks/client/component/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAoD,MAAM,OAAO,CAAA;AASxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAInE,OAAO,cAAc,CAAA;AAErB,KAAK,KAAK,GAAG;IACX,QAAQ,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACnC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAsJ1C,CAAA"}
|
|
@@ -41,9 +41,6 @@ export const BlockComponent = props => {
|
|
|
41
41
|
// Field Schema
|
|
42
42
|
useEffect(() => {
|
|
43
43
|
const awaitInitialState = async () => {
|
|
44
|
-
if (!id) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
44
|
const {
|
|
48
45
|
state
|
|
49
46
|
} = await getFormState({
|
|
@@ -74,9 +71,6 @@ export const BlockComponent = props => {
|
|
|
74
71
|
const onChange = useCallback(async ({
|
|
75
72
|
formState: prevFormState
|
|
76
73
|
}) => {
|
|
77
|
-
if (!id) {
|
|
78
|
-
throw new Error('No ID found');
|
|
79
|
-
}
|
|
80
74
|
const {
|
|
81
75
|
state: formState
|
|
82
76
|
} = await getFormState({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["Collapsible","Form","Pill","RenderComponent","SectionTitle","ShimmerEffect","useConfig","useDocumentInfo","useFieldProps","useFormSubmitted","useTranslation","React","useCallback","useEffect","useMemo","useState","baseClass","getTranslation","getFormState","v4","uuid","useEditorConfigContext","BlockContent","BlockComponent","props","formData","nodeKey","config","submitted","id","path","schemaPath","field","parentLexicalRichTextField","initialState","setInitialState","richTextComponentMap","schemaFieldsPath","blockType","componentMapRenderedBlockPath","blocksField","get","clientBlock","blocks","find","block","slug","awaitInitialState","state","apiRoute","routes","api","body","data","operation","serverURL","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","Error","i18n","classNames","filter","Boolean","join","formContent","_jsx","beforeSubmit","fields","formSchema","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","_jsxs","pillStyle","labels","singular","readOnly","height"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\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 { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlocksFieldClient = richTextComponentMap?.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n if (!id) {\n return\n }\n const { state } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n if (!id) {\n throw new Error('No ID found')\n }\n const { state: formState } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,QACT;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ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,SAAA,gBAAyBS,QAAA,EAAUa,SAAA,EAAW;YACrF+C,SAAA,EAAU;sBAET3C,WAAA,IAAe,OAAOA,WAAA,CAAY4C,MAAM,EAAEC,QAAA,KAAa,WACpDtE,cAAA,CAAeyB,WAAA,CAAY4C,MAAM,CAACC,QAAQ,EAAEtB,IAAA,IAC5CvB,WAAA,EAAaI;2BAEnByB,IAAA,CAACnE,YAAA;YACC0B,IAAA,EAAK;YACL0D,QAAA,EAAUvD,0BAAA,EAA4B6C,KAAA,EAAOU,QAAA,IAAY;;;;gBAQnE,aAAAjB,IAAA,CAAClE,aAAA;QAAcoF,MAAA,EAAO;;OAFjB;EAKX,GAAG,CACD/C,WAAA,EACAR,YAAA,EACA2B,QAAA,EACAjC,SAAA,EACAK,0BAAA,EACAP,OAAA,EACAI,IAAA,EACAO,gBAAA,EACA6B,UAAA,EACAD,IAAA,CACD;EAED,oBAAOM,IAAA,CAAC;IAAII,SAAA,EAAW3D,SAAA,GAAY,MAAMA,SAAA,GAAY,MAAMS,QAAA,CAASa,SAAS;cAAGgC;;AAClF","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"index.js","names":["Collapsible","Form","Pill","RenderComponent","SectionTitle","ShimmerEffect","useConfig","useDocumentInfo","useFieldProps","useFormSubmitted","useTranslation","React","useCallback","useEffect","useMemo","useState","baseClass","getTranslation","getFormState","v4","uuid","useEditorConfigContext","BlockContent","BlockComponent","props","formData","nodeKey","config","submitted","id","path","schemaPath","field","parentLexicalRichTextField","initialState","setInitialState","richTextComponentMap","schemaFieldsPath","blockType","componentMapRenderedBlockPath","blocksField","get","clientBlock","blocks","find","block","slug","awaitInitialState","state","apiRoute","routes","api","body","data","operation","serverURL","blockName","initialValue","passesCondition","valid","value","onChange","formState","prevFormState","i18n","classNames","filter","Boolean","join","formContent","_jsx","beforeSubmit","fields","formSchema","className","collapsibleStyle","header","admin","components","Label","clientProps","blockKind","mappedComponent","_jsxs","pillStyle","labels","singular","readOnly","height"],"sources":["../../../../../src/features/blocks/client/component/index.tsx"],"sourcesContent":["'use client'\n\nimport {\n Collapsible,\n Form,\n Pill,\n RenderComponent,\n SectionTitle,\n ShimmerEffect,\n useConfig,\n useDocumentInfo,\n useFieldProps,\n useFormSubmitted,\n useTranslation,\n} from '@payloadcms/ui'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\n\nconst baseClass = 'lexical-block'\nimport type { BlocksFieldClient, FormState } from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\nimport { getFormState } from '@payloadcms/ui/shared'\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 { BlockContent } from './BlockContent.js'\nimport './index.scss'\n\ntype Props = {\n readonly children?: React.ReactNode\n readonly formData: BlockFields\n readonly nodeKey: string\n}\n\nexport const BlockComponent: React.FC<Props> = (props) => {\n const { formData, nodeKey } = props\n const { config } = useConfig()\n const submitted = useFormSubmitted()\n const { id } = useDocumentInfo()\n const { path, schemaPath } = useFieldProps()\n const { field: parentLexicalRichTextField } = useEditorConfigContext()\n\n const [initialState, setInitialState] = useState<false | FormState>(false)\n const {\n field: { richTextComponentMap },\n } = useEditorConfigContext()\n\n const schemaFieldsPath = `${schemaPath}.lexical_internal_feature.blocks.lexical_blocks.lexical_blocks.${formData.blockType}`\n\n const componentMapRenderedBlockPath = `lexical_internal_feature.blocks.fields.lexical_blocks`\n const blocksField: BlocksFieldClient = richTextComponentMap?.get(componentMapRenderedBlockPath)[0]\n\n const clientBlock = blocksField.blocks.find((block) => block.slug === formData.blockType)\n\n // Field Schema\n useEffect(() => {\n const awaitInitialState = async () => {\n const { state } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n data: formData,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n if (state) {\n state.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n setInitialState(state)\n }\n }\n\n if (formData) {\n void awaitInitialState()\n }\n }, [config.routes.api, config.serverURL, schemaFieldsPath, id]) // DO NOT ADD FORMDATA HERE! Adding formData will kick you out of sub block editors while writing.\n\n const onChange = useCallback(\n async ({ formState: prevFormState }) => {\n const { state: formState } = await getFormState({\n apiRoute: config.routes.api,\n body: {\n id,\n formState: prevFormState,\n operation: 'update',\n schemaPath: schemaFieldsPath,\n },\n serverURL: config.serverURL,\n })\n\n formState.blockName = {\n initialValue: '',\n passesCondition: true,\n valid: true,\n value: formData.blockName,\n }\n\n return formState\n },\n\n [config.routes.api, config.serverURL, id, schemaFieldsPath, formData.blockName],\n )\n const { i18n } = useTranslation()\n\n const classNames = [`${baseClass}__row`, `${baseClass}__row--no-errors`].filter(Boolean).join(' ')\n\n // Memoized Form JSX\n const formContent = useMemo(() => {\n return clientBlock && initialState !== false ? (\n <Form\n beforeSubmit={[onChange]}\n fields={clientBlock.fields}\n initialState={initialState}\n onChange={[onChange]}\n submitted={submitted}\n uuid={uuid()}\n >\n <BlockContent\n baseClass={baseClass}\n clientBlock={clientBlock}\n field={parentLexicalRichTextField}\n formData={formData}\n formSchema={clientBlock.fields}\n nodeKey={nodeKey}\n path={`${path}.lexical_internal_feature.blocks.${formData.blockType}`}\n schemaPath={schemaFieldsPath}\n />\n </Form>\n ) : (\n <Collapsible\n className={classNames}\n collapsibleStyle=\"default\"\n header={\n clientBlock?.admin?.components?.Label ? (\n <RenderComponent\n clientProps={{ blockKind: 'lexicalBlock', formData }}\n mappedComponent={clientBlock.admin.components.Label}\n />\n ) : (\n <div className={`${baseClass}__block-header`}>\n <div>\n <Pill\n className={`${baseClass}__block-pill ${baseClass}__block-pill-${formData?.blockType}`}\n pillStyle=\"white\"\n >\n {clientBlock && typeof clientBlock.labels?.singular === 'string'\n ? getTranslation(clientBlock.labels.singular, i18n)\n : clientBlock?.slug}\n </Pill>\n <SectionTitle\n path=\"blockName\"\n readOnly={parentLexicalRichTextField?.admin?.readOnly || false}\n />\n </div>\n </div>\n )\n }\n key={0}\n >\n <ShimmerEffect height=\"35vh\" />\n </Collapsible>\n )\n }, [\n clientBlock,\n initialState,\n onChange,\n submitted,\n parentLexicalRichTextField,\n nodeKey,\n path,\n schemaFieldsPath,\n classNames,\n i18n,\n ])\n\n return <div className={baseClass + ' ' + baseClass + '-' + formData.blockType}>{formContent}</div>\n}\n"],"mappings":"AAAA;;;AAEA,SACEA,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,eAAe,EACfC,YAAY,EACZC,aAAa,EACbC,SAAS,EACTC,eAAe,EACfC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,QACT;AACP,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AAEjE,MAAMC,SAAA,GAAY;AAGlB,SAASC,cAAc,QAAQ;AAC/B,SAASC,YAAY,QAAQ;AAC7B,SAASC,EAAA,IAAMC,IAAI,QAAQ;AAI3B,SAASC,sBAAsB,QAAQ;AACvC,SAASC,YAAY,QAAQ;AAS7B,OAAO,MAAMC,cAAA,GAAmCC,KAAA;EAC9C,MAAM;IAAEC,QAAQ;IAAEC;EAAO,CAAE,GAAGF,KAAA;EAC9B,MAAM;IAAEG;EAAM,CAAE,GAAGrB,SAAA;EACnB,MAAMsB,SAAA,GAAYnB,gBAAA;EAClB,MAAM;IAAEoB;EAAE,CAAE,GAAGtB,eAAA;EACf,MAAM;IAAEuB,IAAI;IAAEC;EAAU,CAAE,GAAGvB,aAAA;EAC7B,MAAM;IAAEwB,KAAA,EAAOC;EAA0B,CAAE,GAAGZ,sBAAA;EAE9C,MAAM,CAACa,YAAA,EAAcC,eAAA,CAAgB,GAAGpB,QAAA,CAA4B;EACpE,MAAM;IACJiB,KAAA,EAAO;MAAEI;IAAoB;EAAE,CAChC,GAAGf,sBAAA;EAEJ,MAAMgB,gBAAA,GAAmB,GAAGN,UAAA,kEAA4EN,QAAA,CAASa,SAAS,EAAE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