@react-fabric/lexical 1.0.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/LICENSE +21 -0
- package/README.md +10 -0
- package/dist/cjs/_virtual/prism.js +5 -0
- package/dist/cjs/editor/Lexical.module.css +1 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +432 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.js +21 -0
- package/dist/cjs/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +27 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.dev.js +1139 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.js +25 -0
- package/dist/cjs/node_modules/@lexical/code/LexicalCode.prod.js +50 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.dev.js +245 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.js +19 -0
- package/dist/cjs/node_modules/@lexical/html/LexicalHtml.prod.js +18 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.dev.js +471 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.js +17 -0
- package/dist/cjs/node_modules/@lexical/link/LexicalLink.prod.js +24 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.dev.js +1275 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.js +29 -0
- package/dist/cjs/node_modules/@lexical/list/LexicalList.prod.js +29 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.dev.js +789 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.js +29 -0
- package/dist/cjs/node_modules/@lexical/rich-text/LexicalRichText.prod.js +26 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.dev.js +976 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.js +35 -0
- package/dist/cjs/node_modules/@lexical/selection/LexicalSelection.prod.js +35 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.dev.js +2792 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.js +23 -0
- package/dist/cjs/node_modules/@lexical/table/LexicalTable.prod.js +55 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.dev.js +888 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.js +35 -0
- package/dist/cjs/node_modules/@lexical/utils/LexicalUtils.prod.js +66 -0
- package/dist/cjs/node_modules/@mdi/js/mdi.js +8 -0
- package/dist/cjs/node_modules/prismjs/components/prism-c.js +82 -0
- package/dist/cjs/node_modules/prismjs/components/prism-clike.js +33 -0
- package/dist/cjs/node_modules/prismjs/components/prism-cpp.js +101 -0
- package/dist/cjs/node_modules/prismjs/components/prism-css.js +66 -0
- package/dist/cjs/node_modules/prismjs/components/prism-java.js +126 -0
- package/dist/cjs/node_modules/prismjs/components/prism-javascript.js +174 -0
- package/dist/cjs/node_modules/prismjs/components/prism-markdown.js +417 -0
- package/dist/cjs/node_modules/prismjs/components/prism-markup.js +188 -0
- package/dist/cjs/node_modules/prismjs/components/prism-objectivec.js +14 -0
- package/dist/cjs/node_modules/prismjs/components/prism-powershell.js +60 -0
- package/dist/cjs/node_modules/prismjs/components/prism-python.js +67 -0
- package/dist/cjs/node_modules/prismjs/components/prism-rust.js +130 -0
- package/dist/cjs/node_modules/prismjs/components/prism-sql.js +34 -0
- package/dist/cjs/node_modules/prismjs/components/prism-swift.js +150 -0
- package/dist/cjs/node_modules/prismjs/components/prism-typescript.js +62 -0
- package/dist/cjs/node_modules/prismjs/prism.js +1951 -0
- package/dist/cjs/packages/lexical/src/components/StickyComponent.js +221 -0
- package/dist/cjs/packages/lexical/src/editor/LexicalEditor.js +156 -0
- package/dist/cjs/packages/lexical/src/editor/theme.js +97 -0
- package/dist/cjs/packages/lexical/src/hooks/useFormatWatcher.js +451 -0
- package/dist/cjs/packages/lexical/src/index.js +7 -0
- package/dist/cjs/packages/lexical/src/nodes/StickyNode.js +218 -0
- package/dist/cjs/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
- package/dist/cjs/packages/lexical/src/plugins/StickyPlugin.js +20 -0
- package/dist/cjs/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
- package/dist/cjs/packages/lexical/src/utils/index.js +214 -0
- package/dist/esm/_virtual/prism.js +5 -0
- package/dist/esm/editor/Lexical.module.css +1 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.dev.js +423 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.js +19 -0
- package/dist/esm/node_modules/@lexical/clipboard/LexicalClipboard.prod.js +18 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.dev.js +1121 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.js +21 -0
- package/dist/esm/node_modules/@lexical/code/LexicalCode.prod.js +32 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.dev.js +244 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.js +18 -0
- package/dist/esm/node_modules/@lexical/html/LexicalHtml.prod.js +17 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.dev.js +463 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.js +17 -0
- package/dist/esm/node_modules/@lexical/link/LexicalLink.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.dev.js +1262 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.js +23 -0
- package/dist/esm/node_modules/@lexical/list/LexicalList.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.dev.js +781 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.js +23 -0
- package/dist/esm/node_modules/@lexical/rich-text/LexicalRichText.prod.js +18 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.dev.js +957 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.js +26 -0
- package/dist/esm/node_modules/@lexical/selection/LexicalSelection.prod.js +16 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.dev.js +2754 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.js +20 -0
- package/dist/esm/node_modules/@lexical/table/LexicalTable.prod.js +17 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.dev.js +839 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.js +26 -0
- package/dist/esm/node_modules/@lexical/utils/LexicalUtils.prod.js +17 -0
- package/dist/esm/node_modules/@mdi/js/mdi.js +7 -0
- package/dist/esm/node_modules/prismjs/components/prism-c.js +82 -0
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +33 -0
- package/dist/esm/node_modules/prismjs/components/prism-cpp.js +101 -0
- package/dist/esm/node_modules/prismjs/components/prism-css.js +66 -0
- package/dist/esm/node_modules/prismjs/components/prism-java.js +126 -0
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +174 -0
- package/dist/esm/node_modules/prismjs/components/prism-markdown.js +417 -0
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +188 -0
- package/dist/esm/node_modules/prismjs/components/prism-objectivec.js +14 -0
- package/dist/esm/node_modules/prismjs/components/prism-powershell.js +60 -0
- package/dist/esm/node_modules/prismjs/components/prism-python.js +67 -0
- package/dist/esm/node_modules/prismjs/components/prism-rust.js +130 -0
- package/dist/esm/node_modules/prismjs/components/prism-sql.js +34 -0
- package/dist/esm/node_modules/prismjs/components/prism-swift.js +150 -0
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +62 -0
- package/dist/esm/node_modules/prismjs/prism.js +1951 -0
- package/dist/esm/packages/lexical/src/components/StickyComponent.js +221 -0
- package/dist/esm/packages/lexical/src/editor/LexicalEditor.js +156 -0
- package/dist/esm/packages/lexical/src/editor/theme.js +97 -0
- package/dist/esm/packages/lexical/src/hooks/useFormatWatcher.js +450 -0
- package/dist/esm/packages/lexical/src/index.js +3 -0
- package/dist/esm/packages/lexical/src/nodes/StickyNode.js +216 -0
- package/dist/esm/packages/lexical/src/plugins/DraggableBlockPlugin.js +314 -0
- package/dist/esm/packages/lexical/src/plugins/StickyPlugin.js +20 -0
- package/dist/esm/packages/lexical/src/plugins/ToolbarPlugin.js +258 -0
- package/dist/esm/packages/lexical/src/utils/index.js +211 -0
- package/dist/types/components/StickyComponent.d.ts +9 -0
- package/dist/types/editor/LexicalEditor.d.ts +13 -0
- package/dist/types/editor/theme.d.ts +70 -0
- package/dist/types/hooks/useFormatWatcher.d.ts +40 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/nodes/StickyNode.d.ts +35 -0
- package/dist/types/plugins/DraggableBlockPlugin.d.ts +3 -0
- package/dist/types/plugins/StickyPlugin.d.ts +1 -0
- package/dist/types/plugins/ToolbarPlugin.d.ts +1 -0
- package/dist/types/utils/index.d.ts +57 -0
- package/package.json +55 -0
- package/src/components/StickyComponent.tsx +271 -0
- package/src/editor/Lexical.module.css +218 -0
- package/src/editor/LexicalEditor.tsx +222 -0
- package/src/editor/theme.ts +93 -0
- package/src/hooks/useFormatWatcher.ts +504 -0
- package/src/index.ts +24 -0
- package/src/nodes/StickyNode.tsx +249 -0
- package/src/plugins/DraggableBlockPlugin.tsx +418 -0
- package/src/plugins/StickyPlugin.ts +38 -0
- package/src/plugins/ToolbarPlugin.tsx +279 -0
- package/src/utils/index.ts +303 -0
|
@@ -0,0 +1,450 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _asyncToGenerator from '@babel/runtime/helpers/asyncToGenerator';
|
|
4
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
5
|
+
import _regeneratorRuntime from '@babel/runtime/regenerator';
|
|
6
|
+
import { $isCodeNode, CODE_LANGUAGE_MAP, $createCodeNode } from '../../../../node_modules/@lexical/code/LexicalCode.js';
|
|
7
|
+
import { $isLinkNode } from '../../../../node_modules/@lexical/link/LexicalLink.js';
|
|
8
|
+
import { $isListNode, ListNode, INSERT_UNORDERED_LIST_COMMAND, REMOVE_LIST_COMMAND, INSERT_CHECK_LIST_COMMAND, INSERT_ORDERED_LIST_COMMAND } from '../../../../node_modules/@lexical/list/LexicalList.js';
|
|
9
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
10
|
+
import { $isHeadingNode, $createQuoteNode, $createHeadingNode, $isQuoteNode } from '../../../../node_modules/@lexical/rich-text/LexicalRichText.js';
|
|
11
|
+
import { $isParentElementRTL, $getSelectionStyleValueForProperty, $patchStyleText, $setBlocksType, $isAtNodeEnd } from '../../../../node_modules/@lexical/selection/LexicalSelection.js';
|
|
12
|
+
import { $isTableNode } from '../../../../node_modules/@lexical/table/LexicalTable.js';
|
|
13
|
+
import { $findMatchingParent, $getNearestNodeOfType, mergeRegister, $getNearestBlockElementAncestorOrThrow } from '../../../../node_modules/@lexical/utils/LexicalUtils.js';
|
|
14
|
+
import { $getSelection, $isRangeSelection, $isRootOrShadowRoot, FOCUS_COMMAND, COMMAND_PRIORITY_CRITICAL, SELECTION_CHANGE_COMMAND, CAN_UNDO_COMMAND, CAN_REDO_COMMAND, $createParagraphNode, INDENT_CONTENT_COMMAND, OUTDENT_CONTENT_COMMAND, $isTextNode } from 'lexical';
|
|
15
|
+
import { useTransition, useState, useCallback, useEffect } from 'react';
|
|
16
|
+
|
|
17
|
+
var blockTypeToBlockName = {
|
|
18
|
+
bullet: "Bulleted List",
|
|
19
|
+
check: "Check List",
|
|
20
|
+
code: "Code Block",
|
|
21
|
+
h1: "Heading 1",
|
|
22
|
+
h2: "Heading 2",
|
|
23
|
+
h3: "Heading 3",
|
|
24
|
+
h4: "Heading 4",
|
|
25
|
+
h5: "Heading 5",
|
|
26
|
+
h6: "Heading 6",
|
|
27
|
+
number: "Numbered List",
|
|
28
|
+
paragraph: "Normal",
|
|
29
|
+
quote: "Quote"
|
|
30
|
+
};
|
|
31
|
+
function getSelectedNode(selection) {
|
|
32
|
+
var anchor = selection.anchor;
|
|
33
|
+
var focus = selection.focus;
|
|
34
|
+
var anchorNode = selection.anchor.getNode();
|
|
35
|
+
var focusNode = selection.focus.getNode();
|
|
36
|
+
if (anchorNode === focusNode) {
|
|
37
|
+
return anchorNode;
|
|
38
|
+
}
|
|
39
|
+
var isBackward = selection.isBackward();
|
|
40
|
+
if (isBackward) {
|
|
41
|
+
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
42
|
+
} else {
|
|
43
|
+
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var useFormatWatcher = function useFormatWatcher() {
|
|
47
|
+
var _useTransition = useTransition(),
|
|
48
|
+
_useTransition2 = _slicedToArray(_useTransition, 2),
|
|
49
|
+
startTransition = _useTransition2[1];
|
|
50
|
+
var _useLexicalComposerCo = useLexicalComposerContext(),
|
|
51
|
+
_useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
|
|
52
|
+
editor = _useLexicalComposerCo2[0];
|
|
53
|
+
var _useState = useState(editor),
|
|
54
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
55
|
+
activeEditor = _useState2[0],
|
|
56
|
+
setActiveEditor = _useState2[1];
|
|
57
|
+
var _useState3 = useState("paragraph"),
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
blockType = _useState4[0],
|
|
60
|
+
setBlockType = _useState4[1];
|
|
61
|
+
var _useState5 = useState("root"),
|
|
62
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
63
|
+
rootType = _useState6[0],
|
|
64
|
+
setRootType = _useState6[1];
|
|
65
|
+
var _useState7 = useState(null),
|
|
66
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
67
|
+
selectedElementKey = _useState8[0],
|
|
68
|
+
setSelectedElementKey = _useState8[1];
|
|
69
|
+
var _useState9 = useState("16"),
|
|
70
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
|
71
|
+
fontSize = _useState10[0],
|
|
72
|
+
setFontSize = _useState10[1];
|
|
73
|
+
var _useState11 = useState("#000"),
|
|
74
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
|
75
|
+
fontColor = _useState12[0],
|
|
76
|
+
setFontColor = _useState12[1];
|
|
77
|
+
var _useState13 = useState("#fff"),
|
|
78
|
+
_useState14 = _slicedToArray(_useState13, 2),
|
|
79
|
+
bgColor = _useState14[0],
|
|
80
|
+
setBgColor = _useState14[1];
|
|
81
|
+
var _useState15 = useState("Arial"),
|
|
82
|
+
_useState16 = _slicedToArray(_useState15, 2),
|
|
83
|
+
fontFamily = _useState16[0],
|
|
84
|
+
setFontFamily = _useState16[1];
|
|
85
|
+
var _useState17 = useState(false),
|
|
86
|
+
_useState18 = _slicedToArray(_useState17, 2),
|
|
87
|
+
isLink = _useState18[0],
|
|
88
|
+
setIsLink = _useState18[1];
|
|
89
|
+
var _useState19 = useState(false),
|
|
90
|
+
_useState20 = _slicedToArray(_useState19, 2),
|
|
91
|
+
isBold = _useState20[0],
|
|
92
|
+
setIsBold = _useState20[1];
|
|
93
|
+
var _useState21 = useState(false),
|
|
94
|
+
_useState22 = _slicedToArray(_useState21, 2),
|
|
95
|
+
isItalic = _useState22[0],
|
|
96
|
+
setIsItalic = _useState22[1];
|
|
97
|
+
var _useState23 = useState(false),
|
|
98
|
+
_useState24 = _slicedToArray(_useState23, 2),
|
|
99
|
+
isUnderline = _useState24[0],
|
|
100
|
+
setIsUnderline = _useState24[1];
|
|
101
|
+
var _useState25 = useState(false),
|
|
102
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
|
103
|
+
isStrikethrough = _useState26[0],
|
|
104
|
+
setIsStrikethrough = _useState26[1];
|
|
105
|
+
var _useState27 = useState(false),
|
|
106
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
|
107
|
+
isSubscript = _useState28[0],
|
|
108
|
+
setIsSubscript = _useState28[1];
|
|
109
|
+
var _useState29 = useState(false),
|
|
110
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
|
111
|
+
isSuperscript = _useState30[0],
|
|
112
|
+
setIsSuperscript = _useState30[1];
|
|
113
|
+
var _useState31 = useState(false),
|
|
114
|
+
_useState32 = _slicedToArray(_useState31, 2),
|
|
115
|
+
isCode = _useState32[0],
|
|
116
|
+
setIsCode = _useState32[1];
|
|
117
|
+
var _useState33 = useState(false),
|
|
118
|
+
_useState34 = _slicedToArray(_useState33, 2),
|
|
119
|
+
canUndo = _useState34[0],
|
|
120
|
+
setCanUndo = _useState34[1];
|
|
121
|
+
var _useState35 = useState(false),
|
|
122
|
+
_useState36 = _slicedToArray(_useState35, 2),
|
|
123
|
+
canRedo = _useState36[0],
|
|
124
|
+
setCanRedo = _useState36[1];
|
|
125
|
+
var _useState37 = useState(false),
|
|
126
|
+
_useState38 = _slicedToArray(_useState37, 2),
|
|
127
|
+
isRTL = _useState38[0],
|
|
128
|
+
setIsRTL = _useState38[1];
|
|
129
|
+
var _useState39 = useState(""),
|
|
130
|
+
_useState40 = _slicedToArray(_useState39, 2),
|
|
131
|
+
codeLanguage = _useState40[0],
|
|
132
|
+
setCodeLanguage = _useState40[1];
|
|
133
|
+
var _useState41 = useState(function () {
|
|
134
|
+
return editor.isEditable();
|
|
135
|
+
}),
|
|
136
|
+
_useState42 = _slicedToArray(_useState41, 2),
|
|
137
|
+
isEditable = _useState42[0],
|
|
138
|
+
setIsEditable = _useState42[1];
|
|
139
|
+
var $updateToolbar = useCallback(function () {
|
|
140
|
+
var selection = $getSelection();
|
|
141
|
+
if ($isRangeSelection(selection)) {
|
|
142
|
+
var anchorNode = selection.anchor.getNode();
|
|
143
|
+
var element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, function (e) {
|
|
144
|
+
var parent = e.getParent();
|
|
145
|
+
return parent !== null && $isRootOrShadowRoot(parent);
|
|
146
|
+
});
|
|
147
|
+
if (element === null) {
|
|
148
|
+
element = anchorNode.getTopLevelElementOrThrow();
|
|
149
|
+
}
|
|
150
|
+
var elementKey = element.getKey();
|
|
151
|
+
var elementDOM = activeEditor.getElementByKey(elementKey);
|
|
152
|
+
|
|
153
|
+
// Update text format
|
|
154
|
+
setIsBold(selection.hasFormat("bold"));
|
|
155
|
+
setIsItalic(selection.hasFormat("italic"));
|
|
156
|
+
setIsUnderline(selection.hasFormat("underline"));
|
|
157
|
+
setIsStrikethrough(selection.hasFormat("strikethrough"));
|
|
158
|
+
setIsSubscript(selection.hasFormat("subscript"));
|
|
159
|
+
setIsSuperscript(selection.hasFormat("superscript"));
|
|
160
|
+
setIsCode(selection.hasFormat("code"));
|
|
161
|
+
setIsRTL($isParentElementRTL(selection));
|
|
162
|
+
|
|
163
|
+
// Update links
|
|
164
|
+
var node = getSelectedNode(selection);
|
|
165
|
+
var parent = node.getParent();
|
|
166
|
+
if ($isLinkNode(parent) || $isLinkNode(node)) {
|
|
167
|
+
setIsLink(true);
|
|
168
|
+
} else {
|
|
169
|
+
setIsLink(false);
|
|
170
|
+
}
|
|
171
|
+
var tableNode = $findMatchingParent(node, $isTableNode);
|
|
172
|
+
if ($isTableNode(tableNode)) {
|
|
173
|
+
setRootType("table");
|
|
174
|
+
} else {
|
|
175
|
+
setRootType("root");
|
|
176
|
+
}
|
|
177
|
+
if (elementDOM !== null) {
|
|
178
|
+
setSelectedElementKey(elementKey);
|
|
179
|
+
if ($isListNode(element)) {
|
|
180
|
+
var parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
181
|
+
var type = parentList ? parentList.getListType() : element.getListType();
|
|
182
|
+
setBlockType(type);
|
|
183
|
+
} else {
|
|
184
|
+
var _type = $isHeadingNode(element) ? element.getTag() : element.getType();
|
|
185
|
+
if (_type in blockTypeToBlockName) {
|
|
186
|
+
setBlockType(_type);
|
|
187
|
+
}
|
|
188
|
+
if ($isCodeNode(element)) {
|
|
189
|
+
var language = element.getLanguage();
|
|
190
|
+
setCodeLanguage(language ? CODE_LANGUAGE_MAP[language] || language : "");
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
// Handle buttons
|
|
196
|
+
setFontSize(parseInt($getSelectionStyleValueForProperty(selection, "font-size", "16")) + "");
|
|
197
|
+
setFontColor($getSelectionStyleValueForProperty(selection, "color", "#000"));
|
|
198
|
+
setBgColor($getSelectionStyleValueForProperty(selection, "background-color", "#fff"));
|
|
199
|
+
setFontFamily($getSelectionStyleValueForProperty(selection, "font-family", "inherit"));
|
|
200
|
+
}
|
|
201
|
+
}, [activeEditor]);
|
|
202
|
+
useEffect(function () {
|
|
203
|
+
return editor.registerCommand(FOCUS_COMMAND, function (_payload, newEditor) {
|
|
204
|
+
setActiveEditor(newEditor);
|
|
205
|
+
return false;
|
|
206
|
+
}, COMMAND_PRIORITY_CRITICAL);
|
|
207
|
+
}, [editor]);
|
|
208
|
+
useEffect(function () {
|
|
209
|
+
return activeEditor.registerCommand(SELECTION_CHANGE_COMMAND, function (_payload, newEditor) {
|
|
210
|
+
$updateToolbar();
|
|
211
|
+
return false;
|
|
212
|
+
}, COMMAND_PRIORITY_CRITICAL);
|
|
213
|
+
}, [activeEditor, $updateToolbar]);
|
|
214
|
+
useEffect(function () {
|
|
215
|
+
return mergeRegister(editor.registerEditableListener(function (editable) {
|
|
216
|
+
setIsEditable(editable);
|
|
217
|
+
}), activeEditor.registerUpdateListener(function (_ref) {
|
|
218
|
+
var editorState = _ref.editorState;
|
|
219
|
+
editorState.read(function () {
|
|
220
|
+
$updateToolbar();
|
|
221
|
+
});
|
|
222
|
+
}), activeEditor.registerCommand(CAN_UNDO_COMMAND, function (payload) {
|
|
223
|
+
setCanUndo(payload);
|
|
224
|
+
return false;
|
|
225
|
+
}, COMMAND_PRIORITY_CRITICAL), activeEditor.registerCommand(CAN_REDO_COMMAND, function (payload) {
|
|
226
|
+
setCanRedo(payload);
|
|
227
|
+
return false;
|
|
228
|
+
}, COMMAND_PRIORITY_CRITICAL));
|
|
229
|
+
}, [$updateToolbar, activeEditor, editor]);
|
|
230
|
+
var applyStyleText = useCallback(function (styles) {
|
|
231
|
+
setTimeout(function () {
|
|
232
|
+
editor.update(function () {
|
|
233
|
+
var selection = $getSelection();
|
|
234
|
+
if ($isRangeSelection(selection)) {
|
|
235
|
+
$patchStyleText(selection, styles);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}, 100);
|
|
239
|
+
}, [editor]);
|
|
240
|
+
var formatBulletList = function formatBulletList() {
|
|
241
|
+
setTimeout(function () {
|
|
242
|
+
if (blockType !== "bullet") {
|
|
243
|
+
editor.dispatchCommand(INSERT_UNORDERED_LIST_COMMAND, undefined);
|
|
244
|
+
} else {
|
|
245
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
246
|
+
}
|
|
247
|
+
}, 100);
|
|
248
|
+
};
|
|
249
|
+
var formatCheckList = function formatCheckList() {
|
|
250
|
+
setTimeout(function () {
|
|
251
|
+
if (blockType !== "check") {
|
|
252
|
+
editor.dispatchCommand(INSERT_CHECK_LIST_COMMAND, undefined);
|
|
253
|
+
} else {
|
|
254
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
255
|
+
}
|
|
256
|
+
}, 100);
|
|
257
|
+
};
|
|
258
|
+
var formatNumberedList = function formatNumberedList() {
|
|
259
|
+
setTimeout(function () {
|
|
260
|
+
if (blockType !== "number") {
|
|
261
|
+
editor.dispatchCommand(INSERT_ORDERED_LIST_COMMAND, undefined);
|
|
262
|
+
} else {
|
|
263
|
+
editor.dispatchCommand(REMOVE_LIST_COMMAND, undefined);
|
|
264
|
+
}
|
|
265
|
+
}, 100);
|
|
266
|
+
};
|
|
267
|
+
var formatNormal = useCallback(function () {
|
|
268
|
+
setTimeout(function () {
|
|
269
|
+
activeEditor.update(function () {
|
|
270
|
+
var selection = $getSelection();
|
|
271
|
+
if ($isRangeSelection(selection)) {
|
|
272
|
+
$setBlocksType(selection, function () {
|
|
273
|
+
return $createParagraphNode();
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}, 100);
|
|
278
|
+
}, [activeEditor, blockType]);
|
|
279
|
+
var formatQuote = useCallback(function () {
|
|
280
|
+
if (blockType !== "quote") {
|
|
281
|
+
setTimeout(function () {
|
|
282
|
+
activeEditor.update(function () {
|
|
283
|
+
var selection = $getSelection();
|
|
284
|
+
if ($isRangeSelection(selection)) {
|
|
285
|
+
$setBlocksType(selection, function () {
|
|
286
|
+
return $createQuoteNode();
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
}, 100);
|
|
291
|
+
}
|
|
292
|
+
}, [activeEditor, blockType]);
|
|
293
|
+
var formatBlock = useCallback(function () {
|
|
294
|
+
if (blockType !== "code") {
|
|
295
|
+
setTimeout(function () {
|
|
296
|
+
activeEditor.update(function () {
|
|
297
|
+
var selection = $getSelection();
|
|
298
|
+
if ($isRangeSelection(selection)) {
|
|
299
|
+
$setBlocksType(selection, function () {
|
|
300
|
+
return $createCodeNode();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
}, 100);
|
|
305
|
+
}
|
|
306
|
+
}, [activeEditor, blockType]);
|
|
307
|
+
var formatHeading = useCallback(function (headingSize) {
|
|
308
|
+
if (blockType !== headingSize) {
|
|
309
|
+
setTimeout(function () {
|
|
310
|
+
activeEditor.update(function () {
|
|
311
|
+
var selection = $getSelection();
|
|
312
|
+
if ($isRangeSelection(selection)) {
|
|
313
|
+
$setBlocksType(selection, function () {
|
|
314
|
+
return $createHeadingNode(headingSize);
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}, 100);
|
|
319
|
+
}
|
|
320
|
+
}, [activeEditor, blockType]);
|
|
321
|
+
var indent = useCallback(function () {
|
|
322
|
+
activeEditor.dispatchCommand(INDENT_CONTENT_COMMAND, undefined);
|
|
323
|
+
}, [activeEditor]);
|
|
324
|
+
var outdent = useCallback(function () {
|
|
325
|
+
activeEditor.dispatchCommand(OUTDENT_CONTENT_COMMAND, undefined);
|
|
326
|
+
}, [activeEditor]);
|
|
327
|
+
var clearFormatting = useCallback(function () {
|
|
328
|
+
activeEditor.update(function () {
|
|
329
|
+
var selection = $getSelection();
|
|
330
|
+
if ($isRangeSelection(selection)) {
|
|
331
|
+
var anchor = selection.anchor;
|
|
332
|
+
var focus = selection.focus;
|
|
333
|
+
var nodes = selection.getNodes();
|
|
334
|
+
if (anchor.key === focus.key && anchor.offset === focus.offset) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
setFontSize("16");
|
|
338
|
+
setBgColor("#fff");
|
|
339
|
+
setFontColor("#000");
|
|
340
|
+
nodes.forEach(function (node, idx) {
|
|
341
|
+
// We split the first and last node by the selection
|
|
342
|
+
// So that we don't format unselected text inside those nodes
|
|
343
|
+
if ($isTextNode(node)) {
|
|
344
|
+
if (idx === 0 && anchor.offset !== 0) {
|
|
345
|
+
node = node.splitText(anchor.offset)[1] || node;
|
|
346
|
+
}
|
|
347
|
+
if (idx === nodes.length - 1 && $isTextNode(node)) {
|
|
348
|
+
node = node.splitText(focus.offset)[0] || node;
|
|
349
|
+
}
|
|
350
|
+
if ($isTextNode(node)) {
|
|
351
|
+
if (node.__style !== "") {
|
|
352
|
+
node.setStyle("");
|
|
353
|
+
}
|
|
354
|
+
if (node.__format !== 0) {
|
|
355
|
+
node.setFormat(0);
|
|
356
|
+
$getNearestBlockElementAncestorOrThrow(node).setFormat("");
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
} else if ($isHeadingNode(node) || $isQuoteNode(node)) {
|
|
360
|
+
node.replace($createParagraphNode(), true);
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}, [activeEditor]);
|
|
366
|
+
var onSizeChange = useCallback(function (value) {
|
|
367
|
+
startTransition(function () {
|
|
368
|
+
return setFontColor(value);
|
|
369
|
+
});
|
|
370
|
+
applyStyleText({
|
|
371
|
+
"font-size": +value + "px"
|
|
372
|
+
});
|
|
373
|
+
}, [applyStyleText]);
|
|
374
|
+
var onFontColorSelect = useCallback(function (value) {
|
|
375
|
+
startTransition(function () {
|
|
376
|
+
return setFontColor(value);
|
|
377
|
+
});
|
|
378
|
+
applyStyleText({
|
|
379
|
+
color: value
|
|
380
|
+
});
|
|
381
|
+
}, [applyStyleText]);
|
|
382
|
+
var onBgColorSelect = useCallback(function (value) {
|
|
383
|
+
startTransition(function () {
|
|
384
|
+
return setBgColor(value);
|
|
385
|
+
});
|
|
386
|
+
applyStyleText({
|
|
387
|
+
"background-color": value
|
|
388
|
+
});
|
|
389
|
+
}, [applyStyleText]);
|
|
390
|
+
|
|
391
|
+
// @ts-expect-error ignore
|
|
392
|
+
window.$getSelection = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
393
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
394
|
+
while (1) switch (_context.prev = _context.next) {
|
|
395
|
+
case 0:
|
|
396
|
+
_context.next = 2;
|
|
397
|
+
return new Promise(function (resolve) {
|
|
398
|
+
activeEditor.update(function () {
|
|
399
|
+
var selection = $getSelection();
|
|
400
|
+
resolve(selection);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
case 2:
|
|
404
|
+
return _context.abrupt("return", _context.sent);
|
|
405
|
+
case 3:
|
|
406
|
+
case "end":
|
|
407
|
+
return _context.stop();
|
|
408
|
+
}
|
|
409
|
+
}, _callee);
|
|
410
|
+
}));
|
|
411
|
+
return {
|
|
412
|
+
editor: editor,
|
|
413
|
+
blockType: blockType,
|
|
414
|
+
rootType: rootType,
|
|
415
|
+
selectedElementKey: selectedElementKey,
|
|
416
|
+
fontSize: fontSize,
|
|
417
|
+
fontColor: fontColor,
|
|
418
|
+
bgColor: bgColor,
|
|
419
|
+
fontFamily: fontFamily,
|
|
420
|
+
isLink: isLink,
|
|
421
|
+
isBold: isBold,
|
|
422
|
+
isItalic: isItalic,
|
|
423
|
+
isUnderline: isUnderline,
|
|
424
|
+
isStrikethrough: isStrikethrough,
|
|
425
|
+
isSubscript: isSubscript,
|
|
426
|
+
isSuperscript: isSuperscript,
|
|
427
|
+
isCode: isCode,
|
|
428
|
+
canUndo: canUndo,
|
|
429
|
+
canRedo: canRedo,
|
|
430
|
+
isRTL: isRTL,
|
|
431
|
+
isEditable: isEditable,
|
|
432
|
+
codeLanguage: codeLanguage,
|
|
433
|
+
activeEditor: activeEditor,
|
|
434
|
+
indent: indent,
|
|
435
|
+
outdent: outdent,
|
|
436
|
+
clearFormatting: clearFormatting,
|
|
437
|
+
onFontColorSelect: onFontColorSelect,
|
|
438
|
+
onBgColorSelect: onBgColorSelect,
|
|
439
|
+
formatQuote: formatQuote,
|
|
440
|
+
onSizeChange: onSizeChange,
|
|
441
|
+
formatBlock: formatBlock,
|
|
442
|
+
formatNormal: formatNormal,
|
|
443
|
+
formatHeading: formatHeading,
|
|
444
|
+
formatBulletList: formatBulletList,
|
|
445
|
+
formatCheckList: formatCheckList,
|
|
446
|
+
formatNumberedList: formatNumberedList
|
|
447
|
+
};
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
export { getSelectedNode, useFormatWatcher };
|
|
@@ -0,0 +1,216 @@
|
|
|
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 };
|