@payloadcms/richtext-lexical 3.42.0-internal.f9d0258 → 3.42.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"textState.d.ts","sourceRoot":"","sources":["../../../src/features/textState/textState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,SAAS,CAAA;AAOzD,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAUlF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,QASvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,QAU9F;AAED,wBAAgB,WAAW,SAuC1B"}
1
+ {"version":3,"file":"textState.d.ts","sourceRoot":"","sources":["../../../src/features/textState/textState.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAe,MAAM,SAAS,CAAA;AAOzD,OAAO,EAAoB,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAUlF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,QASvE;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,QAU9F;AAED,wBAAgB,WAAW,SA8C1B"}
@@ -40,24 +40,27 @@ export function StatePlugin() {
40
40
  if (!node || !dom) {
41
41
  continue;
42
42
  }
43
- // stateKey could be color for example
44
- stateMap.forEach((stateEntry, _stateKey) => {
45
- // stateValue could be bg-red for example
43
+ const mergedStyles = Object.create(null);
44
+ // Examples:
45
+ // stateKey: 'color'
46
+ // stateValue: 'bg-red'
47
+ stateMap.forEach((stateEntry, stateKey) => {
46
48
  const stateValue = $getState(node, stateEntry.stateConfig);
47
49
  if (!stateValue) {
48
- delete dom.dataset[_stateKey];
49
- dom.style.cssText = '';
50
+ // clear the previous dataset value for this key
51
+ delete dom.dataset[stateKey];
50
52
  return;
51
- }
52
- dom.dataset[_stateKey] = stateValue;
53
+ } // skip - nothing else to do
54
+ dom.dataset[stateKey] = stateValue;
53
55
  const css = stateEntry.stateValues[stateValue]?.css;
54
- if (!css) {
55
- return;
56
+ if (css) {
57
+ // merge existing styles with the new ones
58
+ Object.assign(mergedStyles, css);
56
59
  }
57
- Object.entries(css).forEach(([key, value]) => {
58
- dom.style.setProperty(key, value);
59
- });
60
60
  });
61
+ // wipe previous inline styles once, then set the merged ones
62
+ dom.style.cssText = '';
63
+ Object.assign(dom.style, mergedStyles);
61
64
  }
62
65
  });
63
66
  });
