@milkdown/crepe 7.5.9 → 7.6.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/index-6oBtF_11.js +26 -0
- package/lib/cjs/{index-BIXWL4Or.js.map → index-6oBtF_11.js.map} +1 -1
- package/lib/cjs/{index-Dt55rF23.js → index-8COAwUnB.js} +5 -5
- package/lib/cjs/{index-Dt55rF23.js.map → index-8COAwUnB.js.map} +1 -1
- package/lib/cjs/{index-By3ewOiO.js → index-B4NxKjEA.js} +52 -52
- package/lib/cjs/index-B4NxKjEA.js.map +1 -0
- package/lib/cjs/{index-Dub20F3z.js → index-BOmVuuoY.js} +3 -3
- package/lib/cjs/{index-Dub20F3z.js.map → index-BOmVuuoY.js.map} +1 -1
- package/lib/cjs/{index-BuSAwj4j.js → index-C4JjdSvv.js} +3 -3
- package/lib/cjs/{index-BuSAwj4j.js.map → index-C4JjdSvv.js.map} +1 -1
- package/lib/cjs/index-C6EzkFZ_.js +39 -0
- package/lib/cjs/{index-DmOOfQPi.js.map → index-C6EzkFZ_.js.map} +1 -1
- package/lib/cjs/index-D0OPKY6K.js +65 -0
- package/lib/cjs/index-D0OPKY6K.js.map +1 -0
- package/lib/cjs/index-DkHBuNoK.js +176 -0
- package/lib/cjs/index-DkHBuNoK.js.map +1 -0
- package/lib/cjs/index-DnFbvtbD.js +278 -0
- package/lib/cjs/index-DnFbvtbD.js.map +1 -0
- package/lib/cjs/{index-AlHHvSR_.js → index-YUwSTgPK.js} +3 -3
- package/lib/cjs/{index-AlHHvSR_.js.map → index-YUwSTgPK.js.map} +1 -1
- package/lib/cjs/{index-A8IrOmzS.js → index-koRsjvWB.js} +116 -18
- package/lib/cjs/index-koRsjvWB.js.map +1 -0
- package/lib/cjs/index-nDWnWxJ8.js +38 -0
- package/lib/cjs/{index-CtNE-wHT.js.map → index-nDWnWxJ8.js.map} +1 -1
- package/lib/cjs/index.js +13 -148
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/inline-latex-CwU8Nsfj.js +54 -0
- package/lib/cjs/inline-latex-CwU8Nsfj.js.map +1 -0
- package/lib/cjs/{todoList-V4JWO5-M.js → todo-list-V4JWO5-M.js} +1 -1
- package/lib/cjs/todo-list-V4JWO5-M.js.map +1 -0
- package/lib/esm/index-BOzN8fKq.js +36 -0
- package/lib/esm/{index-BEWessT5.js.map → index-BOzN8fKq.js.map} +1 -1
- package/lib/esm/index-BUFg1FSH.js +172 -0
- package/lib/esm/index-BUFg1FSH.js.map +1 -0
- package/lib/esm/index-BxpDIDRS.js +63 -0
- package/lib/esm/index-BxpDIDRS.js.map +1 -0
- package/lib/esm/index-C5_dM0IB.js +276 -0
- package/lib/esm/index-C5_dM0IB.js.map +1 -0
- package/lib/esm/{index-DlX33Dj0.js → index-C7Xr_l-d.js} +5 -5
- package/lib/esm/{index-DlX33Dj0.js.map → index-C7Xr_l-d.js.map} +1 -1
- package/lib/esm/{index-CxJ9fxJm.js → index-C7_YCA3P.js} +3 -3
- package/lib/esm/{index-CxJ9fxJm.js.map → index-C7_YCA3P.js.map} +1 -1
- package/lib/esm/index-C8tiRHTF.js +37 -0
- package/lib/esm/{index-BDGHz9p-.js.map → index-C8tiRHTF.js.map} +1 -1
- package/lib/esm/{index-D6fLMv29.js → index-CD8fvrRC.js} +3 -3
- package/lib/esm/{index-D6fLMv29.js.map → index-CD8fvrRC.js.map} +1 -1
- package/lib/esm/index-CEup1V8i.js +24 -0
- package/lib/esm/{index-6VoEpEnX.js.map → index-CEup1V8i.js.map} +1 -1
- package/lib/esm/{index-kGl7HgN2.js → index-DroARb55.js} +117 -19
- package/lib/esm/index-DroARb55.js.map +1 -0
- package/lib/esm/{index-zKiGjwHz.js → index-HnGoJxjJ.js} +52 -52
- package/lib/esm/index-HnGoJxjJ.js.map +1 -0
- package/lib/esm/{index-DOrkOhki.js → index-WCe-Xh61.js} +3 -3
- package/lib/esm/{index-DOrkOhki.js.map → index-WCe-Xh61.js.map} +1 -1
- package/lib/esm/index.js +11 -150
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/inline-latex-BLd2QrJC.js +51 -0
- package/lib/esm/inline-latex-BLd2QrJC.js.map +1 -0
- package/lib/esm/{todoList-CAbx4396.js → todo-list-B78GeGtK.js} +2 -2
- package/lib/esm/todo-list-B78GeGtK.js.map +1 -0
- package/lib/theme/common/code-mirror.css +93 -34
- package/lib/theme/common/latex.css +44 -0
- package/lib/theme/common/style.css +1 -0
- package/lib/types/core/crepe.d.ts +2 -0
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +6 -2
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +4 -1
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/latex/block-latex.d.ts +2 -0
- package/lib/types/feature/latex/block-latex.d.ts.map +1 -0
- package/lib/types/feature/latex/index.d.ts +9 -0
- package/lib/types/feature/latex/index.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-latex.d.ts +3 -0
- package/lib/types/feature/latex/inline-latex.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/component.d.ts +15 -0
- package/lib/types/feature/latex/inline-tooltip/component.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/tooltip.d.ts +2 -0
- package/lib/types/feature/latex/inline-tooltip/tooltip.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/view.d.ts +13 -0
- package/lib/types/feature/latex/inline-tooltip/view.d.ts.map +1 -0
- package/lib/types/feature/latex/input-rule.d.ts +3 -0
- package/lib/types/feature/latex/input-rule.d.ts.map +1 -0
- package/lib/types/feature/latex/remark.d.ts +3 -0
- package/lib/types/feature/latex/remark.d.ts.map +1 -0
- package/lib/types/feature/shared.d.ts +1 -1
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +2 -0
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts +1 -0
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/{alignCenter.d.ts → align-center.d.ts} +1 -1
- package/lib/types/icons/align-center.d.ts.map +1 -0
- package/lib/types/icons/{alignLeft.d.ts → align-left.d.ts} +1 -1
- package/lib/types/icons/align-left.d.ts.map +1 -0
- package/lib/types/icons/{alignRight.d.ts → align-right.d.ts} +1 -1
- package/lib/types/icons/align-right.d.ts.map +1 -0
- package/lib/types/icons/{bulletList.d.ts → bullet-list.d.ts} +1 -1
- package/lib/types/icons/bullet-list.d.ts.map +1 -0
- package/lib/types/icons/{checkBoxChecked.d.ts → check-box-checked.d.ts} +1 -1
- package/lib/types/icons/check-box-checked.d.ts.map +1 -0
- package/lib/types/icons/{checkBoxUnchecked.d.ts → check-box-unchecked.d.ts} +1 -1
- package/lib/types/icons/check-box-unchecked.d.ts.map +1 -0
- package/lib/types/icons/{chevronDown.d.ts → chevron-down.d.ts} +1 -1
- package/lib/types/icons/chevron-down.d.ts.map +1 -0
- package/lib/types/icons/{dragHandle.d.ts → drag-handle.d.ts} +1 -1
- package/lib/types/icons/drag-handle.d.ts.map +1 -0
- package/lib/types/icons/functions.d.ts +2 -0
- package/lib/types/icons/functions.d.ts.map +1 -0
- package/lib/types/icons/index.d.ts +10 -10
- package/lib/types/icons/index.d.ts.map +1 -1
- package/lib/types/icons/{orderedList.d.ts → ordered-list.d.ts} +1 -1
- package/lib/types/icons/ordered-list.d.ts.map +1 -0
- package/lib/types/icons/{todoList.d.ts → todo-list.d.ts} +1 -1
- package/lib/types/icons/todo-list.d.ts.map +1 -0
- package/lib/types/icons/visibility-off.d.ts +2 -0
- package/lib/types/icons/visibility-off.d.ts.map +1 -0
- package/package.json +7 -4
- package/src/core/crepe.ts +19 -0
- package/src/feature/block-edit/handle/index.ts +1 -1
- package/src/feature/code-mirror/index.ts +23 -3
- package/src/feature/index.ts +8 -0
- package/src/feature/latex/block-latex.ts +25 -0
- package/src/feature/latex/index.ts +73 -0
- package/src/feature/latex/inline-latex.ts +55 -0
- package/src/feature/latex/inline-tooltip/component.ts +38 -0
- package/src/feature/latex/inline-tooltip/tooltip.ts +3 -0
- package/src/feature/latex/inline-tooltip/view.ts +122 -0
- package/src/feature/latex/input-rule.ts +25 -0
- package/src/feature/latex/remark.ts +35 -0
- package/src/feature/shared.ts +1 -1
- package/src/feature/toolbar/component.ts +91 -3
- package/src/feature/toolbar/index.ts +3 -1
- package/src/icons/functions.ts +15 -0
- package/src/icons/index.ts +10 -10
- package/src/icons/visibility-off.ts +14 -0
- package/src/theme/common/code-mirror.css +95 -34
- package/src/theme/common/latex.css +44 -0
- package/src/theme/common/style.css +1 -0
- package/lib/cjs/index-3mj4YaCA.js +0 -43
- package/lib/cjs/index-3mj4YaCA.js.map +0 -1
- package/lib/cjs/index-A8IrOmzS.js.map +0 -1
- package/lib/cjs/index-BIXWL4Or.js +0 -26
- package/lib/cjs/index-By3ewOiO.js.map +0 -1
- package/lib/cjs/index-CtNE-wHT.js +0 -38
- package/lib/cjs/index-DmOOfQPi.js +0 -39
- package/lib/cjs/todoList-V4JWO5-M.js.map +0 -1
- package/lib/esm/index-6VoEpEnX.js +0 -24
- package/lib/esm/index-BB3Rq6BU.js +0 -41
- package/lib/esm/index-BB3Rq6BU.js.map +0 -1
- package/lib/esm/index-BDGHz9p-.js +0 -37
- package/lib/esm/index-BEWessT5.js +0 -36
- package/lib/esm/index-kGl7HgN2.js.map +0 -1
- package/lib/esm/index-zKiGjwHz.js.map +0 -1
- package/lib/esm/todoList-CAbx4396.js.map +0 -1
- package/lib/types/icons/alignCenter.d.ts.map +0 -1
- package/lib/types/icons/alignLeft.d.ts.map +0 -1
- package/lib/types/icons/alignRight.d.ts.map +0 -1
- package/lib/types/icons/bulletList.d.ts.map +0 -1
- package/lib/types/icons/checkBoxChecked.d.ts.map +0 -1
- package/lib/types/icons/checkBoxUnchecked.d.ts.map +0 -1
- package/lib/types/icons/chevronDown.d.ts.map +0 -1
- package/lib/types/icons/dragHandle.d.ts.map +0 -1
- package/lib/types/icons/orderedList.d.ts.map +0 -1
- package/lib/types/icons/todoList.d.ts.map +0 -1
- /package/src/icons/{alignCenter.ts → align-center.ts} +0 -0
- /package/src/icons/{alignLeft.ts → align-left.ts} +0 -0
- /package/src/icons/{alignRight.ts → align-right.ts} +0 -0
- /package/src/icons/{bulletList.ts → bullet-list.ts} +0 -0
- /package/src/icons/{checkBoxChecked.ts → check-box-checked.ts} +0 -0
- /package/src/icons/{checkBoxUnchecked.ts → check-box-unchecked.ts} +0 -0
- /package/src/icons/{chevronDown.ts → chevron-down.ts} +0 -0
- /package/src/icons/{dragHandle.ts → drag-handle.ts} +0 -0
- /package/src/icons/{orderedList.ts → ordered-list.ts} +0 -0
- /package/src/icons/{todoList.ts → todo-list.ts} +0 -0
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
import { tooltipFactory, TooltipProvider } from '@milkdown/kit/plugin/tooltip';
|
|
2
|
-
import { TextSelection } from '@milkdown/kit/prose/state';
|
|
3
|
-
import { d as defIfNotExists } from './index-
|
|
4
|
-
import { c, useUpdate, useEffect
|
|
2
|
+
import { NodeSelection, TextSelection } from '@milkdown/kit/prose/state';
|
|
3
|
+
import { d as defIfNotExists } from './index-CD8fvrRC.js';
|
|
4
|
+
import { html, c, useUpdate, useEffect } from 'atomico';
|
|
5
5
|
import { editorViewCtx, commandsCtx } from '@milkdown/kit/core';
|
|
6
6
|
import { strongSchema, emphasisSchema, inlineCodeSchema, linkSchema, toggleStrongCommand, toggleEmphasisCommand, toggleInlineCodeCommand } from '@milkdown/kit/preset/commonmark';
|
|
7
7
|
import clsx from 'clsx';
|
|
8
8
|
import { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip';
|
|
9
9
|
import { strikethroughSchema, toggleStrikethroughCommand } from '@milkdown/kit/preset/gfm';
|
|
10
|
-
import { C as boldIcon, D as italicIcon, E as strikethroughIcon, y as codeIcon, F as linkIcon } from './
|
|
10
|
+
import { C as boldIcon, D as italicIcon, E as strikethroughIcon, y as codeIcon, F as linkIcon } from './todo-list-B78GeGtK.js';
|
|
11
|
+
import { m as mathInlineSchema } from './inline-latex-BLd2QrJC.js';
|
|
12
|
+
import { F as FeaturesCtx, C as CrepeFeature } from './index-BUFg1FSH.js';
|
|
13
|
+
import '@milkdown/kit/utils';
|
|
14
|
+
import 'katex';
|
|
15
|
+
import '@milkdown/kit/plugin/history';
|
|
16
|
+
import '@milkdown/kit/plugin/indent';
|
|
17
|
+
import '@milkdown/kit/plugin/clipboard';
|
|
18
|
+
import '@milkdown/kit/plugin/trailing';
|
|
19
|
+
import '@milkdown/kit/ctx';
|
|
20
|
+
import '@milkdown/kit/plugin/listener';
|
|
21
|
+
|
|
22
|
+
const functionsIcon = html`
|
|
23
|
+
<svg
|
|
24
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
25
|
+
width="32"
|
|
26
|
+
height="32"
|
|
27
|
+
viewBox="0 0 24 24"
|
|
28
|
+
>
|
|
29
|
+
<path
|
|
30
|
+
fill="currentColor"
|
|
31
|
+
d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
`;
|
|
11
35
|
|
|
12
36
|
const toolbarComponent = ({
|
|
13
37
|
ctx,
|
|
14
38
|
hide,
|
|
15
39
|
show,
|
|
16
|
-
config
|
|
40
|
+
config,
|
|
41
|
+
selection
|
|
17
42
|
}) => {
|
|
18
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
43
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
19
44
|
const update = useUpdate();
|
|
20
45
|
useEffect(() => {
|
|
21
46
|
update();
|
|
@@ -26,13 +51,73 @@ const toolbarComponent = ({
|
|
|
26
51
|
update();
|
|
27
52
|
};
|
|
28
53
|
const isActive = (mark) => {
|
|
29
|
-
if (!ctx) return false;
|
|
54
|
+
if (!ctx || !selection) return false;
|
|
30
55
|
const view = ctx.get(editorViewCtx);
|
|
31
56
|
const {
|
|
32
|
-
state: { doc
|
|
57
|
+
state: { doc }
|
|
33
58
|
} = view;
|
|
34
59
|
return doc.rangeHasMark(selection.from, selection.to, mark);
|
|
35
60
|
};
|
|
61
|
+
const containsNode = (node) => {
|
|
62
|
+
if (!ctx || !selection) return false;
|
|
63
|
+
const view = ctx.get(editorViewCtx);
|
|
64
|
+
const {
|
|
65
|
+
state: { doc }
|
|
66
|
+
} = view;
|
|
67
|
+
if (selection instanceof NodeSelection) {
|
|
68
|
+
return selection.node.type === node;
|
|
69
|
+
}
|
|
70
|
+
const { from, to } = selection;
|
|
71
|
+
let hasNode = false;
|
|
72
|
+
doc.nodesBetween(from, to, (n) => {
|
|
73
|
+
if (n.type === node) {
|
|
74
|
+
hasNode = true;
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
});
|
|
79
|
+
return hasNode;
|
|
80
|
+
};
|
|
81
|
+
const flags = ctx == null ? undefined : ctx.get(FeaturesCtx);
|
|
82
|
+
const isLatexEnabled = flags == null ? undefined : flags.includes(CrepeFeature.Latex);
|
|
83
|
+
const toggleLatex = (ctx2) => {
|
|
84
|
+
const hasLatex = containsNode(mathInlineSchema.type(ctx2));
|
|
85
|
+
const view = ctx2.get(editorViewCtx);
|
|
86
|
+
const { selection: selection2, doc, tr } = view.state;
|
|
87
|
+
if (!hasLatex) {
|
|
88
|
+
const text = doc.textBetween(selection2.from, selection2.to);
|
|
89
|
+
let _tr2 = tr.replaceSelectionWith(
|
|
90
|
+
mathInlineSchema.type(ctx2).create({
|
|
91
|
+
value: text
|
|
92
|
+
})
|
|
93
|
+
);
|
|
94
|
+
view.dispatch(
|
|
95
|
+
_tr2.setSelection(NodeSelection.create(_tr2.doc, selection2.from))
|
|
96
|
+
);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const { from, to } = selection2;
|
|
100
|
+
let pos = -1;
|
|
101
|
+
let node = null;
|
|
102
|
+
doc.nodesBetween(from, to, (n, p) => {
|
|
103
|
+
if (node) return false;
|
|
104
|
+
if (n.type === mathInlineSchema.type(ctx2)) {
|
|
105
|
+
pos = p;
|
|
106
|
+
node = n;
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
});
|
|
111
|
+
if (!node || pos < 0) return;
|
|
112
|
+
let _tr = tr.delete(pos, pos + 1);
|
|
113
|
+
const content = node.attrs.value;
|
|
114
|
+
_tr = _tr.insertText(content, pos);
|
|
115
|
+
view.dispatch(
|
|
116
|
+
_tr.setSelection(
|
|
117
|
+
TextSelection.create(_tr.doc, from, to + content.length - 1)
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
};
|
|
36
121
|
return html`<host>
|
|
37
122
|
<button
|
|
38
123
|
type="button"
|
|
@@ -45,7 +130,7 @@ const toolbarComponent = ({
|
|
|
45
130
|
commands.call(toggleStrongCommand.key);
|
|
46
131
|
})}
|
|
47
132
|
>
|
|
48
|
-
${(_b = (_a = config == null ?
|
|
133
|
+
${(_b = (_a = config == null ? undefined : config.boldIcon) == null ? undefined : _a.call(config)) != null ? _b : boldIcon}
|
|
49
134
|
</button>
|
|
50
135
|
<button
|
|
51
136
|
type="button"
|
|
@@ -58,7 +143,7 @@ const toolbarComponent = ({
|
|
|
58
143
|
commands.call(toggleEmphasisCommand.key);
|
|
59
144
|
})}
|
|
60
145
|
>
|
|
61
|
-
${(_d = (_c = config == null ?
|
|
146
|
+
${(_d = (_c = config == null ? undefined : config.italicIcon) == null ? undefined : _c.call(config)) != null ? _d : italicIcon}
|
|
62
147
|
</button>
|
|
63
148
|
<button
|
|
64
149
|
type="button"
|
|
@@ -71,7 +156,7 @@ const toolbarComponent = ({
|
|
|
71
156
|
commands.call(toggleStrikethroughCommand.key);
|
|
72
157
|
})}
|
|
73
158
|
>
|
|
74
|
-
${(_f = (_e = config == null ?
|
|
159
|
+
${(_f = (_e = config == null ? undefined : config.strikethroughIcon) == null ? undefined : _e.call(config)) != null ? _f : strikethroughIcon}
|
|
75
160
|
</button>
|
|
76
161
|
<div class="divider"></div>
|
|
77
162
|
<button
|
|
@@ -85,8 +170,18 @@ const toolbarComponent = ({
|
|
|
85
170
|
commands.call(toggleInlineCodeCommand.key);
|
|
86
171
|
})}
|
|
87
172
|
>
|
|
88
|
-
${(_h = (_g = config == null ?
|
|
173
|
+
${(_h = (_g = config == null ? undefined : config.codeIcon) == null ? undefined : _g.call(config)) != null ? _h : codeIcon}
|
|
89
174
|
</button>
|
|
175
|
+
${isLatexEnabled && html`<button
|
|
176
|
+
type="button"
|
|
177
|
+
class=${clsx(
|
|
178
|
+
"toolbar-item",
|
|
179
|
+
ctx && containsNode(mathInlineSchema.type(ctx)) && "active"
|
|
180
|
+
)}
|
|
181
|
+
onmousedown=${onClick(toggleLatex)}
|
|
182
|
+
>
|
|
183
|
+
${(_j = (_i = config == null ? undefined : config.latexIcon) == null ? undefined : _i.call(config)) != null ? _j : functionsIcon}
|
|
184
|
+
</button>`}
|
|
90
185
|
<button
|
|
91
186
|
type="button"
|
|
92
187
|
class=${clsx(
|
|
@@ -95,16 +190,16 @@ const toolbarComponent = ({
|
|
|
95
190
|
)}
|
|
96
191
|
onmousedown=${onClick((ctx2) => {
|
|
97
192
|
const view = ctx2.get(editorViewCtx);
|
|
98
|
-
const { selection } = view.state;
|
|
193
|
+
const { selection: selection2 } = view.state;
|
|
99
194
|
if (isActive(linkSchema.type(ctx2))) {
|
|
100
|
-
ctx2.get(linkTooltipAPI.key).removeLink(
|
|
195
|
+
ctx2.get(linkTooltipAPI.key).removeLink(selection2.from, selection2.to);
|
|
101
196
|
return;
|
|
102
197
|
}
|
|
103
|
-
ctx2.get(linkTooltipAPI.key).addLink(
|
|
104
|
-
hide == null ?
|
|
198
|
+
ctx2.get(linkTooltipAPI.key).addLink(selection2.from, selection2.to);
|
|
199
|
+
hide == null ? undefined : hide();
|
|
105
200
|
})}
|
|
106
201
|
>
|
|
107
|
-
${(
|
|
202
|
+
${(_l = (_k = config == null ? undefined : config.linkIcon) == null ? undefined : _k.call(config)) != null ? _l : linkIcon}
|
|
108
203
|
</button>
|
|
109
204
|
</host>`;
|
|
110
205
|
};
|
|
@@ -112,7 +207,8 @@ toolbarComponent.props = {
|
|
|
112
207
|
ctx: Object,
|
|
113
208
|
hide: Function,
|
|
114
209
|
show: Boolean,
|
|
115
|
-
config: Object
|
|
210
|
+
config: Object,
|
|
211
|
+
selection: Object
|
|
116
212
|
};
|
|
117
213
|
const ToolbarElement = c(toolbarComponent);
|
|
118
214
|
|
|
@@ -131,6 +227,7 @@ class ToolbarView {
|
|
|
131
227
|
__privateAdd(this, _content);
|
|
132
228
|
this.update = (view, prevState) => {
|
|
133
229
|
__privateGet(this, _tooltipProvider).update(view, prevState);
|
|
230
|
+
__privateGet(this, _content).selection = view.state.selection;
|
|
134
231
|
};
|
|
135
232
|
this.destroy = () => {
|
|
136
233
|
__privateGet(this, _tooltipProvider).destroy();
|
|
@@ -144,6 +241,7 @@ class ToolbarView {
|
|
|
144
241
|
__privateGet(this, _content).ctx = ctx;
|
|
145
242
|
__privateGet(this, _content).hide = this.hide;
|
|
146
243
|
__privateGet(this, _content).config = config;
|
|
244
|
+
__privateGet(this, _content).selection = view.state.selection;
|
|
147
245
|
__privateSet(this, _tooltipProvider, new TooltipProvider({
|
|
148
246
|
content: __privateGet(this, _content),
|
|
149
247
|
debounce: 20,
|
|
@@ -183,4 +281,4 @@ const defineFeature = (editor, config) => {
|
|
|
183
281
|
};
|
|
184
282
|
|
|
185
283
|
export { defineFeature };
|
|
186
|
-
//# sourceMappingURL=index-
|
|
284
|
+
//# sourceMappingURL=index-DroARb55.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-DroARb55.js","sources":["../../src/icons/functions.ts","../../src/feature/toolbar/component.ts","../../src/feature/toolbar/index.ts"],"sourcesContent":["import { html } from 'atomico'\n\nexport const functionsIcon = html`\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"32\"\n height=\"32\"\n viewBox=\"0 0 24 24\"\n >\n <path\n fill=\"currentColor\"\n d=\"M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z\"\n />\n </svg>\n`\n","import type { Component } from 'atomico'\nimport { c, html, useEffect, useUpdate } from 'atomico'\nimport type { Ctx } from '@milkdown/kit/ctx'\nimport { commandsCtx, editorViewCtx } from '@milkdown/kit/core'\nimport {\n emphasisSchema,\n inlineCodeSchema,\n linkSchema,\n strongSchema,\n toggleEmphasisCommand,\n toggleInlineCodeCommand,\n toggleStrongCommand,\n} from '@milkdown/kit/preset/commonmark'\nimport type { MarkType, Node, NodeType } from '@milkdown/kit/prose/model'\nimport type { Selection } from '@milkdown/kit/prose/state'\nimport clsx from 'clsx'\nimport { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip'\nimport {\n strikethroughSchema,\n toggleStrikethroughCommand,\n} from '@milkdown/kit/preset/gfm'\nimport {\n boldIcon,\n codeIcon,\n italicIcon,\n linkIcon,\n strikethroughIcon,\n} from '../../icons'\nimport type { ToolbarFeatureConfig } from './index'\nimport { functionsIcon } from '../../icons/functions'\nimport { NodeSelection, TextSelection } from '@milkdown/kit/prose/state'\nimport { mathInlineSchema } from '../latex/inline-latex'\nimport { FeaturesCtx } from '../../core/slice'\nimport { CrepeFeature } from '../..'\n\nexport interface ToolbarProps {\n ctx: Ctx\n hide: () => void\n show: boolean\n selection: Selection\n config?: ToolbarFeatureConfig\n}\n\nexport const toolbarComponent: Component<ToolbarProps> = ({\n ctx,\n hide,\n show,\n config,\n selection,\n}) => {\n const update = useUpdate()\n useEffect(() => {\n update()\n }, [show])\n\n const onClick = (fn: (ctx: Ctx) => void) => (e: MouseEvent) => {\n e.preventDefault()\n ctx && fn(ctx)\n update()\n }\n\n const isActive = (mark: MarkType) => {\n if (!ctx || !selection) return false\n const view = ctx.get(editorViewCtx)\n const {\n state: { doc },\n } = view\n return doc.rangeHasMark(selection.from, selection.to, mark)\n }\n\n const containsNode = (node: NodeType) => {\n if (!ctx || !selection) return false\n const view = ctx.get(editorViewCtx)\n const {\n state: { doc },\n } = view\n if (selection instanceof NodeSelection) {\n return selection.node.type === node\n }\n\n const { from, to } = selection\n\n let hasNode = false\n doc.nodesBetween(from, to, (n) => {\n if (n.type === node) {\n hasNode = true\n return false\n }\n return true\n })\n\n return hasNode\n }\n\n const flags = ctx?.get(FeaturesCtx)\n const isLatexEnabled = flags?.includes(CrepeFeature.Latex)\n\n const toggleLatex = (ctx: Ctx) => {\n const hasLatex = containsNode(mathInlineSchema.type(ctx))\n const view = ctx.get(editorViewCtx)\n const { selection, doc, tr } = view.state\n if (!hasLatex) {\n const text = doc.textBetween(selection.from, selection.to)\n let _tr = tr.replaceSelectionWith(\n mathInlineSchema.type(ctx).create({\n value: text,\n })\n )\n view.dispatch(\n _tr.setSelection(NodeSelection.create(_tr.doc, selection.from))\n )\n return\n }\n\n const { from, to } = selection\n let pos = -1\n let node: Node | null = null\n doc.nodesBetween(from, to, (n, p) => {\n if (node) return false\n if (n.type === mathInlineSchema.type(ctx)) {\n pos = p\n node = n\n return false\n }\n return true\n })\n if (!node || pos < 0) return\n\n let _tr = tr.delete(pos, pos + 1)\n const content = (node as Node).attrs.value\n _tr = _tr.insertText(content, pos)\n view.dispatch(\n _tr.setSelection(\n TextSelection.create(_tr.doc, from, to + content.length - 1)\n )\n )\n }\n\n return html`<host>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(strongSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleStrongCommand.key)\n })}\n >\n ${config?.boldIcon?.() ?? boldIcon}\n </button>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(emphasisSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleEmphasisCommand.key)\n })}\n >\n ${config?.italicIcon?.() ?? italicIcon}\n </button>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(strikethroughSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleStrikethroughCommand.key)\n })}\n >\n ${config?.strikethroughIcon?.() ?? strikethroughIcon}\n </button>\n <div class=\"divider\"></div>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(inlineCodeSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleInlineCodeCommand.key)\n })}\n >\n ${config?.codeIcon?.() ?? codeIcon}\n </button>\n ${isLatexEnabled &&\n html`<button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && containsNode(mathInlineSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick(toggleLatex)}\n >\n ${config?.latexIcon?.() ?? functionsIcon}\n </button>`}\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(linkSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const view = ctx.get(editorViewCtx)\n const { selection } = view.state\n\n if (isActive(linkSchema.type(ctx))) {\n ctx.get(linkTooltipAPI.key).removeLink(selection.from, selection.to)\n return\n }\n\n ctx.get(linkTooltipAPI.key).addLink(selection.from, selection.to)\n hide?.()\n })}\n >\n ${config?.linkIcon?.() ?? linkIcon}\n </button>\n </host>`\n}\n\ntoolbarComponent.props = {\n ctx: Object,\n hide: Function,\n show: Boolean,\n config: Object,\n selection: Object,\n}\n\nexport const ToolbarElement = c(toolbarComponent)\n","import { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'\nimport type { EditorState, PluginView } from '@milkdown/kit/prose/state'\nimport { TextSelection } from '@milkdown/kit/prose/state'\nimport type { Ctx } from '@milkdown/kit/ctx'\nimport type { EditorView } from '@milkdown/kit/prose/view'\nimport type { AtomicoThis } from 'atomico/types/dom'\nimport type { DefineFeature, Icon } from '../shared'\nimport { defIfNotExists } from '../../utils'\nimport type { ToolbarProps } from './component'\nimport { ToolbarElement } from './component'\n\ninterface ToolbarConfig {\n boldIcon: Icon\n codeIcon: Icon\n italicIcon: Icon\n linkIcon: Icon\n strikethroughIcon: Icon\n latexIcon: Icon\n}\n\nexport type ToolbarFeatureConfig = Partial<ToolbarConfig>\n\nconst toolbar = tooltipFactory('CREPE_TOOLBAR')\n\nclass ToolbarView implements PluginView {\n #tooltipProvider: TooltipProvider\n #content: AtomicoThis<ToolbarProps>\n constructor(ctx: Ctx, view: EditorView, config?: ToolbarFeatureConfig) {\n const content = new ToolbarElement()\n this.#content = content\n this.#content.ctx = ctx\n this.#content.hide = this.hide\n this.#content.config = config\n this.#content.selection = view.state.selection\n this.#tooltipProvider = new TooltipProvider({\n content: this.#content,\n debounce: 20,\n offset: 10,\n shouldShow(view: EditorView) {\n const { doc, selection } = view.state\n const { empty, from, to } = selection\n\n const isEmptyTextBlock =\n !doc.textBetween(from, to).length &&\n selection instanceof TextSelection\n\n const isNotTextBlock = !(selection instanceof TextSelection)\n\n const activeElement = (view.dom.getRootNode() as ShadowRoot | Document)\n .activeElement\n const isTooltipChildren = content.contains(activeElement)\n\n const notHasFocus = !view.hasFocus() && !isTooltipChildren\n\n const isReadonly = !view.editable\n\n if (\n notHasFocus ||\n isNotTextBlock ||\n empty ||\n isEmptyTextBlock ||\n isReadonly\n )\n return false\n\n return true\n },\n })\n this.#tooltipProvider.onShow = () => {\n this.#content.show = true\n }\n this.#tooltipProvider.onHide = () => {\n this.#content.show = false\n }\n this.update(view)\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#tooltipProvider.update(view, prevState)\n this.#content.selection = view.state.selection\n }\n\n destroy = () => {\n this.#tooltipProvider.destroy()\n this.#content.remove()\n }\n\n hide = () => {\n this.#tooltipProvider.hide()\n }\n}\n\ndefIfNotExists('milkdown-toolbar', ToolbarElement)\nexport const defineFeature: DefineFeature<ToolbarFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n ctx.set(toolbar.key, {\n view: (view) => new ToolbarView(ctx, view, config),\n })\n })\n .use(toolbar)\n}\n"],"names":["ctx","selection","_tr","view"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEO,MAAM,aAAgB,GAAA,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAAA;;ACyCtB,MAAM,mBAA4C,CAAC;AAAA,EACxD,GAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAM,KAAA;AAjDN,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AAkDE,EAAA,MAAM,SAAS,SAAU,EAAA;AACzB,EAAA,SAAA,CAAU,MAAM;AACd,IAAO,MAAA,EAAA;AAAA,GACT,EAAG,CAAC,IAAI,CAAC,CAAA;AAET,EAAA,MAAM,OAAU,GAAA,CAAC,EAA2B,KAAA,CAAC,CAAkB,KAAA;AAC7D,IAAA,CAAA,CAAE,cAAe,EAAA;AACjB,IAAA,GAAA,IAAO,GAAG,GAAG,CAAA;AACb,IAAO,MAAA,EAAA;AAAA,GACT;AAEA,EAAM,MAAA,QAAA,GAAW,CAAC,IAAmB,KAAA;AACnC,IAAA,IAAI,CAAC,GAAA,IAAO,CAAC,SAAA,EAAkB,OAAA,KAAA;AAC/B,IAAM,MAAA,IAAA,GAAO,GAAI,CAAA,GAAA,CAAI,aAAa,CAAA;AAClC,IAAM,MAAA;AAAA,MACJ,KAAA,EAAO,EAAE,GAAI;AAAA,KACX,GAAA,IAAA;AAC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,KAAK,CAAA,QAAA,MAAc,CAAC,iBAAA;AAEzC,QAAM,MAAA,UAAA,GAAa,CAACA,KAAK,CAAA,QAAA;AAEzB,QACE,IAAA,WAAA,IACA,cACA,IAAA,KAAA,IACA,gBACA,IAAA,UAAA;AAEA,UAAO,OAAA,KAAA;AAET,QAAO,OAAA,IAAA;AAAA;AACT,KACD,CAAA,CAAA;AACD,IAAK,YAAA,CAAA,IAAA,EAAA,gBAAA,CAAA,CAAiB,SAAS,MAAM;AACnC,MAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAO,GAAA,IAAA;AAAA,KACvB;AACA,IAAK,YAAA,CAAA,IAAA,EAAA,gBAAA,CAAA,CAAiB,SAAS,MAAM;AACnC,MAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAO,GAAA,KAAA;AAAA,KACvB;AACA,IAAA,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA;AAgBpB;AAjEE,gBAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AAkEF,cAAA,CAAe,oBAAoB,cAAc,CAAA;AACpC,MAAA,aAAA,GAAqD,CAChE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAI,GAAA,CAAA,GAAA,CAAI,QAAQ,GAAK,EAAA;AAAA,MACnB,MAAM,CAAC,IAAA,KAAS,IAAI,WAAY,CAAA,GAAA,EAAK,MAAM,MAAM;AAAA,KAClD,CAAA;AAAA,GACF,CACA,CAAA,GAAA,CAAI,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -5,11 +5,11 @@ import { paragraphSchema, headingSchema, blockquoteSchema, hrSchema, bulletListS
|
|
|
5
5
|
import { findParent } from '@milkdown/kit/prose';
|
|
6
6
|
import { slashFactory, SlashProvider } from '@milkdown/kit/plugin/slash';
|
|
7
7
|
import { $ctx } from '@milkdown/kit/utils';
|
|
8
|
-
import { d as defIfNotExists, i as isInCodeBlock, a as isInList } from './index-
|
|
8
|
+
import { d as defIfNotExists, i as isInCodeBlock, a as isInList } from './index-CD8fvrRC.js';
|
|
9
9
|
import { c, useMemo, useHost, useState, useRef, useCallback, useEffect, html } from 'atomico';
|
|
10
10
|
import { imageBlockSchema } from '@milkdown/kit/component/image-block';
|
|
11
11
|
import { createTable } from '@milkdown/kit/preset/gfm';
|
|
12
|
-
import { t as textIcon, k as h1Icon, l as h2Icon, m as h3Icon, n as h4Icon, o as h5Icon, p as h6Icon, q as quoteIcon, u as dividerIcon, v as bulletListIcon, w as orderedListIcon, x as todoListIcon, i as imageIcon, y as codeIcon, z as tableIcon, A as plusIcon, B as menuIcon } from './
|
|
12
|
+
import { t as textIcon, k as h1Icon, l as h2Icon, m as h3Icon, n as h4Icon, o as h5Icon, p as h6Icon, q as quoteIcon, u as dividerIcon, v as bulletListIcon, w as orderedListIcon, x as todoListIcon, i as imageIcon, y as codeIcon, z as tableIcon, A as plusIcon, B as menuIcon } from './todo-list-B78GeGtK.js';
|
|
13
13
|
import { findWrapping } from '@milkdown/kit/prose/transform';
|
|
14
14
|
|
|
15
15
|
function clearRange(tr) {
|
|
@@ -117,9 +117,9 @@ _getGroupInstance = new WeakMap();
|
|
|
117
117
|
function getGroups(filter, config) {
|
|
118
118
|
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;
|
|
119
119
|
const groupBuilder = new GroupBuilder();
|
|
120
|
-
groupBuilder.addGroup("text", (_a = config == null ?
|
|
121
|
-
label: (_b = config == null ?
|
|
122
|
-
icon: (_d = (_c = config == null ?
|
|
120
|
+
groupBuilder.addGroup("text", (_a = config == null ? undefined : config.slashMenuTextGroupLabel) != null ? _a : "Text").addItem("text", {
|
|
121
|
+
label: (_b = config == null ? undefined : config.slashMenuTextGroupLabel) != null ? _b : "Text",
|
|
122
|
+
icon: (_d = (_c = config == null ? undefined : config.slashMenuTextIcon) == null ? undefined : _c.call(config)) != null ? _d : textIcon,
|
|
123
123
|
onRun: (ctx) => {
|
|
124
124
|
const view = ctx.get(editorViewCtx);
|
|
125
125
|
const { dispatch, state } = view;
|
|
@@ -127,8 +127,8 @@ function getGroups(filter, config) {
|
|
|
127
127
|
command(state, dispatch);
|
|
128
128
|
}
|
|
129
129
|
}).addItem("h1", {
|
|
130
|
-
label: (_e = config == null ?
|
|
131
|
-
icon: (_g = (_f = config == null ?
|
|
130
|
+
label: (_e = config == null ? undefined : config.slashMenuH1Label) != null ? _e : "Heading 1",
|
|
131
|
+
icon: (_g = (_f = config == null ? undefined : config.slashMenuH1Icon) == null ? undefined : _f.call(config)) != null ? _g : h1Icon,
|
|
132
132
|
onRun: (ctx) => {
|
|
133
133
|
const view = ctx.get(editorViewCtx);
|
|
134
134
|
const { dispatch, state } = view;
|
|
@@ -138,8 +138,8 @@ function getGroups(filter, config) {
|
|
|
138
138
|
command(state, dispatch);
|
|
139
139
|
}
|
|
140
140
|
}).addItem("h2", {
|
|
141
|
-
label: (_h = config == null ?
|
|
142
|
-
icon: (_j = (_i = config == null ?
|
|
141
|
+
label: (_h = config == null ? undefined : config.slashMenuH2Label) != null ? _h : "Heading 2",
|
|
142
|
+
icon: (_j = (_i = config == null ? undefined : config.slashMenuH2Icon) == null ? undefined : _i.call(config)) != null ? _j : h2Icon,
|
|
143
143
|
onRun: (ctx) => {
|
|
144
144
|
const view = ctx.get(editorViewCtx);
|
|
145
145
|
const { dispatch, state } = view;
|
|
@@ -149,8 +149,8 @@ function getGroups(filter, config) {
|
|
|
149
149
|
command(state, dispatch);
|
|
150
150
|
}
|
|
151
151
|
}).addItem("h3", {
|
|
152
|
-
label: (_k = config == null ?
|
|
153
|
-
icon: (_m = (_l = config == null ?
|
|
152
|
+
label: (_k = config == null ? undefined : config.slashMenuH3Label) != null ? _k : "Heading 3",
|
|
153
|
+
icon: (_m = (_l = config == null ? undefined : config.slashMenuH3Icon) == null ? undefined : _l.call(config)) != null ? _m : h3Icon,
|
|
154
154
|
onRun: (ctx) => {
|
|
155
155
|
const view = ctx.get(editorViewCtx);
|
|
156
156
|
const { dispatch, state } = view;
|
|
@@ -160,8 +160,8 @@ function getGroups(filter, config) {
|
|
|
160
160
|
command(state, dispatch);
|
|
161
161
|
}
|
|
162
162
|
}).addItem("h4", {
|
|
163
|
-
label: (_n = config == null ?
|
|
164
|
-
icon: (_p = (_o = config == null ?
|
|
163
|
+
label: (_n = config == null ? undefined : config.slashMenuH4Label) != null ? _n : "Heading 4",
|
|
164
|
+
icon: (_p = (_o = config == null ? undefined : config.slashMenuH4Icon) == null ? undefined : _o.call(config)) != null ? _p : h4Icon,
|
|
165
165
|
onRun: (ctx) => {
|
|
166
166
|
const view = ctx.get(editorViewCtx);
|
|
167
167
|
const { dispatch, state } = view;
|
|
@@ -171,8 +171,8 @@ function getGroups(filter, config) {
|
|
|
171
171
|
command(state, dispatch);
|
|
172
172
|
}
|
|
173
173
|
}).addItem("h5", {
|
|
174
|
-
label: (_q = config == null ?
|
|
175
|
-
icon: (_s = (_r = config == null ?
|
|
174
|
+
label: (_q = config == null ? undefined : config.slashMenuH5Label) != null ? _q : "Heading 5",
|
|
175
|
+
icon: (_s = (_r = config == null ? undefined : config.slashMenuH5Icon) == null ? undefined : _r.call(config)) != null ? _s : h5Icon,
|
|
176
176
|
onRun: (ctx) => {
|
|
177
177
|
const view = ctx.get(editorViewCtx);
|
|
178
178
|
const { dispatch, state } = view;
|
|
@@ -182,8 +182,8 @@ function getGroups(filter, config) {
|
|
|
182
182
|
command(state, dispatch);
|
|
183
183
|
}
|
|
184
184
|
}).addItem("h6", {
|
|
185
|
-
label: (_t = config == null ?
|
|
186
|
-
icon: (_v = (_u = config == null ?
|
|
185
|
+
label: (_t = config == null ? undefined : config.slashMenuH6Label) != null ? _t : "Heading 6",
|
|
186
|
+
icon: (_v = (_u = config == null ? undefined : config.slashMenuH6Icon) == null ? undefined : _u.call(config)) != null ? _v : h6Icon,
|
|
187
187
|
onRun: (ctx) => {
|
|
188
188
|
const view = ctx.get(editorViewCtx);
|
|
189
189
|
const { dispatch, state } = view;
|
|
@@ -193,8 +193,8 @@ function getGroups(filter, config) {
|
|
|
193
193
|
command(state, dispatch);
|
|
194
194
|
}
|
|
195
195
|
}).addItem("quote", {
|
|
196
|
-
label: (_w = config == null ?
|
|
197
|
-
icon: (_y = (_x = config == null ?
|
|
196
|
+
label: (_w = config == null ? undefined : config.slashMenuQuoteLabel) != null ? _w : "Quote",
|
|
197
|
+
icon: (_y = (_x = config == null ? undefined : config.slashMenuQuoteIcon) == null ? undefined : _x.call(config)) != null ? _y : quoteIcon,
|
|
198
198
|
onRun: (ctx) => {
|
|
199
199
|
const view = ctx.get(editorViewCtx);
|
|
200
200
|
const { dispatch, state } = view;
|
|
@@ -204,8 +204,8 @@ function getGroups(filter, config) {
|
|
|
204
204
|
command(state, dispatch);
|
|
205
205
|
}
|
|
206
206
|
}).addItem("divider", {
|
|
207
|
-
label: (_z = config == null ?
|
|
208
|
-
icon: (_B = (_A = config == null ?
|
|
207
|
+
label: (_z = config == null ? undefined : config.slashMenuDividerLabel) != null ? _z : "Divider",
|
|
208
|
+
icon: (_B = (_A = config == null ? undefined : config.slashMenuDividerIcon) == null ? undefined : _A.call(config)) != null ? _B : dividerIcon,
|
|
209
209
|
onRun: (ctx) => {
|
|
210
210
|
const view = ctx.get(editorViewCtx);
|
|
211
211
|
const { dispatch, state } = view;
|
|
@@ -213,9 +213,9 @@ function getGroups(filter, config) {
|
|
|
213
213
|
command(state, dispatch);
|
|
214
214
|
}
|
|
215
215
|
});
|
|
216
|
-
groupBuilder.addGroup("list", (_C = config == null ?
|
|
217
|
-
label: (_D = config == null ?
|
|
218
|
-
icon: (_F = (_E = config == null ?
|
|
216
|
+
groupBuilder.addGroup("list", (_C = config == null ? undefined : config.slashMenuListGroupLabel) != null ? _C : "List").addItem("bullet-list", {
|
|
217
|
+
label: (_D = config == null ? undefined : config.slashMenuBulletListLabel) != null ? _D : "Bullet List",
|
|
218
|
+
icon: (_F = (_E = config == null ? undefined : config.slashMenuBulletListIcon) == null ? undefined : _E.call(config)) != null ? _F : bulletListIcon,
|
|
219
219
|
onRun: (ctx) => {
|
|
220
220
|
const view = ctx.get(editorViewCtx);
|
|
221
221
|
const { dispatch, state } = view;
|
|
@@ -225,8 +225,8 @@ function getGroups(filter, config) {
|
|
|
225
225
|
command(state, dispatch);
|
|
226
226
|
}
|
|
227
227
|
}).addItem("ordered-list", {
|
|
228
|
-
label: (_G = config == null ?
|
|
229
|
-
icon: (_I = (_H = config == null ?
|
|
228
|
+
label: (_G = config == null ? undefined : config.slashMenuOrderedListLabel) != null ? _G : "Ordered List",
|
|
229
|
+
icon: (_I = (_H = config == null ? undefined : config.slashMenuOrderedListIcon) == null ? undefined : _H.call(config)) != null ? _I : orderedListIcon,
|
|
230
230
|
onRun: (ctx) => {
|
|
231
231
|
const view = ctx.get(editorViewCtx);
|
|
232
232
|
const { dispatch, state } = view;
|
|
@@ -236,8 +236,8 @@ function getGroups(filter, config) {
|
|
|
236
236
|
command(state, dispatch);
|
|
237
237
|
}
|
|
238
238
|
}).addItem("todo-list", {
|
|
239
|
-
label: (_J = config == null ?
|
|
240
|
-
icon: (_L = (_K = config == null ?
|
|
239
|
+
label: (_J = config == null ? undefined : config.slashMenuTaskListLabel) != null ? _J : "Todo List",
|
|
240
|
+
icon: (_L = (_K = config == null ? undefined : config.slashMenuTaskListIcon) == null ? undefined : _K.call(config)) != null ? _L : todoListIcon,
|
|
241
241
|
onRun: (ctx) => {
|
|
242
242
|
const view = ctx.get(editorViewCtx);
|
|
243
243
|
const { dispatch, state } = view;
|
|
@@ -248,9 +248,9 @@ function getGroups(filter, config) {
|
|
|
248
248
|
command(state, dispatch);
|
|
249
249
|
}
|
|
250
250
|
});
|
|
251
|
-
groupBuilder.addGroup("advanced", (_M = config == null ?
|
|
252
|
-
label: (_N = config == null ?
|
|
253
|
-
icon: (_P = (_O = config == null ?
|
|
251
|
+
groupBuilder.addGroup("advanced", (_M = config == null ? undefined : config.slashMenuAdvancedGroupLabel) != null ? _M : "Advanced").addItem("image", {
|
|
252
|
+
label: (_N = config == null ? undefined : config.slashMenuImageLabel) != null ? _N : "Image",
|
|
253
|
+
icon: (_P = (_O = config == null ? undefined : config.slashMenuImageIcon) == null ? undefined : _O.call(config)) != null ? _P : imageIcon,
|
|
254
254
|
onRun: (ctx) => {
|
|
255
255
|
const view = ctx.get(editorViewCtx);
|
|
256
256
|
const { dispatch, state } = view;
|
|
@@ -258,8 +258,8 @@ function getGroups(filter, config) {
|
|
|
258
258
|
command(state, dispatch);
|
|
259
259
|
}
|
|
260
260
|
}).addItem("code", {
|
|
261
|
-
label: (_Q = config == null ?
|
|
262
|
-
icon: (_S = (_R = config == null ?
|
|
261
|
+
label: (_Q = config == null ? undefined : config.slashMenuCodeBlockLabel) != null ? _Q : "Code",
|
|
262
|
+
icon: (_S = (_R = config == null ? undefined : config.slashMenuCodeBlockIcon) == null ? undefined : _R.call(config)) != null ? _S : codeIcon,
|
|
263
263
|
onRun: (ctx) => {
|
|
264
264
|
const view = ctx.get(editorViewCtx);
|
|
265
265
|
const { dispatch, state } = view;
|
|
@@ -267,8 +267,8 @@ function getGroups(filter, config) {
|
|
|
267
267
|
command(state, dispatch);
|
|
268
268
|
}
|
|
269
269
|
}).addItem("table", {
|
|
270
|
-
label: (_T = config == null ?
|
|
271
|
-
icon: (_V = (_U = config == null ?
|
|
270
|
+
label: (_T = config == null ? undefined : config.slashMenuTableLabel) != null ? _T : "Table",
|
|
271
|
+
icon: (_V = (_U = config == null ? undefined : config.slashMenuTableIcon) == null ? undefined : _U.call(config)) != null ? _V : tableIcon,
|
|
272
272
|
onRun: (ctx) => {
|
|
273
273
|
const view = ctx.get(editorViewCtx);
|
|
274
274
|
const { dispatch, state } = view;
|
|
@@ -284,7 +284,7 @@ function getGroups(filter, config) {
|
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
286
|
});
|
|
287
|
-
(_W = config == null ?
|
|
287
|
+
(_W = config == null ? undefined : config.buildMenu) == null ? undefined : _W.call(config, groupBuilder);
|
|
288
288
|
let groups = groupBuilder.build();
|
|
289
289
|
if (filter) {
|
|
290
290
|
groups = groups.map((group) => {
|
|
@@ -334,14 +334,14 @@ const menuComponent = ({
|
|
|
334
334
|
prevPos.y = y;
|
|
335
335
|
}, []);
|
|
336
336
|
useEffect(() => {
|
|
337
|
-
if (size === 0 && show) hide == null ?
|
|
337
|
+
if (size === 0 && show) hide == null ? undefined : hide();
|
|
338
338
|
else if (hoverIndex >= size) setHoverIndex(0);
|
|
339
339
|
}, [size, show]);
|
|
340
340
|
const onHover = useCallback(
|
|
341
341
|
(index, after) => {
|
|
342
342
|
setHoverIndex((prev) => {
|
|
343
343
|
const next = typeof index === "function" ? index(prev) : index;
|
|
344
|
-
after == null ?
|
|
344
|
+
after == null ? undefined : after(next);
|
|
345
345
|
return next;
|
|
346
346
|
});
|
|
347
347
|
},
|
|
@@ -359,7 +359,7 @@ const menuComponent = ({
|
|
|
359
359
|
(index) => {
|
|
360
360
|
const item = groups.flatMap((group) => group.items).at(index);
|
|
361
361
|
if (item && ctx) item.onRun(ctx);
|
|
362
|
-
hide == null ?
|
|
362
|
+
hide == null ? undefined : hide();
|
|
363
363
|
},
|
|
364
364
|
[groups]
|
|
365
365
|
);
|
|
@@ -367,7 +367,7 @@ const menuComponent = ({
|
|
|
367
367
|
(e) => {
|
|
368
368
|
if (e.key === "Escape") {
|
|
369
369
|
e.preventDefault();
|
|
370
|
-
hide == null ?
|
|
370
|
+
hide == null ? undefined : hide();
|
|
371
371
|
return;
|
|
372
372
|
}
|
|
373
373
|
if (e.key === "ArrowDown") {
|
|
@@ -460,11 +460,11 @@ const menuComponent = ({
|
|
|
460
460
|
onmouseenter=${onMouseEnter(item.index)}
|
|
461
461
|
onmousedown=${() => {
|
|
462
462
|
var _a;
|
|
463
|
-
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ?
|
|
463
|
+
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? undefined : _a.classList.add("active");
|
|
464
464
|
}}
|
|
465
465
|
onmouseup=${() => {
|
|
466
466
|
var _a;
|
|
467
|
-
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ?
|
|
467
|
+
(_a = host.current.querySelector(`[data-index="${item.index}"]`)) == null ? undefined : _a.classList.remove("active");
|
|
468
468
|
runByIndex(item.index);
|
|
469
469
|
}}
|
|
470
470
|
>
|
|
@@ -589,20 +589,20 @@ const blockHandleComponent = ({
|
|
|
589
589
|
const ref = useRef();
|
|
590
590
|
useEffect(() => {
|
|
591
591
|
var _a;
|
|
592
|
-
(_a = ref.current) == null ?
|
|
592
|
+
(_a = ref.current) == null ? undefined : _a.classList.remove("active");
|
|
593
593
|
});
|
|
594
594
|
const onMouseDown = (e) => {
|
|
595
595
|
var _a;
|
|
596
596
|
e.preventDefault();
|
|
597
597
|
e.stopPropagation();
|
|
598
|
-
(_a = ref.current) == null ?
|
|
598
|
+
(_a = ref.current) == null ? undefined : _a.classList.add("active");
|
|
599
599
|
};
|
|
600
600
|
const onMouseUp = (e) => {
|
|
601
601
|
var _a;
|
|
602
602
|
e.preventDefault();
|
|
603
603
|
e.stopPropagation();
|
|
604
|
-
onAdd == null ?
|
|
605
|
-
(_a = ref.current) == null ?
|
|
604
|
+
onAdd == null ? undefined : onAdd();
|
|
605
|
+
(_a = ref.current) == null ? undefined : _a.classList.remove("active");
|
|
606
606
|
};
|
|
607
607
|
return html`
|
|
608
608
|
<host>
|
|
@@ -612,9 +612,9 @@ const blockHandleComponent = ({
|
|
|
612
612
|
onmouseup=${onMouseUp}
|
|
613
613
|
class="operation-item"
|
|
614
614
|
>
|
|
615
|
-
${(addIcon == null ?
|
|
615
|
+
${(addIcon == null ? undefined : addIcon()) || plusIcon}
|
|
616
616
|
</div>
|
|
617
|
-
<div class="operation-item">${(handleIcon == null ?
|
|
617
|
+
<div class="operation-item">${(handleIcon == null ? undefined : handleIcon()) || menuIcon}</div>
|
|
618
618
|
</host>
|
|
619
619
|
`;
|
|
620
620
|
};
|
|
@@ -665,8 +665,8 @@ class BlockHandleView {
|
|
|
665
665
|
const content = new BlockHandleElement();
|
|
666
666
|
__privateSet(this, _content, content);
|
|
667
667
|
__privateGet(this, _content).onAdd = this.onAdd;
|
|
668
|
-
__privateGet(this, _content).addIcon = config == null ?
|
|
669
|
-
__privateGet(this, _content).handleIcon = config == null ?
|
|
668
|
+
__privateGet(this, _content).addIcon = config == null ? undefined : config.handleAddIcon;
|
|
669
|
+
__privateGet(this, _content).handleIcon = config == null ? undefined : config.handleDragIcon;
|
|
670
670
|
__privateSet(this, _provider, new BlockProvider({
|
|
671
671
|
ctx,
|
|
672
672
|
content,
|
|
@@ -699,7 +699,7 @@ function configureBlockHandle(ctx, config) {
|
|
|
699
699
|
ctx.set(blockConfig.key, {
|
|
700
700
|
filterNodes: (pos) => {
|
|
701
701
|
const filter = findParent(
|
|
702
|
-
(node) => ["table", "blockquote"].includes(node.type.name)
|
|
702
|
+
(node) => ["table", "blockquote", "math_inline"].includes(node.type.name)
|
|
703
703
|
)(pos);
|
|
704
704
|
if (filter) return false;
|
|
705
705
|
return true;
|
|
@@ -715,4 +715,4 @@ const defineFeature = (editor, config) => {
|
|
|
715
715
|
};
|
|
716
716
|
|
|
717
717
|
export { defineFeature };
|
|
718
|
-
//# sourceMappingURL=index-
|
|
718
|
+
//# sourceMappingURL=index-HnGoJxjJ.js.map
|