@payloadcms/richtext-lexical 3.80.0-internal-debug.daef79f → 3.80.0-internal-debug.1c0048d
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.
|
@@ -56,7 +56,7 @@ import React, { createContext, use, useMemo } from 'react';
|
|
|
56
56
|
// Propagate inheritable flag through the hierarchy
|
|
57
57
|
inheritable: parentContext.inheritable || args.inheritable,
|
|
58
58
|
// Only inherit views if parent has a views map
|
|
59
|
-
views: isControlledByParent ? parentContext.views : args.views
|
|
59
|
+
views: isControlledByParent && parentContext.views ? parentContext.views : args.views
|
|
60
60
|
};
|
|
61
61
|
const [currentView, setCurrentView] = useControllableState(currentViewFromProps, 'default');
|
|
62
62
|
const value = useMemo(()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"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 for managing richtext editor view state and inheritance.\n */\ntype RichTextViewContextType = {\n /**\n * The currently active view name (e.g., 'default', 'frontend', 'debug').\n */\n currentView: string\n /**\n * The resolved node map for the current view, containing rendering overrides for each node type.\n */\n currentViewMap?: LexicalEditorNodeMap\n /**\n * True if the current view was explicitly set (via prop) by this provider or an ancestor.\n * Used to distinguish intentional view settings from automatic defaults.\n */\n hasExplicitCurrentView?: boolean\n /**\n * If true, nested richtext editors will inherit this provider's currentView and views.\n */\n inheritable?: boolean\n /**\n * True if this provider's view is controlled by an ancestor provider — either because the\n * ancestor has a views map (view-map inheritance) or an explicit `currentView` prop.\n * When true, the ViewSelector is hidden.\n */\n isControlledByParent?: boolean\n /**\n * Function to programmatically change the current view.\n */\n setCurrentView: (view: string) => void\n /**\n * Map of all available views for this editor. Each key is a view name, each value contains\n * admin config, node overrides, and lexical config for that view.\n */\n views?: LexicalEditorViewMap\n}\n\nconst RichTextViewContext = createContext<RichTextViewContextType>({\n currentView: 'default',\n inheritable: false,\n setCurrentView: () => {},\n})\n\n/**\n * Provider for managing richtext editor view state and its inheritance.\n *\n * Handles two key scenarios:\n * 1. **Explicit view setting**: Wrap with `currentView` and `inheritable={true}` to force nested editors to a specific view\n * 2. **View map inheritance**: Nested editors inherit `views` from parents, allowing view switching across the hierarchy\n *\n * When a nested editor inherits from a parent, its ViewSelector is hidden because the view is controlled by an ancestor.\n *\n * @example\n * Force all nested richtext editors to use \"frontend\" view:\n * ```tsx\n * <RichTextViewProvider currentView=\"frontend\" inheritable={true}>\n * <MyForm /> {/* All richtext fields inside will use \"frontend\" view }\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 // Track if this provider explicitly sets currentView (not just using the default)\n const hasOwnExplicitView = args.currentView !== undefined\n\n const isControlledByParent =\n parentContext.inheritable &&\n (Boolean(parentContext.views) || Boolean(parentContext.hasExplicitCurrentView))\n\n // This provider has explicit currentView if it sets one OR inherits one from parent\n const hasExplicitCurrentView =\n hasOwnExplicitView ||\n (parentContext.inheritable && Boolean(parentContext.hasExplicitCurrentView))\n\n const {\n children,\n currentView: currentViewFromProps,\n inheritable,\n views,\n } = {\n children: args.children,\n currentView: isControlledByParent ? parentContext.currentView : args.currentView,\n // Propagate inheritable flag through the hierarchy\n inheritable: parentContext.inheritable || args.inheritable,\n // Only inherit views if parent has a views map\n views: isControlledByParent ? parentContext.views : args.views,\n }\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 hasExplicitCurrentView,\n inheritable,\n isControlledByParent,\n setCurrentView,\n views,\n }\n }, [\n currentView,\n inheritable,\n hasExplicitCurrentView,\n isControlledByParent,\n setCurrentView,\n views,\n ])\n\n return <RichTextViewContext value={value}>{children}</RichTextViewContext>\n}\n\n/**\n * Access the current richtext editor view context.\n *\n * Returns the active view name, node overrides, inheritance state, and a function to switch views.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { currentView, currentViewMap, isControlledByParent, setCurrentView } = useRichTextView()\n *\n * return (\n * <div>\n * <p>Active view: {currentView}</p>\n * {isControlledByParent && <p>View controlled by parent</p>}\n * {currentViewMap?.heading && <p>Custom heading renderer active</p>}\n * <button onClick={() => setCurrentView('frontend')}>Switch to frontend</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRichTextView(): RichTextViewContextType {\n return use(RichTextViewContext)\n}\n"],"names":["useControllableState","React","createContext","use","useMemo","RichTextViewContext","currentView","inheritable","setCurrentView","RichTextViewProvider","args","parentContext","useRichTextView","hasOwnExplicitView","undefined","isControlledByParent","Boolean","views","hasExplicitCurrentView","children","currentViewFromProps","value","currentViewMap","default"],"mappings":"AAAA;;AACA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,QAAQ,QAAO;AAI1D;;CAEC,GAEC;;GAEC,GAED;;GAEC,GAED;;;GAGC,GAED;;GAEC,GAED;;;;GAIC,GAED;;GAEC,GAED;;;GAGC,GAIH,MAAMC,oCAAsBH,cAAuC;IACjEI,aAAa;IACbC,aAAa;IACbC,gBAAgB,KAAO;AACzB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAKR,CAACC;IACJ,MAAMC,gBAAgBC;IAEtB,kFAAkF;IAClF,MAAMC,qBAAqBH,KAAKJ,WAAW,KAAKQ;IAEhD,MAAMC,uBACJJ,cAAcJ,WAAW,IACxBS,CAAAA,QAAQL,cAAcM,KAAK,KAAKD,QAAQL,cAAcO,sBAAsB,CAAA;IAE/E,oFAAoF;IACpF,MAAMA,yBACJL,sBACCF,cAAcJ,WAAW,IAAIS,QAAQL,cAAcO,sBAAsB;IAE5E,MAAM,EACJC,QAAQ,EACRb,aAAac,oBAAoB,EACjCb,WAAW,EACXU,KAAK,EACN,GAAG;QACFE,UAAUT,KAAKS,QAAQ;QACvBb,aAAaS,uBAAuBJ,cAAcL,WAAW,GAAGI,KAAKJ,WAAW;QAChF,mDAAmD;QACnDC,aAAaI,cAAcJ,WAAW,IAAIG,KAAKH,WAAW;QAC1D,+CAA+C;QAC/CU,OAAOF,
|
|
1
|
+
{"version":3,"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 for managing richtext editor view state and inheritance.\n */\ntype RichTextViewContextType = {\n /**\n * The currently active view name (e.g., 'default', 'frontend', 'debug').\n */\n currentView: string\n /**\n * The resolved node map for the current view, containing rendering overrides for each node type.\n */\n currentViewMap?: LexicalEditorNodeMap\n /**\n * True if the current view was explicitly set (via prop) by this provider or an ancestor.\n * Used to distinguish intentional view settings from automatic defaults.\n */\n hasExplicitCurrentView?: boolean\n /**\n * If true, nested richtext editors will inherit this provider's currentView and views.\n */\n inheritable?: boolean\n /**\n * True if this provider's view is controlled by an ancestor provider — either because the\n * ancestor has a views map (view-map inheritance) or an explicit `currentView` prop.\n * When true, the ViewSelector is hidden.\n */\n isControlledByParent?: boolean\n /**\n * Function to programmatically change the current view.\n */\n setCurrentView: (view: string) => void\n /**\n * Map of all available views for this editor. Each key is a view name, each value contains\n * admin config, node overrides, and lexical config for that view.\n */\n views?: LexicalEditorViewMap\n}\n\nconst RichTextViewContext = createContext<RichTextViewContextType>({\n currentView: 'default',\n inheritable: false,\n setCurrentView: () => {},\n})\n\n/**\n * Provider for managing richtext editor view state and its inheritance.\n *\n * Handles two key scenarios:\n * 1. **Explicit view setting**: Wrap with `currentView` and `inheritable={true}` to force nested editors to a specific view\n * 2. **View map inheritance**: Nested editors inherit `views` from parents, allowing view switching across the hierarchy\n *\n * When a nested editor inherits from a parent, its ViewSelector is hidden because the view is controlled by an ancestor.\n *\n * @example\n * Force all nested richtext editors to use \"frontend\" view:\n * ```tsx\n * <RichTextViewProvider currentView=\"frontend\" inheritable={true}>\n * <MyForm /> {/* All richtext fields inside will use \"frontend\" view }\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 // Track if this provider explicitly sets currentView (not just using the default)\n const hasOwnExplicitView = args.currentView !== undefined\n\n const isControlledByParent =\n parentContext.inheritable &&\n (Boolean(parentContext.views) || Boolean(parentContext.hasExplicitCurrentView))\n\n // This provider has explicit currentView if it sets one OR inherits one from parent\n const hasExplicitCurrentView =\n hasOwnExplicitView ||\n (parentContext.inheritable && Boolean(parentContext.hasExplicitCurrentView))\n\n const {\n children,\n currentView: currentViewFromProps,\n inheritable,\n views,\n } = {\n children: args.children,\n currentView: isControlledByParent ? parentContext.currentView : args.currentView,\n // Propagate inheritable flag through the hierarchy\n inheritable: parentContext.inheritable || args.inheritable,\n // Only inherit views if parent has a views map\n views: isControlledByParent && parentContext.views ? parentContext.views : args.views,\n }\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 hasExplicitCurrentView,\n inheritable,\n isControlledByParent,\n setCurrentView,\n views,\n }\n }, [\n currentView,\n inheritable,\n hasExplicitCurrentView,\n isControlledByParent,\n setCurrentView,\n views,\n ])\n\n return <RichTextViewContext value={value}>{children}</RichTextViewContext>\n}\n\n/**\n * Access the current richtext editor view context.\n *\n * Returns the active view name, node overrides, inheritance state, and a function to switch views.\n *\n * @example\n * ```tsx\n * function MyComponent() {\n * const { currentView, currentViewMap, isControlledByParent, setCurrentView } = useRichTextView()\n *\n * return (\n * <div>\n * <p>Active view: {currentView}</p>\n * {isControlledByParent && <p>View controlled by parent</p>}\n * {currentViewMap?.heading && <p>Custom heading renderer active</p>}\n * <button onClick={() => setCurrentView('frontend')}>Switch to frontend</button>\n * </div>\n * )\n * }\n * ```\n */\nexport function useRichTextView(): RichTextViewContextType {\n return use(RichTextViewContext)\n}\n"],"names":["useControllableState","React","createContext","use","useMemo","RichTextViewContext","currentView","inheritable","setCurrentView","RichTextViewProvider","args","parentContext","useRichTextView","hasOwnExplicitView","undefined","isControlledByParent","Boolean","views","hasExplicitCurrentView","children","currentViewFromProps","value","currentViewMap","default"],"mappings":"AAAA;;AACA,SAASA,oBAAoB,QAAQ,iBAAgB;AACrD,OAAOC,SAASC,aAAa,EAAEC,GAAG,EAAEC,OAAO,QAAQ,QAAO;AAI1D;;CAEC,GAEC;;GAEC,GAED;;GAEC,GAED;;;GAGC,GAED;;GAEC,GAED;;;;GAIC,GAED;;GAEC,GAED;;;GAGC,GAIH,MAAMC,oCAAsBH,cAAuC;IACjEI,aAAa;IACbC,aAAa;IACbC,gBAAgB,KAAO;AACzB;AAEA;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,MAAMC,uBAKR,CAACC;IACJ,MAAMC,gBAAgBC;IAEtB,kFAAkF;IAClF,MAAMC,qBAAqBH,KAAKJ,WAAW,KAAKQ;IAEhD,MAAMC,uBACJJ,cAAcJ,WAAW,IACxBS,CAAAA,QAAQL,cAAcM,KAAK,KAAKD,QAAQL,cAAcO,sBAAsB,CAAA;IAE/E,oFAAoF;IACpF,MAAMA,yBACJL,sBACCF,cAAcJ,WAAW,IAAIS,QAAQL,cAAcO,sBAAsB;IAE5E,MAAM,EACJC,QAAQ,EACRb,aAAac,oBAAoB,EACjCb,WAAW,EACXU,KAAK,EACN,GAAG;QACFE,UAAUT,KAAKS,QAAQ;QACvBb,aAAaS,uBAAuBJ,cAAcL,WAAW,GAAGI,KAAKJ,WAAW;QAChF,mDAAmD;QACnDC,aAAaI,cAAcJ,WAAW,IAAIG,KAAKH,WAAW;QAC1D,+CAA+C;QAC/CU,OAAOF,wBAAwBJ,cAAcM,KAAK,GAAGN,cAAcM,KAAK,GAAGP,KAAKO,KAAK;IACvF;IAEA,MAAM,CAACX,aAAaE,eAAe,GAAGR,qBAAqBoB,sBAAsB;IAEjF,MAAMC,QAAQjB,QAAQ;QACpB,MAAMkB,iBAAiBL,QAAQA,KAAK,CAACX,YAAY,IAAIW,MAAMM,OAAO,GAAGT;QACrE,OAAO;YACLR;YACAgB;YACAJ;YACAX;YACAQ;YACAP;YACAS;QACF;IACF,GAAG;QACDX;QACAC;QACAW;QACAH;QACAP;QACAS;KACD;IAED,qBAAO,QAACZ;QAAoBgB,OAAOA;kBAAQF;;;;;;AAC7C,EAAC;AAED;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,SAASP;IACd,OAAOT,IAAIE;AACb"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/richtext-lexical",
|
|
3
|
-
"version": "3.80.0-internal-debug.
|
|
3
|
+
"version": "3.80.0-internal-debug.1c0048d",
|
|
4
4
|
"description": "The officially supported Lexical richtext adapter for Payload",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -379,8 +379,8 @@
|
|
|
379
379
|
"react-error-boundary": "4.1.2",
|
|
380
380
|
"ts-essentials": "10.0.3",
|
|
381
381
|
"uuid": "10.0.0",
|
|
382
|
-
"@payloadcms/translations": "3.80.0-internal-debug.
|
|
383
|
-
"@payloadcms/ui": "3.80.0-internal-debug.
|
|
382
|
+
"@payloadcms/translations": "3.80.0-internal-debug.1c0048d",
|
|
383
|
+
"@payloadcms/ui": "3.80.0-internal-debug.1c0048d"
|
|
384
384
|
},
|
|
385
385
|
"devDependencies": {
|
|
386
386
|
"@babel/cli": "7.27.2",
|
|
@@ -400,15 +400,15 @@
|
|
|
400
400
|
"esbuild-sass-plugin": "3.3.1",
|
|
401
401
|
"swc-plugin-transform-remove-imports": "8.3.0",
|
|
402
402
|
"@payloadcms/eslint-config": "3.28.0",
|
|
403
|
-
"payload": "3.80.0-internal-debug.
|
|
403
|
+
"payload": "3.80.0-internal-debug.1c0048d"
|
|
404
404
|
},
|
|
405
405
|
"peerDependencies": {
|
|
406
406
|
"@faceless-ui/modal": "3.0.0",
|
|
407
407
|
"@faceless-ui/scroll-info": "2.0.0",
|
|
408
408
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
409
409
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
410
|
-
"@payloadcms/next": "3.80.0-internal-debug.
|
|
411
|
-
"payload": "3.80.0-internal-debug.
|
|
410
|
+
"@payloadcms/next": "3.80.0-internal-debug.1c0048d",
|
|
411
|
+
"payload": "3.80.0-internal-debug.1c0048d"
|
|
412
412
|
},
|
|
413
413
|
"engines": {
|
|
414
414
|
"node": "^18.20.2 || >=20.9.0"
|