@webiny/lexical-nodes 5.43.2 → 6.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FontColorNode.js +97 -145
- package/FontColorNode.js.map +1 -1
- package/HeadingNode.js +94 -146
- package/HeadingNode.js.map +1 -1
- package/ImageNode.js +142 -189
- package/ImageNode.js.map +1 -1
- package/LinkNode.js +253 -346
- package/LinkNode.js.map +1 -1
- package/ListItemNode.js +276 -354
- package/ListItemNode.js.map +1 -1
- package/ListNode.js +150 -204
- package/ListNode.js.map +1 -1
- package/ParagraphNode.js +114 -165
- package/ParagraphNode.js.map +1 -1
- package/QuoteNode.js +118 -172
- package/QuoteNode.js.map +1 -1
- package/TypographyNode.js +93 -130
- package/TypographyNode.js.map +1 -1
- package/components/ImageNode/ContentEditable.js +7 -14
- package/components/ImageNode/ContentEditable.js.map +1 -1
- package/components/ImageNode/ImageComponent.js +104 -124
- package/components/ImageNode/ImageComponent.js.map +1 -1
- package/components/ImageNode/ImageResizer.js +78 -83
- package/components/ImageNode/ImageResizer.js.map +1 -1
- package/components/ImageNode/Placeholder.js +10 -16
- package/components/ImageNode/Placeholder.js.map +1 -1
- package/components/ImageNode/SharedHistoryContext.js +12 -20
- package/components/ImageNode/SharedHistoryContext.js.map +1 -1
- package/index.js +48 -223
- package/index.js.map +1 -1
- package/package.json +4 -4
- package/types.js +1 -5
- package/utils/clearNodeFormating.js +12 -18
- package/utils/clearNodeFormating.js.map +1 -1
- package/utils/formatList.js +171 -208
- package/utils/formatList.js.map +1 -1
- package/utils/formatToHeading.js +8 -15
- package/utils/formatToHeading.js.map +1 -1
- package/utils/formatToParagraph.js +8 -16
- package/utils/formatToParagraph.js.map +1 -1
- package/utils/formatToQuote.js +8 -15
- package/utils/formatToQuote.js.map +1 -1
- package/utils/listNode.js +37 -50
- package/utils/listNode.js.map +1 -1
- package/utils/toggleLink.js +41 -45
- package/utils/toggleLink.js.map +1 -1
package/index.js
CHANGED
|
@@ -1,237 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
import { ParagraphNode as BaseParagraphNode } from "lexical";
|
|
2
|
+
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
3
|
+
import { HashtagNode } from "@lexical/hashtag";
|
|
4
|
+
import { MarkNode } from "@lexical/mark";
|
|
5
|
+
import { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from "@lexical/rich-text";
|
|
6
|
+
import { OverflowNode } from "@lexical/overflow";
|
|
7
|
+
import { AutoLinkNode, LinkNode } from "./LinkNode";
|
|
8
|
+
import { FontColorNode } from "./FontColorNode";
|
|
9
|
+
import { TypographyNode } from "./TypographyNode";
|
|
10
|
+
import { ListNode } from "./ListNode";
|
|
11
|
+
import { ListItemNode } from "./ListItemNode";
|
|
12
|
+
import { HeadingNode } from "./HeadingNode";
|
|
13
|
+
import { ParagraphNode } from "./ParagraphNode";
|
|
14
|
+
import { QuoteNode } from "./QuoteNode";
|
|
15
|
+
import { ImageNode } from "./ImageNode";
|
|
16
|
+
export * from "./FontColorNode";
|
|
17
|
+
export * from "./TypographyNode";
|
|
18
|
+
export * from "./ListNode";
|
|
19
|
+
export * from "./ListItemNode";
|
|
20
|
+
export * from "./HeadingNode";
|
|
21
|
+
export * from "./ParagraphNode";
|
|
22
|
+
export * from "./QuoteNode";
|
|
23
|
+
export * from "./ImageNode";
|
|
24
|
+
export * from "./LinkNode";
|
|
25
|
+
export * from "./utils/formatList";
|
|
26
|
+
export * from "./utils/listNode";
|
|
27
|
+
export * from "./utils/formatToQuote";
|
|
28
|
+
export * from "./utils/formatToHeading";
|
|
29
|
+
export * from "./utils/formatToParagraph";
|
|
30
|
+
export * from "./utils/clearNodeFormating";
|
|
31
|
+
export * from "./utils/toggleLink";
|
|
2
32
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
allNodes: true
|
|
8
|
-
};
|
|
9
|
-
exports.allNodes = void 0;
|
|
10
|
-
var _lexical = require("lexical");
|
|
11
|
-
var _code = require("@lexical/code");
|
|
12
|
-
var _hashtag = require("@lexical/hashtag");
|
|
13
|
-
var _mark = require("@lexical/mark");
|
|
14
|
-
var _richText = require("@lexical/rich-text");
|
|
15
|
-
var _overflow = require("@lexical/overflow");
|
|
16
|
-
var _LinkNode = require("./LinkNode");
|
|
17
|
-
Object.keys(_LinkNode).forEach(function (key) {
|
|
18
|
-
if (key === "default" || key === "__esModule") return;
|
|
19
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
20
|
-
if (key in exports && exports[key] === _LinkNode[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function get() {
|
|
24
|
-
return _LinkNode[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
var _FontColorNode = require("./FontColorNode");
|
|
29
|
-
Object.keys(_FontColorNode).forEach(function (key) {
|
|
30
|
-
if (key === "default" || key === "__esModule") return;
|
|
31
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
-
if (key in exports && exports[key] === _FontColorNode[key]) return;
|
|
33
|
-
Object.defineProperty(exports, key, {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
get: function get() {
|
|
36
|
-
return _FontColorNode[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
var _TypographyNode = require("./TypographyNode");
|
|
41
|
-
Object.keys(_TypographyNode).forEach(function (key) {
|
|
42
|
-
if (key === "default" || key === "__esModule") return;
|
|
43
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
44
|
-
if (key in exports && exports[key] === _TypographyNode[key]) return;
|
|
45
|
-
Object.defineProperty(exports, key, {
|
|
46
|
-
enumerable: true,
|
|
47
|
-
get: function get() {
|
|
48
|
-
return _TypographyNode[key];
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
var _ListNode = require("./ListNode");
|
|
53
|
-
Object.keys(_ListNode).forEach(function (key) {
|
|
54
|
-
if (key === "default" || key === "__esModule") return;
|
|
55
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
56
|
-
if (key in exports && exports[key] === _ListNode[key]) return;
|
|
57
|
-
Object.defineProperty(exports, key, {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function get() {
|
|
60
|
-
return _ListNode[key];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
var _ListItemNode = require("./ListItemNode");
|
|
65
|
-
Object.keys(_ListItemNode).forEach(function (key) {
|
|
66
|
-
if (key === "default" || key === "__esModule") return;
|
|
67
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
68
|
-
if (key in exports && exports[key] === _ListItemNode[key]) return;
|
|
69
|
-
Object.defineProperty(exports, key, {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function get() {
|
|
72
|
-
return _ListItemNode[key];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
var _HeadingNode = require("./HeadingNode");
|
|
77
|
-
Object.keys(_HeadingNode).forEach(function (key) {
|
|
78
|
-
if (key === "default" || key === "__esModule") return;
|
|
79
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
-
if (key in exports && exports[key] === _HeadingNode[key]) return;
|
|
81
|
-
Object.defineProperty(exports, key, {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function get() {
|
|
84
|
-
return _HeadingNode[key];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
var _ParagraphNode = require("./ParagraphNode");
|
|
89
|
-
Object.keys(_ParagraphNode).forEach(function (key) {
|
|
90
|
-
if (key === "default" || key === "__esModule") return;
|
|
91
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
92
|
-
if (key in exports && exports[key] === _ParagraphNode[key]) return;
|
|
93
|
-
Object.defineProperty(exports, key, {
|
|
94
|
-
enumerable: true,
|
|
95
|
-
get: function get() {
|
|
96
|
-
return _ParagraphNode[key];
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
var _QuoteNode = require("./QuoteNode");
|
|
101
|
-
Object.keys(_QuoteNode).forEach(function (key) {
|
|
102
|
-
if (key === "default" || key === "__esModule") return;
|
|
103
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
104
|
-
if (key in exports && exports[key] === _QuoteNode[key]) return;
|
|
105
|
-
Object.defineProperty(exports, key, {
|
|
106
|
-
enumerable: true,
|
|
107
|
-
get: function get() {
|
|
108
|
-
return _QuoteNode[key];
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
var _ImageNode = require("./ImageNode");
|
|
113
|
-
Object.keys(_ImageNode).forEach(function (key) {
|
|
114
|
-
if (key === "default" || key === "__esModule") return;
|
|
115
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
116
|
-
if (key in exports && exports[key] === _ImageNode[key]) return;
|
|
117
|
-
Object.defineProperty(exports, key, {
|
|
118
|
-
enumerable: true,
|
|
119
|
-
get: function get() {
|
|
120
|
-
return _ImageNode[key];
|
|
121
|
-
}
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
var _formatList = require("./utils/formatList");
|
|
125
|
-
Object.keys(_formatList).forEach(function (key) {
|
|
126
|
-
if (key === "default" || key === "__esModule") return;
|
|
127
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
128
|
-
if (key in exports && exports[key] === _formatList[key]) return;
|
|
129
|
-
Object.defineProperty(exports, key, {
|
|
130
|
-
enumerable: true,
|
|
131
|
-
get: function get() {
|
|
132
|
-
return _formatList[key];
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
var _listNode = require("./utils/listNode");
|
|
137
|
-
Object.keys(_listNode).forEach(function (key) {
|
|
138
|
-
if (key === "default" || key === "__esModule") return;
|
|
139
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
140
|
-
if (key in exports && exports[key] === _listNode[key]) return;
|
|
141
|
-
Object.defineProperty(exports, key, {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
get: function get() {
|
|
144
|
-
return _listNode[key];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
var _formatToQuote = require("./utils/formatToQuote");
|
|
149
|
-
Object.keys(_formatToQuote).forEach(function (key) {
|
|
150
|
-
if (key === "default" || key === "__esModule") return;
|
|
151
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
152
|
-
if (key in exports && exports[key] === _formatToQuote[key]) return;
|
|
153
|
-
Object.defineProperty(exports, key, {
|
|
154
|
-
enumerable: true,
|
|
155
|
-
get: function get() {
|
|
156
|
-
return _formatToQuote[key];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
var _formatToHeading = require("./utils/formatToHeading");
|
|
161
|
-
Object.keys(_formatToHeading).forEach(function (key) {
|
|
162
|
-
if (key === "default" || key === "__esModule") return;
|
|
163
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
164
|
-
if (key in exports && exports[key] === _formatToHeading[key]) return;
|
|
165
|
-
Object.defineProperty(exports, key, {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
get: function get() {
|
|
168
|
-
return _formatToHeading[key];
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
});
|
|
172
|
-
var _formatToParagraph = require("./utils/formatToParagraph");
|
|
173
|
-
Object.keys(_formatToParagraph).forEach(function (key) {
|
|
174
|
-
if (key === "default" || key === "__esModule") return;
|
|
175
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
176
|
-
if (key in exports && exports[key] === _formatToParagraph[key]) return;
|
|
177
|
-
Object.defineProperty(exports, key, {
|
|
178
|
-
enumerable: true,
|
|
179
|
-
get: function get() {
|
|
180
|
-
return _formatToParagraph[key];
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
var _clearNodeFormating = require("./utils/clearNodeFormating");
|
|
185
|
-
Object.keys(_clearNodeFormating).forEach(function (key) {
|
|
186
|
-
if (key === "default" || key === "__esModule") return;
|
|
187
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
188
|
-
if (key in exports && exports[key] === _clearNodeFormating[key]) return;
|
|
189
|
-
Object.defineProperty(exports, key, {
|
|
190
|
-
enumerable: true,
|
|
191
|
-
get: function get() {
|
|
192
|
-
return _clearNodeFormating[key];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
var _toggleLink = require("./utils/toggleLink");
|
|
197
|
-
Object.keys(_toggleLink).forEach(function (key) {
|
|
198
|
-
if (key === "default" || key === "__esModule") return;
|
|
199
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
200
|
-
if (key in exports && exports[key] === _toggleLink[key]) return;
|
|
201
|
-
Object.defineProperty(exports, key, {
|
|
202
|
-
enumerable: true,
|
|
203
|
-
get: function get() {
|
|
204
|
-
return _toggleLink[key];
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
33
|
// This is a list of all the nodes that our Lexical implementation supports OOTB.
|
|
209
|
-
|
|
34
|
+
export const allNodes = [
|
|
210
35
|
// These nodes are copy-pasted from Lexical and modified to fit our needs.
|
|
211
36
|
// https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes
|
|
212
37
|
// https://github.com/facebook/lexical/tree/main/packages
|
|
213
|
-
|
|
38
|
+
ImageNode, ListNode, ListItemNode,
|
|
214
39
|
// These nodes are directly imported from Lexical.
|
|
215
|
-
|
|
40
|
+
CodeNode, HashtagNode, CodeHighlightNode, AutoLinkNode, OverflowNode, MarkNode,
|
|
216
41
|
// Our custom nodes.
|
|
217
|
-
|
|
42
|
+
FontColorNode, TypographyNode,
|
|
218
43
|
// The following code replaces the built-in Lexical nodes with our custom ones.
|
|
219
44
|
// https://lexical.dev/docs/concepts/node-replacement
|
|
220
|
-
|
|
221
|
-
replace:
|
|
222
|
-
with:
|
|
223
|
-
return new
|
|
45
|
+
ParagraphNode, {
|
|
46
|
+
replace: BaseParagraphNode,
|
|
47
|
+
with: () => {
|
|
48
|
+
return new ParagraphNode();
|
|
224
49
|
}
|
|
225
|
-
},
|
|
226
|
-
replace:
|
|
227
|
-
with:
|
|
228
|
-
return new
|
|
50
|
+
}, HeadingNode, {
|
|
51
|
+
replace: BaseHeadingNode,
|
|
52
|
+
with: node => {
|
|
53
|
+
return new HeadingNode(node.getTag());
|
|
229
54
|
}
|
|
230
|
-
},
|
|
231
|
-
replace:
|
|
232
|
-
with:
|
|
233
|
-
return new
|
|
55
|
+
}, QuoteNode, {
|
|
56
|
+
replace: BaseQuoteNode,
|
|
57
|
+
with: () => {
|
|
58
|
+
return new QuoteNode();
|
|
234
59
|
}
|
|
235
|
-
},
|
|
60
|
+
}, LinkNode];
|
|
236
61
|
|
|
237
62
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_lexical","require","_code","_hashtag","_mark","_richText","_overflow","_LinkNode","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_FontColorNode","_TypographyNode","_ListNode","_ListItemNode","_HeadingNode","_ParagraphNode","_QuoteNode","_ImageNode","_formatList","_listNode","_formatToQuote","_formatToHeading","_formatToParagraph","_clearNodeFormating","_toggleLink","allNodes","ImageNode","ListNode","ListItemNode","CodeNode","HashtagNode","CodeHighlightNode","AutoLinkNode","OverflowNode","MarkNode","FontColorNode","TypographyNode","ParagraphNode","replace","BaseParagraphNode","with","HeadingNode","BaseHeadingNode","node","getTag","QuoteNode","BaseQuoteNode","LinkNode"],"sources":["index.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode\";\nimport { FontColorNode } from \"./FontColorNode\";\nimport { TypographyNode } from \"./TypographyNode\";\nimport { ListNode } from \"./ListNode\";\nimport { ListItemNode } from \"./ListItemNode\";\nimport { HeadingNode } from \"./HeadingNode\";\nimport { ParagraphNode } from \"./ParagraphNode\";\nimport { QuoteNode } from \"./QuoteNode\";\nimport { ImageNode } from \"./ImageNode\";\n\nexport * from \"./FontColorNode\";\nexport * from \"./TypographyNode\";\nexport * from \"./ListNode\";\nexport * from \"./ListItemNode\";\nexport * from \"./HeadingNode\";\nexport * from \"./ParagraphNode\";\nexport * from \"./QuoteNode\";\nexport * from \"./ImageNode\";\nexport * from \"./LinkNode\";\n\nexport * from \"./utils/formatList\";\nexport * from \"./utils/listNode\";\nexport * from \"./utils/formatToQuote\";\nexport * from \"./utils/formatToHeading\";\nexport * from \"./utils/formatToParagraph\";\nexport * from \"./utils/clearNodeFormating\";\nexport * from \"./utils/toggleLink\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<\n | Klass<LexicalNode>\n | {\n replace: Klass<LexicalNode>;\n with: <T extends { new (...args: any): any }>(node: InstanceType<T>) => LexicalNode;\n }\n> = [\n // These nodes are copy-pasted from Lexical and modified to fit our needs.\n // https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes\n // https://github.com/facebook/lexical/tree/main/packages\n ImageNode,\n ListNode,\n ListItemNode,\n\n // These nodes are directly imported from Lexical.\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n\n // Our custom nodes.\n FontColorNode,\n TypographyNode,\n\n // The following code replaces the built-in Lexical nodes with our custom ones.\n // https://lexical.dev/docs/concepts/node-replacement\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n }\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\n },\n LinkNode\n];\n"],"mappings":";;;;;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,SAAA,GAAAL,OAAA;AAEA,IAAAM,SAAA,GAAAN,OAAA;AAkBAO,MAAA,CAAAC,IAAA,CAAAF,SAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,SAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,IAAA;MAAA,OAAAZ,SAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAjBA,IAAAS,cAAA,GAAAnB,OAAA;AASAO,MAAA,CAAAC,IAAA,CAAAW,cAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA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
1
|
+
{"version":3,"names":["ParagraphNode","BaseParagraphNode","CodeHighlightNode","CodeNode","HashtagNode","MarkNode","HeadingNode","BaseHeadingNode","QuoteNode","BaseQuoteNode","OverflowNode","AutoLinkNode","LinkNode","FontColorNode","TypographyNode","ListNode","ListItemNode","ImageNode","allNodes","replace","with","node","getTag"],"sources":["index.ts"],"sourcesContent":["import type { Klass, LexicalNode } from \"lexical\";\nimport { ParagraphNode as BaseParagraphNode } from \"lexical\";\nimport { CodeHighlightNode, CodeNode } from \"@lexical/code\";\nimport { HashtagNode } from \"@lexical/hashtag\";\nimport { MarkNode } from \"@lexical/mark\";\nimport { HeadingNode as BaseHeadingNode, QuoteNode as BaseQuoteNode } from \"@lexical/rich-text\";\nimport { OverflowNode } from \"@lexical/overflow\";\n\nimport { AutoLinkNode, LinkNode } from \"./LinkNode\";\nimport { FontColorNode } from \"./FontColorNode\";\nimport { TypographyNode } from \"./TypographyNode\";\nimport { ListNode } from \"./ListNode\";\nimport { ListItemNode } from \"./ListItemNode\";\nimport { HeadingNode } from \"./HeadingNode\";\nimport { ParagraphNode } from \"./ParagraphNode\";\nimport { QuoteNode } from \"./QuoteNode\";\nimport { ImageNode } from \"./ImageNode\";\n\nexport * from \"./FontColorNode\";\nexport * from \"./TypographyNode\";\nexport * from \"./ListNode\";\nexport * from \"./ListItemNode\";\nexport * from \"./HeadingNode\";\nexport * from \"./ParagraphNode\";\nexport * from \"./QuoteNode\";\nexport * from \"./ImageNode\";\nexport * from \"./LinkNode\";\n\nexport * from \"./utils/formatList\";\nexport * from \"./utils/listNode\";\nexport * from \"./utils/formatToQuote\";\nexport * from \"./utils/formatToHeading\";\nexport * from \"./utils/formatToParagraph\";\nexport * from \"./utils/clearNodeFormating\";\nexport * from \"./utils/toggleLink\";\n\n// This is a list of all the nodes that our Lexical implementation supports OOTB.\nexport const allNodes: ReadonlyArray<\n | Klass<LexicalNode>\n | {\n replace: Klass<LexicalNode>;\n with: <T extends { new (...args: any): any }>(node: InstanceType<T>) => LexicalNode;\n }\n> = [\n // These nodes are copy-pasted from Lexical and modified to fit our needs.\n // https://github.com/facebook/lexical/tree/main/packages/lexical-playground/src/nodes\n // https://github.com/facebook/lexical/tree/main/packages\n ImageNode,\n ListNode,\n ListItemNode,\n\n // These nodes are directly imported from Lexical.\n CodeNode,\n HashtagNode,\n CodeHighlightNode,\n AutoLinkNode,\n OverflowNode,\n MarkNode,\n\n // Our custom nodes.\n FontColorNode,\n TypographyNode,\n\n // The following code replaces the built-in Lexical nodes with our custom ones.\n // https://lexical.dev/docs/concepts/node-replacement\n ParagraphNode,\n {\n replace: BaseParagraphNode,\n with: () => {\n return new ParagraphNode();\n }\n },\n HeadingNode,\n {\n replace: BaseHeadingNode,\n with: (node: BaseHeadingNode) => {\n return new HeadingNode(node.getTag());\n }\n },\n QuoteNode,\n {\n replace: BaseQuoteNode,\n with: () => {\n return new QuoteNode();\n }\n },\n LinkNode\n];\n"],"mappings":"AACA,SAASA,aAAa,IAAIC,iBAAiB,QAAQ,SAAS;AAC5D,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,eAAe;AAC3D,SAASC,WAAW,QAAQ,kBAAkB;AAC9C,SAASC,QAAQ,QAAQ,eAAe;AACxC,SAASC,WAAW,IAAIC,eAAe,EAAEC,SAAS,IAAIC,aAAa,QAAQ,oBAAoB;AAC/F,SAASC,YAAY,QAAQ,mBAAmB;AAEhD,SAASC,YAAY,EAAEC,QAAQ;AAC/B,SAASC,aAAa;AACtB,SAASC,cAAc;AACvB,SAASC,QAAQ;AACjB,SAASC,YAAY;AACrB,SAASV,WAAW;AACpB,SAASN,aAAa;AACtB,SAASQ,SAAS;AAClB,SAASS,SAAS;AAElB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMC,QAMZ,GAAG;AACA;AACA;AACA;AACAD,SAAS,EACTF,QAAQ,EACRC,YAAY;AAEZ;AACAb,QAAQ,EACRC,WAAW,EACXF,iBAAiB,EACjBS,YAAY,EACZD,YAAY,EACZL,QAAQ;AAER;AACAQ,aAAa,EACbC,cAAc;AAEd;AACA;AACAd,aAAa,EACb;EACImB,OAAO,EAAElB,iBAAiB;EAC1BmB,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAIpB,aAAa,CAAC,CAAC;EAC9B;AACJ,CAAC,EACDM,WAAW,EACX;EACIa,OAAO,EAAEZ,eAAe;EACxBa,IAAI,EAAGC,IAAqB,IAAK;IAC7B,OAAO,IAAIf,WAAW,CAACe,IAAI,CAACC,MAAM,CAAC,CAAC,CAAC;EACzC;AACJ,CAAC,EACDd,SAAS,EACT;EACIW,OAAO,EAAEV,aAAa;EACtBW,IAAI,EAAEA,CAAA,KAAM;IACR,OAAO,IAAIZ,SAAS,CAAC,CAAC;EAC1B;AACJ,CAAC,EACDI,QAAQ,CACX","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webiny/lexical-nodes",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-alpha.0",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@lexical/code": "0.23.1",
|
|
6
6
|
"@lexical/hashtag": "0.23.1",
|
|
@@ -13,11 +13,11 @@
|
|
|
13
13
|
"@lexical/selection": "0.23.1",
|
|
14
14
|
"@lexical/utils": "0.23.1",
|
|
15
15
|
"@types/prismjs": "1.26.4",
|
|
16
|
-
"@webiny/lexical-theme": "
|
|
16
|
+
"@webiny/lexical-theme": "6.0.0-alpha.0",
|
|
17
17
|
"lexical": "0.23.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@webiny/project-utils": "
|
|
20
|
+
"@webiny/project-utils": "6.0.0-alpha.0",
|
|
21
21
|
"react": "18.2.0"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
]
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "a5b28fed7a242d8f56712197a8ea83aa6d2ed101"
|
|
39
39
|
}
|
package/types.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var clearNodeFormatting = exports.clearNodeFormatting = function clearNodeFormatting(activeEditor, selection) {
|
|
12
|
-
activeEditor.update(function () {
|
|
13
|
-
if ((0, _lexical.$isRangeSelection)(selection)) {
|
|
14
|
-
(0, _selection.$selectAll)(selection);
|
|
15
|
-
selection.getNodes().forEach(function (node) {
|
|
16
|
-
if ((0, _lexical.$isTextNode)(node)) {
|
|
1
|
+
import { $isRangeSelection, $isTextNode } from "lexical";
|
|
2
|
+
import { $selectAll } from "@lexical/selection";
|
|
3
|
+
import { $getNearestBlockElementAncestorOrThrow } from "@lexical/utils";
|
|
4
|
+
import { $isDecoratorBlockNode } from "@lexical/react/LexicalDecoratorBlockNode";
|
|
5
|
+
export const clearNodeFormatting = (activeEditor, selection) => {
|
|
6
|
+
activeEditor.update(() => {
|
|
7
|
+
if ($isRangeSelection(selection)) {
|
|
8
|
+
$selectAll(selection);
|
|
9
|
+
selection.getNodes().forEach(node => {
|
|
10
|
+
if ($isTextNode(node)) {
|
|
17
11
|
node.setFormat(0);
|
|
18
12
|
node.setStyle("");
|
|
19
|
-
|
|
13
|
+
$getNearestBlockElementAncestorOrThrow(node).setFormat("");
|
|
20
14
|
}
|
|
21
|
-
if (
|
|
15
|
+
if ($isDecoratorBlockNode(node)) {
|
|
22
16
|
node.setFormat("");
|
|
23
17
|
}
|
|
24
18
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["$isRangeSelection","$isTextNode","$selectAll","$getNearestBlockElementAncestorOrThrow","$isDecoratorBlockNode","clearNodeFormatting","activeEditor","selection","update","getNodes","forEach","node","setFormat","setStyle"],"sources":["clearNodeFormating.ts"],"sourcesContent":["import { $isRangeSelection, $isTextNode, LexicalEditor, RangeSelection } from \"lexical\";\nimport { $selectAll } from \"@lexical/selection\";\nimport { $getNearestBlockElementAncestorOrThrow } from \"@lexical/utils\";\nimport { $isDecoratorBlockNode } from \"@lexical/react/LexicalDecoratorBlockNode\";\n\nexport const clearNodeFormatting = (\n activeEditor: LexicalEditor,\n selection: RangeSelection | null\n) => {\n activeEditor.update(() => {\n if ($isRangeSelection(selection)) {\n $selectAll(selection);\n selection.getNodes().forEach(node => {\n if ($isTextNode(node)) {\n node.setFormat(0);\n node.setStyle(\"\");\n $getNearestBlockElementAncestorOrThrow(node).setFormat(\"\");\n }\n if ($isDecoratorBlockNode(node)) {\n node.setFormat(\"\");\n }\n });\n }\n });\n};\n"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,WAAW,QAAuC,SAAS;AACvF,SAASC,UAAU,QAAQ,oBAAoB;AAC/C,SAASC,sCAAsC,QAAQ,gBAAgB;AACvE,SAASC,qBAAqB,QAAQ,0CAA0C;AAEhF,OAAO,MAAMC,mBAAmB,GAAGA,CAC/BC,YAA2B,EAC3BC,SAAgC,KAC/B;EACDD,YAAY,CAACE,MAAM,CAAC,MAAM;IACtB,IAAIR,iBAAiB,CAACO,SAAS,CAAC,EAAE;MAC9BL,UAAU,CAACK,SAAS,CAAC;MACrBA,SAAS,CAACE,QAAQ,CAAC,CAAC,CAACC,OAAO,CAACC,IAAI,IAAI;QACjC,IAAIV,WAAW,CAACU,IAAI,CAAC,EAAE;UACnBA,IAAI,CAACC,SAAS,CAAC,CAAC,CAAC;UACjBD,IAAI,CAACE,QAAQ,CAAC,EAAE,CAAC;UACjBV,sCAAsC,CAACQ,IAAI,CAAC,CAACC,SAAS,CAAC,EAAE,CAAC;QAC9D;QACA,IAAIR,qBAAqB,CAACO,IAAI,CAAC,EAAE;UAC7BA,IAAI,CAACC,SAAS,CAAC,EAAE,CAAC;QACtB;MACJ,CAAC,CAAC;IACN;EACJ,CAAC,CAAC;AACN,CAAC","ignoreList":[]}
|