@webiny/lexical-nodes 6.3.0 → 6.4.0-beta.1

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 (45) hide show
  1. package/FontColorNode.js +94 -119
  2. package/FontColorNode.js.map +1 -1
  3. package/HeadingNode.js +160 -183
  4. package/HeadingNode.js.map +1 -1
  5. package/ImageNode.js +101 -131
  6. package/ImageNode.js.map +1 -1
  7. package/LinkNode.js +228 -315
  8. package/LinkNode.js.map +1 -1
  9. package/ListItemNode.js +249 -320
  10. package/ListItemNode.js.map +1 -1
  11. package/ListNode.js +174 -223
  12. package/ListNode.js.map +1 -1
  13. package/ParagraphNode.js +119 -148
  14. package/ParagraphNode.js.map +1 -1
  15. package/QuoteNode.js +97 -102
  16. package/QuoteNode.js.map +1 -1
  17. package/components/ImageNode/ImageComponent.js +117 -147
  18. package/components/ImageNode/ImageComponent.js.map +1 -1
  19. package/components/ImageNode/ImageResizer.js +167 -194
  20. package/components/ImageNode/ImageResizer.js.map +1 -1
  21. package/generateInitialLexicalValue.js +20 -23
  22. package/generateInitialLexicalValue.js.map +1 -1
  23. package/index.js +38 -26
  24. package/index.js.map +1 -1
  25. package/package.json +4 -4
  26. package/prepareLexicalState.js +30 -43
  27. package/prepareLexicalState.js.map +1 -1
  28. package/types.js +0 -3
  29. package/utils/clearNodeFormating.js +14 -15
  30. package/utils/clearNodeFormating.js.map +1 -1
  31. package/utils/formatList.js +277 -368
  32. package/utils/formatList.js.map +1 -1
  33. package/utils/formatToHeading.js +6 -13
  34. package/utils/formatToHeading.js.map +1 -1
  35. package/utils/formatToParagraph.js +6 -7
  36. package/utils/formatToParagraph.js.map +1 -1
  37. package/utils/formatToQuote.js +6 -13
  38. package/utils/formatToQuote.js.map +1 -1
  39. package/utils/getStyleId.js +6 -11
  40. package/utils/getStyleId.js.map +1 -1
  41. package/utils/listNode.js +60 -84
  42. package/utils/listNode.js.map +1 -1
  43. package/utils/toggleLink.js +67 -118
  44. package/utils/toggleLink.js.map +1 -1
  45. package/types.js.map +0 -1
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"names":["ParagraphNode","BaseParagraphNode","HeadingNode","BaseHeadingNode","QuoteNode","BaseQuoteNode","CodeHighlightNode","CodeNode","HashtagNode","MarkNode","OverflowNode","AutoLinkNode","LinkNode","FontColorNode","ListNode","ListItemNode","ImageNode","allNodes","replace","with","withKlass","node","getTag"],"sources":["index.ts"],"sourcesContent":["import {\n type Klass,\n type LexicalNode,\n type LexicalNodeReplacement,\n ParagraphNode as BaseParagraphNode\n} from \"lexical\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode.js\";\nimport { FontColorNode } from \"./FontColorNode.js\";\nimport { ListNode } from \"./ListNode.js\";\nimport { ListItemNode } from \"./ListItemNode.js\";\nimport { HeadingNode } from \"./HeadingNode.js\";\nimport { ParagraphNode } from \"./ParagraphNode.js\";\nimport { QuoteNode } from \"./QuoteNode.js\";\nimport { ImageNode } from \"./ImageNode.js\";\n\nexport * from \"./FontColorNode.js\";\nexport * from \"./ListNode.js\";\nexport * from \"./ListItemNode.js\";\nexport * from \"./HeadingNode.js\";\nexport * from \"./ParagraphNode.js\";\nexport * from \"./QuoteNode.js\";\nexport * from \"./ImageNode.js\";\nexport * from \"./LinkNode.js\";\n\nexport * from \"./utils/formatList.js\";\nexport * from \"./utils/listNode.js\";\nexport * from \"./utils/formatToQuote.js\";\nexport * from \"./utils/formatToHeading.js\";\nexport * from \"./utils/formatToParagraph.js\";\nexport * from \"./utils/clearNodeFormating.js\";\nexport * from \"./utils/toggleLink.js\";\nexport * from \"./prepareLexicalState.js\";\nexport * from \"./generateInitialLexicalValue.js\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement> = [\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n },\n withKlass: ParagraphNode\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n },\n withKlass: HeadingNode\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n },\n withKlass: QuoteNode\n },\n ImageNode,\n ListNode,\n ListItemNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n FontColorNode,\n QuoteNode,\n LinkNode\n];\n"],"mappings":"AAAA,SAIIA,aAAa,IAAIC,iBAAiB,QAC/B,SAAS;AAChB,SAASC,WAAW,IAAIC,eAAe,EAAEC,SAAS,IAAIC,aAAa,QAAQ,oBAAoB;AAC/F,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,eAAe;AAC3D,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,QAAQ,QAAQ,eAAe;AACxC,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,SAASC,YAAY,EAAEC,QAAQ;AAC/B,SAASC,aAAa;AACtB,SAASC,QAAQ;AACjB,SAASC,YAAY;AACrB,SAASb,WAAW;AACpB,SAASF,aAAa;AACtB,SAASI,SAAS;AAClB,SAASY,SAAS;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMC,QAAoE,GAAG,CAChFjB,aAAa,EACb;EACIkB,OAAO,EAAEjB,iBAAiB;EAC1BkB,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAInB,aAAa,CAAC,CAAC;EAC9B,CAAC;EACDoB,SAAS,EAAEpB;AACf,CAAC,EACDE,WAAW,EACX;EACIgB,OAAO,EAAEf,eAAe;EACxBgB,IAAI,EAAGE,IAAqB,IAAK;IAC7B,OAAO,IAAInB,WAAW,CAACmB,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;EACzC,CAAC;EACDF,SAAS,EAAElB;AACf,CAAC,EACDE,SAAS,EACT;EACIc,OAAO,EAAEb,aAAa;EACtBc,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAIf,SAAS,CAAC,CAAC;EAC1B,CAAC;EACDgB,SAAS,EAAEhB;AACf,CAAC,EACDY,SAAS,EACTF,QAAQ,EACRC,YAAY,EACZR,QAAQ,EACRC,WAAW,EACXF,iBAAiB,EACjBK,YAAY,EACZD,YAAY,EACZD,QAAQ,EACRI,aAAa,EACbT,SAAS,EACTQ,QAAQ,CACX","ignoreList":[]}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import {\n type Klass,\n type LexicalNode,\n type LexicalNodeReplacement,\n ParagraphNode as BaseParagraphNode\n} from \"lexical\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode.js\";\nimport { FontColorNode } from \"./FontColorNode.js\";\nimport { ListNode } from \"./ListNode.js\";\nimport { ListItemNode } from \"./ListItemNode.js\";\nimport { HeadingNode } from \"./HeadingNode.js\";\nimport { ParagraphNode } from \"./ParagraphNode.js\";\nimport { QuoteNode } from \"./QuoteNode.js\";\nimport { ImageNode } from \"./ImageNode.js\";\n\nexport * from \"./FontColorNode.js\";\nexport * from \"./ListNode.js\";\nexport * from \"./ListItemNode.js\";\nexport * from \"./HeadingNode.js\";\nexport * from \"./ParagraphNode.js\";\nexport * from \"./QuoteNode.js\";\nexport * from \"./ImageNode.js\";\nexport * from \"./LinkNode.js\";\n\nexport * from \"./utils/formatList.js\";\nexport * from \"./utils/listNode.js\";\nexport * from \"./utils/formatToQuote.js\";\nexport * from \"./utils/formatToHeading.js\";\nexport * from \"./utils/formatToParagraph.js\";\nexport * from \"./utils/clearNodeFormating.js\";\nexport * from \"./utils/toggleLink.js\";\nexport * from \"./prepareLexicalState.js\";\nexport * from \"./generateInitialLexicalValue.js\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement> = [\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n },\n withKlass: ParagraphNode\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n },\n withKlass: HeadingNode\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n },\n withKlass: QuoteNode\n },\n ImageNode,\n ListNode,\n ListItemNode,\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n FontColorNode,\n QuoteNode,\n LinkNode\n];\n"],"names":["allNodes","ParagraphNode","BaseParagraphNode","HeadingNode","BaseHeadingNode","node","QuoteNode","BaseQuoteNode","ImageNode","ListNode","ListItemNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","OverflowNode","MarkNode","FontColorNode","LinkNode"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCO,MAAMA,WAAuE;IAChFC;IACA;QACI,SAASC;QACT,MAAM,IACK,IAAID;QAEf,WAAWA;IACf;IACAE;IACA;QACI,SAASC;QACT,MAAM,CAACC,OACI,IAAIF,oCAAYE,KAAK,MAAM;QAEtC,WAAWF;IACf;IACAG;IACA;QACI,SAASC;QACT,MAAM,IACK,IAAID;QAEf,WAAWA;IACf;IACAE;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAC;IACAX;IACAY;CACH"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webiny/lexical-nodes",
3
- "version": "6.3.0",
3
+ "version": "6.4.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": "./index.js",
@@ -17,12 +17,12 @@
17
17
  "@lexical/selection": "0.44.0",
18
18
  "@lexical/utils": "0.44.0",
19
19
  "@types/prismjs": "1.26.6",
20
- "@webiny/lexical-theme": "6.3.0",
20
+ "@webiny/lexical-theme": "6.4.0-beta.1",
21
21
  "lexical": "0.44.0",
22
22
  "react": "18.3.1"
23
23
  },
