@payloadcms/richtext-lexical 3.65.0-canary.7 → 3.65.0-internal.5b33fe0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/dist/exports/client/Field-CFLUGR3C.js +2 -0
  2. package/dist/exports/client/Field-CFLUGR3C.js.map +7 -0
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/chunk-6NIGQP6A.js +12 -0
  5. package/dist/exports/client/chunk-6NIGQP6A.js.map +7 -0
  6. package/dist/exports/client/index.d.ts +1 -0
  7. package/dist/exports/client/index.d.ts.map +1 -1
  8. package/dist/exports/client/index.js +20 -20
  9. package/dist/exports/client/index.js.map +3 -3
  10. package/dist/exports/react/index.d.ts +1 -1
  11. package/dist/exports/react/index.d.ts.map +1 -1
  12. package/dist/exports/react/index.js.map +1 -1
  13. package/dist/features/blocks/client/component/index.d.ts.map +1 -1
  14. package/dist/features/blocks/client/component/index.js +1 -9
  15. package/dist/features/blocks/client/component/index.js.map +1 -1
  16. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +2 -14
  17. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  18. package/dist/features/converters/lexicalToJSX/Component/index.js +4 -2
  19. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  20. package/dist/features/converters/lexicalToJSX/converter/index.d.ts +16 -1
  21. package/dist/features/converters/lexicalToJSX/converter/index.d.ts.map +1 -1
  22. package/dist/features/converters/lexicalToJSX/converter/index.js +76 -4
  23. package/dist/features/converters/lexicalToJSX/converter/index.js.map +1 -1
  24. package/dist/features/converters/lexicalToJSX/converter/types.d.ts +14 -10
  25. package/dist/features/converters/lexicalToJSX/converter/types.d.ts.map +1 -1
  26. package/dist/features/converters/lexicalToJSX/converter/types.js.map +1 -1
  27. package/dist/features/debug/jsxConverter/client/plugin/index.js +1 -1
  28. package/dist/features/debug/jsxConverter/client/plugin/index.js.map +1 -1
  29. package/dist/field/Field.d.ts.map +1 -1
  30. package/dist/field/Field.js +10 -5
  31. package/dist/field/Field.js.map +1 -1
  32. package/dist/field/RichTextViewProvider.d.ts +83 -0
  33. package/dist/field/RichTextViewProvider.d.ts.map +1 -0
  34. package/dist/field/RichTextViewProvider.js +87 -0
  35. package/dist/field/RichTextViewProvider.js.map +1 -0
  36. package/dist/field/ViewSelector.d.ts +4 -0
  37. package/dist/field/ViewSelector.d.ts.map +1 -0
  38. package/dist/field/ViewSelector.js +89 -0
  39. package/dist/field/ViewSelector.js.map +1 -0
  40. package/dist/field/bundled.css +1 -1
  41. package/dist/field/index.d.ts +1 -0
  42. package/dist/field/index.d.ts.map +1 -1
  43. package/dist/field/index.js +47 -29
  44. package/dist/field/index.js.map +1 -1
  45. package/dist/field/rscEntry.d.ts +1 -1
  46. package/dist/field/rscEntry.d.ts.map +1 -1
  47. package/dist/field/rscEntry.js +12 -0
  48. package/dist/field/rscEntry.js.map +1 -1
  49. package/dist/index.d.ts +1 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +3 -1
  52. package/dist/index.js.map +1 -1
  53. package/dist/lexical/LexicalEditor.d.ts.map +1 -1
  54. package/dist/lexical/LexicalEditor.js +2 -1
  55. package/dist/lexical/LexicalEditor.js.map +1 -1
  56. package/dist/lexical/LexicalProvider.d.ts.map +1 -1
  57. package/dist/lexical/LexicalProvider.js +12 -3
  58. package/dist/lexical/LexicalProvider.js.map +1 -1
  59. package/dist/lexical/config/client/sanitize.d.ts +1 -1
  60. package/dist/lexical/config/client/sanitize.d.ts.map +1 -1
  61. package/dist/lexical/config/client/sanitize.js +3 -2
  62. package/dist/lexical/config/client/sanitize.js.map +1 -1
  63. package/dist/lexical/config/types.d.ts +4 -0
  64. package/dist/lexical/config/types.d.ts.map +1 -1
  65. package/dist/lexical/config/types.js.map +1 -1
  66. package/dist/lexical/nodes/index.d.ts +12 -2
  67. package/dist/lexical/nodes/index.d.ts.map +1 -1
  68. package/dist/lexical/nodes/index.js +195 -2
  69. package/dist/lexical/nodes/index.js.map +1 -1
  70. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts +2 -0
  71. package/dist/lexical/plugins/NodeViewOverridePlugin/index.d.ts.map +1 -0
  72. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js +48 -0
  73. package/dist/lexical/plugins/NodeViewOverridePlugin/index.js.map +1 -0
  74. package/dist/types.d.ts +136 -2
  75. package/dist/types.d.ts.map +1 -1
  76. package/dist/types.js.map +1 -1
  77. package/dist/utilities/generateImportMap.d.ts.map +1 -1
  78. package/dist/utilities/generateImportMap.js +1 -0
  79. package/dist/utilities/generateImportMap.js.map +1 -1
  80. package/dist/validate/hasText.d.ts +6 -1
  81. package/dist/validate/hasText.d.ts.map +1 -1
  82. package/dist/validate/hasText.js +10 -4
  83. package/dist/validate/hasText.js.map +1 -1
  84. package/package.json +6 -6
  85. package/dist/exports/client/Field-QUXIGJRC.js +0 -2
  86. package/dist/exports/client/Field-QUXIGJRC.js.map +0 -7
  87. package/dist/exports/client/chunk-AFXLIYGL.js +0 -12
  88. package/dist/exports/client/chunk-AFXLIYGL.js.map +0 -7
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/features/converters/lexicalToJSX/converter/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAEpD,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EACnB,yBAAyB,EAC1B,MAAM,0BAA0B,CAAA;AACjC,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,qBAAqB,IAC5F,CAAC,CAAC,IAAI,EAAE;IACN,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,aAAa,CAAA;IACzB,IAAI,EAAE,CAAC,CAAA;IACP,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M,CAAC,CAAC,GAC/E,CAAC,SAAS;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE,GAC7B,CAAC,CAAC,WAAW,CAAC,GACd,KAAK,GACP,KAAK,EACT,MAAM,CACP,CAAC,CAAC,EAAE,YAAY,CACf,OAAO,CAAC,MAAM,EAAE;YAAE,IAAI,EAAE,aAAa,CAAA;SAAE,CAAC,SAAS,yBAAyB,CAAC,MAAM,CAAC,CAAC,GAC/E,yBAAyB,CAAC,OAAO,CAAC,CAAC,EAAE;YAAE,SAAS,EAAE,CAAC,CAAA;SAAE,CAAC,CAAC,GACvD,yBAAyB,CAC9B;KACF,CAAA;IACD,OAAO,CAAC,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAA;CAC9C,CAAA;AACD,MAAM,MAAM,+BAA+B,GAAG;IAC5C,MAAM,CAAC,EAAE,qBAAqB,CAAA;CAC/B,GAAG,qBAAqB,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\nexport type JSXConverter<T extends { [key: string]: any; type?: string } = SerializedLexicalNode> =\n | ((args: {\n childIndex: number\n converters: JSXConverters\n node: T\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n parent: SerializedLexicalNodeWithParent\n }) => React.ReactNode)\n | React.ReactNode\n\nexport type JSXConverters<\n T extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: JSXConverter<any>\n }\n | JSXConverter<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<T['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<\n Extract<T, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<T, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<T, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<T, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<T, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: JSXConverter<SerializedLexicalNode>\n}\nexport type SerializedLexicalNodeWithParent = {\n parent?: SerializedLexicalNode\n} & SerializedLexicalNode\n"],"mappings":"AAsEA","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../../../../src/features/converters/lexicalToJSX/converter/types.ts"],"sourcesContent":["import type { SerializedLexicalNode } from 'lexical'\n\nimport type {\n DefaultNodeTypes,\n SerializedBlockNode,\n SerializedInlineBlockNode,\n} from '../../../../nodeTypes.js'\n\nexport type JSXConverterArgs<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = {\n childIndex: number\n converters: JSXConverters\n node: TNode\n nodesToJSX: (args: {\n converters?: JSXConverters\n disableIndent?: boolean | string[]\n disableTextAlign?: boolean | string[]\n nodes: SerializedLexicalNode[]\n parent?: SerializedLexicalNodeWithParent\n }) => React.ReactNode[]\n parent: SerializedLexicalNodeWithParent\n}\nexport type JSXConverter<\n TNode extends { [key: string]: any; type?: string } = SerializedLexicalNode,\n> = ((args: JSXConverterArgs<TNode>) => React.ReactNode) | React.ReactNode\n\nexport type JSXConverters<\n TNodes extends { [key: string]: any; type?: string } =\n | DefaultNodeTypes\n | SerializedBlockNode<{ blockName?: null | string; blockType: string }> // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n | SerializedInlineBlockNode<{ blockName?: null | string; blockType: string }>, // need these to ensure types for blocks and inlineBlocks work if no generics are provided\n> = {\n [key: string]:\n | {\n [blockSlug: string]: JSXConverter<any>\n }\n | JSXConverter<any>\n | undefined\n} & {\n [nodeType in Exclude<NonNullable<TNodes['type']>, 'block' | 'inlineBlock'>]?: JSXConverter<\n Extract<TNodes, { type: nodeType }>\n >\n} & {\n blocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<TNodes, { type: 'block' }> extends SerializedBlockNode<infer B>\n ? SerializedBlockNode<Extract<B, { blockType: K }>>\n : SerializedBlockNode\n >\n }\n inlineBlocks?: {\n [K in Extract<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? B extends { blockType: string }\n ? B['blockType']\n : never\n : never,\n string\n >]?: JSXConverter<\n Extract<TNodes, { type: 'inlineBlock' }> extends SerializedInlineBlockNode<infer B>\n ? SerializedInlineBlockNode<Extract<B, { blockType: K }>>\n : SerializedInlineBlockNode\n >\n }\n unknown?: JSXConverter<SerializedLexicalNode>\n}\nexport type SerializedLexicalNodeWithParent = {\n parent?: SerializedLexicalNode\n} & SerializedLexicalNode\n"],"mappings":"AA0EA","ignoreList":[]}
@@ -11,7 +11,7 @@ export function RichTextPlugin() {
11
11
  const [editor] = useLexicalComposerContext();
12
12
  let t0;
13
13
  if ($[0] !== editor) {
14
- t0 = editor.getEditorState().toJSON();
14
+ t0 = () => editor.getEditorState().toJSON();
15
15
  $[0] = editor;
16
16
  $[1] = t0;
17
17
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","$","editor","t0","getEditorState","toJSON","editorState","setEditorState","t1","t2","registerUpdateListener","t3","editorState_0","_jsx","className","children","converters","data"],"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(editor.getEditorState().toJSON())\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n setEditorState(editorState.toJSON())\n })\n }, [editor])\n\n return (\n <div className=\"debug-jsx-converter\">\n <RichText converters={defaultJSXConverters} data={editorState} />\n </div>\n )\n}\n"],"mappings":"AAAA;;AAAA,SAAAA,CAAA,IAAAC,EAAA;;AAEA,SAASC,yBAAyB,QAAQ;AAC1C,SAASC,SAAS,EAAEC,QAAQ,QAAQ;AAEpC;AACA,SAASC,oBAAoB,EAAEC,QAAQ,QAAQ;AAG/C,OAAO,SAAAC,eAAA;EAAA,MAAAC,CAAA,GAAAP,EAAA;EACL,OAAAQ,MAAA,IAAiBP,yBAAA;EAAA,IAAAQ,EAAA;EAAA,IAAAF,CAAA,QAAAC,MAAA;IAC8BC,EAAA,GAAAD,MAAA,CAAAE,cAAA,CAAqB,EAAAC,MAAA,CAAS;IAAAJ,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAE,EAAA;EAAA;IAAAA,EAAA,GAAAF,CAAA;EAAA;EAA7E,OAAAK,WAAA,EAAAC,cAAA,IAAsCV,QAAA,CAASM,EAA8B;EAAA,IAAAK,EAAA;EAAA,IAAAC,EAAA;EAAA,IAAAR,CAAA,QAAAC,MAAA;IAEnEM,EAAA,GAAAA,CAAA,KACDN,MAAA,CAAAQ,sBAAA,CAAAC,EAAA;MAA+B;QAAAL,WAAA,EAAAM;MAAA,IAAAD,EAAe;MACnDJ,cAAA,CAAeD,aAAA,CAAAD,MAAA,CAAkB;IAAA,CACnC;IACCI,EAAA,IAACP,MAAA;IAAOD,CAAA,MAAAC,MAAA;IAAAD,CAAA,MAAAO,EAAA;IAAAP,CAAA,MAAAQ,EAAA;EAAA;IAAAD,EAAA,GAAAP,CAAA;IAAAQ,EAAA,GAAAR,CAAA;EAAA;EAJXL,SAAA,CAAUY,EAIV,EAAGC,EAAQ;EAAA,IAAAE,EAAA;EAAA,IAAAV,CAAA,QAAAK,WAAA;IAGTK,EAAA,GAAAE,IAAA,CAAC;MAAAC,SAAA,EAAc;MAAAC,QAAA,EACbF,IAAA,CAAAd,QAAA;QAAAiB,UAAA,EAAAlB,oBAAA;QAAAmB,IAAA,EAAkDX;MAAA,C;;;;;;;SADpDK,E","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["c","_c","useLexicalComposerContext","useEffect","useState","defaultJSXConverters","RichText","RichTextPlugin","$","editor","t0","getEditorState","toJSON","editorState","setEditorState","t1","t2","registerUpdateListener","t3","editorState_0","_jsx","className","children","converters","data"],"sources":["../../../../../../src/features/debug/jsxConverter/client/plugin/index.tsx"],"sourcesContent":["'use client'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { useEffect, useState } from 'react'\n\n// eslint-disable-next-line payload/no-imports-from-exports-dir\nimport { defaultJSXConverters, RichText } from '../../../../../exports/react/index.js'\nimport './style.scss'\n\nexport function RichTextPlugin() {\n const [editor] = useLexicalComposerContext()\n const [editorState, setEditorState] = useState(() => editor.getEditorState().toJSON())\n\n useEffect(() => {\n return editor.registerUpdateListener(({ editorState }) => {\n setEditorState(editorState.toJSON())\n })\n }, [editor])\n\n return (\n <div className=\"debug-jsx-converter\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mB,IAAA,EAAkDX;MAAA,C;;;;;;;SADpDK,E","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAO5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CA4K9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
1
+ {"version":3,"file":"Field.d.ts","sourceRoot":"","sources":["../../src/field/Field.tsx"],"names":[],"mappings":"AAgBA,OAAO,KAAoD,MAAM,OAAO,CAAA;AAGxE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAA;AAE7E,OAAO,mCAAmC,CAAA;AAC1C,OAAO,eAAe,CAAA;AACtB,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAQ5D,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAC/B;IACE,QAAQ,CAAC,YAAY,EAAE,2BAA2B,CAAA;CACnD,GAAG,yBAAyB,CAsL9B,CAAA;AAaD,eAAO,MAAM,QAAQ,EAAE,OAAO,iBAAqC,CAAA"}
@@ -9,6 +9,7 @@ import { ErrorBoundary } from 'react-error-boundary';
9
9
  import './bundled.css';
