@mdxeditor/editor 0.4.2 → 0.5.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/dist/CodeBlockEditor-7e15d01c.cjs +1 -0
- package/dist/CodeBlockEditor-85a8b6b0.js +79 -0
- package/dist/FrontmatterEditor-a8263f5d.js +119 -0
- package/dist/FrontmatterEditor-bd112c96.cjs +1 -0
- package/dist/JsxEditor-4511b188.js +110 -0
- package/dist/JsxEditor-85e636d6.cjs +1 -0
- package/dist/SandpackEditor-04d3c3ce.cjs +1 -0
- package/dist/SandpackEditor-0a3bfaf0.js +99 -0
- package/dist/TableEditor-0aedb943.js +428 -0
- package/dist/TableEditor-d0c5800f.cjs +1 -0
- package/dist/index-11db5fbf.js +3884 -0
- package/dist/index-731c8e58.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +66 -4540
- package/dist/useCodeMirrorRef-89746e60.js +84 -0
- package/dist/useCodeMirrorRef-cba12130.cjs +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4544 +1,70 @@
|
|
|
1
|
-
|
|
2
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
-
var __publicField = (obj, key, value) => {
|
|
4
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
-
return value;
|
|
6
|
-
};
|
|
7
|
-
import { LexicalComposer } from "@lexical/react/LexicalComposer";
|
|
8
|
-
import { ContentEditable } from "@lexical/react/LexicalContentEditable";
|
|
9
|
-
import LexicalErrorBoundary from "@lexical/react/LexicalErrorBoundary";
|
|
10
|
-
import { HorizontalRulePlugin } from "@lexical/react/LexicalHorizontalRulePlugin";
|
|
11
|
-
import { LinkPlugin } from "@lexical/react/LexicalLinkPlugin";
|
|
12
|
-
import { ListPlugin } from "@lexical/react/LexicalListPlugin";
|
|
13
|
-
import { RichTextPlugin } from "@lexical/react/LexicalRichTextPlugin";
|
|
14
|
-
import { TabIndentationPlugin } from "@lexical/react/LexicalTabIndentationPlugin";
|
|
15
|
-
import classNames from "classnames";
|
|
16
|
-
import { ElementNode, $createParagraphNode, $applyNodeReplacement, DecoratorNode, createEditor, $getRoot, $isRootNode, $isParagraphNode, $isLineBreakNode, $isTextNode, $isElementNode, ParagraphNode, $createTextNode, $getSelection, $isRangeSelection, DEPRECATED_$isGridSelection, FORMAT_TEXT_COMMAND, $isRootOrShadowRoot, SELECTION_CHANGE_COMMAND, COMMAND_PRIORITY_CRITICAL, BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND, KEY_ESCAPE_COMMAND, KEY_MODIFIER_COMMAND, COMMAND_PRIORITY_HIGH, createCommand, INDENT_CONTENT_COMMAND, $getNodeByKey, KEY_TAB_COMMAND, KEY_ENTER_COMMAND } from "lexical";
|
|
1
|
+
import { $, c, f, h, k, n, r, b, d, g, j, l, o, q, A, C, F, I, J, M, m, p, T, v } from "./index-11db5fbf.js";
|
|
17
2
|
import { AdmonitionKind } from "lexical";
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import
|
|
24
|
-
import
|
|
25
|
-
import
|
|
26
|
-
import
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
import
|
|
34
|
-
import
|
|
35
|
-
import
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import
|
|
42
|
-
import
|
|
43
|
-
import
|
|
44
|
-
import
|
|
45
|
-
import
|
|
46
|
-
import
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
50
|
-
import
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
|
|
59
|
-
constructor(kind, key) {
|
|
60
|
-
super(key);
|
|
61
|
-
__publicField(this, "__kind");
|
|
62
|
-
this.__kind = kind || "note";
|
|
63
|
-
}
|
|
64
|
-
static getType() {
|
|
65
|
-
return "admonition";
|
|
66
|
-
}
|
|
67
|
-
getKind() {
|
|
68
|
-
return this.getLatest().__kind;
|
|
69
|
-
}
|
|
70
|
-
setKind(kind) {
|
|
71
|
-
if (kind !== this.getKind()) {
|
|
72
|
-
this.getWritable().__kind = kind;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
static clone(node) {
|
|
76
|
-
return new AdmonitionNode(node.__kind, node.__key);
|
|
77
|
-
}
|
|
78
|
-
// View
|
|
79
|
-
createDOM(config) {
|
|
80
|
-
const element = document.createElement("div");
|
|
81
|
-
addClassNamesToElement(element, config.theme.admonition[this.__kind]);
|
|
82
|
-
return element;
|
|
83
|
-
}
|
|
84
|
-
updateDOM(_prevNode, _dom) {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
// TODO:
|
|
88
|
-
// static importDOM(): DOMConversionMap | null {
|
|
89
|
-
// return {
|
|
90
|
-
// blockquote: (node: Node) => ({
|
|
91
|
-
// conversion: convertBlockquoteElement,
|
|
92
|
-
// priority: 0,
|
|
93
|
-
// }),
|
|
94
|
-
// }
|
|
95
|
-
// }
|
|
96
|
-
static importJSON(serializedNode) {
|
|
97
|
-
const node = $createAdmonitionNode(serializedNode.kind);
|
|
98
|
-
return node;
|
|
99
|
-
}
|
|
100
|
-
exportJSON() {
|
|
101
|
-
return {
|
|
102
|
-
...super.exportJSON(),
|
|
103
|
-
type: "admonition"
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// Mutation
|
|
107
|
-
insertNewAfter(_, restoreSelection) {
|
|
108
|
-
const newBlock = $createAdmonitionNode();
|
|
109
|
-
this.insertAfter(newBlock, restoreSelection);
|
|
110
|
-
return newBlock;
|
|
111
|
-
}
|
|
112
|
-
collapseAtStart() {
|
|
113
|
-
const paragraph = $createParagraphNode();
|
|
114
|
-
const children = this.getChildren();
|
|
115
|
-
children.forEach((child) => paragraph.append(child));
|
|
116
|
-
this.replace(paragraph);
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
function $createAdmonitionNode(kind) {
|
|
121
|
-
return $applyNodeReplacement(new AdmonitionNode(kind));
|
|
122
|
-
}
|
|
123
|
-
function $isAdmonitionNode(node) {
|
|
124
|
-
return node instanceof AdmonitionNode;
|
|
125
|
-
}
|
|
126
|
-
function tap(arg, proc) {
|
|
127
|
-
proc(arg);
|
|
128
|
-
return arg;
|
|
129
|
-
}
|
|
130
|
-
function always(value) {
|
|
131
|
-
return () => value;
|
|
132
|
-
}
|
|
133
|
-
function noop() {
|
|
134
|
-
}
|
|
135
|
-
function voidEmitter$1() {
|
|
136
|
-
let subscription = noop;
|
|
137
|
-
return {
|
|
138
|
-
publish: () => {
|
|
139
|
-
subscription();
|
|
140
|
-
},
|
|
141
|
-
subscribe: (cb) => {
|
|
142
|
-
subscription = cb;
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
}
|
|
146
|
-
class CodeBlockNode extends DecoratorNode {
|
|
147
|
-
constructor(code2, language, meta, key) {
|
|
148
|
-
super(key);
|
|
149
|
-
__publicField(this, "__code");
|
|
150
|
-
__publicField(this, "__meta");
|
|
151
|
-
__publicField(this, "__language");
|
|
152
|
-
__publicField(this, "__focusEmitter", voidEmitter$1());
|
|
153
|
-
this.__code = code2;
|
|
154
|
-
this.__meta = meta;
|
|
155
|
-
this.__language = language;
|
|
156
|
-
}
|
|
157
|
-
static getType() {
|
|
158
|
-
return "codeblock";
|
|
159
|
-
}
|
|
160
|
-
static clone(node) {
|
|
161
|
-
return new CodeBlockNode(node.__code, node.__language, node.__meta, node.__key);
|
|
162
|
-
}
|
|
163
|
-
static importJSON(serializedNode) {
|
|
164
|
-
const { code: code2, meta, language } = serializedNode;
|
|
165
|
-
return $createCodeBlockNode({
|
|
166
|
-
code: code2,
|
|
167
|
-
language,
|
|
168
|
-
meta
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
exportJSON() {
|
|
172
|
-
return {
|
|
173
|
-
code: this.getCode(),
|
|
174
|
-
language: this.getLanguage(),
|
|
175
|
-
meta: this.getMeta(),
|
|
176
|
-
type: "codeblock",
|
|
177
|
-
version: 1
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
// View
|
|
181
|
-
createDOM(_config) {
|
|
182
|
-
return document.createElement("div");
|
|
183
|
-
}
|
|
184
|
-
updateDOM() {
|
|
185
|
-
return false;
|
|
186
|
-
}
|
|
187
|
-
getCode() {
|
|
188
|
-
return this.getLatest().__code;
|
|
189
|
-
}
|
|
190
|
-
getMeta() {
|
|
191
|
-
return this.getLatest().__meta;
|
|
192
|
-
}
|
|
193
|
-
getLanguage() {
|
|
194
|
-
return this.getLatest().__language;
|
|
195
|
-
}
|
|
196
|
-
setCode(code2) {
|
|
197
|
-
if (code2 !== this.__code) {
|
|
198
|
-
this.getWritable().__code = code2;
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
setMeta(meta) {
|
|
202
|
-
if (meta !== this.__meta) {
|
|
203
|
-
this.getWritable().__meta = meta;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
setLanguage(language) {
|
|
207
|
-
if (language !== this.__language) {
|
|
208
|
-
this.getWritable().__language = language;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
select() {
|
|
212
|
-
this.__focusEmitter.publish();
|
|
213
|
-
}
|
|
214
|
-
decorate(_editor, {
|
|
215
|
-
theme: {
|
|
216
|
-
nodeDecoratorComponents: { CodeBlockEditor: CodeBlockEditor2 }
|
|
217
|
-
}
|
|
218
|
-
}) {
|
|
219
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
220
|
-
CodeBlockEditor2,
|
|
221
|
-
{
|
|
222
|
-
nodeKey: this.getKey(),
|
|
223
|
-
code: this.getCode(),
|
|
224
|
-
meta: this.getMeta(),
|
|
225
|
-
language: this.getLanguage(),
|
|
226
|
-
onChange: (code2) => this.setCode(code2),
|
|
227
|
-
focusEmitter: this.__focusEmitter
|
|
228
|
-
}
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
function $createCodeBlockNode(options) {
|
|
233
|
-
const { code: code2, language, meta } = options;
|
|
234
|
-
return new CodeBlockNode(code2, language, meta);
|
|
235
|
-
}
|
|
236
|
-
function $isCodeBlockNode(node) {
|
|
237
|
-
return node instanceof CodeBlockNode;
|
|
238
|
-
}
|
|
239
|
-
class FrontmatterNode extends DecoratorNode {
|
|
240
|
-
constructor(code2, key) {
|
|
241
|
-
super(key);
|
|
242
|
-
__publicField(this, "__yaml");
|
|
243
|
-
this.__yaml = code2;
|
|
244
|
-
}
|
|
245
|
-
static getType() {
|
|
246
|
-
return "frontmatter";
|
|
247
|
-
}
|
|
248
|
-
static clone(node) {
|
|
249
|
-
return new FrontmatterNode(node.__yaml, node.__key);
|
|
250
|
-
}
|
|
251
|
-
static importJSON(serializedNode) {
|
|
252
|
-
const { yaml } = serializedNode;
|
|
253
|
-
const node = $createFrontmatterNode(yaml);
|
|
254
|
-
return node;
|
|
255
|
-
}
|
|
256
|
-
exportJSON() {
|
|
257
|
-
return {
|
|
258
|
-
yaml: this.getYaml(),
|
|
259
|
-
type: "frontmatter",
|
|
260
|
-
version: 1
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
// View
|
|
264
|
-
createDOM(_config) {
|
|
265
|
-
return document.createElement("div");
|
|
266
|
-
}
|
|
267
|
-
updateDOM() {
|
|
268
|
-
return false;
|
|
269
|
-
}
|
|
270
|
-
getYaml() {
|
|
271
|
-
return this.getLatest().__yaml;
|
|
272
|
-
}
|
|
273
|
-
setYaml(yaml) {
|
|
274
|
-
if (yaml !== this.__yaml) {
|
|
275
|
-
this.getWritable().__yaml = yaml;
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
decorate(editor, {
|
|
279
|
-
theme: {
|
|
280
|
-
nodeDecoratorComponents: { FrontmatterEditor: FrontmatterEditor2 }
|
|
281
|
-
}
|
|
282
|
-
}) {
|
|
283
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
284
|
-
FrontmatterEditor2,
|
|
285
|
-
{
|
|
286
|
-
yaml: this.getYaml(),
|
|
287
|
-
onChange: (yaml) => editor == null ? void 0 : editor.update(() => {
|
|
288
|
-
this.setYaml(yaml);
|
|
289
|
-
})
|
|
290
|
-
}
|
|
291
|
-
);
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
function $createFrontmatterNode(yaml) {
|
|
295
|
-
return new FrontmatterNode(yaml);
|
|
296
|
-
}
|
|
297
|
-
function $isFrontmatterNode(node) {
|
|
298
|
-
return node instanceof FrontmatterNode;
|
|
299
|
-
}
|
|
300
|
-
function convertImageElement(domNode) {
|
|
301
|
-
if (domNode instanceof HTMLImageElement) {
|
|
302
|
-
const { alt: altText, src, title } = domNode;
|
|
303
|
-
const node = $createImageNode({ altText, src, title });
|
|
304
|
-
return { node };
|
|
305
|
-
}
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
class ImageNode extends DecoratorNode {
|
|
309
|
-
constructor(src, altText, title, key) {
|
|
310
|
-
super(key);
|
|
311
|
-
__publicField(this, "__src");
|
|
312
|
-
__publicField(this, "__altText");
|
|
313
|
-
__publicField(this, "__title");
|
|
314
|
-
this.__src = src;
|
|
315
|
-
this.__title = title;
|
|
316
|
-
this.__altText = altText;
|
|
317
|
-
}
|
|
318
|
-
static getType() {
|
|
319
|
-
return "image";
|
|
320
|
-
}
|
|
321
|
-
static clone(node) {
|
|
322
|
-
return new ImageNode(node.__src, node.__altText, node.__title, node.__key);
|
|
323
|
-
}
|
|
324
|
-
static importJSON(serializedNode) {
|
|
325
|
-
const { altText, title, src } = serializedNode;
|
|
326
|
-
const node = $createImageNode({
|
|
327
|
-
altText,
|
|
328
|
-
title,
|
|
329
|
-
src
|
|
330
|
-
});
|
|
331
|
-
return node;
|
|
332
|
-
}
|
|
333
|
-
exportDOM() {
|
|
334
|
-
const element = document.createElement("img");
|
|
335
|
-
element.setAttribute("src", this.__src);
|
|
336
|
-
element.setAttribute("alt", this.__altText);
|
|
337
|
-
if (this.__title) {
|
|
338
|
-
element.setAttribute("title", this.__title);
|
|
339
|
-
}
|
|
340
|
-
return { element };
|
|
341
|
-
}
|
|
342
|
-
static importDOM() {
|
|
343
|
-
return {
|
|
344
|
-
img: () => ({
|
|
345
|
-
conversion: convertImageElement,
|
|
346
|
-
priority: 0
|
|
347
|
-
})
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
exportJSON() {
|
|
351
|
-
return {
|
|
352
|
-
altText: this.getAltText(),
|
|
353
|
-
title: this.getTitle(),
|
|
354
|
-
src: this.getSrc(),
|
|
355
|
-
type: "image",
|
|
356
|
-
version: 1
|
|
357
|
-
};
|
|
358
|
-
}
|
|
359
|
-
createDOM(config) {
|
|
360
|
-
const span = document.createElement("span");
|
|
361
|
-
const theme2 = config.theme;
|
|
362
|
-
const className = theme2.image;
|
|
363
|
-
if (className !== void 0) {
|
|
364
|
-
span.className = className;
|
|
365
|
-
}
|
|
366
|
-
return span;
|
|
367
|
-
}
|
|
368
|
-
updateDOM() {
|
|
369
|
-
return false;
|
|
370
|
-
}
|
|
371
|
-
getSrc() {
|
|
372
|
-
return this.__src;
|
|
373
|
-
}
|
|
374
|
-
getAltText() {
|
|
375
|
-
return this.__altText;
|
|
376
|
-
}
|
|
377
|
-
getTitle() {
|
|
378
|
-
return this.__title;
|
|
379
|
-
}
|
|
380
|
-
setTitle(title) {
|
|
381
|
-
this.getWritable().__title = title;
|
|
382
|
-
}
|
|
383
|
-
decorate() {
|
|
384
|
-
return /* @__PURE__ */ React__default.createElement("img", { title: this.__title, src: this.__src, alt: this.__altText });
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
function $createImageNode(options) {
|
|
388
|
-
const { altText, title, src, key } = options;
|
|
389
|
-
return new ImageNode(src, altText, title, key);
|
|
390
|
-
}
|
|
391
|
-
function $isImageNode(node) {
|
|
392
|
-
return node instanceof ImageNode;
|
|
393
|
-
}
|
|
394
|
-
const darkTheme = "_dark-theme_13nbk_1";
|
|
395
|
-
const bold = "_bold_13nbk_10";
|
|
396
|
-
const italic = "_italic_13nbk_14";
|
|
397
|
-
const underline = "_underline_13nbk_18";
|
|
398
|
-
const strikethrough = "_strikethrough_13nbk_34";
|
|
399
|
-
const underlineStrikethrough = "_underlineStrikethrough_13nbk_38";
|
|
400
|
-
const subscript = "_subscript_13nbk_42";
|
|
401
|
-
const superscript = "_superscript_13nbk_47";
|
|
402
|
-
const code = "_code_13nbk_52";
|
|
403
|
-
const nestedListItem$1 = "_nestedListItem_13nbk_59";
|
|
404
|
-
const admonitionDanger = "_admonitionDanger_13nbk_63";
|
|
405
|
-
const admonitionInfo = "_admonitionInfo_13nbk_63";
|
|
406
|
-
const admonitionNote = "_admonitionNote_13nbk_63";
|
|
407
|
-
const admonitionTip = "_admonitionTip_13nbk_63";
|
|
408
|
-
const admonitionCaution = "_admonitionCaution_13nbk_63";
|
|
409
|
-
const styles$1 = {
|
|
410
|
-
darkTheme,
|
|
411
|
-
bold,
|
|
412
|
-
italic,
|
|
413
|
-
underline,
|
|
414
|
-
strikethrough,
|
|
415
|
-
underlineStrikethrough,
|
|
416
|
-
subscript,
|
|
417
|
-
superscript,
|
|
418
|
-
code,
|
|
419
|
-
nestedListItem: nestedListItem$1,
|
|
420
|
-
admonitionDanger,
|
|
421
|
-
admonitionInfo,
|
|
422
|
-
admonitionNote,
|
|
423
|
-
admonitionTip,
|
|
424
|
-
admonitionCaution
|
|
425
|
-
};
|
|
426
|
-
const theme = {
|
|
427
|
-
text: {
|
|
428
|
-
bold: styles$1.bold,
|
|
429
|
-
italic: styles$1.italic,
|
|
430
|
-
underline: styles$1.underline,
|
|
431
|
-
code: styles$1.code,
|
|
432
|
-
strikethrough: styles$1.strikethrough,
|
|
433
|
-
subscript: styles$1.subscript,
|
|
434
|
-
superscript: styles$1.superscript,
|
|
435
|
-
underlineStrikethrough: styles$1.underlineStrikethrough
|
|
436
|
-
},
|
|
437
|
-
list: {
|
|
438
|
-
nested: {
|
|
439
|
-
listitem: styles$1.nestedListItem
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
admonition: {
|
|
443
|
-
danger: styles$1.admonitionDanger,
|
|
444
|
-
info: styles$1.admonitionInfo,
|
|
445
|
-
note: styles$1.admonitionNote,
|
|
446
|
-
tip: styles$1.admonitionTip,
|
|
447
|
-
caution: styles$1.admonitionCaution
|
|
448
|
-
}
|
|
449
|
-
};
|
|
450
|
-
const EmptySerializedTextEditorState = {
|
|
451
|
-
type: "root",
|
|
452
|
-
format: "left",
|
|
453
|
-
indent: 0,
|
|
454
|
-
direction: "ltr",
|
|
455
|
-
version: 1,
|
|
456
|
-
children: [
|
|
457
|
-
{
|
|
458
|
-
type: "paragraph",
|
|
459
|
-
version: 1,
|
|
460
|
-
direction: "ltr",
|
|
461
|
-
format: "left",
|
|
462
|
-
indent: 0,
|
|
463
|
-
children: []
|
|
464
|
-
}
|
|
465
|
-
]
|
|
466
|
-
};
|
|
467
|
-
const EmptySerializedFlowEditorState = {
|
|
468
|
-
type: "root",
|
|
469
|
-
format: "left",
|
|
470
|
-
indent: 0,
|
|
471
|
-
direction: "ltr",
|
|
472
|
-
version: 1,
|
|
473
|
-
children: []
|
|
474
|
-
};
|
|
475
|
-
class JsxNode extends DecoratorNode {
|
|
476
|
-
constructor({ name, kind, attributes, state, updateFn, key }) {
|
|
477
|
-
super(key);
|
|
478
|
-
__publicField(this, "__kind");
|
|
479
|
-
__publicField(this, "__name");
|
|
480
|
-
__publicField(this, "__attributes");
|
|
481
|
-
__publicField(this, "__editor");
|
|
482
|
-
if (!attributes) {
|
|
483
|
-
debugger;
|
|
484
|
-
}
|
|
485
|
-
this.__name = name;
|
|
486
|
-
this.__kind = kind;
|
|
487
|
-
this.__attributes = attributes;
|
|
488
|
-
this.__editor = createEditor();
|
|
489
|
-
if (state) {
|
|
490
|
-
const parsedState = this.__editor.parseEditorState(state);
|
|
491
|
-
if (!parsedState.isEmpty()) {
|
|
492
|
-
this.__editor.setEditorState(parsedState);
|
|
493
|
-
}
|
|
494
|
-
} else if (updateFn) {
|
|
495
|
-
const parsedState = this.__editor.parseEditorState(
|
|
496
|
-
{ root: this.getKind() === "text" ? EmptySerializedTextEditorState : EmptySerializedFlowEditorState },
|
|
497
|
-
() => {
|
|
498
|
-
if (this.getKind() === "text") {
|
|
499
|
-
const rootParagraph = $getRoot().getFirstChildOrThrow();
|
|
500
|
-
updateFn(rootParagraph);
|
|
501
|
-
} else {
|
|
502
|
-
updateFn($getRoot());
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
);
|
|
506
|
-
if (!parsedState.isEmpty()) {
|
|
507
|
-
this.__editor.setEditorState(parsedState);
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
static getType() {
|
|
512
|
-
return "jsx";
|
|
513
|
-
}
|
|
514
|
-
static clone(node) {
|
|
515
|
-
return new JsxNode({
|
|
516
|
-
name: node.__name,
|
|
517
|
-
kind: node.__kind,
|
|
518
|
-
attributes: node.__attributes,
|
|
519
|
-
state: node.__editor.getEditorState().toJSON()
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
static importJSON(serializedNode) {
|
|
523
|
-
const { name, kind, attributes, state } = serializedNode;
|
|
524
|
-
return $createJsxNode({
|
|
525
|
-
kind,
|
|
526
|
-
name,
|
|
527
|
-
attributes,
|
|
528
|
-
state
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
exportJSON() {
|
|
532
|
-
return {
|
|
533
|
-
name: this.getName(),
|
|
534
|
-
kind: this.getKind(),
|
|
535
|
-
attributes: this.getAttributes(),
|
|
536
|
-
state: this.__editor.getEditorState().toJSON(),
|
|
537
|
-
type: "jsx",
|
|
538
|
-
version: 1
|
|
539
|
-
};
|
|
540
|
-
}
|
|
541
|
-
inNestedEditor(callback) {
|
|
542
|
-
this.__editor.getEditorState().read(callback);
|
|
543
|
-
}
|
|
544
|
-
getChildren() {
|
|
545
|
-
if (this.getKey() === "flow") {
|
|
546
|
-
return $getRoot().getChildren() || [];
|
|
547
|
-
} else {
|
|
548
|
-
const firstChild = $getRoot().getFirstChild();
|
|
549
|
-
if (!firstChild) {
|
|
550
|
-
return [];
|
|
551
|
-
}
|
|
552
|
-
return firstChild.getChildren() || [];
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
createDOM() {
|
|
556
|
-
if (this.getKey() === "flow") {
|
|
557
|
-
return document.createElement("div");
|
|
558
|
-
} else {
|
|
559
|
-
return document.createElement("span");
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
updateDOM() {
|
|
563
|
-
return false;
|
|
564
|
-
}
|
|
565
|
-
getName() {
|
|
566
|
-
return this.__name;
|
|
567
|
-
}
|
|
568
|
-
getKind() {
|
|
569
|
-
return this.__kind;
|
|
570
|
-
}
|
|
571
|
-
getAttributes() {
|
|
572
|
-
return this.__attributes;
|
|
573
|
-
}
|
|
574
|
-
updateAttributes(attributeValues) {
|
|
575
|
-
this.getWritable().__attributes = Object.entries(attributeValues).map(([name, value]) => {
|
|
576
|
-
return { name, value };
|
|
577
|
-
});
|
|
578
|
-
}
|
|
579
|
-
decorate(_parentEditor, {
|
|
580
|
-
theme: {
|
|
581
|
-
nodeDecoratorComponents: { JsxEditor: JsxEditor2 }
|
|
582
|
-
}
|
|
583
|
-
}) {
|
|
584
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
585
|
-
JsxEditor2,
|
|
586
|
-
{
|
|
587
|
-
attributes: this.getAttributes(),
|
|
588
|
-
componentName: this.getName(),
|
|
589
|
-
kind: this.getKind(),
|
|
590
|
-
editor: this.__editor,
|
|
591
|
-
onSubmit: (attributeValues) => this.updateAttributes(attributeValues),
|
|
592
|
-
theme
|
|
593
|
-
}
|
|
594
|
-
);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
function $createJsxNode(options) {
|
|
598
|
-
return new JsxNode(options);
|
|
599
|
-
}
|
|
600
|
-
function $isJsxNode(node) {
|
|
601
|
-
return node instanceof JsxNode;
|
|
602
|
-
}
|
|
603
|
-
function voidEmitter() {
|
|
604
|
-
let subscription = noop;
|
|
605
|
-
return {
|
|
606
|
-
publish: () => {
|
|
607
|
-
subscription();
|
|
608
|
-
},
|
|
609
|
-
subscribe: (cb) => {
|
|
610
|
-
subscription = cb;
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
}
|
|
614
|
-
class SandpackNode extends DecoratorNode {
|
|
615
|
-
constructor(code2, language, meta, key) {
|
|
616
|
-
super(key);
|
|
617
|
-
__publicField(this, "__code");
|
|
618
|
-
__publicField(this, "__meta");
|
|
619
|
-
__publicField(this, "__language");
|
|
620
|
-
__publicField(this, "__focusEmitter", voidEmitter());
|
|
621
|
-
this.__code = code2;
|
|
622
|
-
this.__meta = meta;
|
|
623
|
-
this.__language = language;
|
|
624
|
-
}
|
|
625
|
-
static getType() {
|
|
626
|
-
return "sandpack";
|
|
627
|
-
}
|
|
628
|
-
static clone(node) {
|
|
629
|
-
return new SandpackNode(node.__code, node.__language, node.__meta, node.__key);
|
|
630
|
-
}
|
|
631
|
-
static importJSON(serializedNode) {
|
|
632
|
-
const { code: code2, meta, language } = serializedNode;
|
|
633
|
-
return $createSandpackNode({
|
|
634
|
-
code: code2,
|
|
635
|
-
language,
|
|
636
|
-
meta
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
exportJSON() {
|
|
640
|
-
return {
|
|
641
|
-
code: this.getCode(),
|
|
642
|
-
language: this.getLanguage(),
|
|
643
|
-
meta: this.getMeta(),
|
|
644
|
-
type: "sandpack",
|
|
645
|
-
version: 1
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
// View
|
|
649
|
-
createDOM(_config) {
|
|
650
|
-
return document.createElement("div");
|
|
651
|
-
}
|
|
652
|
-
updateDOM() {
|
|
653
|
-
return false;
|
|
654
|
-
}
|
|
655
|
-
getCode() {
|
|
656
|
-
return this.getLatest().__code;
|
|
657
|
-
}
|
|
658
|
-
getMeta() {
|
|
659
|
-
return this.getLatest().__meta;
|
|
660
|
-
}
|
|
661
|
-
getLanguage() {
|
|
662
|
-
return this.getLatest().__language;
|
|
663
|
-
}
|
|
664
|
-
setCode(code2) {
|
|
665
|
-
if (code2 !== this.__code) {
|
|
666
|
-
this.getWritable().__code = code2;
|
|
667
|
-
}
|
|
668
|
-
}
|
|
669
|
-
setMeta(meta) {
|
|
670
|
-
if (meta !== this.__meta) {
|
|
671
|
-
this.getWritable().__meta = meta;
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
setLanguage(language) {
|
|
675
|
-
if (language !== this.__language) {
|
|
676
|
-
this.getWritable().__language = language;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
select() {
|
|
680
|
-
this.__focusEmitter.publish();
|
|
681
|
-
}
|
|
682
|
-
decorate(_parentEditor, {
|
|
683
|
-
theme: {
|
|
684
|
-
nodeDecoratorComponents: { SandpackEditor: SandpackEditor2 }
|
|
685
|
-
}
|
|
686
|
-
}) {
|
|
687
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
688
|
-
SandpackEditor2,
|
|
689
|
-
{
|
|
690
|
-
nodeKey: this.getKey(),
|
|
691
|
-
code: this.getCode(),
|
|
692
|
-
meta: this.getMeta(),
|
|
693
|
-
onChange: (code2) => this.setCode(code2),
|
|
694
|
-
focusEmitter: this.__focusEmitter
|
|
695
|
-
}
|
|
696
|
-
);
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
function $createSandpackNode(options) {
|
|
700
|
-
const { code: code2, language, meta } = options;
|
|
701
|
-
return new SandpackNode(code2, language, meta);
|
|
702
|
-
}
|
|
703
|
-
function $isSandpackNode(node) {
|
|
704
|
-
return node instanceof SandpackNode;
|
|
705
|
-
}
|
|
706
|
-
const EMPTY_CELL = { type: "tableCell", children: [] };
|
|
707
|
-
function coordinatesEmitter() {
|
|
708
|
-
let subscription = noop;
|
|
709
|
-
return {
|
|
710
|
-
publish: (coords) => {
|
|
711
|
-
subscription(coords);
|
|
712
|
-
},
|
|
713
|
-
subscribe: (cb) => {
|
|
714
|
-
subscription = cb;
|
|
715
|
-
}
|
|
716
|
-
};
|
|
717
|
-
}
|
|
718
|
-
class TableNode extends DecoratorNode {
|
|
719
|
-
constructor(mdastNode, key) {
|
|
720
|
-
super(key);
|
|
721
|
-
__publicField(this, "__mdastNode");
|
|
722
|
-
__publicField(this, "focusEmitter", coordinatesEmitter());
|
|
723
|
-
this.__mdastNode = mdastNode || { type: "table", children: [] };
|
|
724
|
-
}
|
|
725
|
-
static getType() {
|
|
726
|
-
return "table";
|
|
727
|
-
}
|
|
728
|
-
static clone(node) {
|
|
729
|
-
return new TableNode(structuredClone(node.__mdastNode), node.__key);
|
|
730
|
-
}
|
|
731
|
-
static importJSON(serializedNode) {
|
|
732
|
-
return $createTableNode(serializedNode.mdastNode);
|
|
733
|
-
}
|
|
734
|
-
exportJSON() {
|
|
735
|
-
return {
|
|
736
|
-
mdastNode: structuredClone(this.__mdastNode),
|
|
737
|
-
type: "table",
|
|
738
|
-
version: 1
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
getMdastNode() {
|
|
742
|
-
return this.__mdastNode;
|
|
743
|
-
}
|
|
744
|
-
getRowCount() {
|
|
745
|
-
return this.__mdastNode.children.length;
|
|
746
|
-
}
|
|
747
|
-
getColCount() {
|
|
748
|
-
var _a;
|
|
749
|
-
return ((_a = this.__mdastNode.children[0]) == null ? void 0 : _a.children.length) || 0;
|
|
750
|
-
}
|
|
751
|
-
createDOM() {
|
|
752
|
-
return document.createElement("div");
|
|
753
|
-
}
|
|
754
|
-
updateDOM() {
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
updateCellContents(colIndex, rowIndex, children) {
|
|
758
|
-
const self = this.getWritable();
|
|
759
|
-
const table = self.__mdastNode;
|
|
760
|
-
const row = table.children[rowIndex];
|
|
761
|
-
const cells = row.children;
|
|
762
|
-
const cell = cells[colIndex];
|
|
763
|
-
const cellsClone = Array.from(cells);
|
|
764
|
-
const cellClone = { ...cell, children };
|
|
765
|
-
const rowClone = { ...row, children: cellsClone };
|
|
766
|
-
cellsClone[colIndex] = cellClone;
|
|
767
|
-
table.children[rowIndex] = rowClone;
|
|
768
|
-
}
|
|
769
|
-
insertColumnAt(colIndex) {
|
|
770
|
-
const self = this.getWritable();
|
|
771
|
-
const table = self.__mdastNode;
|
|
772
|
-
for (let rowIndex = 0; rowIndex < table.children.length; rowIndex++) {
|
|
773
|
-
const row = table.children[rowIndex];
|
|
774
|
-
const cells = row.children;
|
|
775
|
-
const cellsClone = Array.from(cells);
|
|
776
|
-
const rowClone = { ...row, children: cellsClone };
|
|
777
|
-
cellsClone.splice(colIndex, 0, structuredClone(EMPTY_CELL));
|
|
778
|
-
table.children[rowIndex] = rowClone;
|
|
779
|
-
}
|
|
780
|
-
if (table.align && table.align.length > 0) {
|
|
781
|
-
table.align.splice(colIndex, 0, "left");
|
|
782
|
-
}
|
|
783
|
-
}
|
|
784
|
-
deleteColumnAt(colIndex) {
|
|
785
|
-
const self = this.getWritable();
|
|
786
|
-
const table = self.__mdastNode;
|
|
787
|
-
for (let rowIndex = 0; rowIndex < table.children.length; rowIndex++) {
|
|
788
|
-
const row = table.children[rowIndex];
|
|
789
|
-
const cells = row.children;
|
|
790
|
-
const cellsClone = Array.from(cells);
|
|
791
|
-
const rowClone = { ...row, children: cellsClone };
|
|
792
|
-
cellsClone.splice(colIndex, 1);
|
|
793
|
-
table.children[rowIndex] = rowClone;
|
|
794
|
-
}
|
|
795
|
-
}
|
|
796
|
-
insertRowAt(y) {
|
|
797
|
-
const self = this.getWritable();
|
|
798
|
-
const table = self.__mdastNode;
|
|
799
|
-
const newRow = {
|
|
800
|
-
type: "tableRow",
|
|
801
|
-
children: Array.from({ length: this.getColCount() }, () => structuredClone(EMPTY_CELL))
|
|
802
|
-
};
|
|
803
|
-
table.children.splice(y, 0, newRow);
|
|
804
|
-
}
|
|
805
|
-
deleteRowAt(rowIndex) {
|
|
806
|
-
this.getWritable().__mdastNode.children.splice(rowIndex, 1);
|
|
807
|
-
}
|
|
808
|
-
addRowToBottom() {
|
|
809
|
-
this.insertRowAt(this.getRowCount());
|
|
810
|
-
}
|
|
811
|
-
addColumnToRight() {
|
|
812
|
-
this.insertColumnAt(this.getColCount());
|
|
813
|
-
}
|
|
814
|
-
setColumnAlign(colIndex, align) {
|
|
815
|
-
const self = this.getWritable();
|
|
816
|
-
const table = self.__mdastNode;
|
|
817
|
-
if (table.align == null) {
|
|
818
|
-
table.align = [];
|
|
819
|
-
}
|
|
820
|
-
table.align[colIndex] = align;
|
|
821
|
-
}
|
|
822
|
-
decorate(parentEditor, {
|
|
823
|
-
theme: {
|
|
824
|
-
nodeDecoratorComponents: { TableEditor: TableEditor2 }
|
|
825
|
-
}
|
|
826
|
-
}) {
|
|
827
|
-
return /* @__PURE__ */ React__default.createElement(TableEditor2, { lexicalTable: this, mdastNode: this.__mdastNode, parentEditor });
|
|
828
|
-
}
|
|
829
|
-
select(coords) {
|
|
830
|
-
this.focusEmitter.publish(coords);
|
|
831
|
-
}
|
|
832
|
-
isInline() {
|
|
833
|
-
return false;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
function $isTableNode(node) {
|
|
837
|
-
return node instanceof TableNode;
|
|
838
|
-
}
|
|
839
|
-
function $createTableNode(mdastNode) {
|
|
840
|
-
return new TableNode(mdastNode);
|
|
841
|
-
}
|
|
842
|
-
const IS_BOLD = 1;
|
|
843
|
-
const IS_ITALIC = 2;
|
|
844
|
-
const IS_UNDERLINE = 8;
|
|
845
|
-
const IS_CODE = 16;
|
|
846
|
-
const LexicalRootVisitor = {
|
|
847
|
-
testLexicalNode: $isRootNode,
|
|
848
|
-
visitLexicalNode: ({ actions }) => {
|
|
849
|
-
actions.addAndStepInto("root");
|
|
850
|
-
}
|
|
851
|
-
};
|
|
852
|
-
const LexicalParagraphVisitor = {
|
|
853
|
-
testLexicalNode: $isParagraphNode,
|
|
854
|
-
visitLexicalNode: ({ actions }) => {
|
|
855
|
-
actions.addAndStepInto("paragraph");
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
const LexicalFrontmatterVisitor = {
|
|
859
|
-
testLexicalNode: $isFrontmatterNode,
|
|
860
|
-
visitLexicalNode: ({ actions, lexicalNode }) => {
|
|
861
|
-
actions.addAndStepInto("yaml", { value: lexicalNode.getYaml() });
|
|
862
|
-
}
|
|
863
|
-
};
|
|
864
|
-
const LexicalLinkVisitor = {
|
|
865
|
-
testLexicalNode: $isLinkNode,
|
|
866
|
-
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
867
|
-
actions.addAndStepInto("link", { url: lexicalNode.getURL(), title: lexicalNode.getTitle() });
|
|
868
|
-
}
|
|
869
|
-
};
|
|
870
|
-
const LexicalHeadingVisitor = {
|
|
871
|
-
testLexicalNode: $isHeadingNode,
|
|
872
|
-
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
873
|
-
const depth = parseInt(lexicalNode.getTag()[1], 10);
|
|
874
|
-
actions.addAndStepInto("heading", { depth });
|
|
875
|
-
}
|
|
876
|
-
};
|
|
877
|
-
const LexicalListVisitor = {
|
|
878
|
-
testLexicalNode: $isListNode,
|
|
879
|
-
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
880
|
-
actions.addAndStepInto("list", {
|
|
881
|
-
ordered: lexicalNode.getListType() === "number",
|
|
882
|
-
//TODO: figure out when spread can be true
|
|
883
|
-
spread: false
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
const LexicalListItemVisitor = {
|
|
888
|
-
testLexicalNode: $isListItemNode,
|
|
889
|
-
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
890
|
-
const children = lexicalNode.getChildren();
|
|
891
|
-
const firstChild = children[0];
|
|
892
|
-
if (children.length === 1 && $isListNode(firstChild)) {
|
|
893
|
-
const prevListItemNode = mdastParent.children.at(-1);
|
|
894
|
-
actions.visitChildren(lexicalNode, prevListItemNode);
|
|
895
|
-
} else {
|
|
896
|
-
const listItem = actions.appendToParent(mdastParent, {
|
|
897
|
-
type: "listItem",
|
|
898
|
-
spread: false,
|
|
899
|
-
children: [{ type: "paragraph", children: [] }]
|
|
900
|
-
});
|
|
901
|
-
actions.visitChildren(lexicalNode, listItem.children[0]);
|
|
902
|
-
}
|
|
903
|
-
}
|
|
904
|
-
};
|
|
905
|
-
const LexicalQuoteVisitor = {
|
|
906
|
-
testLexicalNode: $isQuoteNode,
|
|
907
|
-
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
908
|
-
const blockquote = actions.appendToParent(mdastParent, {
|
|
909
|
-
type: "blockquote",
|
|
910
|
-
children: [{ type: "paragraph", children: [] }]
|
|
911
|
-
});
|
|
912
|
-
actions.visitChildren(lexicalNode, blockquote.children[0]);
|
|
913
|
-
}
|
|
914
|
-
};
|
|
915
|
-
const AdmonitionVisitor = {
|
|
916
|
-
testLexicalNode: $isAdmonitionNode,
|
|
917
|
-
visitLexicalNode: ({ mdastParent, lexicalNode, actions }) => {
|
|
918
|
-
const admonition = actions.appendToParent(mdastParent, {
|
|
919
|
-
type: "containerDirective",
|
|
920
|
-
name: lexicalNode.getKind(),
|
|
921
|
-
children: [{ type: "paragraph", children: [] }]
|
|
922
|
-
});
|
|
923
|
-
actions.visitChildren(lexicalNode, admonition.children[0]);
|
|
924
|
-
}
|
|
925
|
-
};
|
|
926
|
-
const SandpackNodeVisitor = {
|
|
927
|
-
testLexicalNode: $isSandpackNode,
|
|
928
|
-
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
929
|
-
actions.addAndStepInto("code", {
|
|
930
|
-
value: lexicalNode.getCode(),
|
|
931
|
-
lang: lexicalNode.getLanguage(),
|
|
932
|
-
meta: lexicalNode.getMeta()
|
|
933
|
-
});
|
|
934
|
-
}
|
|
935
|
-
};
|
|
936
|
-
const CodeBlockVisitor = {
|
|
937
|
-
testLexicalNode: $isCodeBlockNode,
|
|
938
|
-
visitLexicalNode: ({ lexicalNode, actions }) => {
|
|
939
|
-
actions.addAndStepInto("code", {
|
|
940
|
-
value: lexicalNode.getCode(),
|
|
941
|
-
lang: lexicalNode.getLanguage(),
|
|
942
|
-
meta: lexicalNode.getMeta()
|
|
943
|
-
});
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
function isMdastText(mdastNode) {
|
|
947
|
-
return mdastNode.type === "text";
|
|
948
|
-
}
|
|
949
|
-
const LexicalLinebreakVisitor = {
|
|
950
|
-
testLexicalNode: $isLineBreakNode,
|
|
951
|
-
visitLexicalNode: ({ mdastParent, actions }) => {
|
|
952
|
-
actions.appendToParent(mdastParent, { type: "text", value: "\n" });
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
const LexicalTextVisitor = {
|
|
956
|
-
shouldJoin: (prevNode, currentNode) => {
|
|
957
|
-
return ["text", "emphasis", "strong", "mdxJsxTextElement"].includes(prevNode.type) && prevNode.type === currentNode.type;
|
|
958
|
-
},
|
|
959
|
-
join(prevNode, currentNode) {
|
|
960
|
-
if (isMdastText(prevNode) && isMdastText(currentNode)) {
|
|
961
|
-
return {
|
|
962
|
-
type: "text",
|
|
963
|
-
value: prevNode.value + currentNode.value
|
|
964
|
-
};
|
|
965
|
-
} else {
|
|
966
|
-
return {
|
|
967
|
-
...prevNode,
|
|
968
|
-
children: [...prevNode.children, ...currentNode.children]
|
|
969
|
-
};
|
|
970
|
-
}
|
|
971
|
-
},
|
|
972
|
-
testLexicalNode: $isTextNode,
|
|
973
|
-
visitLexicalNode: ({ lexicalNode, mdastParent, actions }) => {
|
|
974
|
-
const previousSibling = lexicalNode.getPreviousSibling();
|
|
975
|
-
const prevFormat = $isTextNode(previousSibling) ? previousSibling.getFormat() : 0;
|
|
976
|
-
const textContent = lexicalNode.getTextContent();
|
|
977
|
-
const format = lexicalNode.getFormat() ?? 0;
|
|
978
|
-
if (format & IS_CODE) {
|
|
979
|
-
actions.addAndStepInto("inlineCode", {
|
|
980
|
-
value: textContent
|
|
981
|
-
});
|
|
982
|
-
return;
|
|
983
|
-
}
|
|
984
|
-
let localParentNode = mdastParent;
|
|
985
|
-
if (prevFormat & format & IS_ITALIC) {
|
|
986
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
987
|
-
type: "emphasis",
|
|
988
|
-
children: []
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
if (prevFormat & format & IS_BOLD) {
|
|
992
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
993
|
-
type: "strong",
|
|
994
|
-
children: []
|
|
995
|
-
});
|
|
996
|
-
}
|
|
997
|
-
if (prevFormat & format & IS_UNDERLINE) {
|
|
998
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
999
|
-
type: "mdxJsxTextElement",
|
|
1000
|
-
name: "u",
|
|
1001
|
-
children: [],
|
|
1002
|
-
attributes: []
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
if (format & IS_ITALIC && !(prevFormat & IS_ITALIC)) {
|
|
1006
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
1007
|
-
type: "emphasis",
|
|
1008
|
-
children: []
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
if (format & IS_BOLD && !(prevFormat & IS_BOLD)) {
|
|
1012
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
1013
|
-
type: "strong",
|
|
1014
|
-
children: []
|
|
1015
|
-
});
|
|
1016
|
-
}
|
|
1017
|
-
if (format & IS_UNDERLINE && !(prevFormat & IS_UNDERLINE)) {
|
|
1018
|
-
localParentNode = actions.appendToParent(localParentNode, {
|
|
1019
|
-
type: "mdxJsxTextElement",
|
|
1020
|
-
name: "u",
|
|
1021
|
-
children: [],
|
|
1022
|
-
attributes: []
|
|
1023
|
-
});
|
|
1024
|
-
}
|
|
1025
|
-
actions.appendToParent(localParentNode, {
|
|
1026
|
-
type: "text",
|
|
1027
|
-
value: textContent
|
|
1028
|
-
});
|
|
1029
|
-
}
|
|
1030
|
-
};
|
|
1031
|
-
const LexicalThematicBreakVisitor = {
|
|
1032
|
-
testLexicalNode: $isHorizontalRuleNode,
|
|
1033
|
-
visitLexicalNode({ actions }) {
|
|
1034
|
-
actions.addAndStepInto("thematicBreak");
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
const LexicalImageVisitor = {
|
|
1038
|
-
testLexicalNode: $isImageNode,
|
|
1039
|
-
visitLexicalNode({ lexicalNode, actions }) {
|
|
1040
|
-
actions.addAndStepInto("image", {
|
|
1041
|
-
url: lexicalNode.getSrc(),
|
|
1042
|
-
alt: lexicalNode.getAltText(),
|
|
1043
|
-
title: lexicalNode.getTitle()
|
|
1044
|
-
});
|
|
1045
|
-
}
|
|
1046
|
-
};
|
|
1047
|
-
const LexicalTableVisitor = {
|
|
1048
|
-
testLexicalNode: $isTableNode,
|
|
1049
|
-
visitLexicalNode({ actions, mdastParent, lexicalNode }) {
|
|
1050
|
-
actions.appendToParent(mdastParent, lexicalNode.getMdastNode());
|
|
1051
|
-
}
|
|
1052
|
-
};
|
|
1053
|
-
const JsxVisitor = {
|
|
1054
|
-
testLexicalNode: $isJsxNode,
|
|
1055
|
-
visitLexicalNode({ mdastParent, lexicalNode, actions }) {
|
|
1056
|
-
const nodeType = lexicalNode.getKind() === "text" ? "mdxJsxTextElement" : "mdxJsxFlowElement";
|
|
1057
|
-
actions.registerReferredComponent(lexicalNode.getName());
|
|
1058
|
-
const node = {
|
|
1059
|
-
type: nodeType,
|
|
1060
|
-
name: lexicalNode.getName(),
|
|
1061
|
-
attributes: lexicalNode.getAttributes(),
|
|
1062
|
-
children: []
|
|
1063
|
-
};
|
|
1064
|
-
actions.appendToParent(mdastParent, node);
|
|
1065
|
-
lexicalNode.inNestedEditor(() => {
|
|
1066
|
-
actions.visitChildren(lexicalNode, node);
|
|
1067
|
-
});
|
|
1068
|
-
}
|
|
1069
|
-
};
|
|
1070
|
-
const defaultLexicalVisitors = {
|
|
1071
|
-
LexicalRootVisitor,
|
|
1072
|
-
LexicalParagraphVisitor,
|
|
1073
|
-
LexicalFrontmatterVisitor,
|
|
1074
|
-
LexicalTextVisitor,
|
|
1075
|
-
LexicalLinebreakVisitor,
|
|
1076
|
-
LexicalLinkVisitor,
|
|
1077
|
-
LexicalHeadingVisitor,
|
|
1078
|
-
LexicalListVisitor,
|
|
1079
|
-
LexicalListItemVisitor,
|
|
1080
|
-
LexicalQuoteVisitor,
|
|
1081
|
-
SandpackNodeVisitor,
|
|
1082
|
-
CodeBlockVisitor,
|
|
1083
|
-
LexicalThematicBreakVisitor,
|
|
1084
|
-
AdmonitionVisitor,
|
|
1085
|
-
LexicalImageVisitor,
|
|
1086
|
-
JsxVisitor,
|
|
1087
|
-
LexicalTableVisitor
|
|
1088
|
-
};
|
|
1089
|
-
function isParent$1(node) {
|
|
1090
|
-
return node.children instanceof Array;
|
|
1091
|
-
}
|
|
1092
|
-
function exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors }) {
|
|
1093
|
-
let unistRoot = null;
|
|
1094
|
-
const referredComponents = /* @__PURE__ */ new Set();
|
|
1095
|
-
visit(root, null);
|
|
1096
|
-
function registerReferredComponent(componentName) {
|
|
1097
|
-
referredComponents.add(componentName);
|
|
1098
|
-
}
|
|
1099
|
-
function appendToParent(parentNode, node) {
|
|
1100
|
-
if (unistRoot === null) {
|
|
1101
|
-
unistRoot = node;
|
|
1102
|
-
return unistRoot;
|
|
1103
|
-
}
|
|
1104
|
-
if (!isParent$1(parentNode)) {
|
|
1105
|
-
throw new Error("Attempting to append children to a non-parent");
|
|
1106
|
-
}
|
|
1107
|
-
const siblings = parentNode.children;
|
|
1108
|
-
const prevSibling = siblings.at(-1);
|
|
1109
|
-
if (prevSibling) {
|
|
1110
|
-
const joinVisitor = visitors.find((visitor) => {
|
|
1111
|
-
var _a;
|
|
1112
|
-
return (_a = visitor.shouldJoin) == null ? void 0 : _a.call(visitor, prevSibling, node);
|
|
1113
|
-
});
|
|
1114
|
-
if (joinVisitor) {
|
|
1115
|
-
const joinedNode = joinVisitor.join(prevSibling, node);
|
|
1116
|
-
siblings.splice(siblings.length - 1, 1, joinedNode);
|
|
1117
|
-
return joinedNode;
|
|
1118
|
-
}
|
|
1119
|
-
}
|
|
1120
|
-
siblings.push(node);
|
|
1121
|
-
return node;
|
|
1122
|
-
}
|
|
1123
|
-
function visitChildren(lexicalNode, parentNode) {
|
|
1124
|
-
lexicalNode.getChildren().forEach((lexicalChild) => {
|
|
1125
|
-
visit(lexicalChild, parentNode);
|
|
1126
|
-
});
|
|
1127
|
-
}
|
|
1128
|
-
function visit(lexicalNode, mdastParent) {
|
|
1129
|
-
var _a;
|
|
1130
|
-
const visitor = visitors.find((visitor2) => {
|
|
1131
|
-
var _a2;
|
|
1132
|
-
return (_a2 = visitor2.testLexicalNode) == null ? void 0 : _a2.call(visitor2, lexicalNode);
|
|
1133
|
-
});
|
|
1134
|
-
if (!visitor) {
|
|
1135
|
-
throw new Error(`no lexical visitor found for ${lexicalNode.getType()}`, {
|
|
1136
|
-
cause: lexicalNode
|
|
1137
|
-
});
|
|
1138
|
-
}
|
|
1139
|
-
(_a = visitor.visitLexicalNode) == null ? void 0 : _a.call(visitor, {
|
|
1140
|
-
lexicalNode,
|
|
1141
|
-
mdastParent,
|
|
1142
|
-
actions: {
|
|
1143
|
-
addAndStepInto(type, props = {}, hasChildren = true) {
|
|
1144
|
-
const newNode = {
|
|
1145
|
-
type,
|
|
1146
|
-
...props,
|
|
1147
|
-
...hasChildren ? { children: [] } : {}
|
|
1148
|
-
};
|
|
1149
|
-
appendToParent(mdastParent, newNode);
|
|
1150
|
-
if ($isElementNode(lexicalNode) && hasChildren) {
|
|
1151
|
-
visitChildren(lexicalNode, newNode);
|
|
1152
|
-
}
|
|
1153
|
-
},
|
|
1154
|
-
appendToParent,
|
|
1155
|
-
visitChildren,
|
|
1156
|
-
registerReferredComponent
|
|
1157
|
-
}
|
|
1158
|
-
});
|
|
1159
|
-
}
|
|
1160
|
-
if (unistRoot === null) {
|
|
1161
|
-
throw new Error("traversal ended with no root element");
|
|
1162
|
-
}
|
|
1163
|
-
const importsMap = /* @__PURE__ */ new Map();
|
|
1164
|
-
const defaultImportsMap = /* @__PURE__ */ new Map();
|
|
1165
|
-
for (const componentName of referredComponents) {
|
|
1166
|
-
const descriptor = jsxComponentDescriptors.find((descriptor2) => descriptor2.name === componentName);
|
|
1167
|
-
if (!descriptor) {
|
|
1168
|
-
throw new Error(`Component ${componentName} is used but not imported`);
|
|
1169
|
-
}
|
|
1170
|
-
if (descriptor.defaultExport) {
|
|
1171
|
-
defaultImportsMap.set(componentName, descriptor.source);
|
|
1172
|
-
} else {
|
|
1173
|
-
const { source } = descriptor;
|
|
1174
|
-
const existing = importsMap.get(source);
|
|
1175
|
-
if (existing) {
|
|
1176
|
-
existing.push(componentName);
|
|
1177
|
-
} else {
|
|
1178
|
-
importsMap.set(source, [componentName]);
|
|
1179
|
-
}
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
const imports = Array.from(importsMap).map(([source, componentNames]) => {
|
|
1183
|
-
return {
|
|
1184
|
-
type: "mdxjsEsm",
|
|
1185
|
-
value: `import { ${componentNames.join(", ")} } from '${source}'`
|
|
1186
|
-
};
|
|
1187
|
-
});
|
|
1188
|
-
imports.push(
|
|
1189
|
-
...Array.from(defaultImportsMap).map(([componentName, source]) => {
|
|
1190
|
-
return {
|
|
1191
|
-
type: "mdxjsEsm",
|
|
1192
|
-
value: `import ${componentName} from '${source}'`
|
|
1193
|
-
};
|
|
1194
|
-
})
|
|
1195
|
-
);
|
|
1196
|
-
const typedRoot = unistRoot;
|
|
1197
|
-
const frontmatter2 = typedRoot.children.find((child) => child.type === "yaml");
|
|
1198
|
-
if (frontmatter2) {
|
|
1199
|
-
typedRoot.children.splice(typedRoot.children.indexOf(frontmatter2) + 1, 0, ...imports);
|
|
1200
|
-
} else {
|
|
1201
|
-
typedRoot.children.unshift(...imports);
|
|
1202
|
-
}
|
|
1203
|
-
fixWrappingWhitespace(typedRoot, []);
|
|
1204
|
-
return typedRoot;
|
|
1205
|
-
}
|
|
1206
|
-
const TRAILING_WHITESPACE_REGEXP = /\s+$/;
|
|
1207
|
-
const LEADING_WHITESPACE_REGEXP = /^\s+/;
|
|
1208
|
-
function fixWrappingWhitespace(node, parentChain) {
|
|
1209
|
-
if (node.type === "strong" || node.type === "emphasis") {
|
|
1210
|
-
const lastChild = node.children.at(-1);
|
|
1211
|
-
if ((lastChild == null ? void 0 : lastChild.type) === "text") {
|
|
1212
|
-
const trailingWhitespace = lastChild.value.match(TRAILING_WHITESPACE_REGEXP);
|
|
1213
|
-
if (trailingWhitespace) {
|
|
1214
|
-
lastChild.value = lastChild.value.replace(TRAILING_WHITESPACE_REGEXP, "");
|
|
1215
|
-
const parent = parentChain.at(-1);
|
|
1216
|
-
if (parent) {
|
|
1217
|
-
parent.children.splice(parent.children.indexOf(node) + 1, 0, {
|
|
1218
|
-
type: "text",
|
|
1219
|
-
value: trailingWhitespace[0]
|
|
1220
|
-
});
|
|
1221
|
-
fixWrappingWhitespace(parent, parentChain.slice(0, -1));
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
}
|
|
1225
|
-
const firstChild = node.children.at(0);
|
|
1226
|
-
if ((firstChild == null ? void 0 : firstChild.type) === "text") {
|
|
1227
|
-
const leadingWhitespace = firstChild.value.match(LEADING_WHITESPACE_REGEXP);
|
|
1228
|
-
if (leadingWhitespace) {
|
|
1229
|
-
firstChild.value = firstChild.value.replace(LEADING_WHITESPACE_REGEXP, "");
|
|
1230
|
-
const parent = parentChain.at(-1);
|
|
1231
|
-
if (parent) {
|
|
1232
|
-
parent.children.splice(parent.children.indexOf(node), 0, {
|
|
1233
|
-
type: "text",
|
|
1234
|
-
value: leadingWhitespace[0]
|
|
1235
|
-
});
|
|
1236
|
-
fixWrappingWhitespace(parent, parentChain.slice(0, -1));
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
if (Object.hasOwn(node, "children")) {
|
|
1242
|
-
const nodeAsParent = node;
|
|
1243
|
-
nodeAsParent.children.forEach((child) => fixWrappingWhitespace(child, [...parentChain, nodeAsParent]));
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
const defaultExtensions = {
|
|
1247
|
-
mdxToMarkdown: mdxToMarkdown(),
|
|
1248
|
-
frontmatterToMarkdown: frontmatterToMarkdown("yaml"),
|
|
1249
|
-
directiveToMarkdown,
|
|
1250
|
-
gfmTableToMarkdown: gfmTableToMarkdown({ tableCellPadding: true, tablePipeAlign: true })
|
|
1251
|
-
};
|
|
1252
|
-
const defaultToMarkdownOptions = {
|
|
1253
|
-
listItemIndent: "one"
|
|
1254
|
-
};
|
|
1255
|
-
function exportMarkdownFromLexical({
|
|
1256
|
-
root,
|
|
1257
|
-
toMarkdownOptions,
|
|
1258
|
-
toMarkdownExtensions,
|
|
1259
|
-
visitors,
|
|
1260
|
-
jsxComponentDescriptors
|
|
1261
|
-
}) {
|
|
1262
|
-
return toMarkdown(exportLexicalTreeToMdast({ root, visitors, jsxComponentDescriptors }), {
|
|
1263
|
-
extensions: toMarkdownExtensions,
|
|
1264
|
-
...toMarkdownOptions
|
|
1265
|
-
});
|
|
1266
|
-
}
|
|
1267
|
-
const MdastRootVisitor = {
|
|
1268
|
-
testNode: "root",
|
|
1269
|
-
visitNode({ actions, mdastNode, lexicalParent }) {
|
|
1270
|
-
actions.visitChildren(mdastNode, lexicalParent);
|
|
1271
|
-
}
|
|
1272
|
-
};
|
|
1273
|
-
const MdastParagraphVisitor = {
|
|
1274
|
-
testNode: "paragraph",
|
|
1275
|
-
visitNode: function({ mdastNode, lexicalParent, actions }) {
|
|
1276
|
-
if ($isListItemNode(lexicalParent) || $isQuoteNode(lexicalParent) || $isAdmonitionNode(lexicalParent)) {
|
|
1277
|
-
actions.visitChildren(mdastNode, lexicalParent);
|
|
1278
|
-
} else {
|
|
1279
|
-
actions.addAndStepInto($createParagraphNode());
|
|
1280
|
-
}
|
|
1281
|
-
}
|
|
1282
|
-
};
|
|
1283
|
-
const MdastLinkVisitor = {
|
|
1284
|
-
testNode: "link",
|
|
1285
|
-
visitNode({ mdastNode, actions }) {
|
|
1286
|
-
actions.addAndStepInto(
|
|
1287
|
-
$createLinkNode(mdastNode.url, {
|
|
1288
|
-
title: mdastNode.title
|
|
1289
|
-
})
|
|
1290
|
-
);
|
|
1291
|
-
}
|
|
1292
|
-
};
|
|
1293
|
-
const MdastAdmonitionVisitor = {
|
|
1294
|
-
testNode: "containerDirective",
|
|
1295
|
-
visitNode({ mdastNode, actions }) {
|
|
1296
|
-
actions.addAndStepInto($createAdmonitionNode(mdastNode.name));
|
|
1297
|
-
}
|
|
1298
|
-
};
|
|
1299
|
-
const MdastHeadingVisitor = {
|
|
1300
|
-
testNode: "heading",
|
|
1301
|
-
visitNode: function({ mdastNode, actions }) {
|
|
1302
|
-
actions.addAndStepInto($createHeadingNode(`h${mdastNode.depth}`));
|
|
1303
|
-
}
|
|
1304
|
-
};
|
|
1305
|
-
const MdastListVisitor = {
|
|
1306
|
-
testNode: "list",
|
|
1307
|
-
visitNode: function({ mdastNode, lexicalParent, actions }) {
|
|
1308
|
-
const lexicalNode = $createListNode(mdastNode.ordered ? "number" : "bullet");
|
|
1309
|
-
if ($isListItemNode(lexicalParent)) {
|
|
1310
|
-
const dedicatedParent = $createListItemNode();
|
|
1311
|
-
dedicatedParent.append(lexicalNode);
|
|
1312
|
-
lexicalParent.insertAfter(dedicatedParent);
|
|
1313
|
-
} else {
|
|
1314
|
-
lexicalParent.append(lexicalNode);
|
|
1315
|
-
}
|
|
1316
|
-
actions.visitChildren(mdastNode, lexicalNode);
|
|
1317
|
-
}
|
|
1318
|
-
};
|
|
1319
|
-
const MdastListItemVisitor = {
|
|
1320
|
-
testNode: "listItem",
|
|
1321
|
-
visitNode({ actions }) {
|
|
1322
|
-
actions.addAndStepInto($createListItemNode());
|
|
1323
|
-
}
|
|
1324
|
-
};
|
|
1325
|
-
const MdastBlockQuoteVisitor = {
|
|
1326
|
-
testNode: "blockquote",
|
|
1327
|
-
visitNode({ actions }) {
|
|
1328
|
-
actions.addAndStepInto($createQuoteNode());
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
const MdastTableVisitor = {
|
|
1332
|
-
testNode: "table",
|
|
1333
|
-
visitNode({ mdastNode, lexicalParent }) {
|
|
1334
|
-
lexicalParent.append($createTableNode(mdastNode));
|
|
1335
|
-
}
|
|
1336
|
-
};
|
|
1337
|
-
const MdastFormattingVisitor = {
|
|
1338
|
-
testNode(mdastNode) {
|
|
1339
|
-
return mdastNode.type === "emphasis" || mdastNode.type === "strong" || mdastNode.type === "mdxJsxTextElement" && (mdastNode == null ? void 0 : mdastNode.name) === "u";
|
|
1340
|
-
},
|
|
1341
|
-
visitNode({ mdastNode, lexicalParent, actions }) {
|
|
1342
|
-
if (mdastNode.type === "emphasis") {
|
|
1343
|
-
actions.addFormatting(IS_ITALIC);
|
|
1344
|
-
} else if (mdastNode.type === "strong") {
|
|
1345
|
-
actions.addFormatting(IS_BOLD);
|
|
1346
|
-
} else if (mdastNode.type === "mdxJsxTextElement" && mdastNode.name === "u") {
|
|
1347
|
-
actions.addFormatting(IS_UNDERLINE);
|
|
1348
|
-
}
|
|
1349
|
-
actions.visitChildren(mdastNode, lexicalParent);
|
|
1350
|
-
}
|
|
1351
|
-
};
|
|
1352
|
-
const MdastInlineCodeVisitor = {
|
|
1353
|
-
testNode: "inlineCode",
|
|
1354
|
-
visitNode({ mdastNode, actions }) {
|
|
1355
|
-
actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(IS_CODE));
|
|
1356
|
-
}
|
|
1357
|
-
};
|
|
1358
|
-
const MdastCodeVisitor = {
|
|
1359
|
-
testNode: "code",
|
|
1360
|
-
visitNode({ mdastNode, actions }) {
|
|
1361
|
-
var _a;
|
|
1362
|
-
const constructor = ((_a = mdastNode.meta) == null ? void 0 : _a.startsWith("live")) ? $createSandpackNode : $createCodeBlockNode;
|
|
1363
|
-
actions.addAndStepInto(
|
|
1364
|
-
constructor({
|
|
1365
|
-
code: mdastNode.value,
|
|
1366
|
-
language: mdastNode.lang,
|
|
1367
|
-
meta: mdastNode.meta
|
|
1368
|
-
})
|
|
1369
|
-
);
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
const MdastTextVisitor = {
|
|
1373
|
-
testNode: "text",
|
|
1374
|
-
visitNode({ mdastNode, actions }) {
|
|
1375
|
-
actions.addAndStepInto($createTextNode(mdastNode.value).setFormat(actions.getParentFormatting()));
|
|
1376
|
-
}
|
|
1377
|
-
};
|
|
1378
|
-
const MdastThematicBreakVisitor = {
|
|
1379
|
-
testNode: "thematicBreak",
|
|
1380
|
-
visitNode({ actions }) {
|
|
1381
|
-
actions.addAndStepInto($createHorizontalRuleNode());
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
const MdastImageVisitor = {
|
|
1385
|
-
testNode: "image",
|
|
1386
|
-
visitNode({ mdastNode, actions }) {
|
|
1387
|
-
actions.addAndStepInto(
|
|
1388
|
-
$createImageNode({
|
|
1389
|
-
src: mdastNode.url,
|
|
1390
|
-
altText: mdastNode.alt || "",
|
|
1391
|
-
title: mdastNode.title || ""
|
|
1392
|
-
})
|
|
1393
|
-
);
|
|
1394
|
-
}
|
|
1395
|
-
};
|
|
1396
|
-
const MdastFrontmatterVisitor = {
|
|
1397
|
-
testNode: "yaml",
|
|
1398
|
-
visitNode({ mdastNode, actions }) {
|
|
1399
|
-
actions.addAndStepInto($createFrontmatterNode(mdastNode.value));
|
|
1400
|
-
}
|
|
1401
|
-
};
|
|
1402
|
-
const MdastMdxJsEsmVisitor = {
|
|
1403
|
-
testNode: "mdxjsEsm",
|
|
1404
|
-
visitNode() {
|
|
1405
|
-
}
|
|
1406
|
-
};
|
|
1407
|
-
const MdastMdxJsxElementVisitor = {
|
|
1408
|
-
testNode: (node) => {
|
|
1409
|
-
return node.type === "mdxJsxTextElement" || node.type === "mdxJsxFlowElement";
|
|
1410
|
-
},
|
|
1411
|
-
visitNode({ lexicalParent, mdastNode, actions }) {
|
|
1412
|
-
lexicalParent.append(
|
|
1413
|
-
$createJsxNode({
|
|
1414
|
-
name: mdastNode.name,
|
|
1415
|
-
kind: mdastNode.type === "mdxJsxTextElement" ? "text" : "flow",
|
|
1416
|
-
//TODO: expressions are not supported yet
|
|
1417
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
1418
|
-
attributes: mdastNode.attributes,
|
|
1419
|
-
updateFn: (lexicalParent2) => {
|
|
1420
|
-
actions.visitChildren(mdastNode, lexicalParent2);
|
|
1421
|
-
}
|
|
1422
|
-
})
|
|
1423
|
-
);
|
|
1424
|
-
}
|
|
1425
|
-
};
|
|
1426
|
-
const defaultMdastVisitors = {
|
|
1427
|
-
MdastRootVisitor,
|
|
1428
|
-
MdastParagraphVisitor,
|
|
1429
|
-
MdastTextVisitor,
|
|
1430
|
-
MdastFormattingVisitor,
|
|
1431
|
-
MdastInlineCodeVisitor,
|
|
1432
|
-
MdastLinkVisitor,
|
|
1433
|
-
MdastHeadingVisitor,
|
|
1434
|
-
MdastListVisitor,
|
|
1435
|
-
MdastListItemVisitor,
|
|
1436
|
-
MdastBlockQuoteVisitor,
|
|
1437
|
-
MdastCodeVisitor,
|
|
1438
|
-
MdastThematicBreakVisitor,
|
|
1439
|
-
MdastImageVisitor,
|
|
1440
|
-
MdastFrontmatterVisitor,
|
|
1441
|
-
MdastAdmonitionVisitor,
|
|
1442
|
-
MdastMdxJsEsmVisitor,
|
|
1443
|
-
MdastMdxJsxElementVisitor,
|
|
1444
|
-
MdastTableVisitor
|
|
1445
|
-
};
|
|
1446
|
-
function isParent(node) {
|
|
1447
|
-
return node.children instanceof Array;
|
|
1448
|
-
}
|
|
1449
|
-
const defaultMdastExtensions = {
|
|
1450
|
-
mdxFromMarkdown: mdxFromMarkdown(),
|
|
1451
|
-
frontmatterFromMarkdown: frontmatterFromMarkdown("yaml"),
|
|
1452
|
-
directiveFromMarkdown,
|
|
1453
|
-
gfmTableFromMarkdown
|
|
1454
|
-
};
|
|
1455
|
-
const defaultSyntaxExtensions = {
|
|
1456
|
-
mdxjs: mdxjs(),
|
|
1457
|
-
frontmatter: frontmatter(),
|
|
1458
|
-
directive: directive(),
|
|
1459
|
-
gfmTable
|
|
1460
|
-
};
|
|
1461
|
-
function importMarkdownToLexical({ root, markdown: markdown2, visitors, syntaxExtensions, mdastExtensions }) {
|
|
1462
|
-
const mdastRoot = fromMarkdown(markdown2, {
|
|
1463
|
-
extensions: syntaxExtensions,
|
|
1464
|
-
mdastExtensions
|
|
1465
|
-
});
|
|
1466
|
-
if (mdastRoot.children.length === 0) {
|
|
1467
|
-
mdastRoot.children.push({ type: "paragraph", children: [] });
|
|
1468
|
-
}
|
|
1469
|
-
importMdastTreeToLexical({ root, mdastRoot, visitors });
|
|
1470
|
-
}
|
|
1471
|
-
function importMdastTreeToLexical({ root, mdastRoot, visitors }) {
|
|
1472
|
-
const formattingMap = /* @__PURE__ */ new WeakMap();
|
|
1473
|
-
function visitChildren(mdastNode, lexicalParent) {
|
|
1474
|
-
if (!isParent(mdastNode)) {
|
|
1475
|
-
throw new Error("Attempting to visit children of a non-parent");
|
|
1476
|
-
}
|
|
1477
|
-
mdastNode.children.forEach((child) => visit(child, lexicalParent, mdastNode));
|
|
1478
|
-
}
|
|
1479
|
-
function visit(mdastNode, lexicalParent, mdastParent) {
|
|
1480
|
-
const visitor = visitors.find((visitor2) => {
|
|
1481
|
-
if (typeof visitor2.testNode === "string") {
|
|
1482
|
-
return visitor2.testNode === mdastNode.type;
|
|
1483
|
-
}
|
|
1484
|
-
return visitor2.testNode(mdastNode);
|
|
1485
|
-
});
|
|
1486
|
-
if (!visitor) {
|
|
1487
|
-
throw new Error(`no unist visitor found for ${mdastNode.type}`, {
|
|
1488
|
-
cause: mdastNode
|
|
1489
|
-
});
|
|
1490
|
-
}
|
|
1491
|
-
visitor.visitNode({
|
|
1492
|
-
//@ts-expect-error root type is glitching
|
|
1493
|
-
mdastNode,
|
|
1494
|
-
lexicalParent,
|
|
1495
|
-
actions: {
|
|
1496
|
-
visitChildren,
|
|
1497
|
-
addAndStepInto(lexicalNode) {
|
|
1498
|
-
lexicalParent.append(lexicalNode);
|
|
1499
|
-
if (isParent(mdastNode)) {
|
|
1500
|
-
visitChildren(mdastNode, lexicalNode);
|
|
1501
|
-
}
|
|
1502
|
-
},
|
|
1503
|
-
addFormatting(format) {
|
|
1504
|
-
formattingMap.set(mdastNode, format | (formattingMap.get(mdastParent) ?? 0));
|
|
1505
|
-
},
|
|
1506
|
-
getParentFormatting() {
|
|
1507
|
-
return formattingMap.get(mdastParent) ?? 0;
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
});
|
|
1511
|
-
}
|
|
1512
|
-
visit(mdastRoot, root, null);
|
|
1513
|
-
}
|
|
1514
|
-
const defaultLexicalNodes = {
|
|
1515
|
-
ParagraphNode,
|
|
1516
|
-
LinkNode,
|
|
1517
|
-
HeadingNode,
|
|
1518
|
-
QuoteNode,
|
|
1519
|
-
ListNode,
|
|
1520
|
-
ListItemNode,
|
|
1521
|
-
HorizontalRuleNode,
|
|
1522
|
-
ImageNode,
|
|
1523
|
-
SandpackNode,
|
|
1524
|
-
CodeBlockNode,
|
|
1525
|
-
FrontmatterNode,
|
|
1526
|
-
AdmonitionNode,
|
|
1527
|
-
JsxNode,
|
|
1528
|
-
CodeNode,
|
|
1529
|
-
// this one should not be used, but markdown shortcuts complain about it
|
|
1530
|
-
TableNode
|
|
1531
|
-
};
|
|
1532
|
-
function uuidv4() {
|
|
1533
|
-
const hex = [...Array(256).keys()].map((index2) => index2.toString(16).padStart(2, "0"));
|
|
1534
|
-
const r = crypto.getRandomValues(new Uint8Array(16));
|
|
1535
|
-
r[6] = r[6] & 15 | 64;
|
|
1536
|
-
r[8] = r[8] & 63 | 128;
|
|
1537
|
-
return [...r.entries()].map(([index2, int]) => [4, 6, 8, 10].includes(index2) ? `-${hex[int]}` : hex[int]).join("");
|
|
1538
|
-
}
|
|
1539
|
-
function defaultComparator(current, next) {
|
|
1540
|
-
return current === next;
|
|
1541
|
-
}
|
|
1542
|
-
class SetMap {
|
|
1543
|
-
constructor() {
|
|
1544
|
-
__publicField(this, "map", /* @__PURE__ */ new Map());
|
|
1545
|
-
}
|
|
1546
|
-
getOrCreate(key) {
|
|
1547
|
-
let record = this.map.get(key);
|
|
1548
|
-
if (!record) {
|
|
1549
|
-
record = /* @__PURE__ */ new Set();
|
|
1550
|
-
this.map.set(key, record);
|
|
1551
|
-
}
|
|
1552
|
-
return record;
|
|
1553
|
-
}
|
|
1554
|
-
get(key) {
|
|
1555
|
-
return this.map.get(key);
|
|
1556
|
-
}
|
|
1557
|
-
use(key, cb) {
|
|
1558
|
-
const set = this.get(key);
|
|
1559
|
-
if (set !== void 0) {
|
|
1560
|
-
cb(set);
|
|
1561
|
-
}
|
|
1562
|
-
}
|
|
1563
|
-
delete(key) {
|
|
1564
|
-
return this.map.delete(key);
|
|
1565
|
-
}
|
|
1566
|
-
}
|
|
1567
|
-
class RefCount {
|
|
1568
|
-
constructor(map = /* @__PURE__ */ new Map()) {
|
|
1569
|
-
__publicField(this, "map");
|
|
1570
|
-
this.map = map;
|
|
1571
|
-
}
|
|
1572
|
-
clone() {
|
|
1573
|
-
return new RefCount(new Map(this.map));
|
|
1574
|
-
}
|
|
1575
|
-
increment(key) {
|
|
1576
|
-
const counter = this.map.get(key) ?? 0;
|
|
1577
|
-
this.map.set(key, counter + 1);
|
|
1578
|
-
}
|
|
1579
|
-
decrement(key, ifZero) {
|
|
1580
|
-
let counter = this.map.get(key);
|
|
1581
|
-
if (counter !== void 0) {
|
|
1582
|
-
counter -= 1;
|
|
1583
|
-
this.map.set(key, counter);
|
|
1584
|
-
if (counter === 0) {
|
|
1585
|
-
ifZero();
|
|
1586
|
-
}
|
|
1587
|
-
}
|
|
1588
|
-
}
|
|
1589
|
-
}
|
|
1590
|
-
const NO_VALUE = Symbol("NO_VALUE");
|
|
1591
|
-
function realm() {
|
|
1592
|
-
const subscriptions = new SetMap();
|
|
1593
|
-
const singletonSubscriptions = /* @__PURE__ */ new Map();
|
|
1594
|
-
const graph = new SetMap();
|
|
1595
|
-
const state = /* @__PURE__ */ new Map();
|
|
1596
|
-
const distinctNodes = /* @__PURE__ */ new Map();
|
|
1597
|
-
const labels = {};
|
|
1598
|
-
function node(value = NO_VALUE, distinct = false) {
|
|
1599
|
-
const key = uuidv4();
|
|
1600
|
-
if (value !== NO_VALUE) {
|
|
1601
|
-
state.set(key, value);
|
|
1602
|
-
}
|
|
1603
|
-
if (distinct !== false) {
|
|
1604
|
-
distinctNodes.set(key, distinct === true ? defaultComparator : distinct);
|
|
1605
|
-
}
|
|
1606
|
-
return { key, toString: () => key };
|
|
1607
|
-
}
|
|
1608
|
-
function subSingle({ key }, subscription) {
|
|
1609
|
-
const nodeSubscriptions = subscriptions.getOrCreate(key);
|
|
1610
|
-
nodeSubscriptions.add(subscription);
|
|
1611
|
-
return () => nodeSubscriptions.delete(subscription);
|
|
1612
|
-
}
|
|
1613
|
-
function singletonSub({ key }, subscription) {
|
|
1614
|
-
singletonSubscriptions.set(key, subscription);
|
|
1615
|
-
return () => singletonSubscriptions.delete(key);
|
|
1616
|
-
}
|
|
1617
|
-
function singletonSubKey(key, subscription) {
|
|
1618
|
-
return singletonSub(labels[key], subscription);
|
|
1619
|
-
}
|
|
1620
|
-
function resetSingletonSubs() {
|
|
1621
|
-
singletonSubscriptions.clear();
|
|
1622
|
-
}
|
|
1623
|
-
function subMultiple(sources, cb) {
|
|
1624
|
-
const sink = node();
|
|
1625
|
-
connect({
|
|
1626
|
-
map: (done) => (...args) => {
|
|
1627
|
-
done(args);
|
|
1628
|
-
},
|
|
1629
|
-
sink,
|
|
1630
|
-
sources
|
|
1631
|
-
});
|
|
1632
|
-
return subSingle(sink, cb);
|
|
1633
|
-
}
|
|
1634
|
-
function sub(...args) {
|
|
1635
|
-
const [subscription] = args.slice(-1);
|
|
1636
|
-
const nodes = args.slice(0, -1);
|
|
1637
|
-
if (nodes.length === 1) {
|
|
1638
|
-
return subSingle(nodes[0], subscription);
|
|
1639
|
-
} else {
|
|
1640
|
-
return subMultiple(nodes, subscription);
|
|
1641
|
-
}
|
|
1642
|
-
}
|
|
1643
|
-
function calculateExecutionMap(keys) {
|
|
1644
|
-
const participatingNodeKeys = [];
|
|
1645
|
-
const visitedNodes = /* @__PURE__ */ new Set();
|
|
1646
|
-
const pendingPulls = new SetMap();
|
|
1647
|
-
const refCount = new RefCount();
|
|
1648
|
-
const projections = new SetMap();
|
|
1649
|
-
function visit(key, insertIndex = 0) {
|
|
1650
|
-
refCount.increment(key);
|
|
1651
|
-
if (visitedNodes.has(key)) {
|
|
1652
|
-
return;
|
|
1653
|
-
}
|
|
1654
|
-
pendingPulls.use(key, (pulls) => {
|
|
1655
|
-
insertIndex = Math.max(...Array.from(pulls).map((key2) => participatingNodeKeys.indexOf(key2))) + 1;
|
|
1656
|
-
});
|
|
1657
|
-
graph.use(key, (sinkProjections) => {
|
|
1658
|
-
sinkProjections.forEach((projection) => {
|
|
1659
|
-
if (projection.sources.has(key)) {
|
|
1660
|
-
projections.getOrCreate(projection.sink).add(projection);
|
|
1661
|
-
visit(projection.sink, insertIndex);
|
|
1662
|
-
} else {
|
|
1663
|
-
pendingPulls.getOrCreate(projection.sink).add(key);
|
|
1664
|
-
}
|
|
1665
|
-
});
|
|
1666
|
-
});
|
|
1667
|
-
visitedNodes.add(key);
|
|
1668
|
-
participatingNodeKeys.splice(insertIndex, 0, key);
|
|
1669
|
-
}
|
|
1670
|
-
keys.forEach((key) => visit(key));
|
|
1671
|
-
return { participatingNodeKeys, pendingPulls, projections, refCount };
|
|
1672
|
-
}
|
|
1673
|
-
const executionMaps = /* @__PURE__ */ new Map();
|
|
1674
|
-
function pubIn(values) {
|
|
1675
|
-
var _a;
|
|
1676
|
-
const keys = Object.keys(values);
|
|
1677
|
-
const executionMapKey = keys.join(",");
|
|
1678
|
-
if (!executionMaps.has(executionMapKey)) {
|
|
1679
|
-
executionMaps.set(executionMapKey, calculateExecutionMap(keys));
|
|
1680
|
-
}
|
|
1681
|
-
const map2 = executionMaps.get(executionMapKey);
|
|
1682
|
-
const refCount = map2.refCount.clone();
|
|
1683
|
-
const participatingNodeKeys = map2.participatingNodeKeys.slice();
|
|
1684
|
-
const transientState = new Map(state);
|
|
1685
|
-
function nodeWillNotEmit(key) {
|
|
1686
|
-
graph.use(key, (projections) => {
|
|
1687
|
-
projections.forEach(({ sources, sink }) => {
|
|
1688
|
-
if (sources.has(key)) {
|
|
1689
|
-
refCount.decrement(sink, () => {
|
|
1690
|
-
participatingNodeKeys.splice(participatingNodeKeys.indexOf(sink), 1);
|
|
1691
|
-
nodeWillNotEmit(sink);
|
|
1692
|
-
});
|
|
1693
|
-
}
|
|
1694
|
-
});
|
|
1695
|
-
});
|
|
1696
|
-
}
|
|
1697
|
-
let nodeKey;
|
|
1698
|
-
while (nodeKey = participatingNodeKeys.shift()) {
|
|
1699
|
-
let resolved = false;
|
|
1700
|
-
const done = (value) => {
|
|
1701
|
-
if (distinctNodes.has(nodeKey) && distinctNodes.get(nodeKey)(state.get(nodeKey), value)) {
|
|
1702
|
-
resolved = false;
|
|
1703
|
-
return;
|
|
1704
|
-
}
|
|
1705
|
-
resolved = true;
|
|
1706
|
-
transientState.set(nodeKey, value);
|
|
1707
|
-
if (state.has(nodeKey)) {
|
|
1708
|
-
state.set(nodeKey, value);
|
|
1709
|
-
}
|
|
1710
|
-
};
|
|
1711
|
-
if (Object.prototype.hasOwnProperty.call(values, nodeKey)) {
|
|
1712
|
-
done(values[nodeKey]);
|
|
1713
|
-
} else {
|
|
1714
|
-
map2.projections.use(nodeKey, (nodeProjections) => {
|
|
1715
|
-
nodeProjections.forEach((projection) => {
|
|
1716
|
-
const args = [...Array.from(projection.sources), ...Array.from(projection.pulls)].map((id) => transientState.get(id));
|
|
1717
|
-
projection.map(done)(...args);
|
|
1718
|
-
});
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
if (resolved) {
|
|
1722
|
-
const value = transientState.get(nodeKey);
|
|
1723
|
-
subscriptions.use(nodeKey, (nodeSubscriptions) => {
|
|
1724
|
-
nodeSubscriptions.forEach((subscription) => subscription(value));
|
|
1725
|
-
});
|
|
1726
|
-
(_a = singletonSubscriptions.get(nodeKey)) == null ? void 0 : _a(value);
|
|
1727
|
-
} else {
|
|
1728
|
-
nodeWillNotEmit(nodeKey);
|
|
1729
|
-
}
|
|
1730
|
-
}
|
|
1731
|
-
}
|
|
1732
|
-
function nodesToKeySet(nodes) {
|
|
1733
|
-
return new Set(nodes.map((s) => s.key));
|
|
1734
|
-
}
|
|
1735
|
-
function connect({ sources, pulls = [], map: map2, sink: { key: sink } }) {
|
|
1736
|
-
const dependency = {
|
|
1737
|
-
map: map2,
|
|
1738
|
-
pulls: nodesToKeySet(pulls),
|
|
1739
|
-
sink,
|
|
1740
|
-
sources: nodesToKeySet(sources)
|
|
1741
|
-
};
|
|
1742
|
-
[...sources, ...pulls].forEach(({ key: sourceKey }) => {
|
|
1743
|
-
graph.getOrCreate(sourceKey).add(dependency);
|
|
1744
|
-
});
|
|
1745
|
-
executionMaps.clear();
|
|
1746
|
-
}
|
|
1747
|
-
function debug() {
|
|
1748
|
-
Object.entries(labels).forEach(([name, value]) => {
|
|
1749
|
-
state.get(value.key);
|
|
1750
|
-
});
|
|
1751
|
-
}
|
|
1752
|
-
function pub(...args) {
|
|
1753
|
-
const map2 = {};
|
|
1754
|
-
for (let index2 = 0; index2 < args.length; index2 += 2) {
|
|
1755
|
-
const node2 = args[index2];
|
|
1756
|
-
map2[node2.key] = args[index2 + 1];
|
|
1757
|
-
}
|
|
1758
|
-
pubIn(map2);
|
|
1759
|
-
}
|
|
1760
|
-
function label(newLabels) {
|
|
1761
|
-
Object.assign(labels, newLabels);
|
|
1762
|
-
}
|
|
1763
|
-
function pipe(source, ...operators) {
|
|
1764
|
-
for (const operator of operators) {
|
|
1765
|
-
source = operator(source);
|
|
1766
|
-
}
|
|
1767
|
-
return source;
|
|
1768
|
-
}
|
|
1769
|
-
function spread(source, initialValues) {
|
|
1770
|
-
return initialValues.map((initialValue, index2) => {
|
|
1771
|
-
return tap(node(initialValue, true), (sink) => {
|
|
1772
|
-
connect({
|
|
1773
|
-
map: (done) => (sourceValue) => {
|
|
1774
|
-
done(sourceValue[index2]);
|
|
1775
|
-
},
|
|
1776
|
-
sink,
|
|
1777
|
-
sources: [source]
|
|
1778
|
-
});
|
|
1779
|
-
});
|
|
1780
|
-
});
|
|
1781
|
-
}
|
|
1782
|
-
function link(source, sink) {
|
|
1783
|
-
connect({ map: (done) => (value) => done(value), sink, sources: [source] });
|
|
1784
|
-
}
|
|
1785
|
-
function derive(source, initial) {
|
|
1786
|
-
return tap(node(initial, true), (sink) => {
|
|
1787
|
-
connect({ map: (done) => (value) => done(value), sink, sources: [source] });
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
function map(mapFunction) {
|
|
1791
|
-
return (source) => {
|
|
1792
|
-
const sink = node();
|
|
1793
|
-
connect({
|
|
1794
|
-
map: (done) => (value) => {
|
|
1795
|
-
done(mapFunction(value));
|
|
1796
|
-
},
|
|
1797
|
-
sink,
|
|
1798
|
-
sources: [source]
|
|
1799
|
-
});
|
|
1800
|
-
return sink;
|
|
1801
|
-
};
|
|
1802
|
-
}
|
|
1803
|
-
function mapTo(value) {
|
|
1804
|
-
return (source) => {
|
|
1805
|
-
const sink = node();
|
|
1806
|
-
connect({ map: (done) => () => done(value), sink, sources: [source] });
|
|
1807
|
-
return sink;
|
|
1808
|
-
};
|
|
1809
|
-
}
|
|
1810
|
-
function filter(predicate) {
|
|
1811
|
-
return (source) => {
|
|
1812
|
-
const sink = node();
|
|
1813
|
-
connect({ map: (done) => (value) => predicate(value) && done(value), sink, sources: [source] });
|
|
1814
|
-
return sink;
|
|
1815
|
-
};
|
|
1816
|
-
}
|
|
1817
|
-
function once() {
|
|
1818
|
-
return (source) => {
|
|
1819
|
-
const sink = node();
|
|
1820
|
-
let passed = false;
|
|
1821
|
-
connect({
|
|
1822
|
-
map: (done) => (value) => {
|
|
1823
|
-
if (!passed) {
|
|
1824
|
-
passed = true;
|
|
1825
|
-
done(value);
|
|
1826
|
-
}
|
|
1827
|
-
},
|
|
1828
|
-
sink,
|
|
1829
|
-
sources: [source]
|
|
1830
|
-
});
|
|
1831
|
-
return sink;
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
function scan(accumulator, seed) {
|
|
1835
|
-
return (source) => {
|
|
1836
|
-
const sink = node();
|
|
1837
|
-
connect({ map: (done) => (value) => done(seed = accumulator(seed, value)), sink, sources: [source] });
|
|
1838
|
-
return sink;
|
|
1839
|
-
};
|
|
1840
|
-
}
|
|
1841
|
-
function throttleTime(delay) {
|
|
1842
|
-
return (source) => {
|
|
1843
|
-
const sink = node();
|
|
1844
|
-
let currentValue;
|
|
1845
|
-
let timeout;
|
|
1846
|
-
sub(source, (value) => {
|
|
1847
|
-
currentValue = value;
|
|
1848
|
-
if (timeout) {
|
|
1849
|
-
return;
|
|
1850
|
-
}
|
|
1851
|
-
timeout = setTimeout(() => {
|
|
1852
|
-
timeout = void 0;
|
|
1853
|
-
pub(sink, currentValue);
|
|
1854
|
-
}, delay);
|
|
1855
|
-
});
|
|
1856
|
-
return sink;
|
|
1857
|
-
};
|
|
1858
|
-
}
|
|
1859
|
-
function delayWithMicrotask() {
|
|
1860
|
-
return (source) => {
|
|
1861
|
-
const sink = node();
|
|
1862
|
-
sub(source, (value) => queueMicrotask(() => pub(sink, value)));
|
|
1863
|
-
return sink;
|
|
1864
|
-
};
|
|
1865
|
-
}
|
|
1866
|
-
function debounceTime(delay) {
|
|
1867
|
-
return (source) => {
|
|
1868
|
-
const sink = node();
|
|
1869
|
-
let currentValue;
|
|
1870
|
-
let timeout;
|
|
1871
|
-
sub(source, (value) => {
|
|
1872
|
-
currentValue = value;
|
|
1873
|
-
if (timeout) {
|
|
1874
|
-
clearTimeout(timeout);
|
|
1875
|
-
}
|
|
1876
|
-
timeout = setTimeout(() => {
|
|
1877
|
-
pub(sink, currentValue);
|
|
1878
|
-
}, delay);
|
|
1879
|
-
});
|
|
1880
|
-
return sink;
|
|
1881
|
-
};
|
|
1882
|
-
}
|
|
1883
|
-
function onNext(bufNode) {
|
|
1884
|
-
return (source) => {
|
|
1885
|
-
const sink = node();
|
|
1886
|
-
let pendingValue = NO_VALUE;
|
|
1887
|
-
sub(source, (value) => pendingValue = value);
|
|
1888
|
-
connect({
|
|
1889
|
-
map: (done) => (value) => {
|
|
1890
|
-
if (pendingValue !== NO_VALUE) {
|
|
1891
|
-
done([pendingValue, value]);
|
|
1892
|
-
pendingValue = NO_VALUE;
|
|
1893
|
-
}
|
|
1894
|
-
},
|
|
1895
|
-
sink,
|
|
1896
|
-
sources: [bufNode]
|
|
1897
|
-
});
|
|
1898
|
-
return sink;
|
|
1899
|
-
};
|
|
1900
|
-
}
|
|
1901
|
-
function passOnlyAfterNodeHasEmittedBefore(starterNode, durationNode) {
|
|
1902
|
-
return (source) => {
|
|
1903
|
-
const sink = node();
|
|
1904
|
-
let startTime = 0;
|
|
1905
|
-
sub(starterNode, () => startTime = Date.now());
|
|
1906
|
-
connect({
|
|
1907
|
-
map: (done) => (value) => {
|
|
1908
|
-
if (Date.now() < startTime + state.get(durationNode.key)) {
|
|
1909
|
-
done(value);
|
|
1910
|
-
}
|
|
1911
|
-
},
|
|
1912
|
-
sink,
|
|
1913
|
-
sources: [source]
|
|
1914
|
-
});
|
|
1915
|
-
return sink;
|
|
1916
|
-
};
|
|
1917
|
-
}
|
|
1918
|
-
function withLatestFrom(...nodes) {
|
|
1919
|
-
return (source) => {
|
|
1920
|
-
const sink = node();
|
|
1921
|
-
connect({
|
|
1922
|
-
map: (done) => (...args) => done(args),
|
|
1923
|
-
pulls: nodes,
|
|
1924
|
-
sink,
|
|
1925
|
-
sources: [source]
|
|
1926
|
-
});
|
|
1927
|
-
return sink;
|
|
1928
|
-
};
|
|
1929
|
-
}
|
|
1930
|
-
function combine(...nodes) {
|
|
1931
|
-
const sink = node();
|
|
1932
|
-
connect({
|
|
1933
|
-
map: (done) => (...args) => done(args),
|
|
1934
|
-
sink,
|
|
1935
|
-
sources: nodes
|
|
1936
|
-
});
|
|
1937
|
-
return sink;
|
|
1938
|
-
}
|
|
1939
|
-
function subKey(key, subscription) {
|
|
1940
|
-
return sub(labels[key], subscription);
|
|
1941
|
-
}
|
|
1942
|
-
function subKeys(keys, subscription) {
|
|
1943
|
-
const nodes = keys.map((key) => labels[key]);
|
|
1944
|
-
return sub(...nodes.concat(subscription));
|
|
1945
|
-
}
|
|
1946
|
-
function pubKey(key, value) {
|
|
1947
|
-
pubKeys({ [key]: value });
|
|
1948
|
-
}
|
|
1949
|
-
function pubKeys(values) {
|
|
1950
|
-
const valuesWithInternalKeys = Object.entries(values).reduce(
|
|
1951
|
-
(acc, [key, value]) => tap(acc, (acc2) => acc2[labels[key].key] = value),
|
|
1952
|
-
{}
|
|
1953
|
-
);
|
|
1954
|
-
pubIn(valuesWithInternalKeys);
|
|
1955
|
-
}
|
|
1956
|
-
function getKeyValue(key) {
|
|
1957
|
-
return state.get(labels[key].key);
|
|
1958
|
-
}
|
|
1959
|
-
function getValue(node2) {
|
|
1960
|
-
return state.get(node2.key);
|
|
1961
|
-
}
|
|
1962
|
-
function getKeyValues(keys) {
|
|
1963
|
-
return keys.map((key) => state.get(labels[key].key));
|
|
1964
|
-
}
|
|
1965
|
-
return {
|
|
1966
|
-
combine,
|
|
1967
|
-
connect,
|
|
1968
|
-
debug,
|
|
1969
|
-
derive,
|
|
1970
|
-
getKeyValue,
|
|
1971
|
-
getValue,
|
|
1972
|
-
getKeyValues,
|
|
1973
|
-
label,
|
|
1974
|
-
labels,
|
|
1975
|
-
link,
|
|
1976
|
-
node,
|
|
1977
|
-
o: {
|
|
1978
|
-
delayWithMicrotask,
|
|
1979
|
-
debounceTime,
|
|
1980
|
-
filter,
|
|
1981
|
-
map,
|
|
1982
|
-
mapTo,
|
|
1983
|
-
onNext,
|
|
1984
|
-
scan,
|
|
1985
|
-
throttleTime,
|
|
1986
|
-
withLatestFrom,
|
|
1987
|
-
once,
|
|
1988
|
-
passOnlyAfterNodeHasEmittedBefore
|
|
1989
|
-
},
|
|
1990
|
-
pipe,
|
|
1991
|
-
pub,
|
|
1992
|
-
pubIn,
|
|
1993
|
-
pubKey,
|
|
1994
|
-
pubKeys,
|
|
1995
|
-
resetSingletonSubs,
|
|
1996
|
-
singletonSub,
|
|
1997
|
-
singletonSubKey,
|
|
1998
|
-
spread,
|
|
1999
|
-
sub,
|
|
2000
|
-
subKey,
|
|
2001
|
-
subKeys
|
|
2002
|
-
};
|
|
2003
|
-
}
|
|
2004
|
-
function omit(keys, obj) {
|
|
2005
|
-
const result = {};
|
|
2006
|
-
const index2 = {};
|
|
2007
|
-
let idx = 0;
|
|
2008
|
-
const len = keys.length;
|
|
2009
|
-
while (idx < len) {
|
|
2010
|
-
index2[keys[idx]] = 1;
|
|
2011
|
-
idx += 1;
|
|
2012
|
-
}
|
|
2013
|
-
for (const prop in obj) {
|
|
2014
|
-
if (!Object.prototype.hasOwnProperty.call(index2, prop)) {
|
|
2015
|
-
result[prop] = obj[prop];
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
return result;
|
|
2019
|
-
}
|
|
2020
|
-
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
2021
|
-
const GurxContext = createContext(void 0);
|
|
2022
|
-
function realmFactoryToComponent(realmFactory2, map, Root) {
|
|
2023
|
-
const requiredPropNames = Object.keys(map.required || {});
|
|
2024
|
-
const optionalPropNames = Object.keys(map.optional || {});
|
|
2025
|
-
const methodNames = Object.keys(map.methods || {});
|
|
2026
|
-
const eventNames = Object.keys(map.events || {});
|
|
2027
|
-
const Context = GurxContext;
|
|
2028
|
-
function applyPropsToRealm(realm2, props) {
|
|
2029
|
-
const toBePublished = {};
|
|
2030
|
-
for (const requiredPropName of requiredPropNames) {
|
|
2031
|
-
const nodeName = map.required[requiredPropName];
|
|
2032
|
-
toBePublished[nodeName] = props[requiredPropName];
|
|
2033
|
-
}
|
|
2034
|
-
for (const optionalPropName of optionalPropNames) {
|
|
2035
|
-
const value = props[optionalPropName];
|
|
2036
|
-
if (value !== void 0) {
|
|
2037
|
-
const nodeName = map.optional[optionalPropName];
|
|
2038
|
-
toBePublished[nodeName] = value;
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
|
-
realm2.suppressFlushSync = true;
|
|
2042
|
-
realm2.pubKeys(toBePublished);
|
|
2043
|
-
realm2.suppressFlushSync = false;
|
|
2044
|
-
}
|
|
2045
|
-
function buildMethods(realm2) {
|
|
2046
|
-
return methodNames.reduce((acc, methodName) => {
|
|
2047
|
-
const nodeName = map.methods[methodName];
|
|
2048
|
-
acc[methodName] = (value) => {
|
|
2049
|
-
realm2.pubKey(nodeName, value);
|
|
2050
|
-
};
|
|
2051
|
-
return acc;
|
|
2052
|
-
}, {});
|
|
2053
|
-
}
|
|
2054
|
-
const Component = forwardRef((props, ref) => {
|
|
2055
|
-
const realm2 = useMemo(() => {
|
|
2056
|
-
return tap(realmFactory2(), (realm22) => applyPropsToRealm(realm22, props));
|
|
2057
|
-
}, []);
|
|
2058
|
-
useIsomorphicLayoutEffect(() => {
|
|
2059
|
-
applyPropsToRealm(realm2, props);
|
|
2060
|
-
realm2.resetSingletonSubs();
|
|
2061
|
-
for (const eventName of eventNames) {
|
|
2062
|
-
if (eventName in props) {
|
|
2063
|
-
realm2.singletonSubKey(map.events[eventName], props[eventName]);
|
|
2064
|
-
}
|
|
2065
|
-
}
|
|
2066
|
-
return () => {
|
|
2067
|
-
realm2.resetSingletonSubs();
|
|
2068
|
-
};
|
|
2069
|
-
}, [props]);
|
|
2070
|
-
useImperativeHandle(ref, always(buildMethods(realm2)));
|
|
2071
|
-
const children = props.children;
|
|
2072
|
-
return createElement(
|
|
2073
|
-
Context.Provider,
|
|
2074
|
-
{ value: realm2 },
|
|
2075
|
-
Root ? createElement(
|
|
2076
|
-
Root,
|
|
2077
|
-
omit([...requiredPropNames, ...optionalPropNames, ...eventNames], props),
|
|
2078
|
-
children
|
|
2079
|
-
) : children
|
|
2080
|
-
);
|
|
2081
|
-
});
|
|
2082
|
-
Component.displayName = "Gurx Component";
|
|
2083
|
-
const usePublisher2 = (key) => {
|
|
2084
|
-
const realm2 = React.useContext(Context);
|
|
2085
|
-
return useCallback(
|
|
2086
|
-
(value) => {
|
|
2087
|
-
realm2.pubKey(key, value);
|
|
2088
|
-
},
|
|
2089
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
2090
|
-
[key, realm2]
|
|
2091
|
-
);
|
|
2092
|
-
};
|
|
2093
|
-
const useEmitterValues2 = (...keys) => {
|
|
2094
|
-
const realm2 = useContext(Context);
|
|
2095
|
-
const [values, setValues] = useState(() => realm2.getKeyValues(keys));
|
|
2096
|
-
useIsomorphicLayoutEffect(
|
|
2097
|
-
() => realm2 == null ? void 0 : realm2.subKeys(keys, (newValues) => {
|
|
2098
|
-
const setter = () => {
|
|
2099
|
-
setValues(keys.length === 1 ? [newValues] : newValues);
|
|
2100
|
-
};
|
|
2101
|
-
if (realm2.suppressFlushSync) {
|
|
2102
|
-
setter();
|
|
2103
|
-
} else {
|
|
2104
|
-
setter();
|
|
2105
|
-
}
|
|
2106
|
-
}),
|
|
2107
|
-
[keys]
|
|
2108
|
-
);
|
|
2109
|
-
return values;
|
|
2110
|
-
};
|
|
2111
|
-
const usePubKeys = () => {
|
|
2112
|
-
return useContext(Context).pubKeys;
|
|
2113
|
-
};
|
|
2114
|
-
const useEmitter = (key, callback) => {
|
|
2115
|
-
const realm2 = useContext(Context);
|
|
2116
|
-
useIsomorphicLayoutEffect(() => realm2.subKey(key, callback), [callback]);
|
|
2117
|
-
};
|
|
2118
|
-
return {
|
|
2119
|
-
Component,
|
|
2120
|
-
useEmitter,
|
|
2121
|
-
useEmitterValues: useEmitterValues2,
|
|
2122
|
-
usePubKeys,
|
|
2123
|
-
usePublisher: usePublisher2
|
|
2124
|
-
};
|
|
2125
|
-
}
|
|
2126
|
-
function system(constructor, dependencies = [], id = uuidv4()) {
|
|
2127
|
-
return [
|
|
2128
|
-
{
|
|
2129
|
-
constructor,
|
|
2130
|
-
dependencies,
|
|
2131
|
-
id
|
|
2132
|
-
},
|
|
2133
|
-
{ id }
|
|
2134
|
-
];
|
|
2135
|
-
}
|
|
2136
|
-
function realmFactory(...specs) {
|
|
2137
|
-
const singletons = /* @__PURE__ */ new Map();
|
|
2138
|
-
const r = realm();
|
|
2139
|
-
const _init = ({ id, constructor, dependencies }) => {
|
|
2140
|
-
if (singletons.has(id)) {
|
|
2141
|
-
return singletons.get(id);
|
|
2142
|
-
}
|
|
2143
|
-
const system2 = constructor(
|
|
2144
|
-
r,
|
|
2145
|
-
dependencies.map((t) => _init(specs.find((spec) => spec.id === t.id)))
|
|
2146
|
-
);
|
|
2147
|
-
r.label(system2);
|
|
2148
|
-
singletons.set(id, system2);
|
|
2149
|
-
return system2;
|
|
2150
|
-
};
|
|
2151
|
-
specs.forEach(_init);
|
|
2152
|
-
return r;
|
|
2153
|
-
}
|
|
2154
|
-
function getRealmFactory(...specs) {
|
|
2155
|
-
return () => realmFactory(...specs);
|
|
2156
|
-
}
|
|
2157
|
-
const formatParagraph = (editor) => {
|
|
2158
|
-
editor.update(() => {
|
|
2159
|
-
const selection = $getSelection();
|
|
2160
|
-
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection))
|
|
2161
|
-
$setBlocksType(selection, () => $createParagraphNode());
|
|
2162
|
-
});
|
|
2163
|
-
};
|
|
2164
|
-
const formatHeading = (editor, headingType) => {
|
|
2165
|
-
editor.update(() => {
|
|
2166
|
-
const selection = $getSelection();
|
|
2167
|
-
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
2168
|
-
$setBlocksType(selection, () => $createHeadingNode(headingType));
|
|
2169
|
-
}
|
|
2170
|
-
});
|
|
2171
|
-
};
|
|
2172
|
-
const formatQuote = (editor) => {
|
|
2173
|
-
editor.update(() => {
|
|
2174
|
-
const selection = $getSelection();
|
|
2175
|
-
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
2176
|
-
$setBlocksType(selection, () => $createQuoteNode());
|
|
2177
|
-
}
|
|
2178
|
-
});
|
|
2179
|
-
};
|
|
2180
|
-
const formatAdmonition = (editor, kind) => {
|
|
2181
|
-
editor.update(() => {
|
|
2182
|
-
const selection = $getSelection();
|
|
2183
|
-
if ($isRangeSelection(selection) || DEPRECATED_$isGridSelection(selection)) {
|
|
2184
|
-
$setBlocksType(selection, () => {
|
|
2185
|
-
return $createAdmonitionNode(kind);
|
|
2186
|
-
});
|
|
2187
|
-
}
|
|
2188
|
-
});
|
|
2189
|
-
};
|
|
2190
|
-
const ListTypeCommandMap = /* @__PURE__ */ new Map([
|
|
2191
|
-
["number", INSERT_ORDERED_LIST_COMMAND],
|
|
2192
|
-
["bullet", INSERT_UNORDERED_LIST_COMMAND],
|
|
2193
|
-
["", REMOVE_LIST_COMMAND]
|
|
2194
|
-
]);
|
|
2195
|
-
function seedTable() {
|
|
2196
|
-
return {
|
|
2197
|
-
type: "table",
|
|
2198
|
-
children: [
|
|
2199
|
-
{
|
|
2200
|
-
type: "tableRow",
|
|
2201
|
-
children: [{ type: "tableCell", children: [] }]
|
|
2202
|
-
}
|
|
2203
|
-
]
|
|
2204
|
-
};
|
|
2205
|
-
}
|
|
2206
|
-
const [EditorSystem, EditorSystemType] = system((r) => {
|
|
2207
|
-
const editor = r.node(null, true);
|
|
2208
|
-
const markdownSource = r.node("");
|
|
2209
|
-
const historyState = r.node(createEmptyHistoryState());
|
|
2210
|
-
const activeEditor = r.derive(editor, null);
|
|
2211
|
-
const currentFormat = r.node(0, true);
|
|
2212
|
-
const currentSelection = r.node(null);
|
|
2213
|
-
const currentListType = r.node(null);
|
|
2214
|
-
const currentBlockType = r.node(null);
|
|
2215
|
-
const applyFormat = r.node();
|
|
2216
|
-
const applyListType = r.node();
|
|
2217
|
-
const applyBlockType = r.node();
|
|
2218
|
-
const insertHorizontalRule = r.node();
|
|
2219
|
-
const insertTable = r.node();
|
|
2220
|
-
const insertFrontmatter = r.node();
|
|
2221
|
-
const insertImage = r.node();
|
|
2222
|
-
const createEditorSubscription = r.node();
|
|
2223
|
-
const editorSubscriptions = r.node([]);
|
|
2224
|
-
const inFocus = r.node(false, true);
|
|
2225
|
-
const activeEditorType = r.node({ type: "lexical" });
|
|
2226
|
-
const editorRootElementRef = r.node(null);
|
|
2227
|
-
const markdownParseOptions = r.node(null);
|
|
2228
|
-
const lexicalConvertOptions = r.node(null);
|
|
2229
|
-
const lexicalNodes = r.node([]);
|
|
2230
|
-
const imageAutocompleteSuggestions = r.node([]);
|
|
2231
|
-
r.link(
|
|
2232
|
-
r.pipe(
|
|
2233
|
-
createEditorSubscription,
|
|
2234
|
-
r.o.withLatestFrom(editorSubscriptions),
|
|
2235
|
-
r.o.map(([createSubscription, subscriptions]) => {
|
|
2236
|
-
return [...subscriptions, createSubscription];
|
|
2237
|
-
})
|
|
2238
|
-
),
|
|
2239
|
-
editorSubscriptions
|
|
2240
|
-
);
|
|
2241
|
-
r.sub(r.pipe(applyListType, r.o.withLatestFrom(activeEditor)), ([listType, theEditor]) => {
|
|
2242
|
-
theEditor == null ? void 0 : theEditor.dispatchCommand(ListTypeCommandMap.get(listType), void 0);
|
|
2243
|
-
});
|
|
2244
|
-
r.sub(r.pipe(applyFormat, r.o.withLatestFrom(activeEditor)), ([format, theEditor]) => {
|
|
2245
|
-
theEditor == null ? void 0 : theEditor.dispatchCommand(FORMAT_TEXT_COMMAND, format);
|
|
2246
|
-
});
|
|
2247
|
-
r.sub(r.pipe(insertHorizontalRule, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2248
|
-
theEditor == null ? void 0 : theEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
|
|
2249
|
-
});
|
|
2250
|
-
r.sub(r.pipe(insertImage, r.o.withLatestFrom(activeEditor)), ([src, theEditor]) => {
|
|
2251
|
-
theEditor == null ? void 0 : theEditor.getEditorState().read(() => {
|
|
2252
|
-
const selection = $getSelection();
|
|
2253
|
-
if ($isRangeSelection(selection)) {
|
|
2254
|
-
const focusNode = selection.focus.getNode();
|
|
2255
|
-
if (focusNode !== null) {
|
|
2256
|
-
theEditor.update(() => {
|
|
2257
|
-
const imageNode = $createImageNode({ altText: "", src, title: "" });
|
|
2258
|
-
$insertNodeToNearestRoot(imageNode);
|
|
2259
|
-
});
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
});
|
|
2263
|
-
});
|
|
2264
|
-
r.sub(r.pipe(insertFrontmatter, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2265
|
-
theEditor == null ? void 0 : theEditor.update(() => {
|
|
2266
|
-
const firstItem = $getRoot().getFirstChild();
|
|
2267
|
-
if (!$isFrontmatterNode(firstItem)) {
|
|
2268
|
-
const fmNode = $createFrontmatterNode('"": ""');
|
|
2269
|
-
if (firstItem) {
|
|
2270
|
-
firstItem.insertBefore(fmNode);
|
|
2271
|
-
} else {
|
|
2272
|
-
$getRoot().append(fmNode);
|
|
2273
|
-
}
|
|
2274
|
-
}
|
|
2275
|
-
});
|
|
2276
|
-
});
|
|
2277
|
-
r.sub(r.pipe(insertTable, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2278
|
-
theEditor == null ? void 0 : theEditor.getEditorState().read(() => {
|
|
2279
|
-
const selection = $getSelection();
|
|
2280
|
-
if ($isRangeSelection(selection)) {
|
|
2281
|
-
const focusNode = selection.focus.getNode();
|
|
2282
|
-
if (focusNode !== null) {
|
|
2283
|
-
theEditor.update(() => {
|
|
2284
|
-
const tableNode = $createTableNode(seedTable());
|
|
2285
|
-
$insertNodeToNearestRoot(tableNode);
|
|
2286
|
-
setTimeout(() => {
|
|
2287
|
-
tableNode.select([0, 0]);
|
|
2288
|
-
}, 50);
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
});
|
|
2293
|
-
});
|
|
2294
|
-
r.sub(r.pipe(applyBlockType, r.o.withLatestFrom(activeEditor)), ([type, theEditor]) => {
|
|
2295
|
-
if (theEditor) {
|
|
2296
|
-
switch (type) {
|
|
2297
|
-
case "paragraph": {
|
|
2298
|
-
formatParagraph(theEditor);
|
|
2299
|
-
break;
|
|
2300
|
-
}
|
|
2301
|
-
case "quote": {
|
|
2302
|
-
formatQuote(theEditor);
|
|
2303
|
-
break;
|
|
2304
|
-
}
|
|
2305
|
-
case "note":
|
|
2306
|
-
case "tip":
|
|
2307
|
-
case "danger":
|
|
2308
|
-
case "caution":
|
|
2309
|
-
case "info": {
|
|
2310
|
-
formatAdmonition(theEditor, type);
|
|
2311
|
-
break;
|
|
2312
|
-
}
|
|
2313
|
-
default: {
|
|
2314
|
-
formatHeading(theEditor, type);
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
}
|
|
2318
|
-
});
|
|
2319
|
-
r.sub(r.pipe(currentSelection, r.o.withLatestFrom(activeEditor)), ([selection, theEditor]) => {
|
|
2320
|
-
if (!selection || !theEditor) {
|
|
2321
|
-
return;
|
|
2322
|
-
}
|
|
2323
|
-
const anchorNode = selection.anchor.getNode();
|
|
2324
|
-
let element = anchorNode.getKey() === "root" ? anchorNode : $findMatchingParent(anchorNode, (e) => {
|
|
2325
|
-
const parent = e.getParent();
|
|
2326
|
-
return parent !== null && $isRootOrShadowRoot(parent);
|
|
2327
|
-
});
|
|
2328
|
-
if (element === null) {
|
|
2329
|
-
element = anchorNode.getTopLevelElementOrThrow();
|
|
2330
|
-
}
|
|
2331
|
-
const elementKey = element.getKey();
|
|
2332
|
-
const elementDOM = theEditor.getElementByKey(elementKey);
|
|
2333
|
-
if (elementDOM !== null) {
|
|
2334
|
-
if ($isListNode(element)) {
|
|
2335
|
-
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
2336
|
-
const type = parentList ? parentList.getListType() : element.getListType();
|
|
2337
|
-
r.pubIn({
|
|
2338
|
-
[currentListType.key]: type,
|
|
2339
|
-
[currentBlockType.key]: ""
|
|
2340
|
-
});
|
|
2341
|
-
} else {
|
|
2342
|
-
r.pub(currentListType, null);
|
|
2343
|
-
const blockType = $isHeadingNode(element) ? element.getTag() : $isAdmonitionNode(element) ? element.getKind() : element.getType();
|
|
2344
|
-
r.pubIn({
|
|
2345
|
-
[currentListType.key]: null,
|
|
2346
|
-
[currentBlockType.key]: blockType
|
|
2347
|
-
});
|
|
2348
|
-
}
|
|
2349
|
-
}
|
|
2350
|
-
});
|
|
2351
|
-
function handleSelectionChange() {
|
|
2352
|
-
const selection = $getSelection();
|
|
2353
|
-
if ($isRangeSelection(selection)) {
|
|
2354
|
-
r.pubKeys({
|
|
2355
|
-
currentSelection: selection,
|
|
2356
|
-
currentFormat: selection.format
|
|
2357
|
-
});
|
|
2358
|
-
}
|
|
2359
|
-
}
|
|
2360
|
-
r.sub(editor, (theEditor) => {
|
|
2361
|
-
if (theEditor) {
|
|
2362
|
-
theEditor.registerCommand(
|
|
2363
|
-
SELECTION_CHANGE_COMMAND,
|
|
2364
|
-
(_, editor2) => {
|
|
2365
|
-
r.pubIn({
|
|
2366
|
-
[activeEditor.key]: editor2,
|
|
2367
|
-
[inFocus.key]: true
|
|
2368
|
-
});
|
|
2369
|
-
handleSelectionChange();
|
|
2370
|
-
return false;
|
|
2371
|
-
},
|
|
2372
|
-
COMMAND_PRIORITY_CRITICAL
|
|
2373
|
-
);
|
|
2374
|
-
}
|
|
2375
|
-
});
|
|
2376
|
-
r.pipe(
|
|
2377
|
-
r.combine(editorSubscriptions, activeEditor),
|
|
2378
|
-
r.o.scan((teardowns, [editorSubscriptions2, activeEditorValue]) => {
|
|
2379
|
-
teardowns.forEach((u) => u());
|
|
2380
|
-
return activeEditorValue ? editorSubscriptions2.map((s) => s(activeEditorValue, r.getValue(editor))) : [];
|
|
2381
|
-
}, [])
|
|
2382
|
-
);
|
|
2383
|
-
r.pub(createEditorSubscription, (editor2) => {
|
|
2384
|
-
return editor2.registerUpdateListener(({ editorState }) => {
|
|
2385
|
-
editorState.read(() => {
|
|
2386
|
-
handleSelectionChange();
|
|
2387
|
-
});
|
|
2388
|
-
});
|
|
2389
|
-
});
|
|
2390
|
-
r.pub(createEditorSubscription, (theEditor) => {
|
|
2391
|
-
return theEditor.registerCommand(
|
|
2392
|
-
BLUR_COMMAND,
|
|
2393
|
-
(payload) => {
|
|
2394
|
-
var _a;
|
|
2395
|
-
const rootEditor = r.getValue(editor);
|
|
2396
|
-
const movingOutside = !((_a = rootEditor.getRootElement()) == null ? void 0 : _a.contains(payload.relatedTarget));
|
|
2397
|
-
if (movingOutside) {
|
|
2398
|
-
r.pub(inFocus, false);
|
|
2399
|
-
}
|
|
2400
|
-
return false;
|
|
2401
|
-
},
|
|
2402
|
-
COMMAND_PRIORITY_LOW
|
|
2403
|
-
);
|
|
2404
|
-
});
|
|
2405
|
-
return {
|
|
2406
|
-
editor,
|
|
2407
|
-
activeEditor,
|
|
2408
|
-
currentFormat,
|
|
2409
|
-
currentSelection,
|
|
2410
|
-
currentListType,
|
|
2411
|
-
currentBlockType,
|
|
2412
|
-
applyFormat,
|
|
2413
|
-
applyListType,
|
|
2414
|
-
applyBlockType,
|
|
2415
|
-
insertHorizontalRule,
|
|
2416
|
-
insertFrontmatter,
|
|
2417
|
-
insertImage,
|
|
2418
|
-
insertTable,
|
|
2419
|
-
createEditorSubscription,
|
|
2420
|
-
editorSubscriptions,
|
|
2421
|
-
activeEditorType,
|
|
2422
|
-
inFocus,
|
|
2423
|
-
historyState,
|
|
2424
|
-
editorRootElementRef,
|
|
2425
|
-
markdownParseOptions,
|
|
2426
|
-
lexicalConvertOptions,
|
|
2427
|
-
lexicalNodes,
|
|
2428
|
-
imageAutocompleteSuggestions,
|
|
2429
|
-
markdownSource
|
|
2430
|
-
};
|
|
2431
|
-
}, []);
|
|
2432
|
-
const [JsxSystem, JsxSystemType] = system((r) => {
|
|
2433
|
-
const jsxComponentDescriptors = r.node([]);
|
|
2434
|
-
return {
|
|
2435
|
-
jsxComponentDescriptors
|
|
2436
|
-
};
|
|
2437
|
-
}, []);
|
|
2438
|
-
const [ViewModeSystem] = system(
|
|
2439
|
-
(r, [{ editor, markdownParseOptions, markdownSource }, {}]) => {
|
|
2440
|
-
const viewMode = r.node("editor");
|
|
2441
|
-
const headMarkdown = r.node("");
|
|
2442
|
-
r.sub(
|
|
2443
|
-
r.pipe(
|
|
2444
|
-
viewMode,
|
|
2445
|
-
r.o.scan(
|
|
2446
|
-
(prev, next) => {
|
|
2447
|
-
return {
|
|
2448
|
-
current: prev.next,
|
|
2449
|
-
next
|
|
2450
|
-
};
|
|
2451
|
-
},
|
|
2452
|
-
{ current: "editor", next: "editor" }
|
|
2453
|
-
),
|
|
2454
|
-
r.o.withLatestFrom(editor, markdownSource, markdownParseOptions)
|
|
2455
|
-
),
|
|
2456
|
-
([{ current }, editor2, markdownSource2, markdownParseOptions2]) => {
|
|
2457
|
-
if (current === "markdown") {
|
|
2458
|
-
editor2 == null ? void 0 : editor2.update(() => {
|
|
2459
|
-
$getRoot().clear();
|
|
2460
|
-
importMarkdownToLexical({
|
|
2461
|
-
root: $getRoot(),
|
|
2462
|
-
markdown: markdownSource2,
|
|
2463
|
-
...markdownParseOptions2
|
|
2464
|
-
});
|
|
2465
|
-
});
|
|
2466
|
-
}
|
|
2467
|
-
}
|
|
2468
|
-
);
|
|
2469
|
-
return {
|
|
2470
|
-
viewMode,
|
|
2471
|
-
headMarkdown
|
|
2472
|
-
};
|
|
2473
|
-
},
|
|
2474
|
-
[EditorSystemType, JsxSystemType]
|
|
2475
|
-
);
|
|
2476
|
-
const defaultSnippetContent = `
|
|
2477
|
-
export default function App() {
|
|
2478
|
-
return (
|
|
2479
|
-
<div className="App">
|
|
2480
|
-
<h1>Hello CodeSandbox</h1>
|
|
2481
|
-
<h2>Start editing to see some magic happen!</h2>
|
|
2482
|
-
</div>
|
|
2483
|
-
);
|
|
2484
|
-
}
|
|
2485
|
-
`;
|
|
2486
|
-
const defaultSandpackConfig$1 = {
|
|
2487
|
-
defaultPreset: "react",
|
|
2488
|
-
presets: [
|
|
2489
|
-
{
|
|
2490
|
-
name: "react",
|
|
2491
|
-
meta: "live react",
|
|
2492
|
-
label: "React",
|
|
2493
|
-
sandpackTemplate: "react",
|
|
2494
|
-
sandpackTheme: "light",
|
|
2495
|
-
snippetFileName: "/App.js",
|
|
2496
|
-
snippetLanguage: "jsx",
|
|
2497
|
-
initialSnippetContent: defaultSnippetContent
|
|
2498
|
-
}
|
|
2499
|
-
]
|
|
2500
|
-
};
|
|
2501
|
-
const defaultCodeBlockLanguages = {
|
|
2502
|
-
js: "JavaScript",
|
|
2503
|
-
ts: "TypeScript",
|
|
2504
|
-
tsx: "TypeScript (React)",
|
|
2505
|
-
jsx: "JavaScript (React)",
|
|
2506
|
-
css: "CSS"
|
|
2507
|
-
};
|
|
2508
|
-
const [SandpackSystem] = system(
|
|
2509
|
-
(r, [{ activeEditor, activeEditorType, createEditorSubscription }]) => {
|
|
2510
|
-
const sandpackConfig = r.node(defaultSandpackConfig$1);
|
|
2511
|
-
const codeBlockLanguages = r.node(defaultCodeBlockLanguages);
|
|
2512
|
-
const insertSandpack = r.node();
|
|
2513
|
-
const insertCodeBlock = r.node();
|
|
2514
|
-
r.pub(createEditorSubscription, (editor) => {
|
|
2515
|
-
return editor.registerCommand(
|
|
2516
|
-
FOCUS_COMMAND,
|
|
2517
|
-
() => {
|
|
2518
|
-
r.pub(activeEditorType, { type: "lexical" });
|
|
2519
|
-
return false;
|
|
2520
|
-
},
|
|
2521
|
-
COMMAND_PRIORITY_LOW
|
|
2522
|
-
);
|
|
2523
|
-
});
|
|
2524
|
-
r.sub(r.pipe(insertSandpack, r.o.withLatestFrom(activeEditor, sandpackConfig)), ([meta, theEditor, sandpackConfig2]) => {
|
|
2525
|
-
theEditor == null ? void 0 : theEditor.getEditorState().read(() => {
|
|
2526
|
-
const selection = $getSelection();
|
|
2527
|
-
if ($isRangeSelection(selection)) {
|
|
2528
|
-
const focusNode = selection.focus.getNode();
|
|
2529
|
-
const preset = meta ? sandpackConfig2.presets.find((preset2) => preset2.meta === meta) : sandpackConfig2.presets.find((preset2) => preset2.name == sandpackConfig2.defaultPreset);
|
|
2530
|
-
if (!preset) {
|
|
2531
|
-
throw new Error(`No sandpack preset found with ${meta}`);
|
|
2532
|
-
}
|
|
2533
|
-
if (focusNode !== null) {
|
|
2534
|
-
theEditor.update(() => {
|
|
2535
|
-
const sandpackNode = $createSandpackNode({
|
|
2536
|
-
code: preset.initialSnippetContent || "",
|
|
2537
|
-
language: preset.snippetLanguage || "jsx",
|
|
2538
|
-
meta: preset.meta
|
|
2539
|
-
});
|
|
2540
|
-
$insertNodeToNearestRoot(sandpackNode);
|
|
2541
|
-
setTimeout(() => sandpackNode.select(), 80);
|
|
2542
|
-
});
|
|
2543
|
-
}
|
|
2544
|
-
}
|
|
2545
|
-
});
|
|
2546
|
-
});
|
|
2547
|
-
r.sub(r.pipe(insertCodeBlock, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2548
|
-
theEditor == null ? void 0 : theEditor.getEditorState().read(() => {
|
|
2549
|
-
const selection = $getSelection();
|
|
2550
|
-
if ($isRangeSelection(selection)) {
|
|
2551
|
-
const focusNode = selection.focus.getNode();
|
|
2552
|
-
if (focusNode !== null) {
|
|
2553
|
-
theEditor.update(() => {
|
|
2554
|
-
const codeBlockNode = $createCodeBlockNode({
|
|
2555
|
-
code: "",
|
|
2556
|
-
language: "jsx",
|
|
2557
|
-
meta: ""
|
|
2558
|
-
});
|
|
2559
|
-
$insertNodeToNearestRoot(codeBlockNode);
|
|
2560
|
-
setTimeout(() => codeBlockNode.select(), 80);
|
|
2561
|
-
});
|
|
2562
|
-
}
|
|
2563
|
-
}
|
|
2564
|
-
});
|
|
2565
|
-
});
|
|
2566
|
-
return {
|
|
2567
|
-
codeBlockLanguages,
|
|
2568
|
-
insertSandpack,
|
|
2569
|
-
insertCodeBlock,
|
|
2570
|
-
sandpackConfig
|
|
2571
|
-
};
|
|
2572
|
-
},
|
|
2573
|
-
[EditorSystemType]
|
|
2574
|
-
);
|
|
2575
|
-
function getSelectedNode(selection) {
|
|
2576
|
-
const anchor = selection.anchor;
|
|
2577
|
-
const focus = selection.focus;
|
|
2578
|
-
const anchorNode = selection.anchor.getNode();
|
|
2579
|
-
const focusNode = selection.focus.getNode();
|
|
2580
|
-
if (anchorNode === focusNode) {
|
|
2581
|
-
return anchorNode;
|
|
2582
|
-
}
|
|
2583
|
-
const isBackward = selection.isBackward();
|
|
2584
|
-
if (isBackward) {
|
|
2585
|
-
return $isAtNodeEnd(focus) ? anchorNode : focusNode;
|
|
2586
|
-
} else {
|
|
2587
|
-
return $isAtNodeEnd(anchor) ? anchorNode : focusNode;
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
function getSelectionRectangle(editor) {
|
|
2591
|
-
const selection = $getSelection();
|
|
2592
|
-
const nativeSelection = window.getSelection();
|
|
2593
|
-
const activeElement = document.activeElement;
|
|
2594
|
-
const rootElement = editor.getRootElement();
|
|
2595
|
-
if (selection !== null && nativeSelection !== null && rootElement !== null && rootElement.contains(nativeSelection.anchorNode) && editor.isEditable()) {
|
|
2596
|
-
const domRange = nativeSelection.getRangeAt(0);
|
|
2597
|
-
let rect;
|
|
2598
|
-
if (nativeSelection.anchorNode === rootElement) {
|
|
2599
|
-
let inner = rootElement;
|
|
2600
|
-
while (inner.firstElementChild != null) {
|
|
2601
|
-
inner = inner.firstElementChild;
|
|
2602
|
-
}
|
|
2603
|
-
rect = inner.getBoundingClientRect();
|
|
2604
|
-
} else {
|
|
2605
|
-
rect = domRange.getBoundingClientRect();
|
|
2606
|
-
}
|
|
2607
|
-
return {
|
|
2608
|
-
top: rect.top + window.scrollY,
|
|
2609
|
-
left: rect.left + window.scrollX,
|
|
2610
|
-
width: rect.width,
|
|
2611
|
-
height: rect.height
|
|
2612
|
-
};
|
|
2613
|
-
} else if (!activeElement || activeElement.className !== "link-input") {
|
|
2614
|
-
return null;
|
|
2615
|
-
}
|
|
2616
|
-
return null;
|
|
2617
|
-
}
|
|
2618
|
-
function getStateAsMarkdown(editor, exportParams) {
|
|
2619
|
-
return tap({ markdown: "" }, (result) => {
|
|
2620
|
-
editor.getEditorState().read(() => {
|
|
2621
|
-
result.markdown = exportMarkdownFromLexical({ root: $getRoot(), ...exportParams });
|
|
2622
|
-
});
|
|
2623
|
-
}).markdown;
|
|
2624
|
-
}
|
|
2625
|
-
const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2626
|
-
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
2627
|
-
function getLinkNodeInSelection(selection) {
|
|
2628
|
-
const node = getSelectedNode(selection);
|
|
2629
|
-
const parent = node.getParent();
|
|
2630
|
-
if ($isLinkNode(parent)) {
|
|
2631
|
-
return parent;
|
|
2632
|
-
} else if ($isLinkNode(node)) {
|
|
2633
|
-
return node;
|
|
2634
|
-
}
|
|
2635
|
-
return null;
|
|
2636
|
-
}
|
|
2637
|
-
const [LinkDialogSystem, LinkDialogSystemType] = system(
|
|
2638
|
-
(r, [{ activeEditor, currentSelection, createEditorSubscription }]) => {
|
|
2639
|
-
const dialogState = r.node(false);
|
|
2640
|
-
const onWindowChange = r.node();
|
|
2641
|
-
const linkDialogState = r.node({ type: "inactive" }, true);
|
|
2642
|
-
const updateLinkUrl = r.node();
|
|
2643
|
-
const cancelLinkEdit = r.node();
|
|
2644
|
-
const applyLinkChanges = r.node();
|
|
2645
|
-
const switchFromPreviewToLinkEdit = r.node();
|
|
2646
|
-
const removeLink = r.node();
|
|
2647
|
-
const openLinkEditDialog = r.node();
|
|
2648
|
-
const linkAutocompleteSuggestions = r.node([]);
|
|
2649
|
-
r.sub(
|
|
2650
|
-
r.pipe(
|
|
2651
|
-
openLinkEditDialog,
|
|
2652
|
-
r.o.withLatestFrom(currentSelection, activeEditor),
|
|
2653
|
-
r.o.filter(([, selection]) => $isRangeSelection(selection))
|
|
2654
|
-
),
|
|
2655
|
-
([, selection, editor]) => {
|
|
2656
|
-
editor == null ? void 0 : editor.getEditorState().read(() => {
|
|
2657
|
-
const node = getLinkNodeInSelection(selection);
|
|
2658
|
-
const rectangle = getSelectionRectangle(editor);
|
|
2659
|
-
if (node) {
|
|
2660
|
-
r.pub(linkDialogState, {
|
|
2661
|
-
type: "edit",
|
|
2662
|
-
initialUrl: node.getURL(),
|
|
2663
|
-
url: node.getURL(),
|
|
2664
|
-
linkNodeKey: node.getKey(),
|
|
2665
|
-
rectangle
|
|
2666
|
-
});
|
|
2667
|
-
} else {
|
|
2668
|
-
r.pub(linkDialogState, {
|
|
2669
|
-
type: "edit",
|
|
2670
|
-
initialUrl: "",
|
|
2671
|
-
url: "",
|
|
2672
|
-
linkNodeKey: "",
|
|
2673
|
-
rectangle
|
|
2674
|
-
});
|
|
2675
|
-
}
|
|
2676
|
-
});
|
|
2677
|
-
}
|
|
2678
|
-
);
|
|
2679
|
-
r.sub(r.pipe(removeLink, r.o.withLatestFrom(activeEditor)), ([, editor]) => {
|
|
2680
|
-
editor == null ? void 0 : editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
2681
|
-
});
|
|
2682
|
-
r.pub(createEditorSubscription, (editor) => {
|
|
2683
|
-
return editor.registerCommand(
|
|
2684
|
-
KEY_ESCAPE_COMMAND,
|
|
2685
|
-
() => {
|
|
2686
|
-
const state = r.getValue(linkDialogState);
|
|
2687
|
-
if (state.type === "preview") {
|
|
2688
|
-
r.pub(linkDialogState, { type: "inactive" });
|
|
2689
|
-
return true;
|
|
2690
|
-
}
|
|
2691
|
-
return false;
|
|
2692
|
-
},
|
|
2693
|
-
COMMAND_PRIORITY_LOW
|
|
2694
|
-
);
|
|
2695
|
-
});
|
|
2696
|
-
r.pub(createEditorSubscription, (editor) => {
|
|
2697
|
-
return editor.registerCommand(
|
|
2698
|
-
KEY_MODIFIER_COMMAND,
|
|
2699
|
-
(event) => {
|
|
2700
|
-
if (event.key === "k" && IS_APPLE ? event.metaKey : event.ctrlKey) {
|
|
2701
|
-
r.pub(openLinkEditDialog, true);
|
|
2702
|
-
return true;
|
|
2703
|
-
}
|
|
2704
|
-
return false;
|
|
2705
|
-
},
|
|
2706
|
-
COMMAND_PRIORITY_HIGH
|
|
2707
|
-
);
|
|
2708
|
-
});
|
|
2709
|
-
r.link(
|
|
2710
|
-
r.pipe(
|
|
2711
|
-
switchFromPreviewToLinkEdit,
|
|
2712
|
-
r.o.withLatestFrom(linkDialogState),
|
|
2713
|
-
r.o.map(([, state]) => {
|
|
2714
|
-
if (state.type === "preview") {
|
|
2715
|
-
return {
|
|
2716
|
-
type: "edit",
|
|
2717
|
-
initialUrl: state.url,
|
|
2718
|
-
url: state.url,
|
|
2719
|
-
linkNodeKey: state.linkNodeKey,
|
|
2720
|
-
rectangle: state.rectangle
|
|
2721
|
-
};
|
|
2722
|
-
} else {
|
|
2723
|
-
throw new Error("Cannot switch to edit mode when not in preview mode");
|
|
2724
|
-
}
|
|
2725
|
-
})
|
|
2726
|
-
),
|
|
2727
|
-
linkDialogState
|
|
2728
|
-
);
|
|
2729
|
-
r.sub(r.pipe(applyLinkChanges, r.o.withLatestFrom(linkDialogState, activeEditor)), ([, state, editor]) => {
|
|
2730
|
-
if (state.type === "edit") {
|
|
2731
|
-
const url = state.url.trim();
|
|
2732
|
-
if (url.trim() !== "") {
|
|
2733
|
-
editor == null ? void 0 : editor.dispatchCommand(TOGGLE_LINK_COMMAND, url);
|
|
2734
|
-
r.pub(linkDialogState, {
|
|
2735
|
-
type: "preview",
|
|
2736
|
-
linkNodeKey: state.linkNodeKey,
|
|
2737
|
-
rectangle: state.rectangle,
|
|
2738
|
-
url
|
|
2739
|
-
});
|
|
2740
|
-
} else {
|
|
2741
|
-
if (state.initialUrl !== "") {
|
|
2742
|
-
editor == null ? void 0 : editor.dispatchCommand(TOGGLE_LINK_COMMAND, null);
|
|
2743
|
-
}
|
|
2744
|
-
r.pub(linkDialogState, {
|
|
2745
|
-
type: "inactive"
|
|
2746
|
-
});
|
|
2747
|
-
}
|
|
2748
|
-
} else {
|
|
2749
|
-
throw new Error("Cannot apply link edit when not in edit mode");
|
|
2750
|
-
}
|
|
2751
|
-
});
|
|
2752
|
-
r.link(
|
|
2753
|
-
r.pipe(
|
|
2754
|
-
updateLinkUrl,
|
|
2755
|
-
r.o.withLatestFrom(linkDialogState),
|
|
2756
|
-
r.o.map(([url, state]) => {
|
|
2757
|
-
if (state.type === "edit") {
|
|
2758
|
-
return {
|
|
2759
|
-
...state,
|
|
2760
|
-
url
|
|
2761
|
-
};
|
|
2762
|
-
} else {
|
|
2763
|
-
throw new Error("Cannot update link url when not in edit mode");
|
|
2764
|
-
}
|
|
2765
|
-
})
|
|
2766
|
-
),
|
|
2767
|
-
linkDialogState
|
|
2768
|
-
);
|
|
2769
|
-
r.link(
|
|
2770
|
-
r.pipe(
|
|
2771
|
-
cancelLinkEdit,
|
|
2772
|
-
r.o.withLatestFrom(linkDialogState, activeEditor),
|
|
2773
|
-
r.o.map(([, state, editor]) => {
|
|
2774
|
-
if (state.type === "edit") {
|
|
2775
|
-
editor == null ? void 0 : editor.focus();
|
|
2776
|
-
if (state.initialUrl === "") {
|
|
2777
|
-
return {
|
|
2778
|
-
type: "inactive"
|
|
2779
|
-
};
|
|
2780
|
-
} else {
|
|
2781
|
-
return {
|
|
2782
|
-
type: "preview",
|
|
2783
|
-
url: state.initialUrl,
|
|
2784
|
-
linkNodeKey: state.linkNodeKey,
|
|
2785
|
-
rectangle: state.rectangle
|
|
2786
|
-
};
|
|
2787
|
-
}
|
|
2788
|
-
} else {
|
|
2789
|
-
throw new Error("Cannot cancel edit when not in edit mode");
|
|
2790
|
-
}
|
|
2791
|
-
})
|
|
2792
|
-
),
|
|
2793
|
-
linkDialogState
|
|
2794
|
-
);
|
|
2795
|
-
r.link(
|
|
2796
|
-
r.pipe(
|
|
2797
|
-
r.combine(currentSelection, onWindowChange),
|
|
2798
|
-
r.o.withLatestFrom(activeEditor, linkDialogState),
|
|
2799
|
-
r.o.map(([[selection], activeEditor2]) => {
|
|
2800
|
-
if ($isRangeSelection(selection) && activeEditor2) {
|
|
2801
|
-
const node = getLinkNodeInSelection(selection);
|
|
2802
|
-
if (node) {
|
|
2803
|
-
return {
|
|
2804
|
-
type: "preview",
|
|
2805
|
-
url: node.getURL(),
|
|
2806
|
-
linkNodeKey: node.getKey(),
|
|
2807
|
-
rectangle: getSelectionRectangle(activeEditor2)
|
|
2808
|
-
};
|
|
2809
|
-
} else {
|
|
2810
|
-
return {
|
|
2811
|
-
type: "inactive"
|
|
2812
|
-
};
|
|
2813
|
-
}
|
|
2814
|
-
} else {
|
|
2815
|
-
return {
|
|
2816
|
-
type: "inactive"
|
|
2817
|
-
};
|
|
2818
|
-
}
|
|
2819
|
-
})
|
|
2820
|
-
),
|
|
2821
|
-
linkDialogState
|
|
2822
|
-
);
|
|
2823
|
-
return {
|
|
2824
|
-
dialogState,
|
|
2825
|
-
onWindowChange,
|
|
2826
|
-
linkDialogState,
|
|
2827
|
-
updateLinkUrl,
|
|
2828
|
-
switchFromPreviewToLinkEdit,
|
|
2829
|
-
cancelLinkEdit,
|
|
2830
|
-
removeLink,
|
|
2831
|
-
openLinkEditDialog,
|
|
2832
|
-
applyLinkChanges,
|
|
2833
|
-
linkAutocompleteSuggestions
|
|
2834
|
-
};
|
|
2835
|
-
},
|
|
2836
|
-
[EditorSystemType]
|
|
2837
|
-
);
|
|
2838
|
-
const [OnChangeSystem, OnChangeSystemType] = system(
|
|
2839
|
-
(r, [{ createEditorSubscription, lexicalConvertOptions, markdownSource }, { jsxComponentDescriptors }]) => {
|
|
2840
|
-
const onChange = r.node();
|
|
2841
|
-
r.pub(createEditorSubscription, (activeEditor, rootEditor) => {
|
|
2842
|
-
function updateMarkdown() {
|
|
2843
|
-
const descriptors = r.getValue(jsxComponentDescriptors);
|
|
2844
|
-
const options = r.getValue(lexicalConvertOptions);
|
|
2845
|
-
const markdown2 = getStateAsMarkdown(rootEditor, { jsxComponentDescriptors: descriptors, ...options });
|
|
2846
|
-
r.pub(onChange, markdown2);
|
|
2847
|
-
r.pub(markdownSource, markdown2);
|
|
2848
|
-
}
|
|
2849
|
-
updateMarkdown();
|
|
2850
|
-
return activeEditor.registerUpdateListener(({ dirtyElements, dirtyLeaves, prevEditorState, tags }) => {
|
|
2851
|
-
if (dirtyElements.size === 0 && dirtyLeaves.size === 0 || tags.has("history-merge") || prevEditorState.isEmpty()) {
|
|
2852
|
-
return;
|
|
2853
|
-
}
|
|
2854
|
-
updateMarkdown();
|
|
2855
|
-
});
|
|
2856
|
-
});
|
|
2857
|
-
return {
|
|
2858
|
-
onChange
|
|
2859
|
-
};
|
|
2860
|
-
},
|
|
2861
|
-
[EditorSystemType, JsxSystemType]
|
|
2862
|
-
);
|
|
2863
|
-
const [ToolbarSystem, ToolbarSystemType] = system((r) => {
|
|
2864
|
-
const toolbarComponents = r.node([]);
|
|
2865
|
-
return {
|
|
2866
|
-
toolbarComponents
|
|
2867
|
-
};
|
|
2868
|
-
}, []);
|
|
2869
|
-
const {
|
|
2870
|
-
Component: EditorSystemComponent,
|
|
2871
|
-
usePublisher,
|
|
2872
|
-
useEmitterValues
|
|
2873
|
-
} = realmFactoryToComponent(
|
|
2874
|
-
getRealmFactory(EditorSystem, ViewModeSystem, SandpackSystem, LinkDialogSystem, JsxSystem, OnChangeSystem, ToolbarSystem),
|
|
2875
|
-
{
|
|
2876
|
-
required: {
|
|
2877
|
-
markdownSource: "markdownSource",
|
|
2878
|
-
headMarkdown: "headMarkdown",
|
|
2879
|
-
jsxComponentDescriptors: "jsxComponentDescriptors",
|
|
2880
|
-
sandpackConfig: "sandpackConfig",
|
|
2881
|
-
toolbarComponents: "toolbarComponents",
|
|
2882
|
-
markdownParseOptions: "markdownParseOptions",
|
|
2883
|
-
lexicalConvertOptions: "lexicalConvertOptions",
|
|
2884
|
-
lexicalNodes: "lexicalNodes"
|
|
2885
|
-
},
|
|
2886
|
-
optional: {
|
|
2887
|
-
editorRootElementRef: "editorRootElementRef",
|
|
2888
|
-
viewMode: "viewMode",
|
|
2889
|
-
linkAutocompleteSuggestions: "linkAutocompleteSuggestions",
|
|
2890
|
-
imageAutocompleteSuggestions: "imageAutocompleteSuggestions",
|
|
2891
|
-
codeBlockLanguages: "codeBlockLanguages"
|
|
2892
|
-
},
|
|
2893
|
-
events: {
|
|
2894
|
-
onChange: "onChange"
|
|
2895
|
-
}
|
|
2896
|
-
},
|
|
2897
|
-
({ children }) => {
|
|
2898
|
-
return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(CaptureLexicalEditor, null), children);
|
|
2899
|
-
}
|
|
2900
|
-
);
|
|
2901
|
-
const CaptureLexicalEditor = () => {
|
|
2902
|
-
const setEditor = usePublisher("editor");
|
|
2903
|
-
const [lexicalEditor] = useLexicalComposerContext();
|
|
2904
|
-
React__default.useEffect(() => setEditor(lexicalEditor), [lexicalEditor, setEditor]);
|
|
2905
|
-
return null;
|
|
2906
|
-
};
|
|
2907
|
-
const SvgCheck = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2908
|
-
maskType: "alpha"
|
|
2909
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m9.55 18-5.7-5.7 1.425-1.425L9.55 15.15l9.175-9.175L20.15 7.4 9.55 18Z" })));
|
|
2910
|
-
const CheckIcon = SvgCheck;
|
|
2911
|
-
const SvgClose = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2912
|
-
maskType: "alpha"
|
|
2913
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6.4 19 5 17.6l5.6-5.6L5 6.4 6.4 5l5.6 5.6L17.6 5 19 6.4 13.4 12l5.6 5.6-1.4 1.4-5.6-5.6L6.4 19Z" })));
|
|
2914
|
-
const CloseIcon = SvgClose;
|
|
2915
|
-
const SvgContentCopy = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2916
|
-
maskType: "alpha"
|
|
2917
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M7 18V2h13v16H7Zm2-2h9V4H9v12Zm-6 6V6h2v14h11v2H3Z" })));
|
|
2918
|
-
const CopyIcon = SvgContentCopy;
|
|
2919
|
-
const SvgEdit = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2920
|
-
maskType: "alpha"
|
|
2921
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 19h1.4l8.625-8.625-1.4-1.4L5 17.6V19ZM19.3 8.925l-4.25-4.2L17.875 1.9 22.1 6.125l-2.8 2.8ZM3 21v-4.25l10.6-10.6 4.25 4.25L7.25 21H3Z" })));
|
|
2922
|
-
const EditIcon = SvgEdit;
|
|
2923
|
-
const SvgLinkOff = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2924
|
-
maskType: "alpha"
|
|
2925
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m19.25 16.45-1.5-1.55a3.05 3.05 0 0 0 1.625-1.063A2.867 2.867 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12c0 .95-.246 1.825-.737 2.625a4.79 4.79 0 0 1-2.013 1.825ZM15.85 13l-2-2H16v2h-.15Zm3.95 9.6L1.4 4.2l1.4-1.4 18.4 18.4-1.4 1.4ZM11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12c0-1.15.35-2.175 1.05-3.075.7-.9 1.6-1.492 2.7-1.775L7.6 9H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h1.625l1.975 2H8Z" })));
|
|
2926
|
-
const LinkOffIcon = SvgLinkOff;
|
|
2927
|
-
const SvgOpenInNew = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2928
|
-
maskType: "alpha"
|
|
2929
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 21V3h9v2H5v14h14v-7h2v9H3Zm6.7-5.3-1.4-1.4L17.6 5H14V3h7v7h-2V6.4l-9.3 9.3Z" })));
|
|
2930
|
-
const OpenInNewIcon = SvgOpenInNew;
|
|
2931
|
-
const SvgArrowDropDown$1 = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
2932
|
-
maskType: "alpha"
|
|
2933
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m12 15-5-5h10l-5 5Z" })));
|
|
2934
|
-
const DropDownIcon = SvgArrowDropDown$1;
|
|
2935
|
-
const editorRoot = "_editorRoot_gm91f_47";
|
|
2936
|
-
const editorWrapper = "_editorWrapper_gm91f_141";
|
|
2937
|
-
const nestedListItem = "_nestedListItem_gm91f_145";
|
|
2938
|
-
const toolbarRoot = "_toolbarRoot_gm91f_149";
|
|
2939
|
-
const toolbarModeSwitch = "_toolbarModeSwitch_gm91f_170";
|
|
2940
|
-
const toolbarToggleItem = "_toolbarToggleItem_gm91f_179";
|
|
2941
|
-
const toolbarGroupOfGroups = "_toolbarGroupOfGroups_gm91f_189";
|
|
2942
|
-
const toolbarToggleSingleGroup = "_toolbarToggleSingleGroup_gm91f_193";
|
|
2943
|
-
const toolbarButton = "_toolbarButton_gm91f_207";
|
|
2944
|
-
const toolbarNodeKindSelectContainer = "_toolbarNodeKindSelectContainer_gm91f_236";
|
|
2945
|
-
const toolbarButtonDropdownContainer = "_toolbarButtonDropdownContainer_gm91f_237";
|
|
2946
|
-
const toolbarCodeBlockLanguageSelectContent = "_toolbarCodeBlockLanguageSelectContent_gm91f_238";
|
|
2947
|
-
const toolbarNodeKindSelectTrigger = "_toolbarNodeKindSelectTrigger_gm91f_252";
|
|
2948
|
-
const toolbarButtonSelectTrigger = "_toolbarButtonSelectTrigger_gm91f_253";
|
|
2949
|
-
const toolbarCodeBlockLanguageSelectTrigger = "_toolbarCodeBlockLanguageSelectTrigger_gm91f_286";
|
|
2950
|
-
const toolbarNodeKindSelectItem = "_toolbarNodeKindSelectItem_gm91f_292";
|
|
2951
|
-
const toolbarNodeKindSelectDropdownArrow = "_toolbarNodeKindSelectDropdownArrow_gm91f_315";
|
|
2952
|
-
const contentEditable = "_contentEditable_gm91f_319";
|
|
2953
|
-
const sandpackWrapper = "_sandpackWrapper_gm91f_327";
|
|
2954
|
-
const frontmatterWrapper = "_frontmatterWrapper_gm91f_331";
|
|
2955
|
-
const frontmatterToggleButton = "_frontmatterToggleButton_gm91f_341";
|
|
2956
|
-
const frontmatterEditorTable = "_frontmatterEditorTable_gm91f_349";
|
|
2957
|
-
const iconButton = "_iconButton_gm91f_367";
|
|
2958
|
-
const frontmatterInput = "_frontmatterInput_gm91f_373";
|
|
2959
|
-
const primaryButton = "_primaryButton_gm91f_388";
|
|
2960
|
-
const linkDialogEditForm = "_linkDialogEditForm_gm91f_398";
|
|
2961
|
-
const linkDialogInputContainer = "_linkDialogInputContainer_gm91f_404";
|
|
2962
|
-
const linkDialogInputWrapper = "_linkDialogInputWrapper_gm91f_410";
|
|
2963
|
-
const linkDialogInput = "_linkDialogInput_gm91f_404";
|
|
2964
|
-
const linkDialogAutocompleteContainer = "_linkDialogAutocompleteContainer_gm91f_440";
|
|
2965
|
-
const linkDialogAnchor = "_linkDialogAnchor_gm91f_485";
|
|
2966
|
-
const linkDialogPopoverContent = "_linkDialogPopoverContent_gm91f_499";
|
|
2967
|
-
const tableColumnEditorPopoverContent = "_tableColumnEditorPopoverContent_gm91f_499";
|
|
2968
|
-
const dialogContent = "_dialogContent_gm91f_499";
|
|
2969
|
-
const linkDialogPreviewAnchor = "_linkDialogPreviewAnchor_gm91f_513";
|
|
2970
|
-
const tooltipContent = "_tooltipContent_gm91f_535";
|
|
2971
|
-
const actionButton = "_actionButton_gm91f_549";
|
|
2972
|
-
const primaryActionButton = "_primaryActionButton_gm91f_555";
|
|
2973
|
-
const tableEditor = "_tableEditor_gm91f_564";
|
|
2974
|
-
const toolCell = "_toolCell_gm91f_575";
|
|
2975
|
-
const tableColumnEditorTrigger = "_tableColumnEditorTrigger_gm91f_592";
|
|
2976
|
-
const tableRowEditorTrigger = "_tableRowEditorTrigger_gm91f_592";
|
|
2977
|
-
const addRowButton = "_addRowButton_gm91f_592";
|
|
2978
|
-
const addColumnButton = "_addColumnButton_gm91f_592";
|
|
2979
|
-
const tableColumnEditorToolbar = "_tableColumnEditorToolbar_gm91f_626";
|
|
2980
|
-
const toggleGroupRoot = "_toggleGroupRoot_gm91f_638";
|
|
2981
|
-
const tableToolsColumn = "_tableToolsColumn_gm91f_655";
|
|
2982
|
-
const leftAlignedCell = "_leftAlignedCell_gm91f_663";
|
|
2983
|
-
const rightAlignedCell = "_rightAlignedCell_gm91f_667";
|
|
2984
|
-
const centeredCell = "_centeredCell_gm91f_671";
|
|
2985
|
-
const dialogOverlay = "_dialogOverlay_gm91f_699";
|
|
2986
|
-
const overlayShow = "_overlayShow_gm91f_1";
|
|
2987
|
-
const contentShow = "_contentShow_gm91f_1";
|
|
2988
|
-
const styles = {
|
|
2989
|
-
editorRoot,
|
|
2990
|
-
editorWrapper,
|
|
2991
|
-
nestedListItem,
|
|
2992
|
-
toolbarRoot,
|
|
2993
|
-
toolbarModeSwitch,
|
|
2994
|
-
toolbarToggleItem,
|
|
2995
|
-
toolbarGroupOfGroups,
|
|
2996
|
-
toolbarToggleSingleGroup,
|
|
2997
|
-
toolbarButton,
|
|
2998
|
-
toolbarNodeKindSelectContainer,
|
|
2999
|
-
toolbarButtonDropdownContainer,
|
|
3000
|
-
toolbarCodeBlockLanguageSelectContent,
|
|
3001
|
-
toolbarNodeKindSelectTrigger,
|
|
3002
|
-
toolbarButtonSelectTrigger,
|
|
3003
|
-
toolbarCodeBlockLanguageSelectTrigger,
|
|
3004
|
-
toolbarNodeKindSelectItem,
|
|
3005
|
-
toolbarNodeKindSelectDropdownArrow,
|
|
3006
|
-
contentEditable,
|
|
3007
|
-
sandpackWrapper,
|
|
3008
|
-
frontmatterWrapper,
|
|
3009
|
-
frontmatterToggleButton,
|
|
3010
|
-
frontmatterEditorTable,
|
|
3011
|
-
iconButton,
|
|
3012
|
-
frontmatterInput,
|
|
3013
|
-
primaryButton,
|
|
3014
|
-
linkDialogEditForm,
|
|
3015
|
-
linkDialogInputContainer,
|
|
3016
|
-
linkDialogInputWrapper,
|
|
3017
|
-
linkDialogInput,
|
|
3018
|
-
linkDialogAutocompleteContainer,
|
|
3019
|
-
linkDialogAnchor,
|
|
3020
|
-
linkDialogPopoverContent,
|
|
3021
|
-
tableColumnEditorPopoverContent,
|
|
3022
|
-
dialogContent,
|
|
3023
|
-
linkDialogPreviewAnchor,
|
|
3024
|
-
tooltipContent,
|
|
3025
|
-
actionButton,
|
|
3026
|
-
primaryActionButton,
|
|
3027
|
-
tableEditor,
|
|
3028
|
-
toolCell,
|
|
3029
|
-
tableColumnEditorTrigger,
|
|
3030
|
-
tableRowEditorTrigger,
|
|
3031
|
-
addRowButton,
|
|
3032
|
-
addColumnButton,
|
|
3033
|
-
tableColumnEditorToolbar,
|
|
3034
|
-
toggleGroupRoot,
|
|
3035
|
-
tableToolsColumn,
|
|
3036
|
-
leftAlignedCell,
|
|
3037
|
-
rightAlignedCell,
|
|
3038
|
-
centeredCell,
|
|
3039
|
-
dialogOverlay,
|
|
3040
|
-
overlayShow,
|
|
3041
|
-
contentShow
|
|
3042
|
-
};
|
|
3043
|
-
createCommand();
|
|
3044
|
-
const MAX_SUGGESTIONS$1 = 20;
|
|
3045
|
-
function LinkEditForm({ initialUrl, onSubmit, onCancel, linkAutocompleteSuggestions }) {
|
|
3046
|
-
const [items, setItems] = React__default.useState(linkAutocompleteSuggestions.slice(0, MAX_SUGGESTIONS$1));
|
|
3047
|
-
const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
|
|
3048
|
-
initialInputValue: initialUrl,
|
|
3049
|
-
onInputValueChange({ inputValue }) {
|
|
3050
|
-
inputValue = (inputValue == null ? void 0 : inputValue.toLowerCase()) || "";
|
|
3051
|
-
const matchingItems = [];
|
|
3052
|
-
for (const url of linkAutocompleteSuggestions) {
|
|
3053
|
-
if (url.toLowerCase().includes(inputValue)) {
|
|
3054
|
-
matchingItems.push(url);
|
|
3055
|
-
if (matchingItems.length >= MAX_SUGGESTIONS$1) {
|
|
3056
|
-
break;
|
|
3057
|
-
}
|
|
3058
|
-
}
|
|
3059
|
-
}
|
|
3060
|
-
setItems(matchingItems);
|
|
3061
|
-
},
|
|
3062
|
-
items,
|
|
3063
|
-
itemToString(item) {
|
|
3064
|
-
return item ?? "";
|
|
3065
|
-
}
|
|
3066
|
-
});
|
|
3067
|
-
const onSubmitEH = (e) => {
|
|
3068
|
-
e.preventDefault();
|
|
3069
|
-
onSubmit(selectedItem || "");
|
|
3070
|
-
};
|
|
3071
|
-
const onKeyDownEH = React__default.useCallback(
|
|
3072
|
-
(e) => {
|
|
3073
|
-
var _a;
|
|
3074
|
-
if (e.key === "Escape") {
|
|
3075
|
-
(_a = e.target.form) == null ? void 0 : _a.reset();
|
|
3076
|
-
} else if (e.key === "Enter" && (!isOpen || items.length === 0)) {
|
|
3077
|
-
e.preventDefault();
|
|
3078
|
-
onSubmit(e.target.value);
|
|
3079
|
-
}
|
|
3080
|
-
},
|
|
3081
|
-
[isOpen, items, onSubmit]
|
|
3082
|
-
);
|
|
3083
|
-
const downshiftInputProps = getInputProps();
|
|
3084
|
-
const inputProps = {
|
|
3085
|
-
...downshiftInputProps,
|
|
3086
|
-
onKeyDown: (e) => {
|
|
3087
|
-
onKeyDownEH(e);
|
|
3088
|
-
downshiftInputProps.onKeyDown(e);
|
|
3089
|
-
}
|
|
3090
|
-
};
|
|
3091
|
-
const dropdownIsVisible = isOpen && items.length > 0;
|
|
3092
|
-
return /* @__PURE__ */ React__default.createElement("form", { onSubmit: onSubmitEH, onReset: onCancel, className: classNames(styles.linkDialogEditForm) }, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputContainer }, /* @__PURE__ */ React__default.createElement("div", { "data-visible-dropdown": dropdownIsVisible, className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement("input", { className: styles.linkDialogInput, ...inputProps, autoFocus: true, size: 30, "data-editor-dialog": true }), /* @__PURE__ */ React__default.createElement("button", { "aria-label": "toggle menu", type: "button", ...getToggleButtonProps() }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))), /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogAutocompleteContainer }, /* @__PURE__ */ React__default.createElement("ul", { ...getMenuProps(), "data-visible": dropdownIsVisible }, items.map((item, index2) => /* @__PURE__ */ React__default.createElement(
|
|
3093
|
-
"li",
|
|
3094
|
-
{
|
|
3095
|
-
"data-selected": selectedItem === item,
|
|
3096
|
-
"data-highlighted": highlightedIndex === index2,
|
|
3097
|
-
key: `${item}${index2}`,
|
|
3098
|
-
...getItemProps({ item, index: index2 })
|
|
3099
|
-
},
|
|
3100
|
-
item
|
|
3101
|
-
))))), /* @__PURE__ */ React__default.createElement(ActionButton$1, { type: "submit", title: "Set URL", "aria-label": "Set URL" }, /* @__PURE__ */ React__default.createElement(CheckIcon, null)), /* @__PURE__ */ React__default.createElement(ActionButton$1, { type: "reset", title: "Cancel change", "aria-label": "Cancel change" }, /* @__PURE__ */ React__default.createElement(CloseIcon, null)));
|
|
3102
|
-
}
|
|
3103
|
-
function LinkDialogPlugin() {
|
|
3104
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3105
|
-
const publishWindowChange = usePublisher("onWindowChange");
|
|
3106
|
-
const [linkDialogState, linkAutocompleteSuggestions, activeEditor] = useEmitterValues(
|
|
3107
|
-
"linkDialogState",
|
|
3108
|
-
"linkAutocompleteSuggestions",
|
|
3109
|
-
"activeEditor"
|
|
3110
|
-
);
|
|
3111
|
-
const updateLinkUrl = usePublisher("updateLinkUrl");
|
|
3112
|
-
const cancelLinkEdit = usePublisher("cancelLinkEdit");
|
|
3113
|
-
const switchFromPreviewToLinkEdit = usePublisher("switchFromPreviewToLinkEdit");
|
|
3114
|
-
const removeLink = usePublisher("removeLink");
|
|
3115
|
-
const applyLinkChanges = usePublisher("applyLinkChanges");
|
|
3116
|
-
React__default.useEffect(() => {
|
|
3117
|
-
const update = () => {
|
|
3118
|
-
activeEditor == null ? void 0 : activeEditor.getEditorState().read(() => {
|
|
3119
|
-
publishWindowChange(true);
|
|
3120
|
-
});
|
|
3121
|
-
};
|
|
3122
|
-
window.addEventListener("resize", update);
|
|
3123
|
-
window.addEventListener("scroll", update);
|
|
3124
|
-
return () => {
|
|
3125
|
-
window.removeEventListener("resize", update);
|
|
3126
|
-
window.removeEventListener("scroll", update);
|
|
3127
|
-
};
|
|
3128
|
-
}, [activeEditor, publishWindowChange]);
|
|
3129
|
-
const [copyUrlTooltipOpen, setCopyUrlTooltipOpen] = React__default.useState(false);
|
|
3130
|
-
const theRect = linkDialogState == null ? void 0 : linkDialogState.rectangle;
|
|
3131
|
-
const onSubmitEH = React__default.useCallback(
|
|
3132
|
-
(url) => {
|
|
3133
|
-
updateLinkUrl(url);
|
|
3134
|
-
applyLinkChanges(true);
|
|
3135
|
-
},
|
|
3136
|
-
[applyLinkChanges, updateLinkUrl]
|
|
3137
|
-
);
|
|
3138
|
-
const urlIsExternal = linkDialogState.type === "preview" && linkDialogState.url.startsWith("http");
|
|
3139
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open: linkDialogState.type !== "inactive" }, /* @__PURE__ */ React__default.createElement(
|
|
3140
|
-
RadixPopover.Anchor,
|
|
3141
|
-
{
|
|
3142
|
-
"data-visible": linkDialogState.type === "edit",
|
|
3143
|
-
className: styles.linkDialogAnchor,
|
|
3144
|
-
style: {
|
|
3145
|
-
top: theRect == null ? void 0 : theRect.top,
|
|
3146
|
-
left: theRect == null ? void 0 : theRect.left,
|
|
3147
|
-
width: theRect == null ? void 0 : theRect.width,
|
|
3148
|
-
height: theRect == null ? void 0 : theRect.height
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
3152
|
-
RadixPopover.Content,
|
|
3153
|
-
{
|
|
3154
|
-
className: classNames(styles.linkDialogPopoverContent),
|
|
3155
|
-
sideOffset: 5,
|
|
3156
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
3157
|
-
key: linkDialogState.linkNodeKey
|
|
3158
|
-
},
|
|
3159
|
-
linkDialogState.type === "edit" && /* @__PURE__ */ React__default.createElement(
|
|
3160
|
-
LinkEditForm,
|
|
3161
|
-
{
|
|
3162
|
-
initialUrl: linkDialogState.url,
|
|
3163
|
-
onSubmit: onSubmitEH,
|
|
3164
|
-
onCancel: cancelLinkEdit.bind(null, true),
|
|
3165
|
-
linkAutocompleteSuggestions
|
|
3166
|
-
}
|
|
3167
|
-
),
|
|
3168
|
-
linkDialogState.type === "preview" && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
3169
|
-
"a",
|
|
3170
|
-
{
|
|
3171
|
-
className: styles.linkDialogPreviewAnchor,
|
|
3172
|
-
href: linkDialogState.url,
|
|
3173
|
-
...urlIsExternal ? { target: "_blank", rel: "noreferrer" } : {},
|
|
3174
|
-
title: urlIsExternal ? `Open ${linkDialogState.url} in new window` : linkDialogState.url
|
|
3175
|
-
},
|
|
3176
|
-
/* @__PURE__ */ React__default.createElement("span", null, linkDialogState.url),
|
|
3177
|
-
urlIsExternal && /* @__PURE__ */ React__default.createElement(OpenInNewIcon, null)
|
|
3178
|
-
), /* @__PURE__ */ React__default.createElement(ActionButton$1, { onClick: () => switchFromPreviewToLinkEdit(true), title: "Edit link URL", "aria-label": "Edit link URL" }, /* @__PURE__ */ React__default.createElement(EditIcon, null)), /* @__PURE__ */ React__default.createElement(Tooltip.Provider, null, /* @__PURE__ */ React__default.createElement(Tooltip.Root, { open: copyUrlTooltipOpen }, /* @__PURE__ */ React__default.createElement(Tooltip.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(
|
|
3179
|
-
ActionButton$1,
|
|
3180
|
-
{
|
|
3181
|
-
title: "Copy to clipboard",
|
|
3182
|
-
"aria-label": "Copy link URL",
|
|
3183
|
-
onClick: () => {
|
|
3184
|
-
void window.navigator.clipboard.writeText(linkDialogState.url).then(() => {
|
|
3185
|
-
setCopyUrlTooltipOpen(true);
|
|
3186
|
-
setTimeout(() => setCopyUrlTooltipOpen(false), 1e3);
|
|
3187
|
-
});
|
|
3188
|
-
}
|
|
3189
|
-
},
|
|
3190
|
-
copyUrlTooltipOpen ? /* @__PURE__ */ React__default.createElement(CheckIcon, null) : /* @__PURE__ */ React__default.createElement(CopyIcon, null)
|
|
3191
|
-
)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 5 }, "Copied!", /* @__PURE__ */ React__default.createElement(Tooltip.Arrow, null))))), /* @__PURE__ */ React__default.createElement(ActionButton$1, { title: "Remove link", "aria-label": "Remove link", onClick: () => removeLink(true) }, /* @__PURE__ */ React__default.createElement(LinkOffIcon, null)))
|
|
3192
|
-
)));
|
|
3193
|
-
}
|
|
3194
|
-
const ActionButton$1 = React__default.forwardRef(({ className, ...props }, ref) => {
|
|
3195
|
-
return /* @__PURE__ */ React__default.createElement("button", { className: classNames(styles.actionButton, className), ref, ...props });
|
|
3196
|
-
});
|
|
3197
|
-
function getElementNodesInSelection(selection) {
|
|
3198
|
-
const nodesInSelection = selection.getNodes();
|
|
3199
|
-
if (nodesInSelection.length === 0) {
|
|
3200
|
-
return /* @__PURE__ */ new Set([selection.anchor.getNode().getParentOrThrow(), selection.focus.getNode().getParentOrThrow()]);
|
|
3201
|
-
}
|
|
3202
|
-
return new Set(nodesInSelection.map((n) => $isElementNode(n) ? n : n.getParentOrThrow()));
|
|
3203
|
-
}
|
|
3204
|
-
function isIndentPermitted(maxDepth) {
|
|
3205
|
-
const selection = $getSelection();
|
|
3206
|
-
if (!$isRangeSelection(selection)) {
|
|
3207
|
-
return false;
|
|
3208
|
-
}
|
|
3209
|
-
const elementNodesInSelection = getElementNodesInSelection(selection);
|
|
3210
|
-
let totalDepth = 0;
|
|
3211
|
-
for (const elementNode of elementNodesInSelection) {
|
|
3212
|
-
if ($isListNode(elementNode)) {
|
|
3213
|
-
totalDepth = Math.max($getListDepth(elementNode) + 1, totalDepth);
|
|
3214
|
-
} else if ($isListItemNode(elementNode)) {
|
|
3215
|
-
const parent = elementNode.getParent();
|
|
3216
|
-
if ((parent == null ? void 0 : parent.getChildren().length) === 1) {
|
|
3217
|
-
const grandParentListItem = parent == null ? void 0 : parent.getParent();
|
|
3218
|
-
if ($isListItemNode(grandParentListItem) && grandParentListItem.getChildren().length === 1) {
|
|
3219
|
-
return false;
|
|
3220
|
-
}
|
|
3221
|
-
}
|
|
3222
|
-
if (!$isListNode(parent)) {
|
|
3223
|
-
throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");
|
|
3224
|
-
}
|
|
3225
|
-
totalDepth = Math.max($getListDepth(parent) + 1, totalDepth);
|
|
3226
|
-
}
|
|
3227
|
-
}
|
|
3228
|
-
return totalDepth <= maxDepth;
|
|
3229
|
-
}
|
|
3230
|
-
function ListMaxIndentLevelPlugin({ maxDepth }) {
|
|
3231
|
-
const [editor] = useLexicalComposerContext();
|
|
3232
|
-
useEffect(() => {
|
|
3233
|
-
return editor.registerCommand(INDENT_CONTENT_COMMAND, () => !isIndentPermitted(maxDepth ?? 7), COMMAND_PRIORITY_CRITICAL);
|
|
3234
|
-
}, [editor, maxDepth]);
|
|
3235
|
-
return null;
|
|
3236
|
-
}
|
|
3237
|
-
function patchMarkdownTransformers(transformers) {
|
|
3238
|
-
const codeTransformer = transformers.find((t) => t === CODE);
|
|
3239
|
-
codeTransformer.replace = (parentNode, _children, match) => {
|
|
3240
|
-
const codeBlockNode = $createCodeBlockNode({ code: "", language: match ? match[1] : "", meta: "" });
|
|
3241
|
-
parentNode.replace(codeBlockNode);
|
|
3242
|
-
setTimeout(() => codeBlockNode.select(), 80);
|
|
3243
|
-
};
|
|
3244
|
-
return transformers;
|
|
3245
|
-
}
|
|
3246
|
-
const PatchedMarkdownShortcutPlugin = () => {
|
|
3247
|
-
return /* @__PURE__ */ React__default.createElement(MarkdownShortcutPlugin, { transformers: patchMarkdownTransformers(TRANSFORMERS) });
|
|
3248
|
-
};
|
|
3249
|
-
function useCodeMirrorRef(nodeKey, editorType, language) {
|
|
3250
|
-
const [activeEditor] = useEmitterValues("activeEditor");
|
|
3251
|
-
const setActiveEditorType = usePublisher("activeEditorType");
|
|
3252
|
-
const codeMirrorRef = React__default.useRef(null);
|
|
3253
|
-
const atBottom = React__default.useRef(false);
|
|
3254
|
-
const atTop = React__default.useRef(false);
|
|
3255
|
-
const onFocusHandler = React__default.useCallback(() => {
|
|
3256
|
-
setActiveEditorType({ type: editorType, nodeKey });
|
|
3257
|
-
}, [nodeKey, setActiveEditorType, editorType]);
|
|
3258
|
-
const onKeyDownHandler = React__default.useCallback(
|
|
3259
|
-
(e) => {
|
|
3260
|
-
var _a, _b, _c, _d;
|
|
3261
|
-
if (e.key === "ArrowDown") {
|
|
3262
|
-
const state = (_b = (_a = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _a.getCodemirror()) == null ? void 0 : _b.state;
|
|
3263
|
-
if (state) {
|
|
3264
|
-
const docLength = state.doc.length;
|
|
3265
|
-
const selectionEnd = state.selection.ranges[0].to;
|
|
3266
|
-
if (docLength === selectionEnd) {
|
|
3267
|
-
if (!atBottom.current) {
|
|
3268
|
-
atBottom.current = true;
|
|
3269
|
-
} else {
|
|
3270
|
-
activeEditor == null ? void 0 : activeEditor.update(() => {
|
|
3271
|
-
var _a2, _b2;
|
|
3272
|
-
const node = $getNodeByKey(nodeKey);
|
|
3273
|
-
const nextSibling = node.getNextSibling();
|
|
3274
|
-
if (nextSibling) {
|
|
3275
|
-
(_b2 = (_a2 = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _a2.getCodemirror()) == null ? void 0 : _b2.contentDOM.blur();
|
|
3276
|
-
node.selectNext();
|
|
3277
|
-
} else {
|
|
3278
|
-
node.insertAfter($createParagraphNode());
|
|
3279
|
-
}
|
|
3280
|
-
});
|
|
3281
|
-
atBottom.current = false;
|
|
3282
|
-
}
|
|
3283
|
-
}
|
|
3284
|
-
}
|
|
3285
|
-
} else if (e.key === "ArrowUp") {
|
|
3286
|
-
const state = (_d = (_c = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _c.getCodemirror()) == null ? void 0 : _d.state;
|
|
3287
|
-
if (state) {
|
|
3288
|
-
const selectionStart = state.selection.ranges[0].from;
|
|
3289
|
-
if (selectionStart === 0) {
|
|
3290
|
-
if (!atTop.current) {
|
|
3291
|
-
atTop.current = true;
|
|
3292
|
-
} else {
|
|
3293
|
-
activeEditor == null ? void 0 : activeEditor.update(() => {
|
|
3294
|
-
var _a2, _b2;
|
|
3295
|
-
const node = $getNodeByKey(nodeKey);
|
|
3296
|
-
const previousSibling = node.getPreviousSibling();
|
|
3297
|
-
if (previousSibling) {
|
|
3298
|
-
(_b2 = (_a2 = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _a2.getCodemirror()) == null ? void 0 : _b2.contentDOM.blur();
|
|
3299
|
-
node.selectPrevious();
|
|
3300
|
-
}
|
|
3301
|
-
});
|
|
3302
|
-
atTop.current = false;
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
}
|
|
3306
|
-
} else if (e.key === "Enter") {
|
|
3307
|
-
e.stopPropagation();
|
|
3308
|
-
}
|
|
3309
|
-
},
|
|
3310
|
-
[activeEditor, nodeKey]
|
|
3311
|
-
);
|
|
3312
|
-
React__default.useEffect(() => {
|
|
3313
|
-
const codeMirror = codeMirrorRef.current;
|
|
3314
|
-
setTimeout(() => {
|
|
3315
|
-
var _a, _b, _c, _d;
|
|
3316
|
-
(_b = (_a = codeMirror == null ? void 0 : codeMirror.getCodemirror()) == null ? void 0 : _a.contentDOM) == null ? void 0 : _b.addEventListener("focus", onFocusHandler);
|
|
3317
|
-
(_d = (_c = codeMirror == null ? void 0 : codeMirror.getCodemirror()) == null ? void 0 : _c.contentDOM) == null ? void 0 : _d.addEventListener("keydown", onKeyDownHandler);
|
|
3318
|
-
}, 100);
|
|
3319
|
-
return () => {
|
|
3320
|
-
var _a, _b;
|
|
3321
|
-
(_a = codeMirror == null ? void 0 : codeMirror.getCodemirror()) == null ? void 0 : _a.contentDOM.removeEventListener("focus", onFocusHandler);
|
|
3322
|
-
(_b = codeMirror == null ? void 0 : codeMirror.getCodemirror()) == null ? void 0 : _b.contentDOM.removeEventListener("keydown", onKeyDownHandler);
|
|
3323
|
-
};
|
|
3324
|
-
}, [codeMirrorRef, onFocusHandler, onKeyDownHandler, language]);
|
|
3325
|
-
return codeMirrorRef;
|
|
3326
|
-
}
|
|
3327
|
-
const CodeBlockEditor = ({ nodeKey, code: code2, language, onChange, focusEmitter }) => {
|
|
3328
|
-
const [activeEditor] = useEmitterValues("activeEditor");
|
|
3329
|
-
const codeMirrorRef = useCodeMirrorRef(nodeKey, "codeblock", language);
|
|
3330
|
-
const setActiveEditorType = usePublisher("activeEditorType");
|
|
3331
|
-
React__default.useEffect(() => {
|
|
3332
|
-
focusEmitter.subscribe(() => {
|
|
3333
|
-
var _a, _b;
|
|
3334
|
-
(_b = (_a = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _a.getCodemirror()) == null ? void 0 : _b.focus();
|
|
3335
|
-
setActiveEditorType({ type: "codeblock", nodeKey });
|
|
3336
|
-
});
|
|
3337
|
-
}, [focusEmitter, codeMirrorRef, setActiveEditorType, nodeKey]);
|
|
3338
|
-
const wrappedOnChange = React__default.useCallback(
|
|
3339
|
-
(code22) => {
|
|
3340
|
-
activeEditor == null ? void 0 : activeEditor.update(() => {
|
|
3341
|
-
onChange(code22);
|
|
3342
|
-
});
|
|
3343
|
-
},
|
|
3344
|
-
[onChange, activeEditor]
|
|
3345
|
-
);
|
|
3346
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: styles.sandpackWrapper }, /* @__PURE__ */ React__default.createElement(SandpackProvider, null, /* @__PURE__ */ React__default.createElement(
|
|
3347
|
-
CodeEditor,
|
|
3348
|
-
{
|
|
3349
|
-
showLineNumbers: true,
|
|
3350
|
-
initMode: "immediate",
|
|
3351
|
-
key: language,
|
|
3352
|
-
filePath: `file.${language || "txt"}`,
|
|
3353
|
-
code: code2,
|
|
3354
|
-
onCodeUpdate: wrappedOnChange,
|
|
3355
|
-
ref: codeMirrorRef
|
|
3356
|
-
}
|
|
3357
|
-
)));
|
|
3358
|
-
};
|
|
3359
|
-
const SvgArrowRight = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3360
|
-
maskType: "alpha"
|
|
3361
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M10 17V7l5 5-5 5Z" })));
|
|
3362
|
-
const ArrowRight = SvgArrowRight;
|
|
3363
|
-
const SvgArrowDropDown = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3364
|
-
maskType: "alpha"
|
|
3365
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m12 15-5-5h10l-5 5Z" })));
|
|
3366
|
-
const ArrowDown = SvgArrowDropDown;
|
|
3367
|
-
const SvgDelete$1 = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3368
|
-
maskType: "alpha"
|
|
3369
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 17V6.5H4V5h4V4h4v1h4v1.5h-1V17H5Zm1.5-1.5h7v-9h-7v9ZM8 14h1.5V8H8v6Zm2.5 0H12V8h-1.5v6Z" })));
|
|
3370
|
-
const DeleteIcon$1 = SvgDelete$1;
|
|
3371
|
-
const FrontmatterEditor = ({ yaml, onChange }) => {
|
|
3372
|
-
const [expanded, setExpanded] = React__default.useState(true);
|
|
3373
|
-
const yamlConfig = React__default.useMemo(() => {
|
|
3374
|
-
if (!yaml) {
|
|
3375
|
-
return [];
|
|
3376
|
-
}
|
|
3377
|
-
return Object.entries(YamlParser.load(yaml)).map(([key, value]) => ({ key, value }));
|
|
3378
|
-
}, [yaml]);
|
|
3379
|
-
const { register, control, watch } = useForm({
|
|
3380
|
-
defaultValues: {
|
|
3381
|
-
yamlConfig
|
|
3382
|
-
}
|
|
3383
|
-
});
|
|
3384
|
-
const { fields, append, remove } = useFieldArray({
|
|
3385
|
-
control,
|
|
3386
|
-
name: "yamlConfig"
|
|
3387
|
-
});
|
|
3388
|
-
React__default.useEffect(() => {
|
|
3389
|
-
const subscription = watch(({ yamlConfig: yamlConfig2 }) => {
|
|
3390
|
-
const yaml2 = yamlConfig2.reduce((acc, { key, value }) => {
|
|
3391
|
-
if (key && value) {
|
|
3392
|
-
acc[key] = value;
|
|
3393
|
-
}
|
|
3394
|
-
return acc;
|
|
3395
|
-
}, {});
|
|
3396
|
-
onChange(YamlParser.dump(yaml2).trim());
|
|
3397
|
-
});
|
|
3398
|
-
return () => subscription.unsubscribe();
|
|
3399
|
-
}, [watch, onChange]);
|
|
3400
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: styles.frontmatterWrapper, "data-expanded": expanded, "data-editor-type": "frontmatter" }, /* @__PURE__ */ React__default.createElement(
|
|
3401
|
-
"button",
|
|
3402
|
-
{
|
|
3403
|
-
className: styles.frontmatterToggleButton,
|
|
3404
|
-
onClick: (e) => {
|
|
3405
|
-
e.preventDefault();
|
|
3406
|
-
setExpanded((v) => !v);
|
|
3407
|
-
}
|
|
3408
|
-
},
|
|
3409
|
-
expanded ? /* @__PURE__ */ React__default.createElement(ArrowDown, null) : /* @__PURE__ */ React__default.createElement(ArrowRight, null),
|
|
3410
|
-
"Document frontmatter"
|
|
3411
|
-
), expanded && /* @__PURE__ */ React__default.createElement("form", null, /* @__PURE__ */ React__default.createElement("table", { className: styles.frontmatterEditorTable }, /* @__PURE__ */ React__default.createElement("colgroup", null, /* @__PURE__ */ React__default.createElement("col", null), /* @__PURE__ */ React__default.createElement("col", null), /* @__PURE__ */ React__default.createElement("col", null)), /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null, "Key"), /* @__PURE__ */ React__default.createElement("th", null, "Value"), /* @__PURE__ */ React__default.createElement("th", null))), /* @__PURE__ */ React__default.createElement("tbody", null, fields.map((item, index2) => {
|
|
3412
|
-
return /* @__PURE__ */ React__default.createElement("tr", { key: item.id }, /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement(TableInput, { ...register(`yamlConfig.${index2}.key`, { required: true }), autofocusIfEmpty: true })), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement(TableInput, { ...register(`yamlConfig.${index2}.value`, { required: true }) })), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement("button", { type: "button", onClick: () => remove(index2), className: styles.iconButton }, /* @__PURE__ */ React__default.createElement(DeleteIcon$1, null))));
|
|
3413
|
-
})), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement(
|
|
3414
|
-
"button",
|
|
3415
|
-
{
|
|
3416
|
-
className: styles.primaryButton,
|
|
3417
|
-
type: "button",
|
|
3418
|
-
onClick: () => {
|
|
3419
|
-
append({ key: "", value: "" });
|
|
3420
|
-
}
|
|
3421
|
-
},
|
|
3422
|
-
"Add new key"
|
|
3423
|
-
)))))));
|
|
3424
|
-
};
|
|
3425
|
-
const TableInput = React__default.forwardRef(({ className, autofocusIfEmpty, ...props }, ref) => {
|
|
3426
|
-
props.autoFocus = Boolean(!props.value && autofocusIfEmpty);
|
|
3427
|
-
return /* @__PURE__ */ React__default.createElement("input", { className: classNames(styles.frontmatterInput, className), ...props, ref });
|
|
3428
|
-
});
|
|
3429
|
-
const SvgSettings = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3430
|
-
maskType: "alpha"
|
|
3431
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m9.25 22-.4-3.2a3.79 3.79 0 0 1-.613-.3 8.266 8.266 0 0 1-.562-.375L4.7 19.375l-2.75-4.75 2.575-1.95a2.387 2.387 0 0 1-.025-.338v-.675c0-.108.008-.22.025-.337L1.95 9.375l2.75-4.75 2.975 1.25c.183-.133.375-.258.575-.375.2-.117.4-.217.6-.3l.4-3.2h5.5l.4 3.2c.217.083.42.183.612.3.192.117.38.242.563.375l2.975-1.25 2.75 4.75-2.575 1.95c.017.117.025.23.025.338v.675c0 .108-.017.22-.05.337l2.575 1.95-2.75 4.75-2.95-1.25a6.842 6.842 0 0 1-.575.375c-.2.117-.4.217-.6.3l-.4 3.2h-5.5Zm2.8-6.5c.967 0 1.792-.342 2.475-1.025A3.372 3.372 0 0 0 15.55 12c0-.967-.342-1.792-1.025-2.475A3.373 3.373 0 0 0 12.05 8.5c-.983 0-1.813.342-2.488 1.025A3.393 3.393 0 0 0 8.55 12c0 .967.337 1.792 1.012 2.475.676.683 1.505 1.025 2.488 1.025Zm0-2c-.417 0-.77-.146-1.063-.438A1.446 1.446 0 0 1 10.55 12c0-.417.146-.77.438-1.063a1.446 1.446 0 0 1 1.062-.437c.417 0 .77.146 1.063.438.291.291.437.645.437 1.062 0 .417-.146.77-.438 1.063a1.447 1.447 0 0 1-1.062.437ZM11 20h1.975l.35-2.65a5.61 5.61 0 0 0 1.438-.588c.441-.258.845-.57 1.212-.937l2.475 1.025.975-1.7-2.15-1.625c.083-.233.142-.48.175-.738a6.153 6.153 0 0 0 0-1.575 3.535 3.535 0 0 0-.175-.737l2.15-1.625-.975-1.7-2.475 1.05a5.556 5.556 0 0 0-1.213-.962 5.607 5.607 0 0 0-1.437-.588L13 4h-1.975l-.35 2.65c-.517.133-.996.33-1.438.587a6.015 6.015 0 0 0-1.212.938L5.55 7.15l-.975 1.7 2.15 1.6c-.083.25-.142.5-.175.75a6.122 6.122 0 0 0 0 1.575c.033.25.092.5.175.75l-2.15 1.625.975 1.7 2.475-1.05c.367.383.77.704 1.212.962.442.259.921.455 1.438.588L11 20Z" })));
|
|
3432
|
-
const SettingsIcon = SvgSettings;
|
|
3433
|
-
const PopoverContent = React__default.forwardRef(
|
|
3434
|
-
(props, ref) => {
|
|
3435
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Content, { ...props, className: "", ref });
|
|
3436
|
-
}
|
|
3437
|
-
);
|
|
3438
|
-
const PopoverTrigger = React__default.forwardRef(
|
|
3439
|
-
(props, ref) => {
|
|
3440
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Trigger, { ...props, className: "", ref });
|
|
3441
|
-
}
|
|
3442
|
-
);
|
|
3443
|
-
function JsxEditor({ kind, attributes, componentName, editor, onSubmit, theme: theme2 }) {
|
|
3444
|
-
if (kind === "flow") {
|
|
3445
|
-
return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", null, componentName), /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor, initialTheme: theme2 }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, null), placeholder: /* @__PURE__ */ React__default.createElement("div", null, "Type here.."), ErrorBoundary: LexicalErrorBoundary })));
|
|
3446
|
-
}
|
|
3447
|
-
return /* @__PURE__ */ React__default.createElement("span", null, /* @__PURE__ */ React__default.createElement("span", null, /* @__PURE__ */ React__default.createElement(InlineJsxComponent, { attributes, componentName, onSubmit })), /* @__PURE__ */ React__default.createElement("span", null, componentName, /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor, initialTheme: theme2 }, /* @__PURE__ */ React__default.createElement(
|
|
3448
|
-
RichTextPlugin,
|
|
3449
|
-
{
|
|
3450
|
-
contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { style: { padding: 5, border: "1px solid red" } }),
|
|
3451
|
-
placeholder: /* @__PURE__ */ React__default.createElement("div", null, "Type here.."),
|
|
3452
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
3453
|
-
}
|
|
3454
|
-
))));
|
|
3455
|
-
}
|
|
3456
|
-
const InlineJsxComponent = ({ attributes, componentName, onSubmit }) => {
|
|
3457
|
-
const [open, setOpen] = React__default.useState(false);
|
|
3458
|
-
const decoratedOnSubmit = React__default.useCallback(
|
|
3459
|
-
(values) => {
|
|
3460
|
-
onSubmit(values);
|
|
3461
|
-
setOpen(false);
|
|
3462
|
-
},
|
|
3463
|
-
[onSubmit]
|
|
3464
|
-
);
|
|
3465
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, { open, onOpenChange: (v) => setOpen(v) }, /* @__PURE__ */ React__default.createElement(PopoverTrigger, null, /* @__PURE__ */ React__default.createElement(SettingsIcon, null)), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, null, /* @__PURE__ */ React__default.createElement(PopoverContent, null, /* @__PURE__ */ React__default.createElement(JsxPropertyPanel, { attributes, componentName, onSubmit: decoratedOnSubmit }))));
|
|
3466
|
-
};
|
|
3467
|
-
const JsxPropertyPanel = ({ attributes, componentName, onSubmit }) => {
|
|
3468
|
-
const [jsxComponentDescriptors] = useEmitterValues("jsxComponentDescriptors");
|
|
3469
|
-
const descriptor = jsxComponentDescriptors.find((descriptor2) => descriptor2.name === componentName);
|
|
3470
|
-
const [editor] = useLexicalComposerContext();
|
|
3471
|
-
const { register, handleSubmit } = useForm({
|
|
3472
|
-
defaultValues: attributes.reduce((acc, attribute) => {
|
|
3473
|
-
acc[attribute.name] = attribute.value;
|
|
3474
|
-
return acc;
|
|
3475
|
-
}, {})
|
|
3476
|
-
});
|
|
3477
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3478
|
-
"form",
|
|
3479
|
-
{
|
|
3480
|
-
onSubmit: handleSubmit((data) => {
|
|
3481
|
-
editor.update(() => {
|
|
3482
|
-
onSubmit(data);
|
|
3483
|
-
});
|
|
3484
|
-
})
|
|
3485
|
-
},
|
|
3486
|
-
/* @__PURE__ */ React__default.createElement("table", null, /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null, "Attribute"), /* @__PURE__ */ React__default.createElement("th", null, "Value"))), /* @__PURE__ */ React__default.createElement("tbody", null, descriptor.props.map((propDescriptor) => /* @__PURE__ */ React__default.createElement("tr", { key: propDescriptor.name }, /* @__PURE__ */ React__default.createElement("td", null, " ", propDescriptor.name, " "), /* @__PURE__ */ React__default.createElement("td", null, /* @__PURE__ */ React__default.createElement("input", { ...register(propDescriptor.name) })))))),
|
|
3487
|
-
/* @__PURE__ */ React__default.createElement("button", { type: "submit" }, "Submit")
|
|
3488
|
-
);
|
|
3489
|
-
};
|
|
3490
|
-
const CodeUpdateEmitter = ({ onChange, snippetFileName }) => {
|
|
3491
|
-
const { sandpack } = useSandpack();
|
|
3492
|
-
onChange(sandpack.files[snippetFileName].code);
|
|
3493
|
-
return null;
|
|
3494
|
-
};
|
|
3495
|
-
function getPresetOrDefault(meta, config) {
|
|
3496
|
-
return config.presets.find((preset) => preset.meta === meta) || config.presets.find((preset) => preset.name === config.defaultPreset);
|
|
3497
|
-
}
|
|
3498
|
-
const SandpackEditor = ({ nodeKey, code: code2, meta, onChange, focusEmitter }) => {
|
|
3499
|
-
const [editor] = useLexicalComposerContext();
|
|
3500
|
-
const [config] = useEmitterValues("sandpackConfig");
|
|
3501
|
-
const codeMirrorRef = useCodeMirrorRef(nodeKey, "sandpack", "jsx");
|
|
3502
|
-
const setActiveEditorType = usePublisher("activeEditorType");
|
|
3503
|
-
React__default.useEffect(() => {
|
|
3504
|
-
focusEmitter.subscribe(() => {
|
|
3505
|
-
var _a, _b;
|
|
3506
|
-
(_b = (_a = codeMirrorRef == null ? void 0 : codeMirrorRef.current) == null ? void 0 : _a.getCodemirror()) == null ? void 0 : _b.focus();
|
|
3507
|
-
setActiveEditorType({ type: "sandpack", nodeKey });
|
|
3508
|
-
});
|
|
3509
|
-
}, [focusEmitter, codeMirrorRef, setActiveEditorType, nodeKey]);
|
|
3510
|
-
const wrappedOnChange = React__default.useCallback(
|
|
3511
|
-
(code22) => {
|
|
3512
|
-
editor.update(() => {
|
|
3513
|
-
onChange(code22);
|
|
3514
|
-
});
|
|
3515
|
-
},
|
|
3516
|
-
[onChange, editor]
|
|
3517
|
-
);
|
|
3518
|
-
const preset = getPresetOrDefault(meta, config);
|
|
3519
|
-
if (!preset) {
|
|
3520
|
-
throw new Error(`No sandpack preset found for meta: ${meta}`);
|
|
3521
|
-
}
|
|
3522
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3523
|
-
SandpackProvider,
|
|
3524
|
-
{
|
|
3525
|
-
template: preset.sandpackTemplate,
|
|
3526
|
-
theme: preset.sandpackTheme,
|
|
3527
|
-
files: {
|
|
3528
|
-
[preset.snippetFileName]: code2,
|
|
3529
|
-
...Object.entries(preset.files || {}).reduce(
|
|
3530
|
-
(acc, [filePath, fileContents]) => ({ ...acc, ...{ [filePath]: { code: fileContents, readOnly: true } } }),
|
|
3531
|
-
{}
|
|
3532
|
-
)
|
|
3533
|
-
},
|
|
3534
|
-
customSetup: {
|
|
3535
|
-
dependencies: preset.dependencies
|
|
3536
|
-
}
|
|
3537
|
-
},
|
|
3538
|
-
/* @__PURE__ */ React__default.createElement(SandpackLayout, null, /* @__PURE__ */ React__default.createElement(SandpackCodeEditor, { showLineNumbers: true, showInlineErrors: true, ref: codeMirrorRef }), /* @__PURE__ */ React__default.createElement(SandpackPreview, null)),
|
|
3539
|
-
/* @__PURE__ */ React__default.createElement(CodeUpdateEmitter, { onChange: wrappedOnChange, snippetFileName: preset.snippetFileName })
|
|
3540
|
-
);
|
|
3541
|
-
};
|
|
3542
|
-
const MarkdownAstRenderer = (props) => {
|
|
3543
|
-
const root = { type: "root", children: props.mdastChildren };
|
|
3544
|
-
const hast = raw(toHast(root, { allowDangerousHtml: true }));
|
|
3545
|
-
const safeHast = sanitize(hast);
|
|
3546
|
-
const html = toHtml(safeHast);
|
|
3547
|
-
return /* @__PURE__ */ React__default.createElement("span", { dangerouslySetInnerHTML: { __html: html || " " } });
|
|
3548
|
-
};
|
|
3549
|
-
const SvgMoreHoriz = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3550
|
-
maskType: "alpha"
|
|
3551
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6 14c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 4 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 6 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 6 14Zm6 0c-.55 0-1.02-.196-1.412-.588A1.926 1.926 0 0 1 10 12c0-.55.196-1.02.588-1.412A1.926 1.926 0 0 1 12 10c.55 0 1.02.196 1.412.588.392.391.588.862.588 1.412 0 .55-.196 1.02-.588 1.412A1.926 1.926 0 0 1 12 14Zm6 0c-.55 0-1.02-.196-1.413-.588A1.926 1.926 0 0 1 16 12c0-.55.196-1.02.587-1.412A1.926 1.926 0 0 1 18 10c.55 0 1.02.196 1.413.588.391.391.587.862.587 1.412 0 .55-.196 1.02-.587 1.412A1.926 1.926 0 0 1 18 14Z" })));
|
|
3552
|
-
const MoreHorizIcon = SvgMoreHoriz;
|
|
3553
|
-
const SvgFormatAlignLeft = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3554
|
-
maskType: "alpha"
|
|
3555
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm0-3.125v-1.5h10v1.5H3Zm0-3.125v-1.5h14v1.5H3Zm0-3.125v-1.5h10v1.5H3ZM3 4.5V3h14v1.5H3Z" })));
|
|
3556
|
-
const AlignLeftIcon = SvgFormatAlignLeft;
|
|
3557
|
-
const SvgFormatAlignCenter = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3558
|
-
maskType: "alpha"
|
|
3559
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm3-3.125v-1.5h8v1.5H6ZM3 10.75v-1.5h14v1.5H3Zm3-3.125v-1.5h8v1.5H6ZM3 4.5V3h14v1.5H3Z" })));
|
|
3560
|
-
const AlignCenterIcon = SvgFormatAlignCenter;
|
|
3561
|
-
const SvgFormatAlignRight = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3562
|
-
maskType: "alpha"
|
|
3563
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 17v-1.5h14V17H3Zm4-3.125v-1.5h10v1.5H7ZM3 10.75v-1.5h14v1.5H3Zm4-3.125v-1.5h10v1.5H7ZM3 4.5V3h14v1.5H3Z" })));
|
|
3564
|
-
const AlignRightIcon = SvgFormatAlignRight;
|
|
3565
|
-
const SvgInsertColLeft = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3566
|
-
maskType: "alpha"
|
|
3567
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 20h20v20H0z", transform: "rotate(-90 0 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M15.75 4.5H13v2.75h-1.5V4.5H8.75V3h2.75V.25H13V3h2.75v1.5ZM13 17H5V3h2.25v1.5H6.5v11h5V8.75H13V17Z" })));
|
|
3568
|
-
const InsertColLeftIcon = SvgInsertColLeft;
|
|
3569
|
-
const SvgInsertColRight = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3570
|
-
maskType: "alpha"
|
|
3571
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(0 -1 -1 0 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.25 4.5H7v2.75h1.5V4.5h2.75V3H8.5V.25H7V3H4.25v1.5ZM7 17h8V3h-2.25v1.5h.75v11h-5V8.75H7V17Z" })));
|
|
3572
|
-
const InsertColRightIcon = SvgInsertColRight;
|
|
3573
|
-
const SvgDeleteSmall = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3574
|
-
maskType: "alpha"
|
|
3575
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6.5 17a1.45 1.45 0 0 1-1.06-.44A1.445 1.445 0 0 1 5 15.5v-10H4V4h4V3h4v1h4v1.5h-1v9.991c0 .423-.147.78-.44 1.072A1.45 1.45 0 0 1 13.5 17h-7Zm7-11.5h-7v10h7v-10ZM8 14h1.5V7H8v7Zm2.5 0H12V7h-1.5v7Z" })));
|
|
3576
|
-
const DeleteSmallIcon = SvgDeleteSmall;
|
|
3577
|
-
const SvgInsertRowAbove = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3578
|
-
maskType: "alpha"
|
|
3579
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(-1 0 0 1 20 0)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.5 16.75V14h2.75v-1.5H4.5V9.75H3v2.75H.25V14H3v2.75h1.5ZM17 14V6H3v2.25h1.5V7.5h11v5H8.75V14H17Z" })));
|
|
3580
|
-
const InsertRowAboveIcon = SvgInsertRowAbove;
|
|
3581
|
-
const SvgInsertRowBelow = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3582
|
-
maskType: "alpha"
|
|
3583
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M20 20h20v20H20z", transform: "rotate(180 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4.5 3.25V6h2.75v1.5H4.5v2.75H3V7.5H.25V6H3V3.25h1.5ZM17 6v8H3v-2.25h1.5v.75h11v-5H8.75V6H17Z" })));
|
|
3584
|
-
const InsertRowBelowIcon = SvgInsertRowBelow;
|
|
3585
|
-
const SvgAddRow = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3586
|
-
maskType: "alpha"
|
|
3587
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M20 20h20v20H20z", transform: "rotate(180 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M10.5 3.25V6h2.75v1.5H10.5v2.75H9V7.5H6.25V6H9V3.25h1.5ZM17 6v8H3V6h2.5v1.5h-1v5h11v-5H14V6h3Z" })));
|
|
3588
|
-
const AddRowIcon = SvgAddRow;
|
|
3589
|
-
const SvgAddColumn = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 20, fill: "currentColor", viewBox: "0 0 20 20", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 20, height: 20, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
3590
|
-
maskType: "alpha"
|
|
3591
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h20v20H0z", transform: "matrix(0 -1 -1 0 20 20)" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3.25 10.5H6v2.75h1.5V10.5h2.75V9H7.5V6.25H6V9H3.25v1.5ZM6 17h8V3H6v2.5h1.5v-1h5v11h-5V14H6v3Z" })));
|
|
3592
|
-
const AddColumnIcon = SvgAddColumn;
|
|
3593
|
-
const SharedHistoryPlugin = () => {
|
|
3594
|
-
const [historyState] = useEmitterValues("historyState");
|
|
3595
|
-
return /* @__PURE__ */ React__default.createElement(HistoryPlugin, { externalHistoryState: historyState });
|
|
3596
|
-
};
|
|
3597
|
-
const AlignToTailwindClassMap = {
|
|
3598
|
-
center: styles.centeredCell,
|
|
3599
|
-
left: styles.leftAlignedCell,
|
|
3600
|
-
right: styles.rightAlignedCell
|
|
3601
|
-
};
|
|
3602
|
-
const TableEditor = ({ mdastNode, parentEditor, lexicalTable }) => {
|
|
3603
|
-
const [activeCell, setActiveCell] = React__default.useState(null);
|
|
3604
|
-
const setActiveCellWithBoundaries = React__default.useCallback(
|
|
3605
|
-
(cell) => {
|
|
3606
|
-
const colCount = lexicalTable.getColCount();
|
|
3607
|
-
if (cell === null) {
|
|
3608
|
-
setActiveCell(null);
|
|
3609
|
-
return;
|
|
3610
|
-
}
|
|
3611
|
-
let [colIndex, rowIndex] = cell;
|
|
3612
|
-
if (colIndex > colCount - 1) {
|
|
3613
|
-
colIndex = 0;
|
|
3614
|
-
rowIndex++;
|
|
3615
|
-
}
|
|
3616
|
-
if (colIndex < 0) {
|
|
3617
|
-
colIndex = colCount - 1;
|
|
3618
|
-
rowIndex -= 1;
|
|
3619
|
-
}
|
|
3620
|
-
if (rowIndex > lexicalTable.getRowCount() - 1) {
|
|
3621
|
-
setActiveCell(null);
|
|
3622
|
-
parentEditor.update(() => {
|
|
3623
|
-
const nextSibling = lexicalTable.getLatest().getNextSibling();
|
|
3624
|
-
if (nextSibling) {
|
|
3625
|
-
lexicalTable.getLatest().selectNext();
|
|
3626
|
-
} else {
|
|
3627
|
-
const newParagraph = $createParagraphNode();
|
|
3628
|
-
lexicalTable.insertAfter(newParagraph);
|
|
3629
|
-
newParagraph.select();
|
|
3630
|
-
}
|
|
3631
|
-
});
|
|
3632
|
-
return;
|
|
3633
|
-
}
|
|
3634
|
-
if (rowIndex < 0) {
|
|
3635
|
-
setActiveCell(null);
|
|
3636
|
-
parentEditor.update(() => {
|
|
3637
|
-
lexicalTable.getLatest().selectPrevious();
|
|
3638
|
-
});
|
|
3639
|
-
return;
|
|
3640
|
-
}
|
|
3641
|
-
setActiveCell([colIndex, rowIndex]);
|
|
3642
|
-
},
|
|
3643
|
-
[lexicalTable, parentEditor]
|
|
3644
|
-
);
|
|
3645
|
-
useEffect(() => {
|
|
3646
|
-
lexicalTable.focusEmitter.subscribe(setActiveCellWithBoundaries);
|
|
3647
|
-
}, [lexicalTable, setActiveCellWithBoundaries]);
|
|
3648
|
-
const addRowToBottom = React__default.useCallback(() => {
|
|
3649
|
-
parentEditor.update(() => {
|
|
3650
|
-
lexicalTable.addRowToBottom();
|
|
3651
|
-
setActiveCell([0, lexicalTable.getRowCount()]);
|
|
3652
|
-
});
|
|
3653
|
-
}, [parentEditor, lexicalTable]);
|
|
3654
|
-
const addColumnToRight = React__default.useCallback(() => {
|
|
3655
|
-
parentEditor.update(() => {
|
|
3656
|
-
lexicalTable.addColumnToRight();
|
|
3657
|
-
setActiveCell([lexicalTable.getColCount(), 0]);
|
|
3658
|
-
});
|
|
3659
|
-
}, [parentEditor, lexicalTable]);
|
|
3660
|
-
const [highlightedCoordinates, setHighlightedCoordinates] = React__default.useState([-1, -1]);
|
|
3661
|
-
const onTableMouseOver = React__default.useCallback((e) => {
|
|
3662
|
-
let tableCell = e.target;
|
|
3663
|
-
while (tableCell && !["TH", "TD"].includes(tableCell.tagName)) {
|
|
3664
|
-
if (tableCell === e.currentTarget) {
|
|
3665
|
-
return;
|
|
3666
|
-
}
|
|
3667
|
-
tableCell = tableCell.parentElement;
|
|
3668
|
-
}
|
|
3669
|
-
if (tableCell === null) {
|
|
3670
|
-
return;
|
|
3671
|
-
}
|
|
3672
|
-
const tableRow = tableCell.parentElement;
|
|
3673
|
-
const tableContainer = tableRow.parentElement;
|
|
3674
|
-
const colIndex = tableContainer.tagName === "TFOOT" ? -1 : Array.from(tableRow.children).indexOf(tableCell);
|
|
3675
|
-
const rowIndex = tableCell.tagName === "TH" ? -1 : Array.from(tableRow.parentElement.children).indexOf(tableRow);
|
|
3676
|
-
setHighlightedCoordinates([colIndex, rowIndex]);
|
|
3677
|
-
}, []);
|
|
3678
|
-
return /* @__PURE__ */ React__default.createElement("table", { className: styles.tableEditor, onMouseOver: onTableMouseOver, onMouseLeave: () => setHighlightedCoordinates([-1, -1]) }, /* @__PURE__ */ React__default.createElement("colgroup", null, /* @__PURE__ */ React__default.createElement("col", null), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
|
|
3679
|
-
const align = mdastNode.align || [];
|
|
3680
|
-
const currentColumnAlign = align[colIndex] || "left";
|
|
3681
|
-
const className = AlignToTailwindClassMap[currentColumnAlign];
|
|
3682
|
-
return /* @__PURE__ */ React__default.createElement("col", { key: colIndex, className });
|
|
3683
|
-
}), /* @__PURE__ */ React__default.createElement("col", null)), /* @__PURE__ */ React__default.createElement("thead", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
|
|
3684
|
-
"button",
|
|
3685
|
-
{
|
|
3686
|
-
className: styles.iconButton,
|
|
3687
|
-
title: "Delete table",
|
|
3688
|
-
onClick: () => {
|
|
3689
|
-
parentEditor.update(() => {
|
|
3690
|
-
lexicalTable.selectNext();
|
|
3691
|
-
lexicalTable.remove();
|
|
3692
|
-
});
|
|
3693
|
-
}
|
|
3694
|
-
},
|
|
3695
|
-
/* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)
|
|
3696
|
-
)), Array.from({ length: mdastNode.children[0].children.length }, (_, colIndex) => {
|
|
3697
|
-
return /* @__PURE__ */ React__default.createElement("th", { key: colIndex, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(
|
|
3698
|
-
ColumnEditor,
|
|
3699
|
-
{
|
|
3700
|
-
...{
|
|
3701
|
-
setActiveCellWithBoundaries,
|
|
3702
|
-
parentEditor,
|
|
3703
|
-
colIndex,
|
|
3704
|
-
highlightedCoordinates,
|
|
3705
|
-
lexicalTable,
|
|
3706
|
-
align: (mdastNode.align || [])[colIndex]
|
|
3707
|
-
}
|
|
3708
|
-
}
|
|
3709
|
-
));
|
|
3710
|
-
}), /* @__PURE__ */ React__default.createElement("th", { className: styles.tableToolsColumn }))), /* @__PURE__ */ React__default.createElement("tbody", null, mdastNode.children.map((row, rowIndex) => {
|
|
3711
|
-
return /* @__PURE__ */ React__default.createElement("tr", { key: rowIndex }, /* @__PURE__ */ React__default.createElement("td", { className: styles.toolCell, "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement(RowEditor, { ...{ setActiveCellWithBoundaries, parentEditor, rowIndex, highlightedCoordinates, lexicalTable } })), row.children.map((mdastCell, colIndex) => {
|
|
3712
|
-
var _a;
|
|
3713
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3714
|
-
Cell,
|
|
3715
|
-
{
|
|
3716
|
-
align: (_a = mdastNode.align) == null ? void 0 : _a[colIndex],
|
|
3717
|
-
key: colIndex,
|
|
3718
|
-
contents: mdastCell.children,
|
|
3719
|
-
...{ rowIndex, colIndex, lexicalTable, parentEditor, activeCellTuple: [activeCell, setActiveCellWithBoundaries] }
|
|
3720
|
-
}
|
|
3721
|
-
);
|
|
3722
|
-
}), rowIndex === 0 && /* @__PURE__ */ React__default.createElement("th", { rowSpan: lexicalTable.getRowCount(), "data-tool-cell": true }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addColumnButton, onClick: addColumnToRight }, /* @__PURE__ */ React__default.createElement(AddColumnIcon, null))));
|
|
3723
|
-
})), /* @__PURE__ */ React__default.createElement("tfoot", null, /* @__PURE__ */ React__default.createElement("tr", null, /* @__PURE__ */ React__default.createElement("th", null), /* @__PURE__ */ React__default.createElement("th", { colSpan: lexicalTable.getColCount() }, /* @__PURE__ */ React__default.createElement("button", { className: styles.addRowButton, onClick: addRowToBottom }, /* @__PURE__ */ React__default.createElement(AddRowIcon, null))), /* @__PURE__ */ React__default.createElement("th", null))));
|
|
3724
|
-
};
|
|
3725
|
-
const Cell = ({ align, ...props }) => {
|
|
3726
|
-
const [activeCell, setActiveCell] = props.activeCellTuple;
|
|
3727
|
-
const isActive = activeCell && activeCell[0] === props.colIndex && activeCell[1] === props.rowIndex;
|
|
3728
|
-
const className = AlignToTailwindClassMap[align || "left"];
|
|
3729
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3730
|
-
"td",
|
|
3731
|
-
{
|
|
3732
|
-
className,
|
|
3733
|
-
"data-active": isActive,
|
|
3734
|
-
onClick: () => {
|
|
3735
|
-
setActiveCell([props.colIndex, props.rowIndex]);
|
|
3736
|
-
}
|
|
3737
|
-
},
|
|
3738
|
-
isActive ? /* @__PURE__ */ React__default.createElement(CellEditor, { ...props }) : /* @__PURE__ */ React__default.createElement(MarkdownAstRenderer, { mdastChildren: props.contents })
|
|
3739
|
-
);
|
|
3740
|
-
};
|
|
3741
|
-
const CellEditor = ({ activeCellTuple, parentEditor, lexicalTable, contents, colIndex, rowIndex }) => {
|
|
3742
|
-
const [markdownParseOptions, lexicalConvertOptions, jsxComponentDescriptors, lexicalNodes] = useEmitterValues(
|
|
3743
|
-
"markdownParseOptions",
|
|
3744
|
-
"lexicalConvertOptions",
|
|
3745
|
-
"jsxComponentDescriptors",
|
|
3746
|
-
"lexicalNodes"
|
|
3747
|
-
);
|
|
3748
|
-
const [editor] = React__default.useState(() => {
|
|
3749
|
-
let disposed = false;
|
|
3750
|
-
const editor2 = createEditor({
|
|
3751
|
-
nodes: lexicalNodes,
|
|
3752
|
-
theme
|
|
3753
|
-
});
|
|
3754
|
-
function saveAndDispose(nextCell) {
|
|
3755
|
-
if (disposed) {
|
|
3756
|
-
return;
|
|
3757
|
-
}
|
|
3758
|
-
disposed = true;
|
|
3759
|
-
editor2.getEditorState().read(() => {
|
|
3760
|
-
const mdast = exportLexicalTreeToMdast({
|
|
3761
|
-
root: $getRoot(),
|
|
3762
|
-
jsxComponentDescriptors,
|
|
3763
|
-
...lexicalConvertOptions
|
|
3764
|
-
});
|
|
3765
|
-
parentEditor.update(() => {
|
|
3766
|
-
lexicalTable.updateCellContents(colIndex, rowIndex, mdast.children[0].children);
|
|
3767
|
-
});
|
|
3768
|
-
});
|
|
3769
|
-
activeCellTuple[1](nextCell);
|
|
3770
|
-
}
|
|
3771
|
-
editor2.registerCommand(
|
|
3772
|
-
KEY_TAB_COMMAND,
|
|
3773
|
-
(payload) => {
|
|
3774
|
-
payload.preventDefault();
|
|
3775
|
-
const nextCell = payload.shiftKey ? [colIndex - 1, rowIndex] : [colIndex + 1, rowIndex];
|
|
3776
|
-
saveAndDispose(nextCell);
|
|
3777
|
-
return true;
|
|
3778
|
-
},
|
|
3779
|
-
COMMAND_PRIORITY_CRITICAL
|
|
3780
|
-
);
|
|
3781
|
-
editor2.registerCommand(
|
|
3782
|
-
KEY_ENTER_COMMAND,
|
|
3783
|
-
(payload) => {
|
|
3784
|
-
payload == null ? void 0 : payload.preventDefault();
|
|
3785
|
-
const nextCell = (payload == null ? void 0 : payload.shiftKey) ? [colIndex, rowIndex - 1] : [colIndex, rowIndex + 1];
|
|
3786
|
-
saveAndDispose(nextCell);
|
|
3787
|
-
return true;
|
|
3788
|
-
},
|
|
3789
|
-
COMMAND_PRIORITY_CRITICAL
|
|
3790
|
-
);
|
|
3791
|
-
editor2.registerCommand(
|
|
3792
|
-
BLUR_COMMAND,
|
|
3793
|
-
(payload) => {
|
|
3794
|
-
const relatedTarget = payload.relatedTarget;
|
|
3795
|
-
if ((relatedTarget == null ? void 0 : relatedTarget.dataset["editorDialog"]) !== void 0) {
|
|
3796
|
-
return false;
|
|
3797
|
-
}
|
|
3798
|
-
saveAndDispose(null);
|
|
3799
|
-
return true;
|
|
3800
|
-
},
|
|
3801
|
-
COMMAND_PRIORITY_CRITICAL
|
|
3802
|
-
);
|
|
3803
|
-
editor2.registerRootListener((element) => {
|
|
3804
|
-
if (element) {
|
|
3805
|
-
editor2.focus();
|
|
3806
|
-
}
|
|
3807
|
-
});
|
|
3808
|
-
editor2.update(() => {
|
|
3809
|
-
importMdastTreeToLexical({
|
|
3810
|
-
root: $getRoot(),
|
|
3811
|
-
mdastRoot: { type: "root", children: [{ type: "paragraph", children: contents }] },
|
|
3812
|
-
visitors: markdownParseOptions.visitors
|
|
3813
|
-
});
|
|
3814
|
-
});
|
|
3815
|
-
return editor2;
|
|
3816
|
-
});
|
|
3817
|
-
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(RichTextPlugin, { contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { autoFocus: true }), placeholder: /* @__PURE__ */ React__default.createElement("div", null), ErrorBoundary: LexicalErrorBoundary }), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null));
|
|
3818
|
-
};
|
|
3819
|
-
const ColumnEditor = ({
|
|
3820
|
-
parentEditor,
|
|
3821
|
-
highlightedCoordinates,
|
|
3822
|
-
align,
|
|
3823
|
-
lexicalTable,
|
|
3824
|
-
colIndex,
|
|
3825
|
-
setActiveCellWithBoundaries
|
|
3826
|
-
}) => {
|
|
3827
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3828
|
-
const insertColumnAt = React__default.useCallback(
|
|
3829
|
-
(colIndex2) => {
|
|
3830
|
-
parentEditor.update(() => {
|
|
3831
|
-
lexicalTable.insertColumnAt(colIndex2);
|
|
3832
|
-
});
|
|
3833
|
-
setActiveCellWithBoundaries([colIndex2, 0]);
|
|
3834
|
-
},
|
|
3835
|
-
[parentEditor, lexicalTable, setActiveCellWithBoundaries]
|
|
3836
|
-
);
|
|
3837
|
-
const deleteColumnAt = React__default.useCallback(
|
|
3838
|
-
(colIndex2) => {
|
|
3839
|
-
parentEditor.update(() => {
|
|
3840
|
-
lexicalTable.deleteColumnAt(colIndex2);
|
|
3841
|
-
});
|
|
3842
|
-
},
|
|
3843
|
-
[parentEditor, lexicalTable]
|
|
3844
|
-
);
|
|
3845
|
-
const setColumnAlign = React__default.useCallback(
|
|
3846
|
-
(colIndex2, align2) => {
|
|
3847
|
-
parentEditor.update(() => {
|
|
3848
|
-
lexicalTable.setColumnAlign(colIndex2, align2);
|
|
3849
|
-
});
|
|
3850
|
-
},
|
|
3851
|
-
[parentEditor, lexicalTable]
|
|
3852
|
-
);
|
|
3853
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, null, /* @__PURE__ */ React__default.createElement(
|
|
3854
|
-
RadixPopover.PopoverTrigger,
|
|
3855
|
-
{
|
|
3856
|
-
className: styles.tableColumnEditorTrigger,
|
|
3857
|
-
"data-active": highlightedCoordinates[0] === colIndex + 1,
|
|
3858
|
-
title: "Column menu"
|
|
3859
|
-
},
|
|
3860
|
-
/* @__PURE__ */ React__default.createElement(MoreHorizIcon, null)
|
|
3861
|
-
), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
3862
|
-
RadixPopover.PopoverContent,
|
|
3863
|
-
{
|
|
3864
|
-
className: classNames(styles.tableColumnEditorPopoverContent),
|
|
3865
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
3866
|
-
sideOffset: 5,
|
|
3867
|
-
side: "top"
|
|
3868
|
-
},
|
|
3869
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.Root, { className: styles.tableColumnEditorToolbar }, /* @__PURE__ */ React__default.createElement(
|
|
3870
|
-
RadixToolbar.ToggleGroup,
|
|
3871
|
-
{
|
|
3872
|
-
className: styles.toggleGroupRoot,
|
|
3873
|
-
onValueChange: (value) => {
|
|
3874
|
-
setColumnAlign(colIndex, value);
|
|
3875
|
-
},
|
|
3876
|
-
value: align || "left",
|
|
3877
|
-
type: "single",
|
|
3878
|
-
"aria-label": "Text alignment"
|
|
3879
|
-
},
|
|
3880
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "left", title: "Align left" }, /* @__PURE__ */ React__default.createElement(AlignLeftIcon, null)),
|
|
3881
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "center", title: "Align center" }, /* @__PURE__ */ React__default.createElement(AlignCenterIcon, null)),
|
|
3882
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { value: "right", title: "Align right" }, /* @__PURE__ */ React__default.createElement(AlignRightIcon, null))
|
|
3883
|
-
), /* @__PURE__ */ React__default.createElement(RadixToolbar.Separator, null), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertColumnAt.bind(null, colIndex), title: "Insert a column to the left of this one" }, /* @__PURE__ */ React__default.createElement(InsertColLeftIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertColumnAt.bind(null, colIndex + 1), title: "Insert a column to the right of this one" }, /* @__PURE__ */ React__default.createElement(InsertColRightIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: deleteColumnAt.bind(null, colIndex), title: "Delete this column" }, /* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)))
|
|
3884
|
-
)));
|
|
3885
|
-
};
|
|
3886
|
-
const RowEditor = ({
|
|
3887
|
-
parentEditor,
|
|
3888
|
-
highlightedCoordinates,
|
|
3889
|
-
lexicalTable,
|
|
3890
|
-
rowIndex,
|
|
3891
|
-
setActiveCellWithBoundaries
|
|
3892
|
-
}) => {
|
|
3893
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3894
|
-
const insertRowAt = React__default.useCallback(
|
|
3895
|
-
(rowIndex2) => {
|
|
3896
|
-
parentEditor.update(() => {
|
|
3897
|
-
lexicalTable.insertRowAt(rowIndex2);
|
|
3898
|
-
});
|
|
3899
|
-
setActiveCellWithBoundaries([0, rowIndex2]);
|
|
3900
|
-
},
|
|
3901
|
-
[parentEditor, lexicalTable, setActiveCellWithBoundaries]
|
|
3902
|
-
);
|
|
3903
|
-
const deleteRowAt = React__default.useCallback(
|
|
3904
|
-
(rowIndex2) => {
|
|
3905
|
-
parentEditor.update(() => {
|
|
3906
|
-
lexicalTable.deleteRowAt(rowIndex2);
|
|
3907
|
-
});
|
|
3908
|
-
},
|
|
3909
|
-
[parentEditor, lexicalTable]
|
|
3910
|
-
);
|
|
3911
|
-
return /* @__PURE__ */ React__default.createElement(RadixPopover.Root, null, /* @__PURE__ */ React__default.createElement(RadixPopover.PopoverTrigger, { className: styles.tableColumnEditorTrigger, "data-active": highlightedCoordinates[1] === rowIndex }, /* @__PURE__ */ React__default.createElement(MoreHorizIcon, null)), /* @__PURE__ */ React__default.createElement(RadixPopover.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(
|
|
3912
|
-
RadixPopover.PopoverContent,
|
|
3913
|
-
{
|
|
3914
|
-
className: classNames(styles.tableColumnEditorPopoverContent),
|
|
3915
|
-
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
3916
|
-
sideOffset: 5,
|
|
3917
|
-
side: "bottom"
|
|
3918
|
-
},
|
|
3919
|
-
/* @__PURE__ */ React__default.createElement(RadixToolbar.Root, { className: styles.tableColumnEditorToolbar }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertRowAt.bind(null, rowIndex), title: "Insert a row above this one" }, /* @__PURE__ */ React__default.createElement(InsertRowAboveIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: insertRowAt.bind(null, rowIndex + 1), title: "Insert a row below this one" }, /* @__PURE__ */ React__default.createElement(InsertRowBelowIcon, null)), /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { onClick: deleteRowAt.bind(null, rowIndex), title: "Delete this row" }, /* @__PURE__ */ React__default.createElement(DeleteSmallIcon, null)))
|
|
3920
|
-
)));
|
|
3921
|
-
};
|
|
3922
|
-
const index = "";
|
|
3923
|
-
function DiffViewer({ oldText, newText }) {
|
|
3924
|
-
const diffText = formatLines(diffLines(oldText, newText), { context: 3 });
|
|
3925
|
-
if (diffText.trim() === "")
|
|
3926
|
-
return /* @__PURE__ */ React__default.createElement("div", null, "No changes");
|
|
3927
|
-
const [diff] = parseDiff(diffText, { nearbySequences: "zip" });
|
|
3928
|
-
return /* @__PURE__ */ React__default.createElement(Diff, { viewType: "split", diffType: "modify", hunks: diff.hunks || [] }, (hunks) => hunks.map((hunk) => /* @__PURE__ */ React__default.createElement(Hunk, { key: hunk.content, hunk })));
|
|
3929
|
-
}
|
|
3930
|
-
function MarkdownDiffView() {
|
|
3931
|
-
const [markdown2, headMarkdown] = useEmitterValues("markdownSource", "headMarkdown");
|
|
3932
|
-
return /* @__PURE__ */ React__default.createElement(DiffViewer, { oldText: headMarkdown, newText: markdown2 });
|
|
3933
|
-
}
|
|
3934
|
-
const ViewModeToggler = ({ children }) => {
|
|
3935
|
-
const [viewMode] = useEmitterValues("viewMode");
|
|
3936
|
-
return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement("div", { style: { display: viewMode === "editor" ? "block" : "none" } }, children), viewMode === "diff" ? /* @__PURE__ */ React__default.createElement(MarkdownDiffView, null) : null, viewMode === "markdown" ? /* @__PURE__ */ React__default.createElement(SourceEditor, null) : null);
|
|
3937
|
-
};
|
|
3938
|
-
const SourceEditor = () => {
|
|
3939
|
-
const [markdown$1] = useEmitterValues("markdownSource");
|
|
3940
|
-
const updateMarkdown = usePublisher("markdownSource");
|
|
3941
|
-
const codeMirrorRef = React__default.useRef(null);
|
|
3942
|
-
return /* @__PURE__ */ React__default.createElement("div", null, /* @__PURE__ */ React__default.createElement(SandpackProvider, null, /* @__PURE__ */ React__default.createElement(
|
|
3943
|
-
CodeEditor,
|
|
3944
|
-
{
|
|
3945
|
-
showLineNumbers: true,
|
|
3946
|
-
additionalLanguages: [{ name: "markdown", extensions: ["md"], language: markdown() }],
|
|
3947
|
-
initMode: "lazy",
|
|
3948
|
-
filePath: `file.md`,
|
|
3949
|
-
code: markdown$1,
|
|
3950
|
-
onCodeUpdate: updateMarkdown,
|
|
3951
|
-
ref: codeMirrorRef
|
|
3952
|
-
}
|
|
3953
|
-
)));
|
|
3954
|
-
};
|
|
3955
|
-
const InstantTooltip = React__default.forwardRef(({ title, children }, ref) => {
|
|
3956
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3957
|
-
return /* @__PURE__ */ React__default.createElement(Tooltip.Provider, { delayDuration: 100 }, /* @__PURE__ */ React__default.createElement(Tooltip.Root, null, /* @__PURE__ */ React__default.createElement(Tooltip.Trigger, { ref, asChild: true }, /* @__PURE__ */ React__default.createElement("span", null, children)), /* @__PURE__ */ React__default.createElement(Tooltip.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Tooltip.Content, { className: classNames(styles.tooltipContent), sideOffset: 10 }, title))));
|
|
3958
|
-
});
|
|
3959
|
-
const SelectItem = React__default.forwardRef(
|
|
3960
|
-
({ children, className, ...props }, forwardedRef) => {
|
|
3961
|
-
return /* @__PURE__ */ React__default.createElement(Select.Item, { ...props, ref: forwardedRef, className: classNames(className, styles.toolbarNodeKindSelectItem) }, /* @__PURE__ */ React__default.createElement(Select.ItemText, null, children));
|
|
3962
|
-
}
|
|
3963
|
-
);
|
|
3964
|
-
const SelectTrigger = ({ title, placeholder, className }) => {
|
|
3965
|
-
return /* @__PURE__ */ React__default.createElement(InstantTooltip, { title }, /* @__PURE__ */ React__default.createElement(Select.Trigger, { "aria-label": placeholder, className: classNames(styles.toolbarNodeKindSelectTrigger, className) }, /* @__PURE__ */ React__default.createElement(Select.Value, { placeholder }), /* @__PURE__ */ React__default.createElement(Select.Icon, { className: styles.toolbarNodeKindSelectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))));
|
|
3966
|
-
};
|
|
3967
|
-
const SelectContent = ({
|
|
3968
|
-
children,
|
|
3969
|
-
className = styles.toolbarNodeKindSelectContainer
|
|
3970
|
-
}) => {
|
|
3971
|
-
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3972
|
-
return /* @__PURE__ */ React__default.createElement(Select.Portal, { container: editorRootElementRef == null ? void 0 : editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Select.Content, { className, onCloseAutoFocus: (e) => e.preventDefault(), position: "popper" }, /* @__PURE__ */ React__default.createElement(Select.Viewport, null, children)));
|
|
3973
|
-
};
|
|
3974
|
-
const SelectButtonTrigger = ({
|
|
3975
|
-
children,
|
|
3976
|
-
title,
|
|
3977
|
-
className
|
|
3978
|
-
}) => {
|
|
3979
|
-
return /* @__PURE__ */ React__default.createElement(InstantTooltip, { title }, /* @__PURE__ */ React__default.createElement(Select.Trigger, { className: classNames(styles.toolbarButtonSelectTrigger, className) }, children, /* @__PURE__ */ React__default.createElement(Select.Icon, { className: styles.toolbarNodeKindSelectDropdownArrow }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))));
|
|
3980
|
-
};
|
|
3981
|
-
function CodeBlockLanguageSelect() {
|
|
3982
|
-
const [activeEditorType, activeEditor, codeBlockLanguages] = useEmitterValues("activeEditorType", "activeEditor", "codeBlockLanguages");
|
|
3983
|
-
const nodeLanguage = React__default.useMemo(() => {
|
|
3984
|
-
let language;
|
|
3985
|
-
activeEditor.getEditorState().read(() => {
|
|
3986
|
-
const node = $getNodeByKey(activeEditorType.nodeKey);
|
|
3987
|
-
language = node.getLanguage();
|
|
3988
|
-
});
|
|
3989
|
-
return language;
|
|
3990
|
-
}, [activeEditor, activeEditorType]);
|
|
3991
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
3992
|
-
Select.Root,
|
|
3993
|
-
{
|
|
3994
|
-
value: nodeLanguage,
|
|
3995
|
-
onValueChange: (language) => {
|
|
3996
|
-
activeEditor.update(() => {
|
|
3997
|
-
const node = $getNodeByKey(activeEditorType.nodeKey);
|
|
3998
|
-
node.setLanguage(language);
|
|
3999
|
-
setTimeout(() => {
|
|
4000
|
-
node.select();
|
|
4001
|
-
}, 80);
|
|
4002
|
-
});
|
|
4003
|
-
}
|
|
4004
|
-
},
|
|
4005
|
-
/* @__PURE__ */ React__default.createElement(SelectTrigger, { title: "Change code block language", placeholder: "Language", className: styles.toolbarCodeBlockLanguageSelectTrigger }),
|
|
4006
|
-
/* @__PURE__ */ React__default.createElement(SelectContent, { className: styles.toolbarCodeBlockLanguageSelectContent }, Object.entries(codeBlockLanguages).map(([value, label]) => /* @__PURE__ */ React__default.createElement(SelectItem, { key: value, value }, label)))
|
|
4007
|
-
);
|
|
4008
|
-
}
|
|
4009
|
-
const SvgDelete = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4010
|
-
maskType: "alpha"
|
|
4011
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 21V6H4V4h5V3h6v1h5v2h-1v15H5Zm2-2h10V6H7v13Zm2-2h2V8H9v9Zm4 0h2V8h-2v9Z" })));
|
|
4012
|
-
const DeleteIcon = SvgDelete;
|
|
4013
|
-
const SvgCode = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4014
|
-
maskType: "alpha"
|
|
4015
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m8 18-6-6 6-6 1.425 1.425-4.6 4.6L9.4 16.6 8 18Zm8 0-1.425-1.425 4.6-4.6L14.6 7.4 16 6l6 6-6 6Z" })));
|
|
4016
|
-
const CodeIcon = SvgCode;
|
|
4017
|
-
const SvgDeployedCode = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4018
|
-
maskType: "alpha"
|
|
4019
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "m5 15.95 6 3.475v-6.85L5 9.1v6.85Zm8 3.475 6-3.475V9.1l-6 3.475v6.85Zm-6.925-12L12 10.85l5.925-3.425L12 4 6.075 7.425ZM3 17.125V6.875L12 1.7l9 5.175v10.25L12 22.3l-9-5.175Z" })));
|
|
4020
|
-
const LiveCodeIcon = SvgDeployedCode;
|
|
4021
|
-
const SvgDifference = (props) => /* @__PURE__ */ React.createElement("svg", { width: 25, height: 24, viewBox: "0 0 25 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_318_257", style: {
|
|
4022
|
-
maskType: "alpha"
|
|
4023
|
-
}, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 25, height: 24 }, /* @__PURE__ */ React.createElement("rect", { x: 0.929688, width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_318_257)" }, /* @__PURE__ */ React.createElement("path", { d: "M12.4297 12H14.4297V10H16.4297V8H14.4297V6H12.4297V8H10.4297V10H12.4297V12ZM10.4297 16H16.4297V14H10.4297V16ZM5.92969 20V2H14.9297L20.9297 8V20H5.92969ZM7.92969 18H18.9297V9L13.9297 4H7.92969V18Z", fill: "currentColor" })));
|
|
4024
|
-
const DifferenceIcon = SvgDifference;
|
|
4025
|
-
const SvgFormatBold = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4026
|
-
maskType: "alpha"
|
|
4027
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M6.8 19V5h5.525c1.083 0 2.083.333 3 1 .917.667 1.375 1.592 1.375 2.775 0 .85-.192 1.504-.575 1.962-.383.459-.742.788-1.075.988.417.183.88.525 1.388 1.025.508.5.762 1.25.762 2.25 0 1.483-.542 2.521-1.625 3.113-1.083.591-2.1.887-3.05.887H6.8Zm3.025-2.8h2.6c.8 0 1.287-.204 1.462-.613.175-.408.263-.704.263-.887 0-.183-.088-.48-.263-.888-.175-.408-.687-.612-1.537-.612H9.825v3Zm0-5.7h2.325c.55 0 .95-.142 1.2-.425a1.4 1.4 0 0 0 .375-.95c0-.4-.142-.725-.425-.975-.283-.25-.65-.375-1.1-.375H9.825V10.5Z" })));
|
|
4028
|
-
const BoldIcon = SvgFormatBold;
|
|
4029
|
-
const SvgFormatItalic = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4030
|
-
maskType: "alpha"
|
|
4031
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 19v-2.5h4l3-9H8V5h10v2.5h-3.5l-3 9H15V19H5Z" })));
|
|
4032
|
-
const ItalicIcon = SvgFormatItalic;
|
|
4033
|
-
const SvgFormatListBulleted = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4034
|
-
maskType: "alpha"
|
|
4035
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9ZM5 20a1.93 1.93 0 0 1-1.413-.587A1.928 1.928 0 0 1 3 18c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 16c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.021-.588 1.413A1.925 1.925 0 0 1 5 20Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 12c0-.55.196-1.021.587-1.413A1.928 1.928 0 0 1 5 10c.55 0 1.02.196 1.412.587.392.392.588.863.588 1.413s-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 14Zm0-6c-.55 0-1.021-.196-1.413-.588A1.925 1.925 0 0 1 3 6c0-.55.196-1.02.587-1.412A1.927 1.927 0 0 1 5 4c.55 0 1.02.196 1.412.588C6.804 4.979 7 5.45 7 6c0 .55-.196 1.02-.588 1.412A1.923 1.923 0 0 1 5 8Z" })));
|
|
4036
|
-
const BulletedListIcon = SvgFormatListBulleted;
|
|
4037
|
-
const SvgFormatListNumbered = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4038
|
-
maskType: "alpha"
|
|
4039
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 22v-1.5h2.5v-.75H4v-1.5h1.5v-.75H3V16h4v2.25L6 19l1 .75V22H3Zm0-7v-3.75h2.5v-.75H3V9h4v3.75H4.5v.75H7V15H3Zm1.5-7V3.5H3V2h3v6H4.5ZM9 19v-2h12v2H9Zm0-6v-2h12v2H9Zm0-6V5h12v2H9Z" })));
|
|
4040
|
-
const NumberedListIcon = SvgFormatListNumbered;
|
|
4041
|
-
const SvgFormatUnderlined = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4042
|
-
maskType: "alpha"
|
|
4043
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 21v-2h14v2H5Zm7-4c-1.683 0-2.992-.525-3.925-1.575-.933-1.05-1.4-2.442-1.4-4.175V3H9.25v8.4c0 .933.233 1.692.7 2.275.467.583 1.15.875 2.05.875.9 0 1.583-.292 2.05-.875.467-.583.7-1.342.7-2.275V3h2.575v8.25c0 1.733-.467 3.125-1.4 4.175C14.992 16.475 13.683 17 12 17Z" })));
|
|
4044
|
-
const UnderlinedIcon = SvgFormatUnderlined;
|
|
4045
|
-
const SvgFrameSource = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4046
|
-
maskType: "alpha"
|
|
4047
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 21v-6h2v4h4v2H3Zm12 0v-2h4v-4h2v6h-6Zm-6.4-5.4L5 12l3.6-3.6L10 9.825 7.825 12 10 14.175 8.6 15.6Zm6.8 0L14 14.175 16.175 12 14 9.825 15.4 8.4 19 12l-3.6 3.6ZM3 9V3h6v2H5v4H3Zm16 0V5h-4V3h6v6h-2Z" })));
|
|
4048
|
-
const FrameSourceIcon = SvgFrameSource;
|
|
4049
|
-
const SvgFrontmatter = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4050
|
-
maskType: "alpha"
|
|
4051
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 7h4v2H5z" }), /* @__PURE__ */ React.createElement("path", { d: "M5 7h4v2H5zm0 7h4v2H5z" }), /* @__PURE__ */ React.createElement("path", { d: "M5 14h4v2H5zm5-7h4v2h-4z" }), /* @__PURE__ */ React.createElement("path", { d: "M10 7h4v2h-4zm0 7h4v2h-4z" }), /* @__PURE__ */ React.createElement("path", { d: "M10 14h4v2h-4zm5-7h4v2h-4z" }), /* @__PURE__ */ React.createElement("path", { d: "M15 7h4v2h-4zm0 7h4v2h-4z" }), /* @__PURE__ */ React.createElement("path", { d: "M15 14h4v2h-4z" })));
|
|
4052
|
-
const FrontmatterIcon = SvgFrontmatter;
|
|
4053
|
-
const SvgHorizontalRule = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4054
|
-
maskType: "alpha"
|
|
4055
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M4 13v-2h16v2H4Z" })));
|
|
4056
|
-
const HorizontalRuleIcon = SvgHorizontalRule;
|
|
4057
|
-
const SvgLink = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4058
|
-
maskType: "alpha"
|
|
4059
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M11 17H7c-1.383 0-2.562-.488-3.537-1.463C2.488 14.562 2 13.383 2 12s.488-2.563 1.463-3.538C4.438 7.487 5.617 7 7 7h4v2H7c-.833 0-1.542.292-2.125.875A2.893 2.893 0 0 0 4 12c0 .833.292 1.542.875 2.125A2.893 2.893 0 0 0 7 15h4v2Zm-3-4v-2h8v2H8Zm5 4v-2h4c.833 0 1.542-.292 2.125-.875A2.893 2.893 0 0 0 20 12c0-.833-.292-1.542-.875-2.125A2.893 2.893 0 0 0 17 9h-4V7h4c1.383 0 2.563.487 3.538 1.462C21.513 9.437 22 10.617 22 12s-.487 2.562-1.462 3.537C19.563 16.512 18.383 17 17 17h-4Z" })));
|
|
4060
|
-
const LinkIcon = SvgLink;
|
|
4061
|
-
const SvgMarkdown = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_46_56", style: {
|
|
4062
|
-
maskType: "alpha"
|
|
4063
|
-
}, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 24, height: 24 }, /* @__PURE__ */ React.createElement("rect", { width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_46_56)" }, /* @__PURE__ */ React.createElement("path", { d: "M19 19L14 14L15.4 12.575L18 15.175V5H20V15.175L22.6 12.575L24 14L19 19Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M13 19H10.5V9L6.5 15L2.5 9V19H0V5H2.5L6.5 11L10.5 5H13V19Z", fill: "currentColor" })));
|
|
4064
|
-
const MarkdownIcon = SvgMarkdown;
|
|
4065
|
-
const SvgRichText = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_318_249", style: {
|
|
4066
|
-
maskType: "alpha"
|
|
4067
|
-
}, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 24, height: 24 }, /* @__PURE__ */ React.createElement("rect", { width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_318_249)" }, /* @__PURE__ */ React.createElement("path", { d: "M5 21V19H19V21H5Z", fill: "currentColor" }), /* @__PURE__ */ React.createElement("path", { d: "M6.80005 17V3H12.325C13.4084 3 14.4084 3.33333 15.325 4C16.2417 4.66667 16.7001 5.59167 16.7001 6.775C16.7001 7.625 16.5084 8.279 16.125 8.737C15.7417 9.19567 15.3834 9.525 15.05 9.725C15.4667 9.90833 15.9294 10.25 16.438 10.75C16.946 11.25 17.2001 12 17.2001 13C17.2001 14.4833 16.6584 15.521 15.575 16.113C14.4917 16.7043 13.475 17 12.525 17H6.80005ZM9.82505 14.2H12.425C13.225 14.2 13.7124 13.9957 13.887 13.587C14.0624 13.179 14.15 12.8833 14.15 12.7C14.15 12.5167 14.0624 12.2207 13.887 11.812C13.7124 11.404 13.2 11.2 12.35 11.2H9.82505V14.2ZM9.82505 8.5H12.15C12.7 8.5 13.1 8.35833 13.35 8.075C13.6 7.79167 13.725 7.475 13.725 7.125C13.725 6.725 13.5834 6.4 13.3 6.15C13.0167 5.9 12.65 5.775 12.2 5.775H9.82505V8.5Z", fill: "currentColor" })));
|
|
4068
|
-
const RichTextIcon = SvgRichText;
|
|
4069
|
-
const SvgTable = (props) => /* @__PURE__ */ React.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 24, height: 24, fill: "currentColor", viewBox: "0 0 24 24", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "a", width: 24, height: 24, x: 0, y: 0, maskUnits: "userSpaceOnUse", style: {
|
|
4070
|
-
maskType: "alpha"
|
|
4071
|
-
} }, /* @__PURE__ */ React.createElement("path", { d: "M0 0h24v24H0z" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#a)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 21V3h18v18H3ZM5 9h14V5H5v4Zm5.325 5h3.35v-3h-3.35v3Zm0 5h3.35v-3h-3.35v3ZM5 14h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3ZM5 19h3.325v-3H5v3Zm10.675 0H19v-3h-3.325v3Z" }), /* @__PURE__ */ React.createElement("path", { d: "M8.325 9h2V5h-2v4Zm5.35 0h2V5h-2v4Z" })));
|
|
4072
|
-
const TableIcon = SvgTable;
|
|
4073
|
-
const BlockTypeSelect = () => {
|
|
4074
|
-
const [currentBlockType] = useEmitterValues("currentBlockType");
|
|
4075
|
-
const applyBlockType = usePublisher("applyBlockType");
|
|
4076
|
-
return /* @__PURE__ */ React__default.createElement(Select.Root, { value: currentBlockType || "", onValueChange: applyBlockType }, /* @__PURE__ */ React__default.createElement(SelectTrigger, { title: "Select block type", placeholder: "Block type" }), /* @__PURE__ */ React__default.createElement(SelectContent, null, /* @__PURE__ */ React__default.createElement(SelectItem, { value: "paragraph" }, "Paragraph"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "quote" }, "Quote"), /* @__PURE__ */ React__default.createElement(Select.Separator, null), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h1" }, "Heading 1"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h2" }, "Heading 2"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h3" }, "Heading 3"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h4" }, "Heading 4"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h5" }, "Heading 5"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "h6" }, "Heading 6"), /* @__PURE__ */ React__default.createElement(Select.Separator, null), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "note" }, "Note"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "tip" }, "Tip"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "info" }, "Info"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "caution" }, "Caution"), /* @__PURE__ */ React__default.createElement(SelectItem, { value: "danger" }, "Danger")));
|
|
4077
|
-
};
|
|
4078
|
-
const SvgAddPhoto = (props) => /* @__PURE__ */ React.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...props }, /* @__PURE__ */ React.createElement("mask", { id: "mask0_343_38", style: {
|
|
4079
|
-
maskType: "alpha"
|
|
4080
|
-
}, maskUnits: "userSpaceOnUse", x: 0, y: 0, width: 24, height: 24 }, /* @__PURE__ */ React.createElement("rect", { width: 24, height: 24, fill: "#D9D9D9" })), /* @__PURE__ */ React.createElement("g", { mask: "url(#mask0_343_38)" }, /* @__PURE__ */ React.createElement("path", { d: "M3 21V3H14V5H5V19H19V10H21V21H3ZM17 9V7H15V5H17V3H19V5H21V7H19V9H17ZM6 17H18L14.25 12L11.25 16L9 13L6 17Z", fill: "currentColor" })));
|
|
4081
|
-
const AddPhotoIcon = SvgAddPhoto;
|
|
4082
|
-
const ImageButton = React__default.forwardRef((props, forwardedRef) => {
|
|
4083
|
-
const [editorRootElementRef, imageAutocompleteSuggestions] = useEmitterValues("editorRootElementRef", "imageAutocompleteSuggestions");
|
|
4084
|
-
const [open, setOpen] = React__default.useState(false);
|
|
4085
|
-
const insertImage = usePublisher("insertImage");
|
|
4086
|
-
const onSubmit = React__default.useCallback(
|
|
4087
|
-
(url) => {
|
|
4088
|
-
insertImage(url);
|
|
4089
|
-
setOpen(false);
|
|
4090
|
-
},
|
|
4091
|
-
[insertImage]
|
|
4092
|
-
);
|
|
4093
|
-
return /* @__PURE__ */ React__default.createElement(Dialog.Root, { open, onOpenChange: setOpen }, /* @__PURE__ */ React__default.createElement(Dialog.Trigger, { asChild: true }, /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ...props, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(InstantTooltip, { title: "Insert image" }, /* @__PURE__ */ React__default.createElement(AddPhotoIcon, null)))), /* @__PURE__ */ React__default.createElement(Dialog.Portal, { container: editorRootElementRef.current }, /* @__PURE__ */ React__default.createElement(Dialog.Overlay, { className: styles.dialogOverlay }), /* @__PURE__ */ React__default.createElement(Dialog.Content, { className: styles.dialogContent }, /* @__PURE__ */ React__default.createElement(ImageForm, { initialUrl: "", onSubmit, imageAutocompleteSuggestions }))));
|
|
4094
|
-
});
|
|
4095
|
-
createCommand();
|
|
4096
|
-
const MAX_SUGGESTIONS = 20;
|
|
4097
|
-
const ImageForm = ({ initialUrl, onSubmit, imageAutocompleteSuggestions }) => {
|
|
4098
|
-
const [items, setItems] = React__default.useState(imageAutocompleteSuggestions.slice(0, MAX_SUGGESTIONS));
|
|
4099
|
-
const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
|
|
4100
|
-
initialInputValue: initialUrl,
|
|
4101
|
-
onInputValueChange({ inputValue }) {
|
|
4102
|
-
inputValue = (inputValue == null ? void 0 : inputValue.toLowerCase()) || "";
|
|
4103
|
-
const matchingItems = [];
|
|
4104
|
-
for (const url of imageAutocompleteSuggestions) {
|
|
4105
|
-
if (url.toLowerCase().includes(inputValue)) {
|
|
4106
|
-
matchingItems.push(url);
|
|
4107
|
-
if (matchingItems.length >= MAX_SUGGESTIONS) {
|
|
4108
|
-
break;
|
|
4109
|
-
}
|
|
4110
|
-
}
|
|
4111
|
-
}
|
|
4112
|
-
setItems(matchingItems);
|
|
4113
|
-
},
|
|
4114
|
-
items,
|
|
4115
|
-
itemToString(item) {
|
|
4116
|
-
return item ?? "";
|
|
4117
|
-
}
|
|
4118
|
-
});
|
|
4119
|
-
const onSubmitEH = (e) => {
|
|
4120
|
-
e.preventDefault();
|
|
4121
|
-
onSubmit(selectedItem || "");
|
|
4122
|
-
};
|
|
4123
|
-
const onKeyDownEH = React__default.useCallback(
|
|
4124
|
-
(e) => {
|
|
4125
|
-
var _a;
|
|
4126
|
-
if (e.key === "Escape") {
|
|
4127
|
-
(_a = e.target.form) == null ? void 0 : _a.reset();
|
|
4128
|
-
} else if (e.key === "Enter" && (!isOpen || items.length === 0)) {
|
|
4129
|
-
e.preventDefault();
|
|
4130
|
-
onSubmit(e.target.value);
|
|
4131
|
-
}
|
|
4132
|
-
},
|
|
4133
|
-
[isOpen, items, onSubmit]
|
|
4134
|
-
);
|
|
4135
|
-
const downshiftInputProps = getInputProps();
|
|
4136
|
-
const inputProps = {
|
|
4137
|
-
...downshiftInputProps,
|
|
4138
|
-
onKeyDown: (e) => {
|
|
4139
|
-
onKeyDownEH(e);
|
|
4140
|
-
downshiftInputProps.onKeyDown(e);
|
|
4141
|
-
}
|
|
4142
|
-
};
|
|
4143
|
-
const dropdownIsVisible = isOpen && items.length > 0;
|
|
4144
|
-
return /* @__PURE__ */ React__default.createElement("form", { onSubmit: onSubmitEH, className: classNames(styles.linkDialogEditForm) }, /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogInputContainer }, /* @__PURE__ */ React__default.createElement("div", { "data-visible-dropdown": dropdownIsVisible, className: styles.linkDialogInputWrapper }, /* @__PURE__ */ React__default.createElement(
|
|
4145
|
-
"input",
|
|
4146
|
-
{
|
|
4147
|
-
placeholder: "Paste or select an image url",
|
|
4148
|
-
className: styles.linkDialogInput,
|
|
4149
|
-
...inputProps,
|
|
4150
|
-
autoFocus: true,
|
|
4151
|
-
size: 30,
|
|
4152
|
-
"data-editor-dialog": true
|
|
4153
|
-
}
|
|
4154
|
-
), /* @__PURE__ */ React__default.createElement("button", { "aria-label": "toggle menu", type: "button", ...getToggleButtonProps() }, /* @__PURE__ */ React__default.createElement(DropDownIcon, null))), /* @__PURE__ */ React__default.createElement("div", { className: styles.linkDialogAutocompleteContainer }, /* @__PURE__ */ React__default.createElement("ul", { ...getMenuProps(), "data-visible": dropdownIsVisible }, items.map((item, index2) => /* @__PURE__ */ React__default.createElement(
|
|
4155
|
-
"li",
|
|
4156
|
-
{
|
|
4157
|
-
"data-selected": selectedItem === item,
|
|
4158
|
-
"data-highlighted": highlightedIndex === index2,
|
|
4159
|
-
key: `${item}${index2}`,
|
|
4160
|
-
...getItemProps({ item, index: index2 })
|
|
4161
|
-
},
|
|
4162
|
-
item
|
|
4163
|
-
))))), /* @__PURE__ */ React__default.createElement(ActionButton, { type: "submit", title: "Insert image", "aria-label": "Insert image", className: styles.primaryActionButton }, /* @__PURE__ */ React__default.createElement(CheckIcon, null)), /* @__PURE__ */ React__default.createElement(Dialog.Close, { className: styles.actionButton }, /* @__PURE__ */ React__default.createElement(CloseIcon, null)));
|
|
4164
|
-
};
|
|
4165
|
-
const ActionButton = React__default.forwardRef(({ className, ...props }, ref) => {
|
|
4166
|
-
return /* @__PURE__ */ React__default.createElement("button", { className: classNames(styles.actionButton, className), ref, ...props });
|
|
4167
|
-
});
|
|
4168
|
-
const ToggleItem = React__default.forwardRef(
|
|
4169
|
-
({ title, children, className: passedClassName, ...props }, forwardedRef) => {
|
|
4170
|
-
return /* @__PURE__ */ React__default.createElement(RadixToolbar.ToggleItem, { className: classNames(passedClassName, styles.toolbarToggleItem), ...props, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(InstantTooltip, { title }, children));
|
|
4171
|
-
}
|
|
4172
|
-
);
|
|
4173
|
-
const ToolbarButton = React__default.forwardRef(
|
|
4174
|
-
({ title, children, ...props }, forwardedRef) => {
|
|
4175
|
-
return /* @__PURE__ */ React__default.createElement(RadixToolbar.Button, { className: styles.toolbarButton, ...props, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(InstantTooltip, { title }, children));
|
|
4176
|
-
}
|
|
4177
|
-
);
|
|
4178
|
-
const ToggleSingleGroup = React__default.forwardRef(
|
|
4179
|
-
({ children, className, ...props }, forwardedRef) => {
|
|
4180
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
4181
|
-
RadixToolbar.ToggleGroup,
|
|
4182
|
-
{
|
|
4183
|
-
...props,
|
|
4184
|
-
type: "single",
|
|
4185
|
-
ref: forwardedRef,
|
|
4186
|
-
className: classNames(styles.toolbarToggleSingleGroup, className)
|
|
4187
|
-
},
|
|
4188
|
-
children
|
|
4189
|
-
);
|
|
4190
|
-
}
|
|
4191
|
-
);
|
|
4192
|
-
const ToggleSingleGroupWithItem = React__default.forwardRef(({ on, title, children, ...props }, forwardedRef) => {
|
|
4193
|
-
return /* @__PURE__ */ React__default.createElement(ToggleSingleGroup, { ...props, value: on ? "on" : "off", ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(ToggleItem, { title, value: "on" }, children));
|
|
4194
|
-
});
|
|
4195
|
-
const GroupGroup = ({ children }) => {
|
|
4196
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: styles.toolbarGroupOfGroups }, children);
|
|
4197
|
-
};
|
|
4198
|
-
const ToolbarSeparator = RadixToolbar.ToolbarSeparator;
|
|
4199
|
-
const BoldItalicUnderlineButtons = () => {
|
|
4200
|
-
const [currentFormat] = useEmitterValues("currentFormat", "currentListType");
|
|
4201
|
-
const applyFormat = usePublisher("applyFormat");
|
|
4202
|
-
const boldIsOn = (currentFormat & IS_BOLD) !== 0;
|
|
4203
|
-
const italicIsOn = (currentFormat & IS_ITALIC) !== 0;
|
|
4204
|
-
const underlineIsOn = (currentFormat & IS_UNDERLINE) !== 0;
|
|
4205
|
-
const boldTitle = boldIsOn ? "Remove bold" : "Bold";
|
|
4206
|
-
const italicTitle = italicIsOn ? "Remove italic" : "Italic";
|
|
4207
|
-
const underlineTitle = underlineIsOn ? "Remove underline" : "Underline";
|
|
4208
|
-
return /* @__PURE__ */ React__default.createElement(GroupGroup, null, /* @__PURE__ */ React__default.createElement(ToggleSingleGroupWithItem, { title: boldTitle, "aria-label": "Bold", on: boldIsOn, onValueChange: applyFormat.bind(null, "bold") }, /* @__PURE__ */ React__default.createElement(BoldIcon, null)), /* @__PURE__ */ React__default.createElement(ToggleSingleGroupWithItem, { title: italicTitle, "aria-label": "Italic", on: italicIsOn, onValueChange: applyFormat.bind(null, "italic") }, /* @__PURE__ */ React__default.createElement(ItalicIcon, null)), /* @__PURE__ */ React__default.createElement(
|
|
4209
|
-
ToggleSingleGroupWithItem,
|
|
4210
|
-
{
|
|
4211
|
-
"aria-label": "Underline",
|
|
4212
|
-
title: underlineTitle,
|
|
4213
|
-
on: underlineIsOn,
|
|
4214
|
-
onValueChange: applyFormat.bind(null, "underline")
|
|
4215
|
-
},
|
|
4216
|
-
/* @__PURE__ */ React__default.createElement(UnderlinedIcon, { style: { transform: "translateY(2px)" } })
|
|
4217
|
-
));
|
|
4218
|
-
};
|
|
4219
|
-
const CodeFormattingButton = () => {
|
|
4220
|
-
const [currentFormat] = useEmitterValues("currentFormat", "currentListType");
|
|
4221
|
-
const applyFormat = usePublisher("applyFormat");
|
|
4222
|
-
const codeIsOn = (currentFormat & IS_CODE) !== 0;
|
|
4223
|
-
const codeTitle = codeIsOn ? "Remove inline code" : "Inline code";
|
|
4224
|
-
return /* @__PURE__ */ React__default.createElement(GroupGroup, null, /* @__PURE__ */ React__default.createElement(ToggleSingleGroupWithItem, { title: codeTitle, "aria-label": "Inline code", on: codeIsOn, onValueChange: applyFormat.bind(null, "code") }, /* @__PURE__ */ React__default.createElement(CodeIcon, null)));
|
|
4225
|
-
};
|
|
4226
|
-
const ListButtons = () => {
|
|
4227
|
-
const [currentListType] = useEmitterValues("currentListType");
|
|
4228
|
-
const applyListType = usePublisher("applyListType");
|
|
4229
|
-
return /* @__PURE__ */ React__default.createElement(GroupGroup, null, /* @__PURE__ */ React__default.createElement(
|
|
4230
|
-
ToggleSingleGroup,
|
|
4231
|
-
{
|
|
4232
|
-
"aria-label": "List type",
|
|
4233
|
-
onValueChange: applyListType,
|
|
4234
|
-
value: currentListType || "",
|
|
4235
|
-
onFocus: (e) => e.preventDefault()
|
|
4236
|
-
},
|
|
4237
|
-
/* @__PURE__ */ React__default.createElement(ToggleItem, { title: "Bulleted list", value: "bullet", "aria-label": "Bulleted list" }, /* @__PURE__ */ React__default.createElement(BulletedListIcon, null)),
|
|
4238
|
-
/* @__PURE__ */ React__default.createElement(ToggleItem, { title: "Numbered list", value: "number", "aria-label": "Numbered list" }, /* @__PURE__ */ React__default.createElement(NumberedListIcon, null))
|
|
4239
|
-
));
|
|
4240
|
-
};
|
|
4241
|
-
const LinkButton = () => {
|
|
4242
|
-
const openLinkEditDialog = usePublisher("openLinkEditDialog");
|
|
4243
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Create link", onClick: openLinkEditDialog.bind(null, true) }, /* @__PURE__ */ React__default.createElement(LinkIcon, null));
|
|
4244
|
-
};
|
|
4245
|
-
const TableButton = () => {
|
|
4246
|
-
const insertTable = usePublisher("insertTable");
|
|
4247
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Insert table", onClick: insertTable.bind(null, true) }, /* @__PURE__ */ React__default.createElement(TableIcon, null));
|
|
4248
|
-
};
|
|
4249
|
-
const CodeBlockButton = () => {
|
|
4250
|
-
const insertCodeBlock = usePublisher("insertCodeBlock");
|
|
4251
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Insert code block", onClick: insertCodeBlock.bind(null, true) }, /* @__PURE__ */ React__default.createElement(FrameSourceIcon, null));
|
|
4252
|
-
};
|
|
4253
|
-
const HorizontalRuleButton = () => {
|
|
4254
|
-
const insertHorizontalRule = usePublisher("insertHorizontalRule");
|
|
4255
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Insert horizontal rule", onClick: insertHorizontalRule.bind(null, true) }, /* @__PURE__ */ React__default.createElement(HorizontalRuleIcon, null));
|
|
4256
|
-
};
|
|
4257
|
-
const SandpackButton = () => {
|
|
4258
|
-
const insertSandpack = usePublisher("insertSandpack");
|
|
4259
|
-
const [sandpackConfig] = useEmitterValues("sandpackConfig");
|
|
4260
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, sandpackConfig.presets.length === 1 ? /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Insert live code block", onClick: insertSandpack.bind(null, "") }, /* @__PURE__ */ React__default.createElement(LiveCodeIcon, null)) : /* @__PURE__ */ React__default.createElement(Select.Root, { value: "", onValueChange: insertSandpack }, /* @__PURE__ */ React__default.createElement(SelectButtonTrigger, { title: "Insert live code snippet" }, /* @__PURE__ */ React__default.createElement(LiveCodeIcon, null)), /* @__PURE__ */ React__default.createElement(SelectContent, { className: styles.toolbarButtonDropdownContainer }, sandpackConfig.presets.map((preset) => /* @__PURE__ */ React__default.createElement(SelectItem, { key: preset.name, value: preset.meta }, preset.label)))));
|
|
4261
|
-
};
|
|
4262
|
-
const FrontmatterButton = () => {
|
|
4263
|
-
const insertFrontmatter = usePublisher("insertFrontmatter");
|
|
4264
|
-
return /* @__PURE__ */ React__default.createElement(ToolbarButton, { title: "Insert frontmatter editor", onClick: insertFrontmatter.bind(null, true) }, /* @__PURE__ */ React__default.createElement(FrontmatterIcon, null));
|
|
4265
|
-
};
|
|
4266
|
-
const ViewModeSwitch = () => {
|
|
4267
|
-
const [viewMode] = useEmitterValues("viewMode", "activeEditorType");
|
|
4268
|
-
const setViewMode = usePublisher("viewMode");
|
|
4269
|
-
return /* @__PURE__ */ React__default.createElement(
|
|
4270
|
-
ToggleSingleGroup,
|
|
4271
|
-
{
|
|
4272
|
-
"aria-label": "View Mode",
|
|
4273
|
-
onValueChange: (v) => {
|
|
4274
|
-
if (v !== "") {
|
|
4275
|
-
setViewMode(v);
|
|
4276
|
-
}
|
|
4277
|
-
},
|
|
4278
|
-
value: viewMode,
|
|
4279
|
-
className: styles.toolbarModeSwitch
|
|
4280
|
-
},
|
|
4281
|
-
/* @__PURE__ */ React__default.createElement(ToggleItem, { value: "editor", "aria-label": "Rich text", title: "Rich text mode" }, /* @__PURE__ */ React__default.createElement(RichTextIcon, null)),
|
|
4282
|
-
/* @__PURE__ */ React__default.createElement(ToggleItem, { value: "diff", "aria-label": "View diff", title: "Diff mode" }, /* @__PURE__ */ React__default.createElement(DifferenceIcon, null)),
|
|
4283
|
-
/* @__PURE__ */ React__default.createElement(ToggleItem, { value: "markdown", "aria-label": "View Markdown", title: "Markdown source mode" }, /* @__PURE__ */ React__default.createElement(MarkdownIcon, null))
|
|
4284
|
-
);
|
|
4285
|
-
};
|
|
4286
|
-
const ToolbarComponents = {
|
|
4287
|
-
BlockTypeSelect,
|
|
4288
|
-
BoldItalicUnderlineButtons,
|
|
4289
|
-
CodeBlockButton,
|
|
4290
|
-
FrontmatterButton,
|
|
4291
|
-
GroupGroup,
|
|
4292
|
-
HorizontalRuleIcon,
|
|
4293
|
-
LinkButton,
|
|
4294
|
-
ListButtons,
|
|
4295
|
-
SandpackButton,
|
|
4296
|
-
TableButton,
|
|
4297
|
-
ToggleItem,
|
|
4298
|
-
ToggleSingleGroup,
|
|
4299
|
-
ToggleSingleGroupWithItem,
|
|
4300
|
-
ToolbarButton,
|
|
4301
|
-
ToolbarSeparator,
|
|
4302
|
-
ImageButton
|
|
4303
|
-
};
|
|
4304
|
-
const ToolbarPlugin = () => {
|
|
4305
|
-
const [activeEditorType, viewMode] = useEmitterValues("activeEditorType", "viewMode");
|
|
4306
|
-
return /* @__PURE__ */ React__default.createElement(RadixToolbar.Root, { className: styles.toolbarRoot, "aria-label": "Formatting options" }, viewMode === "editor" && (activeEditorType.type === "lexical" ? /* @__PURE__ */ React__default.createElement(RichTextButtonSet, null) : activeEditorType.type === "codeblock" ? /* @__PURE__ */ React__default.createElement(CodeBlockButtonSet, null) : /* @__PURE__ */ React__default.createElement(SandpackButtonSet, null)), /* @__PURE__ */ React__default.createElement(ToolbarSeparator, null), /* @__PURE__ */ React__default.createElement(ViewModeSwitch, null));
|
|
4307
|
-
};
|
|
4308
|
-
const CodeBlockButtonSet = () => {
|
|
4309
|
-
const [activeEditor, activeEditorType] = useEmitterValues("activeEditor", "activeEditorType");
|
|
4310
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(CodeBlockLanguageSelect, null), /* @__PURE__ */ React__default.createElement(
|
|
4311
|
-
ToolbarButton,
|
|
4312
|
-
{
|
|
4313
|
-
title: "Remove code block",
|
|
4314
|
-
onClick: () => {
|
|
4315
|
-
activeEditor.update(() => {
|
|
4316
|
-
const node = $getNodeByKey(activeEditorType.nodeKey);
|
|
4317
|
-
node.selectNext();
|
|
4318
|
-
node.remove();
|
|
4319
|
-
});
|
|
4320
|
-
}
|
|
4321
|
-
},
|
|
4322
|
-
/* @__PURE__ */ React__default.createElement(DeleteIcon, null)
|
|
4323
|
-
));
|
|
4324
|
-
};
|
|
4325
|
-
const SandpackButtonSet = () => {
|
|
4326
|
-
const [activeEditor, activeEditorType] = useEmitterValues("activeEditor", "activeEditorType");
|
|
4327
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, /* @__PURE__ */ React__default.createElement(
|
|
4328
|
-
ToolbarButton,
|
|
4329
|
-
{
|
|
4330
|
-
title: "Remove live code block",
|
|
4331
|
-
onClick: () => {
|
|
4332
|
-
activeEditor.update(() => {
|
|
4333
|
-
const node = $getNodeByKey(activeEditorType.nodeKey);
|
|
4334
|
-
node.selectNext();
|
|
4335
|
-
node.remove();
|
|
4336
|
-
});
|
|
4337
|
-
}
|
|
4338
|
-
},
|
|
4339
|
-
/* @__PURE__ */ React__default.createElement(DeleteIcon, null)
|
|
4340
|
-
));
|
|
4341
|
-
};
|
|
4342
|
-
const RichTextButtonSet = () => {
|
|
4343
|
-
const [toolbarComponents] = useEmitterValues("toolbarComponents");
|
|
4344
|
-
return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, toolbarComponents.map((Component, index2) => /* @__PURE__ */ React__default.createElement(Component, { key: index2 })));
|
|
4345
|
-
};
|
|
4346
|
-
const defaultNodeDecorators = {
|
|
4347
|
-
FrontmatterEditor,
|
|
4348
|
-
JsxEditor,
|
|
4349
|
-
SandpackEditor,
|
|
4350
|
-
CodeBlockEditor,
|
|
4351
|
-
TableEditor
|
|
4352
|
-
};
|
|
4353
|
-
const defaultToolbarComponents = [
|
|
4354
|
-
BoldItalicUnderlineButtons,
|
|
4355
|
-
ToolbarSeparator,
|
|
4356
|
-
CodeFormattingButton,
|
|
4357
|
-
ToolbarSeparator,
|
|
4358
|
-
ListButtons,
|
|
4359
|
-
ToolbarSeparator,
|
|
4360
|
-
BlockTypeSelect,
|
|
4361
|
-
ToolbarSeparator,
|
|
4362
|
-
LinkButton,
|
|
4363
|
-
ImageButton,
|
|
4364
|
-
TableButton,
|
|
4365
|
-
HorizontalRuleButton,
|
|
4366
|
-
FrontmatterButton,
|
|
4367
|
-
ToolbarSeparator,
|
|
4368
|
-
CodeBlockButton,
|
|
4369
|
-
SandpackButton
|
|
4370
|
-
];
|
|
4371
|
-
const defaultSandpackConfig = {
|
|
4372
|
-
defaultPreset: "react",
|
|
4373
|
-
presets: [
|
|
4374
|
-
{
|
|
4375
|
-
name: "react",
|
|
4376
|
-
meta: "live react",
|
|
4377
|
-
label: "React",
|
|
4378
|
-
sandpackTemplate: "react",
|
|
4379
|
-
sandpackTheme: "light",
|
|
4380
|
-
snippetFileName: "/App.js",
|
|
4381
|
-
snippetLanguage: "jsx",
|
|
4382
|
-
initialSnippetContent: `
|
|
4383
|
-
export default function App() {
|
|
4384
|
-
return (
|
|
4385
|
-
<div className="App">
|
|
4386
|
-
<h1>Hello CodeSandbox</h1>
|
|
4387
|
-
<h2>Start editing to see some magic happen!</h2>
|
|
4388
|
-
</div>
|
|
4389
|
-
);
|
|
4390
|
-
}
|
|
4391
|
-
`.trim()
|
|
4392
|
-
}
|
|
4393
|
-
]
|
|
4394
|
-
};
|
|
4395
|
-
const defaultMdxOptionValues = {
|
|
4396
|
-
markdownParse: {
|
|
4397
|
-
defaultVisitors: defaultMdastVisitors,
|
|
4398
|
-
defaultSyntaxExtensions,
|
|
4399
|
-
defaultMdastExtensions
|
|
4400
|
-
},
|
|
4401
|
-
lexicalConvert: {
|
|
4402
|
-
defaultVisitors: defaultLexicalVisitors,
|
|
4403
|
-
defaultExtensions,
|
|
4404
|
-
defaultMarkdownOptions: defaultToMarkdownOptions
|
|
4405
|
-
},
|
|
4406
|
-
defaultLexicalNodes
|
|
4407
|
-
};
|
|
4408
|
-
const MDXEditor = React__default.forwardRef(
|
|
4409
|
-
({
|
|
4410
|
-
markdown: markdown2,
|
|
4411
|
-
headMarkdown,
|
|
4412
|
-
jsxComponentDescriptors = [],
|
|
4413
|
-
sandpackConfig = defaultSandpackConfig,
|
|
4414
|
-
onChange,
|
|
4415
|
-
viewMode,
|
|
4416
|
-
linkAutocompleteSuggestions,
|
|
4417
|
-
imageAutoCompleteSuggestions,
|
|
4418
|
-
className,
|
|
4419
|
-
contentEditableClassName,
|
|
4420
|
-
toolbarComponents = defaultToolbarComponents,
|
|
4421
|
-
markdownParseOptions: {
|
|
4422
|
-
syntaxExtensions = Object.values(defaultSyntaxExtensions),
|
|
4423
|
-
mdastExtensions = Object.values(defaultMdastExtensions),
|
|
4424
|
-
visitors: importVisitors = Object.values(defaultMdastVisitors)
|
|
4425
|
-
} = {},
|
|
4426
|
-
lexicalConvertOptions: {
|
|
4427
|
-
toMarkdownExtensions = Object.values(defaultExtensions),
|
|
4428
|
-
toMarkdownOptions = defaultToMarkdownOptions,
|
|
4429
|
-
visitors: exportVisitors = Object.values(defaultLexicalVisitors)
|
|
4430
|
-
} = {},
|
|
4431
|
-
lexicalNodes = Object.values(defaultLexicalNodes)
|
|
4432
|
-
}, ref) => {
|
|
4433
|
-
const editorRootElementRef = React__default.useRef(null);
|
|
4434
|
-
return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.editorRoot, styles.editorWrapper, className), ref: editorRootElementRef }, /* @__PURE__ */ React__default.createElement(
|
|
4435
|
-
LexicalComposer,
|
|
4436
|
-
{
|
|
4437
|
-
initialConfig: {
|
|
4438
|
-
editorState: () => {
|
|
4439
|
-
importMarkdownToLexical({
|
|
4440
|
-
root: $getRoot(),
|
|
4441
|
-
visitors: importVisitors,
|
|
4442
|
-
mdastExtensions,
|
|
4443
|
-
markdown: markdown2,
|
|
4444
|
-
syntaxExtensions
|
|
4445
|
-
});
|
|
4446
|
-
},
|
|
4447
|
-
namespace: "MDXEditor",
|
|
4448
|
-
theme: {
|
|
4449
|
-
...theme,
|
|
4450
|
-
nodeDecoratorComponents: defaultNodeDecorators
|
|
4451
|
-
},
|
|
4452
|
-
nodes: lexicalNodes,
|
|
4453
|
-
onError: (error) => console.error(error)
|
|
4454
|
-
}
|
|
4455
|
-
},
|
|
4456
|
-
/* @__PURE__ */ React__default.createElement(
|
|
4457
|
-
EditorSystemComponent,
|
|
4458
|
-
{
|
|
4459
|
-
markdownSource: markdown2,
|
|
4460
|
-
headMarkdown: headMarkdown || markdown2,
|
|
4461
|
-
jsxComponentDescriptors,
|
|
4462
|
-
sandpackConfig,
|
|
4463
|
-
onChange,
|
|
4464
|
-
viewMode,
|
|
4465
|
-
linkAutocompleteSuggestions,
|
|
4466
|
-
imageAutocompleteSuggestions: imageAutoCompleteSuggestions,
|
|
4467
|
-
editorRootElementRef,
|
|
4468
|
-
toolbarComponents,
|
|
4469
|
-
markdownParseOptions: {
|
|
4470
|
-
visitors: importVisitors,
|
|
4471
|
-
mdastExtensions,
|
|
4472
|
-
syntaxExtensions
|
|
4473
|
-
},
|
|
4474
|
-
lexicalConvertOptions: {
|
|
4475
|
-
visitors: exportVisitors,
|
|
4476
|
-
toMarkdownOptions,
|
|
4477
|
-
toMarkdownExtensions
|
|
4478
|
-
},
|
|
4479
|
-
lexicalNodes
|
|
4480
|
-
},
|
|
4481
|
-
/* @__PURE__ */ React__default.createElement(ToolbarPlugin, null),
|
|
4482
|
-
/* @__PURE__ */ React__default.createElement(ViewModeToggler, null, /* @__PURE__ */ React__default.createElement(
|
|
4483
|
-
RichTextPlugin,
|
|
4484
|
-
{
|
|
4485
|
-
contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { className: classNames(styles.contentEditable, contentEditableClassName) }),
|
|
4486
|
-
placeholder: /* @__PURE__ */ React__default.createElement("div", null),
|
|
4487
|
-
ErrorBoundary: LexicalErrorBoundary
|
|
4488
|
-
}
|
|
4489
|
-
)),
|
|
4490
|
-
/* @__PURE__ */ React__default.createElement(LinkPlugin, null),
|
|
4491
|
-
/* @__PURE__ */ React__default.createElement(HorizontalRulePlugin, null),
|
|
4492
|
-
/* @__PURE__ */ React__default.createElement(ListPlugin, null),
|
|
4493
|
-
/* @__PURE__ */ React__default.createElement(ListMaxIndentLevelPlugin, { maxDepth: 7 }),
|
|
4494
|
-
/* @__PURE__ */ React__default.createElement(TabIndentationPlugin, null),
|
|
4495
|
-
/* @__PURE__ */ React__default.createElement(LinkDialogPlugin, null),
|
|
4496
|
-
/* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null),
|
|
4497
|
-
/* @__PURE__ */ React__default.createElement(PatchedMarkdownShortcutPlugin, null),
|
|
4498
|
-
/* @__PURE__ */ React__default.createElement(MDXMethods, { mdxRef: ref })
|
|
4499
|
-
)
|
|
4500
|
-
));
|
|
4501
|
-
}
|
|
4502
|
-
);
|
|
4503
|
-
const MDXMethods = ({ mdxRef }) => {
|
|
4504
|
-
const [markdownSource] = useEmitterValues("markdownSource");
|
|
4505
|
-
React__default.useImperativeHandle(
|
|
4506
|
-
mdxRef,
|
|
4507
|
-
() => {
|
|
4508
|
-
return {
|
|
4509
|
-
getMarkdown: () => {
|
|
4510
|
-
return markdownSource;
|
|
4511
|
-
}
|
|
4512
|
-
};
|
|
4513
|
-
},
|
|
4514
|
-
[markdownSource]
|
|
4515
|
-
);
|
|
4516
|
-
return null;
|
|
4517
|
-
};
|
|
3
|
+
import "@lexical/react/LexicalComposer";
|
|
4
|
+
import "@lexical/react/LexicalContentEditable";
|
|
5
|
+
import "@lexical/react/LexicalErrorBoundary";
|
|
6
|
+
import "@lexical/react/LexicalHorizontalRulePlugin";
|
|
7
|
+
import "@lexical/react/LexicalLinkPlugin";
|
|
8
|
+
import "@lexical/react/LexicalListPlugin";
|
|
9
|
+
import "@lexical/react/LexicalRichTextPlugin";
|
|
10
|
+
import "@lexical/react/LexicalTabIndentationPlugin";
|
|
11
|
+
import "classnames";
|
|
12
|
+
import "react";
|
|
13
|
+
import "@lexical/code";
|
|
14
|
+
import "@lexical/link";
|
|
15
|
+
import "@lexical/list";
|
|
16
|
+
import "@lexical/react/LexicalHorizontalRuleNode";
|
|
17
|
+
import "@lexical/rich-text";
|
|
18
|
+
import "mdast-util-directive";
|
|
19
|
+
import "mdast-util-from-markdown";
|
|
20
|
+
import "mdast-util-frontmatter";
|
|
21
|
+
import "mdast-util-gfm-table";
|
|
22
|
+
import "mdast-util-mdx";
|
|
23
|
+
import "micromark-extension-directive";
|
|
24
|
+
import "micromark-extension-frontmatter";
|
|
25
|
+
import "micromark-extension-gfm-table";
|
|
26
|
+
import "micromark-extension-mdxjs";
|
|
27
|
+
import "@lexical/utils";
|
|
28
|
+
import "@lexical/react/LexicalComposerContext";
|
|
29
|
+
import "@lexical/selection";
|
|
30
|
+
import "@lexical/react/LexicalHistoryPlugin";
|
|
31
|
+
import "mdast-util-to-markdown";
|
|
32
|
+
import "@radix-ui/react-popover";
|
|
33
|
+
import "@radix-ui/react-tooltip";
|
|
34
|
+
import "downshift";
|
|
35
|
+
import "@lexical/markdown";
|
|
36
|
+
import "@lexical/react/LexicalMarkdownShortcutPlugin";
|
|
37
|
+
import "@codemirror/lang-markdown";
|
|
38
|
+
import "@codesandbox/sandpack-react";
|
|
39
|
+
import "react-diff-view";
|
|
40
|
+
import "unidiff";
|
|
41
|
+
import "@radix-ui/react-toolbar";
|
|
42
|
+
import "@radix-ui/react-select";
|
|
43
|
+
import "@radix-ui/react-dialog";
|
|
4518
44
|
export {
|
|
4519
|
-
$createAdmonitionNode,
|
|
4520
|
-
$createCodeBlockNode,
|
|
4521
|
-
$createFrontmatterNode,
|
|
4522
|
-
$createImageNode,
|
|
4523
|
-
$createJsxNode,
|
|
4524
|
-
$createSandpackNode,
|
|
4525
|
-
$createTableNode,
|
|
4526
|
-
$isAdmonitionNode,
|
|
4527
|
-
$isCodeBlockNode,
|
|
4528
|
-
$isFrontmatterNode,
|
|
4529
|
-
$isImageNode,
|
|
4530
|
-
$isJsxNode,
|
|
4531
|
-
$isSandpackNode,
|
|
4532
|
-
$isTableNode,
|
|
45
|
+
$ as $createAdmonitionNode,
|
|
46
|
+
c as $createCodeBlockNode,
|
|
47
|
+
f as $createFrontmatterNode,
|
|
48
|
+
h as $createImageNode,
|
|
49
|
+
k as $createJsxNode,
|
|
50
|
+
n as $createSandpackNode,
|
|
51
|
+
r as $createTableNode,
|
|
52
|
+
b as $isAdmonitionNode,
|
|
53
|
+
d as $isCodeBlockNode,
|
|
54
|
+
g as $isFrontmatterNode,
|
|
55
|
+
j as $isImageNode,
|
|
56
|
+
l as $isJsxNode,
|
|
57
|
+
o as $isSandpackNode,
|
|
58
|
+
q as $isTableNode,
|
|
4533
59
|
AdmonitionKind,
|
|
4534
|
-
AdmonitionNode,
|
|
4535
|
-
CodeBlockNode,
|
|
4536
|
-
FrontmatterNode,
|
|
4537
|
-
ImageNode,
|
|
4538
|
-
JsxNode,
|
|
4539
|
-
MDXEditor,
|
|
4540
|
-
SandpackNode,
|
|
4541
|
-
TableNode,
|
|
4542
|
-
ToolbarComponents,
|
|
4543
|
-
defaultMdxOptionValues
|
|
60
|
+
A as AdmonitionNode,
|
|
61
|
+
C as CodeBlockNode,
|
|
62
|
+
F as FrontmatterNode,
|
|
63
|
+
I as ImageNode,
|
|
64
|
+
J as JsxNode,
|
|
65
|
+
M as MDXEditor,
|
|
66
|
+
m as SandpackNode,
|
|
67
|
+
p as TableNode,
|
|
68
|
+
T as ToolbarComponents,
|
|
69
|
+
v as defaultMdxOptionValues
|
|
4544
70
|
};
|