24
24
  "devDependencies": {
25
- "@webiny/build-tools": "6.3.0"
25
+ "@webiny/build-tools": "6.4.0-beta.1"
26
26
  },
27
27
  "publishConfig": {
28
28
  "access": "public",
@@ -35,5 +35,5 @@
35
35
  ]
36
36
  }
37
37
  },
38
- "gitHead": "7cefe15431dbd65504e1f58147dc9e55bcbfa693"
38
+ "gitHead": "73237b8243693038c072bae1c0b783387448cbbe"
39
39
  }
@@ -1,53 +1,40 @@
1
1
  import { generateInitialLexicalValue } from "./generateInitialLexicalValue.js";
2
-
3
- /**
4
- * Remap various node types to their latest form.
5
- */
6
2
  const nodeTypeMap = {
7
- "webiny-list": "wby-list",
8
- list: "wby-list",
9
- "webiny-listitem": "wby-list-item",
10
- "list-item": "wby-list-item",
11
- "font-color-node": "wby-font-color",
12
- "font-color": "wby-font-color",
13
- "heading-element": "wby-heading",
14
- heading: "wby-heading",
15
- "paragraph-element": "wby-paragraph",
16
- paragraph: "wby-paragraph",
17
- "webiny-quote": "wby-quote",
18
- quote: "wby-quote",
19
- image: "wby-image",
20
- link: "wby-link"
3
+ "webiny-list": "wby-list",
4
+ list: "wby-list",
5
+ "webiny-listitem": "wby-list-item",
6
+ "list-item": "wby-list-item",
7
+ "font-color-node": "wby-font-color",
8
+ "font-color": "wby-font-color",
9
+ "heading-element": "wby-heading",
10
+ heading: "wby-heading",
11
+ "paragraph-element": "wby-paragraph",
12
+ paragraph: "wby-paragraph",
13
+ "webiny-quote": "wby-quote",
14
+ quote: "wby-quote",
15
+ image: "wby-image",
16
+ link: "wby-link"
21
17
  };
