@milkdown/crepe 7.12.0 → 7.13.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.
Files changed (66) hide show
  1. package/lib/cjs/builder.js.map +1 -0
  2. package/lib/cjs/feature/block-edit/index.js +248 -229
  3. package/lib/cjs/feature/block-edit/index.js.map +1 -1
  4. package/lib/cjs/feature/latex/index.js +41 -3
  5. package/lib/cjs/feature/latex/index.js.map +1 -1
  6. package/lib/cjs/feature/placeholder/index.js.map +1 -1
  7. package/lib/cjs/feature/toolbar/index.js +213 -160
  8. package/lib/cjs/feature/toolbar/index.js.map +1 -1
  9. package/lib/cjs/{index/index.js → index.js} +408 -390
  10. package/lib/cjs/index.js.map +1 -0
  11. package/lib/esm/builder.js.map +1 -0
  12. package/lib/esm/feature/block-edit/index.js +250 -231
  13. package/lib/esm/feature/block-edit/index.js.map +1 -1
  14. package/lib/esm/feature/latex/index.js +42 -4
  15. package/lib/esm/feature/latex/index.js.map +1 -1
  16. package/lib/esm/feature/placeholder/index.js.map +1 -1
  17. package/lib/esm/feature/toolbar/index.js +217 -164
  18. package/lib/esm/feature/toolbar/index.js.map +1 -1
  19. package/lib/esm/{index/index.js → index.js} +414 -396
  20. package/lib/esm/index.js.map +1 -0
  21. package/lib/tsconfig.tsbuildinfo +1 -1
  22. package/lib/types/feature/block-edit/index.d.ts +78 -38
  23. package/lib/types/feature/block-edit/index.d.ts.map +1 -1
  24. package/lib/types/feature/block-edit/menu/config.d.ts +3 -2
  25. package/lib/types/feature/block-edit/menu/config.d.ts.map +1 -1
  26. package/lib/types/feature/block-edit/menu/utils.d.ts +2 -24
  27. package/lib/types/feature/block-edit/menu/utils.d.ts.map +1 -1
  28. package/lib/types/feature/latex/command.d.ts +2 -0
  29. package/lib/types/feature/latex/command.d.ts.map +1 -0
  30. package/lib/types/feature/latex/index.d.ts.map +1 -1
  31. package/lib/types/feature/toolbar/component.d.ts +1 -1
  32. package/lib/types/feature/toolbar/component.d.ts.map +1 -1
  33. package/lib/types/feature/toolbar/config.d.ts +12 -0
  34. package/lib/types/feature/toolbar/config.d.ts.map +1 -0
  35. package/lib/types/feature/toolbar/index.d.ts +3 -0
  36. package/lib/types/feature/toolbar/index.d.ts.map +1 -1
  37. package/lib/types/utils/checker.d.ts +4 -0
  38. package/lib/types/utils/checker.d.ts.map +1 -0
  39. package/lib/types/utils/group-builder.d.ts +43 -0
  40. package/lib/types/utils/group-builder.d.ts.map +1 -0
  41. package/lib/types/utils/index.d.ts +3 -3
  42. package/lib/types/utils/index.d.ts.map +1 -1
  43. package/lib/types/utils/types.d.ts +4 -0
  44. package/lib/types/utils/types.d.ts.map +1 -0
  45. package/package.json +2 -2
  46. package/src/feature/block-edit/index.ts +78 -38
  47. package/src/feature/block-edit/menu/config.ts +306 -240
  48. package/src/feature/block-edit/menu/utils.ts +1 -106
  49. package/src/feature/latex/command.ts +48 -0
  50. package/src/feature/latex/index.ts +2 -0
  51. package/src/feature/toolbar/component.tsx +44 -194
  52. package/src/feature/toolbar/config.ts +136 -0
  53. package/src/feature/toolbar/index.ts +3 -0
  54. package/src/utils/checker.ts +11 -0
  55. package/src/utils/group-builder.ts +68 -0
  56. package/src/utils/index.ts +3 -11
  57. package/src/utils/types.ts +9 -0
  58. package/lib/cjs/builder/builder.js.map +0 -1
  59. package/lib/cjs/index/index.js.map +0 -1
  60. package/lib/esm/builder/builder.js.map +0 -1
  61. package/lib/esm/index/index.js.map +0 -1
  62. package/lib/types/feature/block-edit/menu/group-builder.d.ts +0 -29
  63. package/lib/types/feature/block-edit/menu/group-builder.d.ts.map +0 -1
  64. package/src/feature/block-edit/menu/group-builder.ts +0 -49
  65. /package/lib/cjs/{builder/builder.js → builder.js} +0 -0
  66. /package/lib/esm/{builder/builder.js → builder.js} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.js","sources":["../../src/core/slice.ts","../../src/core/builder.ts"],"sourcesContent":["import { createSlice, type Ctx } from '@milkdown/kit/ctx'\n\nimport type { CrepeFeature } from '../feature'\nimport type { CrepeBuilder } from './builder'\n\n/// @internal\n/// The feature flags context.\n/// ⚠️ Most of the time, you should use `useCrepeFeatures` to get the features.\nexport const FeaturesCtx = createSlice([] as CrepeFeature[], 'FeaturesCtx')\n\n/// @internal\n/// The crepe editor context.\n/// ⚠️ Most of the time, you should use `useCrepe` to get the crepe editor instance.\nexport const CrepeCtx = createSlice({} as CrepeBuilder, 'CrepeCtx')\n\n/// The crepe editor context.\n/// You can use this context to access the crepe editor instance within Milkdown plugins.\n/// ```ts\n/// import { crepeCtx } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// return () => {\n/// const crepe = useCrepe(ctx)\n/// crepe.setReadonly(true)\n/// }\n/// }\n/// ```\nexport function useCrepe(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.get<CrepeBuilder, 'CrepeCtx'>('CrepeCtx')\n}\n\n/// Check the enabled FeatureFlags\n/// ```ts\n/// import { useCrepeFeatures } from '@milkdown/crepe'\n/// const plugin = (ctx: Ctx) => {\n/// const features = useCrepeFeatures(ctx)\n/// if (features.get().includes(CrepeFeature.CodeMirror)) {\n/// // Do something with CodeMirror\n/// }\n/// }\nexport function useCrepeFeatures(ctx: Ctx) {\n // We should use string slice here to avoid the slice to be bundled in multiple entries\n return ctx.use<CrepeFeature[], 'FeaturesCtx'>('FeaturesCtx')\n}\n\n/// @internal\nexport function crepeFeatureConfig(feature: CrepeFeature) {\n return (ctx: Ctx) => {\n useCrepeFeatures(ctx).update((features) => {\n if (features.includes(feature)) {\n return features\n }\n return [...features, feature]\n })\n }\n}\n","import {\n type DefaultValue,\n defaultValueCtx,\n Editor,\n EditorStatus,\n editorViewCtx,\n editorViewOptionsCtx,\n rootCtx,\n} from '@milkdown/kit/core'\nimport { clipboard } from '@milkdown/kit/plugin/clipboard'\nimport { history } from '@milkdown/kit/plugin/history'\nimport { indent, indentConfig } from '@milkdown/kit/plugin/indent'\nimport {\n listener,\n listenerCtx,\n type ListenerManager,\n} from '@milkdown/kit/plugin/listener'\nimport { trailing } from '@milkdown/kit/plugin/trailing'\nimport { commonmark } from '@milkdown/kit/preset/commonmark'\nimport { gfm } from '@milkdown/kit/preset/gfm'\nimport { getMarkdown } from '@milkdown/kit/utils'\n\nimport type { CrepeFeature, CrepeFeatureConfig } from '../feature'\nimport type { DefineFeature } from '../feature/shared'\n\nimport { CrepeCtx, FeaturesCtx } from './slice'\n\n/// The crepe builder configuration.\nexport interface CrepeBuilderConfig {\n /// The root element for the editor.\n /// Supports both DOM nodes and CSS selectors,\n /// If not provided, the editor will be appended to the body.\n root?: Node | string | null\n\n /// The default value for the editor.\n defaultValue?: DefaultValue\n}\n\n/// The crepe builder class.\n/// This class allows users to manually add features to the editor.\nexport class CrepeBuilder {\n /// @internal\n readonly #editor: Editor\n\n /// @internal\n readonly #rootElement: Node\n\n /// @internal\n #editable = true\n\n /// The constructor of the crepe builder.\n /// You can pass configs to the builder to configure the editor.\n constructor({ root, defaultValue = '' }: CrepeBuilderConfig) {\n this.#rootElement =\n (typeof root === 'string' ? document.querySelector(root) : root) ??\n document.body\n this.#editor = Editor.make()\n .config((ctx) => {\n ctx.inject(CrepeCtx, this)\n ctx.inject(FeaturesCtx, [])\n })\n .config((ctx) => {\n ctx.set(rootCtx, this.#rootElement)\n ctx.set(defaultValueCtx, defaultValue)\n ctx.set(editorViewOptionsCtx, {\n editable: () => this.#editable,\n })\n ctx.update(indentConfig.key, (value) => ({\n ...value,\n size: 4,\n }))\n })\n .use(commonmark)\n .use(listener)\n .use(history)\n .use(indent)\n .use(trailing)\n .use(clipboard)\n .use(gfm)\n }\n\n /// Add a feature to the editor.\n addFeature: {\n <T extends CrepeFeature>(\n feature: DefineFeature<CrepeFeatureConfig[T]>,\n config?: CrepeFeatureConfig[T]\n ): CrepeBuilder\n <C>(feature: DefineFeature<C>, config?: C): CrepeBuilder\n } = (feature: DefineFeature, config?: never) => {\n feature(this.#editor, config)\n return this\n }\n\n /// Create the editor.\n create = () => {\n return this.#editor.create()\n }\n\n /// Destroy the editor.\n destroy = () => {\n return this.#editor.destroy()\n }\n\n /// Get the milkdown editor instance.\n get editor(): Editor {\n return this.#editor\n }\n\n /// Set the readonly mode of the editor.\n setReadonly = (value: boolean) => {\n this.#editable = !value\n this.#editor.action((ctx) => {\n if (this.#editor.status === EditorStatus.Created) {\n const view = ctx.get(editorViewCtx)\n view.setProps({\n editable: () => !value,\n })\n }\n })\n return this\n }\n\n /// Get the markdown content of the editor.\n getMarkdown = () => {\n return this.#editor.action(getMarkdown())\n }\n\n /// Register event listeners.\n on = (fn: (api: ListenerManager) => void) => {\n if (this.#editor.status !== EditorStatus.Created) {\n this.#editor.config((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n this.#editor.action((ctx) => {\n const listener = ctx.get(listenerCtx)\n fn(listener)\n })\n return this\n }\n}\n"],"names":["createSlice","EditorStatus","editorViewCtx","getMarkdown","listener","listenerCtx","Editor","rootCtx","defaultValueCtx","editorViewOptionsCtx","indentConfig","commonmark","history","indent","trailing","clipboard","gfm"],"mappings":"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"}
