@webiny/lexical-nodes 0.0.0-unstable.06b2ede40f

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 (81) hide show
  1. package/FontColorNode.d.ts +43 -0
  2. package/FontColorNode.js +122 -0
  3. package/FontColorNode.js.map +1 -0
  4. package/HeadingNode.d.ts +40 -0
  5. package/HeadingNode.js +195 -0
  6. package/HeadingNode.js.map +1 -0
  7. package/ImageNode.d.ts +56 -0
  8. package/ImageNode.js +164 -0
  9. package/ImageNode.js.map +1 -0
  10. package/LICENSE +21 -0
  11. package/LinkNode.d.ts +101 -0
  12. package/LinkNode.js +327 -0
  13. package/LinkNode.js.map +1 -0
  14. package/ListItemNode.d.ts +43 -0
  15. package/ListItemNode.js +363 -0
  16. package/ListItemNode.js.map +1 -0
  17. package/ListNode.d.ts +53 -0
  18. package/ListNode.js +248 -0
  19. package/ListNode.js.map +1 -0
  20. package/ParagraphNode.d.ts +39 -0
  21. package/ParagraphNode.js +157 -0
  22. package/ParagraphNode.js.map +1 -0
  23. package/QuoteNode.d.ts +38 -0
  24. package/QuoteNode.js +120 -0
  25. package/QuoteNode.js.map +1 -0
  26. package/README.md +6 -0
  27. package/components/ImageNode/ContentEditable.css +22 -0
  28. package/components/ImageNode/ContentEditable.d.ts +12 -0
  29. package/components/ImageNode/ContentEditable.js +19 -0
  30. package/components/ImageNode/ContentEditable.js.map +1 -0
  31. package/components/ImageNode/ImageComponent.css +43 -0
  32. package/components/ImageNode/ImageComponent.d.ts +18 -0
  33. package/components/ImageNode/ImageComponent.js +235 -0
  34. package/components/ImageNode/ImageComponent.js.map +1 -0
  35. package/components/ImageNode/ImageResizer.d.ts +24 -0
  36. package/components/ImageNode/ImageResizer.js +211 -0
  37. package/components/ImageNode/ImageResizer.js.map +1 -0
  38. package/components/ImageNode/Placeholder.css +20 -0
  39. package/components/ImageNode/Placeholder.d.ts +15 -0
  40. package/components/ImageNode/Placeholder.js +24 -0
  41. package/components/ImageNode/Placeholder.js.map +1 -0
  42. package/components/ImageNode/SharedHistoryContext.d.ts +10 -0
  43. package/components/ImageNode/SharedHistoryContext.js +19 -0
  44. package/components/ImageNode/SharedHistoryContext.js.map +1 -0
  45. package/generateInitialLexicalValue.d.ts +4 -0
  46. package/generateInitialLexicalValue.js +27 -0
  47. package/generateInitialLexicalValue.js.map +1 -0
  48. package/index.d.ts +19 -0
  49. package/index.js +51 -0
  50. package/index.js.map +1 -0
  51. package/package.json +39 -0
  52. package/prepareLexicalState.d.ts +2 -0
  53. package/prepareLexicalState.js +53 -0
  54. package/prepareLexicalState.js.map +1 -0
  55. package/types.d.ts +11 -0
  56. package/types.js +3 -0
  57. package/types.js.map +1 -0
  58. package/utils/clearNodeFormating.d.ts +2 -0
  59. package/utils/clearNodeFormating.js +23 -0
  60. package/utils/clearNodeFormating.js.map +1 -0
  61. package/utils/formatList.d.ts +19 -0
  62. package/utils/formatList.js +412 -0
  63. package/utils/formatList.js.map +1 -0
  64. package/utils/formatToHeading.d.ts +3 -0
  65. package/utils/formatToHeading.js +19 -0
  66. package/utils/formatToHeading.js.map +1 -0
  67. package/utils/formatToParagraph.d.ts +2 -0
  68. package/utils/formatToParagraph.js +13 -0
  69. package/utils/formatToParagraph.js.map +1 -0
  70. package/utils/formatToQuote.d.ts +2 -0
  71. package/utils/formatToQuote.js +19 -0
  72. package/utils/formatToQuote.js.map +1 -0
  73. package/utils/getStyleId.d.ts +11 -0
  74. package/utils/getStyleId.js +14 -0
  75. package/utils/getStyleId.js.map +1 -0
  76. package/utils/listNode.d.ts +21 -0
  77. package/utils/listNode.js +103 -0
  78. package/utils/listNode.js.map +1 -0
  79. package/utils/toggleLink.d.ts +8 -0
  80. package/utils/toggleLink.js +131 -0
  81. package/utils/toggleLink.js.map +1 -0
