@mdxeditor/editor 0.8.0 → 0.9.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/README.md +2 -2
- package/dist/{CodeBlockEditor-59b65408.js → CodeBlockEditor-ce4c85ed.js} +3 -2
- package/dist/{CodeBlockEditor-5ae8b0a9.cjs → CodeBlockEditor-ed222322.cjs} +1 -1
- package/dist/FrontmatterEditor-914aa241.cjs +1 -0
- package/dist/{FrontmatterEditor-2b27f5a7.js → FrontmatterEditor-e2f25a6a.js} +2 -1
- package/dist/{ImageEditor-5f203a1c.js → ImageEditor-ad505654.js} +2 -1
- package/dist/ImageEditor-c4e65554.cjs +1 -0
- package/dist/{JsxEditor-95724372.cjs → JsxEditor-6cff258d.cjs} +1 -1
- package/dist/{JsxEditor-f061cc75.js → JsxEditor-88d55ef8.js} +1 -1
- package/dist/LeafDirectiveEditor-0e1328e6.cjs +1 -0
- package/dist/LeafDirectiveEditor-34ead530.js +59 -0
- package/dist/{SandpackEditor-37261889.cjs → SandpackEditor-a999ca47.cjs} +1 -1
- package/dist/{SandpackEditor-ce901c3c.js → SandpackEditor-b1e22784.js} +3 -2
- package/dist/{SourceEditor-6135bf63.cjs → SourceEditor-0c46ec47.cjs} +1 -1
- package/dist/{SourceEditor-e499b8bb.js → SourceEditor-e509d0a5.js} +2 -1
- package/dist/{TableEditor-bb94be2b.js → TableEditor-44bef804.js} +1 -1
- package/dist/{TableEditor-4d00f956.cjs → TableEditor-ced03ce4.cjs} +1 -1
- package/dist/index-21fcefae.cjs +1 -0
- package/dist/{index-470693d8.js → index-ce0832cc.js} +366 -100
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +134 -13
- package/dist/index.js +23 -17
- package/dist/{useCodeMirrorRef-ff0c2781.js → useCodeMirrorRef-177e9901.js} +1 -1
- package/dist/{useCodeMirrorRef-72d8430b.cjs → useCodeMirrorRef-6cb866bd.cjs} +1 -1
- package/package.json +1 -1
- package/dist/FrontmatterEditor-74ad4eb7.cjs +0 -1
- package/dist/ImageEditor-e5fd6b26.cjs +0 -1
- package/dist/index-383c60bb.cjs +0 -1
|
@@ -45,6 +45,7 @@ import { formatLines, diffLines } from "unidiff";
|
|
|
45
45
|
import * as RadixToolbar from "@radix-ui/react-toolbar";
|
|
46
46
|
import * as Select from "@radix-ui/react-select";
|
|
47
47
|
import * as Dialog from "@radix-ui/react-dialog";
|
|
48
|
+
import { LexicalNestedComposer } from "@lexical/react/LexicalNestedComposer";
|
|
48
49
|
class AdmonitionNode extends ElementNode {
|
|
49
50
|
constructor(kind, key) {
|
|
50
51
|
super(key);
|
|
@@ -833,6 +834,60 @@ function $isTableNode(node) {
|
|
|
833
834
|
function $createTableNode(mdastNode) {
|
|
834
835
|
return new TableNode(mdastNode);
|
|
835
836
|
}
|
|
837
|
+
class LeafDirectiveNode extends DecoratorNode {
|
|
838
|
+
constructor(mdastNode, key) {
|
|
839
|
+
super(key);
|
|
840
|
+
__publicField(this, "__mdastNode");
|
|
841
|
+
this.__mdastNode = mdastNode;
|
|
842
|
+
}
|
|
843
|
+
static getType() {
|
|
844
|
+
return "leafDirective";
|
|
845
|
+
}
|
|
846
|
+
static clone(node) {
|
|
847
|
+
return new LeafDirectiveNode(structuredClone(node.__mdastNode));
|
|
848
|
+
}
|
|
849
|
+
static importJSON(serializedNode) {
|
|
850
|
+
return $createLeafDirectiveNode(serializedNode.mdastNode);
|
|
851
|
+
}
|
|
852
|
+
getMdastNode() {
|
|
853
|
+
return this.__mdastNode;
|
|
854
|
+
}
|
|
855
|
+
exportJSON() {
|
|
856
|
+
return {
|
|
857
|
+
mdastNode: this.getMdastNode(),
|
|
858
|
+
type: "leafDirective",
|
|
859
|
+
version: 1
|
|
860
|
+
};
|
|
861
|
+
}
|
|
862
|
+
createDOM() {
|
|
863
|
+
return document.createElement("div");
|
|
864
|
+
}
|
|
865
|
+
updateDOM() {
|
|
866
|
+
return false;
|
|
867
|
+
}
|
|
868
|
+
setMdastNode(mdastNode) {
|
|
869
|
+
this.getWritable().__mdastNode = mdastNode;
|
|
870
|
+
}
|
|
871
|
+
decorate(parentEditor, {
|
|
872
|
+
theme: {
|
|
873
|
+
nodeDecoratorComponents: { LeafDirectiveEditor }
|
|
874
|
+
}
|
|
875
|
+
}) {
|
|
876
|
+
return /* @__PURE__ */ React__default.createElement(LeafDirectiveEditor, { leafDirective: this, mdastNode: this.getMdastNode(), parentEditor });
|
|
877
|
+
}
|
|
878
|
+
isInline() {
|
|
879
|
+
return false;
|
|
880
|
+
}
|
|
881
|
+
isKeyboardSelectable() {
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
function $createLeafDirectiveNode(mdastNode) {
|
|
886
|
+
return new LeafDirectiveNode(mdastNode);
|
|
887
|
+
}
|
|
888
|
+
function $isLeafDirectiveNode(node) {
|
|
889
|
+
return node instanceof LeafDirectiveNode;
|
|
890
|
+
}
|
|
836
891
|
const IS_BOLD = 1;
|
|
837
892
|
const IS_ITALIC = 2;
|
|
838
893
|
const IS_UNDERLINE = 8;
|
|
@@ -1045,6 +1100,12 @@ const LexicalTableVisitor = {
|
|
|
1045
1100
|
actions.appendToParent(mdastParent, lexicalNode.getMdastNode());
|
|
1046
1101
|
}
|
|
1047
1102
|
};
|
|
1103
|
+
const LexicalLeafDirectiveVisitor = {
|
|
1104
|
+
testLexicalNode: $isLeafDirectiveNode,
|
|
1105
|
+
visitLexicalNode({ actions, mdastParent, lexicalNode }) {
|
|
1106
|
+
actions.appendToParent(mdastParent, lexicalNode.getMdastNode());
|
|
1107
|
+
}
|
|
1108
|
+
};
|
|
1048
1109
|
const JsxVisitor = {
|
|
1049
1110
|
testLexicalNode: $isJsxNode,
|
|
1050
1111
|
visitLexicalNode({ mdastParent, lexicalNode, actions }) {
|
|
@@ -1079,7 +1140,8 @@ const defaultLexicalVisitors = {
|
|
|
1079
1140
|
AdmonitionVisitor,
|
|
1080
1141
|
LexicalImageVisitor,
|
|
1081
1142
|
JsxVisitor,
|
|
1082
|
-
LexicalTableVisitor
|
|
1143
|
+
LexicalTableVisitor,
|
|
1144
|
+
LexicalLeafDirectiveVisitor
|
|
1083
1145
|
};
|
|
1084
1146
|
function isParent$1(node) {
|
|
1085
1147
|
return node.children instanceof Array;
|
|
@@ -1291,6 +1353,12 @@ const MdastAdmonitionVisitor = {
|
|
|
1291
1353
|
actions.addAndStepInto($createAdmonitionNode(mdastNode.name));
|
|
1292
1354
|
}
|
|
1293
1355
|
};
|
|
1356
|
+
const MdastLeafDirectiveVisitor = {
|
|
1357
|
+
testNode: "leafDirective",
|
|
1358
|
+
visitNode({ lexicalParent, mdastNode }) {
|
|
1359
|
+
lexicalParent.append($createLeafDirectiveNode(mdastNode));
|
|
1360
|
+
}
|
|
1361
|
+
};
|
|
1294
1362
|
const MdastHeadingVisitor = {
|
|
1295
1363
|
testNode: "heading",
|
|
1296
1364
|
visitNode: function({ mdastNode, actions }) {
|
|
@@ -1436,7 +1504,8 @@ const defaultMdastVisitors = {
|
|
|
1436
1504
|
MdastAdmonitionVisitor,
|
|
1437
1505
|
MdastMdxJsEsmVisitor,
|
|
1438
1506
|
MdastMdxJsxElementVisitor,
|
|
1439
|
-
MdastTableVisitor
|
|
1507
|
+
MdastTableVisitor,
|
|
1508
|
+
MdastLeafDirectiveVisitor
|
|
1440
1509
|
};
|
|
1441
1510
|
function isParent(node) {
|
|
1442
1511
|
return node.children instanceof Array;
|
|
@@ -1479,7 +1548,8 @@ function importMdastTreeToLexical({ root, mdastRoot, visitors }) {
|
|
|
1479
1548
|
return visitor2.testNode(mdastNode);
|
|
1480
1549
|
});
|
|
1481
1550
|
if (!visitor) {
|
|
1482
|
-
|
|
1551
|
+
debugger;
|
|
1552
|
+
throw new Error(`no MdastImportVisitor found for ${mdastNode.type}`, {
|
|
1483
1553
|
cause: mdastNode
|
|
1484
1554
|
});
|
|
1485
1555
|
}
|
|
@@ -1522,7 +1592,8 @@ const defaultLexicalNodes = {
|
|
|
1522
1592
|
JsxNode,
|
|
1523
1593
|
CodeNode,
|
|
1524
1594
|
// this one should not be used, but markdown shortcuts complain about it
|
|
1525
|
-
TableNode
|
|
1595
|
+
TableNode,
|
|
1596
|
+
LeafDirectiveNode
|
|
1526
1597
|
};
|
|
1527
1598
|
function uuidv4() {
|
|
1528
1599
|
const hex = [...Array(256).keys()].map((index2) => index2.toString(16).padStart(2, "0"));
|
|
@@ -2198,47 +2269,48 @@ function seedTable() {
|
|
|
2198
2269
|
]
|
|
2199
2270
|
};
|
|
2200
2271
|
}
|
|
2201
|
-
const [EditorSystem, EditorSystemType] = system((
|
|
2202
|
-
const editor =
|
|
2203
|
-
const markdownSource =
|
|
2204
|
-
const setMarkdown =
|
|
2205
|
-
const historyState =
|
|
2206
|
-
const activeEditor =
|
|
2207
|
-
const currentFormat =
|
|
2208
|
-
const currentSelection =
|
|
2209
|
-
const currentListType =
|
|
2210
|
-
const currentBlockType =
|
|
2211
|
-
const applyFormat =
|
|
2212
|
-
const applyListType =
|
|
2213
|
-
const applyBlockType =
|
|
2214
|
-
const insertHorizontalRule =
|
|
2215
|
-
const insertTable =
|
|
2216
|
-
const insertFrontmatter =
|
|
2217
|
-
const insertImage =
|
|
2218
|
-
const createEditorSubscription =
|
|
2219
|
-
const editorSubscriptions =
|
|
2220
|
-
const inFocus =
|
|
2221
|
-
const activeEditorType =
|
|
2222
|
-
const editorRootElementRef =
|
|
2223
|
-
const markdownParseOptions =
|
|
2224
|
-
const
|
|
2225
|
-
const
|
|
2226
|
-
const
|
|
2227
|
-
const
|
|
2272
|
+
const [EditorSystem, EditorSystemType] = system((r) => {
|
|
2273
|
+
const editor = r.node(null, true);
|
|
2274
|
+
const markdownSource = r.node("");
|
|
2275
|
+
const setMarkdown = r.node();
|
|
2276
|
+
const historyState = r.node(createEmptyHistoryState());
|
|
2277
|
+
const activeEditor = r.derive(editor, null);
|
|
2278
|
+
const currentFormat = r.node(0, true);
|
|
2279
|
+
const currentSelection = r.node(null);
|
|
2280
|
+
const currentListType = r.node(null);
|
|
2281
|
+
const currentBlockType = r.node(null);
|
|
2282
|
+
const applyFormat = r.node();
|
|
2283
|
+
const applyListType = r.node();
|
|
2284
|
+
const applyBlockType = r.node();
|
|
2285
|
+
const insertHorizontalRule = r.node();
|
|
2286
|
+
const insertTable = r.node();
|
|
2287
|
+
const insertFrontmatter = r.node();
|
|
2288
|
+
const insertImage = r.node();
|
|
2289
|
+
const createEditorSubscription = r.node();
|
|
2290
|
+
const editorSubscriptions = r.node([]);
|
|
2291
|
+
const inFocus = r.node(false, true);
|
|
2292
|
+
const activeEditorType = r.node({ type: "lexical" });
|
|
2293
|
+
const editorRootElementRef = r.node(null);
|
|
2294
|
+
const markdownParseOptions = r.node(null);
|
|
2295
|
+
const customLeafDirectiveEditors = r.node([]);
|
|
2296
|
+
const lexicalConvertOptions = r.node(null);
|
|
2297
|
+
const lexicalNodes = r.node([]);
|
|
2298
|
+
const imageAutocompleteSuggestions = r.node([]);
|
|
2299
|
+
const imageUploadHandler = r.node((_) => {
|
|
2228
2300
|
throw new Error("Image upload handling is not implemented");
|
|
2229
2301
|
});
|
|
2230
|
-
|
|
2231
|
-
|
|
2302
|
+
r.link(
|
|
2303
|
+
r.pipe(
|
|
2232
2304
|
createEditorSubscription,
|
|
2233
|
-
|
|
2234
|
-
|
|
2305
|
+
r.o.withLatestFrom(editorSubscriptions),
|
|
2306
|
+
r.o.map(([createSubscription, subscriptions]) => {
|
|
2235
2307
|
return [...subscriptions, createSubscription];
|
|
2236
2308
|
})
|
|
2237
2309
|
),
|
|
2238
2310
|
editorSubscriptions
|
|
2239
2311
|
);
|
|
2240
|
-
|
|
2241
|
-
|
|
2312
|
+
r.sub(r.pipe(setMarkdown, r.o.withLatestFrom(editor, markdownParseOptions)), ([markdown, editor2, markdownParseOptions2]) => {
|
|
2313
|
+
r.pub(markdownSource, markdown);
|
|
2242
2314
|
editor2 == null ? void 0 : editor2.update(() => {
|
|
2243
2315
|
$getRoot().clear();
|
|
2244
2316
|
importMarkdownToLexical({
|
|
@@ -2248,16 +2320,16 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2248
2320
|
});
|
|
2249
2321
|
});
|
|
2250
2322
|
});
|
|
2251
|
-
|
|
2323
|
+
r.sub(r.pipe(applyListType, r.o.withLatestFrom(activeEditor)), ([listType, theEditor]) => {
|
|
2252
2324
|
theEditor == null ? void 0 : theEditor.dispatchCommand(ListTypeCommandMap.get(listType), void 0);
|
|
2253
2325
|
});
|
|
2254
|
-
|
|
2326
|
+
r.sub(r.pipe(applyFormat, r.o.withLatestFrom(activeEditor)), ([format, theEditor]) => {
|
|
2255
2327
|
theEditor == null ? void 0 : theEditor.dispatchCommand(FORMAT_TEXT_COMMAND, format);
|
|
2256
2328
|
});
|
|
2257
|
-
|
|
2329
|
+
r.sub(r.pipe(insertHorizontalRule, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2258
2330
|
theEditor == null ? void 0 : theEditor.dispatchCommand(INSERT_HORIZONTAL_RULE_COMMAND, void 0);
|
|
2259
2331
|
});
|
|
2260
|
-
|
|
2332
|
+
r.sub(r.pipe(insertImage, r.o.withLatestFrom(activeEditor)), ([src, theEditor]) => {
|
|
2261
2333
|
theEditor == null ? void 0 : theEditor.update(() => {
|
|
2262
2334
|
const imageNode = $createImageNode({ altText: "", src, title: "" });
|
|
2263
2335
|
$insertNodes([imageNode]);
|
|
@@ -2266,7 +2338,7 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2266
2338
|
}
|
|
2267
2339
|
});
|
|
2268
2340
|
});
|
|
2269
|
-
|
|
2341
|
+
r.sub(r.pipe(insertFrontmatter, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2270
2342
|
theEditor == null ? void 0 : theEditor.update(() => {
|
|
2271
2343
|
const firstItem = $getRoot().getFirstChild();
|
|
2272
2344
|
if (!$isFrontmatterNode(firstItem)) {
|
|
@@ -2279,7 +2351,7 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2279
2351
|
}
|
|
2280
2352
|
});
|
|
2281
2353
|
});
|
|
2282
|
-
|
|
2354
|
+
r.sub(r.pipe(insertTable, r.o.withLatestFrom(activeEditor)), ([, theEditor]) => {
|
|
2283
2355
|
theEditor == null ? void 0 : theEditor.getEditorState().read(() => {
|
|
2284
2356
|
const selection = $getSelection();
|
|
2285
2357
|
if ($isRangeSelection(selection)) {
|
|
@@ -2296,7 +2368,7 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2296
2368
|
}
|
|
2297
2369
|
});
|
|
2298
2370
|
});
|
|
2299
|
-
|
|
2371
|
+
r.sub(r.pipe(applyBlockType, r.o.withLatestFrom(activeEditor)), ([type, theEditor]) => {
|
|
2300
2372
|
if (theEditor) {
|
|
2301
2373
|
switch (type) {
|
|
2302
2374
|
case "paragraph": {
|
|
@@ -2321,7 +2393,7 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2321
2393
|
}
|
|
2322
2394
|
}
|
|
2323
2395
|
});
|
|
2324
|
-
|
|
2396
|
+
r.sub(r.pipe(currentSelection, r.o.withLatestFrom(activeEditor)), ([selection, theEditor]) => {
|
|
2325
2397
|
if (!selection || !theEditor) {
|
|
2326
2398
|
return;
|
|
2327
2399
|
}
|
|
@@ -2339,14 +2411,14 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2339
2411
|
if ($isListNode(element)) {
|
|
2340
2412
|
const parentList = $getNearestNodeOfType(anchorNode, ListNode);
|
|
2341
2413
|
const type = parentList ? parentList.getListType() : element.getListType();
|
|
2342
|
-
|
|
2414
|
+
r.pubIn({
|
|
2343
2415
|
[currentListType.key]: type,
|
|
2344
2416
|
[currentBlockType.key]: ""
|
|
2345
2417
|
});
|
|
2346
2418
|
} else {
|
|
2347
|
-
|
|
2419
|
+
r.pub(currentListType, null);
|
|
2348
2420
|
const blockType = $isHeadingNode(element) ? element.getTag() : $isAdmonitionNode(element) ? element.getKind() : element.getType();
|
|
2349
|
-
|
|
2421
|
+
r.pubIn({
|
|
2350
2422
|
[currentListType.key]: null,
|
|
2351
2423
|
[currentBlockType.key]: blockType
|
|
2352
2424
|
});
|
|
@@ -2356,18 +2428,18 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2356
2428
|
function handleSelectionChange() {
|
|
2357
2429
|
const selection = $getSelection();
|
|
2358
2430
|
if ($isRangeSelection(selection)) {
|
|
2359
|
-
|
|
2431
|
+
r.pubKeys({
|
|
2360
2432
|
currentSelection: selection,
|
|
2361
2433
|
currentFormat: selection.format
|
|
2362
2434
|
});
|
|
2363
2435
|
}
|
|
2364
2436
|
}
|
|
2365
|
-
|
|
2437
|
+
r.sub(editor, (theEditor) => {
|
|
2366
2438
|
if (theEditor) {
|
|
2367
2439
|
theEditor.registerCommand(
|
|
2368
2440
|
SELECTION_CHANGE_COMMAND,
|
|
2369
2441
|
(_, editor2) => {
|
|
2370
|
-
|
|
2442
|
+
r.pubIn({
|
|
2371
2443
|
[activeEditor.key]: editor2,
|
|
2372
2444
|
[inFocus.key]: true
|
|
2373
2445
|
});
|
|
@@ -2378,36 +2450,36 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2378
2450
|
);
|
|
2379
2451
|
}
|
|
2380
2452
|
});
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2453
|
+
r.pipe(
|
|
2454
|
+
r.combine(editorSubscriptions, activeEditor),
|
|
2455
|
+
r.o.scan((teardowns, [editorSubscriptions2, activeEditorValue]) => {
|
|
2384
2456
|
teardowns.forEach((u) => u());
|
|
2385
|
-
return activeEditorValue ? editorSubscriptions2.map((s) => s(activeEditorValue,
|
|
2457
|
+
return activeEditorValue ? editorSubscriptions2.map((s) => s(activeEditorValue, r.getValue(editor))) : [];
|
|
2386
2458
|
}, [])
|
|
2387
2459
|
);
|
|
2388
|
-
|
|
2460
|
+
r.pub(createEditorSubscription, (editor2) => {
|
|
2389
2461
|
return editor2.registerUpdateListener(({ editorState }) => {
|
|
2390
2462
|
editorState.read(() => {
|
|
2391
2463
|
handleSelectionChange();
|
|
2392
2464
|
});
|
|
2393
2465
|
});
|
|
2394
2466
|
});
|
|
2395
|
-
|
|
2467
|
+
r.pub(createEditorSubscription, (theEditor) => {
|
|
2396
2468
|
return theEditor.registerCommand(
|
|
2397
2469
|
BLUR_COMMAND,
|
|
2398
2470
|
(payload) => {
|
|
2399
2471
|
var _a;
|
|
2400
|
-
const rootEditor =
|
|
2472
|
+
const rootEditor = r.getValue(editor);
|
|
2401
2473
|
const movingOutside = !((_a = rootEditor.getRootElement()) == null ? void 0 : _a.contains(payload.relatedTarget));
|
|
2402
2474
|
if (movingOutside) {
|
|
2403
|
-
|
|
2475
|
+
r.pub(inFocus, false);
|
|
2404
2476
|
}
|
|
2405
2477
|
return false;
|
|
2406
2478
|
},
|
|
2407
2479
|
COMMAND_PRIORITY_LOW
|
|
2408
2480
|
);
|
|
2409
2481
|
});
|
|
2410
|
-
|
|
2482
|
+
r.pub(createEditorSubscription, (theEditor) => {
|
|
2411
2483
|
return theEditor.registerCommand(
|
|
2412
2484
|
PASTE_COMMAND,
|
|
2413
2485
|
(event) => {
|
|
@@ -2417,10 +2489,10 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2417
2489
|
if (!cbPayload.length || cbPayload.length === 0) {
|
|
2418
2490
|
return false;
|
|
2419
2491
|
}
|
|
2420
|
-
const imageUploadHandlerValue =
|
|
2492
|
+
const imageUploadHandlerValue = r.getValue(imageUploadHandler);
|
|
2421
2493
|
Promise.all(cbPayload.map((file) => imageUploadHandlerValue(file.getAsFile()))).then((urls) => {
|
|
2422
2494
|
urls.forEach((url) => {
|
|
2423
|
-
|
|
2495
|
+
r.pub(insertImage, url);
|
|
2424
2496
|
});
|
|
2425
2497
|
}).catch((e) => {
|
|
2426
2498
|
throw e;
|
|
@@ -2456,7 +2528,8 @@ const [EditorSystem, EditorSystemType] = system((r2) => {
|
|
|
2456
2528
|
imageAutocompleteSuggestions,
|
|
2457
2529
|
markdownSource,
|
|
2458
2530
|
setMarkdown,
|
|
2459
|
-
imageUploadHandler
|
|
2531
|
+
imageUploadHandler,
|
|
2532
|
+
customLeafDirectiveEditors
|
|
2460
2533
|
};
|
|
2461
2534
|
}, []);
|
|
2462
2535
|
const [JsxSystem, JsxSystemType] = system((r) => {
|
|
@@ -2598,6 +2671,8 @@ const [SandpackSystem] = system(
|
|
|
2598
2671
|
},
|
|
2599
2672
|
[EditorSystemType]
|
|
2600
2673
|
);
|
|
2674
|
+
const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2675
|
+
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
2601
2676
|
function getSelectedNode(selection) {
|
|
2602
2677
|
const anchor = selection.anchor;
|
|
2603
2678
|
const focus = selection.focus;
|
|
@@ -2648,8 +2723,6 @@ function getStateAsMarkdown(editor, exportParams) {
|
|
|
2648
2723
|
});
|
|
2649
2724
|
}).markdown;
|
|
2650
2725
|
}
|
|
2651
|
-
const CAN_USE_DOM = typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined";
|
|
2652
|
-
const IS_APPLE = CAN_USE_DOM && /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
|
2653
2726
|
function getLinkNodeInSelection(selection) {
|
|
2654
2727
|
const node = getSelectedNode(selection);
|
|
2655
2728
|
const parent = node.getParent();
|
|
@@ -2873,7 +2946,7 @@ const [OnChangeSystem, OnChangeSystemType] = system(
|
|
|
2873
2946
|
r.pub(markdownSource, markdown);
|
|
2874
2947
|
}
|
|
2875
2948
|
updateMarkdown();
|
|
2876
|
-
return
|
|
2949
|
+
return rootEditor.registerUpdateListener(({ dirtyElements, dirtyLeaves, prevEditorState, tags }) => {
|
|
2877
2950
|
if (dirtyElements.size === 0 && dirtyLeaves.size === 0 || tags.has("history-merge") || prevEditorState.isEmpty()) {
|
|
2878
2951
|
return;
|
|
2879
2952
|
}
|
|
@@ -2915,7 +2988,8 @@ const {
|
|
|
2915
2988
|
viewMode: "viewMode",
|
|
2916
2989
|
linkAutocompleteSuggestions: "linkAutocompleteSuggestions",
|
|
2917
2990
|
imageAutocompleteSuggestions: "imageAutocompleteSuggestions",
|
|
2918
|
-
codeBlockLanguages: "codeBlockLanguages"
|
|
2991
|
+
codeBlockLanguages: "codeBlockLanguages",
|
|
2992
|
+
customLeafDirectiveEditors: "customLeafDirectiveEditors"
|
|
2919
2993
|
},
|
|
2920
2994
|
events: {
|
|
2921
2995
|
onChange: "onChange"
|
|
@@ -3074,9 +3148,9 @@ const styles = {
|
|
|
3074
3148
|
imageWrapper
|
|
3075
3149
|
};
|
|
3076
3150
|
createCommand();
|
|
3077
|
-
const MAX_SUGGESTIONS$
|
|
3151
|
+
const MAX_SUGGESTIONS$2 = 20;
|
|
3078
3152
|
function LinkEditForm({ initialUrl, onSubmit, onCancel, linkAutocompleteSuggestions }) {
|
|
3079
|
-
const [items, setItems] = React__default.useState(linkAutocompleteSuggestions.slice(0, MAX_SUGGESTIONS$
|
|
3153
|
+
const [items, setItems] = React__default.useState(linkAutocompleteSuggestions.slice(0, MAX_SUGGESTIONS$2));
|
|
3080
3154
|
const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
|
|
3081
3155
|
initialInputValue: initialUrl,
|
|
3082
3156
|
onInputValueChange({ inputValue }) {
|
|
@@ -3085,7 +3159,7 @@ function LinkEditForm({ initialUrl, onSubmit, onCancel, linkAutocompleteSuggesti
|
|
|
3085
3159
|
for (const url of linkAutocompleteSuggestions) {
|
|
3086
3160
|
if (url.toLowerCase().includes(inputValue)) {
|
|
3087
3161
|
matchingItems.push(url);
|
|
3088
|
-
if (matchingItems.length >= MAX_SUGGESTIONS$
|
|
3162
|
+
if (matchingItems.length >= MAX_SUGGESTIONS$2) {
|
|
3089
3163
|
break;
|
|
3090
3164
|
}
|
|
3091
3165
|
}
|
|
@@ -3284,7 +3358,7 @@ const SharedHistoryPlugin = () => {
|
|
|
3284
3358
|
return /* @__PURE__ */ React__default.createElement(HistoryPlugin, { externalHistoryState: historyState });
|
|
3285
3359
|
};
|
|
3286
3360
|
const index = "";
|
|
3287
|
-
const SourceEditor = React__default.lazy(() => import("./SourceEditor-
|
|
3361
|
+
const SourceEditor = React__default.lazy(() => import("./SourceEditor-e509d0a5.js").then((module) => ({ default: module.SourceEditor })));
|
|
3288
3362
|
function DiffViewer({ oldText, newText }) {
|
|
3289
3363
|
const diffText = formatLines(diffLines(oldText, newText), { context: 3 });
|
|
3290
3364
|
if (diffText.trim() === "")
|
|
@@ -3427,7 +3501,124 @@ const SvgAddPhoto = (props) => /* @__PURE__ */ React.createElement("svg", { widt
|
|
|
3427
3501
|
maskType: "alpha"
|
|
3428
3502
|
}, 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" })));
|
|
3429
3503
|
const AddPhotoIcon = SvgAddPhoto;
|
|
3430
|
-
const
|
|
3504
|
+
const MAX_SUGGESTIONS$1 = 20;
|
|
3505
|
+
const DialogButton = React__default.forwardRef(
|
|
3506
|
+
({ autocompleteSuggestions = [], submitButtonTitle, dialogInputPlaceholder, onSubmit, tooltipTitle, buttonContent }, forwardedRef) => {
|
|
3507
|
+
const [editorRootElementRef] = useEmitterValues("editorRootElementRef");
|
|
3508
|
+
const [open, setOpen] = React__default.useState(false);
|
|
3509
|
+
const onSubmitCallback = React__default.useCallback(
|
|
3510
|
+
(value) => {
|
|
3511
|
+
onSubmit(value);
|
|
3512
|
+
setOpen(false);
|
|
3513
|
+
},
|
|
3514
|
+
[onSubmit]
|
|
3515
|
+
);
|
|
3516
|
+
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, ref: forwardedRef }, /* @__PURE__ */ React__default.createElement(InstantTooltip, { title: tooltipTitle }, buttonContent))), /* @__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(
|
|
3517
|
+
DialogForm,
|
|
3518
|
+
{
|
|
3519
|
+
submitButtonTitle,
|
|
3520
|
+
autocompleteSuggestions,
|
|
3521
|
+
onSubmitCallback,
|
|
3522
|
+
dialogInputPlaceholder
|
|
3523
|
+
}
|
|
3524
|
+
))));
|
|
3525
|
+
}
|
|
3526
|
+
);
|
|
3527
|
+
const DialogForm = ({ autocompleteSuggestions, onSubmitCallback, dialogInputPlaceholder, submitButtonTitle }) => {
|
|
3528
|
+
const [items, setItems] = React__default.useState(autocompleteSuggestions.slice(0, MAX_SUGGESTIONS$1));
|
|
3529
|
+
const enableAutoComplete = autocompleteSuggestions.length > 0;
|
|
3530
|
+
const { isOpen, getToggleButtonProps, getMenuProps, getInputProps, highlightedIndex, getItemProps, selectedItem } = useCombobox({
|
|
3531
|
+
initialInputValue: "",
|
|
3532
|
+
onInputValueChange({ inputValue }) {
|
|
3533
|
+
inputValue = (inputValue == null ? void 0 : inputValue.toLowerCase()) || "";
|
|
3534
|
+
const matchingItems = [];
|
|
3535
|
+
for (const suggestion of autocompleteSuggestions) {
|
|
3536
|
+
if (suggestion.toLowerCase().includes(inputValue)) {
|
|
3537
|
+
matchingItems.push(suggestion);
|
|
3538
|
+
if (matchingItems.length >= MAX_SUGGESTIONS$1) {
|
|
3539
|
+
break;
|
|
3540
|
+
}
|
|
3541
|
+
}
|
|
3542
|
+
}
|
|
3543
|
+
setItems(matchingItems);
|
|
3544
|
+
},
|
|
3545
|
+
items,
|
|
3546
|
+
itemToString(item) {
|
|
3547
|
+
return item ?? "";
|
|
3548
|
+
}
|
|
3549
|
+
});
|
|
3550
|
+
const onSubmitEH = (e) => {
|
|
3551
|
+
e.preventDefault();
|
|
3552
|
+
onSubmitCallback(selectedItem || "");
|
|
3553
|
+
};
|
|
3554
|
+
const onKeyDownEH = React__default.useCallback(
|
|
3555
|
+
(e) => {
|
|
3556
|
+
var _a;
|
|
3557
|
+
if (e.key === "Escape") {
|
|
3558
|
+
(_a = e.target.form) == null ? void 0 : _a.reset();
|
|
3559
|
+
} else if (e.key === "Enter" && (!isOpen || items.length === 0)) {
|
|
3560
|
+
e.preventDefault();
|
|
3561
|
+
onSubmitCallback(e.target.value);
|
|
3562
|
+
}
|
|
3563
|
+
},
|
|
3564
|
+
[isOpen, items, onSubmitCallback]
|
|
3565
|
+
);
|
|
3566
|
+
const downshiftInputProps = getInputProps();
|
|
3567
|
+
const inputProps = {
|
|
3568
|
+
...downshiftInputProps,
|
|
3569
|
+
onKeyDown: (e) => {
|
|
3570
|
+
onKeyDownEH(e);
|
|
3571
|
+
downshiftInputProps.onKeyDown(e);
|
|
3572
|
+
}
|
|
3573
|
+
};
|
|
3574
|
+
const dropdownIsVisible = isOpen && items.length > 0;
|
|
3575
|
+
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(
|
|
3576
|
+
"input",
|
|
3577
|
+
{
|
|
3578
|
+
placeholder: dialogInputPlaceholder,
|
|
3579
|
+
className: styles.linkDialogInput,
|
|
3580
|
+
...inputProps,
|
|
3581
|
+
autoFocus: true,
|
|
3582
|
+
size: 30,
|
|
3583
|
+
"data-editor-dialog": true
|
|
3584
|
+
}
|
|
3585
|
+
), enableAutoComplete && /* @__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(
|
|
3586
|
+
"li",
|
|
3587
|
+
{
|
|
3588
|
+
"data-selected": selectedItem === item,
|
|
3589
|
+
"data-highlighted": highlightedIndex === index2,
|
|
3590
|
+
key: `${item}${index2}`,
|
|
3591
|
+
...getItemProps({ item, index: index2 })
|
|
3592
|
+
},
|
|
3593
|
+
item
|
|
3594
|
+
))))), /* @__PURE__ */ React__default.createElement(
|
|
3595
|
+
"button",
|
|
3596
|
+
{
|
|
3597
|
+
type: "submit",
|
|
3598
|
+
title: submitButtonTitle,
|
|
3599
|
+
"aria-label": submitButtonTitle,
|
|
3600
|
+
className: classNames(styles.actionButton, styles.primaryActionButton)
|
|
3601
|
+
},
|
|
3602
|
+
/* @__PURE__ */ React__default.createElement(CheckIcon, null)
|
|
3603
|
+
), /* @__PURE__ */ React__default.createElement(Dialog.Close, { className: styles.actionButton }, /* @__PURE__ */ React__default.createElement(CloseIcon, null)));
|
|
3604
|
+
};
|
|
3605
|
+
const ImageButton = React__default.forwardRef((_, forwardedRef) => {
|
|
3606
|
+
const [imageAutocompleteSuggestions] = useEmitterValues("imageAutocompleteSuggestions");
|
|
3607
|
+
const insertImage = usePublisher("insertImage");
|
|
3608
|
+
return /* @__PURE__ */ React__default.createElement(
|
|
3609
|
+
DialogButton,
|
|
3610
|
+
{
|
|
3611
|
+
ref: forwardedRef,
|
|
3612
|
+
submitButtonTitle: "Insert Image",
|
|
3613
|
+
dialogInputPlaceholder: "Paste or select image URL",
|
|
3614
|
+
tooltipTitle: "Insert image",
|
|
3615
|
+
onSubmit: insertImage,
|
|
3616
|
+
buttonContent: /* @__PURE__ */ React__default.createElement(AddPhotoIcon, null),
|
|
3617
|
+
autocompleteSuggestions: imageAutocompleteSuggestions
|
|
3618
|
+
}
|
|
3619
|
+
);
|
|
3620
|
+
});
|
|
3621
|
+
React__default.forwardRef((props, forwardedRef) => {
|
|
3431
3622
|
const [editorRootElementRef, imageAutocompleteSuggestions] = useEmitterValues("editorRootElementRef", "imageAutocompleteSuggestions");
|
|
3432
3623
|
const [open, setOpen] = React__default.useState(false);
|
|
3433
3624
|
const insertImage = usePublisher("insertImage");
|
|
@@ -3440,7 +3631,6 @@ const ImageButton = React__default.forwardRef((props, forwardedRef) => {
|
|
|
3440
3631
|
);
|
|
3441
3632
|
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 }))));
|
|
3442
3633
|
});
|
|
3443
|
-
createCommand();
|
|
3444
3634
|
const MAX_SUGGESTIONS = 20;
|
|
3445
3635
|
const ImageForm = ({ initialUrl, onSubmit, imageAutocompleteSuggestions }) => {
|
|
3446
3636
|
const [items, setItems] = React__default.useState(imageAutocompleteSuggestions.slice(0, MAX_SUGGESTIONS));
|
|
@@ -3644,9 +3834,10 @@ const ToolbarComponents = {
|
|
|
3644
3834
|
BlockTypeSelect,
|
|
3645
3835
|
BoldItalicUnderlineButtons,
|
|
3646
3836
|
CodeBlockButton,
|
|
3837
|
+
CodeFormattingButton,
|
|
3647
3838
|
FrontmatterButton,
|
|
3648
3839
|
GroupGroup,
|
|
3649
|
-
|
|
3840
|
+
HorizontalRuleButton,
|
|
3650
3841
|
LinkButton,
|
|
3651
3842
|
ListButtons,
|
|
3652
3843
|
SandpackButton,
|
|
@@ -3656,7 +3847,8 @@ const ToolbarComponents = {
|
|
|
3656
3847
|
ToggleSingleGroupWithItem,
|
|
3657
3848
|
ToolbarButton,
|
|
3658
3849
|
ToolbarSeparator,
|
|
3659
|
-
ImageButton
|
|
3850
|
+
ImageButton,
|
|
3851
|
+
DialogButton
|
|
3660
3852
|
};
|
|
3661
3853
|
const ToolbarPlugin = () => {
|
|
3662
3854
|
const [activeEditorType, viewMode] = useEmitterValues("activeEditorType", "viewMode");
|
|
@@ -3869,24 +4061,28 @@ function getDragSelection(event) {
|
|
|
3869
4061
|
return range;
|
|
3870
4062
|
}
|
|
3871
4063
|
const LazyFrontmatterEditor = React__default.lazy(
|
|
3872
|
-
() => import("./FrontmatterEditor-
|
|
4064
|
+
() => import("./FrontmatterEditor-e2f25a6a.js").then((module) => ({ default: module.FrontmatterEditor }))
|
|
3873
4065
|
);
|
|
3874
|
-
const LazyJsxEditor = React__default.lazy(() => import("./JsxEditor-
|
|
4066
|
+
const LazyJsxEditor = React__default.lazy(() => import("./JsxEditor-88d55ef8.js").then((module) => ({ default: module.JsxEditor })));
|
|
3875
4067
|
const LazySandpackEditor = React__default.lazy(
|
|
3876
|
-
() => import("./SandpackEditor-
|
|
4068
|
+
() => import("./SandpackEditor-b1e22784.js").then((module) => ({ default: module.SandpackEditor }))
|
|
3877
4069
|
);
|
|
3878
4070
|
const LazyCodeBlockEditor = React__default.lazy(
|
|
3879
|
-
() => import("./CodeBlockEditor-
|
|
4071
|
+
() => import("./CodeBlockEditor-ce4c85ed.js").then((module) => ({ default: module.CodeBlockEditor }))
|
|
4072
|
+
);
|
|
4073
|
+
const LazyTableEditor = React__default.lazy(() => import("./TableEditor-44bef804.js").then((module) => ({ default: module.TableEditor })));
|
|
4074
|
+
const LazyImageEditor = React__default.lazy(() => import("./ImageEditor-ad505654.js").then((module) => ({ default: module.ImageEditor })));
|
|
4075
|
+
const LazyLeafDirectiveEditor = React__default.lazy(
|
|
4076
|
+
() => import("./LeafDirectiveEditor-34ead530.js").then((module) => ({ default: module.LeafDirectiveEditor }))
|
|
3880
4077
|
);
|
|
3881
|
-
const LazyTableEditor = React__default.lazy(() => import("./TableEditor-bb94be2b.js").then((module) => ({ default: module.TableEditor })));
|
|
3882
|
-
const LazyImageEditor = React__default.lazy(() => import("./ImageEditor-5f203a1c.js").then((module) => ({ default: module.ImageEditor })));
|
|
3883
4078
|
const defaultNodeDecorators = {
|
|
3884
4079
|
FrontmatterEditor: LazyFrontmatterEditor,
|
|
3885
4080
|
JsxEditor: LazyJsxEditor,
|
|
3886
4081
|
SandpackEditor: LazySandpackEditor,
|
|
3887
4082
|
CodeBlockEditor: LazyCodeBlockEditor,
|
|
3888
4083
|
TableEditor: LazyTableEditor,
|
|
3889
|
-
ImageEditor: LazyImageEditor
|
|
4084
|
+
ImageEditor: LazyImageEditor,
|
|
4085
|
+
LeafDirectiveEditor: LazyLeafDirectiveEditor
|
|
3890
4086
|
};
|
|
3891
4087
|
const defaultToolbarComponents = [
|
|
3892
4088
|
BoldItalicUnderlineButtons,
|
|
@@ -3967,7 +4163,8 @@ const MDXEditor = React__default.forwardRef(
|
|
|
3967
4163
|
toMarkdownOptions = defaultToMarkdownOptions,
|
|
3968
4164
|
visitors: exportVisitors = Object.values(defaultLexicalVisitors)
|
|
3969
4165
|
} = {},
|
|
3970
|
-
lexicalNodes = Object.values(defaultLexicalNodes)
|
|
4166
|
+
lexicalNodes = Object.values(defaultLexicalNodes),
|
|
4167
|
+
customLeafDirectiveEditors = []
|
|
3971
4168
|
}, ref) => {
|
|
3972
4169
|
const editorRootElementRef = React__default.useRef(null);
|
|
3973
4170
|
return /* @__PURE__ */ React__default.createElement("div", { className: classNames(styles.editorRoot, styles.editorWrapper, className), ref: editorRootElementRef }, /* @__PURE__ */ React__default.createElement(
|
|
@@ -4018,7 +4215,8 @@ const MDXEditor = React__default.forwardRef(
|
|
|
4018
4215
|
toMarkdownExtensions
|
|
4019
4216
|
},
|
|
4020
4217
|
lexicalNodes,
|
|
4021
|
-
imageUploadHandler
|
|
4218
|
+
imageUploadHandler,
|
|
4219
|
+
customLeafDirectiveEditors
|
|
4022
4220
|
},
|
|
4023
4221
|
/* @__PURE__ */ React__default.createElement(ToolbarPlugin, null),
|
|
4024
4222
|
/* @__PURE__ */ React__default.createElement(ViewModeToggler, null, /* @__PURE__ */ React__default.createElement(
|
|
@@ -4060,6 +4258,68 @@ const MDXMethods = ({ mdxRef }) => {
|
|
|
4060
4258
|
);
|
|
4061
4259
|
return null;
|
|
4062
4260
|
};
|
|
4261
|
+
const NestedEditorsContext = React__default.createContext(void 0);
|
|
4262
|
+
const useNestedEditorContext = () => {
|
|
4263
|
+
const context = React__default.useContext(NestedEditorsContext);
|
|
4264
|
+
if (!context) {
|
|
4265
|
+
throw new Error("useNestedEditor must be used within a NestedEditorsProvider");
|
|
4266
|
+
}
|
|
4267
|
+
return context;
|
|
4268
|
+
};
|
|
4269
|
+
function useMdastNodeUpdater() {
|
|
4270
|
+
const { parentEditor, lexicalNode } = useNestedEditorContext();
|
|
4271
|
+
return function updateMdastNode(node) {
|
|
4272
|
+
parentEditor.update(() => {
|
|
4273
|
+
lexicalNode.setMdastNode(node);
|
|
4274
|
+
});
|
|
4275
|
+
};
|
|
4276
|
+
}
|
|
4277
|
+
const NestedEditor = function(props) {
|
|
4278
|
+
const { getContent, getUpdatedMdastNode, contentEditableProps } = props;
|
|
4279
|
+
const { mdastNode } = useNestedEditorContext();
|
|
4280
|
+
const updateMdastNode = useMdastNodeUpdater();
|
|
4281
|
+
const [markdownParseOptions, lexicalConvertOptions, jsxComponentDescriptors, lexicalNodes] = useEmitterValues(
|
|
4282
|
+
"markdownParseOptions",
|
|
4283
|
+
"lexicalConvertOptions",
|
|
4284
|
+
"jsxComponentDescriptors",
|
|
4285
|
+
"lexicalNodes"
|
|
4286
|
+
);
|
|
4287
|
+
const [editor] = React__default.useState(() => {
|
|
4288
|
+
const editor2 = createEditor({
|
|
4289
|
+
nodes: lexicalNodes,
|
|
4290
|
+
theme
|
|
4291
|
+
});
|
|
4292
|
+
editor2.update(() => {
|
|
4293
|
+
importMdastTreeToLexical({
|
|
4294
|
+
root: $getRoot(),
|
|
4295
|
+
mdastRoot: { type: "root", children: [{ type: "paragraph", children: getContent(mdastNode) }] },
|
|
4296
|
+
visitors: markdownParseOptions.visitors
|
|
4297
|
+
});
|
|
4298
|
+
});
|
|
4299
|
+
return editor2;
|
|
4300
|
+
});
|
|
4301
|
+
React__default.useEffect(() => {
|
|
4302
|
+
return editor.registerUpdateListener(({ editorState }) => {
|
|
4303
|
+
editorState.read(() => {
|
|
4304
|
+
const mdast = exportLexicalTreeToMdast({
|
|
4305
|
+
root: $getRoot(),
|
|
4306
|
+
jsxComponentDescriptors,
|
|
4307
|
+
...lexicalConvertOptions
|
|
4308
|
+
});
|
|
4309
|
+
const rootParagraph = mdast.children[0];
|
|
4310
|
+
updateMdastNode(getUpdatedMdastNode(mdastNode, rootParagraph.children));
|
|
4311
|
+
});
|
|
4312
|
+
});
|
|
4313
|
+
}, [editor, getUpdatedMdastNode, jsxComponentDescriptors, lexicalConvertOptions, mdastNode, updateMdastNode]);
|
|
4314
|
+
return /* @__PURE__ */ React__default.createElement(LexicalNestedComposer, { initialEditor: editor }, /* @__PURE__ */ React__default.createElement(
|
|
4315
|
+
RichTextPlugin,
|
|
4316
|
+
{
|
|
4317
|
+
contentEditable: /* @__PURE__ */ React__default.createElement(ContentEditable, { ...contentEditableProps }),
|
|
4318
|
+
placeholder: /* @__PURE__ */ React__default.createElement("div", null),
|
|
4319
|
+
ErrorBoundary: LexicalErrorBoundary
|
|
4320
|
+
}
|
|
4321
|
+
), /* @__PURE__ */ React__default.createElement(SharedHistoryPlugin, null));
|
|
4322
|
+
};
|
|
4063
4323
|
export {
|
|
4064
4324
|
$isImageNode as $,
|
|
4065
4325
|
AdmonitionNode as A,
|
|
@@ -4067,29 +4327,35 @@ export {
|
|
|
4067
4327
|
FrontmatterNode as F,
|
|
4068
4328
|
ImageNode as I,
|
|
4069
4329
|
JsxNode as J,
|
|
4330
|
+
LeafDirectiveNode as L,
|
|
4070
4331
|
MDXEditor as M,
|
|
4332
|
+
NestedEditorsContext as N,
|
|
4071
4333
|
SharedHistoryPlugin as S,
|
|
4072
4334
|
ToolbarComponents as T,
|
|
4073
4335
|
usePublisher as a,
|
|
4074
|
-
|
|
4075
|
-
|
|
4076
|
-
$
|
|
4336
|
+
NestedEditor as b,
|
|
4337
|
+
useMdastNodeUpdater as c,
|
|
4338
|
+
$createAdmonitionNode as d,
|
|
4077
4339
|
exportLexicalTreeToMdast as e,
|
|
4078
|
-
$
|
|
4079
|
-
$
|
|
4080
|
-
$
|
|
4340
|
+
$isAdmonitionNode as f,
|
|
4341
|
+
$createCodeBlockNode as g,
|
|
4342
|
+
$isCodeBlockNode as h,
|
|
4081
4343
|
importMdastTreeToLexical as i,
|
|
4082
|
-
$
|
|
4083
|
-
$
|
|
4084
|
-
$
|
|
4085
|
-
|
|
4086
|
-
$
|
|
4087
|
-
|
|
4088
|
-
|
|
4089
|
-
$
|
|
4090
|
-
|
|
4344
|
+
$createFrontmatterNode as j,
|
|
4345
|
+
$isFrontmatterNode as k,
|
|
4346
|
+
$createImageNode as l,
|
|
4347
|
+
$createJsxNode as m,
|
|
4348
|
+
$isJsxNode as n,
|
|
4349
|
+
SandpackNode as o,
|
|
4350
|
+
$createSandpackNode as p,
|
|
4351
|
+
$isSandpackNode as q,
|
|
4352
|
+
TableNode as r,
|
|
4091
4353
|
styles as s,
|
|
4092
4354
|
theme as t,
|
|
4093
4355
|
useEmitterValues as u,
|
|
4094
|
-
|
|
4356
|
+
$isTableNode as v,
|
|
4357
|
+
$createTableNode as w,
|
|
4358
|
+
$createLeafDirectiveNode as x,
|
|
4359
|
+
$isLeafDirectiveNode as y,
|
|
4360
|
+
defaultMdxOptionValues as z
|
|
4095
4361
|
};
|