@@ -12,7 +12,6 @@ var utils = require('@milkdown/kit/utils');
12
12
  var component = require('@milkdown/kit/component');
13
13
  var imageBlock = require('@milkdown/kit/component/image-block');
14
14
  var gfm = require('@milkdown/kit/preset/gfm');
15
- var transform = require('@milkdown/kit/prose/transform');
16
15
 
17
16
  ctx.createSlice([], "FeaturesCtx");
18
17
  ctx.createSlice({}, "CrepeCtx");
@@ -422,7 +421,7 @@ class GroupBuilder {
422
421
  const groupInstance = {
423
422
  group,
424
423
  addItem: (key, item) => {
425
- const data = { key, ...item };
424
+ const data = { ...item, key };
426
425
  group.items.push(data);
427
426
  return groupInstance;
428
427
  },
@@ -456,260 +455,280 @@ class GroupBuilder {
456
455
  _groups = new WeakMap();
457
456
  _getGroupInstance = new WeakMap();
458
457
 
459
- function clearRange(tr) {
460
- const { $from, $to } = tr.selection;
461
- const { pos: from } = $from;
462
- const { pos: to } = $to;
463
- tr = tr.deleteRange(from - $from.node().content.size, to);
464
- return tr;
465
- }
466
- function setBlockType(tr, nodeType, attrs = null) {
467
- const { from, to } = tr.selection;
468
- return tr.setBlockType(from, to, nodeType, attrs);
469
- }
470
- function wrapInBlockType(tr, nodeType, attrs = null) {
471
- const { $from, $to } = tr.selection;
472
- const range = $from.blockRange($to);
473
- const wrapping = range && transform.findWrapping(range, nodeType, attrs);
474
- if (!wrapping) return null;
475
- return tr.wrap(range, wrapping);
476
- }
477
- function addBlockType(tr, nodeType, attrs = null) {
478
- const node = nodeType.createAndFill(attrs);
479
- if (!node) return null;
480
- return tr.replaceSelectionWith(node);
481
- }
482
- function clearContentAndSetBlockType(nodeType, attrs = null) {
483
- return (state, dispatch) => {
484
- if (dispatch) {
485
- const tr = setBlockType(clearRange(state.tr), nodeType, attrs);
486
- dispatch(tr.scrollIntoView());
487
- }
488
- return true;
489
- };
490
- }
491
- function clearContentAndWrapInBlockType(nodeType, attrs = null) {
492
- return (state, dispatch) => {
493
- const tr = wrapInBlockType(clearRange(state.tr), nodeType, attrs);
494
- if (!tr) return false;
495
- if (dispatch) dispatch(tr.scrollIntoView());
496
- return true;
497
- };
498
- }
499
- function clearContentAndAddBlockType(nodeType, attrs = null) {
500
- return (state, dispatch) => {
501
- const tr = addBlockType(clearRange(state.tr), nodeType, attrs);
502
- if (!tr) return false;
503
- if (dispatch) dispatch(tr.scrollIntoView());
504
- return true;
505
- };
506
- }
507
-
508
458
  function getGroups(filter, config, ctx) {
509
- 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;
459
+ 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;
510
460
  const flags = ctx && useCrepeFeatures(ctx).get();
511
461
  const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
512
462
  const isImageBlockEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.ImageBlock);
513
463
  const isTableEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Table);
514
464
  const groupBuilder = new GroupBuilder();
515
- groupBuilder.addGroup("text", (_a = config == null ? void 0 : config.slashMenuTextGroupLabel) != null ? _a : "Text").addItem("text", {
516
- label: (_b = config == null ? void 0 : config.slashMenuTextLabel) != null ? _b : "Text",
517
- icon: (_c = config == null ? void 0 : config.slashMenuTextIcon) != null ? _c : textIcon,
518
- onRun: (ctx2) => {
519
- const view = ctx2.get(core.editorViewCtx);
520
- const { dispatch, state } = view;
521
- const command = clearContentAndSetBlockType(commonmark.paragraphSchema.type(ctx2));
522
- command(state, dispatch);
465
+ if ((config == null ? void 0 : config.textGroup) !== null) {
466
+ const textGroup = groupBuilder.addGroup(
467
+ "text",
468
+ (_b = (_a = config == null ? void 0 : config.textGroup) == null ? void 0 : _a.label) != null ? _b : "Text"
469
+ );
470
+ if (((_c = config == null ? void 0 : config.textGroup) == null ? void 0 : _c.text) !== null) {
471
+ textGroup.addItem("text", {
472
+ label: (_f = (_e = (_d = config == null ? void 0 : config.textGroup) == null ? void 0 : _d.text) == null ? void 0 : _e.label) != null ? _f : "Text",
473
+ icon: (_i = (_h = (_g = config == null ? void 0 : config.textGroup) == null ? void 0 : _g.text) == null ? void 0 : _h.icon) != null ? _i : textIcon,
474
+ onRun: (ctx2) => {
475
+ const commands = ctx2.get(core.commandsCtx);
476
+ const paragraph = commonmark.paragraphSchema.type(ctx2);
477
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
478
+ commands.call(commonmark.setBlockTypeCommand.key, {
479
+ nodeType: paragraph
480
+ });
481
+ }
482
+ });
523
483
  }
524
- }).addItem("h1", {
525
- label: (_d = config == null ? void 0 : config.slashMenuH1Label) != null ? _d : "Heading 1",
526
- icon: (_e = config == null ? void 0 : config.slashMenuH1Icon) != null ? _e : h1Icon,
527
- onRun: (ctx2) => {
528
- const view = ctx2.get(core.editorViewCtx);
529
- const { dispatch, state } = view;
530
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
531
- level: 1
484
+ if (((_j = config == null ? void 0 : config.textGroup) == null ? void 0 : _j.h1) !== null) {
485
+ textGroup.addItem("h1", {
486
+ label: (_m = (_l = (_k = config == null ? void 0 : config.textGroup) == null ? void 0 : _k.h1) == null ? void 0 : _l.label) != null ? _m : "Heading 1",
487
+ icon: (_p = (_o = (_n = config == null ? void 0 : config.textGroup) == null ? void 0 : _n.h1) == null ? void 0 : _o.icon) != null ? _p : h1Icon,
488
+ onRun: (ctx2) => {
489
+ const commands = ctx2.get(core.commandsCtx);
490
+ const heading = commonmark.headingSchema.type(ctx2);
491
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
492
+ commands.call(commonmark.setBlockTypeCommand.key, {
493
+ nodeType: heading,
494
+ attrs: {
495
+ level: 1
496
+ }
497
+ });
498
+ }
532
499
  });
533
- command(state, dispatch);
534
500
  }
535
- }).addItem("h2", {
536
- label: (_f = config == null ? void 0 : config.slashMenuH2Label) != null ? _f : "Heading 2",
537
- icon: (_g = config == null ? void 0 : config.slashMenuH2Icon) != null ? _g : h2Icon,
538
- onRun: (ctx2) => {
539
- const view = ctx2.get(core.editorViewCtx);
540
- const { dispatch, state } = view;
541
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
542
- level: 2
501
+ if (((_q = config == null ? void 0 : config.textGroup) == null ? void 0 : _q.h2) !== null) {
502
+ textGroup.addItem("h2", {
503
+ label: (_t = (_s = (_r = config == null ? void 0 : config.textGroup) == null ? void 0 : _r.h2) == null ? void 0 : _s.label) != null ? _t : "Heading 2",
504
+ icon: (_w = (_v = (_u = config == null ? void 0 : config.textGroup) == null ? void 0 : _u.h2) == null ? void 0 : _v.icon) != null ? _w : h2Icon,
505
+ onRun: (ctx2) => {
506
+ const commands = ctx2.get(core.commandsCtx);
507
+ const heading = commonmark.headingSchema.type(ctx2);
508
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
509
+ commands.call(commonmark.setBlockTypeCommand.key, {
510
+ nodeType: heading,
511
+ attrs: {
512
+ level: 2
513
+ }
514
+ });
515
+ }
543
516
  });
544
- command(state, dispatch);
545
517
  }
546
- }).addItem("h3", {
547
- label: (_h = config == null ? void 0 : config.slashMenuH3Label) != null ? _h : "Heading 3",
548
- icon: (_i = config == null ? void 0 : config.slashMenuH3Icon) != null ? _i : h3Icon,
549
- onRun: (ctx2) => {
550
- const view = ctx2.get(core.editorViewCtx);
551
- const { dispatch, state } = view;
552
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
553
- level: 3
518
+ if (((_x = config == null ? void 0 : config.textGroup) == null ? void 0 : _x.h3) !== null) {
519
+ textGroup.addItem("h3", {
520
+ label: (_A = (_z = (_y = config == null ? void 0 : config.textGroup) == null ? void 0 : _y.h3) == null ? void 0 : _z.label) != null ? _A : "Heading 3",
521
+ icon: (_D = (_C = (_B = config == null ? void 0 : config.textGroup) == null ? void 0 : _B.h3) == null ? void 0 : _C.icon) != null ? _D : h3Icon,
522
+ onRun: (ctx2) => {
523
+ const commands = ctx2.get(core.commandsCtx);
524
+ const heading = commonmark.headingSchema.type(ctx2);
525
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
526
+ commands.call(commonmark.setBlockTypeCommand.key, {
527
+ nodeType: heading,
528
+ attrs: {
529
+ level: 3
530
+ }
531
+ });
532
+ }
554
533
  });
555
- command(state, dispatch);
556
534
  }
557
- }).addItem("h4", {
558
- label: (_j = config == null ? void 0 : config.slashMenuH4Label) != null ? _j : "Heading 4",
559
- icon: (_k = config == null ? void 0 : config.slashMenuH4Icon) != null ? _k : h4Icon,
560
- onRun: (ctx2) => {
561
- const view = ctx2.get(core.editorViewCtx);
562
- const { dispatch, state } = view;
563
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
564
- level: 4
535
+ if (((_E = config == null ? void 0 : config.textGroup) == null ? void 0 : _E.h4) !== null) {
536
+ textGroup.addItem("h4", {
537
+ label: (_H = (_G = (_F = config == null ? void 0 : config.textGroup) == null ? void 0 : _F.h4) == null ? void 0 : _G.label) != null ? _H : "Heading 4",
538
+ icon: (_K = (_J = (_I = config == null ? void 0 : config.textGroup) == null ? void 0 : _I.h4) == null ? void 0 : _J.icon) != null ? _K : h4Icon,
539
+ onRun: (ctx2) => {
540
+ const commands = ctx2.get(core.commandsCtx);
541
+ const heading = commonmark.headingSchema.type(ctx2);
542
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
543
+ commands.call(commonmark.setBlockTypeCommand.key, {
544
+ nodeType: heading,
545
+ attrs: {
546
+ level: 4
547
+ }
548
+ });
549
+ }
565
550
  });
566
- command(state, dispatch);
567
551
  }
568
- }).addItem("h5", {
569
- label: (_l = config == null ? void 0 : config.slashMenuH5Label) != null ? _l : "Heading 5",
570
- icon: (_m = config == null ? void 0 : config.slashMenuH5Icon) != null ? _m : h5Icon,
571
- onRun: (ctx2) => {
572
- const view = ctx2.get(core.editorViewCtx);
573
- const { dispatch, state } = view;
574
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
575
- level: 5
552
+ if (((_L = config == null ? void 0 : config.textGroup) == null ? void 0 : _L.h5) !== null) {
553
+ textGroup.addItem("h5", {
554
+ label: (_O = (_N = (_M = config == null ? void 0 : config.textGroup) == null ? void 0 : _M.h5) == null ? void 0 : _N.label) != null ? _O : "Heading 5",
555
+ icon: (_R = (_Q = (_P = config == null ? void 0 : config.textGroup) == null ? void 0 : _P.h5) == null ? void 0 : _Q.icon) != null ? _R : h5Icon,
556
+ onRun: (ctx2) => {
557
+ const commands = ctx2.get(core.commandsCtx);
558
+ const heading = commonmark.headingSchema.type(ctx2);
559
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
560
+ commands.call(commonmark.setBlockTypeCommand.key, {
561
+ nodeType: heading,
562
+ attrs: {
563
+ level: 5
564
+ }
565
+ });
566
+ }
576
567
  });
577
- command(state, dispatch);
578
568
  }
579
- }).addItem("h6", {
580
- label: (_n = config == null ? void 0 : config.slashMenuH6Label) != null ? _n : "Heading 6",
581
- icon: (_o = config == null ? void 0 : config.slashMenuH6Icon) != null ? _o : h6Icon,
582
- onRun: (ctx2) => {
583
- const view = ctx2.get(core.editorViewCtx);
584
- const { dispatch, state } = view;
585
- const command = clearContentAndSetBlockType(commonmark.headingSchema.type(ctx2), {
586
- level: 6
569
+ if (((_S = config == null ? void 0 : config.textGroup) == null ? void 0 : _S.h6) !== null) {
570
+ textGroup.addItem("h6", {
571
+ label: (_V = (_U = (_T = config == null ? void 0 : config.textGroup) == null ? void 0 : _T.h6) == null ? void 0 : _U.label) != null ? _V : "Heading 6",
572
+ icon: (_Y = (_X = (_W = config == null ? void 0 : config.textGroup) == null ? void 0 : _W.h6) == null ? void 0 : _X.icon) != null ? _Y : h6Icon,
573
+ onRun: (ctx2) => {
574
+ const commands = ctx2.get(core.commandsCtx);
575
+ const heading = commonmark.headingSchema.type(ctx2);
576
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
577
+ commands.call(commonmark.setBlockTypeCommand.key, {
578
+ nodeType: heading,
579
+ attrs: {
580
+ level: 6
581
+ }
582
+ });
583
+ }
587
584
  });
588
- command(state, dispatch);
589
585
  }
590
- }).addItem("quote", {
591
- label: (_p = config == null ? void 0 : config.slashMenuQuoteLabel) != null ? _p : "Quote",
592
- icon: (_q = config == null ? void 0 : config.slashMenuQuoteIcon) != null ? _q : quoteIcon,
593
- onRun: (ctx2) => {
594
- const view = ctx2.get(core.editorViewCtx);
595
- const { dispatch, state } = view;
596
- const command = clearContentAndWrapInBlockType(
597
- commonmark.blockquoteSchema.type(ctx2)
598
- );
599
- command(state, dispatch);
586
+ if (((_Z = config == null ? void 0 : config.textGroup) == null ? void 0 : _Z.quote) !== null) {
587
+ textGroup.addItem("quote", {
588
+ label: (_aa = (_$ = (__ = config == null ? void 0 : config.textGroup) == null ? void 0 : __.quote) == null ? void 0 : _$.label) != null ? _aa : "Quote",
589
+ icon: (_da = (_ca = (_ba = config == null ? void 0 : config.textGroup) == null ? void 0 : _ba.quote) == null ? void 0 : _ca.icon) != null ? _da : quoteIcon,
590
+ onRun: (ctx2) => {
591
+ const commands = ctx2.get(core.commandsCtx);
592
+ const blockquote = commonmark.blockquoteSchema.type(ctx2);
593
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
594
+ commands.call(commonmark.wrapInBlockTypeCommand.key, {
595
+ nodeType: blockquote
596
+ });
597
+ }
598
+ });
600
599
  }
601
- }).addItem("divider", {
602
- label: (_r = config == null ? void 0 : config.slashMenuDividerLabel) != null ? _r : "Divider",
603
- icon: (_s = config == null ? void 0 : config.slashMenuDividerIcon) != null ? _s : dividerIcon,
604
- onRun: (ctx2) => {
605
- const view = ctx2.get(core.editorViewCtx);
606
- const { dispatch, state } = view;
607
- const command = clearContentAndAddBlockType(commonmark.hrSchema.type(ctx2));
608
- command(state, dispatch);
600
+ if (((_ea = config == null ? void 0 : config.textGroup) == null ? void 0 : _ea.divider) !== null) {
601
+ textGroup.addItem("divider", {
602
+ label: (_ha = (_ga = (_fa = config == null ? void 0 : config.textGroup) == null ? void 0 : _fa.divider) == null ? void 0 : _ga.label) != null ? _ha : "Divider",
603
+ icon: (_ka = (_ja = (_ia = config == null ? void 0 : config.textGroup) == null ? void 0 : _ia.divider) == null ? void 0 : _ja.icon) != null ? _ka : dividerIcon,
604
+ onRun: (ctx2) => {
605
+ const commands = ctx2.get(core.commandsCtx);
606
+ const hr = commonmark.hrSchema.type(ctx2);
607
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
608
+ commands.call(commonmark.addBlockTypeCommand.key, {
609
+ nodeType: hr
610
+ });
611
+ }
612
+ });
609
613
  }
610
- });
611
- groupBuilder.addGroup("list", (_t = config == null ? void 0 : config.slashMenuListGroupLabel) != null ? _t : "List").addItem("bullet-list", {
612
- label: (_u = config == null ? void 0 : config.slashMenuBulletListLabel) != null ? _u : "Bullet List",
613
- icon: (_v = config == null ? void 0 : config.slashMenuBulletListIcon) != null ? _v : bulletListIcon,
614
- onRun: (ctx2) => {
615
- const view = ctx2.get(core.editorViewCtx);
616
- const { dispatch, state } = view;
617
- const command = clearContentAndWrapInBlockType(
618
- commonmark.bulletListSchema.type(ctx2)
619
- );
620
- command(state, dispatch);
614
+ }
615
+ if ((config == null ? void 0 : config.listGroup) !== null) {
616
+ const listGroup = groupBuilder.addGroup(
617
+ "list",
618
+ (_ma = (_la = config == null ? void 0 : config.listGroup) == null ? void 0 : _la.label) != null ? _ma : "List"
619
+ );
620
+ if (((_na = config == null ? void 0 : config.listGroup) == null ? void 0 : _na.bulletList) !== null) {
621
+ listGroup.addItem("bullet-list", {
622
+ label: (_qa = (_pa = (_oa = config == null ? void 0 : config.listGroup) == null ? void 0 : _oa.bulletList) == null ? void 0 : _pa.label) != null ? _qa : "Bullet List",
623
+ icon: (_ta = (_sa = (_ra = config == null ? void 0 : config.listGroup) == null ? void 0 : _ra.bulletList) == null ? void 0 : _sa.icon) != null ? _ta : bulletListIcon,
624
+ onRun: (ctx2) => {
625
+ const commands = ctx2.get(core.commandsCtx);
626
+ const bulletList = commonmark.bulletListSchema.type(ctx2);
627
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
628
+ commands.call(commonmark.wrapInBlockTypeCommand.key, {
629
+ nodeType: bulletList
630
+ });
631
+ }
632
+ });
621
633
  }
622
- }).addItem("ordered-list", {
623
- label: (_w = config == null ? void 0 : config.slashMenuOrderedListLabel) != null ? _w : "Ordered List",
624
- icon: (_x = config == null ? void 0 : config.slashMenuOrderedListIcon) != null ? _x : orderedListIcon,
625
- onRun: (ctx2) => {
626
- const view = ctx2.get(core.editorViewCtx);
627
- const { dispatch, state } = view;
628
- const command = clearContentAndWrapInBlockType(
629
- commonmark.orderedListSchema.type(ctx2)
630
- );
631
- command(state, dispatch);
634
+ if (((_ua = config == null ? void 0 : config.listGroup) == null ? void 0 : _ua.orderedList) !== null) {
635
+ listGroup.addItem("ordered-list", {
636
+ label: (_xa = (_wa = (_va = config == null ? void 0 : config.listGroup) == null ? void 0 : _va.orderedList) == null ? void 0 : _wa.label) != null ? _xa : "Ordered List",
637
+ icon: (_Aa = (_za = (_ya = config == null ? void 0 : config.listGroup) == null ? void 0 : _ya.orderedList) == null ? void 0 : _za.icon) != null ? _Aa : orderedListIcon,
638
+ onRun: (ctx2) => {
639
+ const commands = ctx2.get(core.commandsCtx);
640
+ const orderedList = commonmark.orderedListSchema.type(ctx2);
641
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
642
+ commands.call(commonmark.wrapInBlockTypeCommand.key, {
643
+ nodeType: orderedList
644
+ });
645
+ }
646
+ });
632
647
  }
633
- }).addItem("todo-list", {
634
- label: (_y = config == null ? void 0 : config.slashMenuTaskListLabel) != null ? _y : "Todo List",
635
- icon: (_z = config == null ? void 0 : config.slashMenuTaskListIcon) != null ? _z : todoListIcon,
636
- onRun: (ctx2) => {
637
- const view = ctx2.get(core.editorViewCtx);
638
- const { dispatch, state } = view;
639
- const command = clearContentAndWrapInBlockType(
640
- commonmark.listItemSchema.type(ctx2),
641
- { checked: false }
642
- );
643
- command(state, dispatch);
648
+ if (((_Ba = config == null ? void 0 : config.listGroup) == null ? void 0 : _Ba.taskList) !== null) {
649
+ listGroup.addItem("task-list", {
650
+ label: (_Ea = (_Da = (_Ca = config == null ? void 0 : config.listGroup) == null ? void 0 : _Ca.taskList) == null ? void 0 : _Da.label) != null ? _Ea : "Task List",
651
+ icon: (_Ha = (_Ga = (_Fa = config == null ? void 0 : config.listGroup) == null ? void 0 : _Fa.taskList) == null ? void 0 : _Ga.icon) != null ? _Ha : todoListIcon,
652
+ onRun: (ctx2) => {
653
+ const commands = ctx2.get(core.commandsCtx);
654
+ const listItem = commonmark.listItemSchema.type(ctx2);
655
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
656
+ commands.call(commonmark.wrapInBlockTypeCommand.key, {
657
+ nodeType: listItem,
658
+ attrs: { checked: false }
659
+ });
660
+ }
661
+ });
644
662
  }
645
- });
646
- const advancedGroup = groupBuilder.addGroup(
647
- "advanced",
648
- (_A = config == null ? void 0 : config.slashMenuAdvancedGroupLabel) != null ? _A : "Advanced"
649
- );
650
- if (isImageBlockEnabled) {
651
- advancedGroup.addItem("image", {
652
- label: (_B = config == null ? void 0 : config.slashMenuImageLabel) != null ? _B : "Image",
653
- icon: (_C = config == null ? void 0 : config.slashMenuImageIcon) != null ? _C : imageIcon,
654
- onRun: (ctx2) => {
655
- const view = ctx2.get(core.editorViewCtx);
656
- const { dispatch, state } = view;
657
- const command = clearContentAndAddBlockType(imageBlock.imageBlockSchema.type(ctx2));
658
- command(state, dispatch);
659
- }
660
- });
661
663
  }
662
- advancedGroup.addItem("code", {
663
- label: (_D = config == null ? void 0 : config.slashMenuCodeBlockLabel) != null ? _D : "Code",
664
- icon: (_E = config == null ? void 0 : config.slashMenuCodeBlockIcon) != null ? _E : codeIcon,
665
- onRun: (ctx2) => {
666
- const view = ctx2.get(core.editorViewCtx);
667
- const { dispatch, state } = view;
668
- const command = clearContentAndAddBlockType(commonmark.codeBlockSchema.type(ctx2));
669
- command(state, dispatch);
664
+ if ((config == null ? void 0 : config.advancedGroup) !== null) {
665
+ const advancedGroup = groupBuilder.addGroup(
666
+ "advanced",
667
+ (_Ja = (_Ia = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ia.label) != null ? _Ja : "Advanced"
668
+ );
669
+ if (((_Ka = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ka.image) !== null && isImageBlockEnabled) {
670
+ advancedGroup.addItem("image", {
671
+ label: (_Na = (_Ma = (_La = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _La.image) == null ? void 0 : _Ma.label) != null ? _Na : "Image",
672
+ icon: (_Qa = (_Pa = (_Oa = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Oa.image) == null ? void 0 : _Pa.icon) != null ? _Qa : imageIcon,
673
+ onRun: (ctx2) => {
674
+ const commands = ctx2.get(core.commandsCtx);
675
+ const imageBlock$1 = imageBlock.imageBlockSchema.type(ctx2);
676
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
677
+ commands.call(commonmark.addBlockTypeCommand.key, {
678
+ nodeType: imageBlock$1
679
+ });
680
+ }
681
+ });
682
+ }
683
+ if (((_Ra = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ra.codeBlock) !== null) {
684
+ advancedGroup.addItem("code", {
685
+ label: (_Ua = (_Ta = (_Sa = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Sa.codeBlock) == null ? void 0 : _Ta.label) != null ? _Ua : "Code",
686
+ icon: (_Xa = (_Wa = (_Va = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Va.codeBlock) == null ? void 0 : _Wa.icon) != null ? _Xa : codeIcon,
687
+ onRun: (ctx2) => {
688
+ const commands = ctx2.get(core.commandsCtx);
689
+ const codeBlock = commonmark.codeBlockSchema.type(ctx2);
690
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
691
+ commands.call(commonmark.setBlockTypeCommand.key, {
692
+ nodeType: codeBlock
693
+ });
694
+ }
695
+ });
696
+ }
697
+ if (((_Ya = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Ya.table) !== null && isTableEnabled) {
698
+ advancedGroup.addItem("table", {
699
+ label: (_$a = (__a = (_Za = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _Za.table) == null ? void 0 : __a.label) != null ? _$a : "Table",
700
+ icon: (_cb = (_bb = (_ab = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _ab.table) == null ? void 0 : _bb.icon) != null ? _cb : tableIcon,
701
+ onRun: (ctx2) => {
702
+ const commands = ctx2.get(core.commandsCtx);
703
+ const view = ctx2.get(core.editorViewCtx);
704
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
705
+ const { from } = view.state.selection;
706
+ commands.call(commonmark.addBlockTypeCommand.key, {
707
+ nodeType: gfm.createTable(ctx2, 3, 3)
708
+ });
709
+ commands.call(commonmark.selectTextNearPosCommand.key, {
710
+ pos: from
711
+ });
712
+ }
713
+ });
714
+ }
715
+ if (((_db = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _db.math) !== null && isLatexEnabled) {
716
+ advancedGroup.addItem("math", {
717
+ label: (_gb = (_fb = (_eb = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _eb.math) == null ? void 0 : _fb.label) != null ? _gb : "Math",
718
+ icon: (_jb = (_ib = (_hb = config == null ? void 0 : config.advancedGroup) == null ? void 0 : _hb.math) == null ? void 0 : _ib.icon) != null ? _jb : functionsIcon,
719
+ onRun: (ctx2) => {
720
+ const commands = ctx2.get(core.commandsCtx);
721
+ const codeBlock = commonmark.codeBlockSchema.type(ctx2);
722
+ commands.call(commonmark.clearTextInCurrentBlockCommand.key);
723
+ commands.call(commonmark.addBlockTypeCommand.key, {
724
+ nodeType: codeBlock,
725
+ attrs: { language: "LaTex" }
726
+ });
727
+ }
728
+ });
670
729
  }
671
- });
672
- if (isTableEnabled) {
673
- advancedGroup.addItem("table", {
674
- label: (_F = config == null ? void 0 : config.slashMenuTableLabel) != null ? _F : "Table",
675
- icon: (_G = config == null ? void 0 : config.slashMenuTableIcon) != null ? _G : tableIcon,
676
- onRun: (ctx2) => {
677
- const view = ctx2.get(core.editorViewCtx);
678
- const { dispatch, state: state$1 } = view;
679
- let { tr } = state$1;
680
- tr = clearRange(tr);
681
- const from = tr.selection.from;
682
- const table = gfm.createTable(ctx2, 3, 3);
683
- tr = tr.replaceSelectionWith(table);
684
- dispatch(tr);
685
- requestAnimationFrame(() => {
686
- const docSize = view.state.doc.content.size;
687
- const $pos = view.state.doc.resolve(
688
- from > docSize ? docSize : from < 0 ? 0 : from
689
- );
690
- const selection = state.TextSelection.near($pos);
691
- const tr2 = view.state.tr;
692
- tr2.setSelection(selection);
693
- dispatch(tr2.scrollIntoView());
694
- });
695
- }
696
- });
697
- }
698
- if (isLatexEnabled) {
699
- advancedGroup.addItem("math", {
700
- label: (_H = config == null ? void 0 : config.slashMenuMathLabel) != null ? _H : "Math",
701
- icon: (_I = config == null ? void 0 : config.slashMenuMathIcon) != null ? _I : functionsIcon,
702
- onRun: (ctx2) => {
703
- const view = ctx2.get(core.editorViewCtx);
704
- const { dispatch, state } = view;
705
- const command = clearContentAndAddBlockType(commonmark.codeBlockSchema.type(ctx2), {
706
- language: "LaTex"
707
- });
708
- command(state, dispatch);
709
- }
710
- });
711
730
  }
712
- (_J = config == null ? void 0 : config.buildMenu) == null ? void 0 : _J.call(config, groupBuilder);
731
+ (_kb = config == null ? void 0 : config.buildMenu) == null ? void 0 : _kb.call(config, groupBuilder);
713
732
  let groups = groupBuilder.build();
714
733
  if (filter) {
715
734
  groups = groups.map((group) => {