@@ -0,0 +1,211 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import * as React from "react";
10
+ import { useRef } from "react";
11
+ function clamp(value, min, max) {
12
+ return Math.min(Math.max(value, min), max);
13
+ }
14
+ const Direction = {
15
+ east: 1 << 0,
16
+ north: 1 << 3,
17
+ south: 1 << 1,
18
+ west: 1 << 2
19
+ };
20
+ export function ImageResizer({
21
+ onResizeStart,
22
+ onResizeEnd,
23
+ buttonRef,
24
+ imageRef,
25
+ maxWidth,
26
+ editor,
27
+ showCaption,
28
+ setShowCaption,
29
+ captionsEnabled
30
+ }) {
31
+ const controlWrapperRef = useRef(null);
32
+ const userSelect = useRef({
33
+ priority: "",
34
+ value: "default"
35
+ });
36
+ const positioningRef = useRef({
37
+ currentHeight: 0,
38
+ currentWidth: 0,
39
+ direction: 0,
40
+ isResizing: false,
41
+ ratio: 0,
42
+ startHeight: 0,
43
+ startWidth: 0,
44
+ startX: 0,
45
+ startY: 0
46
+ });
47
+ const editorRootElement = editor.getRootElement();
48
+ // Find max width, accounting for editor padding.
49
+ const maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
50
+ const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
51
+ const minWidth = 100;
52
+ const minHeight = 100;
53
+ const setStartCursor = direction => {
54
+ const ew = direction === Direction.east || direction === Direction.west;
55
+ const ns = direction === Direction.north || direction === Direction.south;
56
+ const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
57
+ const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
58
+ if (editorRootElement !== null) {
59
+ editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
60
+ }
61
+ if (document.body !== null) {
62
+ document.body.style.setProperty("cursor", `${cursorDir}-resize`, "important");
63
+ userSelect.current.value = document.body.style.getPropertyValue("-webkit-user-select");
64
+ userSelect.current.priority = document.body.style.getPropertyPriority("-webkit-user-select");
65
+ document.body.style.setProperty("-webkit-user-select", `none`, "important");
66
+ }
67
+ };
68
+ const setEndCursor = () => {
69
+ if (editorRootElement !== null) {
70
+ editorRootElement.style.setProperty("cursor", "text");
71
+ }
72
+ if (document.body !== null) {
73
+ document.body.style.setProperty("cursor", "default");
74
+ document.body.style.setProperty("-webkit-user-select", userSelect.current.value, userSelect.current.priority);
75
+ }
76
+ };
77
+ const handlePointerDown = (event, direction) => {
78
+ if (!editor.isEditable()) {
79
+ return;
80
+ }
81
+ const image = imageRef.current;
82
+ const controlWrapper = controlWrapperRef.current;
83
+ if (image !== null && controlWrapper !== null) {
84
+ const {
85
+ width,
86
+ height
87
+ } = image.getBoundingClientRect();
88
+ const positioning = positioningRef.current;
89
+ positioning.startWidth = width;
90
+ positioning.startHeight = height;
91
+ positioning.ratio = width / height;
92
+ positioning.currentWidth = width;
93
+ positioning.currentHeight = height;
94
+ positioning.startX = event.clientX;
95
+ positioning.startY = event.clientY;
96
+ positioning.isResizing = true;
97
+ positioning.direction = direction;
98
+ setStartCursor(direction);
99
+ onResizeStart();
100
+ controlWrapper.classList.add("image-control-wrapper--resizing");
101
+ image.style.height = `${height}px`;
102
+ image.style.width = `${width}px`;
103
+ document.addEventListener("pointermove", handlePointerMove);
104
+ document.addEventListener("pointerup", handlePointerUp);
105
+ }
106
+ };
107
+ const handlePointerMove = event => {
108
+ const image = imageRef.current;
109
+ const positioning = positioningRef.current;
110
+ const isHorizontal = positioning.direction & (Direction.east | Direction.west);
111
+ const isVertical = positioning.direction & (Direction.south | Direction.north);
112
+ if (image !== null && positioning.isResizing) {
113
+ // Corner cursor
114
+ if (isHorizontal && isVertical) {
115
+ let diff = Math.floor(positioning.startX - event.clientX);
116
+ diff = positioning.direction & Direction.east ? -diff : diff;
117
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
118
+ const height = width / positioning.ratio;
119
+ image.style.width = `${width}px`;
120
+ image.style.height = `${height}px`;
121
+ positioning.currentHeight = height;
122
+ positioning.currentWidth = width;
123
+ } else if (isVertical) {
124
+ let diff = Math.floor(positioning.startY - event.clientY);
125
+ diff = positioning.direction & Direction.south ? -diff : diff;
126
+ const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
127
+ image.style.height = `${height}px`;
128
+ positioning.currentHeight = height;
129
+ } else {
130
+ let diff = Math.floor(positioning.startX - event.clientX);
131
+ diff = positioning.direction & Direction.east ? -diff : diff;
132
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
133
+ image.style.width = `${width}px`;
134
+ positioning.currentWidth = width;
135
+ }
136
+ }
137
+ };
138
+ const handlePointerUp = () => {
139
+ const image = imageRef.current;
140
+ const positioning = positioningRef.current;
141
+ const controlWrapper = controlWrapperRef.current;
142
+ if (image !== null && controlWrapper !== null && positioning.isResizing) {
143
+ const width = positioning.currentWidth;
144
+ const height = positioning.currentHeight;
145
+ positioning.startWidth = 0;
146
+ positioning.startHeight = 0;
147
+ positioning.ratio = 0;
148
+ positioning.startX = 0;
149
+ positioning.startY = 0;
150
+ positioning.currentWidth = 0;
151
+ positioning.currentHeight = 0;
152
+ positioning.isResizing = false;
153
+ controlWrapper.classList.remove("image-control-wrapper--resizing");
154
+ setEndCursor();
155
+ onResizeEnd(width, height);
156
+ document.removeEventListener("pointermove", handlePointerMove);
157
+ document.removeEventListener("pointerup", handlePointerUp);
158
+ }
159
+ };
160
+ return /*#__PURE__*/React.createElement("div", {
161
+ ref: controlWrapperRef
162
+ }, !showCaption && captionsEnabled && /*#__PURE__*/React.createElement("button", {
163
+ className: "image-caption-button",
164
+ ref: buttonRef,
165
+ onClick: () => {
166
+ setShowCaption(!showCaption);
167
+ }
168
+ }, "Add Caption"), /*#__PURE__*/React.createElement("div", {
169
+ className: "image-resizer image-resizer-n",
170
+ onPointerDown: event => {
171
+ handlePointerDown(event, Direction.north);
172
+ }
173
+ }), /*#__PURE__*/React.createElement("div", {
174
+ className: "image-resizer image-resizer-ne",
175
+ onPointerDown: event => {
176
+ handlePointerDown(event, Direction.north | Direction.east);
177
+ }
178
+ }), /*#__PURE__*/React.createElement("div", {
179
+ className: "image-resizer image-resizer-e",
180
+ onPointerDown: event => {
181
+ handlePointerDown(event, Direction.east);
182
+ }
183
+ }), /*#__PURE__*/React.createElement("div", {
184
+ className: "image-resizer image-resizer-se",
185
+ onPointerDown: event => {
186
+ handlePointerDown(event, Direction.south | Direction.east);
187
+ }
188
+ }), /*#__PURE__*/React.createElement("div", {
189
+ className: "image-resizer image-resizer-s",
190
+ onPointerDown: event => {
191
+ handlePointerDown(event, Direction.south);
192
+ }
193
+ }), /*#__PURE__*/React.createElement("div", {
194
+ className: "image-resizer image-resizer-sw",
195
+ onPointerDown: event => {
196
+ handlePointerDown(event, Direction.south | Direction.west);
197
+ }
198
+ }), /*#__PURE__*/React.createElement("div", {
199
+ className: "image-resizer image-resizer-w",
200
+ onPointerDown: event => {
201
+ handlePointerDown(event, Direction.west);
202
+ }
203
+ }), /*#__PURE__*/React.createElement("div", {
204
+ className: "image-resizer image-resizer-nw",
205
+ onPointerDown: event => {
206
+ handlePointerDown(event, Direction.north | Direction.west);
207
+ }
208
+ }));
209
+ }
210
+
211
+ //# sourceMappingURL=ImageResizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useRef","clamp","value","min","max","Math","Direction","east","north","south","west","ImageResizer","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","userSelect","priority","positioningRef","currentHeight","currentWidth","direction","isResizing","ratio","startHeight","startWidth","startX","startY","editorRootElement","getRootElement","maxWidthContainer","getBoundingClientRect","width","maxHeightContainer","height","minWidth","minHeight","setStartCursor","ew","ns","nwse","cursorDir","style","setProperty","document","body","current","getPropertyValue","getPropertyPriority","setEndCursor","handlePointerDown","event","isEditable","image","controlWrapper","positioning","clientX","clientY","classList","add","addEventListener","handlePointerMove","handlePointerUp","isHorizontal","isVertical","diff","floor","remove","removeEventListener","createElement","ref","className","onClick","onPointerDown"],"sources":["ImageResizer.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport type { LexicalEditor } from \"lexical\";\n\nimport * as React from \"react\";\nimport { useRef } from \"react\";\n\nfunction clamp(value: number, min: number, max: number) {\n return Math.min(Math.max(value, min), max);\n}\n\nconst Direction = {\n east: 1 << 0,\n north: 1 << 3,\n south: 1 << 1,\n west: 1 << 2\n};\n\nexport function ImageResizer({\n onResizeStart,\n onResizeEnd,\n buttonRef,\n imageRef,\n maxWidth,\n editor,\n showCaption,\n setShowCaption,\n captionsEnabled\n}: {\n editor: LexicalEditor;\n buttonRef: { current: null | HTMLButtonElement };\n imageRef: { current: null | HTMLElement };\n maxWidth?: number;\n onResizeEnd: (width: \"inherit\" | number, height: \"inherit\" | number) => void;\n onResizeStart: () => void;\n setShowCaption: (show: boolean) => void;\n showCaption: boolean;\n captionsEnabled: boolean;\n}): JSX.Element {\n const controlWrapperRef = useRef<HTMLDivElement>(null);\n const userSelect = useRef({\n priority: \"\",\n value: \"default\"\n });\n const positioningRef = useRef<{\n currentHeight: \"inherit\" | number;\n currentWidth: \"inherit\" | number;\n direction: number;\n isResizing: boolean;\n ratio: number;\n startHeight: number;\n startWidth: number;\n startX: number;\n startY: number;\n }>({\n currentHeight: 0,\n currentWidth: 0,\n direction: 0,\n isResizing: false,\n ratio: 0,\n startHeight: 0,\n startWidth: 0,\n startX: 0,\n startY: 0\n });\n const editorRootElement = editor.getRootElement();\n // Find max width, accounting for editor padding.\n const maxWidthContainer = maxWidth\n ? maxWidth\n : editorRootElement !== null\n ? editorRootElement.getBoundingClientRect().width - 20\n : 100;\n const maxHeightContainer =\n editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;\n\n const minWidth = 100;\n const minHeight = 100;\n\n const setStartCursor = (direction: number) => {\n const ew = direction === Direction.east || direction === Direction.west;\n const ns = direction === Direction.north || direction === Direction.south;\n const nwse =\n (direction & Direction.north && direction & Direction.west) ||\n (direction & Direction.south && direction & Direction.east);\n\n const cursorDir = ew ? \"ew\" : ns ? \"ns\" : nwse ? \"nwse\" : \"nesw\";\n\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", `${cursorDir}-resize`, \"important\");\n userSelect.current.value = document.body.style.getPropertyValue(\"-webkit-user-select\");\n userSelect.current.priority =\n document.body.style.getPropertyPriority(\"-webkit-user-select\");\n document.body.style.setProperty(\"-webkit-user-select\", `none`, \"important\");\n }\n };\n\n const setEndCursor = () => {\n if (editorRootElement !== null) {\n editorRootElement.style.setProperty(\"cursor\", \"text\");\n }\n if (document.body !== null) {\n document.body.style.setProperty(\"cursor\", \"default\");\n document.body.style.setProperty(\n \"-webkit-user-select\",\n userSelect.current.value,\n userSelect.current.priority\n );\n }\n };\n\n const handlePointerDown = (event: React.PointerEvent<HTMLDivElement>, direction: number) => {\n if (!editor.isEditable()) {\n return;\n }\n\n const image = imageRef.current;\n const controlWrapper = controlWrapperRef.current;\n\n if (image !== null && controlWrapper !== null) {\n const { width, height } = image.getBoundingClientRect();\n const positioning = positioningRef.current;\n positioning.startWidth = width;\n positioning.startHeight = height;\n positioning.ratio = width / height;\n positioning.currentWidth = width;\n positioning.currentHeight = height;\n positioning.startX = event.clientX;\n positioning.startY = event.clientY;\n positioning.isResizing = true;\n positioning.direction = direction;\n\n setStartCursor(direction);\n onResizeStart();\n\n controlWrapper.classList.add(\"image-control-wrapper--resizing\");\n image.style.height = `${height}px`;\n image.style.width = `${width}px`;\n\n document.addEventListener(\"pointermove\", handlePointerMove);\n document.addEventListener(\"pointerup\", handlePointerUp);\n }\n };\n const handlePointerMove = (event: PointerEvent) => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n\n const isHorizontal = positioning.direction & (Direction.east | Direction.west);\n const isVertical = positioning.direction & (Direction.south | Direction.north);\n\n if (image !== null && positioning.isResizing) {\n // Corner cursor\n if (isHorizontal && isVertical) {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n const height = width / positioning.ratio;\n image.style.width = `${width}px`;\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n positioning.currentWidth = width;\n } else if (isVertical) {\n let diff = Math.floor(positioning.startY - event.clientY);\n diff = positioning.direction & Direction.south ? -diff : diff;\n\n const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);\n\n image.style.height = `${height}px`;\n positioning.currentHeight = height;\n } else {\n let diff = Math.floor(positioning.startX - event.clientX);\n diff = positioning.direction & Direction.east ? -diff : diff;\n\n const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);\n\n image.style.width = `${width}px`;\n positioning.currentWidth = width;\n }\n }\n };\n const handlePointerUp = () => {\n const image = imageRef.current;\n const positioning = positioningRef.current;\n const controlWrapper = controlWrapperRef.current;\n if (image !== null && controlWrapper !== null && positioning.isResizing) {\n const width = positioning.currentWidth;\n const height = positioning.currentHeight;\n positioning.startWidth = 0;\n positioning.startHeight = 0;\n positioning.ratio = 0;\n positioning.startX = 0;\n positioning.startY = 0;\n positioning.currentWidth = 0;\n positioning.currentHeight = 0;\n positioning.isResizing = false;\n\n controlWrapper.classList.remove(\"image-control-wrapper--resizing\");\n\n setEndCursor();\n onResizeEnd(width, height);\n\n document.removeEventListener(\"pointermove\", handlePointerMove);\n document.removeEventListener(\"pointerup\", handlePointerUp);\n }\n };\n return (\n <div ref={controlWrapperRef}>\n {!showCaption && captionsEnabled && (\n <button\n className=\"image-caption-button\"\n ref={buttonRef}\n onClick={() => {\n setShowCaption(!showCaption);\n }}\n >\n Add Caption\n </button>\n )}\n <div\n className=\"image-resizer image-resizer-n\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north);\n }}\n />\n <div\n className=\"image-resizer image-resizer-ne\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-e\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-se\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.east);\n }}\n />\n <div\n className=\"image-resizer image-resizer-s\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south);\n }}\n />\n <div\n className=\"image-resizer image-resizer-sw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.south | Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-w\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.west);\n }}\n />\n <div\n className=\"image-resizer image-resizer-nw\"\n onPointerDown={event => {\n handlePointerDown(event, Direction.north | Direction.west);\n }}\n />\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,MAAM,QAAQ,OAAO;AAE9B,SAASC,KAAKA,CAACC,KAAa,EAAEC,GAAW,EAAEC,GAAW,EAAE;EACpD,OAAOC,IAAI,CAACF,GAAG,CAACE,IAAI,CAACD,GAAG,CAACF,KAAK,EAAEC,GAAG,CAAC,EAAEC,GAAG,CAAC;AAC9C;AAEA,MAAME,SAAS,GAAG;EACdC,IAAI,EAAE,CAAC,IAAI,CAAC;EACZC,KAAK,EAAE,CAAC,IAAI,CAAC;EACbC,KAAK,EAAE,CAAC,IAAI,CAAC;EACbC,IAAI,EAAE,CAAC,IAAI;AACf,CAAC;AAED,OAAO,SAASC,YAAYA,CAAC;EACzBC,aAAa;EACbC,WAAW;EACXC,SAAS;EACTC,QAAQ;EACRC,QAAQ;EACRC,MAAM;EACNC,WAAW;EACXC,cAAc;EACdC;AAWJ,CAAC,EAAe;EACZ,MAAMC,iBAAiB,GAAGrB,MAAM,CAAiB,IAAI,CAAC;EAC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D,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACC,IAAI,CAAC;IAC5C;EAAE,CACL,CAAC,eACFR,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,GAAGH,SAAS,CAACC,IAAI,CAAC;IAC9D;EAAE,CACL,CAAC,eACFR,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,+BAA+B;IACzCE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,CAAC;IAC7C;EAAE,CACL,CAAC,eACFV,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACG,KAAK,GAAGH,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,+BAA+B;IACzCE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACI,IAAI,CAAC;IAC5C;EAAE,CACL,CAAC,eACFX,KAAA,CAAA4E,aAAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAEtB,KAAK,IAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEnD,SAAS,CAACE,KAAK,GAAGF,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CACA,CAAC;AAEd","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ *
8
+ */
9
+
10
+ .Placeholder__root {
11
+ font-size: 15px;
12
+ margin-top: -20px;
13
+ color: #999;
14
+ overflow: hidden;
15
+ position: relative;
16
+ text-overflow: ellipsis;
17
+ user-select: none;
18
+ white-space: nowrap;
19
+ pointer-events: none;
20
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+ import "./Placeholder.css";
9
+ import * as React from "react";
10
+ import type { ReactNode } from "react";
11
+ export declare function Placeholder({ children, className, styles }: {
12
+ children: ReactNode;
13
+ className?: string;
14
+ styles?: React.CSSProperties;
15
+ }): JSX.Element;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ *
4
+ * This source code is licensed under the MIT license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ *
7
+ */
8
+
9
+ import "./Placeholder.css";
10
+ import * as React from "react";
11
+ export function Placeholder({
12
+ children,
13
+ className,
14
+ styles
15
+ }) {
16
+ return /*#__PURE__*/React.createElement("div", {
17
+ style: {
18
+ ...styles
19
+ },
20
+ className: className || "Placeholder__root"
21
+ }, children);
22
+ }
23
+
24
+ //# sourceMappingURL=Placeholder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","Placeholder","children","className","styles","createElement","style"],"sources":["Placeholder.tsx"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n */\n\nimport \"./Placeholder.css\";\n\nimport * as React from \"react\";\nimport type { ReactNode } from \"react\";\n\nexport function Placeholder({\n children,\n className,\n styles\n}: {\n children: ReactNode;\n className?: string;\n styles?: React.CSSProperties;\n}): JSX.Element {\n return (\n <div style={{ ...styles }} className={className || \"Placeholder__root\"}>\n {children}\n </div>\n );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AAEA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,OAAO,SAASC,WAAWA,CAAC;EACxBC,QAAQ;EACRC,SAAS;EACTC;AAKJ,CAAC,EAAe;EACZ,oBACIJ,KAAA,CAAAK,aAAA;IAAKC,KAAK,EAAE;MAAE,GAAGF;IAAO,CAAE;IAACD,SAAS,EAAEA,SAAS,IAAI;EAAoB,GAClED,QACA,CAAC;AAEd","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from "react";
2
+ import type { HistoryState } from "@lexical/history";
3
+ type ContextShape = {
4
+ historyState?: HistoryState;
5
+ };
6
+ export declare const SharedHistoryContext: ({ children }: {
7
+ children: ReactNode;
8
+ }) => JSX.Element;
9
+ export declare const useSharedHistoryContext: () => ContextShape;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ import * as React from "react";
2
+ import { createContext, useContext, useMemo } from "react";
3
+ import { createEmptyHistoryState } from "@lexical/history";
4
+ const Context = /*#__PURE__*/createContext({});
5
+ export const SharedHistoryContext = ({
6
+ children
7
+ }) => {
8
+ const historyContext = useMemo(() => ({
9
+ historyState: createEmptyHistoryState()
10
+ }), []);
11
+ return /*#__PURE__*/React.createElement(Context.Provider, {
12
+ value: historyContext
13
+ }, children);
14
+ };
15
+ export const useSharedHistoryContext = () => {
16
+ return useContext(Context);
17
+ };
18
+
19
+ //# sourceMappingURL=SharedHistoryContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","createContext","useContext","useMemo","createEmptyHistoryState","Context","SharedHistoryContext","children","historyContext","historyState","createElement","Provider","value","useSharedHistoryContext"],"sources":["SharedHistoryContext.tsx"],"sourcesContent":["import * as React from \"react\";\nimport type { ReactNode } from \"react\";\nimport { createContext, useContext, useMemo } from \"react\";\nimport type { HistoryState } from \"@lexical/history\";\nimport { createEmptyHistoryState } from \"@lexical/history\";\n\ntype ContextShape = {\n historyState?: HistoryState;\n};\n\nconst Context: React.Context<ContextShape> = createContext({});\n\nexport const SharedHistoryContext = ({ children }: { children: ReactNode }): JSX.Element => {\n const historyContext = useMemo(() => ({ historyState: createEmptyHistoryState() }), []);\n return <Context.Provider value={historyContext}>{children}</Context.Provider>;\n};\n\nexport const useSharedHistoryContext = (): ContextShape => {\n return useContext(Context);\n};\n"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAASC,aAAa,EAAEC,UAAU,EAAEC,OAAO,QAAQ,OAAO;AAE1D,SAASC,uBAAuB,QAAQ,kBAAkB;AAM1D,MAAMC,OAAoC,gBAAGJ,aAAa,CAAC,CAAC,CAAC,CAAC;AAE9D,OAAO,MAAMK,oBAAoB,GAAGA,CAAC;EAAEC;AAAkC,CAAC,KAAkB;EACxF,MAAMC,cAAc,GAAGL,OAAO,CAAC,OAAO;IAAEM,YAAY,EAAEL,uBAAuB,CAAC;EAAE,CAAC,CAAC,EAAE,EAAE,CAAC;EACvF,oBAAOJ,KAAA,CAAAU,aAAA,CAACL,OAAO,CAACM,QAAQ;IAACC,KAAK,EAAEJ;EAAe,GAAED,QAA2B,CAAC;AACjF,CAAC;AAED,OAAO,MAAMM,uBAAuB,GAAGA,CAAA,KAAoB;EACvD,OAAOX,UAAU,CAACG,OAAO,CAAC;AAC9B,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @description Basic JSON data string that will initialize the editor.
3
+ */
4
+ export declare const generateInitialLexicalValue: () => string;
@@ -0,0 +1,27 @@
1
+ const defaultLexicalValue = JSON.stringify({
2
+ root: {
3
+ children: [{
4
+ children: [],
5
+ direction: null,
6
+ format: "",
7
+ indent: 0,
8
+ styles: [],
9
+ type: "wby-paragraph",
10
+ version: 1
11
+ }],
12
+ direction: null,
13
+ format: "",
14
+ indent: 0,
15
+ type: "root",
16
+ version: 1
17
+ }
18
+ });
19
+
20
+ /**
21
+ * @description Basic JSON data string that will initialize the editor.
22
+ */
23
+ export const generateInitialLexicalValue = () => {
24
+ return defaultLexicalValue;
25
+ };
26
+
27
+ //# sourceMappingURL=generateInitialLexicalValue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["defaultLexicalValue","JSON","stringify","root","children","direction","format","indent","styles","type","version","generateInitialLexicalValue"],"sources":["generateInitialLexicalValue.ts"],"sourcesContent":["const defaultLexicalValue = JSON.stringify({\n root: {\n children: [\n {\n children: [],\n direction: null,\n format: \"\",\n indent: 0,\n styles: [],\n type: \"wby-paragraph\",\n version: 1\n }\n ],\n direction: null,\n format: \"\",\n indent: 0,\n type: \"root\",\n version: 1\n }\n});\n\n/**\n * @description Basic JSON data string that will initialize the editor.\n */\nexport const generateInitialLexicalValue = (): string => {\n return defaultLexicalValue;\n};\n"],"mappings":"AAAA,MAAMA,mBAAmB,GAAGC,IAAI,CAACC,SAAS,CAAC;EACvCC,IAAI,EAAE;IACFC,QAAQ,EAAE,CACN;MACIA,QAAQ,EAAE,EAAE;MACZC,SAAS,EAAE,IAAI;MACfC,MAAM,EAAE,EAAE;MACVC,MAAM,EAAE,CAAC;MACTC,MAAM,EAAE,EAAE;MACVC,IAAI,EAAE,eAAe;MACrBC,OAAO,EAAE;IACb,CAAC,CACJ;IACDL,SAAS,EAAE,IAAI;IACfC,MAAM,EAAE,EAAE;IACVC,MAAM,EAAE,CAAC;IACTE,IAAI,EAAE,MAAM;IACZC,OAAO,EAAE;EACb;AACJ,CAAC,CAAC;;AAEF;AACA;AACA;AACA,OAAO,MAAMC,2BAA2B,GAAGA,CAAA,KAAc;EACrD,OAAOX,mBAAmB;AAC9B,CAAC","ignoreList":[]}
package/index.d.ts ADDED
@@ -0,0 +1,19 @@
1
+ import { type Klass, type LexicalNode, type LexicalNodeReplacement } from "lexical";
2
+ export * from "./FontColorNode";
3
+ export * from "./ListNode";
4
+ export * from "./ListItemNode";
5
+ export * from "./HeadingNode";
6
+ export * from "./ParagraphNode";
7
+ export * from "./QuoteNode";
8
+ export * from "./ImageNode";
9
+ export * from "./LinkNode";
10
+ export * from "./utils/formatList";
11
+ export * from "./utils/listNode";
12
+ export * from "./utils/formatToQuote";
13
+ export * from "./utils/formatToHeading";
14
+ export * from "./utils/formatToParagraph";
15
+ export * from "./utils/clearNodeFormating";
16
+ export * from "./utils/toggleLink";
17
+ export * from "./prepareLexicalState";
18
+ export * from "./generateInitialLexicalValue";
19
+ export declare const allNodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;
package/index.js ADDED
@@ -0,0 +1,51 @@
1
+ import { ParagraphNode as BaseParagraphNode } from "lexical";
2
+ import { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
3
+ import { CodeHighlightNode, CodeNode } from "@lexical/code";
4
+ import { HashtagNode } from "@lexical/hashtag";
5
+ import { MarkNode } from "@lexical/mark";
6
+ import { OverflowNode } from "@lexical/overflow";
7
+ import { AutoLinkNode, LinkNode } from "./LinkNode";
8
+ import { FontColorNode } from "./FontColorNode";
9
+ import { ListNode } from "./ListNode";
10
+ import { ListItemNode } from "./ListItemNode";
11
+ import { HeadingNode } from "./HeadingNode";
12
+ import { ParagraphNode } from "./ParagraphNode";
13
+ import { QuoteNode } from "./QuoteNode";
14
+ import { ImageNode } from "./ImageNode";
15
+ export * from "./FontColorNode";
16
+ export * from "./ListNode";
17
+ export * from "./ListItemNode";
18
+ export * from "./HeadingNode";
19
+ export * from "./ParagraphNode";
20
+ export * from "./QuoteNode";
21
+ export * from "./ImageNode";
22
+ export * from "./LinkNode";
23
+ export * from "./utils/formatList";
24
+ export * from "./utils/listNode";
25
+ export * from "./utils/formatToQuote";
26
+ export * from "./utils/formatToHeading";
27
+ export * from "./utils/formatToParagraph";
28
+ export * from "./utils/clearNodeFormating";
29
+ export * from "./utils/toggleLink";
30
+ export * from "./prepareLexicalState";
31
+ export * from "./generateInitialLexicalValue";
32
+
33
+ // This is a list of all the nodes that our Lexical implementation supports OOTB.
34
+ export const allNodes = [ParagraphNode, {
35
+ replace: BaseParagraphNode,
36
+ with: () => {
37
+ return new ParagraphNode();
38
+ }
39
+ }, HeadingNode, {
40
+ replace: BaseHeadingNode,
41
+ with: node => {
42
+ return new HeadingNode(node.getTag());
43
+ }
44
+ }, QuoteNode, {
45
+ replace: BaseQuoteNode,
46
+ with: () => {
47
+ return new QuoteNode();
48
+ }
49
+ }, ImageNode, ListNode, ListItemNode, CodeNode, HashtagNode, CodeHighlightNode, AutoLinkNode, OverflowNode, MarkNode, FontColorNode, QuoteNode, LinkNode];
50
+
51
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +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","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\";\nimport { FontColorNode } from \"./FontColorNode\";\nimport { ListNode } from \"./ListNode\";\nimport { ListItemNode } from \"./ListItemNode\";\nimport { HeadingNode } from \"./HeadingNode\";\nimport { ParagraphNode } from \"./ParagraphNode\";\nimport { QuoteNode } from \"./QuoteNode\";\nimport { ImageNode } from \"./ImageNode\";\n\nexport * from \"./FontColorNode\";\nexport * from \"./ListNode\";\nexport * from \"./ListItemNode\";\nexport * from \"./HeadingNode\";\nexport * from \"./ParagraphNode\";\nexport * from \"./QuoteNode\";\nexport * from \"./ImageNode\";\nexport * from \"./LinkNode\";\n\nexport * from \"./utils/formatList\";\nexport * from \"./utils/listNode\";\nexport * from \"./utils/formatToQuote\";\nexport * from \"./utils/formatToHeading\";\nexport * from \"./utils/formatToParagraph\";\nexport * from \"./utils/clearNodeFormating\";\nexport * from \"./utils/toggleLink\";\nexport * from \"./prepareLexicalState\";\nexport * from \"./generateInitialLexicalValue\";\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 },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\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;AACJ,CAAC,EACDE,WAAW,EACX;EACIgB,OAAO,EAAEf,eAAe;EACxBgB,IAAI,EAAGC,IAAqB,IAAK;IAC7B,OAAO,IAAIlB,WAAW,CAACkB,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;EACzC;AACJ,CAAC,EACDjB,SAAS,EACT;EACIc,OAAO,EAAEb,aAAa;EACtBc,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAIf,SAAS,CAAC,CAAC;EAC1B;AACJ,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":[]}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@webiny/lexical-nodes",
3
+ "version": "0.0.0-unstable.06b2ede40f",
4
+ "dependencies": {
5
+ "@lexical/code": "0.23.1",
6
+ "@lexical/hashtag": "0.23.1",
7
+ "@lexical/history": "0.23.1",
8
+ "@lexical/list": "0.23.1",
9
+ "@lexical/mark": "0.23.1",
10
+ "@lexical/overflow": "0.23.1",
11
+ "@lexical/react": "0.23.1",
12
+ "@lexical/rich-text": "0.23.1",
13
+ "@lexical/selection": "0.23.1",
14
+ "@lexical/utils": "0.23.1",
15
+ "@types/prismjs": "1.26.4",
16
+ "@webiny/lexical-theme": "0.0.0-unstable.06b2ede40f",
17
+ "lexical": "0.23.1"
18
+ },
19
+ "devDependencies": {
20
+ "@webiny/project-utils": "0.0.0-unstable.06b2ede40f",
21
+ "react": "18.2.0"
22
+ },
23
+ "publishConfig": {
24
+ "access": "public",
25
+ "directory": "dist"
26
+ },
27
+ "scripts": {
28
+ "build": "node ../cli/bin.js run build",
29
+ "watch": "node ../cli/bin.js run watch"
30
+ },
31
+ "adio": {
32
+ "ignore": {
33
+ "dependencies": [
34
+ "@types/prismjs"
35
+ ]
36
+ }
37
+ },
38
+ "gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
39
+ }
@@ -0,0 +1,2 @@
1
+ import type { SerializedEditorState } from "lexical";
2
+ export declare const prepareLexicalState: (value: string | SerializedEditorState | null | undefined) => string;
@@ -0,0 +1,53 @@
1
+ import { generateInitialLexicalValue } from "./generateInitialLexicalValue";
2
+
3
+ /**
4
+ * Remap various node types to their latest form.
5
+ */
6
+ 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"
21
+ };
22
+
23
+ // Migrate old node types
24
+ 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
+ }
31
+ }
32
+ export const prepareLexicalState = value => {
33
+ if (!value) {
34
+ return generateInitialLexicalValue();
35
+ }
36
+ if (typeof value === "string") {
37
+ try {
38
+ const stateAsObject = JSON.parse(value);
39
+ deepReplaceType(stateAsObject.root);
40
+ return JSON.stringify(stateAsObject);
41
+ } catch {
42
+ return generateInitialLexicalValue();
43
+ }
44
+ }
45
+ try {
46
+ deepReplaceType(value.root);
47
+ return JSON.stringify(value);
48
+ } catch (e) {
49
+ return generateInitialLexicalValue();
50
+ }
51
+ };
52
+
53
+ //# sourceMappingURL=prepareLexicalState.js.map
@@ -0,0 +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","e"],"sources":["prepareLexicalState.ts"],"sourcesContent":["import type { SerializedEditorState } from \"lexical\";\nimport { generateInitialLexicalValue } from \"./generateInitialLexicalValue\";\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 (e) {\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,OAAOM,CAAC,EAAE;IACR,OAAOrB,2BAA2B,CAAC,CAAC;EACxC;AACJ,CAAC","ignoreList":[]}
package/types.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type ThemeStyleType = "typography" | "colors" | "fonts";
2
+ export interface ThemeStyleValue {
3
+ styleId: string;
4
+ type: ThemeStyleType;
5
+ }
6
+ export interface TypographyStylesNode {
7
+ getStyleId: () => string | undefined;
8
+ setStyleId: (id: string) => void;
9
+ getClassName: () => string | undefined;
10
+ setClassName: (className: string) => void;
11
+ }
package/types.js ADDED
@@ -0,0 +1,3 @@
1
+ export {};
2
+
3
+ //# sourceMappingURL=types.js.map
package/types.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["export type ThemeStyleType = \"typography\" | \"colors\" | \"fonts\";\n\nexport interface ThemeStyleValue {\n styleId: string;\n type: ThemeStyleType;\n}\n\nexport interface TypographyStylesNode {\n getStyleId: () => string | undefined;\n setStyleId: (id: string) => void;\n getClassName: () => string | undefined;\n setClassName: (className: string) => void;\n}\n"],"mappings":"","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ import type { LexicalEditor, RangeSelection } from "lexical";
2
+ export declare const clearNodeFormatting: (activeEditor: LexicalEditor, selection: RangeSelection | null) => void;
@@ -0,0 +1,23 @@
1
+ import { $isRangeSelection, $isTextNode } from "lexical";
2
+ import { $selectAll } from "@lexical/selection";
3
+ import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
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("");
14
+ }
15
+ if ($isDecoratorBlockNode(node)) {
16
+ node.setFormat("");
17
+ }
18
+ });
19
+ }
20
+ });
21
+ };
22
+
23
+ //# sourceMappingURL=clearNodeFormating.js.map