@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.
- package/FontColorNode.d.ts +6 -6
- package/FontColorNode.js +102 -145
- package/FontColorNode.js.map +1 -1
- package/HeadingNode.d.ts +29 -17
- package/HeadingNode.js +184 -152
- package/HeadingNode.js.map +1 -1
- package/ImageNode.d.ts +1 -11
- package/ImageNode.js +119 -190
- package/ImageNode.js.map +1 -1
- package/LinkNode.d.ts +2 -2
- package/LinkNode.js +249 -346
- package/LinkNode.js.map +1 -1
- package/ListItemNode.d.ts +4 -3
- package/ListItemNode.js +275 -354
- package/ListItemNode.js.map +1 -1
- package/ListNode.d.ts +28 -14
- package/ListNode.js +170 -209
- package/ListNode.js.map +1 -1
- package/ParagraphNode.d.ts +28 -16
- package/ParagraphNode.js +143 -179
- package/ParagraphNode.js.map +1 -1
- package/QuoteNode.d.ts +26 -19
- package/QuoteNode.js +102 -188
- package/QuoteNode.js.map +1 -1
- package/README.md +9 -4
- package/components/ImageNode/ImageComponent.d.ts +2 -7
- package/components/ImageNode/ImageComponent.js +72 -166
- package/components/ImageNode/ImageComponent.js.map +1 -1
- package/components/ImageNode/ImageResizer.d.ts +1 -8
- package/components/ImageNode/ImageResizer.js +74 -89
- package/components/ImageNode/ImageResizer.js.map +1 -1
- package/generateInitialLexicalValue.d.ts +4 -0
- package/generateInitialLexicalValue.js +27 -0
- package/generateInitialLexicalValue.js.map +1 -0
- package/index.d.ts +19 -23
- package/index.js +50 -233
- package/index.js.map +1 -1
- package/package.json +16 -20
- package/prepareLexicalState.d.ts +2 -0
- package/prepareLexicalState.js +53 -0
- package/prepareLexicalState.js.map +1 -0
- package/types.d.ts +4 -5
- package/types.js +1 -5
- package/types.js.map +1 -1
- package/utils/clearNodeFormating.d.ts +1 -1
- package/utils/clearNodeFormating.js +12 -18
- package/utils/clearNodeFormating.js.map +1 -1
- package/utils/formatList.d.ts +4 -4
- package/utils/formatList.js +171 -208
- package/utils/formatList.js.map +1 -1
- package/utils/formatToHeading.d.ts +2 -2
- package/utils/formatToHeading.js +8 -15
- package/utils/formatToHeading.js.map +1 -1
- package/utils/formatToParagraph.d.ts +1 -1
- package/utils/formatToParagraph.js +8 -16
- package/utils/formatToParagraph.js.map +1 -1
- package/utils/formatToQuote.d.ts +1 -1
- package/utils/formatToQuote.js +8 -15
- package/utils/formatToQuote.js.map +1 -1
- package/utils/getStyleId.d.ts +11 -0
- package/utils/getStyleId.js +14 -0
- package/utils/getStyleId.js.map +1 -0
- package/utils/listNode.d.ts +2 -2
- package/utils/listNode.js +37 -50
- package/utils/listNode.js.map +1 -1
- package/utils/toggleLink.d.ts +1 -1
- package/utils/toggleLink.js +41 -45
- package/utils/toggleLink.js.map +1 -1
- package/TypographyNode.d.ts +0 -39
- package/TypographyNode.js +0 -146
- package/TypographyNode.js.map +0 -1
- package/components/ImageNode/ContentEditable.css +0 -22
- package/components/ImageNode/ContentEditable.d.ts +0 -12
- package/components/ImageNode/ContentEditable.js +0 -26
- package/components/ImageNode/ContentEditable.js.map +0 -1
- package/components/ImageNode/ImageComponent.css +0 -43
- package/components/ImageNode/Placeholder.css +0 -20
- package/components/ImageNode/Placeholder.d.ts +0 -15
- package/components/ImageNode/Placeholder.js +0 -30
- package/components/ImageNode/Placeholder.js.map +0 -1
- package/components/ImageNode/SharedHistoryContext.d.ts +0 -10
- package/components/ImageNode/SharedHistoryContext.js +0 -27
- 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
|
-
|
|
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(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
43
|
+
const editorRootElement = editor.getRootElement();
|
|
54
44
|
// Find max width, accounting for editor padding.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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",
|
|
55
|
+
editorRootElement.style.setProperty("cursor", `${cursorDir}-resize`, "important");
|
|
66
56
|
}
|
|
67
57
|
if (document.body !== null) {
|
|
68
|
-
document.body.style.setProperty("cursor",
|
|
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",
|
|
61
|
+
document.body.style.setProperty("-webkit-user-select", `none`, "important");
|
|
72
62
|
}
|
|
73
63
|
};
|
|
74
|
-
|
|
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
|
-
|
|
73
|
+
const handlePointerDown = (event, direction) => {
|
|
84
74
|
if (!editor.isEditable()) {
|
|
85
75
|
return;
|
|
86
76
|
}
|
|
87
|
-
|
|
88
|
-
|
|
77
|
+
const image = imageRef.current;
|
|
78
|
+
const controlWrapper = controlWrapperRef.current;
|
|
89
79
|
if (image !== null && controlWrapper !== null) {
|
|
90
|
-
|
|
91
|
-
width
|
|
92
|
-
height
|
|
93
|
-
|
|
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 =
|
|
107
|
-
image.style.width =
|
|
97
|
+
image.style.height = `${height}px`;
|
|
98
|
+
image.style.width = `${width}px`;
|
|
108
99
|
document.addEventListener("pointermove", handlePointerMove);
|
|
109
|
-
document.addEventListener("pointerup",
|
|
100
|
+
document.addEventListener("pointerup", handlePointerUp);
|
|
110
101
|
}
|
|
111
102
|
};
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
111
|
+
let diff = Math.floor(positioning.startX - event.clientX);
|
|
121
112
|
diff = positioning.direction & Direction.east ? -diff : diff;
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
image.style.width =
|
|
125
|
-
image.style.height =
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
image.style.height =
|
|
133
|
-
positioning.currentHeight =
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
image.style.width =
|
|
139
|
-
positioning.currentWidth =
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
-
|
|
149
|
-
|
|
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",
|
|
153
|
+
document.removeEventListener("pointerup", handlePointerUp);
|
|
163
154
|
}
|
|
164
155
|
};
|
|
165
156
|
return /*#__PURE__*/React.createElement("div", {
|
|
166
157
|
ref: controlWrapperRef
|
|
167
|
-
},
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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,MAA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,+BAA+B;IACzCE,aAAa,EAAE,SAAfA,aAAaA,CAAEvB,KAAK,EAAI;MACpBD,iBAAiB,CAACC,KAAK,EAAEtD,SAAS,CAACI,IAAI,CAAC;IAC5C;EAAE,CACL,CAAC,eACFV,KAAA,CAAA+E,aAAA;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;AAC9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iBAAiB,CAACC,KAAK,EAAE/C,SAAS,CAACE,KAAK,GAAGF,SAAS,CAACI,IAAI,CAAC;IAC9D;EAAE,CACL,CACA,CAAC;AAEd","ignoreList":[]}
|
|
@@ -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
|
|
2
|
-
export * from "./FontColorNode";
|
|
3
|
-
export * from "./
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./utils/
|
|
12
|
-
export * from "./utils/
|
|
13
|
-
export * from "./utils/
|
|
14
|
-
export * from "./utils/
|
|
15
|
-
export * from "./utils/
|
|
16
|
-
export * from "./utils/
|
|
17
|
-
export * from "./
|
|
18
|
-
export
|
|
19
|
-
|
|
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>;
|