@payloadcms/richtext-lexical 3.39.0-canary.6 → 3.39.0-internal.1c212c9

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 (37) hide show
  1. package/dist/exports/client/{Field-DGC4DDYL.js → Field-PWFMMJ4H.js} +1 -1
  2. package/dist/exports/client/{Field-DGC4DDYL.js.map → Field-PWFMMJ4H.js.map} +1 -1
  3. package/dist/exports/client/bundled.css +1 -1
  4. package/dist/exports/client/index.d.ts +0 -1
  5. package/dist/exports/client/index.d.ts.map +1 -1
  6. package/dist/exports/client/index.js +10 -10
  7. package/dist/exports/client/index.js.map +4 -4
  8. package/dist/features/converters/lexicalToJSX/Component/index.d.ts +1 -0
  9. package/dist/features/converters/lexicalToJSX/Component/index.d.ts.map +1 -1
  10. package/dist/features/converters/lexicalToJSX/Component/index.js.map +1 -1
  11. package/dist/field/bundled.css +1 -1
  12. package/dist/index.d.ts +0 -2
  13. package/dist/index.d.ts.map +1 -1
  14. package/dist/index.js +0 -2
  15. package/dist/index.js.map +1 -1
  16. package/dist/lexical/plugins/TextPlugin/index.js.map +1 -1
  17. package/package.json +7 -7
  18. package/dist/features/textState/defaultColors.d.ts +0 -91
  19. package/dist/features/textState/defaultColors.d.ts.map +0 -1
  20. package/dist/features/textState/defaultColors.js +0 -386
  21. package/dist/features/textState/defaultColors.js.map +0 -1
  22. package/dist/features/textState/feature.client.d.ts +0 -3
  23. package/dist/features/textState/feature.client.d.ts.map +0 -1
  24. package/dist/features/textState/feature.client.js +0 -69
  25. package/dist/features/textState/feature.client.js.map +0 -1
  26. package/dist/features/textState/feature.server.d.ts +0 -60
  27. package/dist/features/textState/feature.server.d.ts.map +0 -1
  28. package/dist/features/textState/feature.server.js +0 -25
  29. package/dist/features/textState/feature.server.js.map +0 -1
  30. package/dist/features/textState/textState.d.ts +0 -6
  31. package/dist/features/textState/textState.d.ts.map +0 -1
  32. package/dist/features/textState/textState.js +0 -67
  33. package/dist/features/textState/textState.js.map +0 -1
  34. package/dist/lexical/ui/icons/TextState/index.d.ts +0 -5
  35. package/dist/lexical/ui/icons/TextState/index.d.ts.map +0 -1
  36. package/dist/lexical/ui/icons/TextState/index.js +0 -23
  37. package/dist/lexical/ui/icons/TextState/index.js.map +0 -1
