@milkdown/crepe 7.11.1 → 7.12.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/lib/cjs/builder/builder.js +107 -0
- package/lib/cjs/builder/builder.js.map +1 -0
- package/lib/cjs/{index-CtTpZYVe.js → feature/block-edit/index.js} +165 -61
- package/lib/cjs/feature/block-edit/index.js.map +1 -0
- package/lib/cjs/feature/code-mirror/index.js +161 -0
- package/lib/cjs/feature/code-mirror/index.js.map +1 -0
- package/lib/cjs/feature/cursor/index.js +57 -0
- package/lib/cjs/feature/cursor/index.js.map +1 -0
- package/lib/cjs/feature/image-block/index.js +123 -0
- package/lib/cjs/feature/image-block/index.js.map +1 -0
- package/lib/cjs/{index-2icTTGim.js → feature/latex/index.js} +111 -24
- package/lib/cjs/feature/latex/index.js.map +1 -0
- package/lib/cjs/feature/link-tooltip/index.js +124 -0
- package/lib/cjs/feature/link-tooltip/index.js.map +1 -0
- package/lib/cjs/{index-Dw6lXgs6.js → feature/list-item/index.js} +39 -8
- package/lib/cjs/feature/list-item/index.js.map +1 -0
- package/lib/cjs/{index-B91KhPew.js → feature/placeholder/index.js} +46 -6
- package/lib/cjs/feature/placeholder/index.js.map +1 -0
- package/lib/cjs/{index-DEs_IHHy.js → feature/table/index.js} +78 -16
- package/lib/cjs/feature/table/index.js.map +1 -0
- package/lib/cjs/{index-k3lGvKiX.js → feature/toolbar/index.js} +133 -31
- package/lib/cjs/feature/toolbar/index.js.map +1 -0
- package/lib/cjs/index/index.js +2464 -0
- package/lib/cjs/index/index.js.map +1 -0
- package/lib/esm/builder/builder.js +105 -0
- package/lib/esm/builder/builder.js.map +1 -0
- package/lib/esm/{index-BEe1TpeS.js → feature/block-edit/index.js} +161 -57
- package/lib/esm/feature/block-edit/index.js.map +1 -0
- package/lib/esm/feature/code-mirror/index.js +159 -0
- package/lib/esm/feature/code-mirror/index.js.map +1 -0
- package/lib/esm/feature/cursor/index.js +55 -0
- package/lib/esm/feature/cursor/index.js.map +1 -0
- package/lib/esm/feature/image-block/index.js +121 -0
- package/lib/esm/feature/image-block/index.js.map +1 -0
- package/lib/esm/{index-ZGfGszIQ.js → feature/latex/index.js} +107 -20
- package/lib/esm/feature/latex/index.js.map +1 -0
- package/lib/esm/feature/link-tooltip/index.js +122 -0
- package/lib/esm/feature/link-tooltip/index.js.map +1 -0
- package/lib/esm/{index-E8UgFLeN.js → feature/list-item/index.js} +39 -8
- package/lib/esm/feature/list-item/index.js.map +1 -0
- package/lib/esm/{index-BCvtgOeI.js → feature/placeholder/index.js} +45 -5
- package/lib/esm/feature/placeholder/index.js.map +1 -0
- package/lib/esm/{index-CwMVnVeI.js → feature/table/index.js} +78 -16
- package/lib/esm/feature/table/index.js.map +1 -0
- package/lib/esm/{index-CTBg0aec.js → feature/toolbar/index.js} +128 -26
- package/lib/esm/feature/toolbar/index.js.map +1 -0
- package/lib/esm/index/index.js +2458 -0
- package/lib/esm/index/index.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types/builder.d.ts +2 -0
- package/lib/types/builder.d.ts.map +1 -0
- package/lib/types/core/builder.d.ts +23 -0
- package/lib/types/core/builder.d.ts.map +1 -0
- package/lib/types/core/crepe.d.ts +4 -15
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/core/index.d.ts +2 -1
- package/lib/types/core/index.d.ts.map +1 -1
- package/lib/types/core/slice.d.ts +6 -4
- package/lib/types/core/slice.d.ts.map +1 -1
- package/lib/types/default-config/index.d.ts +3 -0
- package/lib/types/default-config/index.d.ts.map +1 -0
- package/lib/types/feature/block-edit/handle/component.d.ts +2 -3
- package/lib/types/feature/block-edit/handle/component.d.ts.map +1 -1
- package/lib/types/feature/block-edit/index.d.ts +20 -20
- package/lib/types/feature/block-edit/index.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +7 -7
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/cursor/index.d.ts +1 -1
- package/lib/types/feature/cursor/index.d.ts.map +1 -1
- package/lib/types/feature/image-block/index.d.ts +9 -9
- package/lib/types/feature/image-block/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +2 -4
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/latex/index.d.ts +3 -3
- package/lib/types/feature/latex/index.d.ts.map +1 -1
- package/lib/types/feature/link-tooltip/index.d.ts +6 -6
- package/lib/types/feature/link-tooltip/index.d.ts.map +1 -1
- package/lib/types/feature/list-item/index.d.ts +5 -5
- package/lib/types/feature/list-item/index.d.ts.map +1 -1
- package/lib/types/feature/loader.d.ts +4 -0
- package/lib/types/feature/loader.d.ts.map +1 -0
- package/lib/types/feature/placeholder/index.d.ts +2 -2
- package/lib/types/feature/placeholder/index.d.ts.map +1 -1
- package/lib/types/feature/shared.d.ts +1 -2
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/table/index.d.ts +11 -11
- package/lib/types/feature/table/index.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts +8 -8
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/index.d.ts +1 -0
- package/lib/types/icons/index.d.ts.map +1 -1
- package/lib/types/index.d.ts +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/utils/index.d.ts +0 -1
- package/lib/types/utils/index.d.ts.map +1 -1
- package/package.json +60 -3
- package/src/builder.ts +1 -0
- package/src/core/builder.ts +143 -0
- package/src/core/crepe.ts +14 -130
- package/src/core/index.ts +2 -1
- package/src/core/slice.ts +37 -8
- package/src/default-config/index.ts +25 -0
- package/src/feature/block-edit/handle/component.tsx +6 -8
- package/src/feature/block-edit/handle/index.ts +2 -2
- package/src/feature/block-edit/index.ts +23 -20
- package/src/feature/block-edit/menu/config.ts +19 -19
- package/src/feature/code-mirror/index.ts +32 -28
- package/src/feature/cursor/index.ts +10 -6
- package/src/feature/image-block/index.ts +19 -16
- package/src/feature/index.ts +2 -53
- package/src/feature/latex/index.ts +8 -10
- package/src/feature/latex/inline-tooltip/component.tsx +1 -1
- package/src/feature/link-tooltip/index.ts +13 -10
- package/src/feature/list-item/index.ts +11 -8
- package/src/feature/loader.ts +52 -0
- package/src/feature/placeholder/index.ts +5 -2
- package/src/feature/shared.ts +1 -3
- package/src/feature/table/index.ts +23 -23
- package/src/feature/toolbar/component.tsx +9 -9
- package/src/feature/toolbar/index.ts +14 -11
- package/src/icons/index.ts +1 -0
- package/src/index.ts +1 -1
- package/src/utils/index.ts +0 -8
- package/lib/cjs/confirm-CNveM9QH.js +0 -26
- package/lib/cjs/confirm-CNveM9QH.js.map +0 -1
- package/lib/cjs/edit-BUtBJHpV.js +0 -24
- package/lib/cjs/edit-BUtBJHpV.js.map +0 -1
- package/lib/cjs/functions-BAY51plB.js +0 -39
- package/lib/cjs/functions-BAY51plB.js.map +0 -1
- package/lib/cjs/image-BXLkOVnO.js +0 -24
- package/lib/cjs/image-BXLkOVnO.js.map +0 -1
- package/lib/cjs/index-2icTTGim.js.map +0 -1
- package/lib/cjs/index-B91KhPew.js.map +0 -1
- package/lib/cjs/index-BsrJn8Jp.js +0 -41
- package/lib/cjs/index-BsrJn8Jp.js.map +0 -1
- package/lib/cjs/index-C2CAbC2F.js +0 -26
- package/lib/cjs/index-C2CAbC2F.js.map +0 -1
- package/lib/cjs/index-CtTpZYVe.js.map +0 -1
- package/lib/cjs/index-DEs_IHHy.js.map +0 -1
- package/lib/cjs/index-DLIudQKW.js +0 -126
- package/lib/cjs/index-DLIudQKW.js.map +0 -1
- package/lib/cjs/index-Dw6lXgs6.js.map +0 -1
- package/lib/cjs/index-k3lGvKiX.js.map +0 -1
- package/lib/cjs/index-urTgNBfI.js +0 -202
- package/lib/cjs/index-urTgNBfI.js.map +0 -1
- package/lib/cjs/index-xbwf60wt.js +0 -15
- package/lib/cjs/index-xbwf60wt.js.map +0 -1
- package/lib/cjs/index-xbxqAqH2.js +0 -52
- package/lib/cjs/index-xbxqAqH2.js.map +0 -1
- package/lib/cjs/index.js +0 -20
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/inline-latex-D0G71cGk.js +0 -54
- package/lib/cjs/inline-latex-D0G71cGk.js.map +0 -1
- package/lib/cjs/plus-XLomtlXf.js +0 -24
- package/lib/cjs/plus-XLomtlXf.js.map +0 -1
- package/lib/cjs/remove-Ba-ypwBf.js +0 -17
- package/lib/cjs/remove-Ba-ypwBf.js.map +0 -1
- package/lib/esm/confirm-DtE-HkVd.js +0 -24
- package/lib/esm/confirm-DtE-HkVd.js.map +0 -1
- package/lib/esm/edit-D--t_JAb.js +0 -22
- package/lib/esm/edit-D--t_JAb.js.map +0 -1
- package/lib/esm/functions-DlJPkGmE.js +0 -36
- package/lib/esm/functions-DlJPkGmE.js.map +0 -1
- package/lib/esm/image-DoB1o1sl.js +0 -22
- package/lib/esm/image-DoB1o1sl.js.map +0 -1
- package/lib/esm/index-BCvtgOeI.js.map +0 -1
- package/lib/esm/index-BEe1TpeS.js.map +0 -1
- package/lib/esm/index-BPG8iO8t.js +0 -12
- package/lib/esm/index-BPG8iO8t.js.map +0 -1
- package/lib/esm/index-BUBXHhHG.js +0 -39
- package/lib/esm/index-BUBXHhHG.js.map +0 -1
- package/lib/esm/index-Bvz1Yyiz.js +0 -24
- package/lib/esm/index-Bvz1Yyiz.js.map +0 -1
- package/lib/esm/index-C1aVAv1l.js +0 -124
- package/lib/esm/index-C1aVAv1l.js.map +0 -1
- package/lib/esm/index-CTBg0aec.js.map +0 -1
- package/lib/esm/index-ChR5Qhyf.js +0 -50
- package/lib/esm/index-ChR5Qhyf.js.map +0 -1
- package/lib/esm/index-CshFzSt2.js +0 -197
- package/lib/esm/index-CshFzSt2.js.map +0 -1
- package/lib/esm/index-CwMVnVeI.js.map +0 -1
- package/lib/esm/index-E8UgFLeN.js.map +0 -1
- package/lib/esm/index-ZGfGszIQ.js.map +0 -1
- package/lib/esm/index.js +0 -12
- package/lib/esm/index.js.map +0 -1
- package/lib/esm/inline-latex-C9IGAXXQ.js +0 -51
- package/lib/esm/inline-latex-C9IGAXXQ.js.map +0 -1
- package/lib/esm/plus-lrX0Q75O.js +0 -22
- package/lib/esm/plus-lrX0Q75O.js.map +0 -1
- package/lib/esm/remove-D3g0Cd6_.js +0 -15
- package/lib/esm/remove-D3g0Cd6_.js.map +0 -1
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@milkdown/kit/core');
|
|
4
|
+
var clipboard = require('@milkdown/kit/plugin/clipboard');
|
|
5
|
+
var history = require('@milkdown/kit/plugin/history');
|
|
6
|
+
var indent = require('@milkdown/kit/plugin/indent');
|
|
7
|
+
var listener = require('@milkdown/kit/plugin/listener');
|
|
8
|
+
var trailing = require('@milkdown/kit/plugin/trailing');
|
|
9
|
+
var commonmark = require('@milkdown/kit/preset/commonmark');
|
|
10
|
+
var gfm = require('@milkdown/kit/preset/gfm');
|
|
11
|
+
var utils = require('@milkdown/kit/utils');
|
|
12
|
+
var ctx = require('@milkdown/kit/ctx');
|
|
13
|
+
|
|
14
|
+
const FeaturesCtx = ctx.createSlice([], "FeaturesCtx");
|
|
15
|
+
const CrepeCtx = ctx.createSlice({}, "CrepeCtx");
|
|
16
|
+
|
|
17
|
+
var __typeError = (msg) => {
|
|
18
|
+
throw TypeError(msg);
|
|
19
|
+
};
|
|
20
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
21
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
22
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
23
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
24
|
+
var _editor, _rootElement, _editable;
|
|
25
|
+
class CrepeBuilder {
|
|
26
|
+
/// The constructor of the crepe builder.
|
|
27
|
+
/// You can pass configs to the builder to configure the editor.
|
|
28
|
+
constructor({ root, defaultValue = "" }) {
|
|
29
|
+
/// @internal
|
|
30
|
+
__privateAdd(this, _editor);
|
|
31
|
+
/// @internal
|
|
32
|
+
__privateAdd(this, _rootElement);
|
|
33
|
+
/// @internal
|
|
34
|
+
__privateAdd(this, _editable, true);
|
|
35
|
+
/// Add a feature to the editor.
|
|
36
|
+
this.addFeature = (feature, config) => {
|
|
37
|
+
feature(__privateGet(this, _editor), config);
|
|
38
|
+
return this;
|
|
39
|
+
};
|
|
40
|
+
/// Create the editor.
|
|
41
|
+
this.create = () => {
|
|
42
|
+
return __privateGet(this, _editor).create();
|
|
43
|
+
};
|
|
44
|
+
/// Destroy the editor.
|
|
45
|
+
this.destroy = () => {
|
|
46
|
+
return __privateGet(this, _editor).destroy();
|
|
47
|
+
};
|
|
48
|
+
/// Set the readonly mode of the editor.
|
|
49
|
+
this.setReadonly = (value) => {
|
|
50
|
+
__privateSet(this, _editable, !value);
|
|
51
|
+
__privateGet(this, _editor).action((ctx) => {
|
|
52
|
+
if (__privateGet(this, _editor).status === core.EditorStatus.Created) {
|
|
53
|
+
const view = ctx.get(core.editorViewCtx);
|
|
54
|
+
view.setProps({
|
|
55
|
+
editable: () => !value
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return this;
|
|
60
|
+
};
|
|
61
|
+
/// Get the markdown content of the editor.
|
|
62
|
+
this.getMarkdown = () => {
|
|
63
|
+
return __privateGet(this, _editor).action(utils.getMarkdown());
|
|
64
|
+
};
|
|
65
|
+
/// Register event listeners.
|
|
66
|
+
this.on = (fn) => {
|
|
67
|
+
if (__privateGet(this, _editor).status !== core.EditorStatus.Created) {
|
|
68
|
+
__privateGet(this, _editor).config((ctx) => {
|
|
69
|
+
const listener2 = ctx.get(listener.listenerCtx);
|
|
70
|
+
fn(listener2);
|
|
71
|
+
});
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
__privateGet(this, _editor).action((ctx) => {
|
|
75
|
+
const listener2 = ctx.get(listener.listenerCtx);
|
|
76
|
+
fn(listener2);
|
|
77
|
+
});
|
|
78
|
+
return this;
|
|
79
|
+
};
|
|
80
|
+
var _a;
|
|
81
|
+
__privateSet(this, _rootElement, (_a = typeof root === "string" ? document.querySelector(root) : root) != null ? _a : document.body);
|
|
82
|
+
__privateSet(this, _editor, core.Editor.make().config((ctx) => {
|
|
83
|
+
ctx.inject(CrepeCtx, this);
|
|
84
|
+
ctx.inject(FeaturesCtx, []);
|
|
85
|
+
}).config((ctx) => {
|
|
86
|
+
ctx.set(core.rootCtx, __privateGet(this, _rootElement));
|
|
87
|
+
ctx.set(core.defaultValueCtx, defaultValue);
|
|
88
|
+
ctx.set(core.editorViewOptionsCtx, {
|
|
89
|
+
editable: () => __privateGet(this, _editable)
|
|
90
|
+
});
|
|
91
|
+
ctx.update(indent.indentConfig.key, (value) => ({
|
|
92
|
+
...value,
|
|
93
|
+
size: 4
|
|
94
|
+
}));
|
|
95
|
+
}).use(commonmark.commonmark).use(listener.listener).use(history.history).use(indent.indent).use(trailing.trailing).use(clipboard.clipboard).use(gfm.gfm));
|
|
96
|
+
}
|
|
97
|
+
/// Get the milkdown editor instance.
|
|
98
|
+
get editor() {
|
|
99
|
+
return __privateGet(this, _editor);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
_editor = new WeakMap();
|
|
103
|
+
_rootElement = new WeakMap();
|
|
104
|
+
_editable = new WeakMap();
|
|
105
|
+
|
|
106
|
+
exports.CrepeBuilder = CrepeBuilder;
|
|
107
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -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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"}
|
|
@@ -1,28 +1,48 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var block = require('@milkdown/kit/plugin/block');
|
|
4
|
+
var ctx = require('@milkdown/kit/ctx');
|
|
4
5
|
var core = require('@milkdown/kit/core');
|
|
5
6
|
var commonmark = require('@milkdown/kit/preset/commonmark');
|
|
6
7
|
var prose = require('@milkdown/kit/prose');
|
|
7
8
|
var state = require('@milkdown/kit/prose/state');
|
|
8
9
|
var vue = require('vue');
|
|
9
|
-
var plus = require('./plus-XLomtlXf.js');
|
|
10
10
|
var slash = require('@milkdown/kit/plugin/slash');
|
|
11
11
|
var utils = require('@milkdown/kit/utils');
|
|
12
|
-
var index$1 = require('./index-xbwf60wt.js');
|
|
13
12
|
var component = require('@milkdown/kit/component');
|
|
14
13
|
var imageBlock = require('@milkdown/kit/component/image-block');
|
|
15
14
|
var gfm = require('@milkdown/kit/preset/gfm');
|
|
16
|
-
var index = require('./index-urTgNBfI.js');
|
|
17
|
-
var functions = require('./functions-BAY51plB.js');
|
|
18
|
-
var image = require('./image-BXLkOVnO.js');
|
|
19
15
|
var transform = require('@milkdown/kit/prose/transform');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
16
|
+
|
|
17
|
+
ctx.createSlice([], "FeaturesCtx");
|
|
18
|
+
ctx.createSlice({}, "CrepeCtx");
|
|
19
|
+
function useCrepeFeatures(ctx) {
|
|
20
|
+
return ctx.use("FeaturesCtx");
|
|
21
|
+
}
|
|
22
|
+
function crepeFeatureConfig(feature) {
|
|
23
|
+
return (ctx) => {
|
|
24
|
+
useCrepeFeatures(ctx).update((features) => {
|
|
25
|
+
if (features.includes(feature)) {
|
|
26
|
+
return features;
|
|
27
|
+
}
|
|
28
|
+
return [...features, feature];
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
var CrepeFeature = /* @__PURE__ */ ((CrepeFeature2) => {
|
|
34
|
+
CrepeFeature2["CodeMirror"] = "code-mirror";
|
|
35
|
+
CrepeFeature2["ListItem"] = "list-item";
|
|
36
|
+
CrepeFeature2["LinkTooltip"] = "link-tooltip";
|
|
37
|
+
CrepeFeature2["Cursor"] = "cursor";
|
|
38
|
+
CrepeFeature2["ImageBlock"] = "image-block";
|
|
39
|
+
CrepeFeature2["BlockEdit"] = "block-edit";
|
|
40
|
+
CrepeFeature2["Toolbar"] = "toolbar";
|
|
41
|
+
CrepeFeature2["Placeholder"] = "placeholder";
|
|
42
|
+
CrepeFeature2["Table"] = "table";
|
|
43
|
+
CrepeFeature2["Latex"] = "latex";
|
|
44
|
+
return CrepeFeature2;
|
|
45
|
+
})(CrepeFeature || {});
|
|
26
46
|
|
|
27
47
|
const bulletListIcon = `
|
|
28
48
|
<svg
|
|
@@ -44,6 +64,26 @@ const bulletListIcon = `
|
|
|
44
64
|
</svg>
|
|
45
65
|
`;
|
|
46
66
|
|
|
67
|
+
const codeIcon = `
|
|
68
|
+
<svg
|
|
69
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
70
|
+
width="24"
|
|
71
|
+
height="24"
|
|
72
|
+
viewBox="0 0 24 24"
|
|
73
|
+
>
|
|
74
|
+
<g clip-path="url(#clip0_977_8081)">
|
|
75
|
+
<path
|
|
76
|
+
d="M9.4 16.6L4.8 12L9.4 7.4L8 6L2 12L8 18L9.4 16.6ZM14.6 16.6L19.2 12L14.6 7.4L16 6L22 12L16 18L14.6 16.6Z"
|
|
77
|
+
/>
|
|
78
|
+
</g>
|
|
79
|
+
<defs>
|
|
80
|
+
<clipPath id="clip0_977_8081">
|
|
81
|
+
<rect width="24" height="24" />
|
|
82
|
+
</clipPath>
|
|
83
|
+
</defs>
|
|
84
|
+
</svg>
|
|
85
|
+
`;
|
|
86
|
+
|
|
47
87
|
const dividerIcon = `
|
|
48
88
|
<svg
|
|
49
89
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -186,6 +226,26 @@ const h6Icon = `
|
|
|
186
226
|
</svg>
|
|
187
227
|
`;
|
|
188
228
|
|
|
229
|
+
const imageIcon = `
|
|
230
|
+
<svg
|
|
231
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
232
|
+
width="24"
|
|
233
|
+
height="24"
|
|
234
|
+
viewBox="0 0 24 24"
|
|
235
|
+
>
|
|
236
|
+
<g clip-path="url(#clip0_977_8075)">
|
|
237
|
+
<path
|
|
238
|
+
d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z"
|
|
239
|
+
/>
|
|
240
|
+
</g>
|
|
241
|
+
<defs>
|
|
242
|
+
<clipPath id="clip0_977_8075">
|
|
243
|
+
<rect width="24" height="24" />
|
|
244
|
+
</clipPath>
|
|
245
|
+
</defs>
|
|
246
|
+
</svg>
|
|
247
|
+
`;
|
|
248
|
+
|
|
189
249
|
const menuIcon = `
|
|
190
250
|
<svg
|
|
191
251
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -226,6 +286,26 @@ const orderedListIcon = `
|
|
|
226
286
|
</svg>
|
|
227
287
|
`;
|
|
228
288
|
|
|
289
|
+
const plusIcon = `
|
|
290
|
+
<svg
|
|
291
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
292
|
+
width="24"
|
|
293
|
+
height="24"
|
|
294
|
+
viewBox="0 0 24 24"
|
|
295
|
+
>
|
|
296
|
+
<g clip-path="url(#clip0_971_7676)">
|
|
297
|
+
<path
|
|
298
|
+
d="M18 13H13V18C13 18.55 12.55 19 12 19C11.45 19 11 18.55 11 18V13H6C5.45 13 5 12.55 5 12C5 11.45 5.45 11 6 11H11V6C11 5.45 11.45 5 12 5C12.55 5 13 5.45 13 6V11H18C18.55 11 19 11.45 19 12C19 12.55 18.55 13 18 13Z"
|
|
299
|
+
/>
|
|
300
|
+
</g>
|
|
301
|
+
<defs>
|
|
302
|
+
<clipPath id="clip0_971_7676">
|
|
303
|
+
<rect width="24" height="24" />
|
|
304
|
+
</clipPath>
|
|
305
|
+
</defs>
|
|
306
|
+
</svg>
|
|
307
|
+
`;
|
|
308
|
+
|
|
229
309
|
const quoteIcon = `
|
|
230
310
|
<svg
|
|
231
311
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -299,6 +379,30 @@ const todoListIcon = `
|
|
|
299
379
|
</svg>
|
|
300
380
|
`;
|
|
301
381
|
|
|
382
|
+
const functionsIcon = `
|
|
383
|
+
<svg
|
|
384
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
385
|
+
width="32"
|
|
386
|
+
height="32"
|
|
387
|
+
viewBox="0 0 24 24"
|
|
388
|
+
>
|
|
389
|
+
<path
|
|
390
|
+
fill="currentColor"
|
|
391
|
+
d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
|
|
392
|
+
/>
|
|
393
|
+
</svg>
|
|
394
|
+
`;
|
|
395
|
+
|
|
396
|
+
function isInCodeBlock(selection) {
|
|
397
|
+
const type = selection.$from.parent.type;
|
|
398
|
+
return type.name === "code_block";
|
|
399
|
+
}
|
|
400
|
+
function isInList(selection) {
|
|
401
|
+
var _a;
|
|
402
|
+
const type = (_a = selection.$from.node(selection.$from.depth - 1)) == null ? void 0 : _a.type;
|
|
403
|
+
return (type == null ? void 0 : type.name) === "list_item";
|
|
404
|
+
}
|
|
405
|
+
|
|
302
406
|
var __typeError$2 = (msg) => {
|
|
303
407
|
throw TypeError(msg);
|
|
304
408
|
};
|
|
@@ -402,15 +506,15 @@ function clearContentAndAddBlockType(nodeType, attrs = null) {
|
|
|
402
506
|
}
|
|
403
507
|
|
|
404
508
|
function getGroups(filter, config, ctx) {
|
|
405
|
-
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
|
|
406
|
-
const flags = ctx
|
|
407
|
-
const isLatexEnabled = flags == null ? void 0 : flags.includes(
|
|
408
|
-
const isImageBlockEnabled = flags == null ? void 0 : flags.includes(
|
|
409
|
-
const isTableEnabled = flags == null ? void 0 : flags.includes(
|
|
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;
|
|
510
|
+
const flags = ctx && useCrepeFeatures(ctx).get();
|
|
511
|
+
const isLatexEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Latex);
|
|
512
|
+
const isImageBlockEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.ImageBlock);
|
|
513
|
+
const isTableEnabled = flags == null ? void 0 : flags.includes(CrepeFeature.Table);
|
|
410
514
|
const groupBuilder = new GroupBuilder();
|
|
411
515
|
groupBuilder.addGroup("text", (_a = config == null ? void 0 : config.slashMenuTextGroupLabel) != null ? _a : "Text").addItem("text", {
|
|
412
516
|
label: (_b = config == null ? void 0 : config.slashMenuTextLabel) != null ? _b : "Text",
|
|
413
|
-
icon: (
|
|
517
|
+
icon: (_c = config == null ? void 0 : config.slashMenuTextIcon) != null ? _c : textIcon,
|
|
414
518
|
onRun: (ctx2) => {
|
|
415
519
|
const view = ctx2.get(core.editorViewCtx);
|
|
416
520
|
const { dispatch, state } = view;
|
|
@@ -418,8 +522,8 @@ function getGroups(filter, config, ctx) {
|
|
|
418
522
|
command(state, dispatch);
|
|
419
523
|
}
|
|
420
524
|
}).addItem("h1", {
|
|
421
|
-
label: (
|
|
422
|
-
icon: (
|
|
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,
|
|
423
527
|
onRun: (ctx2) => {
|
|
424
528
|
const view = ctx2.get(core.editorViewCtx);
|
|
425
529
|
const { dispatch, state } = view;
|
|
@@ -429,8 +533,8 @@ function getGroups(filter, config, ctx) {
|
|
|
429
533
|
command(state, dispatch);
|
|
430
534
|
}
|
|
431
535
|
}).addItem("h2", {
|
|
432
|
-
label: (
|
|
433
|
-
icon: (
|
|
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,
|
|
434
538
|
onRun: (ctx2) => {
|
|
435
539
|
const view = ctx2.get(core.editorViewCtx);
|
|
436
540
|
const { dispatch, state } = view;
|
|
@@ -440,8 +544,8 @@ function getGroups(filter, config, ctx) {
|
|
|
440
544
|
command(state, dispatch);
|
|
441
545
|
}
|
|
442
546
|
}).addItem("h3", {
|
|
443
|
-
label: (
|
|
444
|
-
icon: (
|
|
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,
|
|
445
549
|
onRun: (ctx2) => {
|
|
446
550
|
const view = ctx2.get(core.editorViewCtx);
|
|
447
551
|
const { dispatch, state } = view;
|
|
@@ -451,8 +555,8 @@ function getGroups(filter, config, ctx) {
|
|
|
451
555
|
command(state, dispatch);
|
|
452
556
|
}
|
|
453
557
|
}).addItem("h4", {
|
|
454
|
-
label: (
|
|
455
|
-
icon: (
|
|
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,
|
|
456
560
|
onRun: (ctx2) => {
|
|
457
561
|
const view = ctx2.get(core.editorViewCtx);
|
|
458
562
|
const { dispatch, state } = view;
|
|
@@ -462,8 +566,8 @@ function getGroups(filter, config, ctx) {
|
|
|
462
566
|
command(state, dispatch);
|
|
463
567
|
}
|
|
464
568
|
}).addItem("h5", {
|
|
465
|
-
label: (
|
|
466
|
-
icon: (
|
|
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,
|
|
467
571
|
onRun: (ctx2) => {
|
|
468
572
|
const view = ctx2.get(core.editorViewCtx);
|
|
469
573
|
const { dispatch, state } = view;
|
|
@@ -473,8 +577,8 @@ function getGroups(filter, config, ctx) {
|
|
|
473
577
|
command(state, dispatch);
|
|
474
578
|
}
|
|
475
579
|
}).addItem("h6", {
|
|
476
|
-
label: (
|
|
477
|
-
icon: (
|
|
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,
|
|
478
582
|
onRun: (ctx2) => {
|
|
479
583
|
const view = ctx2.get(core.editorViewCtx);
|
|
480
584
|
const { dispatch, state } = view;
|
|
@@ -484,8 +588,8 @@ function getGroups(filter, config, ctx) {
|
|
|
484
588
|
command(state, dispatch);
|
|
485
589
|
}
|
|
486
590
|
}).addItem("quote", {
|
|
487
|
-
label: (
|
|
488
|
-
icon: (
|
|
591
|
+
label: (_p = config == null ? void 0 : config.slashMenuQuoteLabel) != null ? _p : "Quote",
|
|
592
|
+
icon: (_q = config == null ? void 0 : config.slashMenuQuoteIcon) != null ? _q : quoteIcon,
|
|
489
593
|
onRun: (ctx2) => {
|
|
490
594
|
const view = ctx2.get(core.editorViewCtx);
|
|
491
595
|
const { dispatch, state } = view;
|
|
@@ -495,8 +599,8 @@ function getGroups(filter, config, ctx) {
|
|
|
495
599
|
command(state, dispatch);
|
|
496
600
|
}
|
|
497
601
|
}).addItem("divider", {
|
|
498
|
-
label: (
|
|
499
|
-
icon: (
|
|
602
|
+
label: (_r = config == null ? void 0 : config.slashMenuDividerLabel) != null ? _r : "Divider",
|
|
603
|
+
icon: (_s = config == null ? void 0 : config.slashMenuDividerIcon) != null ? _s : dividerIcon,
|
|
500
604
|
onRun: (ctx2) => {
|
|
501
605
|
const view = ctx2.get(core.editorViewCtx);
|
|
502
606
|
const { dispatch, state } = view;
|
|
@@ -504,9 +608,9 @@ function getGroups(filter, config, ctx) {
|
|
|
504
608
|
command(state, dispatch);
|
|
505
609
|
}
|
|
506
610
|
});
|
|
507
|
-
groupBuilder.addGroup("list", (
|
|
508
|
-
label: (
|
|
509
|
-
icon: (
|
|
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,
|
|
510
614
|
onRun: (ctx2) => {
|
|
511
615
|
const view = ctx2.get(core.editorViewCtx);
|
|
512
616
|
const { dispatch, state } = view;
|
|
@@ -516,8 +620,8 @@ function getGroups(filter, config, ctx) {
|
|
|
516
620
|
command(state, dispatch);
|
|
517
621
|
}
|
|
518
622
|
}).addItem("ordered-list", {
|
|
519
|
-
label: (
|
|
520
|
-
icon: (
|
|
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,
|
|
521
625
|
onRun: (ctx2) => {
|
|
522
626
|
const view = ctx2.get(core.editorViewCtx);
|
|
523
627
|
const { dispatch, state } = view;
|
|
@@ -527,8 +631,8 @@ function getGroups(filter, config, ctx) {
|
|
|
527
631
|
command(state, dispatch);
|
|
528
632
|
}
|
|
529
633
|
}).addItem("todo-list", {
|
|
530
|
-
label: (
|
|
531
|
-
icon: (
|
|
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,
|
|
532
636
|
onRun: (ctx2) => {
|
|
533
637
|
const view = ctx2.get(core.editorViewCtx);
|
|
534
638
|
const { dispatch, state } = view;
|
|
@@ -541,12 +645,12 @@ function getGroups(filter, config, ctx) {
|
|
|
541
645
|
});
|
|
542
646
|
const advancedGroup = groupBuilder.addGroup(
|
|
543
647
|
"advanced",
|
|
544
|
-
(
|
|
648
|
+
(_A = config == null ? void 0 : config.slashMenuAdvancedGroupLabel) != null ? _A : "Advanced"
|
|
545
649
|
);
|
|
546
650
|
if (isImageBlockEnabled) {
|
|
547
651
|
advancedGroup.addItem("image", {
|
|
548
|
-
label: (
|
|
549
|
-
icon: (
|
|
652
|
+
label: (_B = config == null ? void 0 : config.slashMenuImageLabel) != null ? _B : "Image",
|
|
653
|
+
icon: (_C = config == null ? void 0 : config.slashMenuImageIcon) != null ? _C : imageIcon,
|
|
550
654
|
onRun: (ctx2) => {
|
|
551
655
|
const view = ctx2.get(core.editorViewCtx);
|
|
552
656
|
const { dispatch, state } = view;
|
|
@@ -556,8 +660,8 @@ function getGroups(filter, config, ctx) {
|
|
|
556
660
|
});
|
|
557
661
|
}
|
|
558
662
|
advancedGroup.addItem("code", {
|
|
559
|
-
label: (
|
|
560
|
-
icon: (
|
|
663
|
+
label: (_D = config == null ? void 0 : config.slashMenuCodeBlockLabel) != null ? _D : "Code",
|
|
664
|
+
icon: (_E = config == null ? void 0 : config.slashMenuCodeBlockIcon) != null ? _E : codeIcon,
|
|
561
665
|
onRun: (ctx2) => {
|
|
562
666
|
const view = ctx2.get(core.editorViewCtx);
|
|
563
667
|
const { dispatch, state } = view;
|
|
@@ -567,8 +671,8 @@ function getGroups(filter, config, ctx) {
|
|
|
567
671
|
});
|
|
568
672
|
if (isTableEnabled) {
|
|
569
673
|
advancedGroup.addItem("table", {
|
|
570
|
-
label: (
|
|
571
|
-
icon: (
|
|
674
|
+
label: (_F = config == null ? void 0 : config.slashMenuTableLabel) != null ? _F : "Table",
|
|
675
|
+
icon: (_G = config == null ? void 0 : config.slashMenuTableIcon) != null ? _G : tableIcon,
|
|
572
676
|
onRun: (ctx2) => {
|
|
573
677
|
const view = ctx2.get(core.editorViewCtx);
|
|
574
678
|
const { dispatch, state: state$1 } = view;
|
|
@@ -593,8 +697,8 @@ function getGroups(filter, config, ctx) {
|
|
|
593
697
|
}
|
|
594
698
|
if (isLatexEnabled) {
|
|
595
699
|
advancedGroup.addItem("math", {
|
|
596
|
-
label: (
|
|
597
|
-
icon: (
|
|
700
|
+
label: (_H = config == null ? void 0 : config.slashMenuMathLabel) != null ? _H : "Math",
|
|
701
|
+
icon: (_I = config == null ? void 0 : config.slashMenuMathIcon) != null ? _I : functionsIcon,
|
|
598
702
|
onRun: (ctx2) => {
|
|
599
703
|
const view = ctx2.get(core.editorViewCtx);
|
|
600
704
|
const { dispatch, state } = view;
|
|
@@ -605,7 +709,7 @@ function getGroups(filter, config, ctx) {
|
|
|
605
709
|
}
|
|
606
710
|
});
|
|
607
711
|
}
|
|
608
|
-
(
|
|
712
|
+
(_J = config == null ? void 0 : config.buildMenu) == null ? void 0 : _J.call(config, groupBuilder);
|
|
609
713
|
let groups = groupBuilder.build();
|
|
610
714
|
if (filter) {
|
|
611
715
|
groups = groups.map((group) => {
|
|
@@ -861,7 +965,7 @@ class MenuView {
|
|
|
861
965
|
content: __privateGet$1(this, _content$1),
|
|
862
966
|
debounce: 20,
|
|
863
967
|
shouldShow(view2) {
|
|
864
|
-
if (
|
|
968
|
+
if (isInCodeBlock(view2.state.selection) || isInList(view2.state.selection))
|
|
865
969
|
return false;
|
|
866
970
|
const currentText = this.getContent(
|
|
867
971
|
view2,
|
|
@@ -920,11 +1024,11 @@ const BlockHandle = vue.defineComponent({
|
|
|
920
1024
|
required: true
|
|
921
1025
|
},
|
|
922
1026
|
addIcon: {
|
|
923
|
-
type:
|
|
1027
|
+
type: String,
|
|
924
1028
|
required: true
|
|
925
1029
|
},
|
|
926
1030
|
handleIcon: {
|
|
927
|
-
type:
|
|
1031
|
+
type: String,
|
|
928
1032
|
required: true
|
|
929
1033
|
}
|
|
930
1034
|
},
|
|
@@ -950,8 +1054,8 @@ const BlockHandle = vue.defineComponent({
|
|
|
950
1054
|
props.onAdd();
|
|
951
1055
|
}
|
|
952
1056
|
},
|
|
953
|
-
/* @__PURE__ */ vue.h(component.Icon, { icon: props.addIcon
|
|
954
|
-
), /* @__PURE__ */ vue.h("div", { class: "operation-item" }, /* @__PURE__ */ vue.h(component.Icon, { icon: props.handleIcon
|
|
1057
|
+
/* @__PURE__ */ vue.h(component.Icon, { icon: props.addIcon })
|
|
1058
|
+
), /* @__PURE__ */ vue.h("div", { class: "operation-item" }, /* @__PURE__ */ vue.h(component.Icon, { icon: props.handleIcon })));
|
|
955
1059
|
};
|
|
956
1060
|
}
|
|
957
1061
|
});
|
|
@@ -999,8 +1103,8 @@ class BlockHandleView {
|
|
|
999
1103
|
content.classList.add("milkdown-block-handle");
|
|
1000
1104
|
const app = vue.createApp(BlockHandle, {
|
|
1001
1105
|
onAdd: this.onAdd,
|
|
1002
|
-
addIcon: (_a = config == null ? void 0 : config.handleAddIcon) != null ? _a :
|
|
1003
|
-
handleIcon: (_b = config == null ? void 0 : config.handleDragIcon) != null ? _b :
|
|
1106
|
+
addIcon: (_a = config == null ? void 0 : config.handleAddIcon) != null ? _a : plusIcon,
|
|
1107
|
+
handleIcon: (_b = config == null ? void 0 : config.handleDragIcon) != null ? _b : menuIcon
|
|
1004
1108
|
});
|
|
1005
1109
|
app.mount(content);
|
|
1006
1110
|
__privateSet(this, _app, app);
|
|
@@ -1048,9 +1152,9 @@ function configureBlockHandle(ctx, config) {
|
|
|
1048
1152
|
});
|
|
1049
1153
|
}
|
|
1050
1154
|
|
|
1051
|
-
const
|
|
1052
|
-
editor.config((ctx) => configureBlockHandle(ctx, config)).config((ctx) => configureMenu(ctx, config)).use(menuAPI).use(block.block).use(menu);
|
|
1155
|
+
const blockEdit = (editor, config) => {
|
|
1156
|
+
editor.config(crepeFeatureConfig(CrepeFeature.BlockEdit)).config((ctx) => configureBlockHandle(ctx, config)).config((ctx) => configureMenu(ctx, config)).use(menuAPI).use(block.block).use(menu);
|
|
1053
1157
|
};
|
|
1054
1158
|
|
|
1055
|
-
exports.
|
|
1056
|
-
//# sourceMappingURL=index
|
|
1159
|
+
exports.blockEdit = blockEdit;
|
|
1160
|
+
//# sourceMappingURL=index.js.map
|