@webiny/lexical-nodes 5.44.1-beta.0 → 5.45.0-beta.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.
Files changed (83) hide show
  1. package/FontColorNode.d.ts +6 -6
  2. package/FontColorNode.js +102 -145
  3. package/FontColorNode.js.map +1 -1
  4. package/HeadingNode.d.ts +29 -17
  5. package/HeadingNode.js +184 -152
  6. package/HeadingNode.js.map +1 -1
  7. package/ImageNode.d.ts +1 -11
  8. package/ImageNode.js +119 -190
  9. package/ImageNode.js.map +1 -1
  10. package/LinkNode.d.ts +2 -2
  11. package/LinkNode.js +249 -346
  12. package/LinkNode.js.map +1 -1
  13. package/ListItemNode.d.ts +4 -3
  14. package/ListItemNode.js +275 -354
  15. package/ListItemNode.js.map +1 -1
  16. package/ListNode.d.ts +28 -14
  17. package/ListNode.js +170 -209
  18. package/ListNode.js.map +1 -1
  19. package/ParagraphNode.d.ts +28 -16
  20. package/ParagraphNode.js +143 -179
  21. package/ParagraphNode.js.map +1 -1
  22. package/QuoteNode.d.ts +26 -19
  23. package/QuoteNode.js +102 -188
  24. package/QuoteNode.js.map +1 -1
  25. package/README.md +9 -4
  26. package/components/ImageNode/ImageComponent.d.ts +2 -7
  27. package/components/ImageNode/ImageComponent.js +72 -166
  28. package/components/ImageNode/ImageComponent.js.map +1 -1
  29. package/components/ImageNode/ImageResizer.d.ts +1 -8
  30. package/components/ImageNode/ImageResizer.js +74 -89
  31. package/components/ImageNode/ImageResizer.js.map +1 -1
  32. package/generateInitialLexicalValue.d.ts +4 -0
  33. package/generateInitialLexicalValue.js +27 -0
  34. package/generateInitialLexicalValue.js.map +1 -0
  35. package/index.d.ts +19 -23
  36. package/index.js +50 -233
  37. package/index.js.map +1 -1
  38. package/package.json +16 -20
  39. package/prepareLexicalState.d.ts +2 -0
  40. package/prepareLexicalState.js +53 -0
  41. package/prepareLexicalState.js.map +1 -0
  42. package/types.d.ts +4 -5
  43. package/types.js +1 -5
  44. package/types.js.map +1 -1
  45. package/utils/clearNodeFormating.d.ts +1 -1
  46. package/utils/clearNodeFormating.js +12 -18
  47. package/utils/clearNodeFormating.js.map +1 -1
  48. package/utils/formatList.d.ts +4 -4
  49. package/utils/formatList.js +171 -208
  50. package/utils/formatList.js.map +1 -1
  51. package/utils/formatToHeading.d.ts +2 -2
  52. package/utils/formatToHeading.js +8 -15
  53. package/utils/formatToHeading.js.map +1 -1
  54. package/utils/formatToParagraph.d.ts +1 -1
  55. package/utils/formatToParagraph.js +8 -16
  56. package/utils/formatToParagraph.js.map +1 -1
  57. package/utils/formatToQuote.d.ts +1 -1
  58. package/utils/formatToQuote.js +8 -15
  59. package/utils/formatToQuote.js.map +1 -1
  60. package/utils/getStyleId.d.ts +11 -0
  61. package/utils/getStyleId.js +14 -0
  62. package/utils/getStyleId.js.map +1 -0
  63. package/utils/listNode.d.ts +2 -2
  64. package/utils/listNode.js +37 -50
  65. package/utils/listNode.js.map +1 -1
  66. package/utils/toggleLink.d.ts +1 -1
  67. package/utils/toggleLink.js +41 -45
  68. package/utils/toggleLink.js.map +1 -1
  69. package/TypographyNode.d.ts +0 -39
  70. package/TypographyNode.js +0 -146
  71. package/TypographyNode.js.map +0 -1
  72. package/components/ImageNode/ContentEditable.css +0 -22
  73. package/components/ImageNode/ContentEditable.d.ts +0 -12
  74. package/components/ImageNode/ContentEditable.js +0 -26
  75. package/components/ImageNode/ContentEditable.js.map +0 -1
  76. package/components/ImageNode/ImageComponent.css +0 -43
  77. package/components/ImageNode/Placeholder.css +0 -20
  78. package/components/ImageNode/Placeholder.d.ts +0 -15
  79. package/components/ImageNode/Placeholder.js +0 -30
  80. package/components/ImageNode/Placeholder.js.map +0 -1
  81. package/components/ImageNode/SharedHistoryContext.d.ts +0 -10
  82. package/components/ImageNode/SharedHistoryContext.js +0 -27
  83. package/components/ImageNode/SharedHistoryContext.js.map +0 -1