@@ -1 +1 @@
1
- {"version":3,"file":"textState.js","names":["useLexicalComposerContext","$forEachSelectedTextNode","$getNodeByKey","$getState","$setState","createState","TextNode","useEffect","stateMap","Map","registerTextStates","state","stateKey","stateValues","stateConfig","parse","value","Object","keys","includes","undefined","set","setTextState","editor","update","textNode","stateMapEntry","get","Error","StatePlugin","registerMutationListener","mutatedNodes","getEditorState","read","nodeKey","mutation","node","dom","getElementByKey","forEach","stateEntry","_stateKey","stateValue","dataset","style","cssText","css","entries","key","setProperty"],"sources":["../../../src/features/textState/textState.ts"],"sourcesContent":["import type { LexicalEditor, StateConfig } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $forEachSelectedTextNode } from '@lexical/selection'\nimport { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { type StateValues, type TextStateFeatureProps } from './feature.server.js'\n\nconst stateMap = new Map<\n string,\n {\n stateConfig: StateConfig<string, string | undefined>\n stateValues: StateValues\n }\n>()\n\nexport function registerTextStates(state: TextStateFeatureProps['state']) {\n for (const stateKey in state) {\n const stateValues = state[stateKey]!\n const stateConfig = createState(stateKey, {\n parse: (value) =>\n typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined,\n })\n stateMap.set(stateKey, { stateConfig, stateValues })\n }\n}\n\nexport function setTextState(editor: LexicalEditor, stateKey: string, value: string | undefined) {\n editor.update(() => {\n $forEachSelectedTextNode((textNode) => {\n const stateMapEntry = stateMap.get(stateKey)\n if (!stateMapEntry) {\n throw new Error(`State config for ${stateKey} not found`)\n }\n $setState(textNode, stateMapEntry.stateConfig, value)\n })\n })\n}\n\nexport function StatePlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerMutationListener(TextNode, (mutatedNodes) => {\n editor.getEditorState().read(() => {\n for (const [nodeKey, mutation] of mutatedNodes) {\n if (mutation === 'destroyed') {\n continue\n }\n const node = $getNodeByKey(nodeKey)\n const dom = editor.getElementByKey(nodeKey)\n if (!node || !dom) {\n continue\n }\n // stateKey could be color for example\n stateMap.forEach((stateEntry, _stateKey) => {\n // stateValue could be bg-red for example\n const stateValue = $getState(node, stateEntry.stateConfig)\n if (!stateValue) {\n delete dom.dataset[_stateKey]\n dom.style.cssText = ''\n return\n }\n dom.dataset[_stateKey] = stateValue\n const css = stateEntry.stateValues[stateValue]?.css\n if (!css) {\n return\n }\n Object.entries(css).forEach(([key, value]) => {\n dom.style.setProperty(key, value)\n })\n })\n }\n })\n })\n }, [editor])\n\n return null\n}\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SAASC,aAAa,EAAEC,SAAS,EAAEC,SAAS,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAC3E,SAASC,SAAS,QAAQ;AAI1B,MAAMC,QAAA,GAAW,IAAIC,GAAA;AAQrB,OAAO,SAASC,mBAAmBC,KAAqC;EACtE,KAAK,MAAMC,QAAA,IAAYD,KAAA,EAAO;IAC5B,MAAME,WAAA,GAAcF,KAAK,CAACC,QAAA,CAAS;IACnC,MAAME,WAAA,GAAcT,WAAA,CAAYO,QAAA,EAA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,EAAY;cACf,OAAOL,GAAA,CAAIM,OAAO,CAACF,SAAA,CAAU;cAC7BJ,GAAA,CAAIO,KAAK,CAACC,OAAO,GAAG;cACpB;YACF;YACAR,GAAA,CAAIM,OAAO,CAACF,SAAA,CAAU,GAAGC,UAAA;YACzB,MAAMI,GAAA,GAAMN,UAAA,CAAW3B,WAAW,CAAC6B,UAAA,CAAW,EAAEI,GAAA;YAChD,IAAI,CAACA,GAAA,EAAK;cACR;YACF;YACA7B,MAAA,CAAO8B,OAAO,CAACD,GAAA,EAAKP,OAAO,CAAC,CAAC,CAACS,GAAA,EAAKhC,KAAA,CAAM;cACvCqB,GAAA,CAAIO,KAAK,CAACK,WAAW,CAACD,GAAA,EAAKhC,KAAA;YAC7B;UACF;QACF;MACF;IACF;EACF,GAAG,CAACO,MAAA,CAAO;EAEX,OAAO;AACT","ignoreList":[]}
1
+ {"version":3,"file":"textState.js","names":["useLexicalComposerContext","$forEachSelectedTextNode","$getNodeByKey","$getState","$setState","createState","TextNode","useEffect","stateMap","Map","registerTextStates","state","stateKey","stateValues","stateConfig","parse","value","Object","keys","includes","undefined","set","setTextState","editor","update","textNode","stateMapEntry","get","Error","StatePlugin","registerMutationListener","mutatedNodes","getEditorState","read","nodeKey","mutation","node","dom","getElementByKey","mergedStyles","create","forEach","stateEntry","stateValue","dataset","css","assign","style","cssText"],"sources":["../../../src/features/textState/textState.ts"],"sourcesContent":["import type { LexicalEditor, StateConfig } from 'lexical'\n\nimport { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext'\nimport { $forEachSelectedTextNode } from '@lexical/selection'\nimport { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical'\nimport { useEffect } from 'react'\n\nimport { type StateValues, type TextStateFeatureProps } from './feature.server.js'\n\nconst stateMap = new Map<\n string,\n {\n stateConfig: StateConfig<string, string | undefined>\n stateValues: StateValues\n }\n>()\n\nexport function registerTextStates(state: TextStateFeatureProps['state']) {\n for (const stateKey in state) {\n const stateValues = state[stateKey]!\n const stateConfig = createState(stateKey, {\n parse: (value) =>\n typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined,\n })\n stateMap.set(stateKey, { stateConfig, stateValues })\n }\n}\n\nexport function setTextState(editor: LexicalEditor, stateKey: string, value: string | undefined) {\n editor.update(() => {\n $forEachSelectedTextNode((textNode) => {\n const stateMapEntry = stateMap.get(stateKey)\n if (!stateMapEntry) {\n throw new Error(`State config for ${stateKey} not found`)\n }\n $setState(textNode, stateMapEntry.stateConfig, value)\n })\n })\n}\n\nexport function StatePlugin() {\n const [editor] = useLexicalComposerContext()\n\n useEffect(() => {\n return editor.registerMutationListener(TextNode, (mutatedNodes) => {\n editor.getEditorState().read(() => {\n for (const [nodeKey, mutation] of mutatedNodes) {\n if (mutation === 'destroyed') {\n continue\n }\n const node = $getNodeByKey(nodeKey)\n const dom = editor.getElementByKey(nodeKey)\n if (!node || !dom) {\n continue\n }\n\n const mergedStyles: Record<string, string> = Object.create(null)\n // Examples:\n // stateKey: 'color'\n // stateValue: 'bg-red'\n stateMap.forEach((stateEntry, stateKey) => {\n const stateValue = $getState(node, stateEntry.stateConfig)\n if (!stateValue) {\n // clear the previous dataset value for this key\n delete dom.dataset[stateKey]\n return\n } // skip - nothing else to do\n\n dom.dataset[stateKey] = stateValue\n\n const css = stateEntry.stateValues[stateValue]?.css\n if (css) {\n // merge existing styles with the new ones\n Object.assign(mergedStyles, css)\n }\n })\n\n // wipe previous inline styles once, then set the merged ones\n dom.style.cssText = ''\n Object.assign(dom.style, mergedStyles)\n }\n })\n })\n }, [editor])\n\n return null\n}\n"],"mappings":"AAEA,SAASA,yBAAyB,QAAQ;AAC1C,SAASC,wBAAwB,QAAQ;AACzC,SAASC,aAAa,EAAEC,SAAS,EAAEC,SAAS,EAAEC,WAAW,EAAEC,QAAQ,QAAQ;AAC3E,SAASC,SAAS,QAAQ;AAI1B,MAAMC,QAAA,GAAW,IAAIC,GAAA;AAQrB,OAAO,SAASC,mBAAmBC,KAAqC;EACtE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A,CAAOuB,MAAM,CAAC;UAC3D;UACA;UACA;UACAhC,QAAA,CAASiC,OAAO,CAAC,CAACC,UAAA,EAAY9B,QAAA;YAC5B,MAAM+B,UAAA,GAAaxC,SAAA,CAAUiC,IAAA,EAAMM,UAAA,CAAW5B,WAAW;YACzD,IAAI,CAAC6B,UAAA,EAAY;cACf;cACA,OAAON,GAAA,CAAIO,OAAO,CAAChC,QAAA,CAAS;cAC5B;YACF,EAAE;YAEFyB,GAAA,CAAIO,OAAO,CAAChC,QAAA,CAAS,GAAG+B,UAAA;YAExB,MAAME,GAAA,GAAMH,UAAA,CAAW7B,WAAW,CAAC8B,UAAA,CAAW,EAAEE,GAAA;YAChD,IAAIA,GAAA,EAAK;cACP;cACA5B,MAAA,CAAO6B,MAAM,CAACP,YAAA,EAAcM,GAAA;YAC9B;UACF;UAEA;UACAR,GAAA,CAAIU,KAAK,CAACC,OAAO,GAAG;UACpB/B,MAAA,CAAO6B,MAAM,CAACT,GAAA,CAAIU,KAAK,EAAER,YAAA;QAC3B;MACF;IACF;EACF,GAAG,CAAChB,MAAA,CAAO;EAEX,OAAO;AACT","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/richtext-lexical",
3
- "version": "3.42.0-internal.f9d0258",
3
+ "version": "3.42.0",
4
4
  "description": "The officially supported Lexical richtext adapter for Payload",
5
5
  "homepage": "https://payloadcms.com",
6
6
  "repository": {
@@ -368,8 +368,8 @@
368
368
  "react-error-boundary": "4.1.2",
369
369
  "ts-essentials": "10.0.3",
370
370
  "uuid": "10.0.0",
371
- "@payloadcms/translations": "3.42.0-internal.f9d0258",
372
- "@payloadcms/ui": "3.42.0-internal.f9d0258"
371
+ "@payloadcms/translations": "3.42.0",
372
+ "@payloadcms/ui": "3.42.0"
373
373
  },
374
374
  "devDependencies": {
375
375
  "@babel/cli": "7.27.2",
@@ -388,16 +388,16 @@
388
388
  "esbuild": "0.25.5",
389
389
  "esbuild-sass-plugin": "3.3.1",
390
390
  "swc-plugin-transform-remove-imports": "4.0.4",
391
- "@payloadcms/eslint-config": "3.28.0",
392
- "payload": "3.42.0-internal.f9d0258"
391
+ "payload": "3.42.0",
392
+ "@payloadcms/eslint-config": "3.28.0"
393
393
  },
394
394
  "peerDependencies": {
395
395
  "@faceless-ui/modal": "3.0.0-beta.2",
396
396
  "@faceless-ui/scroll-info": "2.0.0",
397
397
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
398
398
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
399
- "@payloadcms/next": "3.42.0-internal.f9d0258",
400
- "payload": "3.42.0-internal.f9d0258"
399
+ "@payloadcms/next": "3.42.0",
400
+ "payload": "3.42.0"
401
401
  },
402
402
  "engines": {
403
403
  "node": "^18.20.2 || >=20.9.0"