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