22
-
23
- // Migrate old node types
24
18
  function deepReplaceType(node) {
25
- if (nodeTypeMap.hasOwnProperty(node.type)) {
26
- node.type = nodeTypeMap[node.type];
27
- }
28
- if (node.children) {
29
- node.children.forEach(deepReplaceType);
30
- }
19
+ if (nodeTypeMap.hasOwnProperty(node.type)) node.type = nodeTypeMap[node.type];
20
+ if (node.children) node.children.forEach(deepReplaceType);
31
21
  }
32
- export const prepareLexicalState = value => {
33
- if (!value) {
34
- return generateInitialLexicalValue();
35
- }
36
- if (typeof value === "string") {
22
+ const prepareLexicalState = (value)=>{
23
+ if (!value) return generateInitialLexicalValue();
24
+ if ("string" == typeof value) try {
25
+ const stateAsObject = JSON.parse(value);
26
+ deepReplaceType(stateAsObject.root);
27
+ return JSON.stringify(stateAsObject);
28
+ } catch {
29
+ return generateInitialLexicalValue();
30
+ }
37
31
  try {
38
- const stateAsObject = JSON.parse(value);
39
- deepReplaceType(stateAsObject.root);
40
- return JSON.stringify(stateAsObject);
41
- } catch {
42
- return generateInitialLexicalValue();
32
+ deepReplaceType(value.root);
33
+ return JSON.stringify(value);
34
+ } catch {
35
+ return generateInitialLexicalValue();
43
36
  }
44
- }
45
- try {
46
- deepReplaceType(value.root);
47
- return JSON.stringify(value);
48
- } catch {
49
- return generateInitialLexicalValue();
50
- }
51
37
  };
38
+ export { prepareLexicalState };
52
39
 
53
40
  //# sourceMappingURL=prepareLexicalState.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["generateInitialLexicalValue","nodeTypeMap","list","heading","paragraph","quote","image","link","deepReplaceType","node","hasOwnProperty","type","children","forEach","prepareLexicalState","value","stateAsObject","JSON","parse","root","stringify"],"sources":["prepareLexicalState.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport { generateInitialLexicalValue } from \"./generateInitialLexicalValue.js\";\n\n/**\n * Remap various node types to their latest form.\n */\nconst nodeTypeMap: Record<string, string> = {\n \"webiny-list\": \"wby-list\",\n list: \"wby-list\",\n \"webiny-listitem\": \"wby-list-item\",\n \"list-item\": \"wby-list-item\",\n \"font-color-node\": \"wby-font-color\",\n \"font-color\": \"wby-font-color\",\n \"heading-element\": \"wby-heading\",\n heading: \"wby-heading\",\n \"paragraph-element\": \"wby-paragraph\",\n paragraph: \"wby-paragraph\",\n \"webiny-quote\": \"wby-quote\",\n quote: \"wby-quote\",\n image: \"wby-image\",\n link: \"wby-link\"\n};\n\n// Migrate old node types\nfunction deepReplaceType(node: any): void {\n if (nodeTypeMap.hasOwnProperty(node.type)) {\n node.type = nodeTypeMap[node.type];\n }\n\n if (node.children) {\n node.children.forEach(deepReplaceType);\n }\n}\n\nexport const prepareLexicalState = (\n value: string | SerializedEditorState | null | undefined\n): string => {\n if (!value) {\n return generateInitialLexicalValue();\n }\n\n if (typeof value === \"string\") {\n try {\n const stateAsObject = JSON.parse(value) as SerializedEditorState;\n deepReplaceType(stateAsObject.root);\n return JSON.stringify(stateAsObject);\n } catch {\n return generateInitialLexicalValue();\n }\n }\n\n try {\n deepReplaceType(value.root);\n return JSON.stringify(value);\n } catch {\n return generateInitialLexicalValue();\n }\n};\n"],"mappings":"AACA,SAASA,2BAA2B;;AAEpC;AACA;AACA;AACA,MAAMC,WAAmC,GAAG;EACxC,aAAa,EAAE,UAAU;EACzBC,IAAI,EAAE,UAAU;EAChB,iBAAiB,EAAE,eAAe;EAClC,WAAW,EAAE,eAAe;EAC5B,iBAAiB,EAAE,gBAAgB;EACnC,YAAY,EAAE,gBAAgB;EAC9B,iBAAiB,EAAE,aAAa;EAChCC,OAAO,EAAE,aAAa;EACtB,mBAAmB,EAAE,eAAe;EACpCC,SAAS,EAAE,eAAe;EAC1B,cAAc,EAAE,WAAW;EAC3BC,KAAK,EAAE,WAAW;EAClBC,KAAK,EAAE,WAAW;EAClBC,IAAI,EAAE;AACV,CAAC;;AAED;AACA,SAASC,eAAeA,CAACC,IAAS,EAAQ;EACtC,IAAIR,WAAW,CAACS,cAAc,CAACD,IAAI,CAACE,IAAI,CAAC,EAAE;IACvCF,IAAI,CAACE,IAAI,GAAGV,WAAW,CAACQ,IAAI,CAACE,IAAI,CAAC;EACtC;EAEA,IAAIF,IAAI,CAACG,QAAQ,EAAE;IACfH,IAAI,CAACG,QAAQ,CAACC,OAAO,CAACL,eAAe,CAAC;EAC1C;AACJ;AAEA,OAAO,MAAMM,mBAAmB,GAC5BC,KAAwD,IAC/C;EACT,IAAI,CAACA,KAAK,EAAE;IACR,OAAOf,2BAA2B,CAAC,CAAC;EACxC;EAEA,IAAI,OAAOe,KAAK,KAAK,QAAQ,EAAE;IAC3B,IAAI;MACA,MAAMC,aAAa,GAAGC,IAAI,CAACC,KAAK,CAACH,KAAK,CAA0B;MAChEP,eAAe,CAACQ,aAAa,CAACG,IAAI,CAAC;MACnC,OAAOF,IAAI,CAACG,SAAS,CAACJ,aAAa,CAAC;IACxC,CAAC,CAAC,MAAM;MACJ,OAAOhB,2BAA2B,CAAC,CAAC;IACxC;EACJ;EAEA,IAAI;IACAQ,eAAe,CAACO,KAAK,CAACI,IAAI,CAAC;IAC3B,OAAOF,IAAI,CAACG,SAAS,CAACL,KAAK,CAAC;EAChC,CAAC,CAAC,MAAM;IACJ,OAAOf,2BAA2B,CAAC,CAAC;EACxC;AACJ,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"prepareLexicalState.js","sources":["../src/prepareLexicalState.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport { generateInitialLexicalValue } from \"./generateInitialLexicalValue.js\";\n\n/**\n * Remap various node types to their latest form.\n */\nconst nodeTypeMap: Record<string, string> = {\n \"webiny-list\": \"wby-list\",\n list: \"wby-list\",\n \"webiny-listitem\": \"wby-list-item\",\n \"list-item\": \"wby-list-item\",\n \"font-color-node\": \"wby-font-color\",\n \"font-color\": \"wby-font-color\",\n \"heading-element\": \"wby-heading\",\n heading: \"wby-heading\",\n \"paragraph-element\": \"wby-paragraph\",\n paragraph: \"wby-paragraph\",\n \"webiny-quote\": \"wby-quote\",\n quote: \"wby-quote\",\n image: \"wby-image\",\n link: \"wby-link\"\n};\n\n// Migrate old node types\nfunction deepReplaceType(node: any): void {\n if (nodeTypeMap.hasOwnProperty(node.type)) {\n node.type = nodeTypeMap[node.type];\n }\n\n if (node.children) {\n node.children.forEach(deepReplaceType);\n }\n}\n\nexport const prepareLexicalState = (\n value: string | SerializedEditorState | null | undefined\n): string => {\n if (!value) {\n return generateInitialLexicalValue();\n }\n\n if (typeof value === \"string\") {\n try {\n const stateAsObject = JSON.parse(value) as SerializedEditorState;\n deepReplaceType(stateAsObject.root);\n return JSON.stringify(stateAsObject);\n } catch {\n return generateInitialLexicalValue();\n }\n }\n\n try {\n deepReplaceType(value.root);\n return JSON.stringify(value);\n } catch {\n return generateInitialLexicalValue();\n }\n};\n"],"names":["nodeTypeMap","deepReplaceType","node","prepareLexicalState","value","generateInitialLexicalValue","stateAsObject","JSON"],"mappings":";AAMA,MAAMA,cAAsC;IACxC,eAAe;IACf,MAAM;IACN,mBAAmB;IACnB,aAAa;IACb,mBAAmB;IACnB,cAAc;IACd,mBAAmB;IACnB,SAAS;IACT,qBAAqB;IACrB,WAAW;IACX,gBAAgB;IAChB,OAAO;IACP,OAAO;IACP,MAAM;AACV;AAGA,SAASC,gBAAgBC,IAAS;IAC9B,IAAIF,YAAY,cAAc,CAACE,KAAK,IAAI,GACpCA,KAAK,IAAI,GAAGF,WAAW,CAACE,KAAK,IAAI,CAAC;IAGtC,IAAIA,KAAK,QAAQ,EACbA,KAAK,QAAQ,CAAC,OAAO,CAACD;AAE9B;AAEO,MAAME,sBAAsB,CAC/BC;IAEA,IAAI,CAACA,OACD,OAAOC;IAGX,IAAI,AAAiB,YAAjB,OAAOD,OACP,IAAI;QACA,MAAME,gBAAgBC,KAAK,KAAK,CAACH;QACjCH,gBAAgBK,cAAc,IAAI;QAClC,OAAOC,KAAK,SAAS,CAACD;IAC1B,EAAE,OAAM;QACJ,OAAOD;IACX;IAGJ,IAAI;QACAJ,gBAAgBG,MAAM,IAAI;QAC1B,OAAOG,KAAK,SAAS,CAACH;IAC1B,EAAE,OAAM;QACJ,OAAOC;IACX;AACJ"}
package/types.js CHANGED
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- //# sourceMappingURL=types.js.map
@@ -2,22 +2,21 @@ import { $isRangeSelection, $isTextNode } from "lexical";
2
2
  import { $selectAll } from "@lexical/selection";
3
3
  import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
4
4
  import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
5
- export const clearNodeFormatting = (activeEditor, selection) => {
6
- activeEditor.update(() => {
7
- if ($isRangeSelection(selection)) {
8
- $selectAll(selection);
9
- selection.getNodes().forEach(node => {
10
- if ($isTextNode(node)) {
11
- node.setFormat(0);
12
- node.setStyle("");
13
- $getNearestBlockElementAncestorOrThrow(node).setFormat("");
5
+ const clearNodeFormatting = (activeEditor, selection)=>{
6
+ activeEditor.update(()=>{
7
+ if ($isRangeSelection(selection)) {
8
+ $selectAll(selection);
9
+ selection.getNodes().forEach((node)=>{
10
+ if ($isTextNode(node)) {
11
+ node.setFormat(0);
12
+ node.setStyle("");
13
+ $getNearestBlockElementAncestorOrThrow(node).setFormat("");
14
+ }
15
+ if ($isDecoratorBlockNode(node)) node.setFormat("");
16
+ });
14
17
  }
15
- if ($isDecoratorBlockNode(node)) {
16
- node.setFormat("");
17
- }
18
- });
19
- }
20
- });
18
+ });
21
19
  };
20
+ export { clearNodeFormatting };
22
21
 
23
22
  //# sourceMappingURL=clearNodeFormating.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["$isRangeSelection","$isTextNode","$selectAll","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode","clearNodeFormatting","activeEditor","selection","update","getNodes","forEach","node","setFormat","setStyle"],"sources":["clearNodeFormating.ts"],"sourcesContent":["import type { LexicalEditor, RangeSelection } from \"lexical\";\nimport { $isRangeSelection, $isTextNode } from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"mappings":"AACA,SAASA,iBAAiB,EAAEC,WAAW,QAAQ,SAAS;AACxD,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,sCAAsC,QAAQ,gBAAgB;AACvE,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,OAAO,MAAMC,mBAAmB,GAAGA,CAC/BC,YAA2B,EAC3BC,SAAgC,KAC/B;EACDD,YAAY,CAACE,MAAM,CAAC,MAAM;IACtB,IAAIR,iBAAiB,CAACO,SAAS,CAAC,EAAE;MAC9BL,UAAU,CAACK,SAAS,CAAC;MACrBA,SAAS,CAACE,QAAQ,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,IAAI;QACjC,IAAIV,WAAW,CAACU,IAAI,CAAC,EAAE;UACnBA,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC;UACjBD,IAAI,CAACE,QAAQ,CAAC,EAAE,CAAC;UACjBV,sCAAsC,CAACQ,IAAI,CAAC,CAACC,SAAS,CAAC,EAAE,CAAC;QAC9D;QACA,IAAIR,qBAAqB,CAACO,IAAI,CAAC,EAAE;UAC7BA,IAAI,CAACC,SAAS,CAAC,EAAE,CAAC;QACtB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"utils/clearNodeFormating.js","sources":["../../src/utils/clearNodeFormating.ts"],"sourcesContent":["import type { LexicalEditor, RangeSelection } from \"lexical\";\nimport { $isRangeSelection, $isTextNode } from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"names":["clearNodeFormatting","activeEditor","selection","$isRangeSelection","$selectAll","node","$isTextNode","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode"],"mappings":";;;;AAMO,MAAMA,sBAAsB,CAC/BC,cACAC;IAEAD,aAAa,MAAM,CAAC;QAChB,IAAIE,kBAAkBD,YAAY;YAC9BE,WAAWF;YACXA,UAAU,QAAQ,GAAG,OAAO,CAACG,CAAAA;gBACzB,IAAIC,YAAYD,OAAO;oBACnBA,KAAK,SAAS,CAAC;oBACfA,KAAK,QAAQ,CAAC;oBACdE,uCAAuCF,MAAM,SAAS,CAAC;gBAC3D;gBACA,IAAIG,sBAAsBH,OACtBA,KAAK,SAAS,CAAC;YAEvB;QACJ;IACJ;AACJ"}