@react-fabric/lexical 1.0.0-beta.9 → 1.0.2
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/{src/editor/Lexical.module.css → css/_lexical.css} +79 -13
- package/css/styles.css +24 -0
- package/dist/cjs/{packages/lexical/src/editor → editor}/LexicalEditor.js +98 -45
- package/dist/cjs/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +147 -140
- package/dist/cjs/i18n/ar/lexical.json.js +30 -0
- package/dist/cjs/i18n/en/lexical.json.js +30 -0
- package/{src/plugins/StickyPlugin.ts → dist/cjs/i18n/index.js} +10 -15
- package/dist/cjs/index.js +36 -0
- package/dist/cjs/plugins/CommentPlugin.js +481 -0
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +17 -20
- package/dist/cjs/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +58 -37
- package/dist/esm/{packages/lexical/src/editor → editor}/LexicalEditor.js +101 -48
- package/dist/esm/{packages/lexical/src/hooks → hooks}/useFormatWatcher.js +95 -88
- package/dist/esm/i18n/ar/lexical.json.js +25 -0
- package/dist/esm/i18n/en/lexical.json.js +25 -0
- package/dist/esm/i18n/index.js +33 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/plugins/CommentPlugin.js +481 -0
- package/dist/esm/{packages/lexical/src/plugins → plugins}/DraggableBlockPlugin.js +15 -18
- package/dist/esm/{packages/lexical/src/plugins → plugins}/ToolbarPlugin.js +59 -38
- package/dist/types/editor/LexicalEditor.d.ts +33 -4
- package/dist/types/hooks/useFormatWatcher.d.ts +7 -4
- package/dist/types/i18n/index.d.ts +1 -0
- package/dist/types/index.d.ts +27 -0
- package/dist/types/plugins/CommentPlugin.d.ts +5 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -2
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -1
- package/dist/types/utils/index.d.ts +3 -6
- package/package.json +18 -18
- package/src/editor/LexicalEditor.tsx +95 -55
- package/src/hooks/useFormatWatcher.ts +50 -74
- package/src/i18n/ar/lexical.json +18 -0
- package/src/i18n/en/lexical.json +18 -0
- package/src/i18n/index.ts +28 -0
- package/src/index.ts +24 -17
- package/src/plugins/CommentPlugin.tsx +523 -0
- package/src/plugins/DraggableBlockPlugin.tsx +23 -68
- package/src/plugins/ToolbarPlugin.tsx +83 -131
- package/src/utils/index.ts +12 -108
- package/dist/cjs/_virtual/prism.js +0 -5
- package/dist/cjs/editor/Lexical.module.css +0 -1
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -432
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -21
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -27
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +0 -1139
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +0 -25
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +0 -50
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +0 -245
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +0 -19
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +0 -18
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +0 -471
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +0 -24
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +0 -1275
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +0 -29
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -789
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +0 -29
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -26
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -976
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +0 -35
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -35
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +0 -2792
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +0 -23
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +0 -55
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -888
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +0 -35
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -66
- package/dist/cjs/node_modules/@mdi/js/mdi.js +0 -8
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/cjs/node_modules/prismjs/prism.js +0 -1951
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/cjs/packages/lexical/src/index.js +0 -7
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +0 -218
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/esm/_virtual/prism.js +0 -5
- package/dist/esm/editor/Lexical.module.css +0 -1
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +0 -423
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +0 -19
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +0 -1121
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +0 -21
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +0 -32
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +0 -244
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +0 -18
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +0 -463
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +0 -17
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +0 -1262
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +0 -23
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +0 -781
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +0 -23
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +0 -18
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +0 -957
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +0 -26
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +0 -16
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +0 -2754
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +0 -20
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +0 -17
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +0 -839
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +0 -26
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +0 -17
- package/dist/esm/node_modules/@mdi/js/mdi.js +0 -7
- package/dist/esm/node_modules/prismjs/components/prism-c.js +0 -82
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -33
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +0 -101
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -66
- package/dist/esm/node_modules/prismjs/components/prism-java.js +0 -126
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -174
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +0 -417
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -188
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +0 -14
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +0 -60
- package/dist/esm/node_modules/prismjs/components/prism-python.js +0 -67
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +0 -130
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +0 -34
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +0 -150
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -62
- package/dist/esm/node_modules/prismjs/prism.js +0 -1951
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +0 -221
- package/dist/esm/packages/lexical/src/index.js +0 -3
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +0 -216
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +0 -20
- package/dist/types/components/StickyComponent.d.ts +0 -9
- package/dist/types/nodes/StickyNode.d.ts +0 -35
- package/dist/types/plugins/StickyPlugin.d.ts +0 -1
- package/src/components/StickyComponent.tsx +0 -271
- package/src/nodes/StickyNode.tsx +0 -249
- /package/dist/cjs/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/cjs/{packages/lexical/src/utils → utils}/index.js +0 -0
- /package/dist/esm/{packages/lexical/src/editor → editor}/theme.js +0 -0
- /package/dist/esm/{packages/lexical/src/utils → utils}/index.js +0 -0
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { AutoFocusPlugin } from '@lexical/react/LexicalAutoFocusPlugin';
|
|
5
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
6
|
-
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
7
|
-
import LexicalErrorBoundary from '@lexical/react/LexicalErrorBoundary';
|
|
8
|
-
import { LexicalNestedComposer } from '@lexical/react/LexicalNestedComposer';
|
|
9
|
-
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
10
|
-
import { mdiFormatColorFill, mdiClose } from '../../../../node_modules/@mdi/js/mdi.js';
|
|
11
|
-
import { Icon } from '@react-fabric/core';
|
|
12
|
-
import { createEditor, $getNodeByKey } from 'lexical';
|
|
13
|
-
import { useRef, useEffect, useMemo } from 'react';
|
|
14
|
-
import { $isStickyNode } from '../nodes/StickyNode.js';
|
|
15
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
16
|
-
|
|
17
|
-
function positionSticky(stickyElem, positioning) {
|
|
18
|
-
var style = stickyElem.style;
|
|
19
|
-
style.top = "".concat(positioning.y, "px");
|
|
20
|
-
style.left = "".concat(positioning.x, "px");
|
|
21
|
-
}
|
|
22
|
-
var StickyComponent = function StickyComponent(_ref) {
|
|
23
|
-
var _ref$x = _ref.x,
|
|
24
|
-
x = _ref$x === void 0 ? 0 : _ref$x,
|
|
25
|
-
_ref$y = _ref.y,
|
|
26
|
-
y = _ref$y === void 0 ? 0 : _ref$y,
|
|
27
|
-
nodeKey = _ref.nodeKey,
|
|
28
|
-
color = _ref.color,
|
|
29
|
-
state = _ref.state,
|
|
30
|
-
user = _ref.user;
|
|
31
|
-
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
32
|
-
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
33
|
-
editor = _useLexicalComposerCo2[0];
|
|
34
|
-
var stickyContainerRef = useRef(null);
|
|
35
|
-
var positioningRef = useRef({
|
|
36
|
-
isDragging: false,
|
|
37
|
-
offsetX: 0,
|
|
38
|
-
offsetY: 0,
|
|
39
|
-
rootElementRect: {
|
|
40
|
-
left: 8,
|
|
41
|
-
top: 8
|
|
42
|
-
},
|
|
43
|
-
x: 8,
|
|
44
|
-
y: 8
|
|
45
|
-
});
|
|
46
|
-
useEffect(function () {
|
|
47
|
-
var position = positioningRef.current;
|
|
48
|
-
position.x = x;
|
|
49
|
-
position.y = y;
|
|
50
|
-
var stickyContainer = stickyContainerRef.current;
|
|
51
|
-
if (stickyContainer !== null) {
|
|
52
|
-
positioningRef.current.rootElementRect = {
|
|
53
|
-
left: x,
|
|
54
|
-
top: y
|
|
55
|
-
};
|
|
56
|
-
positionSticky(stickyContainer, position);
|
|
57
|
-
}
|
|
58
|
-
}, [x, y]);
|
|
59
|
-
useEffect(function () {
|
|
60
|
-
var stickyContainer = stickyContainerRef.current;
|
|
61
|
-
if (stickyContainer !== null) {
|
|
62
|
-
// Delay adding transition so we don't trigger the
|
|
63
|
-
// transition on load of the sticky.
|
|
64
|
-
setTimeout(function () {
|
|
65
|
-
stickyContainer.style.setProperty("transition", "top 300ms ease 0s, left 300ms ease 0s");
|
|
66
|
-
}, 500);
|
|
67
|
-
}
|
|
68
|
-
}, []);
|
|
69
|
-
var handlePointerMove = function handlePointerMove(event) {
|
|
70
|
-
var stickyContainer = stickyContainerRef.current;
|
|
71
|
-
var positioning = positioningRef.current;
|
|
72
|
-
var rootElementRect = positioning.rootElementRect;
|
|
73
|
-
if (stickyContainer !== null && positioning.isDragging && rootElementRect !== null) {
|
|
74
|
-
positioning.x = rootElementRect.left + (event.pageX - positioning.offsetX);
|
|
75
|
-
positioning.y = rootElementRect.top + (event.pageY - positioning.offsetY);
|
|
76
|
-
if (positioning.x < 0) positioning.x = 0;
|
|
77
|
-
if (positioning.x > 642) positioning.x = 642 - stickyContainer.offsetWidth;
|
|
78
|
-
if (positioning.y < 0) positioning.y = 0;
|
|
79
|
-
positionSticky(stickyContainer, positioning);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
var handlePointerUp = function handlePointerUp(event) {
|
|
83
|
-
var stickyContainer = stickyContainerRef.current;
|
|
84
|
-
var positioning = positioningRef.current;
|
|
85
|
-
if (stickyContainer !== null) {
|
|
86
|
-
positioning.isDragging = false;
|
|
87
|
-
stickyContainer.classList.remove("dragging");
|
|
88
|
-
editor.update(function () {
|
|
89
|
-
var node = $getNodeByKey(nodeKey);
|
|
90
|
-
if ($isStickyNode(node)) {
|
|
91
|
-
node.setPosition(positioning.x, positioning.y);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
document.removeEventListener("pointermove", handlePointerMove);
|
|
96
|
-
document.removeEventListener("pointerup", handlePointerUp);
|
|
97
|
-
};
|
|
98
|
-
var handleDelete = function handleDelete() {
|
|
99
|
-
editor.update(function () {
|
|
100
|
-
var node = $getNodeByKey(nodeKey);
|
|
101
|
-
if ($isStickyNode(node)) {
|
|
102
|
-
node.remove();
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
|
-
var handleColorChange = function handleColorChange() {
|
|
107
|
-
editor.update(function () {
|
|
108
|
-
var node = $getNodeByKey(nodeKey);
|
|
109
|
-
if ($isStickyNode(node)) {
|
|
110
|
-
node.toggleColor();
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
};
|
|
114
|
-
var innerEditor = useMemo(function () {
|
|
115
|
-
var editor = createEditor({
|
|
116
|
-
editable: true
|
|
117
|
-
});
|
|
118
|
-
if (state) {
|
|
119
|
-
var editorState = editor.parseEditorState(state);
|
|
120
|
-
editor.setEditorState(editorState);
|
|
121
|
-
}
|
|
122
|
-
return editor;
|
|
123
|
-
}, []);
|
|
124
|
-
useEffect(function () {
|
|
125
|
-
if (innerEditor._editable) {
|
|
126
|
-
var dispose = innerEditor.registerUpdateListener(function (_ref2) {
|
|
127
|
-
_ref2.editorState;
|
|
128
|
-
editor.update(function () {
|
|
129
|
-
var node = $getNodeByKey(nodeKey);
|
|
130
|
-
if ($isStickyNode(node)) {
|
|
131
|
-
node.updateState(innerEditor.getEditorState().toJSON());
|
|
132
|
-
}
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
return function () {
|
|
136
|
-
dispose();
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
}, [innerEditor._editable]);
|
|
140
|
-
return /*#__PURE__*/jsxs("div", {
|
|
141
|
-
ref: stickyContainerRef,
|
|
142
|
-
className: "sticky__container",
|
|
143
|
-
children: [/*#__PURE__*/jsx("div", {
|
|
144
|
-
className: "sticky__handle",
|
|
145
|
-
onPointerDown: function onPointerDown(event) {
|
|
146
|
-
var stickyContainer = stickyContainerRef.current;
|
|
147
|
-
if (stickyContainer == null || event.button === 2 || event.target !== stickyContainer.firstChild) {
|
|
148
|
-
// Right click or click on editor should not work
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
var stickContainer = stickyContainer;
|
|
152
|
-
var positioning = positioningRef.current;
|
|
153
|
-
if (stickContainer !== null) {
|
|
154
|
-
positioning.offsetX = event.clientX;
|
|
155
|
-
positioning.offsetY = event.clientY;
|
|
156
|
-
positioning.rootElementRect = {
|
|
157
|
-
left: positioning.x,
|
|
158
|
-
top: positioning.y
|
|
159
|
-
};
|
|
160
|
-
positioning.isDragging = true;
|
|
161
|
-
stickContainer.classList.add("dragging");
|
|
162
|
-
document.addEventListener("pointermove", handlePointerMove);
|
|
163
|
-
document.addEventListener("pointerup", handlePointerUp);
|
|
164
|
-
event.preventDefault();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
168
|
-
className: "sticky-note ".concat(color),
|
|
169
|
-
children: [/*#__PURE__*/jsxs("div", {
|
|
170
|
-
className: "sticky__tools",
|
|
171
|
-
children: [/*#__PURE__*/jsx("button", {
|
|
172
|
-
onClick: handleColorChange,
|
|
173
|
-
className: "sticky--color",
|
|
174
|
-
"aria-label": "Change sticky note color",
|
|
175
|
-
title: "Color",
|
|
176
|
-
children: /*#__PURE__*/jsx(Icon, {
|
|
177
|
-
icon: mdiFormatColorFill
|
|
178
|
-
})
|
|
179
|
-
}), /*#__PURE__*/jsx("button", {
|
|
180
|
-
onClick: handleDelete,
|
|
181
|
-
className: "sticky--delete",
|
|
182
|
-
"aria-label": "Delete sticky note",
|
|
183
|
-
title: "Delete",
|
|
184
|
-
children: /*#__PURE__*/jsx(Icon, {
|
|
185
|
-
icon: mdiClose
|
|
186
|
-
})
|
|
187
|
-
})]
|
|
188
|
-
}), /*#__PURE__*/jsx("div", {
|
|
189
|
-
className: "text-sm font-semibold",
|
|
190
|
-
children: user
|
|
191
|
-
}), /*#__PURE__*/jsxs(LexicalNestedComposer, {
|
|
192
|
-
initialEditor: innerEditor,
|
|
193
|
-
initialTheme: {
|
|
194
|
-
paragraph: "sticky__paragraph",
|
|
195
|
-
text: {
|
|
196
|
-
bold: "editor-textBold",
|
|
197
|
-
code: "editor-textCode",
|
|
198
|
-
italic: "editor-textItalic",
|
|
199
|
-
strikethrough: "editor-textStrikethrough",
|
|
200
|
-
subscript: "editor-textSubscript",
|
|
201
|
-
superscript: "editor-textSuperscript",
|
|
202
|
-
underline: "editor-textUnderline",
|
|
203
|
-
underlineStrikethrough: "editor-textUnderlineStrikethrough"
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
children: [/*#__PURE__*/jsx(RichTextPlugin, {
|
|
207
|
-
contentEditable: /*#__PURE__*/jsx(ContentEditable, {
|
|
208
|
-
className: "sticky__editor"
|
|
209
|
-
}),
|
|
210
|
-
placeholder: /*#__PURE__*/jsx("div", {
|
|
211
|
-
className: "sticky-placeholder",
|
|
212
|
-
children: "Sticky note..."
|
|
213
|
-
}),
|
|
214
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
215
|
-
}), /*#__PURE__*/jsx(AutoFocusPlugin, {})]
|
|
216
|
-
})]
|
|
217
|
-
})]
|
|
218
|
-
});
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
export { StickyComponent };
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _classCallCheck from '@babel/runtime/helpers/classCallCheck';
|
|
4
|
-
import _createClass from '@babel/runtime/helpers/createClass';
|
|
5
|
-
import _possibleConstructorReturn from '@babel/runtime/helpers/possibleConstructorReturn';
|
|
6
|
-
import _getPrototypeOf from '@babel/runtime/helpers/getPrototypeOf';
|
|
7
|
-
import _inherits from '@babel/runtime/helpers/inherits';
|
|
8
|
-
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
9
|
-
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
10
|
-
import { DecoratorNode, $applyNodeReplacement } from 'lexical';
|
|
11
|
-
import { Suspense, lazy } from 'react';
|
|
12
|
-
import { createPortal } from 'react-dom';
|
|
13
|
-
import { jsx } from 'react/jsx-runtime';
|
|
14
|
-
|
|
15
|
-
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
16
|
-
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
17
|
-
var StickyComponent = /*#__PURE__*/lazy( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
18
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
19
|
-
while (1) switch (_context.prev = _context.next) {
|
|
20
|
-
case 0:
|
|
21
|
-
_context.next = 2;
|
|
22
|
-
return import('../components/StickyComponent.js').then(function (_ref2) {
|
|
23
|
-
var StickyComponent = _ref2.StickyComponent;
|
|
24
|
-
return {
|
|
25
|
-
"default": StickyComponent
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
case 2:
|
|
29
|
-
return _context.abrupt("return", _context.sent);
|
|
30
|
-
case 3:
|
|
31
|
-
case "end":
|
|
32
|
-
return _context.stop();
|
|
33
|
-
}
|
|
34
|
-
}, _callee);
|
|
35
|
-
})));
|
|
36
|
-
var convertStickyElement = function convertStickyElement(domNode) {
|
|
37
|
-
var sticky = domNode.getAttribute("data-lexical-sticky") === "true";
|
|
38
|
-
if (sticky) {
|
|
39
|
-
var _domNode$getAttribute, _domNode$getAttribute2, _domNode$getAttribute3, _domNode$getAttribute4;
|
|
40
|
-
var node = $createStickyNode({
|
|
41
|
-
xOffset: +((_domNode$getAttribute = domNode.getAttribute("data-x")) !== null && _domNode$getAttribute !== void 0 ? _domNode$getAttribute : "8"),
|
|
42
|
-
yOffset: +((_domNode$getAttribute2 = domNode.getAttribute("data-y")) !== null && _domNode$getAttribute2 !== void 0 ? _domNode$getAttribute2 : "8"),
|
|
43
|
-
user: (_domNode$getAttribute3 = domNode.getAttribute("data-user")) !== null && _domNode$getAttribute3 !== void 0 ? _domNode$getAttribute3 : "",
|
|
44
|
-
color: domNode.getAttribute("data-color"),
|
|
45
|
-
state: (_domNode$getAttribute4 = domNode.getAttribute("data-state")) !== null && _domNode$getAttribute4 !== void 0 ? _domNode$getAttribute4 : ""
|
|
46
|
-
});
|
|
47
|
-
return {
|
|
48
|
-
node: node
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
return null;
|
|
52
|
-
};
|
|
53
|
-
var colors = {
|
|
54
|
-
yellow: "green",
|
|
55
|
-
green: "blue",
|
|
56
|
-
blue: "pink",
|
|
57
|
-
pink: "yellow"
|
|
58
|
-
};
|
|
59
|
-
var StickyNode = /*#__PURE__*/function (_DecoratorNode) {
|
|
60
|
-
function StickyNode(x, y) {
|
|
61
|
-
var _this;
|
|
62
|
-
var user = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
63
|
-
var color = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "yellow";
|
|
64
|
-
var state = arguments.length > 4 ? arguments[4] : undefined;
|
|
65
|
-
var key = arguments.length > 5 ? arguments[5] : undefined;
|
|
66
|
-
_classCallCheck(this, StickyNode);
|
|
67
|
-
_this = _callSuper(this, StickyNode, [key]);
|
|
68
|
-
_this.__x = x;
|
|
69
|
-
_this.__y = y;
|
|
70
|
-
_this.__user = user;
|
|
71
|
-
_this.__state = state;
|
|
72
|
-
_this.__color = color;
|
|
73
|
-
return _this;
|
|
74
|
-
}
|
|
75
|
-
_inherits(StickyNode, _DecoratorNode);
|
|
76
|
-
return _createClass(StickyNode, [{
|
|
77
|
-
key: "exportJSON",
|
|
78
|
-
value: function exportJSON() {
|
|
79
|
-
return {
|
|
80
|
-
state: this.__state,
|
|
81
|
-
color: this.__color,
|
|
82
|
-
user: this.__user,
|
|
83
|
-
type: "sticky",
|
|
84
|
-
version: 1,
|
|
85
|
-
xOffset: this.__x,
|
|
86
|
-
yOffset: this.__y
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
key: "createDOM",
|
|
91
|
-
value: function createDOM(config) {
|
|
92
|
-
var div = document.createElement("div");
|
|
93
|
-
div.style.display = "contents";
|
|
94
|
-
return div;
|
|
95
|
-
}
|
|
96
|
-
}, {
|
|
97
|
-
key: "updateDOM",
|
|
98
|
-
value: function updateDOM() {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
}, {
|
|
102
|
-
key: "exportDOM",
|
|
103
|
-
value: function exportDOM() {
|
|
104
|
-
var writable = this.getWritable();
|
|
105
|
-
var element = document.createElement("div");
|
|
106
|
-
element.setAttribute("data-lexical-sticky", "true");
|
|
107
|
-
element.setAttribute("data-x", "".concat(writable.__x));
|
|
108
|
-
element.setAttribute("data-y", "".concat(writable.__y));
|
|
109
|
-
element.setAttribute("data-user", "".concat(writable.__user));
|
|
110
|
-
element.setAttribute("data-color", "".concat(writable.__color));
|
|
111
|
-
element.setAttribute("data-state", "".concat(writable.__state));
|
|
112
|
-
return {
|
|
113
|
-
element: element
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
}, {
|
|
117
|
-
key: "setPosition",
|
|
118
|
-
value: function setPosition(x, y) {
|
|
119
|
-
var writable = this.getWritable();
|
|
120
|
-
writable.__x = x;
|
|
121
|
-
writable.__y = y;
|
|
122
|
-
}
|
|
123
|
-
}, {
|
|
124
|
-
key: "toggleColor",
|
|
125
|
-
value: function toggleColor() {
|
|
126
|
-
var _writable$__color;
|
|
127
|
-
var writable = this.getWritable();
|
|
128
|
-
writable.__color = colors[(_writable$__color = writable.__color) !== null && _writable$__color !== void 0 ? _writable$__color : "yellow"];
|
|
129
|
-
}
|
|
130
|
-
}, {
|
|
131
|
-
key: "updateState",
|
|
132
|
-
value: function updateState(text) {
|
|
133
|
-
var writable = this.getWritable();
|
|
134
|
-
writable.__state = text;
|
|
135
|
-
}
|
|
136
|
-
}, {
|
|
137
|
-
key: "decorate",
|
|
138
|
-
value: function decorate(editor, config) {
|
|
139
|
-
var _document$querySelect;
|
|
140
|
-
return /*#__PURE__*/createPortal( /*#__PURE__*/jsx(Suspense, {
|
|
141
|
-
fallback: null,
|
|
142
|
-
children: /*#__PURE__*/jsx(StickyComponent, {
|
|
143
|
-
x: this.__x,
|
|
144
|
-
y: this.__y,
|
|
145
|
-
user: this.__user,
|
|
146
|
-
state: this.__state,
|
|
147
|
-
nodeKey: this.getKey(),
|
|
148
|
-
color: this.__color
|
|
149
|
-
})
|
|
150
|
-
}), (_document$querySelect = document.querySelector(".lexical-container")) !== null && _document$querySelect !== void 0 ? _document$querySelect : document.body);
|
|
151
|
-
}
|
|
152
|
-
}, {
|
|
153
|
-
key: "isIsolated",
|
|
154
|
-
value: function isIsolated() {
|
|
155
|
-
return true;
|
|
156
|
-
}
|
|
157
|
-
}], [{
|
|
158
|
-
key: "getType",
|
|
159
|
-
value: function getType() {
|
|
160
|
-
return "sticky";
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "clone",
|
|
164
|
-
value: function clone(node) {
|
|
165
|
-
return new StickyNode(node.__x, node.__y, node.__user, node.__color, node.__state, node.__key);
|
|
166
|
-
}
|
|
167
|
-
}, {
|
|
168
|
-
key: "importJSON",
|
|
169
|
-
value: function importJSON(serializedNode) {
|
|
170
|
-
var stickyNode = new StickyNode(serializedNode.xOffset, serializedNode.yOffset, serializedNode.user, serializedNode.color, serializedNode.state);
|
|
171
|
-
return stickyNode;
|
|
172
|
-
}
|
|
173
|
-
}, {
|
|
174
|
-
key: "importDOM",
|
|
175
|
-
value: function importDOM() {
|
|
176
|
-
return {
|
|
177
|
-
div: function div(domNode) {
|
|
178
|
-
if (!domNode.hasAttribute("data-lexical-sticky")) {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
return {
|
|
182
|
-
conversion: convertStickyElement,
|
|
183
|
-
priority: 2
|
|
184
|
-
};
|
|
185
|
-
},
|
|
186
|
-
span: function span(domNode) {
|
|
187
|
-
if (!domNode.hasAttribute("data-lexical-sticky")) {
|
|
188
|
-
return null;
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
conversion: convertStickyElement,
|
|
192
|
-
priority: 1
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
}
|
|
197
|
-
}]);
|
|
198
|
-
}(DecoratorNode);
|
|
199
|
-
function $isStickyNode(node) {
|
|
200
|
-
return node instanceof StickyNode;
|
|
201
|
-
}
|
|
202
|
-
function $createStickyNode(_ref3) {
|
|
203
|
-
var _ref3$xOffset = _ref3.xOffset,
|
|
204
|
-
xOffset = _ref3$xOffset === void 0 ? 650 : _ref3$xOffset,
|
|
205
|
-
_ref3$yOffset = _ref3.yOffset,
|
|
206
|
-
yOffset = _ref3$yOffset === void 0 ? 32 : _ref3$yOffset,
|
|
207
|
-
_ref3$user = _ref3.user,
|
|
208
|
-
user = _ref3$user === void 0 ? "" : _ref3$user,
|
|
209
|
-
_ref3$color = _ref3.color,
|
|
210
|
-
color = _ref3$color === void 0 ? "yellow" : _ref3$color,
|
|
211
|
-
state = _ref3.state;
|
|
212
|
-
var node = new StickyNode(xOffset, yOffset, user, color, state);
|
|
213
|
-
return $applyNodeReplacement(node);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export { $createStickyNode, $isStickyNode, StickyNode };
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
4
|
-
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
5
|
-
import { useEffect } from 'react';
|
|
6
|
-
import { StickyNode } from '../nodes/StickyNode.js';
|
|
7
|
-
|
|
8
|
-
var StickyPlugin = function StickyPlugin() {
|
|
9
|
-
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
10
|
-
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
11
|
-
editor = _useLexicalComposerCo2[0];
|
|
12
|
-
useEffect(function () {
|
|
13
|
-
if (!editor.hasNodes([StickyNode])) {
|
|
14
|
-
throw new Error("StickyPlugin: StickyNode not registered on editor");
|
|
15
|
-
}
|
|
16
|
-
}, [editor]);
|
|
17
|
-
return null;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export { StickyPlugin };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type NodeKey } from "lexical";
|
|
2
|
-
export declare const StickyComponent: ({ x, y, nodeKey, color, state, user, }: {
|
|
3
|
-
user: string;
|
|
4
|
-
state?: AnyObject;
|
|
5
|
-
color: "pink" | "yellow";
|
|
6
|
-
nodeKey: NodeKey;
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { DecoratorNode, type DOMConversionMap, type DOMExportOutput, type EditorConfig, type LexicalEditor, type LexicalNode, type NodeKey, type SerializedLexicalNode, type Spread } from "lexical";
|
|
3
|
-
type StickyNoteColor = "pink" | "yellow" | "green" | "blue";
|
|
4
|
-
interface StickyNodeType {
|
|
5
|
-
xOffset: number;
|
|
6
|
-
yOffset: number;
|
|
7
|
-
user?: string;
|
|
8
|
-
color?: StickyNoteColor;
|
|
9
|
-
state?: AnyObject;
|
|
10
|
-
}
|
|
11
|
-
export type SerializedStickyNode = Spread<StickyNodeType, SerializedLexicalNode>;
|
|
12
|
-
export declare class StickyNode extends DecoratorNode<JSX.Element> {
|
|
13
|
-
__x: number;
|
|
14
|
-
__y: number;
|
|
15
|
-
__user: string;
|
|
16
|
-
__state?: AnyObject;
|
|
17
|
-
__color: StickyNoteColor;
|
|
18
|
-
static getType(): string;
|
|
19
|
-
static clone(node: StickyNode): StickyNode;
|
|
20
|
-
static importJSON(serializedNode: SerializedStickyNode): StickyNode;
|
|
21
|
-
static importDOM(): DOMConversionMap | null;
|
|
22
|
-
constructor(x: number, y: number, user?: string, color?: StickyNoteColor, state?: KeyValue, key?: NodeKey);
|
|
23
|
-
exportJSON(): SerializedStickyNode;
|
|
24
|
-
createDOM(config: EditorConfig): HTMLElement;
|
|
25
|
-
updateDOM(): false;
|
|
26
|
-
exportDOM(): DOMExportOutput;
|
|
27
|
-
setPosition(x: number, y: number): void;
|
|
28
|
-
toggleColor(): void;
|
|
29
|
-
updateState(text: KeyValue): void;
|
|
30
|
-
decorate(editor: LexicalEditor, config: EditorConfig): JSX.Element;
|
|
31
|
-
isIsolated(): true;
|
|
32
|
-
}
|
|
33
|
-
export declare function $isStickyNode(node: LexicalNode | null | undefined): node is StickyNode;
|
|
34
|
-
export declare function $createStickyNode({ xOffset, yOffset, user, color, state, }: StickyNodeType): StickyNode;
|
|
35
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const StickyPlugin: () => JSX.Element | null;
|