10
10
  import { LexicalProvider } from '../lexical/LexicalProvider.js';
11
11
  import { useRunDeprioritized } from '../utilities/useRunDeprioritized.js';
12
+ import { ViewSelector } from './ViewSelector.js';
12
13
  const baseClass = 'rich-text-lexical';
13
14
  const RichTextComponent = props => {
14
15
  const {
@@ -119,6 +120,7 @@ const RichTextComponent = props => {
119
120
  }, [initialValue]);
120
121
  return /*#__PURE__*/_jsxs("div", {
121
122
  className: classes,
123
+ "data-lexical-view": editorConfig?.view,
122
124
  style: styles,
123
125
  children: [/*#__PURE__*/_jsx(RenderCustomComponent, {
124
126
  CustomComponent: Error,
@@ -126,11 +128,14 @@ const RichTextComponent = props => {
126
128
  path: path,
127
129
  showError: showError
128
130
  })
129
- }), Label || /*#__PURE__*/_jsx(FieldLabel, {
130
- label: label,
131
- localized: localized,
132
- path: path,
133
- required: required
131
+ }), /*#__PURE__*/_jsxs("div", {
132
+ className: `${baseClass}__label-row`,
133
+ children: [Label || /*#__PURE__*/_jsx(FieldLabel, {
134
+ label: label,
135
+ localized: localized,
136
+ path: path,
137
+ required: required
138
+ }), /*#__PURE__*/_jsx(ViewSelector, {})]
134
139
  }), /*#__PURE__*/_jsxs("div", {
135
140
  className: `${baseClass}__wrap`,
136
141
  children: [/*#__PURE__*/_jsxs(ErrorBoundary, {
@@ -1 +1 @@
1
- {"version":3,"file":"Field.js","names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","_jsxs","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div className={classes} key={pathWithEditDepth} style={styles}>\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n {Label || <FieldLabel label={label} localized={localized} path={path} required={required} />}\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAGA,SACEA,kBAAkB,EAClBC,gBAAgB,EAChBC,UAAU,EACVC,UAAU,EACVC,qBAAqB,EACrBC,YAAY,EACZC,cAAc,EACdC,QAAQ,QACH;AACP,SAASC,gBAAgB,QAAQ;AACjC,SAASC,MAAM,QAAQ;AAEvB,OAAOC,KAAA,IAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ;AACjE,SAASC,aAAa,QAAQ;AAK9B,OAAO;AAKP,SAASC,eAAe,QAAQ;AAChC,SAASC,mBAAmB,QAAQ;AAEpC,MAAMC,SAAA,GAAY;AAElB,MAAMC,iBAAA,GAIDC,KAAA;EACH,MAAM;IACJC,YAAY;IACZC,KAAK;IACLA,KAAA,EAAO;MACLC,KAAA,EAAO;QAAEC,SAAS;QAAEC,WAAW;QAAEC,QAAA,EAAUC;MAAiB,CAAE,GAAG,CAAC,CAAC;MACnEC,KAAK;MACLC,SAAS;MACTC;IAAQ,CACT;IACDC,IAAA,EAAMC,aAAa;IACnBN,QAAA,EAAUO,yBAAyB;IACnCC;EAAQ,CACT,GAAGd,KAAA;EAEJ,MAAMe,iBAAA,GAAoBF,yBAAA,IAA6BN,iBAAA;EAEvD,MAAMS,SAAA,GAAY/B,YAAA;EAElB,MAAMgC,gBAAA,GAAmB1B,WAAA,CACvB,CAAC2B,KAAA,EAAOC,iBAAA;IACN,IAAI,OAAOL,QAAA,KAAa,YAAY;MAClC;MACA,OAAOA,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EAEA,oBACEX,KAAA,CAAC;IAAI/D,SAAA,EAAU;IAAgB2E,IAAA,EAAK;4BAClCV,IAAA,CAAC;gBAAE;qBACHA,IAAA,CAAC;MAAID,KAAA,EAAO;QAAEY,KAAA,EAAO;MAAM;gBAAIF,KAAA,CAAMG;;;AAG3C;AAEA,OAAO,MAAMC,QAAA,GAAqCnF,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"Field.js","names":["BulkUploadProvider","FieldDescription","FieldError","FieldLabel","RenderCustomComponent","useEditDepth","useEffectEvent","useField","mergeFieldStyles","dequal","React","useCallback","useEffect","useMemo","useState","ErrorBoundary","LexicalProvider","useRunDeprioritized","ViewSelector","baseClass","RichTextComponent","props","editorConfig","field","admin","className","description","readOnly","readOnlyFromAdmin","label","localized","required","path","pathFromProps","readOnlyFromTopLevelProps","validate","readOnlyFromProps","editDepth","memoizedValidate","value","validationOptions","customComponents","AfterInput","BeforeInput","Description","Error","Label","disabled","disabledFromField","initialValue","setValue","showError","potentiallyStalePath","isSmallWidthViewport","setIsSmallWidthViewport","rerenderProviderKey","setRerenderProviderKey","prevInitialValueRef","useRef","prevValueRef","updateViewPortWidth","isNextSmallWidthViewport","window","matchMedia","matches","addEventListener","removeEventListener","classes","hideGutter","filter","Boolean","join","pathWithEditDepth","runDeprioritized","handleChange","editorState","updateFieldValue","newState","toJSON","current","styles","handleInitialValueChange","JSON","parse","stringify","Date","Object","is","_jsxs","view","style","_jsx","CustomComponent","Fallback","fallbackRender","onReset","drawerSlugPrefix","composerKey","fieldProps","onChange","error","role","color","message","RichText"],"sources":["../../src/field/Field.tsx"],"sourcesContent":["'use client'\nimport type { EditorState, SerializedEditorState } from 'lexical'\n\nimport {\n BulkUploadProvider,\n FieldDescription,\n FieldError,\n FieldLabel,\n RenderCustomComponent,\n useEditDepth,\n useEffectEvent,\n useField,\n} from '@payloadcms/ui'\nimport { mergeFieldStyles } from '@payloadcms/ui/shared'\nimport { dequal } from 'dequal/lite'\nimport { type Validate } from 'payload'\nimport React, { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ErrorBoundary } from 'react-error-boundary'\n\nimport type { SanitizedClientEditorConfig } from '../lexical/config/types.js'\n\nimport '../lexical/theme/EditorTheme.scss'\nimport './bundled.css'\nimport './index.scss'\n\nimport type { LexicalRichTextFieldProps } from '../types.js'\n\nimport { LexicalProvider } from '../lexical/LexicalProvider.js'\nimport { useRunDeprioritized } from '../utilities/useRunDeprioritized.js'\nimport { ViewSelector } from './ViewSelector.js'\n\nconst baseClass = 'rich-text-lexical'\n\nconst RichTextComponent: React.FC<\n {\n readonly editorConfig: SanitizedClientEditorConfig // With rendered features n stuff\n } & LexicalRichTextFieldProps\n> = (props) => {\n const {\n editorConfig,\n field,\n field: {\n admin: { className, description, readOnly: readOnlyFromAdmin } = {},\n label,\n localized,\n required,\n },\n path: pathFromProps,\n readOnly: readOnlyFromTopLevelProps,\n validate, // Users can pass in client side validation if they WANT to, but it's not required anymore\n } = props\n\n const readOnlyFromProps = readOnlyFromTopLevelProps || readOnlyFromAdmin\n\n const editDepth = useEditDepth()\n\n const memoizedValidate = useCallback<Validate>(\n (value, validationOptions) => {\n if (typeof validate === 'function') {\n // @ts-expect-error - vestiges of when tsconfig was not strict. Feel free to improve\n return validate(value, { ...validationOptions, required })\n }\n return true\n },\n // Important: do not add props to the dependencies array.\n // This would cause an infinite loop and endless re-rendering.\n // Removing props from the dependencies array fixed this issue: https://github.com/payloadcms/payload/issues/3709\n [validate, required],\n )\n\n const {\n customComponents: { AfterInput, BeforeInput, Description, Error, Label } = {},\n disabled: disabledFromField,\n initialValue,\n path,\n setValue,\n showError,\n value,\n } = useField<SerializedEditorState>({\n potentiallyStalePath: pathFromProps,\n validate: memoizedValidate,\n })\n\n const disabled = readOnlyFromProps || disabledFromField\n\n const [isSmallWidthViewport, setIsSmallWidthViewport] = useState<boolean>(false)\n const [rerenderProviderKey, setRerenderProviderKey] = useState<Date>()\n\n const prevInitialValueRef = React.useRef<SerializedEditorState | undefined>(initialValue)\n const prevValueRef = React.useRef<SerializedEditorState | undefined>(value)\n\n useEffect(() => {\n const updateViewPortWidth = () => {\n const isNextSmallWidthViewport = window.matchMedia('(max-width: 768px)').matches\n\n if (isNextSmallWidthViewport !== isSmallWidthViewport) {\n setIsSmallWidthViewport(isNextSmallWidthViewport)\n }\n }\n updateViewPortWidth()\n window.addEventListener('resize', updateViewPortWidth)\n\n return () => {\n window.removeEventListener('resize', updateViewPortWidth)\n }\n }, [isSmallWidthViewport])\n\n const classes = [\n baseClass,\n 'field-type',\n className,\n showError && 'error',\n disabled && `${baseClass}--read-only`,\n editorConfig?.admin?.hideGutter !== true && !isSmallWidthViewport\n ? `${baseClass}--show-gutter`\n : null,\n ]\n .filter(Boolean)\n .join(' ')\n\n const pathWithEditDepth = `${path}.${editDepth}`\n\n const runDeprioritized = useRunDeprioritized() // defaults to 500 ms timeout\n\n const handleChange = useCallback(\n (editorState: EditorState) => {\n // Capture `editorState` in the closure so we can safely run later.\n const updateFieldValue = () => {\n const newState = editorState.toJSON()\n prevValueRef.current = newState\n setValue(newState)\n }\n\n // Queue the update for the browser’s idle time (or Safari shim)\n // and let the hook handle debouncing/cancellation.\n void runDeprioritized(updateFieldValue)\n },\n [setValue, runDeprioritized], // `runDeprioritized` is stable (useCallback inside hook)\n )\n\n const styles = useMemo(() => mergeFieldStyles(field), [field])\n\n const handleInitialValueChange = useEffectEvent(\n (initialValue: SerializedEditorState | undefined) => {\n // Object deep equality check here, as re-mounting the editor if\n // the new value is the same as the old one is not necessary.\n // In postgres, the order of keys in JSON objects is not guaranteed to be preserved,\n // so we need to do a deep equality check here that does not care about key order => we use dequal.\n // If we used JSON.stringify, the editor would re-mount every time you save the document, as the order of keys changes => change detected => re-mount.\n if (\n prevValueRef.current !== value &&\n !dequal(\n prevValueRef.current != null\n ? JSON.parse(JSON.stringify(prevValueRef.current))\n : prevValueRef.current,\n value,\n )\n ) {\n prevInitialValueRef.current = initialValue\n prevValueRef.current = value\n setRerenderProviderKey(new Date())\n }\n },\n )\n\n useEffect(() => {\n // Needs to trigger for object reference changes - otherwise,\n // reacting to the same initial value change twice will cause\n // the second change to be ignored, even though the value has changed.\n // That's because initialValue is not kept up-to-date\n if (!Object.is(initialValue, prevInitialValueRef.current)) {\n handleInitialValueChange(initialValue)\n }\n }, [initialValue])\n\n return (\n <div\n className={classes}\n data-lexical-view={editorConfig?.view}\n key={pathWithEditDepth}\n style={styles}\n >\n <RenderCustomComponent\n CustomComponent={Error}\n Fallback={<FieldError path={path} showError={showError} />}\n />\n <div className={`${baseClass}__label-row`}>\n {Label || (\n <FieldLabel label={label} localized={localized} path={path} required={required} />\n )}\n <ViewSelector />\n </div>\n <div className={`${baseClass}__wrap`}>\n <ErrorBoundary fallbackRender={fallbackRender} onReset={() => {}}>\n {BeforeInput}\n {/* Lexical may be in a drawer. We need to define another BulkUploadProvider to ensure that the bulk upload drawer\n is rendered in the correct depth (not displayed *behind* the current drawer)*/}\n <BulkUploadProvider drawerSlugPrefix={path}>\n <LexicalProvider\n composerKey={pathWithEditDepth}\n editorConfig={editorConfig}\n fieldProps={props}\n isSmallWidthViewport={isSmallWidthViewport}\n key={JSON.stringify({ path, rerenderProviderKey })} // makes sure lexical is completely re-rendered when initialValue changes, bypassing the lexical-internal value memoization. That way, external changes to the form will update the editor. More infos in PR description (https://github.com/payloadcms/payload/pull/5010)\n onChange={handleChange}\n readOnly={disabled}\n value={value}\n />\n </BulkUploadProvider>\n {AfterInput}\n </ErrorBoundary>\n <RenderCustomComponent\n CustomComponent={Description}\n Fallback={<FieldDescription description={description} path={path} />}\n />\n </div>\n </div>\n )\n}\n\nfunction fallbackRender({ error }: { error: Error }) {\n // Call resetErrorBoundary() to reset the error boundary and retry the render.\n\n return (\n <div className=\"errorBoundary\" role=\"alert\">\n <p>Something went wrong:</p>\n <pre style={{ color: 'red' }}>{error.message}</pre>\n </div>\n )\n}\n\nexport const RichText: typeof RichTextComponent = RichTextComponent\n"],"mappings":"AAAA;;;AAGA,SAC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AAEA,OAAO,MAAMC,QAAA,GAAqCpF,iBAAA","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js';
3
+ /**
4
+ * Context type for rich text view management.
5
+ */
6
+ type RichTextViewContextType = {
7
+ /**
8
+ * The name of the currently active view (e.g., 'default', 'frontend', 'debug')
9
+ */
10
+ currentView: string;
11
+ /**
12
+ * The node map for the currently active view, containing rendering overrides for each node type.
13
+ * This is the resolved view from the views map based on currentView.
14
+ */
15
+ currentViewMap?: LexicalEditorNodeMap;
16
+ /**
17
+ * If true, the current view will be inherited by nested richtext editors.
18
+ */
19
+ inheritable?: boolean;
20
+ /**
21
+ * Function to change the current view.
22
+ */
23
+ setCurrentView: (view: string) => void;
24
+ /**
25
+ * The complete map of all available views for this field.
26
+ */
27
+ views?: LexicalEditorViewMap;
28
+ };
29
+ /**
30
+ * Provider component for rich text view context.
31
+ *
32
+ * This provider manages the current view state internally and makes it accessible to child components
33
+ * via the useRichTextView hook. It automatically resolves the current view's node map
34
+ * based on the active view name.
35
+ *
36
+ * @example
37
+ * ```tsx
38
+ * <RichTextViewProvider
39
+ * currentView="frontend"
40
+ * views={myViews}
41
+ * >
42
+ * <MyEditor />
43
+ * </RichTextViewProvider>
44
+ * ```
45
+ */
46
+ export declare const RichTextViewProvider: React.FC<{
47
+ children: React.ReactNode;
48
+ currentView?: string;
49
+ inheritable?: boolean;
50
+ views?: LexicalEditorViewMap;
51
+ }>;
52
+ /**
53
+ * Hook to access the current rich text view context.
54
+ *
55
+ * Use this hook to access the currently active view and its node map,
56
+ * or to programmatically switch between views.
57
+ *
58
+ * @returns An object containing:
59
+ * - `currentView`: The name of the active view
60
+ * - `currentViewMap`: The node overrides for the current view
61
+ * - `setCurrentView`: Function to change views
62
+ * - `views`: All available views
63
+ *
64
+ * @example
65
+ * ```tsx
66
+ * function MyComponent() {
67
+ * const { currentView, currentViewMap, setCurrentView } = useRichTextView()
68
+ *
69
+ * return (
70
+ * <div>
71
+ * <p>Current view: {currentView}</p>
72
+ * {currentViewMap?.heading && <p>Heading overrides are active</p>}
73
+ * <button onClick={() => setCurrentView('frontend')}>
74
+ * Switch to frontend view
75
+ * </button>
76
+ * </div>
77
+ * )
78
+ * }
79
+ * ```
80
+ */
81
+ export declare function useRichTextView(): RichTextViewContextType;
82
+ export {};
83
+ //# sourceMappingURL=RichTextViewProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextViewProvider.d.ts","sourceRoot":"","sources":["../../src/field/RichTextViewProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAE1D,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAE7E;;GAEG;AACH,KAAK,uBAAuB,GAAG;IAC7B;;OAEG;IACH,WAAW,EAAE,MAAM,CAAA;IACnB;;;OAGG;IACH,cAAc,CAAC,EAAE,oBAAoB,CAAA;IACrC;;OAEG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;OAEG;IACH,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACtC;;OAEG;IACH,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CAAA;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC1C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,KAAK,CAAC,EAAE,oBAAoB,CAAA;CAC7B,CA6BA,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,eAAe,IAAI,uBAAuB,CAEzD"}
@@ -0,0 +1,87 @@
1
+ 'use client';
2
+
3
+ import { jsx as _jsx } from "react/jsx-runtime";
4
+ import { useControllableState } from '@payloadcms/ui';
5
+ import React, { createContext, use, useMemo } from 'react';
6
+ const RichTextViewContext = /*#__PURE__*/createContext({
7
+ currentView: 'default',
8
+ inheritable: false,
9
+ setCurrentView: () => {}
10
+ });
11
+ /**
12
+ * Provider component for rich text view context.
13
+ *
14
+ * This provider manages the current view state internally and makes it accessible to child components
15
+ * via the useRichTextView hook. It automatically resolves the current view's node map
16
+ * based on the active view name.
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * <RichTextViewProvider
21
+ * currentView="frontend"
22
+ * views={myViews}
23
+ * >
24
+ * <MyEditor />
25
+ * </RichTextViewProvider>
26
+ * ```
27
+ */
28
+ export const RichTextViewProvider = args => {
29
+ const parentContext = useRichTextView();
30
+ const {
31
+ children,
32
+ currentView: currentViewFromProps,
33
+ inheritable,
34
+ views
35
+ } = parentContext.inheritable ? {
36
+ ...parentContext,
37
+ ...args
38
+ } : args;
39
+ const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default');
40
+ const value = useMemo(() => {
41
+ const currentViewMap = views ? views[currentView] || views.default : undefined;
42
+ return {
43
+ currentView,
44
+ currentViewMap,
45
+ inheritable,
46
+ setCurrentView,
47
+ views
48
+ };
49
+ }, [currentView, inheritable, setCurrentView, views]);
50
+ return /*#__PURE__*/_jsx(RichTextViewContext, {
51
+ value: value,
52
+ children: children
53
+ });
54
+ };
55
+ /**
56
+ * Hook to access the current rich text view context.
57
+ *
58
+ * Use this hook to access the currently active view and its node map,
59
+ * or to programmatically switch between views.
60
+ *
61
+ * @returns An object containing:
62
+ * - `currentView`: The name of the active view
63
+ * - `currentViewMap`: The node overrides for the current view
64
+ * - `setCurrentView`: Function to change views
65
+ * - `views`: All available views
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * function MyComponent() {
70
+ * const { currentView, currentViewMap, setCurrentView } = useRichTextView()
71
+ *
72
+ * return (
73
+ * <div>
74
+ * <p>Current view: {currentView}</p>
75
+ * {currentViewMap?.heading && <p>Heading overrides are active</p>}
76
+ * <button onClick={() => setCurrentView('frontend')}>
77
+ * Switch to frontend view
78
+ * </button>
79
+ * </div>
80
+ * )
81
+ * }
82
+ * ```
83
+ */
84
+ export function useRichTextView() {
85
+ return use(RichTextViewContext);
86
+ }
87
+ //# sourceMappingURL=RichTextViewProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RichTextViewProvider.js","names":["useControllableState","React","createContext","use","useMemo","RichTextViewContext","currentView","inheritable","setCurrentView","RichTextViewProvider","args","parentContext","useRichTextView","children","currentViewFromProps","views","value","currentViewMap","default","undefined","_jsx"],"sources":["../../src/field/RichTextViewProvider.tsx"],"sourcesContent":["'use client'\nimport { useControllableState } from '@payloadcms/ui'\nimport React, { createContext, use, useMemo } from 'react'\n\nimport type { LexicalEditorNodeMap, LexicalEditorViewMap } from '../types.js'\n\n/**\n * Context type for rich text view management.\n */\ntype RichTextViewContextType = {\n /**\n * The name of the currently active view (e.g., 'default', 'frontend', 'debug')\n */\n currentView: string\n /**\n * The node map for the currently active view, containing rendering overrides for each node type.\n * This is the resolved view from the views map based on currentView.\n */\n currentViewMap?: LexicalEditorNodeMap\n /**\n * If true, the current view will be inherited by nested richtext editors.\n */\n inheritable?: boolean\n /**\n * Function to change the current view.\n */\n setCurrentView: (view: string) => void\n /**\n * The complete map of all available views for this field.\n */\n views?: LexicalEditorViewMap\n}\n\nconst RichTextViewContext = createContext<RichTextViewContextType>({\n currentView: 'default',\n inheritable: false,\n setCurrentView: () => {},\n})\n\n/**\n * Provider component for rich text view context.\n *\n * This provider manages the current view state internally and makes it accessible to child components\n * via the useRichTextView hook. It automatically resolves the current view's node map\n * based on the active view name.\n *\n * @example\n * ```tsx\n * <RichTextViewProvider\n * currentView=\"frontend\"\n * views={myViews}\n * >\n * <MyEditor />\n * </RichTextViewProvider>\n * ```\n */\nexport const RichTextViewProvider: React.FC<{\n children: React.ReactNode\n currentView?: string\n inheritable?: boolean\n views?: LexicalEditorViewMap\n}> = (args) => {\n const parentContext = useRichTextView()\n\n const {\n children,\n currentView: currentViewFromProps,\n inheritable,\n views,\n } = parentContext.inheritable\n ? {\n ...parentContext,\n ...args,\n }\n : args\n\n const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default')\n\n const value = useMemo(() => {\n const currentViewMap = views ? views[currentView] || views.default : undefined\n return {\n currentView,\n currentViewMap,\n inheritable,\n setCurrentView,\n views,\n }\n }, [currentView, inheritable, setCurrentView, views])\n\n return <RichTextViewContext value={value}>{children}</RichTextViewContext>\n}\n\n/**\n * Hook to access the current rich text view context.\n *\n * Use this hook to access the currently active view and its node map,\n * or to programmatically switch between views.\n *\n * @returns An object containing:\n * - `currentView`: The name of the active view\n * - `currentViewMap`: The node overrides for the current view\n * - `setCurrentView`: Function to change views\n * - `views`: All available views\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { currentView, currentViewMap, setCurrentView } = useRichTextView()\n *\n * return (\n * <div>\n * <p>Current view: {currentView}</p>\n * {currentViewMap?.heading && <p>Heading overrides are active</p>}\n * <button onClick={() => setCurrentView('frontend')}>\n * Switch to frontend view\n * </button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRichTextView(): RichTextViewContextType {\n return use(RichTextViewContext)\n}\n"],"mappings":"AAAA;;;AACA,SAASA,oBAAoB,QAAQ;AACrC,OAAOC,KAAA,IAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,QAAQ;AA+BnD,MAAMC,mBAAA,gBAAsBH,aAAA,CAAuC;EACjEI,WAAA,EAAa;EACbC,WAAA,EAAa;EACbC,cAAA,EAAgBA,CAAA,MAAO;AACzB;AAEA;;;;;;;;;;;;;;;;;AAiBA,OAAO,MAAMC,oBAAA,GAKPC,IAAA;EACJ,MAAMC,aAAA,GAAgBC,eAAA;EAEtB,MAAM;IACJC,QAAQ;IACRP,WAAA,EAAaQ,oBAAoB;IACjCP,WAAW;IACXQ;EAAK,CACN,GAAGJ,aAAA,CAAcJ,WAAW,GACzB;IACE,GAAGI,aAAa;IAChB,GAAGD;EACL,IACAA,IAAA;EAEJ,MAAM,CAACJ,WAAA,EAAaE,cAAA,CAAe,GAAGR,oBAAA,CAAqBc,oBAAA,EAAsB;EAEjF,MAAME,KAAA,GAAQZ,OAAA,CAAQ;IACpB,MAAMa,cAAA,GAAiBF,KAAA,GAAQA,KAAK,CAACT,WAAA,CAAY,IAAIS,KAAA,CAAMG,OAAO,GAAGC,SAAA;IACrE,OAAO;MACLb,WAAA;MACAW,cAAA;MACAV,WAAA;MACAC,cAAA;MACAO;IACF;EACF,GAAG,CAACT,WAAA,EAAaC,WAAA,EAAaC,cAAA,EAAgBO,KAAA,CAAM;EAEpD,oBAAOK,IAAA,CAACf,mBAAA;IAAoBW,KAAA,EAAOA,KAAA;cAAQH;;AAC7C;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,OAAO,SAASD,gBAAA;EACd,OAAOT,GAAA,CAAIE,mBAAA;AACb","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import './ViewSelector.scss';
3
+ export declare function ViewSelector(): null | React.ReactElement;
4
+ //# sourceMappingURL=ViewSelector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewSelector.d.ts","sourceRoot":"","sources":["../../src/field/ViewSelector.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,qBAAqB,CAAA;AAE5B,wBAAgB,YAAY,IAAI,IAAI,GAAG,KAAK,CAAC,YAAY,CAyDxD"}
@@ -0,0 +1,89 @@
1
+ 'use client';
2
+
3
+ import { c as _c } from "react/compiler-runtime";
4
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
5
+ import { ChevronIcon, Popup, PopupList } from '@payloadcms/ui';
6
+ import React from 'react';
7
+ import { useRichTextView } from './RichTextViewProvider.js';
8
+ export function ViewSelector() {
9
+ const $ = _c(5);
10
+ const {
11
+ currentView,
12
+ setCurrentView,
13
+ views
14
+ } = useRichTextView();
15
+ if (!views || Object.keys(views).length === 0) {
16
+ return null;
17
+ }
18
+ let t0;
19
+ let t1;
20
+ if ($[0] !== currentView || $[1] !== setCurrentView || $[2] !== views) {
21
+ t1 = Symbol.for("react.early_return_sentinel");
22
+ bb0: {
23
+ const viewKeys = Object.keys(views);
24
+ const hasNonDefaultViews = viewKeys.some(_temp);
25
+ if (!hasNonDefaultViews) {
26
+ t1 = null;
27
+ break bb0;
28
+ }
29
+ const allViews = ["default", ...viewKeys.filter(_temp2)];
30
+ const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1);
31
+ t0 = _jsx("div", {
32
+ className: "lexical-view-selector",
33
+ children: _jsx(Popup, {
34
+ button: _jsxs("button", {
35
+ className: "lexical-view-selector__button",
36
+ type: "button",
37
+ children: [_jsx("span", {
38
+ className: "lexical-view-selector__label",
39
+ children: currentViewLabel
40
+ }), _jsx(ChevronIcon, {
41
+ className: "lexical-view-selector__icon"
42
+ })]
43
+ }),
44
+ buttonType: "custom",
45
+ horizontalAlign: "left",
46
+ render: t2 => {
47
+ const {
48
+ close
49
+ } = t2;
50
+ return _jsx(PopupList.ButtonGroup, {
51
+ children: allViews.map(viewName => {
52
+ const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1);
53
+ return _jsx(PopupList.Button, {
54
+ active: viewName === currentView,
55
+ disabled: viewName === currentView,
56
+ onClick: () => {
57
+ setCurrentView?.(viewName);
58
+ close();
59
+ },
60
+ children: viewLabel
61
+ }, viewName);
62
+ })
63
+ });
64
+ },
65
+ size: "large"
66
+ })
67
+ });
68
+ }
69
+ $[0] = currentView;
70
+ $[1] = setCurrentView;
71
+ $[2] = views;
72
+ $[3] = t0;
73
+ $[4] = t1;
74
+ } else {
75
+ t0 = $[3];
76
+ t1 = $[4];
77
+ }
78
+ if (t1 !== Symbol.for("react.early_return_sentinel")) {
79
+ return t1;
80
+ }
81
+ return t0;
82
+ }
83
+ function _temp2(key_0) {
84
+ return key_0 !== "default";
85
+ }
86
+ function _temp(key) {
87
+ return key !== "default";
88
+ }
89
+ //# sourceMappingURL=ViewSelector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewSelector.js","names":["c","_c","ChevronIcon","Popup","PopupList","React","useRichTextView","ViewSelector","$","currentView","setCurrentView","views","Object","keys","length","t0","t1","Symbol","for","bb0","viewKeys","hasNonDefaultViews","some","_temp","allViews","filter","_temp2","currentViewLabel","charAt","toUpperCase","slice","_jsx","className","children","button","_jsxs","type","horizontalAlign","render","t2","close","ButtonGroup","map","viewName","viewLabel","Button","active","disabled","onClick","key_0","key"],"sources":["../../src/field/ViewSelector.tsx"],"sourcesContent":["'use client'\nimport { ChevronIcon, Popup, PopupList } from '@payloadcms/ui'\nimport React from 'react'\n\nimport { useRichTextView } from './RichTextViewProvider.js'\nimport './ViewSelector.scss'\n\nexport function ViewSelector(): null | React.ReactElement {\n const { currentView, setCurrentView, views } = useRichTextView()\n\n // Don't show if no views or only default exists\n if (!views || Object.keys(views).length === 0) {\n return null\n }\n\n const viewKeys = Object.keys(views)\n const hasNonDefaultViews = viewKeys.some((key) => key !== 'default')\n\n // If only 'default' exists, no need to show selector\n if (!hasNonDefaultViews) {\n return null\n }\n\n // Build list of available views\n const allViews = ['default', ...viewKeys.filter((key) => key !== 'default')]\n\n const currentViewLabel = currentView.charAt(0).toUpperCase() + currentView.slice(1)\n\n return (\n <div className=\"lexical-view-selector\">\n <Popup\n button={\n <button className=\"lexical-view-selector__button\" type=\"button\">\n <span className=\"lexical-view-selector__label\">{currentViewLabel}</span>\n <ChevronIcon className=\"lexical-view-selector__icon\" />\n </button>\n }\n buttonType=\"custom\"\n horizontalAlign=\"left\"\n render={({ close }) => (\n <PopupList.ButtonGroup>\n {allViews.map((viewName) => {\n const viewLabel = viewName.charAt(0).toUpperCase() + viewName.slice(1)\n\n return (\n <PopupList.Button\n active={viewName === currentView}\n disabled={viewName === currentView}\n key={viewName}\n onClick={() => {\n setCurrentView?.(viewName)\n close()\n }}\n >\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