@@ -1,67 +0,0 @@
1
- import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
2
- import { $forEachSelectedTextNode } from '@lexical/selection';
3
- import { $getNodeByKey, $getState, $setState, createState, TextNode } from 'lexical';
4
- import { useEffect } from 'react';
5
- const stateMap = new Map();
6
- export function registerTextStates(state) {
7
- for (const stateKey in state) {
8
- const stateValues = state[stateKey];
9
- const stateConfig = createState(stateKey, {
10
- parse: value => typeof value === 'string' && Object.keys(stateValues).includes(value) ? value : undefined
11
- });
12
- stateMap.set(stateKey, {
13
- stateConfig,
14
- stateValues
15
- });
16
- }
17
- }
18
- export function setTextState(editor, stateKey, value) {
19
- editor.update(() => {
20
- $forEachSelectedTextNode(textNode => {
21
- const stateMapEntry = stateMap.get(stateKey);
22
- if (!stateMapEntry) {
23
- throw new Error(`State config for ${stateKey} not found`);
24
- }
25
- $setState(textNode, stateMapEntry.stateConfig, value);
26
- });
27
- });
28
- }
29
- export function StatePlugin() {
30
- const [editor] = useLexicalComposerContext();
31
- useEffect(() => {
32
- return editor.registerMutationListener(TextNode, mutatedNodes => {
33
- editor.getEditorState().read(() => {
34
- for (const [nodeKey, mutation] of mutatedNodes) {
35
- if (mutation === 'destroyed') {
36
- continue;
37
- }
38
- const node = $getNodeByKey(nodeKey);
39
- const dom = editor.getElementByKey(nodeKey);
40
- if (!node || !dom) {
41
- continue;
42
- }
43
- // stateKey could be color for example
44
- stateMap.forEach((stateEntry, _stateKey) => {
45
- // stateValue could be bg-red for example
46
- const stateValue = $getState(node, stateEntry.stateConfig);
47
- if (!stateValue) {
48
- delete dom.dataset[_stateKey];
49
- dom.style.cssText = '';
50
- return;
51
- }
52
- dom.dataset[_stateKey] = stateValue;
53
- const css = stateEntry.stateValues[stateValue]?.css;
54
- if (!css) {
55
- return;
56
- }
57
- Object.entries(css).forEach(([key, value]) => {
58
- dom.style.setProperty(key, value);
59
- });
60
- });
61
- }
62
- });
63
- });
64
- }, [editor]);
65
- return null;
66
- }
67
- //# sourceMappingURL=textState.js.map
@@ -1 +0,0 @@
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,EAAU;MACxCG,KAAA,EAAQC,KAAA,IACN,OAAOA,KAAA,KAAU,YAAYC,MAAA,CAAOC,IAAI,CAACL,WAAA,EAAaM,QAAQ,CAACH,KAAA,IAASA,KAAA,GAAQI;IACpF;IACAZ,QAAA,CAASa,GAAG,CAACT,QAAA,EAAU;MAAEE,WAAA;MAAaD;IAAY;EACpD;AACF;AAEA,OAAO,SAASS,aAAaC,MAAqB,EAAEX,QAAgB,EAAEI,KAAyB;EAC7F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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,5 +0,0 @@
1
- import type { StyleObject } from '../../../../features/textState/feature.server.js';
2
- export declare const TextStateIcon: React.FC<{
3
- css?: StyleObject;
4
- }>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lexical/ui/icons/TextState/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAMnF,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC;IACnC,GAAG,CAAC,EAAE,WAAW,CAAA;CAClB,CAqBA,CAAA"}
@@ -1,23 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- function kebabToCamelCase(str) {
3
- return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
4
- }
5
- export const TextStateIcon = ({
6
- css
7
- }) => {
8
- const convertedCss = css ? Object.fromEntries(Object.entries(css).map(([key, value]) => [kebabToCamelCase(key), value])) : {};
9
- return /*#__PURE__*/_jsx("span", {
10
- style: {
11
- ...convertedCss,
12
- alignItems: 'center',
13
- borderRadius: '4px',
14
- display: 'flex',
15
- fontSize: '16px',
16
- height: '20px',
17
- justifyContent: 'center',
18
- width: '20px'
19
- },
20
- children: "A"
21
- });
22
- };
23
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["kebabToCamelCase","str","replace","_","letter","toUpperCase","TextStateIcon","css","convertedCss","Object","fromEntries","entries","map","key","value","_jsx","style","alignItems","borderRadius","display","fontSize","height","justifyContent","width"],"sources":["../../../../../src/lexical/ui/icons/TextState/index.tsx"],"sourcesContent":["import type { StyleObject } from '../../../../features/textState/feature.server.js'\n\nfunction kebabToCamelCase(str: string): string {\n return str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase())\n}\n\nexport const TextStateIcon: React.FC<{\n css?: StyleObject\n}> = ({ css }) => {\n const convertedCss = css\n ? Object.fromEntries(Object.entries(css).map(([key, value]) => [kebabToCamelCase(key), value]))\n : {}\n\n return (\n <span\n style={{\n ...convertedCss,\n alignItems: 'center',\n borderRadius: '4px',\n display: 'flex',\n fontSize: '16px',\n height: '20px',\n justifyContent: 'center',\n width: '20px',\n }}\n >\n A\n </span>\n )\n}\n"],"mappings":";AAEA,SAASA,iBAAiBC,GAAW;EACnC,OAAOA,GAAA,CAAIC,OAAO,CAAC,aAAa,CAACC,CAAA,EAAGC,MAAA,KAAWA,MAAA,CAAOC,WAAW;AACnE;AAEA,OAAO,MAAMC,aAAA,GAERA,CAAC;EAAEC;AAAG,CAAE;EACX,MAAMC,YAAA,GAAeD,GAAA,GACjBE,MAAA,CAAOC,WAAW,CAACD,MAAA,CAAOE,OAAO,CAACJ,GAAA,EAAKK,GAAG,CAAC,CAAC,CAACC,GAAA,EAAKC,KAAA,CAAM,KAAK,CAACd,gBAAA,CAAiBa,GAAA,GAAMC,KAAA,CAAM,KAC3F,CAAC;EAEL,oBACEC,IAAA,CAAC;IACCC,KAAA,EAAO;MACL,GAAGR,YAAY;MACfS,UAAA,EAAY;MACZC,YAAA,EAAc;MACdC,OAAA,EAAS;MACTC,QAAA,EAAU;MACVC,MAAA,EAAQ;MACRC,cAAA,EAAgB;MAChBC,KAAA,EAAO;IACT;cACD;;AAIL","ignoreList":[]}