@tiny-codes/react-easy 1.3.1 → 1.4.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/CHANGELOG.md +8 -0
- package/es/components/Lexical/helpers/index.d.ts +58 -0
- package/es/components/Lexical/helpers/index.js +249 -0
- package/es/components/Lexical/helpers/index.js.map +1 -0
- package/es/components/Lexical/index.d.ts +5 -0
- package/es/components/Lexical/index.js +6 -0
- package/es/components/Lexical/index.js.map +1 -0
- package/es/components/Lexical/nodes/DivNode.d.ts +25 -0
- package/es/components/Lexical/nodes/DivNode.js +163 -0
- package/es/components/Lexical/nodes/DivNode.js.map +1 -0
- package/es/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
- package/es/components/Lexical/nodes/ExtendTextNode.js +102 -0
- package/es/components/Lexical/nodes/ExtendTextNode.js.map +1 -0
- package/es/components/Lexical/nodes/SelectNode.d.ts +44 -0
- package/es/components/Lexical/nodes/SelectNode.js +204 -0
- package/es/components/Lexical/nodes/SelectNode.js.map +1 -0
- package/es/components/Lexical/nodes/base.d.ts +51 -0
- package/es/components/Lexical/nodes/base.js +168 -0
- package/es/components/Lexical/nodes/base.js.map +1 -0
- package/es/hooks/useRefValue.d.ts +2 -2
- package/es/hooks/useRefValue.js.map +1 -1
- package/lib/components/Lexical/helpers/index.d.ts +58 -0
- package/lib/components/Lexical/helpers/index.js +198 -0
- package/lib/components/Lexical/helpers/index.js.map +7 -0
- package/lib/components/Lexical/index.d.ts +5 -0
- package/lib/components/Lexical/index.js +32 -0
- package/lib/components/Lexical/index.js.map +7 -0
- package/lib/components/Lexical/nodes/DivNode.d.ts +25 -0
- package/lib/components/Lexical/nodes/DivNode.js +139 -0
- package/lib/components/Lexical/nodes/DivNode.js.map +7 -0
- package/lib/components/Lexical/nodes/ExtendTextNode.d.ts +24 -0
- package/lib/components/Lexical/nodes/ExtendTextNode.js +87 -0
- package/lib/components/Lexical/nodes/ExtendTextNode.js.map +7 -0
- package/lib/components/Lexical/nodes/SelectNode.d.ts +44 -0
- package/lib/components/Lexical/nodes/SelectNode.js +157 -0
- package/lib/components/Lexical/nodes/SelectNode.js.map +7 -0
- package/lib/components/Lexical/nodes/base.d.ts +51 -0
- package/lib/components/Lexical/nodes/base.js +116 -0
- package/lib/components/Lexical/nodes/base.js.map +7 -0
- package/lib/hooks/useRefValue.d.ts +2 -2
- package/lib/hooks/useRefValue.js.map +2 -2
- package/package.json +20 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { CSSProperties, HtmlHTMLAttributes } from 'react';
|
|
2
|
+
import type { LexicalEditor, LexicalNode } from 'lexical';
|
|
3
|
+
/**
|
|
4
|
+
* 将节点插入到当前光标位置
|
|
5
|
+
*
|
|
6
|
+
* @param editor LexicalEditor 实例
|
|
7
|
+
* @param node 要插入的节点
|
|
8
|
+
*/
|
|
9
|
+
export declare function insertNodeAtCursor(editor: LexicalEditor, node: LexicalNode): void;
|
|
10
|
+
/**
|
|
11
|
+
* 将文本插入到当前光标位置
|
|
12
|
+
*
|
|
13
|
+
* @param editor LexicalEditor 实例
|
|
14
|
+
* @param text 要插入的文本
|
|
15
|
+
*/
|
|
16
|
+
export declare function insertTextAtCursor(editor: LexicalEditor, text: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* 清空编辑器内容
|
|
19
|
+
*
|
|
20
|
+
* @param editor LexicalEditor 实例
|
|
21
|
+
*/
|
|
22
|
+
export declare function clearEditorContent(editor: LexicalEditor): void;
|
|
23
|
+
/**
|
|
24
|
+
* 查找符合条件的节点
|
|
25
|
+
*
|
|
26
|
+
* @param editor LexicalEditor 实例
|
|
27
|
+
* @param predicate 用于匹配节点的函数
|
|
28
|
+
* @param options 选项
|
|
29
|
+
*
|
|
30
|
+
* @returns 符合条件的节点数组
|
|
31
|
+
*/
|
|
32
|
+
export declare function findNode<T extends LexicalNode>(editor: LexicalEditor, predicate: (node: LexicalNode) => boolean): T | undefined;
|
|
33
|
+
/**
|
|
34
|
+
* 查找所有符合条件的节点数组
|
|
35
|
+
*
|
|
36
|
+
* @param editor LexicalEditor 实例
|
|
37
|
+
* @param predicate 用于匹配节点的函数
|
|
38
|
+
* @param options 选项
|
|
39
|
+
*
|
|
40
|
+
* @returns 符合条件的节点数组
|
|
41
|
+
*/
|
|
42
|
+
export declare function findNodes<T extends LexicalNode>(editor: LexicalEditor, predicate: (node: LexicalNode) => boolean, options?: {
|
|
43
|
+
stopOnFirstMatch?: boolean;
|
|
44
|
+
}): T[];
|
|
45
|
+
/**
|
|
46
|
+
* 更新 DOM 元素的属性
|
|
47
|
+
*
|
|
48
|
+
* @param dom 要更新的 DOM 元素
|
|
49
|
+
* @param props 要设置的属性
|
|
50
|
+
*/
|
|
51
|
+
export declare function updateDomProps(dom: HTMLElement | undefined, props: HtmlHTMLAttributes<HTMLElement>): void;
|
|
52
|
+
/**
|
|
53
|
+
* 更新 DOM 元素的样式
|
|
54
|
+
*
|
|
55
|
+
* @param dom 要更新的 DOM 元素
|
|
56
|
+
* @param style 要设置的样式
|
|
57
|
+
*/
|
|
58
|
+
export declare function updateDomStyle(dom: HTMLElement | undefined, style: CSSProperties | undefined): void;
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
3
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
5
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
6
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
11
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
14
|
+
import { $createTextNode, $getRoot, $getSelection, $isDecoratorNode, $isElementNode, $isParagraphNode, $isRangeSelection, $isTextNode } from 'lexical';
|
|
15
|
+
import { $createDivNode, $isDivNode } from "../nodes/DivNode";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 将节点插入到当前光标位置
|
|
19
|
+
*
|
|
20
|
+
* @param editor LexicalEditor 实例
|
|
21
|
+
* @param node 要插入的节点
|
|
22
|
+
*/
|
|
23
|
+
export function insertNodeAtCursor(editor, node) {
|
|
24
|
+
editor.update(function () {
|
|
25
|
+
var selection = $getSelection();
|
|
26
|
+
if (selection) {
|
|
27
|
+
if ($isRangeSelection(selection)) {
|
|
28
|
+
// 如果没有选取,则直接在根节点末尾插入
|
|
29
|
+
var lastNode = selection.focus.getNode();
|
|
30
|
+
if (lastNode) {
|
|
31
|
+
if ($isParagraphNode(lastNode)) {
|
|
32
|
+
lastNode.append(node);
|
|
33
|
+
} else if ($isTextNode(lastNode)) {
|
|
34
|
+
// 如果最后一个节点是文本节点,则在其后插入 SelectNode
|
|
35
|
+
lastNode.insertAfter(node);
|
|
36
|
+
} else if ($isDivNode(lastNode)) {
|
|
37
|
+
lastNode.append(node);
|
|
38
|
+
} else {
|
|
39
|
+
selection.insertNodes([node]);
|
|
40
|
+
}
|
|
41
|
+
node.selectNext();
|
|
42
|
+
}
|
|
43
|
+
} else {
|
|
44
|
+
selection.insertNodes([node]);
|
|
45
|
+
node.selectNext();
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
var root = $getRoot();
|
|
49
|
+
var nodeToInsert = node;
|
|
50
|
+
if ($isElementNode(node) || $isDecoratorNode(node)) {
|
|
51
|
+
nodeToInsert = node;
|
|
52
|
+
} else {
|
|
53
|
+
var container = $createDivNode({
|
|
54
|
+
style: {
|
|
55
|
+
display: 'inline-block'
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
container.append(node);
|
|
59
|
+
nodeToInsert = container;
|
|
60
|
+
}
|
|
61
|
+
root.append(nodeToInsert);
|
|
62
|
+
node.selectNext();
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* 将文本插入到当前光标位置
|
|
69
|
+
*
|
|
70
|
+
* @param editor LexicalEditor 实例
|
|
71
|
+
* @param text 要插入的文本
|
|
72
|
+
*/
|
|
73
|
+
export function insertTextAtCursor(editor, text) {
|
|
74
|
+
editor === null || editor === void 0 || editor.update(function () {
|
|
75
|
+
var textNode = $createTextNode(text);
|
|
76
|
+
var root = $getRoot();
|
|
77
|
+
var selection = $getSelection();
|
|
78
|
+
if (selection) {
|
|
79
|
+
// 插入光标位置
|
|
80
|
+
selection.insertText(text);
|
|
81
|
+
} else {
|
|
82
|
+
// 如果没有选取,则直接在根节点末尾插入
|
|
83
|
+
var lastNode = root.getLastChild();
|
|
84
|
+
if (lastNode && $isParagraphNode(lastNode)) {
|
|
85
|
+
lastNode.append(textNode);
|
|
86
|
+
} else {
|
|
87
|
+
var container = $createDivNode({
|
|
88
|
+
style: {
|
|
89
|
+
display: 'inline-block'
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
container.append(textNode);
|
|
93
|
+
root.append(container);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 清空编辑器内容
|
|
101
|
+
*
|
|
102
|
+
* @param editor LexicalEditor 实例
|
|
103
|
+
*/
|
|
104
|
+
export function clearEditorContent(editor) {
|
|
105
|
+
var state = editor.getEditorState();
|
|
106
|
+
var stateJson = state.toJSON();
|
|
107
|
+
// 默认创建一个ParagraphNode
|
|
108
|
+
var newJson = _objectSpread(_objectSpread({}, stateJson), {}, {
|
|
109
|
+
root: _objectSpread(_objectSpread({}, stateJson.root), {}, {
|
|
110
|
+
children: [{
|
|
111
|
+
children: [],
|
|
112
|
+
direction: null,
|
|
113
|
+
format: '',
|
|
114
|
+
indent: 0,
|
|
115
|
+
type: 'paragraph',
|
|
116
|
+
version: 1,
|
|
117
|
+
textFormat: 0,
|
|
118
|
+
textStyle: ''
|
|
119
|
+
}]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
var emptyState = editor.parseEditorState(JSON.stringify(newJson));
|
|
123
|
+
editor.setEditorState(emptyState);
|
|
124
|
+
editor.update(function () {
|
|
125
|
+
var root = $getRoot();
|
|
126
|
+
root.clear();
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 查找符合条件的节点
|
|
132
|
+
*
|
|
133
|
+
* @param editor LexicalEditor 实例
|
|
134
|
+
* @param predicate 用于匹配节点的函数
|
|
135
|
+
* @param options 选项
|
|
136
|
+
*
|
|
137
|
+
* @returns 符合条件的节点数组
|
|
138
|
+
*/
|
|
139
|
+
export function findNode(editor, predicate) {
|
|
140
|
+
var matched = findNodes(editor, predicate, {
|
|
141
|
+
stopOnFirstMatch: true
|
|
142
|
+
});
|
|
143
|
+
return matched[0];
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* 查找所有符合条件的节点数组
|
|
147
|
+
*
|
|
148
|
+
* @param editor LexicalEditor 实例
|
|
149
|
+
* @param predicate 用于匹配节点的函数
|
|
150
|
+
* @param options 选项
|
|
151
|
+
*
|
|
152
|
+
* @returns 符合条件的节点数组
|
|
153
|
+
*/
|
|
154
|
+
export function findNodes(editor, predicate, options) {
|
|
155
|
+
var matched = [];
|
|
156
|
+
editor.getEditorState().read(function () {
|
|
157
|
+
var root = $getRoot();
|
|
158
|
+
var traverse = function traverse(node, result) {
|
|
159
|
+
if (predicate(node)) {
|
|
160
|
+
result.push(node);
|
|
161
|
+
if (options !== null && options !== void 0 && options.stopOnFirstMatch) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
if ($isElementNode(node)) {
|
|
166
|
+
var children = node.getChildren();
|
|
167
|
+
var _iterator = _createForOfIteratorHelper(children),
|
|
168
|
+
_step;
|
|
169
|
+
try {
|
|
170
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
171
|
+
var child = _step.value;
|
|
172
|
+
traverse(child, result);
|
|
173
|
+
if (options !== null && options !== void 0 && options.stopOnFirstMatch && result.length > 0) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} catch (err) {
|
|
178
|
+
_iterator.e(err);
|
|
179
|
+
} finally {
|
|
180
|
+
_iterator.f();
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
traverse(root, matched);
|
|
185
|
+
});
|
|
186
|
+
return matched;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* 更新 DOM 元素的属性
|
|
191
|
+
*
|
|
192
|
+
* @param dom 要更新的 DOM 元素
|
|
193
|
+
* @param props 要设置的属性
|
|
194
|
+
*/
|
|
195
|
+
export function updateDomProps(dom, props) {
|
|
196
|
+
if (!dom) return;
|
|
197
|
+
Array.from(dom.attributes).forEach(function (attr) {
|
|
198
|
+
if (!attr.name.startsWith('data-lexical')) {
|
|
199
|
+
dom.removeAttribute(attr.name);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
dom.removeAttribute('style');
|
|
203
|
+
dom.removeAttribute('class');
|
|
204
|
+
if (props) {
|
|
205
|
+
Object.entries(props).forEach(function (_ref) {
|
|
206
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
207
|
+
key = _ref2[0],
|
|
208
|
+
value = _ref2[1];
|
|
209
|
+
if (key === 'style' && value) {
|
|
210
|
+
Object.entries(value).forEach(function (_ref3) {
|
|
211
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
212
|
+
styleKey = _ref4[0],
|
|
213
|
+
styleValue = _ref4[1];
|
|
214
|
+
if (styleValue !== undefined) {
|
|
215
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
216
|
+
dom.style[styleKey] = styleValue;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
} else if (key === 'className' && value) {
|
|
220
|
+
dom.className = value;
|
|
221
|
+
} else if (value !== undefined && value !== null) {
|
|
222
|
+
dom.setAttribute(key, value.toString());
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* 更新 DOM 元素的样式
|
|
230
|
+
*
|
|
231
|
+
* @param dom 要更新的 DOM 元素
|
|
232
|
+
* @param style 要设置的样式
|
|
233
|
+
*/
|
|
234
|
+
export function updateDomStyle(dom, style) {
|
|
235
|
+
if (!dom) return;
|
|
236
|
+
dom.removeAttribute('style');
|
|
237
|
+
if (style) {
|
|
238
|
+
Object.entries(style).forEach(function (_ref5) {
|
|
239
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
240
|
+
styleKey = _ref6[0],
|
|
241
|
+
styleValue = _ref6[1];
|
|
242
|
+
if (styleValue !== undefined) {
|
|
243
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
244
|
+
dom.style[styleKey] = styleValue;
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["$createTextNode","$getRoot","$getSelection","$isDecoratorNode","$isElementNode","$isParagraphNode","$isRangeSelection","$isTextNode","$createDivNode","$isDivNode","insertNodeAtCursor","editor","node","update","selection","lastNode","focus","getNode","append","insertAfter","insertNodes","selectNext","root","nodeToInsert","container","style","display","insertTextAtCursor","text","textNode","insertText","getLastChild","clearEditorContent","state","getEditorState","stateJson","toJSON","newJson","_objectSpread","children","direction","format","indent","type","version","textFormat","textStyle","emptyState","parseEditorState","JSON","stringify","setEditorState","clear","findNode","predicate","matched","findNodes","stopOnFirstMatch","options","read","traverse","result","push","getChildren","_iterator","_createForOfIteratorHelper","_step","s","n","done","child","value","length","err","e","f","updateDomProps","dom","props","Array","from","attributes","forEach","attr","name","startsWith","removeAttribute","Object","entries","_ref","_ref2","_slicedToArray","key","_ref3","_ref4","styleKey","styleValue","undefined","className","setAttribute","toString","updateDomStyle","_ref5","_ref6"],"sources":["../../../../src/components/Lexical/helpers/index.ts"],"sourcesContent":["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type { LexicalEditor, LexicalNode } from 'lexical';\nimport {\n $createTextNode,\n $getRoot,\n $getSelection,\n $isDecoratorNode,\n $isElementNode,\n $isParagraphNode,\n $isRangeSelection,\n $isTextNode,\n} from 'lexical';\nimport { $createDivNode, $isDivNode } from '../nodes/DivNode';\n\n/**\n * 将节点插入到当前光标位置\n *\n * @param editor LexicalEditor 实例\n * @param node 要插入的节点\n */\nexport function insertNodeAtCursor(editor: LexicalEditor, node: LexicalNode): void {\n editor.update(() => {\n const selection = $getSelection();\n if (selection) {\n if ($isRangeSelection(selection)) {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = selection.focus.getNode();\n if (lastNode) {\n if ($isParagraphNode(lastNode)) {\n lastNode.append(node);\n } else if ($isTextNode(lastNode)) {\n // 如果最后一个节点是文本节点,则在其后插入 SelectNode\n lastNode.insertAfter(node);\n } else if ($isDivNode(lastNode)) {\n lastNode.append(node);\n } else {\n selection.insertNodes([node]);\n }\n node.selectNext();\n }\n } else {\n selection.insertNodes([node]);\n node.selectNext();\n }\n } else {\n const root = $getRoot();\n let nodeToInsert: LexicalNode = node;\n if ($isElementNode(node) || $isDecoratorNode(node)) {\n nodeToInsert = node;\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(node);\n nodeToInsert = container;\n }\n root.append(nodeToInsert);\n node.selectNext();\n }\n });\n}\n\n/**\n * 将文本插入到当前光标位置\n *\n * @param editor LexicalEditor 实例\n * @param text 要插入的文本\n */\nexport function insertTextAtCursor(editor: LexicalEditor, text: string): void {\n editor?.update(() => {\n const textNode = $createTextNode(text);\n const root = $getRoot();\n const selection = $getSelection();\n if (selection) {\n // 插入光标位置\n selection.insertText(text);\n } else {\n // 如果没有选取,则直接在根节点末尾插入\n const lastNode = root.getLastChild();\n if (lastNode && $isParagraphNode(lastNode)) {\n lastNode.append(textNode);\n } else {\n const container = $createDivNode({\n style: { display: 'inline-block' },\n });\n container.append(textNode);\n root.append(container);\n }\n }\n });\n}\n\n/**\n * 清空编辑器内容\n *\n * @param editor LexicalEditor 实例\n */\nexport function clearEditorContent(editor: LexicalEditor) {\n const state = editor.getEditorState();\n const stateJson = state.toJSON();\n // 默认创建一个ParagraphNode\n const newJson = {\n ...stateJson,\n root: {\n ...stateJson.root,\n children: [\n {\n children: [],\n direction: null,\n format: '',\n indent: 0,\n type: 'paragraph',\n version: 1,\n textFormat: 0,\n textStyle: '',\n },\n ],\n },\n };\n const emptyState = editor.parseEditorState(JSON.stringify(newJson));\n editor.setEditorState(emptyState);\n editor.update(() => {\n const root = $getRoot();\n root.clear();\n });\n}\n\n/**\n * 查找符合条件的节点\n *\n * @param editor LexicalEditor 实例\n * @param predicate 用于匹配节点的函数\n * @param options 选项\n *\n * @returns 符合条件的节点数组\n */\nexport function findNode<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean\n): T | undefined {\n const matched = findNodes<T>(editor, predicate, { stopOnFirstMatch: true });\n return matched[0];\n}\n/**\n * 查找所有符合条件的节点数组\n *\n * @param editor LexicalEditor 实例\n * @param predicate 用于匹配节点的函数\n * @param options 选项\n *\n * @returns 符合条件的节点数组\n */\nexport function findNodes<T extends LexicalNode>(\n editor: LexicalEditor,\n predicate: (node: LexicalNode) => boolean,\n options?: {\n stopOnFirstMatch?: boolean;\n }\n): T[] {\n const matched: T[] = [];\n editor.getEditorState().read(() => {\n const root = $getRoot();\n const traverse = (node: LexicalNode, result: T[]) => {\n if (predicate(node)) {\n result.push(node as unknown as T);\n if (options?.stopOnFirstMatch) {\n return;\n }\n }\n if ($isElementNode(node)) {\n const children = node.getChildren();\n for (const child of children) {\n traverse(child, result);\n if (options?.stopOnFirstMatch && result.length > 0) {\n return;\n }\n }\n }\n };\n traverse(root, matched);\n });\n return matched;\n}\n\n/**\n * 更新 DOM 元素的属性\n *\n * @param dom 要更新的 DOM 元素\n * @param props 要设置的属性\n */\nexport function updateDomProps(dom: HTMLElement | undefined, props: HtmlHTMLAttributes<HTMLElement>): void {\n if (!dom) return;\n Array.from(dom.attributes).forEach((attr) => {\n if (!attr.name.startsWith('data-lexical')) {\n dom.removeAttribute(attr.name);\n }\n });\n\n dom.removeAttribute('style');\n dom.removeAttribute('class');\n\n if (props) {\n Object.entries(props).forEach(([key, value]) => {\n if (key === 'style' && value) {\n Object.entries(value as CSSProperties).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n } else if (key === 'className' && value) {\n dom.className = value as string;\n } else if (value !== undefined && value !== null) {\n dom.setAttribute(key, value.toString());\n }\n });\n }\n}\n\n/**\n * 更新 DOM 元素的样式\n *\n * @param dom 要更新的 DOM 元素\n * @param style 要设置的样式\n */\nexport function updateDomStyle(dom: HTMLElement | undefined, style: CSSProperties | undefined): void {\n if (!dom) return;\n dom.removeAttribute('style');\n if (style) {\n Object.entries(style).forEach(([styleKey, styleValue]) => {\n if (styleValue !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (dom.style as any)[styleKey] = styleValue;\n }\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAEA,SACEA,eAAe,EACfC,QAAQ,EACRC,aAAa,EACbC,gBAAgB,EAChBC,cAAc,EACdC,gBAAgB,EAChBC,iBAAiB,EACjBC,WAAW,QACN,SAAS;AAChB,SAASC,cAAc,EAAEC,UAAU;;AAEnC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,kBAAkBA,CAACC,MAAqB,EAAEC,IAAiB,EAAQ;EACjFD,MAAM,CAACE,MAAM,CAAC,YAAM;IAClB,IAAMC,SAAS,GAAGZ,aAAa,CAAC,CAAC;IACjC,IAAIY,SAAS,EAAE;MACb,IAAIR,iBAAiB,CAACQ,SAAS,CAAC,EAAE;QAChC;QACA,IAAMC,QAAQ,GAAGD,SAAS,CAACE,KAAK,CAACC,OAAO,CAAC,CAAC;QAC1C,IAAIF,QAAQ,EAAE;UACZ,IAAIV,gBAAgB,CAACU,QAAQ,CAAC,EAAE;YAC9BA,QAAQ,CAACG,MAAM,CAACN,IAAI,CAAC;UACvB,CAAC,MAAM,IAAIL,WAAW,CAACQ,QAAQ,CAAC,EAAE;YAChC;YACAA,QAAQ,CAACI,WAAW,CAACP,IAAI,CAAC;UAC5B,CAAC,MAAM,IAAI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Q,CAAC,GAAGC,UAAU;UAC3C;QACF,CAAC,CAAC;MACJ,CAAC,MAAM,IAAIJ,GAAG,KAAK,WAAW,IAAIrB,KAAK,EAAE;QACvCM,GAAG,CAACqB,SAAS,GAAG3B,KAAe;MACjC,CAAC,MAAM,IAAIA,KAAK,KAAK0B,SAAS,IAAI1B,KAAK,KAAK,IAAI,EAAE;QAChDM,GAAG,CAACsB,YAAY,CAACP,GAAG,EAAErB,KAAK,CAAC6B,QAAQ,CAAC,CAAC,CAAC;MACzC;IACF,CAAC,CAAC;EACJ;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,cAAcA,CAACxB,GAA4B,EAAEpD,KAAgC,EAAQ;EACnG,IAAI,CAACoD,GAAG,EAAE;EACVA,GAAG,CAACS,eAAe,CAAC,OAAO,CAAC;EAC5B,IAAI7D,KAAK,EAAE;IACT8D,MAAM,CAACC,OAAO,CAAC/D,KAAK,CAAC,CAACyD,OAAO,CAAC,UAAAoB,KAAA,EAA4B;MAAA,IAAAC,KAAA,GAAAZ,cAAA,CAAAW,KAAA;QAA1BP,QAAQ,GAAAQ,KAAA;QAAEP,UAAU,GAAAO,KAAA;MAClD,IAAIP,UAAU,KAAKC,SAAS,EAAE;QAC5B;QACCpB,GAAG,CAACpD,KAAK,CAASsE,QAAQ,CAAC,GAAGC,UAAU;MAC3C;IACF,CAAC,CAAC;EACJ;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/components/Lexical/index.ts"],"sourcesContent":["export * from './helpers';\nexport * from './nodes/base';\nexport * from './nodes/DivNode';\nexport * from './nodes/SelectNode';\nexport * from './nodes/ExtendTextNode';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { CSSProperties, HtmlHTMLAttributes } from 'react';
|
|
2
|
+
import type { DOMConversionMap, DOMExportOutput, LexicalNode, SerializedElementNode, Spread } from 'lexical';
|
|
3
|
+
import { BaseElementNode, type BaseElementProps } from './base';
|
|
4
|
+
export interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {
|
|
5
|
+
}
|
|
6
|
+
export type SerializedDivNode = Spread<{
|
|
7
|
+
props?: DivNodeProps;
|
|
8
|
+
}, SerializedElementNode>;
|
|
9
|
+
export declare class DivNode extends BaseElementNode<DivNodeProps> {
|
|
10
|
+
static getType(): string;
|
|
11
|
+
static clone(node: DivNode): DivNode;
|
|
12
|
+
protected getForceDisplay(): CSSProperties['display'];
|
|
13
|
+
createDOM(): HTMLElement;
|
|
14
|
+
updateDOM(prevNode: DivNode, dom: HTMLElement): boolean;
|
|
15
|
+
static importDOM(): DOMConversionMap | null;
|
|
16
|
+
static importJSON(serializedNode: SerializedDivNode): DivNode;
|
|
17
|
+
exportJSON(): SerializedDivNode;
|
|
18
|
+
exportDOM(): DOMExportOutput;
|
|
19
|
+
isInline(): boolean;
|
|
20
|
+
getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined;
|
|
21
|
+
setProps(props: DivNodeProps): void;
|
|
22
|
+
private shallowEqual;
|
|
23
|
+
}
|
|
24
|
+
export declare function $createDivNode(props?: DivNodeProps): DivNode;
|
|
25
|
+
export declare function $isDivNode(node: LexicalNode | null | undefined): node is DivNode;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
10
|
+
function _get() { if (typeof Reflect !== "undefined" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }
|
|
11
|
+
function _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }
|
|
12
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
13
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
14
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
15
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
16
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
17
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
18
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
19
|
+
import { updateDomProps } from "../helpers";
|
|
20
|
+
import { BaseElementNode } from "./base";
|
|
21
|
+
export var DivNode = /*#__PURE__*/function (_BaseElementNode) {
|
|
22
|
+
_inherits(DivNode, _BaseElementNode);
|
|
23
|
+
var _super = _createSuper(DivNode);
|
|
24
|
+
function DivNode() {
|
|
25
|
+
_classCallCheck(this, DivNode);
|
|
26
|
+
return _super.apply(this, arguments);
|
|
27
|
+
}
|
|
28
|
+
_createClass(DivNode, [{
|
|
29
|
+
key: "getForceDisplay",
|
|
30
|
+
value: function getForceDisplay() {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}, {
|
|
34
|
+
key: "createDOM",
|
|
35
|
+
value: function createDOM() {
|
|
36
|
+
var div = document.createElement('div');
|
|
37
|
+
var domProps = this.getUnderlyingProps(this.__props);
|
|
38
|
+
if (domProps) {
|
|
39
|
+
updateDomProps(div, domProps);
|
|
40
|
+
}
|
|
41
|
+
return div;
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "updateDOM",
|
|
45
|
+
value: function updateDOM(prevNode, dom) {
|
|
46
|
+
var prevProps = prevNode.__props;
|
|
47
|
+
var currentProps = this.__props;
|
|
48
|
+
var propsChanged = !this.shallowEqual(prevProps, currentProps);
|
|
49
|
+
if (propsChanged) {
|
|
50
|
+
updateDomProps(dom, this.getUnderlyingProps(currentProps));
|
|
51
|
+
}
|
|
52
|
+
// 不重新创建
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}, {
|
|
56
|
+
key: "exportJSON",
|
|
57
|
+
value: function exportJSON() {
|
|
58
|
+
return _objectSpread(_objectSpread({}, _get(_getPrototypeOf(DivNode.prototype), "exportJSON", this).call(this)), {}, {
|
|
59
|
+
props: this.__props,
|
|
60
|
+
type: this.getType()
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}, {
|
|
64
|
+
key: "exportDOM",
|
|
65
|
+
value: function exportDOM() {
|
|
66
|
+
var element = this.createDOM();
|
|
67
|
+
return {
|
|
68
|
+
element: element
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "isInline",
|
|
73
|
+
value: function isInline() {
|
|
74
|
+
var _this$__props;
|
|
75
|
+
var display = (_this$__props = this.__props) === null || _this$__props === void 0 || (_this$__props = _this$__props.style) === null || _this$__props === void 0 ? void 0 : _this$__props.display;
|
|
76
|
+
return display === 'inline' || display === 'inline-flex' || display === 'inline-block' || display === 'inline-grid' || display === 'inline-table' || display === 'inline-list-item';
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
key: "getPropValue",
|
|
80
|
+
value: function getPropValue(key) {
|
|
81
|
+
var _this$__props2;
|
|
82
|
+
return (_this$__props2 = this.__props) === null || _this$__props2 === void 0 ? void 0 : _this$__props2[key];
|
|
83
|
+
}
|
|
84
|
+
}, {
|
|
85
|
+
key: "setProps",
|
|
86
|
+
value: function setProps(props) {
|
|
87
|
+
var _writable$__props;
|
|
88
|
+
var writable = this.getWritable();
|
|
89
|
+
writable.__props = _objectSpread(_objectSpread(_objectSpread({}, writable.__props), props), {}, {
|
|
90
|
+
style: _objectSpread(_objectSpread({}, (_writable$__props = writable.__props) === null || _writable$__props === void 0 ? void 0 : _writable$__props.style), props.style)
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
|
+
}, {
|
|
96
|
+
key: "shallowEqual",
|
|
97
|
+
value: function shallowEqual(obj1, obj2) {
|
|
98
|
+
if (obj1 === obj2) return true;
|
|
99
|
+
if (!obj1 || !obj2) return false;
|
|
100
|
+
var keys1 = Object.keys(obj1);
|
|
101
|
+
var keys2 = Object.keys(obj2);
|
|
102
|
+
if (keys1.length !== keys2.length) return false;
|
|
103
|
+
for (var _i = 0, _keys = keys1; _i < _keys.length; _i++) {
|
|
104
|
+
var key = _keys[_i];
|
|
105
|
+
if (key === 'style') {
|
|
106
|
+
// 特殊处理 style 对象
|
|
107
|
+
if (!this.shallowEqual(obj1[key], obj2[key])) return false;
|
|
108
|
+
} else if (obj1[key] !== obj2[key]) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
}], [{
|
|
115
|
+
key: "getType",
|
|
116
|
+
value: function getType() {
|
|
117
|
+
return 'html.div';
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "clone",
|
|
121
|
+
value: function clone(node) {
|
|
122
|
+
return new DivNode(_objectSpread(_objectSpread({}, node.__props), {}, {
|
|
123
|
+
key: node.getKey()
|
|
124
|
+
}));
|
|
125
|
+
}
|
|
126
|
+
}, {
|
|
127
|
+
key: "importDOM",
|
|
128
|
+
value: function importDOM() {
|
|
129
|
+
return {
|
|
130
|
+
div: function div(node) {
|
|
131
|
+
return {
|
|
132
|
+
conversion: convertDivElement,
|
|
133
|
+
priority: 1
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "importJSON",
|
|
140
|
+
value: function importJSON(serializedNode) {
|
|
141
|
+
return $createDivNode(serializedNode.props);
|
|
142
|
+
}
|
|
143
|
+
}]);
|
|
144
|
+
return DivNode;
|
|
145
|
+
}(BaseElementNode);
|
|
146
|
+
function convertDivElement(domNode) {
|
|
147
|
+
var element = domNode;
|
|
148
|
+
if (element.nodeName === 'DIV') {
|
|
149
|
+
return {
|
|
150
|
+
node: $createDivNode()
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
node: null
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
export function $createDivNode(props) {
|
|
158
|
+
return new DivNode(props);
|
|
159
|
+
}
|
|
160
|
+
export function $isDivNode(node) {
|
|
161
|
+
return node instanceof DivNode;
|
|
162
|
+
}
|
|
163
|
+
//# sourceMappingURL=DivNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["updateDomProps","BaseElementNode","DivNode","_BaseElementNode","_inherits","_super","_createSuper","_classCallCheck","apply","arguments","_createClass","key","value","getForceDisplay","undefined","createDOM","div","document","createElement","domProps","getUnderlyingProps","__props","updateDOM","prevNode","dom","prevProps","currentProps","propsChanged","shallowEqual","exportJSON","_objectSpread","_get","_getPrototypeOf","prototype","call","props","type","getType","exportDOM","element","isInline","_this$__props","display","style","getPropValue","_this$__props2","setProps","_writable$__props","writable","getWritable","obj1","obj2","keys1","Object","keys","keys2","length","_i","_keys","clone","node","getKey","importDOM","conversion","convertDivElement","priority","importJSON","serializedNode","$createDivNode","domNode","nodeName","$isDivNode"],"sources":["../../../../src/components/Lexical/nodes/DivNode.tsx"],"sourcesContent":["import type { CSSProperties, HtmlHTMLAttributes } from 'react';\nimport type {\n DOMConversionMap,\n DOMConversionOutput,\n DOMExportOutput,\n LexicalNode,\n SerializedElementNode,\n Spread,\n} from 'lexical';\nimport { updateDomProps } from '../helpers';\nimport { BaseElementNode, type BaseElementProps } from './base';\n\nexport interface DivNodeProps extends HtmlHTMLAttributes<HTMLDivElement>, BaseElementProps {}\n\nexport type SerializedDivNode = Spread<\n {\n props?: DivNodeProps;\n },\n SerializedElementNode\n>;\n\nexport class DivNode extends BaseElementNode<DivNodeProps> {\n static getType(): string {\n return 'html.div';\n }\n\n static clone(node: DivNode): DivNode {\n return new DivNode({ ...node.__props, key: node.getKey() });\n }\n\n protected getForceDisplay(): CSSProperties['display'] {\n return undefined;\n }\n\n createDOM(): HTMLElement {\n const div = document.createElement('div');\n const domProps = this.getUnderlyingProps(this.__props);\n if (domProps) {\n updateDomProps(div, domProps);\n }\n return div;\n }\n\n updateDOM(prevNode: DivNode, dom: HTMLElement): boolean {\n const prevProps = prevNode.__props;\n const currentProps = this.__props;\n const propsChanged = !this.shallowEqual(prevProps, currentProps);\n if (propsChanged) {\n updateDomProps(dom, this.getUnderlyingProps(currentProps));\n }\n // 不重新创建\n return false;\n }\n\n static importDOM(): DOMConversionMap | null {\n return {\n div: (node: Node) => ({\n conversion: convertDivElement,\n priority: 1,\n }),\n };\n }\n\n static importJSON(serializedNode: SerializedDivNode): DivNode {\n return $createDivNode(serializedNode.props);\n }\n\n exportJSON(): SerializedDivNode {\n return {\n ...super.exportJSON(),\n props: this.__props,\n type: this.getType(),\n };\n }\n\n exportDOM(): DOMExportOutput {\n const element = this.createDOM();\n return { element };\n }\n\n isInline(): boolean {\n const display = this.__props?.style?.display;\n return (\n display === 'inline' ||\n display === 'inline-flex' ||\n display === 'inline-block' ||\n display === 'inline-grid' ||\n display === 'inline-table' ||\n display === 'inline-list-item'\n );\n }\n\n getPropValue<K extends keyof DivNodeProps>(key: K): DivNodeProps[K] | undefined {\n return this.__props?.[key];\n }\n setProps(props: DivNodeProps): void {\n const writable = this.getWritable();\n writable.__props = {\n ...writable.__props,\n ...props,\n style: {\n ...writable.__props?.style,\n ...props.style,\n },\n };\n }\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private shallowEqual(obj1: any, obj2: any): boolean {\n if (obj1 === obj2) return true;\n if (!obj1 || !obj2) return false;\n\n const keys1 = Object.keys(obj1);\n const keys2 = Object.keys(obj2);\n\n if (keys1.length !== keys2.length) return false;\n\n for (const key of keys1) {\n if (key === 'style') {\n // 特殊处理 style 对象\n if (!this.shallowEqual(obj1[key], obj2[key])) return false;\n } else if (obj1[key] !== obj2[key]) {\n return false;\n }\n }\n\n return true;\n }\n}\n\nfunction convertDivElement(domNode: Node): DOMConversionOutput {\n const element = domNode as HTMLElement;\n if (element.nodeName === 'DIV') {\n return { node: $createDivNode() };\n }\n return { node: null };\n}\n\nexport function $createDivNode(props?: DivNodeProps): DivNode {\n return new DivNode(props);\n}\n\nexport function $isDivNode(node: LexicalNode | null | undefined): node is DivNode {\n return node instanceof DivNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AASA,SAASA,cAAc;AACvB,SAASC,eAAe;AAWxB,WAAaC,OAAO,0BAAAC,gBAAA;EAAAC,SAAA,CAAAF,OAAA,EAAAC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AA,OAAM;YACpBG,UAAU,EAAEC,iBAAiB;YAC7BC,QAAQ,EAAE;UACZ,CAAC;QAAA;MACH,CAAC;IACH;EAAC;IAAAtD,GAAA;IAAAC,KAAA,EAED,SAAAsD,WAAkBC,cAAiC,EAAW;MAC5D,OAAOC,cAAc,CAACD,cAAc,CAAChC,KAAK,CAAC;IAC7C;EAAC;EAAA,OAAAjC,OAAA;AAAA,EA5C0BD,eAAe;AA6G5C,SAAS+D,iBAAiBA,CAACK,OAAa,EAAuB;EAC7D,IAAM9B,OAAO,GAAG8B,OAAsB;EACtC,IAAI9B,OAAO,CAAC+B,QAAQ,KAAK,KAAK,EAAE;IAC9B,OAAO;MAAEV,IAAI,EAAEQ,cAAc,CAAC;IAAE,CAAC;EACnC;EACA,OAAO;IAAER,IAAI,EAAE;EAAK,CAAC;AACvB;AAEA,OAAO,SAASQ,cAAcA,CAACjC,KAAoB,EAAW;EAC5D,OAAO,IAAIjC,OAAO,CAACiC,KAAK,CAAC;AAC3B;AAEA,OAAO,SAASoC,UAAUA,CAACX,IAAoC,EAAmB;EAChF,OAAOA,IAAI,YAAY1D,OAAO;AAChC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { LexicalNode, NodeKey, SerializedTextNode, Spread } from 'lexical';
|
|
2
|
+
import { TextNode } from 'lexical';
|
|
3
|
+
import type { BaseNodeProps } from './base';
|
|
4
|
+
import { BaseNodeHelper } from './base';
|
|
5
|
+
export interface ExtendTextNodeProps extends BaseNodeProps {
|
|
6
|
+
text?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare class ExtendTextNode extends TextNode {
|
|
9
|
+
__props: ExtendTextNodeProps | undefined;
|
|
10
|
+
__base: BaseNodeHelper<ExtendTextNodeProps>;
|
|
11
|
+
constructor(props?: ExtendTextNodeProps & {
|
|
12
|
+
key?: NodeKey;
|
|
13
|
+
});
|
|
14
|
+
static getType(): string;
|
|
15
|
+
static clone(node: ExtendTextNode): ExtendTextNode;
|
|
16
|
+
static importJSON(serializedNode: SerializedExtendTextNode): ExtendTextNode;
|
|
17
|
+
exportJSON(): SerializedExtendTextNode;
|
|
18
|
+
}
|
|
19
|
+
export type SerializedExtendTextNode = Spread<{
|
|
20
|
+
props?: ExtendTextNodeProps;
|
|
21
|
+
text: string;
|
|
22
|
+
}, SerializedTextNode>;
|
|
23
|
+
export declare function $createExtendTextNode(props?: ExtendTextNodeProps): ExtendTextNode;
|
|
24
|
+
export declare function $isExtendTextNode(node: LexicalNode | null | undefined): node is ExtendTextNode;
|