@haklex/rich-headless 0.0.82 → 0.0.84
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/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +461 -443
- package/dist/transformers.d.ts +1 -0
- package/dist/transformers.d.ts.map +1 -1
- package/dist/transformers.mjs +393 -323
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,462 +1,480 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CodeHighlightNode, CodeNode } from "@lexical/code";
|
|
1
|
+
import { CodeNode, CodeHighlightNode } from "@lexical/code";
|
|
3
2
|
import { HorizontalRuleNode } from "@lexical/extension";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { LinkNode, AutoLinkNode } from "@lexical/link";
|
|
4
|
+
import { ListNode, ListItemNode } from "@lexical/list";
|
|
6
5
|
import { HeadingNode, QuoteNode } from "@lexical/rich-text";
|
|
7
|
-
import {
|
|
6
|
+
import { TableNode, TableCellNode, TableRowNode } from "@lexical/table";
|
|
8
7
|
import { DecoratorNode, ElementNode } from "lexical";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
QuoteNode,
|
|
24
|
-
ListNode,
|
|
25
|
-
ListItemNode,
|
|
26
|
-
LinkNode,
|
|
27
|
-
AutoLinkNode,
|
|
28
|
-
HorizontalRuleNode,
|
|
29
|
-
TableNode,
|
|
30
|
-
TableCellNode,
|
|
31
|
-
TableRowNode,
|
|
32
|
-
CodeNode,
|
|
33
|
-
CodeHighlightNode
|
|
8
|
+
import { $toMarkdown, allHeadlessTransformers } from "./transformers.mjs";
|
|
9
|
+
const builtinNodes = [
|
|
10
|
+
HeadingNode,
|
|
11
|
+
QuoteNode,
|
|
12
|
+
ListNode,
|
|
13
|
+
ListItemNode,
|
|
14
|
+
LinkNode,
|
|
15
|
+
AutoLinkNode,
|
|
16
|
+
HorizontalRuleNode,
|
|
17
|
+
TableNode,
|
|
18
|
+
TableCellNode,
|
|
19
|
+
TableRowNode,
|
|
20
|
+
CodeNode,
|
|
21
|
+
CodeHighlightNode
|
|
34
22
|
];
|
|
35
23
|
function stubDOM() {
|
|
36
|
-
|
|
24
|
+
return document.createElement("span");
|
|
37
25
|
}
|
|
38
26
|
function extractText(state) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
27
|
+
if (!state || typeof state !== "object") return "";
|
|
28
|
+
const root = state.root;
|
|
29
|
+
if (!root) return "";
|
|
30
|
+
return walkChildren(root);
|
|
43
31
|
}
|
|
44
32
|
function walkChildren(node) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
const children = node.children;
|
|
34
|
+
if (!children) return node.text ?? "";
|
|
35
|
+
return children.map(walkChildren).join("\n");
|
|
36
|
+
}
|
|
37
|
+
class SpoilerNode extends ElementNode {
|
|
38
|
+
static getType() {
|
|
39
|
+
return "spoiler";
|
|
40
|
+
}
|
|
41
|
+
static clone(node) {
|
|
42
|
+
return new SpoilerNode(node.__key);
|
|
43
|
+
}
|
|
44
|
+
constructor(key) {
|
|
45
|
+
super(key);
|
|
46
|
+
}
|
|
47
|
+
static importJSON(_json) {
|
|
48
|
+
return new SpoilerNode();
|
|
49
|
+
}
|
|
50
|
+
exportJSON() {
|
|
51
|
+
return { ...super.exportJSON(), type: "spoiler", version: 1 };
|
|
52
|
+
}
|
|
53
|
+
createDOM() {
|
|
54
|
+
return stubDOM();
|
|
55
|
+
}
|
|
56
|
+
updateDOM() {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
isInline() {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
class RubyNode extends ElementNode {
|
|
64
|
+
constructor(key) {
|
|
65
|
+
super(key);
|
|
66
|
+
this.__reading = "";
|
|
67
|
+
}
|
|
68
|
+
static getType() {
|
|
69
|
+
return "ruby";
|
|
70
|
+
}
|
|
71
|
+
static clone(node) {
|
|
72
|
+
const n = new RubyNode(node.__key);
|
|
73
|
+
n.__reading = node.__reading;
|
|
74
|
+
return n;
|
|
75
|
+
}
|
|
76
|
+
static importJSON(json) {
|
|
77
|
+
const node = new RubyNode();
|
|
78
|
+
node.__reading = json.reading ?? "";
|
|
79
|
+
return node;
|
|
80
|
+
}
|
|
81
|
+
exportJSON() {
|
|
82
|
+
return {
|
|
83
|
+
...super.exportJSON(),
|
|
84
|
+
type: "ruby",
|
|
85
|
+
reading: this.__reading,
|
|
86
|
+
version: 1
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
createDOM() {
|
|
90
|
+
return stubDOM();
|
|
91
|
+
}
|
|
92
|
+
updateDOM() {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
isInline() {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
class DetailsNode extends ElementNode {
|
|
100
|
+
constructor(key) {
|
|
101
|
+
super(key);
|
|
102
|
+
this.__summary = "";
|
|
103
|
+
this.__open = false;
|
|
104
|
+
}
|
|
105
|
+
static getType() {
|
|
106
|
+
return "details";
|
|
107
|
+
}
|
|
108
|
+
static clone(node) {
|
|
109
|
+
const n = new DetailsNode(node.__key);
|
|
110
|
+
n.__summary = node.__summary;
|
|
111
|
+
n.__open = node.__open;
|
|
112
|
+
return n;
|
|
113
|
+
}
|
|
114
|
+
static importJSON(json) {
|
|
115
|
+
const node = new DetailsNode();
|
|
116
|
+
node.__summary = json.summary ?? "";
|
|
117
|
+
node.__open = json.open ?? false;
|
|
118
|
+
return node;
|
|
119
|
+
}
|
|
120
|
+
exportJSON() {
|
|
121
|
+
return {
|
|
122
|
+
...super.exportJSON(),
|
|
123
|
+
type: "details",
|
|
124
|
+
summary: this.__summary,
|
|
125
|
+
open: this.__open
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
createDOM() {
|
|
129
|
+
return stubDOM();
|
|
130
|
+
}
|
|
131
|
+
updateDOM() {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
48
134
|
}
|
|
49
|
-
var SpoilerNode = class SpoilerNode extends ElementNode {
|
|
50
|
-
static getType() {
|
|
51
|
-
return "spoiler";
|
|
52
|
-
}
|
|
53
|
-
static clone(node) {
|
|
54
|
-
return new SpoilerNode(node.__key);
|
|
55
|
-
}
|
|
56
|
-
constructor(key) {
|
|
57
|
-
super(key);
|
|
58
|
-
}
|
|
59
|
-
static importJSON(_json) {
|
|
60
|
-
return new SpoilerNode();
|
|
61
|
-
}
|
|
62
|
-
exportJSON() {
|
|
63
|
-
return {
|
|
64
|
-
...super.exportJSON(),
|
|
65
|
-
type: "spoiler",
|
|
66
|
-
version: 1
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
createDOM() {
|
|
70
|
-
return stubDOM();
|
|
71
|
-
}
|
|
72
|
-
updateDOM() {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
isInline() {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
var RubyNode = class RubyNode extends ElementNode {
|
|
80
|
-
static getType() {
|
|
81
|
-
return "ruby";
|
|
82
|
-
}
|
|
83
|
-
static clone(node) {
|
|
84
|
-
const n = new RubyNode(node.__key);
|
|
85
|
-
n.__reading = node.__reading;
|
|
86
|
-
return n;
|
|
87
|
-
}
|
|
88
|
-
constructor(key) {
|
|
89
|
-
super(key);
|
|
90
|
-
this.__reading = "";
|
|
91
|
-
}
|
|
92
|
-
static importJSON(json) {
|
|
93
|
-
const node = new RubyNode();
|
|
94
|
-
node.__reading = json.reading ?? "";
|
|
95
|
-
return node;
|
|
96
|
-
}
|
|
97
|
-
exportJSON() {
|
|
98
|
-
return {
|
|
99
|
-
...super.exportJSON(),
|
|
100
|
-
type: "ruby",
|
|
101
|
-
reading: this.__reading,
|
|
102
|
-
version: 1
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
createDOM() {
|
|
106
|
-
return stubDOM();
|
|
107
|
-
}
|
|
108
|
-
updateDOM() {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
isInline() {
|
|
112
|
-
return true;
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
var DetailsNode = class DetailsNode extends ElementNode {
|
|
116
|
-
static getType() {
|
|
117
|
-
return "details";
|
|
118
|
-
}
|
|
119
|
-
static clone(node) {
|
|
120
|
-
const n = new DetailsNode(node.__key);
|
|
121
|
-
n.__summary = node.__summary;
|
|
122
|
-
n.__open = node.__open;
|
|
123
|
-
return n;
|
|
124
|
-
}
|
|
125
|
-
constructor(key) {
|
|
126
|
-
super(key);
|
|
127
|
-
this.__summary = "";
|
|
128
|
-
this.__open = false;
|
|
129
|
-
}
|
|
130
|
-
static importJSON(json) {
|
|
131
|
-
const node = new DetailsNode();
|
|
132
|
-
node.__summary = json.summary ?? "";
|
|
133
|
-
node.__open = json.open ?? false;
|
|
134
|
-
return node;
|
|
135
|
-
}
|
|
136
|
-
exportJSON() {
|
|
137
|
-
return {
|
|
138
|
-
...super.exportJSON(),
|
|
139
|
-
type: "details",
|
|
140
|
-
summary: this.__summary,
|
|
141
|
-
open: this.__open
|
|
142
|
-
};
|
|
143
|
-
}
|
|
144
|
-
createDOM() {
|
|
145
|
-
return stubDOM();
|
|
146
|
-
}
|
|
147
|
-
updateDOM() {
|
|
148
|
-
return false;
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
135
|
function headlessDecorator(type, propKeys, defaults, inline = false) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
136
|
+
class Node extends DecoratorNode {
|
|
137
|
+
constructor(key) {
|
|
138
|
+
super(key);
|
|
139
|
+
for (const k of propKeys) {
|
|
140
|
+
this[`__${k}`] = defaults[k];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
static getType() {
|
|
144
|
+
return type;
|
|
145
|
+
}
|
|
146
|
+
static clone(node) {
|
|
147
|
+
const n = new Node(node.__key);
|
|
148
|
+
for (const k of propKeys) {
|
|
149
|
+
n[`__${k}`] = node[`__${k}`];
|
|
150
|
+
}
|
|
151
|
+
return n;
|
|
152
|
+
}
|
|
153
|
+
static importJSON(json) {
|
|
154
|
+
const node = new Node();
|
|
155
|
+
for (const k of propKeys) {
|
|
156
|
+
node[`__${k}`] = json[k] ?? defaults[k];
|
|
157
|
+
}
|
|
158
|
+
return node;
|
|
159
|
+
}
|
|
160
|
+
exportJSON() {
|
|
161
|
+
const out = { type, version: 1 };
|
|
162
|
+
for (const k of propKeys) {
|
|
163
|
+
out[k] = this[`__${k}`];
|
|
164
|
+
}
|
|
165
|
+
return out;
|
|
166
|
+
}
|
|
167
|
+
createDOM(_config) {
|
|
168
|
+
return stubDOM();
|
|
169
|
+
}
|
|
170
|
+
updateDOM() {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
decorate(_editor, _config) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
isInline() {
|
|
177
|
+
return inline;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return Node;
|
|
192
181
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
182
|
+
const ImageNode = headlessDecorator(
|
|
183
|
+
"image",
|
|
184
|
+
["src", "altText", "width", "height", "caption", "thumbhash", "accent"],
|
|
185
|
+
{
|
|
186
|
+
src: "",
|
|
187
|
+
altText: "",
|
|
188
|
+
width: void 0,
|
|
189
|
+
height: void 0,
|
|
190
|
+
caption: void 0,
|
|
191
|
+
thumbhash: void 0,
|
|
192
|
+
accent: void 0
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
const VideoNode = headlessDecorator("video", ["src", "poster", "width", "height"], {
|
|
196
|
+
src: "",
|
|
197
|
+
poster: void 0,
|
|
198
|
+
width: void 0,
|
|
199
|
+
height: void 0
|
|
209
200
|
});
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
201
|
+
const LinkCardNode = headlessDecorator(
|
|
202
|
+
"link-card",
|
|
203
|
+
["url", "source", "id", "title", "description", "favicon", "image"],
|
|
204
|
+
{
|
|
205
|
+
url: "",
|
|
206
|
+
source: void 0,
|
|
207
|
+
id: void 0,
|
|
208
|
+
title: void 0,
|
|
209
|
+
description: void 0,
|
|
210
|
+
favicon: void 0,
|
|
211
|
+
image: void 0
|
|
212
|
+
}
|
|
213
|
+
);
|
|
214
|
+
const KaTeXInlineNode = headlessDecorator(
|
|
215
|
+
"katex-inline",
|
|
216
|
+
["equation"],
|
|
217
|
+
{ equation: "" },
|
|
218
|
+
true
|
|
219
|
+
);
|
|
220
|
+
const KaTeXBlockNode = headlessDecorator("katex-block", ["equation"], {
|
|
221
|
+
equation: ""
|
|
220
222
|
});
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
"source",
|
|
224
|
-
"id",
|
|
225
|
-
"title",
|
|
226
|
-
"description",
|
|
227
|
-
"favicon",
|
|
228
|
-
"image"
|
|
229
|
-
], {
|
|
230
|
-
url: "",
|
|
231
|
-
source: void 0,
|
|
232
|
-
id: void 0,
|
|
233
|
-
title: void 0,
|
|
234
|
-
description: void 0,
|
|
235
|
-
favicon: void 0,
|
|
236
|
-
image: void 0
|
|
223
|
+
const MermaidNode = headlessDecorator("mermaid", ["diagram"], {
|
|
224
|
+
diagram: ""
|
|
237
225
|
});
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
handle: "",
|
|
248
|
-
displayName: void 0
|
|
249
|
-
}, true);
|
|
250
|
-
var CodeBlockNode = headlessDecorator("code-block", ["code", "language"], {
|
|
251
|
-
code: "",
|
|
252
|
-
language: ""
|
|
226
|
+
const MentionNode = headlessDecorator(
|
|
227
|
+
"mention",
|
|
228
|
+
["platform", "handle", "displayName"],
|
|
229
|
+
{ platform: "", handle: "", displayName: void 0 },
|
|
230
|
+
true
|
|
231
|
+
);
|
|
232
|
+
const CodeBlockNode = headlessDecorator("code-block", ["code", "language"], {
|
|
233
|
+
code: "",
|
|
234
|
+
language: ""
|
|
253
235
|
});
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
url: "",
|
|
258
|
-
source: null
|
|
236
|
+
const FootnoteNode = headlessDecorator("footnote", ["identifier"], { identifier: "" }, true);
|
|
237
|
+
const FootnoteSectionNode = headlessDecorator("footnote-section", ["definitions"], {
|
|
238
|
+
definitions: {}
|
|
259
239
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
layout: "grid"
|
|
240
|
+
const EmbedNode = headlessDecorator("embed", ["url", "source"], {
|
|
241
|
+
url: "",
|
|
242
|
+
source: null
|
|
264
243
|
});
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
244
|
+
const CodeSnippetNode = headlessDecorator("code-snippet", ["files"], {
|
|
245
|
+
files: []
|
|
246
|
+
});
|
|
247
|
+
const GalleryNode = headlessDecorator("gallery", ["images", "layout"], {
|
|
248
|
+
images: [],
|
|
249
|
+
layout: "grid"
|
|
250
|
+
});
|
|
251
|
+
const ExcalidrawNode = headlessDecorator("excalidraw", ["snapshot"], {
|
|
252
|
+
snapshot: ""
|
|
253
|
+
});
|
|
254
|
+
const TagNode = headlessDecorator("tag", ["text"], { text: "" }, true);
|
|
255
|
+
const CommentNode = headlessDecorator("comment", ["text"], { text: "" }, true);
|
|
256
|
+
class BannerNode extends DecoratorNode {
|
|
257
|
+
constructor(key) {
|
|
258
|
+
super(key);
|
|
259
|
+
this.__bannerType = "note";
|
|
260
|
+
this.__contentState = null;
|
|
261
|
+
}
|
|
262
|
+
static getType() {
|
|
263
|
+
return "banner";
|
|
264
|
+
}
|
|
265
|
+
static clone(node) {
|
|
266
|
+
const n = new BannerNode(node.__key);
|
|
267
|
+
n.__bannerType = node.__bannerType;
|
|
268
|
+
n.__contentState = node.__contentState;
|
|
269
|
+
return n;
|
|
270
|
+
}
|
|
271
|
+
static importJSON(json) {
|
|
272
|
+
const node = new BannerNode();
|
|
273
|
+
node.__bannerType = json.bannerType ?? "note";
|
|
274
|
+
node.__contentState = json.content ?? null;
|
|
275
|
+
return node;
|
|
276
|
+
}
|
|
277
|
+
exportJSON() {
|
|
278
|
+
return {
|
|
279
|
+
type: "banner",
|
|
280
|
+
version: 1,
|
|
281
|
+
bannerType: this.__bannerType,
|
|
282
|
+
content: this.__contentState
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
createDOM() {
|
|
286
|
+
return stubDOM();
|
|
287
|
+
}
|
|
288
|
+
updateDOM() {
|
|
289
|
+
return false;
|
|
290
|
+
}
|
|
291
|
+
decorate() {
|
|
292
|
+
return null;
|
|
293
|
+
}
|
|
294
|
+
getTextContent() {
|
|
295
|
+
return extractText(this.__contentState);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
class AlertQuoteNode extends DecoratorNode {
|
|
299
|
+
constructor(key) {
|
|
300
|
+
super(key);
|
|
301
|
+
this.__alertType = "note";
|
|
302
|
+
this.__contentState = null;
|
|
303
|
+
}
|
|
304
|
+
static getType() {
|
|
305
|
+
return "alert-quote";
|
|
306
|
+
}
|
|
307
|
+
static clone(node) {
|
|
308
|
+
const n = new AlertQuoteNode(node.__key);
|
|
309
|
+
n.__alertType = node.__alertType;
|
|
310
|
+
n.__contentState = node.__contentState;
|
|
311
|
+
return n;
|
|
312
|
+
}
|
|
313
|
+
static importJSON(json) {
|
|
314
|
+
const node = new AlertQuoteNode();
|
|
315
|
+
node.__alertType = json.alertType ?? "note";
|
|
316
|
+
node.__contentState = json.content ?? null;
|
|
317
|
+
return node;
|
|
318
|
+
}
|
|
319
|
+
exportJSON() {
|
|
320
|
+
return {
|
|
321
|
+
type: "alert-quote",
|
|
322
|
+
version: 1,
|
|
323
|
+
alertType: this.__alertType,
|
|
324
|
+
content: this.__contentState
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
createDOM() {
|
|
328
|
+
return stubDOM();
|
|
329
|
+
}
|
|
330
|
+
updateDOM() {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
decorate() {
|
|
334
|
+
return null;
|
|
335
|
+
}
|
|
336
|
+
getTextContent() {
|
|
337
|
+
return extractText(this.__contentState);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
class NestedDocNode extends DecoratorNode {
|
|
341
|
+
constructor(key) {
|
|
342
|
+
super(key);
|
|
343
|
+
this.__contentState = null;
|
|
344
|
+
}
|
|
345
|
+
static getType() {
|
|
346
|
+
return "nested-doc";
|
|
347
|
+
}
|
|
348
|
+
static clone(node) {
|
|
349
|
+
const n = new NestedDocNode(node.__key);
|
|
350
|
+
n.__contentState = node.__contentState;
|
|
351
|
+
return n;
|
|
352
|
+
}
|
|
353
|
+
static importJSON(json) {
|
|
354
|
+
const node = new NestedDocNode();
|
|
355
|
+
node.__contentState = json.content ?? null;
|
|
356
|
+
return node;
|
|
357
|
+
}
|
|
358
|
+
exportJSON() {
|
|
359
|
+
return {
|
|
360
|
+
type: "nested-doc",
|
|
361
|
+
version: 1,
|
|
362
|
+
content: this.__contentState
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
createDOM() {
|
|
366
|
+
return stubDOM();
|
|
367
|
+
}
|
|
368
|
+
updateDOM() {
|
|
369
|
+
return false;
|
|
370
|
+
}
|
|
371
|
+
decorate() {
|
|
372
|
+
return null;
|
|
373
|
+
}
|
|
374
|
+
getTextContent() {
|
|
375
|
+
return extractText(this.__contentState);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
class GridContainerNode extends DecoratorNode {
|
|
379
|
+
constructor(key) {
|
|
380
|
+
super(key);
|
|
381
|
+
this.__cols = 2;
|
|
382
|
+
this.__gap = "16px";
|
|
383
|
+
this.__cells = [];
|
|
384
|
+
}
|
|
385
|
+
static getType() {
|
|
386
|
+
return "grid-container";
|
|
387
|
+
}
|
|
388
|
+
static clone(node) {
|
|
389
|
+
const n = new GridContainerNode(node.__key);
|
|
390
|
+
n.__cols = node.__cols;
|
|
391
|
+
n.__gap = node.__gap;
|
|
392
|
+
n.__cells = node.__cells;
|
|
393
|
+
return n;
|
|
394
|
+
}
|
|
395
|
+
static importJSON(json) {
|
|
396
|
+
const node = new GridContainerNode();
|
|
397
|
+
node.__cols = json.cols ?? 2;
|
|
398
|
+
const rawGap = json.gap;
|
|
399
|
+
node.__gap = typeof rawGap === "number" ? `${rawGap}px` : rawGap ?? "16px";
|
|
400
|
+
node.__cells = json.cells ?? [];
|
|
401
|
+
return node;
|
|
402
|
+
}
|
|
403
|
+
exportJSON() {
|
|
404
|
+
return {
|
|
405
|
+
type: "grid-container",
|
|
406
|
+
version: 1,
|
|
407
|
+
cols: this.__cols,
|
|
408
|
+
gap: this.__gap,
|
|
409
|
+
cells: this.__cells
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
createDOM() {
|
|
413
|
+
return stubDOM();
|
|
414
|
+
}
|
|
415
|
+
updateDOM() {
|
|
416
|
+
return false;
|
|
417
|
+
}
|
|
418
|
+
decorate() {
|
|
419
|
+
return null;
|
|
420
|
+
}
|
|
421
|
+
getTextContent() {
|
|
422
|
+
return this.__cells.map((cell) => extractText(cell)).join("\n");
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
const customHeadlessNodes = [
|
|
426
|
+
SpoilerNode,
|
|
427
|
+
RubyNode,
|
|
428
|
+
DetailsNode,
|
|
429
|
+
ImageNode,
|
|
430
|
+
VideoNode,
|
|
431
|
+
LinkCardNode,
|
|
432
|
+
KaTeXInlineNode,
|
|
433
|
+
KaTeXBlockNode,
|
|
434
|
+
MermaidNode,
|
|
435
|
+
MentionNode,
|
|
436
|
+
CodeBlockNode,
|
|
437
|
+
FootnoteNode,
|
|
438
|
+
FootnoteSectionNode,
|
|
439
|
+
EmbedNode,
|
|
440
|
+
CodeSnippetNode,
|
|
441
|
+
GalleryNode,
|
|
442
|
+
ExcalidrawNode,
|
|
443
|
+
TagNode,
|
|
444
|
+
CommentNode,
|
|
445
|
+
BannerNode,
|
|
446
|
+
AlertQuoteNode,
|
|
447
|
+
NestedDocNode,
|
|
448
|
+
GridContainerNode
|
|
459
449
|
];
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
450
|
+
const allHeadlessNodes = [...builtinNodes, ...customHeadlessNodes];
|
|
451
|
+
export {
|
|
452
|
+
$toMarkdown,
|
|
453
|
+
AlertQuoteNode,
|
|
454
|
+
BannerNode,
|
|
455
|
+
CodeBlockNode,
|
|
456
|
+
CodeSnippetNode,
|
|
457
|
+
CommentNode,
|
|
458
|
+
DetailsNode,
|
|
459
|
+
EmbedNode,
|
|
460
|
+
ExcalidrawNode,
|
|
461
|
+
FootnoteNode,
|
|
462
|
+
FootnoteSectionNode,
|
|
463
|
+
GalleryNode,
|
|
464
|
+
GridContainerNode,
|
|
465
|
+
ImageNode,
|
|
466
|
+
KaTeXBlockNode,
|
|
467
|
+
KaTeXInlineNode,
|
|
468
|
+
LinkCardNode,
|
|
469
|
+
MentionNode,
|
|
470
|
+
MermaidNode,
|
|
471
|
+
NestedDocNode,
|
|
472
|
+
RubyNode,
|
|
473
|
+
SpoilerNode,
|
|
474
|
+
TagNode,
|
|
475
|
+
VideoNode,
|
|
476
|
+
allHeadlessNodes,
|
|
477
|
+
allHeadlessTransformers,
|
|
478
|
+
builtinNodes,
|
|
479
|
+
customHeadlessNodes
|
|
480
|
+
};
|