@@ -1,12 +1,3 @@
1
- "use strict";
2
-
3
- var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.ImageResizer = ImageResizer;
8
- var _react = _interopRequireWildcard(require("react"));
9
- var React = _react;
10
1
  /**
11
2
  * Copyright (c) Meta Platforms, Inc. and affiliates.
12
3
  *
@@ -15,31 +6,30 @@ var React = _react;
15
6
  *
16
7
  */
17
8
 
9
+ import * as React from "react";
10
+ import { useRef } from "react";
18
11
  function clamp(value, min, max) {
19
12
  return Math.min(Math.max(value, min), max);
20
13
  }
21
- var Direction = {
14
+ const Direction = {
22
15
  east: 1 << 0,
23
16
  north: 1 << 3,
24
17
  south: 1 << 1,
25
18
  west: 1 << 2
26
19
  };
27
- function ImageResizer(_ref) {
28
- var onResizeStart = _ref.onResizeStart,
29
- onResizeEnd = _ref.onResizeEnd,
30
- buttonRef = _ref.buttonRef,
31
- imageRef = _ref.imageRef,
32
- maxWidth = _ref.maxWidth,
33
- editor = _ref.editor,
34
- showCaption = _ref.showCaption,
35
- setShowCaption = _ref.setShowCaption,
36
- captionsEnabled = _ref.captionsEnabled;
37
- var controlWrapperRef = (0, _react.useRef)(null);
38
- var userSelect = (0, _react.useRef)({
20
+ export function ImageResizer({
21
+ onResizeStart,
22
+ onResizeEnd,
23
+ imageRef,
24
+ maxWidth,
25
+ editor
26
+ }) {
27
+ const controlWrapperRef = useRef(null);
28
+ const userSelect = useRef({
39
29
  priority: "",
40
30
  value: "default"
41
31
  });
42
- var positioningRef = (0, _react.useRef)({
32
+ const positioningRef = useRef({
43
33
  currentHeight: 0,
44
34
  currentWidth: 0,
45
35
  direction: 0,
@@ -50,28 +40,28 @@ function ImageResizer(_ref) {
50
40
  startX: 0,
51
41
  startY: 0
52
42
  });
53
- var editorRootElement = editor.getRootElement();
43
+ const editorRootElement = editor.getRootElement();
54
44
  // Find max width, accounting for editor padding.
55
- var maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
56
- var maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
57
- var minWidth = 100;
58
- var minHeight = 100;
59
- var setStartCursor = function setStartCursor(direction) {
60
- var ew = direction === Direction.east || direction === Direction.west;
61
- var ns = direction === Direction.north || direction === Direction.south;
62
- var nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
63
- var cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
45
+ const maxWidthContainer = maxWidth ? maxWidth : editorRootElement !== null ? editorRootElement.getBoundingClientRect().width - 20 : 100;
46
+ const maxHeightContainer = editorRootElement !== null ? editorRootElement.getBoundingClientRect().height - 20 : 100;
47
+ const minWidth = 100;
48
+ const minHeight = 100;
49
+ const setStartCursor = direction => {
50
+ const ew = direction === Direction.east || direction === Direction.west;
51
+ const ns = direction === Direction.north || direction === Direction.south;
52
+ const nwse = direction & Direction.north && direction & Direction.west || direction & Direction.south && direction & Direction.east;
53
+ const cursorDir = ew ? "ew" : ns ? "ns" : nwse ? "nwse" : "nesw";
64
54
  if (editorRootElement !== null) {
65
- editorRootElement.style.setProperty("cursor", "".concat(cursorDir, "-resize"), "important");
55
+ editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
66
56
  }
67
57
  if (document.body !== null) {
68
- document.body.style.setProperty("cursor", "".concat(cursorDir, "-resize"), "important");
58
+ document.body.style.setProperty("cursor", `${cursorDir}-resize`, "important");
69
59
  userSelect.current.value = document.body.style.getPropertyValue("-webkit-user-select");
70
60
  userSelect.current.priority = document.body.style.getPropertyPriority("-webkit-user-select");
71
- document.body.style.setProperty("-webkit-user-select", "none", "important");
61
+ document.body.style.setProperty("-webkit-user-select", `none`, "important");
72
62
  }
73
63
  };
74
- var setEndCursor = function setEndCursor() {
64
+ const setEndCursor = () => {
75
65
  if (editorRootElement !== null) {
76
66
  editorRootElement.style.setProperty("cursor", "text");
77
67
  }
@@ -80,17 +70,18 @@ function ImageResizer(_ref) {
80
70
  document.body.style.setProperty("-webkit-user-select", userSelect.current.value, userSelect.current.priority);
81
71
  }
82
72
  };
83
- var handlePointerDown = function handlePointerDown(event, direction) {
73
+ const handlePointerDown = (event, direction) => {
84
74
  if (!editor.isEditable()) {
85
75
  return;
86
76
  }
87
- var image = imageRef.current;
88
- var controlWrapper = controlWrapperRef.current;
77
+ const image = imageRef.current;
78
+ const controlWrapper = controlWrapperRef.current;
89
79
  if (image !== null && controlWrapper !== null) {
90
- var _image$getBoundingCli = image.getBoundingClientRect(),
91
- width = _image$getBoundingCli.width,
92
- height = _image$getBoundingCli.height;
93
- var positioning = positioningRef.current;
80
+ const {
81
+ width,
82
+ height
83
+ } = image.getBoundingClientRect();
84
+ const positioning = positioningRef.current;
94
85
  positioning.startWidth = width;
95
86
  positioning.startHeight = height;
96
87
  positioning.ratio = width / height;
@@ -103,50 +94,50 @@ function ImageResizer(_ref) {
103
94
  setStartCursor(direction);
104
95
  onResizeStart();
105
96
  controlWrapper.classList.add("image-control-wrapper--resizing");
106
- image.style.height = "".concat(height, "px");
107
- image.style.width = "".concat(width, "px");
97
+ image.style.height = `${height}px`;
98
+ image.style.width = `${width}px`;
108
99
  document.addEventListener("pointermove", handlePointerMove);
109
- document.addEventListener("pointerup", _handlePointerUp);
100
+ document.addEventListener("pointerup", handlePointerUp);
110
101
  }
111
102
  };
112
- var handlePointerMove = function handlePointerMove(event) {
113
- var image = imageRef.current;
114
- var positioning = positioningRef.current;
115
- var isHorizontal = positioning.direction & (Direction.east | Direction.west);
116
- var isVertical = positioning.direction & (Direction.south | Direction.north);
103
+ const handlePointerMove = event => {
104
+ const image = imageRef.current;
105
+ const positioning = positioningRef.current;
106
+ const isHorizontal = positioning.direction & (Direction.east | Direction.west);
107
+ const isVertical = positioning.direction & (Direction.south | Direction.north);
117
108
  if (image !== null && positioning.isResizing) {
118
109
  // Corner cursor
119
110
  if (isHorizontal && isVertical) {
120
- var diff = Math.floor(positioning.startX - event.clientX);
111
+ let diff = Math.floor(positioning.startX - event.clientX);
121
112
  diff = positioning.direction & Direction.east ? -diff : diff;
122
- var width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
123
- var height = width / positioning.ratio;
124
- image.style.width = "".concat(width, "px");
125
- image.style.height = "".concat(height, "px");
113
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
114
+ const height = width / positioning.ratio;
115
+ image.style.width = `${width}px`;
116
+ image.style.height = `${height}px`;
126
117
  positioning.currentHeight = height;
127
118
  positioning.currentWidth = width;
128
119
  } else if (isVertical) {
129
- var _diff = Math.floor(positioning.startY - event.clientY);
130
- _diff = positioning.direction & Direction.south ? -_diff : _diff;
131
- var _height = clamp(positioning.startHeight + _diff, minHeight, maxHeightContainer);
132
- image.style.height = "".concat(_height, "px");
133
- positioning.currentHeight = _height;
120
+ let diff = Math.floor(positioning.startY - event.clientY);
121
+ diff = positioning.direction & Direction.south ? -diff : diff;
122
+ const height = clamp(positioning.startHeight + diff, minHeight, maxHeightContainer);
123
+ image.style.height = `${height}px`;
124
+ positioning.currentHeight = height;
134
125
  } else {
135
- var _diff2 = Math.floor(positioning.startX - event.clientX);
136
- _diff2 = positioning.direction & Direction.east ? -_diff2 : _diff2;
137
- var _width = clamp(positioning.startWidth + _diff2, minWidth, maxWidthContainer);
138
- image.style.width = "".concat(_width, "px");
139
- positioning.currentWidth = _width;
126
+ let diff = Math.floor(positioning.startX - event.clientX);
127
+ diff = positioning.direction & Direction.east ? -diff : diff;
128
+ const width = clamp(positioning.startWidth + diff, minWidth, maxWidthContainer);
129
+ image.style.width = `${width}px`;
130
+ positioning.currentWidth = width;
140
131
  }
141
132
  }
142
133
  };
143
- var _handlePointerUp = function handlePointerUp() {
144
- var image = imageRef.current;
145
- var positioning = positioningRef.current;
146
- var controlWrapper = controlWrapperRef.current;
134
+ const handlePointerUp = () => {
135
+ const image = imageRef.current;
136
+ const positioning = positioningRef.current;
137
+ const controlWrapper = controlWrapperRef.current;
147
138
  if (image !== null && controlWrapper !== null && positioning.isResizing) {
148
- var width = positioning.currentWidth;
149
- var height = positioning.currentHeight;
139
+ const width = positioning.currentWidth;
140
+ const height = positioning.currentHeight;
150
141
  positioning.startWidth = 0;
151
142
  positioning.startHeight = 0;
152
143
  positioning.ratio = 0;
@@ -159,55 +150,49 @@ function ImageResizer(_ref) {
159
150
  setEndCursor();
160
151
  onResizeEnd(width, height);
161
152
  document.removeEventListener("pointermove", handlePointerMove);
162
- document.removeEventListener("pointerup", _handlePointerUp);
153
+ document.removeEventListener("pointerup", handlePointerUp);
163
154
  }
164
155
  };
165
156
  return /*#__PURE__*/React.createElement("div", {
166
157
  ref: controlWrapperRef
167
- }, !showCaption && captionsEnabled && /*#__PURE__*/React.createElement("button", {
168
- className: "image-caption-button",
169
- ref: buttonRef,
170
- onClick: function onClick() {
171
- setShowCaption(!showCaption);
172
- }
173
- }, "Add Caption"), /*#__PURE__*/React.createElement("div", {
158
+ }, /*#__PURE__*/React.createElement("div", {
174
159
  className: "image-resizer image-resizer-n",
175
- onPointerDown: function onPointerDown(event) {
160
+ onPointerDown: event => {
176
161
  handlePointerDown(event, Direction.north);
177
162
  }
178
163
  }), /*#__PURE__*/React.createElement("div", {
179
164
  className: "image-resizer image-resizer-ne",
180
- onPointerDown: function onPointerDown(event) {
165
+ onPointerDown: event => {
181
166
  handlePointerDown(event, Direction.north | Direction.east);
182
167
  }
183
168
  }), /*#__PURE__*/React.createElement("div", {
184
169
  className: "image-resizer image-resizer-e",
185
- onPointerDown: function onPointerDown(event) {
170
+ onPointerDown: event => {
186
171
  handlePointerDown(event, Direction.east);
187
172
  }
188
173
  }), /*#__PURE__*/React.createElement("div", {
189
174
  className: "image-resizer image-resizer-se",
190
- onPointerDown: function onPointerDown(event) {
175
+ onPointerDown: event => {
191
176
  handlePointerDown(event, Direction.south | Direction.east);
192
177
  }
193
178
  }), /*#__PURE__*/React.createElement("div", {
194
179
  className: "image-resizer image-resizer-s",
195
- onPointerDown: function onPointerDown(event) {
180
+ onPointerDown: event => {
196
181
  handlePointerDown(event, Direction.south);
197
182
  }
198
183
  }), /*#__PURE__*/React.createElement("div", {
199
184
  className: "image-resizer image-resizer-sw",
200
- onPointerDown: function onPointerDown(event) {
185
+ onPointerDown: event => {
201
186
  handlePointerDown(event, Direction.south | Direction.west);
202
187
  }
203
188
  }), /*#__PURE__*/React.createElement("div", {
204
189
  className: "image-resizer image-resizer-w",
205
- onPointerDown: function onPointerDown(event) {
190
+ onPointerDown: event => {
206
191
  handlePointerDown(event, Direction.west);
207
192
  }
208
193
  }), /*#__PURE__*/React.createElement("div", {
209
194
  className: "image-resizer image-resizer-nw",
210
- onPointerDown: function onPointerDown(event) {
195
+ onPointerDown: event => {
211
196
  handlePointerDown(event, Direction.north | Direction.west);
212
197
  }
213
198
  }));
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","React","clamp","value","min","max","Math","Direction","east","north","south","west","ImageResizer","_ref","onResizeStart","onResizeEnd","buttonRef","imageRef","maxWidth","editor","showCaption","setShowCaption","captionsEnabled","controlWrapperRef","useRef","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","concat","document","body","current","getPropertyValue","getPropertyPriority","setEndCursor","handlePointerDown","event","isEditable","image","controlWrapper","_image$getBoundingCli","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":";;;;;;;AAUA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,IAAAC,KAAA,GAAAH,MAAA;AAV/B;AACA;AACA;AACA;AACA;AACA;AACA;;AAOA,SAASI,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,IAAME,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;AAEM,SAASC,YAAYA,CAAAC,IAAA,EAoBZ;EAAA,IAnBZC,aAAa,GAAAD,IAAA,CAAbC,aAAa;IACbC,WAAW,GAAAF,IAAA,CAAXE,WAAW;IACXC,SAAS,GAAAH,IAAA,CAATG,SAAS;IACTC,QAAQ,GAAAJ,IAAA,CAARI,QAAQ;IACRC,QAAQ,GAAAL,IAAA,CAARK,QAAQ;IACRC,MAAM,GAAAN,IAAA,CAANM,MAAM;IACNC,WAAW,GAAAP,IAAA,CAAXO,WAAW;IACXC,cAAc,GAAAR,IAAA,CAAdQ,cAAc;IACdC,eAAe,GAAAT,IAAA,CAAfS,eAAe;EAYf,IAAMC,iBAAiB,GAA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AAA;IACIE,SAAS,EAAC,gCAAgC;IAC1CE,aAAa,EAAE,SAAfA,aAAaA,CAAEvB,KAAK,EAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEtD,SAAS,CAACE,KAAK,GAAGF,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CACA,CAAC;AAEd","ignoreList":[]}
1
+ {"version":3,"names":["React","useRef","clamp","value","min","max","Math","Direction","east","north","south","west","ImageResizer","onResizeStart","onResizeEnd","imageRef","maxWidth","editor","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","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 imageRef,\n maxWidth,\n editor\n}: {\n editor: LexicalEditor;\n imageRef: { current: null | HTMLElement };\n maxWidth?: number;\n onResizeEnd: (width: \"inherit\" | number, height: \"inherit\" | number) => void;\n onResizeStart: () => void;\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 <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,CAA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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 CHANGED
@@ -1,23 +1,19 @@
1
- import type { Klass, LexicalNode } from "lexical";
2
- export * from "./FontColorNode";
3
- export * from "./TypographyNode";
4
- export * from "./ListNode";
5
- export * from "./ListItemNode";
6
- export * from "./HeadingNode";
7
- export * from "./ParagraphNode";
8
- export * from "./QuoteNode";
9
- export * from "./ImageNode";
10
- export * from "./LinkNode";
11
- export * from "./utils/formatList";
12
- export * from "./utils/listNode";
13
- export * from "./utils/formatToQuote";
14
- export * from "./utils/formatToHeading";
15
- export * from "./utils/formatToParagraph";
16
- export * from "./utils/clearNodeFormating";
17
- export * from "./utils/toggleLink";
18
- export declare const allNodes: ReadonlyArray<Klass<LexicalNode> | {
19
- replace: Klass<LexicalNode>;
20
- with: <T extends {
21
- new (...args: any): any;
22
- }>(node: InstanceType<T>) => LexicalNode;
23
- }>;
1
+ import { type Klass, type LexicalNode, type LexicalNodeReplacement } from "lexical";
2
+ export * from "./FontColorNode.js";
3
+ export * from "./ListNode.js";
4
+ export * from "./ListItemNode.js";
5
+ export * from "./HeadingNode.js";
6
+ export * from "./ParagraphNode.js";
7
+ export * from "./QuoteNode.js";
8
+ export * from "./ImageNode.js";
9
+ export * from "./LinkNode.js";
10
+ export * from "./utils/formatList.js";
11
+ export * from "./utils/listNode.js";
12
+ export * from "./utils/formatToQuote.js";
13
+ export * from "./utils/formatToHeading.js";
14
+ export * from "./utils/formatToParagraph.js";
15
+ export * from "./utils/clearNodeFormating.js";
16
+ export * from "./utils/toggleLink.js";
17
+ export * from "./prepareLexicalState.js";
18
+ export * from "./generateInitialLexicalValue.js";
19
+ export declare const allNodes: ReadonlyArray<Klass<LexicalNode> | LexicalNodeReplacement>;