@milkdown/crepe 7.12.1 → 7.13.1
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/lib/cjs/feature/block-edit/index.js +248 -229
- package/lib/cjs/feature/block-edit/index.js.map +1 -1
- package/lib/cjs/feature/latex/index.js +41 -3
- package/lib/cjs/feature/latex/index.js.map +1 -1
- package/lib/cjs/feature/placeholder/index.js.map +1 -1
- package/lib/cjs/feature/toolbar/index.js +213 -160
- package/lib/cjs/feature/toolbar/index.js.map +1 -1
- package/lib/cjs/index.js +408 -390
- package/lib/cjs/index.js.map +1 -1
- package/lib/esm/feature/block-edit/index.js +250 -231
- package/lib/esm/feature/block-edit/index.js.map +1 -1
- package/lib/esm/feature/latex/index.js +42 -4
- package/lib/esm/feature/latex/index.js.map +1 -1
- package/lib/esm/feature/placeholder/index.js.map +1 -1
- package/lib/esm/feature/toolbar/index.js +217 -164
- package/lib/esm/feature/toolbar/index.js.map +1 -1
- package/lib/esm/index.js +414 -396
- package/lib/esm/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/feature/block-edit/index.d.ts +78 -38
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/config.d.ts +3 -2
- package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
- package/lib/types/feature/block-edit/menu/utils.d.ts +2 -24
- package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
- package/lib/types/feature/latex/command.d.ts +2 -0
- package/lib/types/feature/latex/command.d.ts.map +1 -0
- package/lib/types/feature/latex/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +1 -1
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/config.d.ts +12 -0
- package/lib/types/feature/toolbar/config.d.ts.map +1 -0
- package/lib/types/feature/toolbar/index.d.ts +3 -0
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/utils/checker.d.ts +4 -0
- package/lib/types/utils/checker.d.ts.map +1 -0
- package/lib/types/utils/group-builder.d.ts +43 -0
- package/lib/types/utils/group-builder.d.ts.map +1 -0
- package/lib/types/utils/index.d.ts +3 -3
- package/lib/types/utils/index.d.ts.map +1 -1
- package/lib/types/utils/types.d.ts +4 -0
- package/lib/types/utils/types.d.ts.map +1 -0
- package/package.json +2 -2
- package/src/feature/block-edit/index.ts +78 -38
- package/src/feature/block-edit/menu/config.ts +306 -240
- package/src/feature/block-edit/menu/utils.ts +1 -106
- package/src/feature/latex/command.ts +48 -0
- package/src/feature/latex/index.ts +2 -0
- package/src/feature/toolbar/component.tsx +44 -194
- package/src/feature/toolbar/config.ts +136 -0
- package/src/feature/toolbar/index.ts +3 -0
- package/src/utils/checker.ts +11 -0
- package/src/utils/group-builder.ts +68 -0
- package/src/utils/index.ts +3 -11
- package/src/utils/types.ts +9 -0
- package/lib/types/feature/block-edit/menu/group-builder.d.ts +0 -29
- package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +0 -1
- package/src/feature/block-edit/menu/group-builder.ts +0 -49
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { blockConfig, block, BlockProvider } from '@milkdown/kit/plugin/block';
|
|
2
2
|
import { createSlice } from '@milkdown/kit/ctx';
|
|
3
|
-
import { editorViewCtx } from '@milkdown/kit/core';
|
|
4
|
-
import { paragraphSchema, headingSchema, blockquoteSchema, hrSchema, bulletListSchema, orderedListSchema, listItemSchema, codeBlockSchema } from '@milkdown/kit/preset/commonmark';
|
|
3
|
+
import { commandsCtx, editorViewCtx } from '@milkdown/kit/core';
|
|
4
|
+
import { paragraphSchema, clearTextInCurrentBlockCommand, setBlockTypeCommand, headingSchema, blockquoteSchema, wrapInBlockTypeCommand, hrSchema, addBlockTypeCommand, bulletListSchema, orderedListSchema, listItemSchema, codeBlockSchema, selectTextNearPosCommand } from '@milkdown/kit/preset/commonmark';
|
|
5
5
|
import { findParent } from '@milkdown/kit/prose';
|
|
6
6
|
import { TextSelection } from '@milkdown/kit/prose/state';
|
|
7
7
|
import { defineComponent, ref, computed, watch, watchEffect, onUnmounted, h, createApp, Fragment } from 'vue';
|
|
@@ -10,7 +10,6 @@ import { $ctx } from '@milkdown/kit/utils';
|
|
|
10
10
|
import { Icon } from '@milkdown/kit/component';
|
|
11
11
|
import { imageBlockSchema } from '@milkdown/kit/component/image-block';
|
|
12
12
|
import { createTable } from '@milkdown/kit/preset/gfm';
|
|
13
|
-
import { findWrapping } from '@milkdown/kit/prose/transform';
|
|
14
13
|
|
|
15
14
|
createSlice([], "FeaturesCtx");
|
|
16
15
|
createSlice({}, "CrepeCtx");
|
|
@@ -420,7 +419,7 @@ class GroupBuilder {
|
|
|
420
419
|
const groupInstance = {
|
|
421
420
|
group,
|
|
422
421
|
addItem: (key, item) => {
|
|
423
|
-
const data = {
|
|
422
|
+
const data = { ...item, key };
|
|
424
423
|
group.items.push(data);
|
|
425
424
|
return groupInstance;
|
|
426
425
|
},
|
|
@@ -454,260 +453,280 @@ class GroupBuilder {
|
|
|
454
453
|
_groups = new WeakMap();
|
|
455
454
|
_getGroupInstance = new WeakMap();
|
|
456
455
|
|
|
457
|
-
function clearRange(tr) {
|
|
458
|
-
const { $from, $to } = tr.selection;
|
|
459
|
-
const { pos: from } = $from;
|
|
460
|
-
const { pos: to } = $to;
|
|
461
|
-
tr = tr.deleteRange(from - $from.node().content.size, to);
|
|
462
|
-
return tr;
|
|
463
|
-
}
|
|
464
|
-
function setBlockType(tr, nodeType, attrs = null) {
|
|
465
|
-
const { from, to } = tr.selection;
|
|
466
|
-
return tr.setBlockType(from, to, nodeType, attrs);
|
|
467
|
-
}
|
|
468
|
-
function wrapInBlockType(tr, nodeType, attrs = null) {
|
|
469
|
-
const { $from, $to } = tr.selection;
|
|
470
|
-
const range = $from.blockRange($to);
|
|
471
|
-
const wrapping = range && findWrapping(range, nodeType, attrs);
|
|
472
|
-
if (!wrapping) return null;
|
|
473
|
-
return tr.wrap(range, wrapping);
|
|
474
|
-
}
|
|
475
|
-
function addBlockType(tr, nodeType, attrs = null) {
|
|
476
|
-
const node = nodeType.createAndFill(attrs);
|
|
477
|
-
if (!node) return null;
|
|
478
|
-
return tr.replaceSelectionWith(node);
|
|
479
|
-
}
|
|
480
|
-
function clearContentAndSetBlockType(nodeType, attrs = null) {
|
|
481
|
-
return (state, dispatch) => {
|
|
482
|
-
if (dispatch) {
|
|
483
|
-
const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
|
|
484
|
-
dispatch(tr.scrollIntoView());
|
|
485
|
-
}
|
|
486
|
-
return true;
|
|
487
|
-
};
|
|
488
|
-
}
|
|
489
|
-
function clearContentAndWrapInBlockType(nodeType, attrs = null) {
|
|
490
|
-
return (state, dispatch) => {
|
|
491
|
-
const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
|
|
492
|
-
if (!tr) return false;
|
|
493
|
-
if (dispatch) dispatch(tr.scrollIntoView());
|
|
494
|
-
return true;
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
function clearContentAndAddBlockType(nodeType, attrs = null) {
|
|
498
|
-
return (state, dispatch) => {
|
|
499
|
-
const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
|
|
500
|
-
if (!tr) return false;
|
|
501
|
-
if (dispatch) dispatch(tr.scrollIntoView());
|
|
502
|
-
return true;
|
|
503
|
-
};
|
|
504
|
-
}
|
|
505
|
-
|
|
506
456
|
function getGroups(filter, config, ctx) {
|
|
507
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J;
|
|
457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la, _ma, _na, _oa, _pa, _qa, _ra, _sa, _ta, _ua, _va, _wa, _xa, _ya, _za, _Aa, _Ba, _Ca, _Da, _Ea, _Fa, _Ga, _Ha, _Ia, _Ja, _Ka, _La, _Ma, _Na, _Oa, _Pa, _Qa, _Ra, _Sa, _Ta, _Ua, _Va, _Wa, _Xa, _Ya, _Za, __a, _$a, _ab, _bb, _cb, _db, _eb, _fb, _gb, _hb, _ib, _jb, _kb;
|
|
508
458
|
const flags = ctx && useCrepeFeatures(ctx).get();
|
|
509
459
|
const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
|
|
510
460
|
const isImageBlockEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.ImageBlock);
|
|
511
461
|
const isTableEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Table);
|
|
512
462
|
const groupBuilder = new GroupBuilder();
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
463
|
+
if ((config == null ? void 0 : config.textGroup) !== null) {
|
|
464
|
+
const textGroup = groupBuilder.addGroup(
|
|
465
|
+
"text",
|
|
466
|
+
(_b = (_a = config == null ? void 0 : config.textGroup) == null ? void 0 : _a.label) != null ? _b : "Text"
|
|
467
|
+
);
|
|
468
|
+
if (((_c = config == null ? void 0 : config.textGroup) == null ? void 0 : _c.text) !== null) {
|
|
469
|
+
textGroup.addItem("text", {
|
|
470
|
+
label: (_f = (_e = (_d = config == null ? void 0 : config.textGroup) == null ? void 0 : _d.text) == null ? void 0 : _e.label) != null ? _f : "Text",
|
|
471
|
+
icon: (_i = (_h = (_g = config == null ? void 0 : config.textGroup) == null ? void 0 : _g.text) == null ? void 0 : _h.icon) != null ? _i : textIcon,
|
|
472
|
+
onRun: (ctx2) => {
|
|
473
|
+
const commands = ctx2.get(commandsCtx);
|
|
474
|
+
const paragraph = paragraphSchema.type(ctx2);
|
|
475
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
476
|
+
commands.call(setBlockTypeCommand.key, {
|
|
477
|
+
nodeType: paragraph
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
});
|
|
521
481
|
}
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
482
|
+
if (((_j = config == null ? void 0 : config.textGroup) == null ? void 0 : _j.h1) !== null) {
|
|
483
|
+
textGroup.addItem("h1", {
|
|
484
|
+
label: (_m = (_l = (_k = config == null ? void 0 : config.textGroup) == null ? void 0 : _k.h1) == null ? void 0 : _l.label) != null ? _m : "Heading 1",
|
|
485
|
+
icon: (_p = (_o = (_n = config == null ? void 0 : config.textGroup) == null ? void 0 : _n.h1) == null ? void 0 : _o.icon) != null ? _p : h1Icon,
|
|
486
|
+
onRun: (ctx2) => {
|
|
487
|
+
const commands = ctx2.get(commandsCtx);
|
|
488
|
+
const heading = headingSchema.type(ctx2);
|
|
489
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
490
|
+
commands.call(setBlockTypeCommand.key, {
|
|
491
|
+
nodeType: heading,
|
|
492
|
+
attrs: {
|
|
493
|
+
level: 1
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
}
|
|
530
497
|
});
|
|
531
|
-
command(state, dispatch);
|
|
532
498
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
499
|
+
if (((_q = config == null ? void 0 : config.textGroup) == null ? void 0 : _q.h2) !== null) {
|
|
500
|
+
textGroup.addItem("h2", {
|
|
501
|
+
label: (_t = (_s = (_r = config == null ? void 0 : config.textGroup) == null ? void 0 : _r.h2) == null ? void 0 : _s.label) != null ? _t : "Heading 2",
|
|
502
|
+
icon: (_w = (_v = (_u = config == null ? void 0 : config.textGroup) == null ? void 0 : _u.h2) == null ? void 0 : _v.icon) != null ? _w : h2Icon,
|
|
503
|
+
onRun: (ctx2) => {
|
|
504
|
+
const commands = ctx2.get(commandsCtx);
|
|
505
|
+
const heading = headingSchema.type(ctx2);
|
|
506
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
507
|
+
commands.call(setBlockTypeCommand.key, {
|
|
508
|
+
nodeType: heading,
|
|
509
|
+
attrs: {
|
|
510
|
+
level: 2
|
|
511
|
+
}
|
|
512
|
+
});
|
|
513
|
+
}
|
|
541
514
|
});
|
|
542
|
-
command(state, dispatch);
|
|
543
515
|
}
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
516
|
+
if (((_x = config == null ? void 0 : config.textGroup) == null ? void 0 : _x.h3) !== null) {
|
|
517
|
+
textGroup.addItem("h3", {
|
|
518
|
+
label: (_A = (_z = (_y = config == null ? void 0 : config.textGroup) == null ? void 0 : _y.h3) == null ? void 0 : _z.label) != null ? _A : "Heading 3",
|
|
519
|
+
icon: (_D = (_C = (_B = config == null ? void 0 : config.textGroup) == null ? void 0 : _B.h3) == null ? void 0 : _C.icon) != null ? _D : h3Icon,
|
|
520
|
+
onRun: (ctx2) => {
|
|
521
|
+
const commands = ctx2.get(commandsCtx);
|
|
522
|
+
const heading = headingSchema.type(ctx2);
|
|
523
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
524
|
+
commands.call(setBlockTypeCommand.key, {
|
|
525
|
+
nodeType: heading,
|
|
526
|
+
attrs: {
|
|
527
|
+
level: 3
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
552
531
|
});
|
|
553
|
-
command(state, dispatch);
|
|
554
532
|
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
533
|
+
if (((_E = config == null ? void 0 : config.textGroup) == null ? void 0 : _E.h4) !== null) {
|
|
534
|
+
textGroup.addItem("h4", {
|
|
535
|
+
label: (_H = (_G = (_F = config == null ? void 0 : config.textGroup) == null ? void 0 : _F.h4) == null ? void 0 : _G.label) != null ? _H : "Heading 4",
|
|
536
|
+
icon: (_K = (_J = (_I = config == null ? void 0 : config.textGroup) == null ? void 0 : _I.h4) == null ? void 0 : _J.icon) != null ? _K : h4Icon,
|
|
537
|
+
onRun: (ctx2) => {
|
|
538
|
+
const commands = ctx2.get(commandsCtx);
|
|
539
|
+
const heading = headingSchema.type(ctx2);
|
|
540
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
541
|
+
commands.call(setBlockTypeCommand.key, {
|
|
542
|
+
nodeType: heading,
|
|
543
|
+
attrs: {
|
|
544
|
+
level: 4
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
563
548
|
});
|
|
564
|
-
command(state, dispatch);
|
|
565
549
|
}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
550
|
+
if (((_L = config == null ? void 0 : config.textGroup) == null ? void 0 : _L.h5) !== null) {
|
|
551
|
+
textGroup.addItem("h5", {
|
|
552
|
+
label: (_O = (_N = (_M = config == null ? void 0 : config.textGroup) == null ? void 0 : _M.h5) == null ? void 0 : _N.label) != null ? _O : "Heading 5",
|
|
553
|
+
icon: (_R = (_Q = (_P = config == null ? void 0 : config.textGroup) == null ? void 0 : _P.h5) == null ? void 0 : _Q.icon) != null ? _R : h5Icon,
|
|
554
|
+
onRun: (ctx2) => {
|
|
555
|
+
const commands = ctx2.get(commandsCtx);
|
|
556
|
+
const heading = headingSchema.type(ctx2);
|
|
557
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
558
|
+
commands.call(setBlockTypeCommand.key, {
|
|
559
|
+
nodeType: heading,
|
|
560
|
+
attrs: {
|
|
561
|
+
level: 5
|
|
562
|
+
}
|
|
563
|
+
});
|
|
564
|
+
}
|
|
574
565
|
});
|
|
575
|
-
command(state, dispatch);
|
|
576
566
|
}
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
567
|
+
if (((_S = config == null ? void 0 : config.textGroup) == null ? void 0 : _S.h6) !== null) {
|
|
568
|
+
textGroup.addItem("h6", {
|
|
569
|
+
label: (_V = (_U = (_T = config == null ? void 0 : config.textGroup) == null ? void 0 : _T.h6) == null ? void 0 : _U.label) != null ? _V : "Heading 6",
|
|
570
|
+
icon: (_Y = (_X = (_W = config == null ? void 0 : config.textGroup) == null ? void 0 : _W.h6) == null ? void 0 : _X.icon) != null ? _Y : h6Icon,
|
|
571
|
+
onRun: (ctx2) => {
|
|
572
|
+
const commands = ctx2.get(commandsCtx);
|
|
573
|
+
const heading = headingSchema.type(ctx2);
|
|
574
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
575
|
+
commands.call(setBlockTypeCommand.key, {
|
|
576
|
+
nodeType: heading,
|
|
577
|
+
attrs: {
|
|
578
|
+
level: 6
|
|
579
|
+
}
|
|
580
|
+
});
|
|
581
|
+
}
|
|
585
582
|
});
|
|
586
|
-
command(state, dispatch);
|
|
587
583
|
}
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
584
|
+
if (((_Z = config == null ? void 0 : config.textGroup) == null ? void 0 : _Z.quote) !== null) {
|
|
585
|
+
textGroup.addItem("quote", {
|
|
586
|
+
label: (_aa = (_$ = (__ = config == null ? void 0 : config.textGroup) == null ? void 0 : __.quote) == null ? void 0 : _$.label) != null ? _aa : "Quote",
|
|
587
|
+
icon: (_da = (_ca = (_ba = config == null ? void 0 : config.textGroup) == null ? void 0 : _ba.quote) == null ? void 0 : _ca.icon) != null ? _da : quoteIcon,
|
|
588
|
+
onRun: (ctx2) => {
|
|
589
|
+
const commands = ctx2.get(commandsCtx);
|
|
590
|
+
const blockquote = blockquoteSchema.type(ctx2);
|
|
591
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
592
|
+
commands.call(wrapInBlockTypeCommand.key, {
|
|
593
|
+
nodeType: blockquote
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
});
|
|
598
597
|
}
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
598
|
+
if (((_ea = config == null ? void 0 : config.textGroup) == null ? void 0 : _ea.divider) !== null) {
|
|
599
|
+
textGroup.addItem("divider", {
|
|
600
|
+
label: (_ha = (_ga = (_fa = config == null ? void 0 : config.textGroup) == null ? void 0 : _fa.divider) == null ? void 0 : _ga.label) != null ? _ha : "Divider",
|
|
601
|
+
icon: (_ka = (_ja = (_ia = config == null ? void 0 : config.textGroup) == null ? void 0 : _ia.divider) == null ? void 0 : _ja.icon) != null ? _ka : dividerIcon,
|
|
602
|
+
onRun: (ctx2) => {
|
|
603
|
+
const commands = ctx2.get(commandsCtx);
|
|
604
|
+
const hr = hrSchema.type(ctx2);
|
|
605
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
606
|
+
commands.call(addBlockTypeCommand.key, {
|
|
607
|
+
nodeType: hr
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
});
|
|
607
611
|
}
|
|
608
|
-
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
612
|
+
}
|
|
613
|
+
if ((config == null ? void 0 : config.listGroup) !== null) {
|
|
614
|
+
const listGroup = groupBuilder.addGroup(
|
|
615
|
+
"list",
|
|
616
|
+
(_ma = (_la = config == null ? void 0 : config.listGroup) == null ? void 0 : _la.label) != null ? _ma : "List"
|
|
617
|
+
);
|
|
618
|
+
if (((_na = config == null ? void 0 : config.listGroup) == null ? void 0 : _na.bulletList) !== null) {
|
|
619
|
+
listGroup.addItem("bullet-list", {
|
|
620
|
+
label: (_qa = (_pa = (_oa = config == null ? void 0 : config.listGroup) == null ? void 0 : _oa.bulletList) == null ? void 0 : _pa.label) != null ? _qa : "Bullet List",
|
|
621
|
+
icon: (_ta = (_sa = (_ra = config == null ? void 0 : config.listGroup) == null ? void 0 : _ra.bulletList) == null ? void 0 : _sa.icon) != null ? _ta : bulletListIcon,
|
|
622
|
+
onRun: (ctx2) => {
|
|
623
|
+
const commands = ctx2.get(commandsCtx);
|
|
624
|
+
const bulletList = bulletListSchema.type(ctx2);
|
|
625
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
626
|
+
commands.call(wrapInBlockTypeCommand.key, {
|
|
627
|
+
nodeType: bulletList
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
});
|
|
619
631
|
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
632
|
+
if (((_ua = config == null ? void 0 : config.listGroup) == null ? void 0 : _ua.orderedList) !== null) {
|
|
633
|
+
listGroup.addItem("ordered-list", {
|
|
634
|
+
label: (_xa = (_wa = (_va = config == null ? void 0 : config.listGroup) == null ? void 0 : _va.orderedList) == null ? void 0 : _wa.label) != null ? _xa : "Ordered List",
|
|
635
|
+
icon: (_Aa = (_za = (_ya = config == null ? void 0 : config.listGroup) == null ? void 0 : _ya.orderedList) == null ? void 0 : _za.icon) != null ? _Aa : orderedListIcon,
|
|
636
|
+
onRun: (ctx2) => {
|
|
637
|
+
const commands = ctx2.get(commandsCtx);
|
|
638
|
+
const orderedList = orderedListSchema.type(ctx2);
|
|
639
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
640
|
+
commands.call(wrapInBlockTypeCommand.key, {
|
|
641
|
+
nodeType: orderedList
|
|
642
|
+
});
|
|
643
|
+
}
|
|
644
|
+
});
|
|
630
645
|
}
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
646
|
+
if (((_Ba = config == null ? void 0 : config.listGroup) == null ? void 0 : _Ba.taskList) !== null) {
|
|
647
|
+
listGroup.addItem("task-list", {
|
|
648
|
+
label: (_Ea = (_Da = (_Ca = config == null ? void 0 : config.listGroup) == null ? void 0 : _Ca.taskList) == null ? void 0 : _Da.label) != null ? _Ea : "Task List",
|
|
649
|
+
icon: (_Ha = (_Ga = (_Fa = config == null ? void 0 : config.listGroup) == null ? void 0 : _Fa.taskList) == null ? void 0 : _Ga.icon) != null ? _Ha : todoListIcon,
|
|
650
|
+
onRun: (ctx2) => {
|
|
651
|
+
const commands = ctx2.get(commandsCtx);
|
|
652
|
+
const listItem = listItemSchema.type(ctx2);
|
|
653
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
654
|
+
commands.call(wrapInBlockTypeCommand.key, {
|
|
655
|
+
nodeType: listItem,
|
|
656
|
+
attrs: { checked: false }
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
});
|
|
642
660
|
}
|
|
643
|
-
});
|
|
644
|
-
const advancedGroup = groupBuilder.addGroup(
|
|
645
|
-
"advanced",
|
|
646
|
-
(_A = config == null ? void 0 : config.slashMenuAdvancedGroupLabel) != null ? _A : "Advanced"
|
|
647
|
-
);
|
|
648
|
-
if (isImageBlockEnabled) {
|
|
649
|
-
advancedGroup.addItem("image", {
|
|
650
|
-
label: (_B = config == null ? void 0 : config.slashMenuImageLabel) != null ? _B : "Image",
|
|
651
|
-
icon: (_C = config == null ? void 0 : config.slashMenuImageIcon) != null ? _C : imageIcon,
|
|
652
|
-
onRun: (ctx2) => {
|
|
653
|
-
const view = ctx2.get(editorViewCtx);
|
|
654
|
-
const { dispatch, state } = view;
|
|
655
|
-
const command = clearContentAndAddBlockType(imageBlockSchema.type(ctx2));
|
|
656
|
-
command(state, dispatch);
|
|
657
|
-
}
|
|
658
|
-
});
|
|
659
661
|
}
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
662
|
+
if ((config == null ? void 0 : config.advancedGroup) !== null) {
|
|
663
|
+
const advancedGroup = groupBuilder.addGroup(
|
|
664
|
+
"advanced",
|
|
665
|
+
(_Ja = (_Ia = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ia.label) != null ? _Ja : "Advanced"
|
|
666
|
+
);
|
|
667
|
+
if (((_Ka = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ka.image) !== null && isImageBlockEnabled) {
|
|
668
|
+
advancedGroup.addItem("image", {
|
|
669
|
+
label: (_Na = (_Ma = (_La = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _La.image) == null ? void 0 : _Ma.label) != null ? _Na : "Image",
|
|
670
|
+
icon: (_Qa = (_Pa = (_Oa = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Oa.image) == null ? void 0 : _Pa.icon) != null ? _Qa : imageIcon,
|
|
671
|
+
onRun: (ctx2) => {
|
|
672
|
+
const commands = ctx2.get(commandsCtx);
|
|
673
|
+
const imageBlock = imageBlockSchema.type(ctx2);
|
|
674
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
675
|
+
commands.call(addBlockTypeCommand.key, {
|
|
676
|
+
nodeType: imageBlock
|
|
677
|
+
});
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
}
|
|
681
|
+
if (((_Ra = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ra.codeBlock) !== null) {
|
|
682
|
+
advancedGroup.addItem("code", {
|
|
683
|
+
label: (_Ua = (_Ta = (_Sa = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Sa.codeBlock) == null ? void 0 : _Ta.label) != null ? _Ua : "Code",
|
|
684
|
+
icon: (_Xa = (_Wa = (_Va = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Va.codeBlock) == null ? void 0 : _Wa.icon) != null ? _Xa : codeIcon,
|
|
685
|
+
onRun: (ctx2) => {
|
|
686
|
+
const commands = ctx2.get(commandsCtx);
|
|
687
|
+
const codeBlock = codeBlockSchema.type(ctx2);
|
|
688
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
689
|
+
commands.call(setBlockTypeCommand.key, {
|
|
690
|
+
nodeType: codeBlock
|
|
691
|
+
});
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
if (((_Ya = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ya.table) !== null && isTableEnabled) {
|
|
696
|
+
advancedGroup.addItem("table", {
|
|
697
|
+
label: (_$a = (__a = (_Za = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Za.table) == null ? void 0 : __a.label) != null ? _$a : "Table",
|
|
698
|
+
icon: (_cb = (_bb = (_ab = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _ab.table) == null ? void 0 : _bb.icon) != null ? _cb : tableIcon,
|
|
699
|
+
onRun: (ctx2) => {
|
|
700
|
+
const commands = ctx2.get(commandsCtx);
|
|
701
|
+
const view = ctx2.get(editorViewCtx);
|
|
702
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
703
|
+
const { from } = view.state.selection;
|
|
704
|
+
commands.call(addBlockTypeCommand.key, {
|
|
705
|
+
nodeType: createTable(ctx2, 3, 3)
|
|
706
|
+
});
|
|
707
|
+
commands.call(selectTextNearPosCommand.key, {
|
|
708
|
+
pos: from
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
if (((_db = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _db.math) !== null && isLatexEnabled) {
|
|
714
|
+
advancedGroup.addItem("math", {
|
|
715
|
+
label: (_gb = (_fb = (_eb = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _eb.math) == null ? void 0 : _fb.label) != null ? _gb : "Math",
|
|
716
|
+
icon: (_jb = (_ib = (_hb = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _hb.math) == null ? void 0 : _ib.icon) != null ? _jb : functionsIcon,
|
|
717
|
+
onRun: (ctx2) => {
|
|
718
|
+
const commands = ctx2.get(commandsCtx);
|
|
719
|
+
const codeBlock = codeBlockSchema.type(ctx2);
|
|
720
|
+
commands.call(clearTextInCurrentBlockCommand.key);
|
|
721
|
+
commands.call(addBlockTypeCommand.key, {
|
|
722
|
+
nodeType: codeBlock,
|
|
723
|
+
attrs: { language: "LaTex" }
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
});
|
|
668
727
|
}
|
|
669
|
-
});
|
|
670
|
-
if (isTableEnabled) {
|
|
671
|
-
advancedGroup.addItem("table", {
|
|
672
|
-
label: (_F = config == null ? void 0 : config.slashMenuTableLabel) != null ? _F : "Table",
|
|
673
|
-
icon: (_G = config == null ? void 0 : config.slashMenuTableIcon) != null ? _G : tableIcon,
|
|
674
|
-
onRun: (ctx2) => {
|
|
675
|
-
const view = ctx2.get(editorViewCtx);
|
|
676
|
-
const { dispatch, state } = view;
|
|
677
|
-
let { tr } = state;
|
|
678
|
-
tr = clearRange(tr);
|
|
679
|
-
const from = tr.selection.from;
|
|
680
|
-
const table = createTable(ctx2, 3, 3);
|
|
681
|
-
tr = tr.replaceSelectionWith(table);
|
|
682
|
-
dispatch(tr);
|
|
683
|
-
requestAnimationFrame(() => {
|
|
684
|
-
const docSize = view.state.doc.content.size;
|
|
685
|
-
const $pos = view.state.doc.resolve(
|
|
686
|
-
from > docSize ? docSize : from < 0 ? 0 : from
|
|
687
|
-
);
|
|
688
|
-
const selection = TextSelection.near($pos);
|
|
689
|
-
const tr2 = view.state.tr;
|
|
690
|
-
tr2.setSelection(selection);
|
|
691
|
-
dispatch(tr2.scrollIntoView());
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
});
|
|
695
|
-
}
|
|
696
|
-
if (isLatexEnabled) {
|
|
697
|
-
advancedGroup.addItem("math", {
|
|
698
|
-
label: (_H = config == null ? void 0 : config.slashMenuMathLabel) != null ? _H : "Math",
|
|
699
|
-
icon: (_I = config == null ? void 0 : config.slashMenuMathIcon) != null ? _I : functionsIcon,
|
|
700
|
-
onRun: (ctx2) => {
|
|
701
|
-
const view = ctx2.get(editorViewCtx);
|
|
702
|
-
const { dispatch, state } = view;
|
|
703
|
-
const command = clearContentAndAddBlockType(codeBlockSchema.type(ctx2), {
|
|
704
|
-
language: "LaTex"
|
|
705
|
-
});
|
|
706
|
-
command(state, dispatch);
|
|
707
|
-
}
|
|
708
|
-
});
|
|
709
728
|
}
|
|
710
|
-
(
|
|
729
|
+
(_kb = config == null ? void 0 : config.buildMenu) == null ? void 0 : _kb.call(config, groupBuilder);
|
|
711
730
|
let groups = groupBuilder.build();
|
|
712
731
|
if (filter) {
|
|
713
732
|
groups = groups.map((group) => {
|