@payloadcms/richtext-lexical 3.0.0-alpha.47 → 3.0.0-alpha.49
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/cell/index.d.ts.map +1 -1
- package/dist/cell/index.js +6 -5
- package/dist/cell/index.js.map +1 -1
- package/dist/field/Field.d.ts +2 -1
- package/dist/field/Field.d.ts.map +1 -1
- package/dist/field/Field.js +7 -4
- package/dist/field/Field.js.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.d.ts +2 -2
- package/dist/field/features/blocks/component/BlockContent.d.ts.map +1 -1
- package/dist/field/features/blocks/component/BlockContent.js +34 -16
- package/dist/field/features/blocks/component/BlockContent.js.map +1 -1
- package/dist/field/features/blocks/component/FormSavePlugin.d.ts.map +1 -1
- package/dist/field/features/blocks/component/FormSavePlugin.js +2 -1
- package/dist/field/features/blocks/component/FormSavePlugin.js.map +1 -1
- package/dist/field/features/blocks/component/index.d.ts.map +1 -1
- package/dist/field/features/blocks/component/index.js +10 -8
- package/dist/field/features/blocks/component/index.js.map +1 -1
- package/dist/field/features/blocks/drawer/index.d.ts.map +1 -1
- package/dist/field/features/blocks/drawer/index.js +4 -1
- package/dist/field/features/blocks/drawer/index.js.map +1 -1
- package/dist/field/features/blocks/feature.client.d.ts +1 -1
- package/dist/field/features/blocks/feature.client.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.client.js.map +1 -1
- package/dist/field/features/blocks/feature.server.d.ts.map +1 -1
- package/dist/field/features/blocks/feature.server.js +4 -11
- package/dist/field/features/blocks/feature.server.js.map +1 -1
- package/dist/field/features/createClientComponent.d.ts +1 -2
- package/dist/field/features/createClientComponent.d.ts.map +1 -1
- package/dist/field/features/createFeaturePropComponent.d.ts.map +1 -1
- package/dist/field/features/createFeaturePropComponent.js +3 -2
- package/dist/field/features/createFeaturePropComponent.js.map +1 -1
- package/dist/field/features/link/drawer/index.d.ts.map +1 -1
- package/dist/field/features/link/drawer/index.js +16 -10
- package/dist/field/features/link/drawer/index.js.map +1 -1
- package/dist/field/features/link/plugins/autoLink/index.js +1 -1
- package/dist/field/features/link/plugins/autoLink/index.js.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.d.ts.map +1 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js +4 -1
- package/dist/field/features/link/plugins/floatingLinkEditor/LinkEditor/index.js.map +1 -1
- package/dist/field/features/relationship/drawer/index.js +1 -1
- package/dist/field/features/relationship/drawer/index.js.map +1 -1
- package/dist/field/features/relationship/feature.client.js +1 -1
- package/dist/field/features/relationship/feature.client.js.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.d.ts.map +1 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js +5 -1
- package/dist/field/features/relationship/nodes/components/RelationshipComponent.js.map +1 -1
- package/dist/field/features/relationship/plugins/index.d.ts.map +1 -1
- package/dist/field/features/relationship/plugins/index.js +2 -2
- package/dist/field/features/relationship/plugins/index.js.map +1 -1
- package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.d.ts.map +1 -1
- package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js +2 -1
- package/dist/field/features/relationship/utils/EnabledRelationshipsCondition.js.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts +2 -2
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js +17 -9
- package/dist/field/features/upload/component/ExtraFieldsDrawer/index.js.map +1 -1
- package/dist/field/features/upload/component/index.d.ts.map +1 -1
- package/dist/field/features/upload/component/index.js +10 -2
- package/dist/field/features/upload/component/index.js.map +1 -1
- package/dist/field/features/upload/drawer/index.js +1 -1
- package/dist/field/features/upload/drawer/index.js.map +1 -1
- package/dist/field/features/upload/plugin/index.d.ts.map +1 -1
- package/dist/field/features/upload/plugin/index.js +1 -1
- package/dist/field/features/upload/plugin/index.js.map +1 -1
- package/dist/field/index.d.ts +1 -1
- package/dist/field/index.d.ts.map +1 -1
- package/dist/field/index.js +5 -5
- package/dist/field/index.js.map +1 -1
- package/dist/field/lexical/LexicalProvider.d.ts +1 -1
- package/dist/field/lexical/LexicalProvider.d.ts.map +1 -1
- package/dist/field/lexical/LexicalProvider.js.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.d.ts +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.d.ts.map +1 -1
- package/dist/field/lexical/config/client/EditorConfigProvider.js.map +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js +1 -1
- package/dist/field/lexical/plugins/SlashMenu/index.js.map +1 -1
- package/dist/generateComponentMap.d.ts.map +1 -1
- package/dist/generateComponentMap.js +5 -3
- package/dist/generateComponentMap.js.map +1 -1
- package/dist/generateSchemaMap.d.ts.map +1 -1
- package/dist/generateSchemaMap.js +2 -1
- package/dist/generateSchemaMap.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -19
- package/dist/index.js.map +1 -1
- package/dist/useLexicalFeature.d.ts.map +1 -1
- package/dist/useLexicalFeature.js +3 -3
- package/dist/useLexicalFeature.js.map +1 -1
- package/package.json +10 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/field/lexical/LexicalProvider.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\nimport type { LexicalEditor } from 'lexical'\n\nimport lexicalComposerImport from '@lexical/react/LexicalComposer.js'\nconst { LexicalComposer } = lexicalComposerImport\n\nimport type { InitialConfigType } from '@lexical/react/LexicalComposer.js'\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\n\nimport type { SanitizedClientEditorConfig } from './config/types.js'\n\nimport { LexicalEditor as LexicalEditorComponent } from './LexicalEditor.js'\nimport { EditorConfigProvider } from './config/client/EditorConfigProvider.js'\nimport { getEnabledNodes } from './nodes/index.js'\n\nexport type LexicalProviderProps = {\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n onChange: (editorState: EditorState, editor: LexicalEditor, tags: Set<string>) => void\n path: string\n readOnly: boolean\n value: SerializedEditorState\n}\nexport const LexicalProvider: React.FC<LexicalProviderProps> = (props) => {\n const { editorConfig, fieldProps, onChange, path, readOnly } = props\n let { value } = props\n\n const [initialConfig, setInitialConfig] = React.useState<InitialConfigType | null>(null)\n\n // set lexical config in useEffect: // TODO: Is this the most performant way to do this? Prob not\n React.useEffect(() => {\n const newInitialConfig: InitialConfigType = {\n editable: readOnly !== true,\n editorState: value != null ? JSON.stringify(value) : undefined,\n namespace: editorConfig.lexical.namespace,\n nodes: [...getEnabledNodes({ editorConfig })],\n onError: (error: Error) => {\n throw error\n },\n theme: editorConfig.lexical.theme,\n }\n setInitialConfig(newInitialConfig)\n }, [editorConfig, readOnly, value])\n\n if (editorConfig?.features?.hooks?.load?.length) {\n editorConfig.features.hooks.load.forEach((hook) => {\n value = hook({ incomingEditorState: value })\n })\n }\n\n if (value && typeof value !== 'object') {\n throw new Error(\n 'The value passed to the Lexical editor is not an object. This is not supported. Please remove the data from the field and start again. This is the value that was passed in: ' +\n JSON.stringify(value),\n )\n }\n\n if (value && Array.isArray(value) && !('root' in value)) {\n throw new Error(\n 'You have tried to pass in data from the old, Slate editor, to the new, Lexical editor. This is not supported. There is no automatic conversion from Slate to Lexical data available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (value && 'jsonContent' in value) {\n throw new Error(\n 'You have tried to pass in data from payload-plugin-lexical. This is not supported. The data structure has changed in this editor, compared to the plugin, and there is no automatic conversion available yet (coming soon). Please remove the data from the field and start again.',\n )\n }\n\n if (!initialConfig) {\n return <p>Loading...</p>\n }\n\n return (\n <LexicalComposer initialConfig={initialConfig} key={path}>\n <EditorConfigProvider editorConfig={editorConfig} fieldProps={fieldProps}>\n <div className=\"editor-shell\">\n <LexicalEditorComponent editorConfig={editorConfig} onChange={onChange} />\n </div>\n </EditorConfigProvider>\n </LexicalComposer>\n )\n}\n"],"names":["lexicalComposerImport","LexicalComposer","React","LexicalEditor","LexicalEditorComponent","EditorConfigProvider","getEnabledNodes","LexicalProvider","props","editorConfig","fieldProps","onChange","path","readOnly","value","initialConfig","setInitialConfig","useState","useEffect","newInitialConfig","editable","editorState","JSON","stringify","undefined","namespace","lexical","nodes","onError","error","theme","features","hooks","load","length","forEach","hook","incomingEditorState","Error","Array","isArray","p","key","div","className"],"mappings":"AAAA;AAIA,OAAOA,2BAA2B,oCAAmC;AACrE,MAAM,EAAEC,eAAe,EAAE,GAAGD;AAK5B,YAAYE,WAAW,QAAO;AAI9B,SAASC,iBAAiBC,sBAAsB,QAAQ,qBAAoB;AAC5E,SAASC,oBAAoB,QAAQ,0CAAyC;AAC9E,SAASC,eAAe,QAAQ,mBAAkB;AAclD,OAAO,MAAMC,kBAAkD,CAACC;IAC9D,MAAM,EAAEC,YAAY,EAAEC,UAAU,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGL;IAC/D,IAAI,EAAEM,KAAK,EAAE,GAAGN;IAEhB,MAAM,CAACO,eAAeC,iBAAiB,GAAGd,MAAMe,QAAQ,CAA2B;IAEnF,iGAAiG;IACjGf,MAAMgB,SAAS,CAAC;QACd,MAAMC,mBAAsC;YAC1CC,UAAUP,aAAa;YACvBQ,aAAaP,SAAS,OAAOQ,KAAKC,SAAS,CAACT,SAASU;YACrDC,WAAWhB,aAAaiB,OAAO,CAACD,SAAS;YACzCE,OAAO;mBAAIrB,gBAAgB;oBAAEG;gBAAa;aAAG;YAC7CmB,SAAS,CAACC;gBACR,MAAMA;YACR;YACAC,OAAOrB,aAAaiB,OAAO,CAACI,KAAK;QACnC;QACAd,iBAAiBG;IACnB,GAAG;QAACV;QAAcI;QAAUC;KAAM;IAElC,IAAIL,cAAcsB,UAAUC,OAAOC,MAAMC,QAAQ;QAC/CzB,aAAasB,QAAQ,CAACC,KAAK,CAACC,IAAI,CAACE,OAAO,CAAC,CAACC;YACxCtB,QAAQsB,KAAK;gBAAEC,qBAAqBvB;YAAM;QAC5C;IACF;IAEA,IAAIA,SAAS,OAAOA,UAAU,UAAU;QACtC,MAAM,IAAIwB,MACR,kLACEhB,KAAKC,SAAS,CAACT;IAErB;IAEA,IAAIA,SAASyB,MAAMC,OAAO,CAAC1B,UAAU,CAAE,CAAA,UAAUA,KAAI,GAAI;QACvD,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAIxB,SAAS,iBAAiBA,OAAO;QACnC,MAAM,IAAIwB,MACR;IAEJ;IAEA,IAAI,CAACvB,eAAe;QAClB,qBAAO,oBAAC0B,WAAE;IACZ;IAEA,qBACE,oBAACxC;QAAgBc,eAAeA;QAAe2B,KAAK9B;qBAClD,oBAACP;QAAqBI,cAAcA;QAAcC,YAAYA;qBAC5D,oBAACiC;QAAIC,WAAU;qBACb,oBAACxC;QAAuBK,cAAcA;QAAcE,UAAUA;;AAKxE,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorConfigProvider.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditorConfigProvider.d.ts","sourceRoot":"","sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAA;AAEjE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAA;AAM9D,UAAU,WAAW;IACnB,YAAY,EAAE,2BAA2B,CAAA;IACzC,KAAK,EAAE,aAAa,GAAG;QACrB,YAAY,EAAE,2BAA2B,CAAA;QACzC,IAAI,EAAE,MAAM,CAAA;QACZ,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,CAAA;KACnD,CAAA;IACD,IAAI,EAAE,MAAM,CAAA;CACb;AAQD,eAAO,MAAM,oBAAoB;cAKrB,MAAM,SAAS;kBACX,2BAA2B;;sBAEzB,2BAA2B;cACnC,MAAM;8BACU,IAAI,MAAM,EAAE,MAAM,SAAS,CAAC;;MAElD,MAAM,SAeT,CAAA;AAED,eAAO,MAAM,sBAAsB,QAAO,WAMzC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\nimport type { FormFieldBase } from '@payloadcms/ui'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\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}\ninterface ContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<ContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): ContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"mappings":"AAAA;
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/config/client/EditorConfigProvider.tsx"],"sourcesContent":["'use client'\n\nimport type { FormFieldBase } from '@payloadcms/ui/fields/shared'\n\nimport * as React from 'react'\nimport { createContext, useContext, useEffect, useMemo, useState } from 'react'\n\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}\ninterface ContextType {\n editorConfig: SanitizedClientEditorConfig\n field: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n uuid: string\n}\n\nconst Context: React.Context<ContextType> = createContext({\n editorConfig: null,\n field: null,\n uuid: generateQuickGuid(),\n})\n\nexport const EditorConfigProvider = ({\n children,\n editorConfig,\n fieldProps,\n}: {\n children: React.ReactNode\n editorConfig: SanitizedClientEditorConfig\n fieldProps: FormFieldBase & {\n editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n name: string\n richTextComponentMap: Map<string, React.ReactNode>\n }\n}): React.ReactNode => {\n // State to store the UUID\n const [uuid, setUuid] = useState(generateQuickGuid())\n\n // When the component mounts, generate a new UUID only once\n useEffect(() => {\n setUuid(generateQuickGuid())\n }, [])\n\n const editorContext = useMemo(\n () => ({ editorConfig, field: fieldProps, uuid }),\n [editorConfig, fieldProps, uuid],\n )\n\n return <Context.Provider value={editorContext}>{children}</Context.Provider>\n}\n\nexport const useEditorConfigContext = (): ContextType => {\n const context = useContext(Context)\n if (context === undefined) {\n throw new Error('useEditorConfigContext must be used within an EditorConfigProvider')\n }\n return context\n}\n"],"names":["React","createContext","useContext","useEffect","useMemo","useState","generateQuickGuid","Math","random","toString","substring","Context","editorConfig","field","uuid","EditorConfigProvider","children","fieldProps","setUuid","editorContext","Provider","value","useEditorConfigContext","context","undefined","Error"],"mappings":"AAAA;AAIA,YAAYA,WAAW,QAAO;AAC9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AAI/E,4DAA4D;AAC5D,SAASC;IACP,OAAOC,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG,MAAMH,KAAKC,MAAM,GAAGC,QAAQ,CAAC,IAAIC,SAAS,CAAC,GAAG;AAC/F;AAWA,MAAMC,wBAAsCV,cAAc;IACxDW,cAAc;IACdC,OAAO;IACPC,MAAMR;AACR;AAEA,OAAO,MAAMS,uBAAuB,CAAC,EACnCC,QAAQ,EACRJ,YAAY,EACZK,UAAU,EASX;IACC,0BAA0B;IAC1B,MAAM,CAACH,MAAMI,QAAQ,GAAGb,SAASC;IAEjC,2DAA2D;IAC3DH,UAAU;QACRe,QAAQZ;IACV,GAAG,EAAE;IAEL,MAAMa,gBAAgBf,QACpB,IAAO,CAAA;YAAEQ;YAAcC,OAAOI;YAAYH;QAAK,CAAA,GAC/C;QAACF;QAAcK;QAAYH;KAAK;IAGlC,qBAAO,oBAACH,QAAQS,QAAQ;QAACC,OAAOF;OAAgBH;AAClD,EAAC;AAED,OAAO,MAAMM,yBAAyB;IACpC,MAAMC,UAAUrB,WAAWS;IAC3B,IAAIY,YAAYC,WAAW;QACzB,MAAM,IAAIC,MAAM;IAClB;IACA,OAAOF;AACT,EAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js';
|
|
3
3
|
const { useLexicalComposerContext } = lexicalComposerContextImport;
|
|
4
|
-
import { useTranslation } from '@payloadcms/ui';
|
|
4
|
+
import { useTranslation } from '@payloadcms/ui/providers/Translation';
|
|
5
5
|
import { useCallback, useMemo, useState } from 'react';
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import * as ReactDOM from 'react-dom';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport { useTranslation } from '@payloadcms/ui'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type { SlashMenuGroup, SlashMenuOption } from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport './index.scss'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n onClick,\n onMouseEnter,\n option,\n}: {\n index: number\n isSelected: boolean\n onClick: () => void\n onMouseEnter: () => void\n option: SlashMenuOption\n}) {\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${option.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = option.key\n if (option.displayName) {\n title =\n typeof option.displayName === 'function' ? option.displayName({ i18n }) : option.displayName\n }\n // Crop title to max. 50 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + option.key}\n key={option.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={option.setRefElement}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {option?.Icon && <option.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicOptions = useCallback(() => {\n let groupWithOptions: Array<SlashMenuGroup> = []\n\n for (const dynamicOption of editorConfig.features.slashMenu.dynamicOptions) {\n const dynamicGroupWithOptions = dynamicOption({\n editor,\n queryString,\n })\n groupWithOptions = groupWithOptions.concat(dynamicGroupWithOptions)\n }\n\n return groupWithOptions\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithOptions: SlashMenuGroup[] = []\n for (const groupWithOption of editorConfig?.features.slashMenu.groupsWithOptions ?? []) {\n groupsWithOptions.push(groupWithOption)\n }\n\n if (queryString) {\n // Filter current groups first\n groupsWithOptions = groupsWithOptions.map((group) => {\n const filteredOptions = group.options.filter((option) => {\n let optionTitle = option.key\n if (option.displayName) {\n optionTitle =\n typeof option.displayName === 'function'\n ? option.displayName({ i18n })\n : option.displayName\n }\n\n return new RegExp(queryString, 'gi').exec(optionTitle) || option.keywords != null\n ? option.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n : false\n })\n if (filteredOptions.length) {\n return {\n ...group,\n options: filteredOptions,\n }\n }\n return null\n })\n\n groupsWithOptions = groupsWithOptions.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicOptionGroups = getDynamicOptions()\n\n // merge dynamic options into groups\n for (const dynamicGroup of dynamicOptionGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithOptions.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n options: [],\n }\n } else {\n groupsWithOptions = groupsWithOptions.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.options?.length) {\n group.options = group.options.concat(group.options)\n }\n groupsWithOptions.push(group)\n }\n }\n\n return groupsWithOptions\n }, [getDynamicOptions, queryString, editorConfig?.features, i18n])\n\n const onSelectOption = useCallback(\n (\n selectedOption: SlashMenuOption,\n nodeToRemove: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => {\n editor.update(() => {\n if (nodeToRemove) {\n nodeToRemove.remove()\n }\n selectedOption.onSelect({ editor, queryString: matchingString })\n closeMenu()\n })\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groupsWithOptions={groups}\n menuRenderFn={(\n anchorElementRef,\n { selectOptionAndCleanUp, selectedOptionKey, setSelectedOptionKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.displayName) {\n groupTitle =\n typeof group.displayName === 'function'\n ? group.displayName({ i18n })\n : group.displayName\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.options.map((option, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedOptionKey === option.key}\n key={option.key}\n onClick={() => {\n setSelectedOptionKey(option.key)\n selectOptionAndCleanUp(option)\n }}\n onMouseEnter={() => {\n setSelectedOptionKey(option.key)\n }}\n option={option}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n onSelectOption={onSelectOption}\n triggerFn={checkForTriggerMatch}\n />\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","onClick","onMouseEnter","option","i18n","className","key","title","displayName","length","substring","button","aria-selected","id","ref","setRefElement","role","tabIndex","type","Icon","span","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicOptions","groupWithOptions","dynamicOption","features","slashMenu","dynamicOptions","dynamicGroupWithOptions","concat","groups","groupsWithOptions","groupWithOption","push","map","group","filteredOptions","options","filter","optionTitle","RegExp","exec","keywords","some","keyword","dynamicOptionGroups","dynamicGroup","find","onSelectOption","selectedOption","nodeToRemove","closeMenu","matchingString","update","remove","onSelect","Fragment","menuRenderFn","anchorElementRef","selectOptionAndCleanUp","selectedOptionKey","setSelectedOptionKey","current","createPortal","div","groupTitle","oi","index","onQueryChange","triggerFn"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,SAASE,cAAc,QAAQ,iBAAgB;AAC/C,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,YAAYC,WAAW,QAAO;AAC9B,YAAYC,cAAc,YAAW;AAIrC,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,0BAA0B,QAAQ,wCAAuC;AAClF,OAAO,eAAc;AACrB,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,MAAMC,YAAY;AAElB,SAASC,cAAc,EACrBC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,MAAM,EAOP;IACC,MAAM,EAAEC,IAAI,EAAE,GAAGf;IAEjB,IAAIgB,YAAY,CAAC,EAAEP,UAAU,OAAO,EAAEA,UAAU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AW,CAAC,EAAEP,UAAU,aAAa,CAAC;mBAAG4E,aAC7C9B,MAAME,OAAO,CAACH,GAAG,CAAC,CAACxC,QAAQwE,mBAC1B,oBAAC5E;wBACC6E,OAAOD;wBACP3E,YAAYqE,sBAAsBlE,OAAOG,GAAG;wBAC5CA,KAAKH,OAAOG,GAAG;wBACfL,SAAS;4BACPqE,qBAAqBnE,OAAOG,GAAG;4BAC/B8D,uBAAuBjE;wBACzB;wBACAD,cAAc;4BACZoE,qBAAqBnE,OAAOG,GAAG;wBACjC;wBACAH,QAAQA;;YAKlB,KAEFgE,iBAAiBI,OAAO,IAE1B;QAENM,eAAelD;QACf8B,gBAAgBA;QAChBqB,WAAWjD;;AAInB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/field/lexical/plugins/SlashMenu/index.tsx"],"sourcesContent":["'use client'\nimport type { TextNode } from 'lexical'\n\nimport lexicalComposerContextImport from '@lexical/react/LexicalComposerContext.js'\nconst { useLexicalComposerContext } = lexicalComposerContextImport\n\nimport { useTranslation } from '@payloadcms/ui/providers/Translation'\nimport { useCallback, useMemo, useState } from 'react'\nimport * as React from 'react'\nimport * as ReactDOM from 'react-dom'\n\nimport type { SlashMenuGroup, SlashMenuOption } from './LexicalTypeaheadMenuPlugin/types.js'\n\nimport { useEditorConfigContext } from '../../config/client/EditorConfigProvider.js'\nimport { LexicalTypeaheadMenuPlugin } from './LexicalTypeaheadMenuPlugin/index.js'\nimport './index.scss'\nimport { useMenuTriggerMatch } from './useMenuTriggerMatch.js'\n\nconst baseClass = 'slash-menu-popup'\n\nfunction SlashMenuItem({\n isSelected,\n onClick,\n onMouseEnter,\n option,\n}: {\n index: number\n isSelected: boolean\n onClick: () => void\n onMouseEnter: () => void\n option: SlashMenuOption\n}) {\n const { i18n } = useTranslation()\n\n let className = `${baseClass}__item ${baseClass}__item-${option.key}`\n if (isSelected) {\n className += ` ${baseClass}__item--selected`\n }\n\n let title = option.key\n if (option.displayName) {\n title =\n typeof option.displayName === 'function' ? option.displayName({ i18n }) : option.displayName\n }\n // Crop title to max. 50 characters\n if (title.length > 25) {\n title = title.substring(0, 25) + '...'\n }\n\n return (\n <button\n aria-selected={isSelected}\n className={className}\n id={baseClass + '__item-' + option.key}\n key={option.key}\n onClick={onClick}\n onMouseEnter={onMouseEnter}\n ref={option.setRefElement}\n role=\"option\"\n tabIndex={-1}\n type=\"button\"\n >\n {option?.Icon && <option.Icon />}\n\n <span className={`${baseClass}__item-text`}>{title}</span>\n </button>\n )\n}\n\nexport function SlashMenuPlugin({\n anchorElem = document.body,\n}: {\n anchorElem?: HTMLElement\n}): JSX.Element {\n const [editor] = useLexicalComposerContext()\n const [queryString, setQueryString] = useState<null | string>(null)\n const { editorConfig } = useEditorConfigContext()\n const { i18n } = useTranslation()\n\n const checkForTriggerMatch = useMenuTriggerMatch('/', {\n minLength: 0,\n })\n\n const getDynamicOptions = useCallback(() => {\n let groupWithOptions: Array<SlashMenuGroup> = []\n\n for (const dynamicOption of editorConfig.features.slashMenu.dynamicOptions) {\n const dynamicGroupWithOptions = dynamicOption({\n editor,\n queryString,\n })\n groupWithOptions = groupWithOptions.concat(dynamicGroupWithOptions)\n }\n\n return groupWithOptions\n }, [editor, queryString, editorConfig?.features])\n\n const groups: SlashMenuGroup[] = useMemo(() => {\n let groupsWithOptions: SlashMenuGroup[] = []\n for (const groupWithOption of editorConfig?.features.slashMenu.groupsWithOptions ?? []) {\n groupsWithOptions.push(groupWithOption)\n }\n\n if (queryString) {\n // Filter current groups first\n groupsWithOptions = groupsWithOptions.map((group) => {\n const filteredOptions = group.options.filter((option) => {\n let optionTitle = option.key\n if (option.displayName) {\n optionTitle =\n typeof option.displayName === 'function'\n ? option.displayName({ i18n })\n : option.displayName\n }\n\n return new RegExp(queryString, 'gi').exec(optionTitle) || option.keywords != null\n ? option.keywords.some((keyword) => new RegExp(queryString, 'gi').exec(keyword))\n : false\n })\n if (filteredOptions.length) {\n return {\n ...group,\n options: filteredOptions,\n }\n }\n return null\n })\n\n groupsWithOptions = groupsWithOptions.filter((group) => group != null)\n\n // Now add dynamic groups\n const dynamicOptionGroups = getDynamicOptions()\n\n // merge dynamic options into groups\n for (const dynamicGroup of dynamicOptionGroups) {\n // 1. find the group with the same name or create new one\n let group = groupsWithOptions.find((group) => group.key === dynamicGroup.key)\n if (!group) {\n group = {\n ...dynamicGroup,\n options: [],\n }\n } else {\n groupsWithOptions = groupsWithOptions.filter((group) => group.key !== dynamicGroup.key)\n }\n\n // 2. Add options to group options array and add to sanitized.slashMenu.groupsWithOptions\n if (group?.options?.length) {\n group.options = group.options.concat(group.options)\n }\n groupsWithOptions.push(group)\n }\n }\n\n return groupsWithOptions\n }, [getDynamicOptions, queryString, editorConfig?.features, i18n])\n\n const onSelectOption = useCallback(\n (\n selectedOption: SlashMenuOption,\n nodeToRemove: TextNode | null,\n closeMenu: () => void,\n matchingString: string,\n ) => {\n editor.update(() => {\n if (nodeToRemove) {\n nodeToRemove.remove()\n }\n selectedOption.onSelect({ editor, queryString: matchingString })\n closeMenu()\n })\n },\n [editor],\n )\n\n return (\n <React.Fragment>\n <LexicalTypeaheadMenuPlugin\n anchorElem={anchorElem}\n groupsWithOptions={groups}\n menuRenderFn={(\n anchorElementRef,\n { selectOptionAndCleanUp, selectedOptionKey, setSelectedOptionKey },\n ) =>\n anchorElementRef.current && groups.length\n ? ReactDOM.createPortal(\n <div className={baseClass}>\n {groups.map((group) => {\n let groupTitle = group.key\n if (group.displayName) {\n groupTitle =\n typeof group.displayName === 'function'\n ? group.displayName({ i18n })\n : group.displayName\n }\n\n return (\n <div\n className={`${baseClass}__group ${baseClass}__group-${group.key}`}\n key={group.key}\n >\n <div className={`${baseClass}__group-title`}>{groupTitle}</div>\n {group.options.map((option, oi: number) => (\n <SlashMenuItem\n index={oi}\n isSelected={selectedOptionKey === option.key}\n key={option.key}\n onClick={() => {\n setSelectedOptionKey(option.key)\n selectOptionAndCleanUp(option)\n }}\n onMouseEnter={() => {\n setSelectedOptionKey(option.key)\n }}\n option={option}\n />\n ))}\n </div>\n )\n })}\n </div>,\n anchorElementRef.current,\n )\n : null\n }\n onQueryChange={setQueryString}\n onSelectOption={onSelectOption}\n triggerFn={checkForTriggerMatch}\n />\n </React.Fragment>\n )\n}\n"],"names":["lexicalComposerContextImport","useLexicalComposerContext","useTranslation","useCallback","useMemo","useState","React","ReactDOM","useEditorConfigContext","LexicalTypeaheadMenuPlugin","useMenuTriggerMatch","baseClass","SlashMenuItem","isSelected","onClick","onMouseEnter","option","i18n","className","key","title","displayName","length","substring","button","aria-selected","id","ref","setRefElement","role","tabIndex","type","Icon","span","SlashMenuPlugin","anchorElem","document","body","editor","queryString","setQueryString","editorConfig","checkForTriggerMatch","minLength","getDynamicOptions","groupWithOptions","dynamicOption","features","slashMenu","dynamicOptions","dynamicGroupWithOptions","concat","groups","groupsWithOptions","groupWithOption","push","map","group","filteredOptions","options","filter","optionTitle","RegExp","exec","keywords","some","keyword","dynamicOptionGroups","dynamicGroup","find","onSelectOption","selectedOption","nodeToRemove","closeMenu","matchingString","update","remove","onSelect","Fragment","menuRenderFn","anchorElementRef","selectOptionAndCleanUp","selectedOptionKey","setSelectedOptionKey","current","createPortal","div","groupTitle","oi","index","onQueryChange","triggerFn"],"mappings":"AAAA;AAGA,OAAOA,kCAAkC,2CAA0C;AACnF,MAAM,EAAEC,yBAAyB,EAAE,GAAGD;AAEtC,SAASE,cAAc,QAAQ,uCAAsC;AACrE,SAASC,WAAW,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACtD,YAAYC,WAAW,QAAO;AAC9B,YAAYC,cAAc,YAAW;AAIrC,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,0BAA0B,QAAQ,wCAAuC;AAClF,OAAO,eAAc;AACrB,SAASC,mBAAmB,QAAQ,2BAA0B;AAE9D,MAAMC,YAAY;AAElB,SAASC,cAAc,EACrBC,UAAU,EACVC,OAAO,EACPC,YAAY,EACZC,MAAM,EAOP;IACC,MAAM,EAAEC,I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GAAG,CAAC,CAAC;oBACjEA,KAAKsC,MAAMtC,GAAG;iCAEd,oBAACmE;oBAAIpE,WAAW,CAAC,EAAEP,UAAU,aAAa,CAAC;mBAAG4E,aAC7C9B,MAAME,OAAO,CAACH,GAAG,CAAC,CAACxC,QAAQwE,mBAC1B,oBAAC5E;wBACC6E,OAAOD;wBACP3E,YAAYqE,sBAAsBlE,OAAOG,GAAG;wBAC5CA,KAAKH,OAAOG,GAAG;wBACfL,SAAS;4BACPqE,qBAAqBnE,OAAOG,GAAG;4BAC/B8D,uBAAuBjE;wBACzB;wBACAD,cAAc;4BACZoE,qBAAqBnE,OAAOG,GAAG;wBACjC;wBACAH,QAAQA;;YAKlB,KAEFgE,iBAAiBI,OAAO,IAE1B;QAENM,eAAelD;QACf8B,gBAAgBA;QAChBqB,WAAWjD;;AAInB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateComponentMap.d.ts","sourceRoot":"","sources":["../src/generateComponentMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAMpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"generateComponentMap.d.ts","sourceRoot":"","sources":["../src/generateComponentMap.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAMpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAKzE,eAAO,MAAM,uBAAuB,SAC3B;IACL,kBAAkB,EAAE,wBAAwB,CAAA;CAC7C,KAAG,eAAe,CAAC,sBAAsB,CA8GzC,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { mapFields } from '@payloadcms/ui/utilities';
|
|
1
|
+
import { mapFields } from '@payloadcms/ui/utilities/buildComponentMap';
|
|
2
2
|
import { sanitizeFields } from 'payload/config';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { cloneDeep } from './field/lexical/utils/cloneDeep.js';
|
|
4
5
|
export const getGenerateComponentMap = (args)=>({ config, schemaPath })=>{
|
|
5
6
|
const validRelationships = config.collections.map((c)=>c.slug) || [];
|
|
6
7
|
const componentMap = new Map();
|
|
@@ -41,13 +42,14 @@ export const getGenerateComponentMap = (args)=>({ config, schemaPath })=>{
|
|
|
41
42
|
const fields = schemas[schemaKey];
|
|
42
43
|
const sanitizedFields = sanitizeFields({
|
|
43
44
|
config,
|
|
44
|
-
fields,
|
|
45
|
+
fields: cloneDeep(fields),
|
|
45
46
|
validRelationships
|
|
46
47
|
});
|
|
47
48
|
const mappedFields = mapFields({
|
|
48
49
|
config,
|
|
50
|
+
disableAddingID: true,
|
|
49
51
|
fieldSchema: sanitizedFields,
|
|
50
|
-
|
|
52
|
+
parentPath: `${schemaPath}.feature.${featureKey}.fields.${schemaKey}`,
|
|
51
53
|
readOnly: false
|
|
52
54
|
});
|
|
53
55
|
componentMap.set(`feature.${featureKey}.fields.${schemaKey}`, mappedFields);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateComponentMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { mapFields } from '@payloadcms/ui/utilities'\nimport { sanitizeFields } from 'payload/config'\nimport React from 'react'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { GeneratedFeatureProviderComponent } from './types.js'\n\nexport const getGenerateComponentMap =\n (args: {\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateComponentMap'] =>\n ({ config, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const componentMap = new Map()\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(args.resolvedFeatureMap.entries()).sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n componentMap.set(\n `features`,\n resolvedFeatureMapArray\n .map(([featureKey, resolvedFeature]) => {\n const ClientComponent = resolvedFeature.ClientComponent\n const clientComponentProps = resolvedFeature.clientFeatureProps\n\n /**\n * Handle Feature Component Maps\n */\n if (\n 'generateComponentMap' in resolvedFeature &&\n typeof resolvedFeature.generateComponentMap === 'function'\n ) {\n const components = resolvedFeature.generateComponentMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaPath,\n })\n\n for (const componentKey in components) {\n const Component = components[componentKey]\n if (Component) {\n componentMap.set(\n `feature.${featureKey}.components.${componentKey}`,\n <Component\n componentKey={componentKey}\n featureKey={resolvedFeature.key}\n key={`${resolvedFeature.key}-${componentKey}`}\n />,\n )\n }\n }\n }\n\n /**\n * Handle Feature Schema Maps (rendered fields)\n */\n if (\n 'generateSchemaMap' in resolvedFeature &&\n typeof resolvedFeature.generateSchemaMap === 'function'\n ) {\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap: new Map(),\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields,\n validRelationships,\n })\n\n const mappedFields = mapFields({\n config,\n fieldSchema: sanitizedFields,\n
|
|
1
|
+
{"version":3,"sources":["../src/generateComponentMap.tsx"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { mapFields } from '@payloadcms/ui/utilities/buildComponentMap'\nimport { sanitizeFields } from 'payload/config'\nimport React from 'react'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { GeneratedFeatureProviderComponent } from './types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateComponentMap =\n (args: {\n resolvedFeatureMap: ResolvedServerFeatureMap\n }): RichTextAdapter['generateComponentMap'] =>\n ({ config, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n const componentMap = new Map()\n\n // turn args.resolvedFeatureMap into an array of [key, value] pairs, ordered by value.order, lowest order first:\n const resolvedFeatureMapArray = Array.from(args.resolvedFeatureMap.entries()).sort(\n (a, b) => a[1].order - b[1].order,\n )\n\n componentMap.set(\n `features`,\n resolvedFeatureMapArray\n .map(([featureKey, resolvedFeature]) => {\n const ClientComponent = resolvedFeature.ClientComponent\n const clientComponentProps = resolvedFeature.clientFeatureProps\n\n /**\n * Handle Feature Component Maps\n */\n if (\n 'generateComponentMap' in resolvedFeature &&\n typeof resolvedFeature.generateComponentMap === 'function'\n ) {\n const components = resolvedFeature.generateComponentMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaPath,\n })\n\n for (const componentKey in components) {\n const Component = components[componentKey]\n\n if (Component) {\n componentMap.set(\n `feature.${featureKey}.components.${componentKey}`,\n <Component\n componentKey={componentKey}\n featureKey={resolvedFeature.key}\n key={`${resolvedFeature.key}-${componentKey}`}\n />,\n )\n }\n }\n }\n\n /**\n * Handle Feature Schema Maps (rendered fields)\n */\n if (\n 'generateSchemaMap' in resolvedFeature &&\n typeof resolvedFeature.generateSchemaMap === 'function'\n ) {\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap: new Map(),\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n validRelationships,\n })\n\n const mappedFields = mapFields({\n config,\n disableAddingID: true,\n fieldSchema: sanitizedFields,\n parentPath: `${schemaPath}.feature.${featureKey}.fields.${schemaKey}`,\n readOnly: false,\n })\n\n componentMap.set(`feature.${featureKey}.fields.${schemaKey}`, mappedFields)\n }\n }\n\n if (!ClientComponent) {\n return null\n }\n\n return {\n ClientComponent:\n clientComponentProps && typeof clientComponentProps === 'object' ? (\n <ClientComponent\n {...clientComponentProps}\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ) : (\n <ClientComponent\n featureKey={resolvedFeature.key}\n key={resolvedFeature.key}\n order={resolvedFeature.order}\n />\n ),\n key: resolvedFeature.key,\n order: resolvedFeature.order,\n } as GeneratedFeatureProviderComponent\n })\n .filter((feature) => feature !== null),\n )\n\n return componentMap\n }\n"],"names":["mapFields","sanitizeFields","React","cloneDeep","getGenerateComponentMap","args","config","schemaPath","validRelationships","collections","map","c","slug","componentMap","Map","resolvedFeatureMapArray","Array","from","resolvedFeatureMap","entries","sort","a","b","order","set","featureKey","resolvedFeature","ClientComponent","clientComponentProps","clientFeatureProps","generateComponentMap","components","props","serverFeatureProps","componentKey","Component","key","generateSchemaMap","schemas","schemaMap","schemaKey","fields","sanitizedFields","mappedFields","disableAddingID","fieldSchema","parentPath","readOnly","filter","feature"],"mappings":"AAEA,SAASA,SAAS,QAAQ,6CAA4C;AACtE,SAASC,cAAc,QAAQ,iBAAgB;AAC/C,OAAOC,WAAW,QAAO;AAKzB,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,0BACX,CAACC,OAGD,CAAC,EAAEC,MAAM,EAAEC,UAAU,EAAE;QACrB,MAAMC,qBAAqBF,OAAOG,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,MAAMC,eAAe,IAAIC;QAEzB,gHAAgH;QAChH,MAAMC,0BAA0BC,MAAMC,IAAI,CAACZ,KAAKa,kBAAkB,CAACC,OAAO,IAAIC,IAAI,CAChF,CAACC,GAAGC,IAAMD,CAAC,CAAC,EAAE,CAACE,KAAK,GAAGD,CAAC,CAAC,EAAE,CAACC,KAAK;QAGnCV,aAAaW,GAAG,CACd,CAAC,QAAQ,CAAC,EACVT,wBACGL,GAAG,CAAC,CAAC,CAACe,YAAYC,gBAAgB;YACjC,MAAMC,kBAAkBD,gBAAgBC,eAAe;YACvD,MAAMC,uBAAuBF,gBAAgBG,kBAAkB;YAE/D;;WAEC,GACD,IACE,0BAA0BH,mBAC1B,OAAOA,gBAAgBI,oBAAoB,KAAK,YAChD;gBACA,MAAM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AKV,gBAAgBU,GAAG;oBACxBb,OAAOG,gBAAgBH,KAAK;mCAG9B,oBAACI;oBACCF,YAAYC,gBAAgBU,GAAG;oBAC/BA,KAAKV,gBAAgBU,GAAG;oBACxBb,OAAOG,gBAAgBH,KAAK;;gBAGlCa,KAAKV,gBAAgBU,GAAG;gBACxBb,OAAOG,gBAAgBH,KAAK;YAC9B;QACF,GACCyB,MAAM,CAAC,CAACC,UAAYA,YAAY;QAGrC,OAAOpC;IACT,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateSchemaMap.d.ts","sourceRoot":"","sources":["../src/generateSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;
|
|
1
|
+
{"version":3,"file":"generateSchemaMap.d.ts","sourceRoot":"","sources":["../src/generateSchemaMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAIpD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAA;AAIzE,eAAO,MAAM,oBAAoB,SACxB;IAAE,kBAAkB,EAAE,wBAAwB,CAAA;CAAE,KAAG,eAAe,CAAC,mBAAmB,CAgC5F,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { sanitizeFields } from 'payload/config';
|
|
2
|
+
import { cloneDeep } from './field/lexical/utils/cloneDeep.js';
|
|
2
3
|
export const getGenerateSchemaMap = (args)=>({ config, schemaMap, schemaPath })=>{
|
|
3
4
|
const validRelationships = config.collections.map((c)=>c.slug) || [];
|
|
4
5
|
for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()){
|
|
@@ -15,7 +16,7 @@ export const getGenerateSchemaMap = (args)=>({ config, schemaMap, schemaPath })=
|
|
|
15
16
|
const fields = schemas[schemaKey];
|
|
16
17
|
const sanitizedFields = sanitizeFields({
|
|
17
18
|
config,
|
|
18
|
-
fields,
|
|
19
|
+
fields: cloneDeep(fields),
|
|
19
20
|
validRelationships
|
|
20
21
|
});
|
|
21
22
|
schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, schemaMap, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields,\n validRelationships,\n })\n\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields)\n }\n }\n\n return schemaMap\n }\n"],"names":["sanitizeFields","getGenerateSchemaMap","args","config","schemaMap","schemaPath","validRelationships","collections","map","c","slug","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","serverFeatureProps","schemaKey","fields","sanitizedFields","set"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,OAAO,MAAMC,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE;QAChC,MAAMC,qBAAqBH,OAAOI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIV,KAAKW,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDZ;gBACAc,OAAOL,gBAAgBM,kBAAkB;gBACzCd;gBACAC;YACF;YAEA,IAAK,MAAMc,aAAaH,QAAS;gBAC/B,MAAMI,SAASJ,OAAO,CAACG,UAAU;gBAEjC,MAAME,
|
|
1
|
+
{"version":3,"sources":["../src/generateSchemaMap.ts"],"sourcesContent":["import type { RichTextAdapter } from 'payload/types'\n\nimport { sanitizeFields } from 'payload/config'\n\nimport type { ResolvedServerFeatureMap } from './field/features/types.js'\n\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\n\nexport const getGenerateSchemaMap =\n (args: { resolvedFeatureMap: ResolvedServerFeatureMap }): RichTextAdapter['generateSchemaMap'] =>\n ({ config, schemaMap, schemaPath }) => {\n const validRelationships = config.collections.map((c) => c.slug) || []\n\n for (const [featureKey, resolvedFeature] of args.resolvedFeatureMap.entries()) {\n if (\n !('generateSchemaMap' in resolvedFeature) ||\n typeof resolvedFeature.generateSchemaMap !== 'function'\n ) {\n continue\n }\n const schemas = resolvedFeature.generateSchemaMap({\n config,\n props: resolvedFeature.serverFeatureProps,\n schemaMap,\n schemaPath,\n })\n\n for (const schemaKey in schemas) {\n const fields = schemas[schemaKey]\n\n const sanitizedFields = sanitizeFields({\n config,\n fields: cloneDeep(fields),\n validRelationships,\n })\n\n schemaMap.set(`${schemaPath}.feature.${featureKey}.${schemaKey}`, sanitizedFields)\n }\n }\n\n return schemaMap\n }\n"],"names":["sanitizeFields","cloneDeep","getGenerateSchemaMap","args","config","schemaMap","schemaPath","validRelationships","collections","map","c","slug","featureKey","resolvedFeature","resolvedFeatureMap","entries","generateSchemaMap","schemas","props","serverFeatureProps","schemaKey","fields","sanitizedFields","set"],"mappings":"AAEA,SAASA,cAAc,QAAQ,iBAAgB;AAI/C,SAASC,SAAS,QAAQ,qCAAoC;AAE9D,OAAO,MAAMC,uBACX,CAACC,OACD,CAAC,EAAEC,MAAM,EAAEC,SAAS,EAAEC,UAAU,EAAE;QAChC,MAAMC,qBAAqBH,OAAOI,WAAW,CAACC,GAAG,CAAC,CAACC,IAAMA,EAAEC,IAAI,KAAK,EAAE;QAEtE,KAAK,MAAM,CAACC,YAAYC,gBAAgB,IAAIV,KAAKW,kBAAkB,CAACC,OAAO,GAAI;YAC7E,IACE,CAAE,CAAA,uBAAuBF,eAAc,KACvC,OAAOA,gBAAgBG,iBAAiB,KAAK,YAC7C;gBACA;YACF;YACA,MAAMC,UAAUJ,gBAAgBG,iBAAiB,CAAC;gBAChDZ;gBACAc,OAAOL,gBAAgBM,kBAAkB;gBACzCd;gBACAC;YACF;YAEA,IAAK,MAAMc,aAAaH,QAAS;gBAC/B,MAAMI,SAASJ,OAAO,CAACG,UAAU;gBAEjC,MAAME,kBAAkBtB,eAAe;oBACrCI;oBACAiB,QAAQpB,UAAUoB;oBAClBd;gBACF;gBAEAF,UAAUkB,GAAG,CAAC,CAAC,EAAEjB,WAAW,SAAS,EAAEM,WAAW,CAAC,EAAEQ,UAAU,CAAC,EAAEE;YACpE;QACF;QAEA,OAAOjB;IACT,EAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot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AAoB,EACpB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import { withMergedProps } from '@payloadcms/ui/elements/withMergedProps';
|
|
1
2
|
import { withNullableJSONSchemaType } from 'payload/utilities';
|
|
3
|
+
import { RichTextCell } from './cell/index.js';
|
|
4
|
+
import { RichTextField } from './field/index.js';
|
|
2
5
|
import { defaultEditorConfig, defaultEditorFeatures, defaultSanitizedServerEditorConfig } from './field/lexical/config/server/default.js';
|
|
3
6
|
import { loadFeatures } from './field/lexical/config/server/loader.js';
|
|
4
7
|
import { sanitizeServerFeatures } from './field/lexical/config/server/sanitize.js';
|
|
@@ -35,25 +38,18 @@ export function lexicalEditor(props) {
|
|
|
35
38
|
};
|
|
36
39
|
}
|
|
37
40
|
return {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return import('@payloadcms/ui').then((module2)=>module2.withMergedProps({
|
|
51
|
-
Component: RichTextField,
|
|
52
|
-
toMergeIntoProps: {
|
|
53
|
-
lexicalEditorConfig: finalSanitizedEditorConfig.lexical
|
|
54
|
-
}
|
|
55
|
-
}));
|
|
56
|
-
}),
|
|
41
|
+
CellComponent: withMergedProps({
|
|
42
|
+
Component: RichTextCell,
|
|
43
|
+
toMergeIntoProps: {
|
|
44
|
+
lexicalEditorConfig: finalSanitizedEditorConfig.lexical
|
|
45
|
+
}
|
|
46
|
+
}),
|
|
47
|
+
FieldComponent: withMergedProps({
|
|
48
|
+
Component: RichTextField,
|
|
49
|
+
toMergeIntoProps: {
|
|
50
|
+
lexicalEditorConfig: finalSanitizedEditorConfig.lexical
|
|
51
|
+
}
|
|
52
|
+
}),
|
|
57
53
|
afterReadPromise: ({ field, incomingEditorState, siblingDoc })=>{
|
|
58
54
|
return new Promise((resolve, reject)=>{
|
|
59
55
|
const promises = [];
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type { SerializedEditorState } from 'lexical'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\nimport type { RichTextAdapter } from 'payload/types'\n\nimport { withNullableJSONSchemaType } from 'payload/utilities'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { SanitizedServerEditorConfig } from './field/lexical/config/types.js'\nimport type { AdapterProps } from './types.js'\n\nimport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultSanitizedServerEditorConfig,\n} from './field/lexical/config/server/default.js'\nimport { loadFeatures } from './field/lexical/config/server/loader.js'\nimport { sanitizeServerFeatures } from './field/lexical/config/server/sanitize.js'\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\nimport { getGenerateComponentMap } from './generateComponentMap.js'\nimport { getGenerateSchemaMap } from './generateSchemaMap.js'\nimport { richTextRelationshipPromise } from './populate/richTextRelationshipPromise.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nexport type LexicalEditorProps = {\n features?:\n | (({\n defaultFeatures,\n }: {\n defaultFeatures: FeatureProviderServer<unknown, unknown>[]\n }) => FeatureProviderServer<unknown, unknown>[])\n | FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type LexicalRichTextAdapter = RichTextAdapter<SerializedEditorState, AdapterProps, any> & {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapter {\n let resolvedFeatureMap: ResolvedServerFeatureMap = null\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!props || (!props.features && !props.lexical)) {\n finalSanitizedEditorConfig = cloneDeep(defaultSanitizedServerEditorConfig)\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n let features: FeatureProviderServer<unknown, unknown>[] =\n props.features && typeof props.features === 'function'\n ? props.features({ defaultFeatures: cloneDeep(defaultEditorFeatures) })\n : (props.features as FeatureProviderServer<unknown, unknown>[])\n if (!features) {\n features = cloneDeep(defaultEditorFeatures)\n }\n\n const lexical: LexicalEditorConfig = props.lexical\n\n resolvedFeatureMap = loadFeatures({\n unSanitizedEditorConfig: {\n features,\n lexical: lexical ? lexical : defaultEditorConfig.lexical,\n },\n })\n\n finalSanitizedEditorConfig = {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: lexical ? lexical : defaultEditorConfig.lexical,\n resolvedFeatureMap,\n }\n }\n\n return {\n LazyCellComponent: () =>\n // @ts-expect-error\n import('./cell/index.js').then((module) => {\n const RichTextCell = module.RichTextCell\n return import('@payloadcms/ui').then((module2) =>\n module2.withMergedProps({\n Component: RichTextCell,\n toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical }, // lexicalEditorConfig is serializable\n }),\n )\n }),\n\n LazyFieldComponent: () =>\n import('./field/index.js').then((module) => {\n const RichTextField = module.RichTextField\n return import('@payloadcms/ui').then((module2) =>\n module2.withMergedProps({\n Component: RichTextField,\n toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical }, // lexicalEditorConfig is serializable\n }),\n )\n }),\n afterReadPromise: ({ field, incomingEditorState, siblingDoc }) => {\n return new Promise<void>((resolve, reject) => {\n const promises: Promise<void>[] = []\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterReadPromises?.length) {\n for (const afterReadPromise of finalSanitizedEditorConfig.features.hooks\n .afterReadPromises) {\n const promise = afterReadPromise({\n field,\n incomingEditorState,\n siblingDoc,\n })\n if (promise) {\n promises.push(promise)\n }\n }\n }\n\n Promise.all(promises)\n .then(() => resolve())\n .catch((error) => reject(error))\n })\n },\n editorConfig: finalSanitizedEditorConfig,\n generateComponentMap: getGenerateComponentMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n populationPromise({\n context,\n currentDepth,\n depth,\n field,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.populationPromises?.size) {\n return richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n editorPopulationPromises: finalSanitizedEditorConfig.features.populationPromises,\n field,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n\n return null\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n}\n\nexport { AlignFeature } from './field/features/align/feature.server.js'\nexport { BlockQuoteFeature } from './field/features/blockquote/feature.server.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './field/features/blocks/feature.server.js'\nexport {\n $createBlockNode,\n $isBlockNode,\n type BlockFields,\n BlockNode,\n type SerializedBlockNode,\n} from './field/features/blocks/nodes/BlocksNode.js'\n\nexport { TextDropdownSectionWithEntries } from './field/features/common/floatingSelectToolbarTextDropdownSection/index.js'\nexport { LinebreakHTMLConverter } from './field/features/converters/html/converter/converters/linebreak.js'\nexport { ParagraphHTMLConverter } from './field/features/converters/html/converter/converters/paragraph.js'\n\nexport { TextHTMLConverter } from './field/features/converters/html/converter/converters/text.js'\nexport { defaultHTMLConverters } from './field/features/converters/html/converter/defaultConverters.js'\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './field/features/converters/html/converter/index.js'\nexport type { HTMLConverter } from './field/features/converters/html/converter/types.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './field/features/converters/html/feature.server.js'\nexport { consolidateHTMLConverters } from './field/features/converters/html/field/index.js'\nexport { lexicalHTML } from './field/features/converters/html/field/index.js'\nexport { createClientComponent } from './field/features/createClientComponent.js'\nexport { TestRecorderFeature } from './field/features/debug/testrecorder/feature.server.js'\nexport { TreeViewFeature } from './field/features/debug/treeview/feature.server.js'\nexport { BoldFeature } from './field/features/format/bold/feature.server.js'\nexport { SectionWithEntries as FormatSectionWithEntries } from './field/features/format/common/floatingSelectToolbarSection.js'\nexport { InlineCodeFeature } from './field/features/format/inlinecode/feature.server.js'\nexport { ItalicFeature } from './field/features/format/italic/feature.server.js'\nexport { StrikethroughFeature } from './field/features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './field/features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './field/features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './field/features/format/underline/feature.server.js'\n\nexport { HeadingFeature } from './field/features/heading/feature.server.js'\nexport { IndentFeature } from './field/features/indent/feature.server.js'\n\nexport { LinkFeature, type LinkFeatureServerProps } from './field/features/link/feature.server.js'\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './field/features/link/nodes/AutoLinkNode.js'\nexport {\n $createLinkNode,\n $isLinkNode,\n LinkNode,\n TOGGLE_LINK_COMMAND,\n} from './field/features/link/nodes/LinkNode.js'\nexport type {\n LinkFields,\n SerializedAutoLinkNode,\n SerializedLinkNode,\n} from './field/features/link/nodes/types.js'\nexport { CheckListFeature } from './field/features/lists/checklist/feature.server.js'\nexport { OrderedListFeature } from './field/features/lists/orderedlist/feature.server.js'\nexport { UnorderedListFeature } from './field/features/lists/unorderedlist/feature.server.js'\nexport { LexicalPluginToLexicalFeature } from './field/features/migrations/lexicalPluginToLexical/feature.server.js'\nexport { SlateBlockquoteConverter } from './field/features/migrations/slateToLexical/converter/converters/blockquote/index.js'\nexport { SlateHeadingConverter } from './field/features/migrations/slateToLexical/converter/converters/heading/index.js'\nexport { SlateIndentConverter } from './field/features/migrations/slateToLexical/converter/converters/indent/index.js'\nexport { SlateLinkConverter } from './field/features/migrations/slateToLexical/converter/converters/link/index.js'\nexport { SlateListItemConverter } from './field/features/migrations/slateToLexical/converter/converters/listItem/index.js'\nexport { SlateOrderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/orderedList/index.js'\nexport { SlateRelationshipConverter } from './field/features/migrations/slateToLexical/converter/converters/relationship/index.js'\nexport { SlateUnknownConverter } from './field/features/migrations/slateToLexical/converter/converters/unknown/index.js'\nexport { SlateUnorderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/unorderedList/index.js'\n\nexport { SlateUploadConverter } from './field/features/migrations/slateToLexical/converter/converters/upload/index.js'\nexport { defaultSlateConverters } from './field/features/migrations/slateToLexical/converter/defaultConverters.js'\nexport {\n convertSlateNodesToLexical,\n convertSlateToLexical,\n} from './field/features/migrations/slateToLexical/converter/index.js'\n\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './field/features/migrations/slateToLexical/converter/types.js'\nexport { SlateToLexicalFeature } from './field/features/migrations/slateToLexical/feature.server.js'\nexport { ParagraphFeature } from './field/features/paragraph/feature.server.js'\nexport { RelationshipFeature } from './field/features/relationship/feature.server.js'\nexport {\n $createRelationshipNode,\n $isRelationshipNode,\n type RelationshipData,\n RelationshipNode,\n type SerializedRelationshipNode,\n} from './field/features/relationship/nodes/RelationshipNode.js'\nexport type {\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n PopulationPromise,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './field/features/types.js'\nexport { UploadFeature } from './field/features/upload/feature.server.js'\n\nexport type { UploadFeatureProps } from './field/features/upload/feature.server.js'\n\nexport type { RawUploadPayload } from './field/features/upload/nodes/UploadNode.js'\n\nexport {\n $createUploadNode,\n $isUploadNode,\n type SerializedUploadNode,\n type UploadData,\n UploadNode,\n} from './field/features/upload/nodes/UploadNode.js'\nexport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './field/lexical/config/client/EditorConfigProvider.js'\nexport {\n sanitizeClientEditorConfig,\n sanitizeClientFeatures,\n} from './field/lexical/config/client/sanitize.js'\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n defaultSanitizedServerEditorConfig,\n} from './field/lexical/config/server/default.js'\nexport {\n loadFeatures,\n sortFeaturesForOptimalLoading,\n} from './field/lexical/config/server/loader.js'\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './field/lexical/config/server/sanitize.js'\n\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './field/lexical/config/types.js'\nexport { getEnabledNodes } from './field/lexical/nodes/index.js'\n\nexport {\n type FloatingToolbarSection,\n type FloatingToolbarSectionEntry,\n} from './field/lexical/plugins/FloatingSelectToolbar/types.js'\nexport { ENABLE_SLASH_MENU_COMMAND } from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nexport type { AdapterProps }\n\nexport {\n SlashMenuGroup,\n SlashMenuOption,\n} from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport { CAN_USE_DOM } from './field/lexical/utils/canUseDOM.js'\nexport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\nexport { getDOMRangeRect } from './field/lexical/utils/getDOMRangeRect.js'\nexport { getSelectedNode } from './field/lexical/utils/getSelectedNode.js'\nexport { isHTMLElement } from './field/lexical/utils/guard.js'\nexport { invariant } from './field/lexical/utils/invariant.js'\nexport { joinClasses } from './field/lexical/utils/joinClasses.js'\nexport { createBlockNode } from './field/lexical/utils/markdown/createBlockNode.js'\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NON_BREAKING_SPACE,\n NodeFormat,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './field/lexical/utils/nodeFormat.js'\nexport { Point, isPoint } from './field/lexical/utils/point.js'\nexport { Rect } from './field/lexical/utils/rect.js'\nexport { setFloatingElemPosition } from './field/lexical/utils/setFloatingElemPosition.js'\nexport { setFloatingElemPositionForLinkEditor } from './field/lexical/utils/setFloatingElemPositionForLinkEditor.js'\nexport {\n addSwipeDownListener,\n addSwipeLeftListener,\n addSwipeRightListener,\n addSwipeUpListener,\n} from './field/lexical/utils/swipe.js'\nexport { sanitizeUrl, validateUrl } from './field/lexical/utils/url.js'\nexport { defaultRichTextValue } from './populate/defaultValue.js'\n"],"names":["withNullableJSONSchemaType","defaultEditorConfig","defaultEditorFeatures","defaultSanitizedServerEditorConfig","loadFeatures","sanitizeServerFeatures","cloneDeep","getGenerateComponentMap","getGenerateSchemaMap","richTextRelationshipPromise","richTextValidateHOC","lexicalEditor","props","resolvedFeatureMap","finalSanitizedEditorConfig","features","lexical","defaultFeatures","unSanitizedEditorConfig","LazyCellComponent","then","module","RichTextCell","module2","withMergedProps","Component","toMergeIntoProps","lexicalEditorConfig","LazyFieldComponent","RichTextField","afterReadPromise","field","incomingEditorState","siblingDoc","Promise","resolve","reject","promises","hooks","afterReadPromises","length","promise","push","all","catch","error","editorConfig","generateComponentMap","generateSchemaMap","outputSchema","collectionIDFieldTypes","config","interfaceNameDefinitions","isRequired","type","properties","root","additionalProperties","children","items","version","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","populationPromise","context","currentDepth","depth","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","size","editorPopulationPromises","validate","AlignFeature","BlockQuoteFeature","BlocksFeature","$createBlockNode","$isBlockNode","BlockNode","TextDropdownSectionWithEntries","LinebreakHTMLConverter","ParagraphHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","HTMLConverterFeature","consolidateHTMLConverters","lexicalHTML","createClientComponent","TestRecorderFeature","TreeViewFeature","BoldFeature","SectionWithEntries","FormatSectionWithEntries","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","IndentFeature","LinkFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","TOGGLE_LINK_COMMAND","CheckListFeature","OrderedListFeature","UnorderedListFeature","LexicalPluginToLexicalFeature","SlateBlockquoteConverter","SlateHeadingConverter","SlateIndentConverter","SlateLinkConverter","SlateListItemConverter","SlateOrderedListConverter","SlateRelationshipConverter","SlateUnknownConverter","SlateUnorderedListConverter","SlateUploadConverter","defaultSlateConverters","convertSlateNodesToLexical","convertSlateToLexical","SlateToLexicalFeature","ParagraphFeature","RelationshipFeature","$createRelationshipNode","$isRelationshipNode","RelationshipNode","UploadFeature","$createUploadNode","$isUploadNode","UploadNode","EditorConfigProvider","useEditorConfigContext","sanitizeClientEditorConfig","sanitizeClientFeatures","defaultEditorLexicalConfig","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","getEnabledNodes","ENABLE_SLASH_MENU_COMMAND","SlashMenuGroup","SlashMenuOption","CAN_USE_DOM","getDOMRangeRect","getSelectedNode","isHTMLElement","invariant","joinClasses","createBlockNode","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NON_BREAKING_SPACE","NodeFormat","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","Point","isPoint","Rect","setFloatingElemPosition","setFloatingElemPositionForLinkEditor","addSwipeDownListener","addSwipeLeftListener","addSwipeRightListener","addSwipeUpListener","sanitizeUrl","validateUrl","defaultRichTextValue"],"mappings":"AAKA,SAASA,0BAA0B,QAAQ,oBAAmB;AAM9D,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,kCAAkC,QAC7B,2CAA0C;AACjD,SAASC,YAAY,QAAQ,0CAAyC;AACtE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,SAA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SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,SAAS,QAAQ,qCAAoC;AAC9D,SAASC,WAAW,QAAQ,uCAAsC;AAClE,SAASC,eAAe,QAAQ,oDAAmD;AACnF,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,SAAS,EACTC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ,sCAAqC;AAC5C,SAASC,KAAK,EAAEC,OAAO,QAAQ,iCAAgC;AAC/D,SAASC,IAAI,QAAQ,gCAA+B;AACpD,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oCAAoC,QAAQ,gEAA+D;AACpH,SACEC,oBAAoB,EACpBC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb,iCAAgC;AACvC,SAASC,WAAW,EAAEC,WAAW,QAAQ,+BAA8B;AACvE,SAASC,oBAAoB,QAAQ,6BAA4B"}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { JSONSchema4 } from 'json-schema'\nimport type { SerializedEditorState } from 'lexical'\nimport type { EditorConfig as LexicalEditorConfig } from 'lexical/LexicalEditor.js'\nimport type { RichTextAdapter } from 'payload/types'\n\nimport { withMergedProps } from '@payloadcms/ui/elements/withMergedProps'\nimport { withNullableJSONSchemaType } from 'payload/utilities'\n\nimport type { FeatureProviderServer, ResolvedServerFeatureMap } from './field/features/types.js'\nimport type { SanitizedServerEditorConfig } from './field/lexical/config/types.js'\nimport type { AdapterProps } from './types.js'\n\nimport { RichTextCell } from './cell/index.js'\nimport { RichTextField } from './field/index.js'\nimport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultSanitizedServerEditorConfig,\n} from './field/lexical/config/server/default.js'\nimport { loadFeatures } from './field/lexical/config/server/loader.js'\nimport { sanitizeServerFeatures } from './field/lexical/config/server/sanitize.js'\nimport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\nimport { getGenerateComponentMap } from './generateComponentMap.js'\nimport { getGenerateSchemaMap } from './generateSchemaMap.js'\nimport { richTextRelationshipPromise } from './populate/richTextRelationshipPromise.js'\nimport { richTextValidateHOC } from './validate/index.js'\n\nexport type LexicalEditorProps = {\n features?:\n | (({\n defaultFeatures,\n }: {\n defaultFeatures: FeatureProviderServer<unknown, unknown>[]\n }) => FeatureProviderServer<unknown, unknown>[])\n | FeatureProviderServer<unknown, unknown>[]\n lexical?: LexicalEditorConfig\n}\n\n// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents\nexport type LexicalRichTextAdapter = RichTextAdapter<SerializedEditorState, AdapterProps, any> & {\n editorConfig: SanitizedServerEditorConfig\n}\n\nexport function lexicalEditor(props?: LexicalEditorProps): LexicalRichTextAdapter {\n let resolvedFeatureMap: ResolvedServerFeatureMap = null\n\n let finalSanitizedEditorConfig: SanitizedServerEditorConfig // For server only\n if (!props || (!props.features && !props.lexical)) {\n finalSanitizedEditorConfig = cloneDeep(defaultSanitizedServerEditorConfig)\n resolvedFeatureMap = finalSanitizedEditorConfig.resolvedFeatureMap\n } else {\n let features: FeatureProviderServer<unknown, unknown>[] =\n props.features && typeof props.features === 'function'\n ? props.features({ defaultFeatures: cloneDeep(defaultEditorFeatures) })\n : (props.features as FeatureProviderServer<unknown, unknown>[])\n if (!features) {\n features = cloneDeep(defaultEditorFeatures)\n }\n\n const lexical: LexicalEditorConfig = props.lexical\n\n resolvedFeatureMap = loadFeatures({\n unSanitizedEditorConfig: {\n features,\n lexical: lexical ? lexical : defaultEditorConfig.lexical,\n },\n })\n\n finalSanitizedEditorConfig = {\n features: sanitizeServerFeatures(resolvedFeatureMap),\n lexical: lexical ? lexical : defaultEditorConfig.lexical,\n resolvedFeatureMap,\n }\n }\n\n return {\n CellComponent: withMergedProps({\n Component: RichTextCell,\n toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical },\n }),\n FieldComponent: withMergedProps({\n Component: RichTextField,\n toMergeIntoProps: { lexicalEditorConfig: finalSanitizedEditorConfig.lexical },\n }),\n afterReadPromise: ({ field, incomingEditorState, siblingDoc }) => {\n return new Promise<void>((resolve, reject) => {\n const promises: Promise<void>[] = []\n\n if (finalSanitizedEditorConfig?.features?.hooks?.afterReadPromises?.length) {\n for (const afterReadPromise of finalSanitizedEditorConfig.features.hooks\n .afterReadPromises) {\n const promise = afterReadPromise({\n field,\n incomingEditorState,\n siblingDoc,\n })\n if (promise) {\n promises.push(promise)\n }\n }\n }\n\n Promise.all(promises)\n .then(() => resolve())\n .catch((error) => reject(error))\n })\n },\n editorConfig: finalSanitizedEditorConfig,\n generateComponentMap: getGenerateComponentMap({\n resolvedFeatureMap,\n }),\n generateSchemaMap: getGenerateSchemaMap({\n resolvedFeatureMap,\n }),\n outputSchema: ({\n collectionIDFieldTypes,\n config,\n field,\n interfaceNameDefinitions,\n isRequired,\n }) => {\n let outputSchema: JSONSchema4 = {\n // This schema matches the SerializedEditorState type so far, that it's possible to cast SerializedEditorState to this schema without any errors.\n // In the future, we should\n // 1) allow recursive children\n // 2) Pass in all the different types for every node added to the editorconfig. This can be done with refs in the schema.\n type: withNullableJSONSchemaType('object', isRequired),\n properties: {\n root: {\n type: 'object',\n additionalProperties: false,\n properties: {\n type: {\n type: 'string',\n },\n children: {\n type: 'array',\n items: {\n type: 'object',\n additionalProperties: true,\n properties: {\n type: {\n type: 'string',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['type', 'version'],\n },\n },\n direction: {\n oneOf: [\n {\n enum: ['ltr', 'rtl'],\n },\n {\n type: 'null',\n },\n ],\n },\n format: {\n type: 'string',\n enum: ['left', 'start', 'center', 'right', 'end', 'justify', ''], // ElementFormatType, since the root node is an element\n },\n indent: {\n type: 'integer',\n },\n version: {\n type: 'integer',\n },\n },\n required: ['children', 'direction', 'format', 'indent', 'type', 'version'],\n },\n },\n required: ['root'],\n }\n for (const modifyOutputSchema of finalSanitizedEditorConfig.features.generatedTypes\n .modifyOutputSchemas) {\n outputSchema = modifyOutputSchema({\n collectionIDFieldTypes,\n config,\n currentSchema: outputSchema,\n field,\n interfaceNameDefinitions,\n isRequired,\n })\n }\n\n return outputSchema\n },\n populationPromise({\n context,\n currentDepth,\n depth,\n field,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n }) {\n // check if there are any features with nodes which have populationPromises for this field\n if (finalSanitizedEditorConfig?.features?.populationPromises?.size) {\n return richTextRelationshipPromise({\n context,\n currentDepth,\n depth,\n editorPopulationPromises: finalSanitizedEditorConfig.features.populationPromises,\n field,\n findMany,\n flattenLocales,\n overrideAccess,\n populationPromises,\n req,\n showHiddenFields,\n siblingDoc,\n })\n }\n\n return null\n },\n validate: richTextValidateHOC({\n editorConfig: finalSanitizedEditorConfig,\n }),\n }\n}\n\nexport { AlignFeature } from './field/features/align/feature.server.js'\nexport { BlockQuoteFeature } from './field/features/blockquote/feature.server.js'\nexport { BlocksFeature, type BlocksFeatureProps } from './field/features/blocks/feature.server.js'\nexport {\n $createBlockNode,\n $isBlockNode,\n type BlockFields,\n BlockNode,\n type SerializedBlockNode,\n} from './field/features/blocks/nodes/BlocksNode.js'\n\nexport { TextDropdownSectionWithEntries } from './field/features/common/floatingSelectToolbarTextDropdownSection/index.js'\nexport { LinebreakHTMLConverter } from './field/features/converters/html/converter/converters/linebreak.js'\nexport { ParagraphHTMLConverter } from './field/features/converters/html/converter/converters/paragraph.js'\n\nexport { TextHTMLConverter } from './field/features/converters/html/converter/converters/text.js'\nexport { defaultHTMLConverters } from './field/features/converters/html/converter/defaultConverters.js'\nexport {\n convertLexicalNodesToHTML,\n convertLexicalToHTML,\n} from './field/features/converters/html/converter/index.js'\nexport type { HTMLConverter } from './field/features/converters/html/converter/types.js'\nexport {\n HTMLConverterFeature,\n type HTMLConverterFeatureProps,\n} from './field/features/converters/html/feature.server.js'\nexport { consolidateHTMLConverters } from './field/features/converters/html/field/index.js'\nexport { lexicalHTML } from './field/features/converters/html/field/index.js'\nexport { createClientComponent } from './field/features/createClientComponent.js'\nexport { TestRecorderFeature } from './field/features/debug/testrecorder/feature.server.js'\nexport { TreeViewFeature } from './field/features/debug/treeview/feature.server.js'\nexport { BoldFeature } from './field/features/format/bold/feature.server.js'\nexport { SectionWithEntries as FormatSectionWithEntries } from './field/features/format/common/floatingSelectToolbarSection.js'\nexport { InlineCodeFeature } from './field/features/format/inlinecode/feature.server.js'\nexport { ItalicFeature } from './field/features/format/italic/feature.server.js'\nexport { StrikethroughFeature } from './field/features/format/strikethrough/feature.server.js'\nexport { SubscriptFeature } from './field/features/format/subscript/feature.server.js'\nexport { SuperscriptFeature } from './field/features/format/superscript/feature.server.js'\nexport { UnderlineFeature } from './field/features/format/underline/feature.server.js'\n\nexport { HeadingFeature } from './field/features/heading/feature.server.js'\nexport { IndentFeature } from './field/features/indent/feature.server.js'\n\nexport { LinkFeature, type LinkFeatureServerProps } from './field/features/link/feature.server.js'\nexport {\n $createAutoLinkNode,\n $isAutoLinkNode,\n AutoLinkNode,\n} from './field/features/link/nodes/AutoLinkNode.js'\nexport {\n $createLinkNode,\n $isLinkNode,\n LinkNode,\n TOGGLE_LINK_COMMAND,\n} from './field/features/link/nodes/LinkNode.js'\nexport type {\n LinkFields,\n SerializedAutoLinkNode,\n SerializedLinkNode,\n} from './field/features/link/nodes/types.js'\nexport { CheckListFeature } from './field/features/lists/checklist/feature.server.js'\nexport { OrderedListFeature } from './field/features/lists/orderedlist/feature.server.js'\nexport { UnorderedListFeature } from './field/features/lists/unorderedlist/feature.server.js'\nexport { LexicalPluginToLexicalFeature } from './field/features/migrations/lexicalPluginToLexical/feature.server.js'\nexport { SlateBlockquoteConverter } from './field/features/migrations/slateToLexical/converter/converters/blockquote/index.js'\nexport { SlateHeadingConverter } from './field/features/migrations/slateToLexical/converter/converters/heading/index.js'\nexport { SlateIndentConverter } from './field/features/migrations/slateToLexical/converter/converters/indent/index.js'\nexport { SlateLinkConverter } from './field/features/migrations/slateToLexical/converter/converters/link/index.js'\nexport { SlateListItemConverter } from './field/features/migrations/slateToLexical/converter/converters/listItem/index.js'\nexport { SlateOrderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/orderedList/index.js'\nexport { SlateRelationshipConverter } from './field/features/migrations/slateToLexical/converter/converters/relationship/index.js'\nexport { SlateUnknownConverter } from './field/features/migrations/slateToLexical/converter/converters/unknown/index.js'\nexport { SlateUnorderedListConverter } from './field/features/migrations/slateToLexical/converter/converters/unorderedList/index.js'\n\nexport { SlateUploadConverter } from './field/features/migrations/slateToLexical/converter/converters/upload/index.js'\nexport { defaultSlateConverters } from './field/features/migrations/slateToLexical/converter/defaultConverters.js'\nexport {\n convertSlateNodesToLexical,\n convertSlateToLexical,\n} from './field/features/migrations/slateToLexical/converter/index.js'\n\nexport type {\n SlateNode,\n SlateNodeConverter,\n} from './field/features/migrations/slateToLexical/converter/types.js'\nexport { SlateToLexicalFeature } from './field/features/migrations/slateToLexical/feature.server.js'\nexport { ParagraphFeature } from './field/features/paragraph/feature.server.js'\nexport { RelationshipFeature } from './field/features/relationship/feature.server.js'\nexport {\n $createRelationshipNode,\n $isRelationshipNode,\n type RelationshipData,\n RelationshipNode,\n type SerializedRelationshipNode,\n} from './field/features/relationship/nodes/RelationshipNode.js'\nexport type {\n ClientFeature,\n ClientFeatureProviderMap,\n FeatureProviderClient,\n FeatureProviderProviderClient,\n FeatureProviderProviderServer,\n FeatureProviderServer,\n NodeValidation,\n PopulationPromise,\n ResolvedClientFeature,\n ResolvedClientFeatureMap,\n ResolvedServerFeature,\n ResolvedServerFeatureMap,\n SanitizedClientFeatures,\n SanitizedPlugin,\n SanitizedServerFeatures,\n ServerFeature,\n ServerFeatureProviderMap,\n} from './field/features/types.js'\nexport { UploadFeature } from './field/features/upload/feature.server.js'\n\nexport type { UploadFeatureProps } from './field/features/upload/feature.server.js'\n\nexport type { RawUploadPayload } from './field/features/upload/nodes/UploadNode.js'\n\nexport {\n $createUploadNode,\n $isUploadNode,\n type SerializedUploadNode,\n type UploadData,\n UploadNode,\n} from './field/features/upload/nodes/UploadNode.js'\nexport {\n EditorConfigProvider,\n useEditorConfigContext,\n} from './field/lexical/config/client/EditorConfigProvider.js'\nexport {\n sanitizeClientEditorConfig,\n sanitizeClientFeatures,\n} from './field/lexical/config/client/sanitize.js'\nexport {\n defaultEditorConfig,\n defaultEditorFeatures,\n defaultEditorLexicalConfig,\n defaultSanitizedServerEditorConfig,\n} from './field/lexical/config/server/default.js'\nexport {\n loadFeatures,\n sortFeaturesForOptimalLoading,\n} from './field/lexical/config/server/loader.js'\nexport {\n sanitizeServerEditorConfig,\n sanitizeServerFeatures,\n} from './field/lexical/config/server/sanitize.js'\n\nexport type {\n ClientEditorConfig,\n SanitizedClientEditorConfig,\n SanitizedServerEditorConfig,\n ServerEditorConfig,\n} from './field/lexical/config/types.js'\nexport { getEnabledNodes } from './field/lexical/nodes/index.js'\n\nexport {\n type FloatingToolbarSection,\n type FloatingToolbarSectionEntry,\n} from './field/lexical/plugins/FloatingSelectToolbar/types.js'\nexport { ENABLE_SLASH_MENU_COMMAND } from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/index.js'\nexport type { AdapterProps }\n\nexport {\n SlashMenuGroup,\n SlashMenuOption,\n} from './field/lexical/plugins/SlashMenu/LexicalTypeaheadMenuPlugin/types.js'\nexport { CAN_USE_DOM } from './field/lexical/utils/canUseDOM.js'\nexport { cloneDeep } from './field/lexical/utils/cloneDeep.js'\nexport { getDOMRangeRect } from './field/lexical/utils/getDOMRangeRect.js'\nexport { getSelectedNode } from './field/lexical/utils/getSelectedNode.js'\nexport { isHTMLElement } from './field/lexical/utils/guard.js'\nexport { invariant } from './field/lexical/utils/invariant.js'\nexport { joinClasses } from './field/lexical/utils/joinClasses.js'\nexport { createBlockNode } from './field/lexical/utils/markdown/createBlockNode.js'\nexport {\n DETAIL_TYPE_TO_DETAIL,\n DOUBLE_LINE_BREAK,\n ELEMENT_FORMAT_TO_TYPE,\n ELEMENT_TYPE_TO_FORMAT,\n IS_ALL_FORMATTING,\n LTR_REGEX,\n NON_BREAKING_SPACE,\n NodeFormat,\n RTL_REGEX,\n TEXT_MODE_TO_TYPE,\n TEXT_TYPE_TO_FORMAT,\n TEXT_TYPE_TO_MODE,\n} from './field/lexical/utils/nodeFormat.js'\nexport { Point, isPoint } from './field/lexical/utils/point.js'\nexport { Rect } from './field/lexical/utils/rect.js'\nexport { setFloatingElemPosition } from './field/lexical/utils/setFloatingElemPosition.js'\nexport { setFloatingElemPositionForLinkEditor } from './field/lexical/utils/setFloatingElemPositionForLinkEditor.js'\nexport {\n addSwipeDownListener,\n addSwipeLeftListener,\n addSwipeRightListener,\n addSwipeUpListener,\n} from './field/lexical/utils/swipe.js'\nexport { sanitizeUrl, validateUrl } from './field/lexical/utils/url.js'\nexport { defaultRichTextValue } from './populate/defaultValue.js'\n"],"names":["withMergedProps","withNullableJSONSchemaType","RichTextCell","RichTextField","defaultEditorConfig","defaultEditorFeatures","defaultSanitizedServerEditorConfig","loadFeatures","sanitizeServerFeatures","cloneDeep","getGenerateComponentMap","getGenerateSchemaMap","richTextRelationshipPromise","richTextValidateHOC","lexicalEditor","props","resolvedFeatureMap","finalSanitizedEditorConfig","features","lexical","defaultFeatures","unSanitizedEditorConfig","CellComponent","Component","toMergeIntoProps","lexicalEditorConfig","FieldComponent","afterReadPromise","field","incomingEditorState","siblingDoc","Promise","resolve","reject","promises","hooks","afterReadPromises","length","promise","push","all","then","catch","error","editorConfig","generateComponentMap","generateSchemaMap","outputSchema","collectionIDFieldTypes","config","interfaceNameDefinitions","isRequired","type","properties","root","additionalProperties","children","items","version","required","direction","oneOf","enum","format","indent","modifyOutputSchema","generatedTypes","modifyOutputSchemas","currentSchema","populationPromise","context","currentDepth","depth","findMany","flattenLocales","overrideAccess","populationPromises","req","showHiddenFields","size","editorPopulationPromises","validate","AlignFeature","BlockQuoteFeature","BlocksFeature","$createBlockNode","$isBlockNode","BlockNode","TextDropdownSectionWithEntries","LinebreakHTMLConverter","ParagraphHTMLConverter","TextHTMLConverter","defaultHTMLConverters","convertLexicalNodesToHTML","convertLexicalToHTML","HTMLConverterFeature","consolidateHTMLConverters","lexicalHTML","createClientComponent","TestRecorderFeature","TreeViewFeature","BoldFeature","SectionWithEntries","FormatSectionWithEntries","InlineCodeFeature","ItalicFeature","StrikethroughFeature","SubscriptFeature","SuperscriptFeature","UnderlineFeature","HeadingFeature","IndentFeature","LinkFeature","$createAutoLinkNode","$isAutoLinkNode","AutoLinkNode","$createLinkNode","$isLinkNode","LinkNode","TOGGLE_LINK_COMMAND","CheckListFeature","OrderedListFeature","UnorderedListFeature","LexicalPluginToLexicalFeature","SlateBlockquoteConverter","SlateHeadingConverter","SlateIndentConverter","SlateLinkConverter","SlateListItemConverter","SlateOrderedListConverter","SlateRelationshipConverter","SlateUnknownConverter","SlateUnorderedListConverter","SlateUploadConverter","defaultSlateConverters","convertSlateNodesToLexical","convertSlateToLexical","SlateToLexicalFeature","ParagraphFeature","RelationshipFeature","$createRelationshipNode","$isRelationshipNode","RelationshipNode","UploadFeature","$createUploadNode","$isUploadNode","UploadNode","EditorConfigProvider","useEditorConfigContext","sanitizeClientEditorConfig","sanitizeClientFeatures","defaultEditorLexicalConfig","sortFeaturesForOptimalLoading","sanitizeServerEditorConfig","getEnabledNodes","ENABLE_SLASH_MENU_COMMAND","SlashMenuGroup","SlashMenuOption","CAN_USE_DOM","getDOMRangeRect","getSelectedNode","isHTMLElement","invariant","joinClasses","createBlockNode","DETAIL_TYPE_TO_DETAIL","DOUBLE_LINE_BREAK","ELEMENT_FORMAT_TO_TYPE","ELEMENT_TYPE_TO_FORMAT","IS_ALL_FORMATTING","LTR_REGEX","NON_BREAKING_SPACE","NodeFormat","RTL_REGEX","TEXT_MODE_TO_TYPE","TEXT_TYPE_TO_FORMAT","TEXT_TYPE_TO_MODE","Point","isPoint","Rect","setFloatingElemPosition","setFloatingElemPositionForLinkEditor","addSwipeDownListener","addSwipeLeftListener","addSwipeRightListener","addSwipeUpListener","sanitizeUrl","validateUrl","defaultRichTextValue"],"mappings":"AAKA,SAASA,eAAe,QAAQ,0CAAyC;AACzE,SAASC,0BAA0B,QAAQ,oBAAmB;AAM9D,SAASC,YAAY,QAAQ,kBAAiB;AAC9C,SAASC,aAAa,QAAQ,mBAAkB;AAChD,SACEC,mBAAmB,EACnBC,qBAAqB,EACrBC,kCAAkC,QAC7B,2CAA0C;AACjD,SAASC,YAAY,QAAQ,0CAAyC;AACtE,SAASC,sBAAsB,QAAQ,4CAA2C;AAClF,SAASC,SAAS,QAAQ,qCAAoC;AAC9D,SAASC,uBAAuB,QAAQ,4BAA2B;AACnE,SAASC,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,2BAA2B,QAAQ,4CAA2C;AACvF,SAASC,mBAAmB,QAAQ,sBAAqB;AAkBzD,OAAO,SAASC,cAAcC,KAA0B;IACtD,IAAIC,qBAA+C;IAEnD,IAAIC,0BAAwD,kBAAkB;;IAC9E,IAAI,CAACF,SAAU,CAACA,MAAMG,QAAQ,IAAI,CAACH,MAAMI,OAAO,EAAG;QACjDF,6BAA6BR,UAAUH;QACvCU,qBAAqBC,2BAA2BD,kBAAkB;IACpE,OAAO;QACL,IAAIE,WACFH,MAAMG,QAAQ,IAAI,OAAOH,MAAMG,QAAQ,KAAK,aACxCH,MAAMG,QAAQ,CAAC;YAAEE,iBAAiBX,UAAUJ;QAAuB,KAClEU,MAAMG,QAAQ;QACrB,IAAI,CAACA,UAAU;YACbA,WAAWT,UAAUJ;QACvB;QAEA,MAAMc,UAA+BJ,MAAMI,OAAO;QAElDH,qBAAqBT,aAAa;YAChCc,yBAAyB;gBACvBH;gBACAC,SAASA,UAAUA,UAAUf,oBAAoBe,OAAO;YAC1D;QACF;QAEAF,6BAA6B;YAC3BC,UAAUV,uBAAuBQ;YACjCG,SAASA,UAAUA,UAAUf,oBAAoBe,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AASrJ,SAAS,QAAQ,qCAAoC;AAC9D,SAASsJ,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,aAAa,QAAQ,iCAAgC;AAC9D,SAASC,SAAS,QAAQ,qCAAoC;AAC9D,SAASC,WAAW,QAAQ,uCAAsC;AAClE,SAASC,eAAe,QAAQ,oDAAmD;AACnF,SACEC,qBAAqB,EACrBC,iBAAiB,EACjBC,sBAAsB,EACtBC,sBAAsB,EACtBC,iBAAiB,EACjBC,SAAS,EACTC,kBAAkB,EAClBC,UAAU,EACVC,SAAS,EACTC,iBAAiB,EACjBC,mBAAmB,EACnBC,iBAAiB,QACZ,sCAAqC;AAC5C,SAASC,KAAK,EAAEC,OAAO,QAAQ,iCAAgC;AAC/D,SAASC,IAAI,QAAQ,gCAA+B;AACpD,SAASC,uBAAuB,QAAQ,mDAAkD;AAC1F,SAASC,oCAAoC,QAAQ,gEAA+D;AACpH,SACEC,oBAAoB,EACpBC,oBAAoB,EACpBC,qBAAqB,EACrBC,kBAAkB,QACb,iCAAgC;AACvC,SAASC,WAAW,EAAEC,WAAW,QAAQ,+BAA8B;AACvE,SAASC,oBAAoB,QAAQ,6BAA4B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLexicalFeature.d.ts","sourceRoot":"","sources":["../src/useLexicalFeature.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLexicalFeature.d.ts","sourceRoot":"","sources":["../src/useLexicalFeature.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AAEtE,eAAO,MAAM,iBAAiB,mCAChB,MAAM,WACT,sBAAsB,kBAAkB,CAAC,SAKnD,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import { useAddClientFunction } from '@payloadcms/ui/providers';
|
|
2
|
+
import { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider';
|
|
3
|
+
import { useAddClientFunction } from '@payloadcms/ui/providers/ClientFunction';
|
|
4
4
|
export const useLexicalFeature = (featureKey, feature)=>{
|
|
5
|
-
const { schemaPath } =
|
|
5
|
+
const { schemaPath } = useFieldProps();
|
|
6
6
|
useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature);
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/useLexicalFeature.tsx"],"sourcesContent":["'use client'\nimport {
|
|
1
|
+
{"version":3,"sources":["../src/useLexicalFeature.tsx"],"sourcesContent":["'use client'\n\nimport { useFieldProps } from '@payloadcms/ui/forms/FieldPropsProvider'\nimport { useAddClientFunction } from '@payloadcms/ui/providers/ClientFunction'\n\nimport type { FeatureProviderClient } from './field/features/types.js'\n\nexport const useLexicalFeature = <ClientFeatureProps,>(\n featureKey: string,\n feature: FeatureProviderClient<ClientFeatureProps>,\n) => {\n const { schemaPath } = useFieldProps()\n\n useAddClientFunction(`lexicalFeature.${schemaPath}.${featureKey}`, feature)\n}\n"],"names":["useFieldProps","useAddClientFunction","useLexicalFeature","featureKey","feature","schemaPath"],"mappings":"AAAA;AAEA,SAASA,aAAa,QAAQ,0CAAyC;AACvE,SAASC,oBAAoB,QAAQ,0CAAyC;AAI9E,OAAO,MAAMC,oBAAoB,CAC/BC,YACAC;IAEA,MAAM,EAAEC,UAAU,EAAE,GAAGL;IAEvBC,qBAAqB,CAAC,eAAe,EAAEI,WAAW,CAAC,EAAEF,WAAW,CAAC,EAAEC;AACrE,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.49",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"repository": "https://github.com/payloadcms/payload",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,15 +36,17 @@
|
|
|
36
36
|
"@types/node": "20.6.2",
|
|
37
37
|
"@types/react": "18.2.15",
|
|
38
38
|
"@types/react-dom": "18.2.7",
|
|
39
|
-
"
|
|
40
|
-
"@payloadcms/
|
|
41
|
-
"
|
|
42
|
-
"@payloadcms/
|
|
39
|
+
"payload": "3.0.0-alpha.49",
|
|
40
|
+
"@payloadcms/ui": "3.0.0-alpha.49",
|
|
41
|
+
"@payloadcms/translations": "3.0.0-alpha.49",
|
|
42
|
+
"@payloadcms/next": "3.0.0-alpha.49",
|
|
43
|
+
"@payloadcms/eslint-config": "1.1.1"
|
|
43
44
|
},
|
|
44
45
|
"peerDependencies": {
|
|
45
|
-
"@payloadcms/
|
|
46
|
-
"
|
|
47
|
-
"
|
|
46
|
+
"@payloadcms/ui": "3.0.0-alpha.49",
|
|
47
|
+
"payload": "3.0.0-alpha.49",
|
|
48
|
+
"@payloadcms/next": "3.0.0-alpha.49",
|
|
49
|
+
"@payloadcms/translations": "3.0.0-alpha.49"
|
|
48
50
|
},
|
|
49
51
|
"exports": {
|
|
50
52
|
".": {
|