@templatical/editor 0.0.1 → 0.0.3
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/dist/AiChatSidebar-busJk9hm.js +214 -0
- package/dist/AiFeatureMenu-DLGv_-pj.js +63 -0
- package/dist/CloudEditor-BDnHd6Um.js +919 -0
- package/dist/CollaboratorBar-Dv3l52vC.js +91 -0
- package/dist/CommentsSidebar-4tjp0VU5.js +439 -0
- package/dist/DesignReferenceSidebar-CmwXvltV.js +273 -0
- package/dist/LoadingTrack-vK8W2PJf.js +10 -0
- package/dist/ModuleBrowserModal-lrk3Fr0H.js +205 -0
- package/dist/ModulePreviewCanvas-BcBJLnwL.js +106 -0
- package/dist/ParagraphEditor-DH8cSC6m.js +625 -0
- package/dist/RichTextEditorContent-CQqodi7p.js +133 -0
- package/dist/SaveModuleDialog-Bmzi72td.js +122 -0
- package/dist/SnapshotHistory-AEgi9Xsn.js +126 -0
- package/dist/TemplateScoringPanel-CTgMtc0-.js +249 -0
- package/dist/TestEmailModal-Dpq1is9S.js +94 -0
- package/dist/TitleEditor-CLcDdcWI.js +167 -0
- package/dist/TplModal-CGzRjR96.js +44 -0
- package/dist/_plugin-vue_export-helper-B1-bu7yR.js +47 -0
- package/dist/blockTypeIcons-BpPTqcok.js +126 -0
- package/dist/cdn/chunks/ParagraphEditor-CCtWbGDv.js +3 -0
- package/dist/cdn/chunks/ParagraphEditor-CCtWbGDv.js.map +1 -0
- package/dist/cdn/chunks/RichTextEditorContent-BUD9veXd.js +2 -0
- package/dist/cdn/chunks/RichTextEditorContent-BUD9veXd.js.map +1 -0
- package/dist/cdn/chunks/TitleEditor-e_UTyxjd.js +3 -0
- package/dist/cdn/chunks/TitleEditor-e_UTyxjd.js.map +1 -0
- package/dist/cdn/chunks/dist-0UheN8rK.js +1 -0
- package/dist/cdn/chunks/dist-55mmbGQ9.js +1 -0
- package/dist/cdn/chunks/dist-B31mxKyP.js +1 -0
- package/dist/cdn/chunks/dist-B5JI9nIg.js +1 -0
- package/dist/cdn/chunks/dist-B93vLKhU.js +1 -0
- package/dist/cdn/chunks/dist-BDt3FJvj.js +1 -0
- package/dist/cdn/chunks/dist-BJRuFHmi.js +1 -0
- package/dist/cdn/chunks/dist-BKSzrf0L.js +1 -0
- package/dist/cdn/chunks/dist-BL8c5gYQ.js +1 -0
- package/dist/cdn/chunks/dist-CYThWMP5.js +1 -0
- package/dist/cdn/chunks/dist-DxZbPJYt.js +1 -0
- package/dist/cdn/chunks/draggable-ClUwYCFL.js +17 -0
- package/dist/cdn/chunks/draggable-ClUwYCFL.js.map +1 -0
- package/dist/cdn/chunks/emojiData-6fVLNqeH.js +2 -0
- package/dist/cdn/chunks/emojiData-6fVLNqeH.js.map +1 -0
- package/dist/cdn/chunks/extensions-ea_ewKUl.js +2 -0
- package/dist/cdn/chunks/extensions-ea_ewKUl.js.map +1 -0
- package/dist/cdn/chunks/icons-vmLJTaJk.js +2 -0
- package/dist/cdn/chunks/icons-vmLJTaJk.js.map +1 -0
- package/dist/cdn/chunks/rolldown-runtime-BakkzWXw.js +1 -0
- package/dist/cdn/chunks/styleConstants-CNejCb-L.js +2 -0
- package/dist/cdn/chunks/styleConstants-CNejCb-L.js.map +1 -0
- package/dist/cdn/chunks/tiptap-Cya4P9CN.js +145 -0
- package/dist/cdn/chunks/tiptap-Cya4P9CN.js.map +1 -0
- package/dist/cdn/chunks/useEditorCore-CwuxQuvh.js +2 -0
- package/dist/cdn/chunks/useEditorCore-CwuxQuvh.js.map +1 -0
- package/dist/cdn/chunks/useMergeTag-DVOz1v9p.js +2 -0
- package/dist/cdn/chunks/useMergeTag-DVOz1v9p.js.map +1 -0
- package/dist/cdn/editor.css +1 -0
- package/dist/cdn/editor.js +2 -0
- package/dist/cdn/editor.js.map +1 -0
- package/dist/check-B7kDuZmP.js +7 -0
- package/dist/chevron-down-DJLW2Q9Z.js +7 -0
- package/dist/circle-alert-E2vYPs5r.js +25 -0
- package/dist/clock-lWIIQA3C.js +12 -0
- package/dist/de-B4Ob4vCo.js +682 -0
- package/dist/dist-4LiM9FDd.js +35 -0
- package/dist/dist-Bu7veieH.js +776 -0
- package/dist/dist-C1BIRHCQ.js +61 -0
- package/dist/dist-CG-vEqSU.js +314 -0
- package/dist/dist-C_ymrGFi.js +10625 -0
- package/dist/dist-ChAGLpWo.js +35 -0
- package/dist/dist-D_HQYSY-.js +189 -0
- package/dist/dist-DkypH7qG.js +5 -0
- package/dist/dist-DmOE-Ubp.js +74 -0
- package/dist/dist-DmpMJbmZ.js +513 -0
- package/dist/dist-DrvKRSU6.js +47 -0
- package/dist/dist-Dxnd0GRf.js +5 -0
- package/dist/dist-DysAFIPy.js +2054 -0
- package/dist/emojiData-BfWQS72m.js +17 -0
- package/dist/en-YXsspZJG.js +682 -0
- package/dist/extensions-CKM99njP.js +420 -0
- package/dist/formatRelativeTime-DX3FgqN9.js +8 -0
- package/dist/i18n-CJsFtdbZ.js +23 -0
- package/dist/image-up-X4xIq4ea.js +23 -0
- package/dist/keys-Dwa2PmdD.js +10 -0
- package/dist/liquid.browser-BemTg3sZ.js +3272 -0
- package/dist/loader-circle-BTQQxC3l.js +7 -0
- package/dist/message-circle-Blgm6V_h.js +7 -0
- package/dist/refresh-cw-Bb4PEeW1.js +44 -0
- package/dist/scan-line-7lZPfOdm.js +25 -0
- package/dist/send-C0ltAQrv.js +10 -0
- package/dist/shield-check-f-qv4RKs.js +10 -0
- package/dist/sparkles-KhBCGlqB.js +23 -0
- package/dist/styleConstants-D4SOZGBV.js +94 -0
- package/dist/styles-DSw1VNU3.js +3406 -0
- package/dist/templatical-editor.css +2 -1
- package/dist/templatical-editor.js +242 -9
- package/dist/templatical-editor.umd.cjs +112 -524
- package/dist/timeouts-CmBrLeZA.js +4 -0
- package/dist/trash-2-OwjZ-guZ.js +25 -0
- package/dist/triangle-alert-DOSRIUYZ.js +17 -0
- package/dist/useEditorCore-Cc4RCwWq.js +5556 -0
- package/dist/useI18n-DUirdXEX.js +17 -0
- package/dist/useMergeTag-DVnlvPYJ.js +33 -0
- package/dist/x-CGlq2XQe.js +10 -0
- package/package.json +30 -20
- package/dist/AiChatSidebar-0vx9TP5B.js +0 -305
- package/dist/AiFeatureMenu-CI-v74ND.js +0 -69
- package/dist/CloudEditor-Wdfv_9xn.js +0 -1132
- package/dist/CollaboratorBar-B3uV4Wtw.js +0 -89
- package/dist/CommentsSidebar-PVUlloyB.js +0 -655
- package/dist/DesignReferenceSidebar-DAlAWrxU.js +0 -351
- package/dist/ModuleBrowserModal-1JEcChd8.js +0 -323
- package/dist/ModulePreviewCanvas-Cdp484Ae.js +0 -169
- package/dist/SaveModuleDialog-eNyr3XKn.js +0 -168
- package/dist/SnapshotHistory-D-ZiIj1v.js +0 -169
- package/dist/TemplateScoringPanel-DSZPo15C.js +0 -385
- package/dist/TestEmailModal-Cwre5elw.js +0 -128
- package/dist/TextEditor-BuUOIByX.js +0 -780
- package/dist/de-BWIAblxs.js +0 -685
- package/dist/en-cYyUzNV1.js +0 -685
- package/dist/index-0tWUczNu.js +0 -47
- package/dist/index-4okvXjqk.js +0 -41
- package/dist/index-BSc6h5zo.js +0 -967
- package/dist/index-CrvwWlhN.js +0 -41
- package/dist/index-D-iD-7lO.js +0 -10961
- package/dist/index-D-ygXbc8.js +0 -2452
- package/dist/index-DbrWKz-e.js +0 -1415
- package/dist/index-DeUeHy6g.js +0 -422
- package/dist/index-Ude6e9RU.js +0 -41
- package/dist/index-ZQzHBwkr.js +0 -12767
- package/dist/liquid.browser-CeNxS2GL.js +0 -3493
- package/dist/loader-circle-tM9j2mRh.js +0 -13
- package/dist/shield-check-Ngi9jAQc.js +0 -20
package/dist/index-DbrWKz-e.js
DELETED
|
@@ -1,1415 +0,0 @@
|
|
|
1
|
-
import { N as b, w as x, m as g, M as E, a as C, b as L, P as O, c as $, T as w, t as D, S as H, d as te, E as B, F as z, e as Y, k as ne, f as V, D as re, g as se, h as ie, i as oe, j as ae, n as le, l as ue, o as pe } from "./index-ZQzHBwkr.js";
|
|
2
|
-
const de = /^\s*>\s$/, ce = b.create({
|
|
3
|
-
name: "blockquote",
|
|
4
|
-
addOptions() {
|
|
5
|
-
return {
|
|
6
|
-
HTMLAttributes: {}
|
|
7
|
-
};
|
|
8
|
-
},
|
|
9
|
-
content: "block+",
|
|
10
|
-
group: "block",
|
|
11
|
-
defining: !0,
|
|
12
|
-
parseHTML() {
|
|
13
|
-
return [
|
|
14
|
-
{ tag: "blockquote" }
|
|
15
|
-
];
|
|
16
|
-
},
|
|
17
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
18
|
-
return ["blockquote", g(this.options.HTMLAttributes, t), 0];
|
|
19
|
-
},
|
|
20
|
-
addCommands() {
|
|
21
|
-
return {
|
|
22
|
-
setBlockquote: () => ({ commands: t }) => t.wrapIn(this.name),
|
|
23
|
-
toggleBlockquote: () => ({ commands: t }) => t.toggleWrap(this.name),
|
|
24
|
-
unsetBlockquote: () => ({ commands: t }) => t.lift(this.name)
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
addKeyboardShortcuts() {
|
|
28
|
-
return {
|
|
29
|
-
"Mod-Shift-b": () => this.editor.commands.toggleBlockquote()
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
addInputRules() {
|
|
33
|
-
return [
|
|
34
|
-
x({
|
|
35
|
-
find: de,
|
|
36
|
-
type: this.type
|
|
37
|
-
})
|
|
38
|
-
];
|
|
39
|
-
}
|
|
40
|
-
}), he = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, fe = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, me = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, ge = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, ye = E.create({
|
|
41
|
-
name: "bold",
|
|
42
|
-
addOptions() {
|
|
43
|
-
return {
|
|
44
|
-
HTMLAttributes: {}
|
|
45
|
-
};
|
|
46
|
-
},
|
|
47
|
-
parseHTML() {
|
|
48
|
-
return [
|
|
49
|
-
{
|
|
50
|
-
tag: "strong"
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
tag: "b",
|
|
54
|
-
getAttrs: (t) => t.style.fontWeight !== "normal" && null
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
style: "font-weight=400",
|
|
58
|
-
clearMark: (t) => t.type.name === this.name
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
style: "font-weight",
|
|
62
|
-
getAttrs: (t) => /^(bold(er)?|[5-9]\d{2,})$/.test(t) && null
|
|
63
|
-
}
|
|
64
|
-
];
|
|
65
|
-
},
|
|
66
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
67
|
-
return ["strong", g(this.options.HTMLAttributes, t), 0];
|
|
68
|
-
},
|
|
69
|
-
addCommands() {
|
|
70
|
-
return {
|
|
71
|
-
setBold: () => ({ commands: t }) => t.setMark(this.name),
|
|
72
|
-
toggleBold: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
73
|
-
unsetBold: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
addKeyboardShortcuts() {
|
|
77
|
-
return {
|
|
78
|
-
"Mod-b": () => this.editor.commands.toggleBold(),
|
|
79
|
-
"Mod-B": () => this.editor.commands.toggleBold()
|
|
80
|
-
};
|
|
81
|
-
},
|
|
82
|
-
addInputRules() {
|
|
83
|
-
return [
|
|
84
|
-
L({
|
|
85
|
-
find: he,
|
|
86
|
-
type: this.type
|
|
87
|
-
}),
|
|
88
|
-
L({
|
|
89
|
-
find: me,
|
|
90
|
-
type: this.type
|
|
91
|
-
})
|
|
92
|
-
];
|
|
93
|
-
},
|
|
94
|
-
addPasteRules() {
|
|
95
|
-
return [
|
|
96
|
-
C({
|
|
97
|
-
find: fe,
|
|
98
|
-
type: this.type
|
|
99
|
-
}),
|
|
100
|
-
C({
|
|
101
|
-
find: ge,
|
|
102
|
-
type: this.type
|
|
103
|
-
})
|
|
104
|
-
];
|
|
105
|
-
}
|
|
106
|
-
}), Me = "listItem", F = "textStyle", W = /^\s*([-+*])\s$/, be = b.create({
|
|
107
|
-
name: "bulletList",
|
|
108
|
-
addOptions() {
|
|
109
|
-
return {
|
|
110
|
-
itemTypeName: "listItem",
|
|
111
|
-
HTMLAttributes: {},
|
|
112
|
-
keepMarks: !1,
|
|
113
|
-
keepAttributes: !1
|
|
114
|
-
};
|
|
115
|
-
},
|
|
116
|
-
group: "block list",
|
|
117
|
-
content() {
|
|
118
|
-
return `${this.options.itemTypeName}+`;
|
|
119
|
-
},
|
|
120
|
-
parseHTML() {
|
|
121
|
-
return [
|
|
122
|
-
{ tag: "ul" }
|
|
123
|
-
];
|
|
124
|
-
},
|
|
125
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
126
|
-
return ["ul", g(this.options.HTMLAttributes, t), 0];
|
|
127
|
-
},
|
|
128
|
-
addCommands() {
|
|
129
|
-
return {
|
|
130
|
-
toggleBulletList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(Me, this.editor.getAttributes(F)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
131
|
-
};
|
|
132
|
-
},
|
|
133
|
-
addKeyboardShortcuts() {
|
|
134
|
-
return {
|
|
135
|
-
"Mod-Shift-8": () => this.editor.commands.toggleBulletList()
|
|
136
|
-
};
|
|
137
|
-
},
|
|
138
|
-
addInputRules() {
|
|
139
|
-
let t = x({
|
|
140
|
-
find: W,
|
|
141
|
-
type: this.type
|
|
142
|
-
});
|
|
143
|
-
return (this.options.keepMarks || this.options.keepAttributes) && (t = x({
|
|
144
|
-
find: W,
|
|
145
|
-
type: this.type,
|
|
146
|
-
keepMarks: this.options.keepMarks,
|
|
147
|
-
keepAttributes: this.options.keepAttributes,
|
|
148
|
-
getAttributes: () => this.editor.getAttributes(F),
|
|
149
|
-
editor: this.editor
|
|
150
|
-
})), [
|
|
151
|
-
t
|
|
152
|
-
];
|
|
153
|
-
}
|
|
154
|
-
}), ve = /(^|[^`])`([^`]+)`(?!`)/, ke = /(^|[^`])`([^`]+)`(?!`)/g, Ae = E.create({
|
|
155
|
-
name: "code",
|
|
156
|
-
addOptions() {
|
|
157
|
-
return {
|
|
158
|
-
HTMLAttributes: {}
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
excludes: "_",
|
|
162
|
-
code: !0,
|
|
163
|
-
exitable: !0,
|
|
164
|
-
parseHTML() {
|
|
165
|
-
return [
|
|
166
|
-
{ tag: "code" }
|
|
167
|
-
];
|
|
168
|
-
},
|
|
169
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
170
|
-
return ["code", g(this.options.HTMLAttributes, t), 0];
|
|
171
|
-
},
|
|
172
|
-
addCommands() {
|
|
173
|
-
return {
|
|
174
|
-
setCode: () => ({ commands: t }) => t.setMark(this.name),
|
|
175
|
-
toggleCode: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
176
|
-
unsetCode: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
177
|
-
};
|
|
178
|
-
},
|
|
179
|
-
addKeyboardShortcuts() {
|
|
180
|
-
return {
|
|
181
|
-
"Mod-e": () => this.editor.commands.toggleCode()
|
|
182
|
-
};
|
|
183
|
-
},
|
|
184
|
-
addInputRules() {
|
|
185
|
-
return [
|
|
186
|
-
L({
|
|
187
|
-
find: ve,
|
|
188
|
-
type: this.type
|
|
189
|
-
})
|
|
190
|
-
];
|
|
191
|
-
},
|
|
192
|
-
addPasteRules() {
|
|
193
|
-
return [
|
|
194
|
-
C({
|
|
195
|
-
find: ke,
|
|
196
|
-
type: this.type
|
|
197
|
-
})
|
|
198
|
-
];
|
|
199
|
-
}
|
|
200
|
-
}), Te = /^```([a-z]+)?[\s\n]$/, we = /^~~~([a-z]+)?[\s\n]$/, Ce = b.create({
|
|
201
|
-
name: "codeBlock",
|
|
202
|
-
addOptions() {
|
|
203
|
-
return {
|
|
204
|
-
languageClassPrefix: "language-",
|
|
205
|
-
exitOnTripleEnter: !0,
|
|
206
|
-
exitOnArrowDown: !0,
|
|
207
|
-
defaultLanguage: null,
|
|
208
|
-
HTMLAttributes: {}
|
|
209
|
-
};
|
|
210
|
-
},
|
|
211
|
-
content: "text*",
|
|
212
|
-
marks: "",
|
|
213
|
-
group: "block",
|
|
214
|
-
code: !0,
|
|
215
|
-
defining: !0,
|
|
216
|
-
addAttributes() {
|
|
217
|
-
return {
|
|
218
|
-
language: {
|
|
219
|
-
default: this.options.defaultLanguage,
|
|
220
|
-
parseHTML: (t) => {
|
|
221
|
-
var e;
|
|
222
|
-
const { languageClassPrefix: n } = this.options, i = [...((e = t.firstElementChild) === null || e === void 0 ? void 0 : e.classList) || []].filter((o) => o.startsWith(n)).map((o) => o.replace(n, ""))[0];
|
|
223
|
-
return i || null;
|
|
224
|
-
},
|
|
225
|
-
rendered: !1
|
|
226
|
-
}
|
|
227
|
-
};
|
|
228
|
-
},
|
|
229
|
-
parseHTML() {
|
|
230
|
-
return [
|
|
231
|
-
{
|
|
232
|
-
tag: "pre",
|
|
233
|
-
preserveWhitespace: "full"
|
|
234
|
-
}
|
|
235
|
-
];
|
|
236
|
-
},
|
|
237
|
-
renderHTML({ node: t, HTMLAttributes: e }) {
|
|
238
|
-
return [
|
|
239
|
-
"pre",
|
|
240
|
-
g(this.options.HTMLAttributes, e),
|
|
241
|
-
[
|
|
242
|
-
"code",
|
|
243
|
-
{
|
|
244
|
-
class: t.attrs.language ? this.options.languageClassPrefix + t.attrs.language : null
|
|
245
|
-
},
|
|
246
|
-
0
|
|
247
|
-
]
|
|
248
|
-
];
|
|
249
|
-
},
|
|
250
|
-
addCommands() {
|
|
251
|
-
return {
|
|
252
|
-
setCodeBlock: (t) => ({ commands: e }) => e.setNode(this.name, t),
|
|
253
|
-
toggleCodeBlock: (t) => ({ commands: e }) => e.toggleNode(this.name, "paragraph", t)
|
|
254
|
-
};
|
|
255
|
-
},
|
|
256
|
-
addKeyboardShortcuts() {
|
|
257
|
-
return {
|
|
258
|
-
"Mod-Alt-c": () => this.editor.commands.toggleCodeBlock(),
|
|
259
|
-
// remove code block when at start of document or code block is empty
|
|
260
|
-
Backspace: () => {
|
|
261
|
-
const { empty: t, $anchor: e } = this.editor.state.selection, n = e.pos === 1;
|
|
262
|
-
return !t || e.parent.type.name !== this.name ? !1 : n || !e.parent.textContent.length ? this.editor.commands.clearNodes() : !1;
|
|
263
|
-
},
|
|
264
|
-
// exit node on triple enter
|
|
265
|
-
Enter: ({ editor: t }) => {
|
|
266
|
-
if (!this.options.exitOnTripleEnter)
|
|
267
|
-
return !1;
|
|
268
|
-
const { state: e } = t, { selection: n } = e, { $from: r, empty: s } = n;
|
|
269
|
-
if (!s || r.parent.type !== this.type)
|
|
270
|
-
return !1;
|
|
271
|
-
const i = r.parentOffset === r.parent.nodeSize - 2, o = r.parent.textContent.endsWith(`
|
|
272
|
-
|
|
273
|
-
`);
|
|
274
|
-
return !i || !o ? !1 : t.chain().command(({ tr: a }) => (a.delete(r.pos - 2, r.pos), !0)).exitCode().run();
|
|
275
|
-
},
|
|
276
|
-
// exit node on arrow down
|
|
277
|
-
ArrowDown: ({ editor: t }) => {
|
|
278
|
-
if (!this.options.exitOnArrowDown)
|
|
279
|
-
return !1;
|
|
280
|
-
const { state: e } = t, { selection: n, doc: r } = e, { $from: s, empty: i } = n;
|
|
281
|
-
if (!i || s.parent.type !== this.type || !(s.parentOffset === s.parent.nodeSize - 2))
|
|
282
|
-
return !1;
|
|
283
|
-
const a = s.after();
|
|
284
|
-
return a === void 0 ? !1 : r.nodeAt(a) ? t.commands.command(({ tr: p }) => (p.setSelection(H.near(r.resolve(a))), !0)) : t.commands.exitCode();
|
|
285
|
-
}
|
|
286
|
-
};
|
|
287
|
-
},
|
|
288
|
-
addInputRules() {
|
|
289
|
-
return [
|
|
290
|
-
D({
|
|
291
|
-
find: Te,
|
|
292
|
-
type: this.type,
|
|
293
|
-
getAttributes: (t) => ({
|
|
294
|
-
language: t[1]
|
|
295
|
-
})
|
|
296
|
-
}),
|
|
297
|
-
D({
|
|
298
|
-
find: we,
|
|
299
|
-
type: this.type,
|
|
300
|
-
getAttributes: (t) => ({
|
|
301
|
-
language: t[1]
|
|
302
|
-
})
|
|
303
|
-
})
|
|
304
|
-
];
|
|
305
|
-
},
|
|
306
|
-
addProseMirrorPlugins() {
|
|
307
|
-
return [
|
|
308
|
-
// this plugin creates a code block for pasted content from VS Code
|
|
309
|
-
// we can also detect the copied code language
|
|
310
|
-
new O({
|
|
311
|
-
key: new $("codeBlockVSCodeHandler"),
|
|
312
|
-
props: {
|
|
313
|
-
handlePaste: (t, e) => {
|
|
314
|
-
if (!e.clipboardData || this.editor.isActive(this.type.name))
|
|
315
|
-
return !1;
|
|
316
|
-
const n = e.clipboardData.getData("text/plain"), r = e.clipboardData.getData("vscode-editor-data"), s = r ? JSON.parse(r) : void 0, i = s == null ? void 0 : s.mode;
|
|
317
|
-
if (!n || !i)
|
|
318
|
-
return !1;
|
|
319
|
-
const { tr: o, schema: a } = t.state, l = a.text(n.replace(/\r\n?/g, `
|
|
320
|
-
`));
|
|
321
|
-
return o.replaceSelectionWith(this.type.create({ language: i }, l)), o.selection.$from.parent.type !== this.type && o.setSelection(w.near(o.doc.resolve(Math.max(0, o.selection.from - 2)))), o.setMeta("paste", !0), t.dispatch(o), !0;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
})
|
|
325
|
-
];
|
|
326
|
-
}
|
|
327
|
-
}), Le = b.create({
|
|
328
|
-
name: "doc",
|
|
329
|
-
topNode: !0,
|
|
330
|
-
content: "block+"
|
|
331
|
-
});
|
|
332
|
-
function Ie(t = {}) {
|
|
333
|
-
return new O({
|
|
334
|
-
view(e) {
|
|
335
|
-
return new xe(e, t);
|
|
336
|
-
}
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
class xe {
|
|
340
|
-
constructor(e, n) {
|
|
341
|
-
var r;
|
|
342
|
-
this.editorView = e, this.cursorPos = null, this.element = null, this.timeout = -1, this.width = (r = n.width) !== null && r !== void 0 ? r : 1, this.color = n.color === !1 ? void 0 : n.color || "black", this.class = n.class, this.handlers = ["dragover", "dragend", "drop", "dragleave"].map((s) => {
|
|
343
|
-
let i = (o) => {
|
|
344
|
-
this[s](o);
|
|
345
|
-
};
|
|
346
|
-
return e.dom.addEventListener(s, i), { name: s, handler: i };
|
|
347
|
-
});
|
|
348
|
-
}
|
|
349
|
-
destroy() {
|
|
350
|
-
this.handlers.forEach(({ name: e, handler: n }) => this.editorView.dom.removeEventListener(e, n));
|
|
351
|
-
}
|
|
352
|
-
update(e, n) {
|
|
353
|
-
this.cursorPos != null && n.doc != e.state.doc && (this.cursorPos > e.state.doc.content.size ? this.setCursor(null) : this.updateOverlay());
|
|
354
|
-
}
|
|
355
|
-
setCursor(e) {
|
|
356
|
-
e != this.cursorPos && (this.cursorPos = e, e == null ? (this.element.parentNode.removeChild(this.element), this.element = null) : this.updateOverlay());
|
|
357
|
-
}
|
|
358
|
-
updateOverlay() {
|
|
359
|
-
let e = this.editorView.state.doc.resolve(this.cursorPos), n = !e.parent.inlineContent, r, s = this.editorView.dom, i = s.getBoundingClientRect(), o = i.width / s.offsetWidth, a = i.height / s.offsetHeight;
|
|
360
|
-
if (n) {
|
|
361
|
-
let u = e.nodeBefore, d = e.nodeAfter;
|
|
362
|
-
if (u || d) {
|
|
363
|
-
let f = this.editorView.nodeDOM(this.cursorPos - (u ? u.nodeSize : 0));
|
|
364
|
-
if (f) {
|
|
365
|
-
let y = f.getBoundingClientRect(), T = u ? y.bottom : y.top;
|
|
366
|
-
u && d && (T = (T + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2);
|
|
367
|
-
let I = this.width / 2 * a;
|
|
368
|
-
r = { left: y.left, right: y.right, top: T - I, bottom: T + I };
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
if (!r) {
|
|
373
|
-
let u = this.editorView.coordsAtPos(this.cursorPos), d = this.width / 2 * o;
|
|
374
|
-
r = { left: u.left - d, right: u.left + d, top: u.top, bottom: u.bottom };
|
|
375
|
-
}
|
|
376
|
-
let l = this.editorView.dom.offsetParent;
|
|
377
|
-
this.element || (this.element = l.appendChild(document.createElement("div")), this.class && (this.element.className = this.class), this.element.style.cssText = "position: absolute; z-index: 50; pointer-events: none;", this.color && (this.element.style.backgroundColor = this.color)), this.element.classList.toggle("prosemirror-dropcursor-block", n), this.element.classList.toggle("prosemirror-dropcursor-inline", !n);
|
|
378
|
-
let p, c;
|
|
379
|
-
if (!l || l == document.body && getComputedStyle(l).position == "static")
|
|
380
|
-
p = -pageXOffset, c = -pageYOffset;
|
|
381
|
-
else {
|
|
382
|
-
let u = l.getBoundingClientRect(), d = u.width / l.offsetWidth, f = u.height / l.offsetHeight;
|
|
383
|
-
p = u.left - l.scrollLeft * d, c = u.top - l.scrollTop * f;
|
|
384
|
-
}
|
|
385
|
-
this.element.style.left = (r.left - p) / o + "px", this.element.style.top = (r.top - c) / a + "px", this.element.style.width = (r.right - r.left) / o + "px", this.element.style.height = (r.bottom - r.top) / a + "px";
|
|
386
|
-
}
|
|
387
|
-
scheduleRemoval(e) {
|
|
388
|
-
clearTimeout(this.timeout), this.timeout = setTimeout(() => this.setCursor(null), e);
|
|
389
|
-
}
|
|
390
|
-
dragover(e) {
|
|
391
|
-
if (!this.editorView.editable)
|
|
392
|
-
return;
|
|
393
|
-
let n = this.editorView.posAtCoords({ left: e.clientX, top: e.clientY }), r = n && n.inside >= 0 && this.editorView.state.doc.nodeAt(n.inside), s = r && r.type.spec.disableDropCursor, i = typeof s == "function" ? s(this.editorView, n, e) : s;
|
|
394
|
-
if (n && !i) {
|
|
395
|
-
let o = n.pos;
|
|
396
|
-
if (this.editorView.dragging && this.editorView.dragging.slice) {
|
|
397
|
-
let a = te(this.editorView.state.doc, o, this.editorView.dragging.slice);
|
|
398
|
-
a != null && (o = a);
|
|
399
|
-
}
|
|
400
|
-
this.setCursor(o), this.scheduleRemoval(5e3);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
dragend() {
|
|
404
|
-
this.scheduleRemoval(20);
|
|
405
|
-
}
|
|
406
|
-
drop() {
|
|
407
|
-
this.scheduleRemoval(20);
|
|
408
|
-
}
|
|
409
|
-
dragleave(e) {
|
|
410
|
-
this.editorView.dom.contains(e.relatedTarget) || this.setCursor(null);
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
const He = B.create({
|
|
414
|
-
name: "dropCursor",
|
|
415
|
-
addOptions() {
|
|
416
|
-
return {
|
|
417
|
-
color: "currentColor",
|
|
418
|
-
width: 1,
|
|
419
|
-
class: void 0
|
|
420
|
-
};
|
|
421
|
-
},
|
|
422
|
-
addProseMirrorPlugins() {
|
|
423
|
-
return [
|
|
424
|
-
Ie(this.options)
|
|
425
|
-
];
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
class h extends H {
|
|
429
|
-
/**
|
|
430
|
-
Create a gap cursor.
|
|
431
|
-
*/
|
|
432
|
-
constructor(e) {
|
|
433
|
-
super(e, e);
|
|
434
|
-
}
|
|
435
|
-
map(e, n) {
|
|
436
|
-
let r = e.resolve(n.map(this.head));
|
|
437
|
-
return h.valid(r) ? new h(r) : H.near(r);
|
|
438
|
-
}
|
|
439
|
-
content() {
|
|
440
|
-
return Y.empty;
|
|
441
|
-
}
|
|
442
|
-
eq(e) {
|
|
443
|
-
return e instanceof h && e.head == this.head;
|
|
444
|
-
}
|
|
445
|
-
toJSON() {
|
|
446
|
-
return { type: "gapcursor", pos: this.head };
|
|
447
|
-
}
|
|
448
|
-
/**
|
|
449
|
-
@internal
|
|
450
|
-
*/
|
|
451
|
-
static fromJSON(e, n) {
|
|
452
|
-
if (typeof n.pos != "number")
|
|
453
|
-
throw new RangeError("Invalid input for GapCursor.fromJSON");
|
|
454
|
-
return new h(e.resolve(n.pos));
|
|
455
|
-
}
|
|
456
|
-
/**
|
|
457
|
-
@internal
|
|
458
|
-
*/
|
|
459
|
-
getBookmark() {
|
|
460
|
-
return new K(this.anchor);
|
|
461
|
-
}
|
|
462
|
-
/**
|
|
463
|
-
@internal
|
|
464
|
-
*/
|
|
465
|
-
static valid(e) {
|
|
466
|
-
let n = e.parent;
|
|
467
|
-
if (n.inlineContent || !Se(e) || !Re(e))
|
|
468
|
-
return !1;
|
|
469
|
-
let r = n.type.spec.allowGapCursor;
|
|
470
|
-
if (r != null)
|
|
471
|
-
return r;
|
|
472
|
-
let s = n.contentMatchAt(e.index()).defaultType;
|
|
473
|
-
return s && s.isTextblock;
|
|
474
|
-
}
|
|
475
|
-
/**
|
|
476
|
-
@internal
|
|
477
|
-
*/
|
|
478
|
-
static findGapCursorFrom(e, n, r = !1) {
|
|
479
|
-
e: for (; ; ) {
|
|
480
|
-
if (!r && h.valid(e))
|
|
481
|
-
return e;
|
|
482
|
-
let s = e.pos, i = null;
|
|
483
|
-
for (let o = e.depth; ; o--) {
|
|
484
|
-
let a = e.node(o);
|
|
485
|
-
if (n > 0 ? e.indexAfter(o) < a.childCount : e.index(o) > 0) {
|
|
486
|
-
i = a.child(n > 0 ? e.indexAfter(o) : e.index(o) - 1);
|
|
487
|
-
break;
|
|
488
|
-
} else if (o == 0)
|
|
489
|
-
return null;
|
|
490
|
-
s += n;
|
|
491
|
-
let l = e.doc.resolve(s);
|
|
492
|
-
if (h.valid(l))
|
|
493
|
-
return l;
|
|
494
|
-
}
|
|
495
|
-
for (; ; ) {
|
|
496
|
-
let o = n > 0 ? i.firstChild : i.lastChild;
|
|
497
|
-
if (!o) {
|
|
498
|
-
if (i.isAtom && !i.isText && !V.isSelectable(i)) {
|
|
499
|
-
e = e.doc.resolve(s + i.nodeSize * n), r = !1;
|
|
500
|
-
continue e;
|
|
501
|
-
}
|
|
502
|
-
break;
|
|
503
|
-
}
|
|
504
|
-
i = o, s += n;
|
|
505
|
-
let a = e.doc.resolve(s);
|
|
506
|
-
if (h.valid(a))
|
|
507
|
-
return a;
|
|
508
|
-
}
|
|
509
|
-
return null;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
h.prototype.visible = !1;
|
|
514
|
-
h.findFrom = h.findGapCursorFrom;
|
|
515
|
-
H.jsonID("gapcursor", h);
|
|
516
|
-
class K {
|
|
517
|
-
constructor(e) {
|
|
518
|
-
this.pos = e;
|
|
519
|
-
}
|
|
520
|
-
map(e) {
|
|
521
|
-
return new K(e.map(this.pos));
|
|
522
|
-
}
|
|
523
|
-
resolve(e) {
|
|
524
|
-
let n = e.resolve(this.pos);
|
|
525
|
-
return h.valid(n) ? new h(n) : H.near(n);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
function J(t) {
|
|
529
|
-
return t.isAtom || t.spec.isolating || t.spec.createGapCursor;
|
|
530
|
-
}
|
|
531
|
-
function Se(t) {
|
|
532
|
-
for (let e = t.depth; e >= 0; e--) {
|
|
533
|
-
let n = t.index(e), r = t.node(e);
|
|
534
|
-
if (n == 0) {
|
|
535
|
-
if (r.type.spec.isolating)
|
|
536
|
-
return !0;
|
|
537
|
-
continue;
|
|
538
|
-
}
|
|
539
|
-
for (let s = r.child(n - 1); ; s = s.lastChild) {
|
|
540
|
-
if (s.childCount == 0 && !s.inlineContent || J(s.type))
|
|
541
|
-
return !0;
|
|
542
|
-
if (s.inlineContent)
|
|
543
|
-
return !1;
|
|
544
|
-
}
|
|
545
|
-
}
|
|
546
|
-
return !0;
|
|
547
|
-
}
|
|
548
|
-
function Re(t) {
|
|
549
|
-
for (let e = t.depth; e >= 0; e--) {
|
|
550
|
-
let n = t.indexAfter(e), r = t.node(e);
|
|
551
|
-
if (n == r.childCount) {
|
|
552
|
-
if (r.type.spec.isolating)
|
|
553
|
-
return !0;
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
|
-
for (let s = r.child(n); ; s = s.firstChild) {
|
|
557
|
-
if (s.childCount == 0 && !s.inlineContent || J(s.type))
|
|
558
|
-
return !0;
|
|
559
|
-
if (s.inlineContent)
|
|
560
|
-
return !1;
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
return !0;
|
|
564
|
-
}
|
|
565
|
-
function Pe() {
|
|
566
|
-
return new O({
|
|
567
|
-
props: {
|
|
568
|
-
decorations: Ne,
|
|
569
|
-
createSelectionBetween(t, e, n) {
|
|
570
|
-
return e.pos == n.pos && h.valid(n) ? new h(n) : null;
|
|
571
|
-
},
|
|
572
|
-
handleClick: Oe,
|
|
573
|
-
handleKeyDown: Ee,
|
|
574
|
-
handleDOMEvents: { beforeinput: Be }
|
|
575
|
-
}
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
const Ee = ne({
|
|
579
|
-
ArrowLeft: S("horiz", -1),
|
|
580
|
-
ArrowRight: S("horiz", 1),
|
|
581
|
-
ArrowUp: S("vert", -1),
|
|
582
|
-
ArrowDown: S("vert", 1)
|
|
583
|
-
});
|
|
584
|
-
function S(t, e) {
|
|
585
|
-
const n = t == "vert" ? e > 0 ? "down" : "up" : e > 0 ? "right" : "left";
|
|
586
|
-
return function(r, s, i) {
|
|
587
|
-
let o = r.selection, a = e > 0 ? o.$to : o.$from, l = o.empty;
|
|
588
|
-
if (o instanceof w) {
|
|
589
|
-
if (!i.endOfTextblock(n) || a.depth == 0)
|
|
590
|
-
return !1;
|
|
591
|
-
l = !1, a = r.doc.resolve(e > 0 ? a.after() : a.before());
|
|
592
|
-
}
|
|
593
|
-
let p = h.findGapCursorFrom(a, e, l);
|
|
594
|
-
return p ? (s && s(r.tr.setSelection(new h(p))), !0) : !1;
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
function Oe(t, e, n) {
|
|
598
|
-
if (!t || !t.editable)
|
|
599
|
-
return !1;
|
|
600
|
-
let r = t.state.doc.resolve(e);
|
|
601
|
-
if (!h.valid(r))
|
|
602
|
-
return !1;
|
|
603
|
-
let s = t.posAtCoords({ left: n.clientX, top: n.clientY });
|
|
604
|
-
return s && s.inside > -1 && V.isSelectable(t.state.doc.nodeAt(s.inside)) ? !1 : (t.dispatch(t.state.tr.setSelection(new h(r))), !0);
|
|
605
|
-
}
|
|
606
|
-
function Be(t, e) {
|
|
607
|
-
if (e.inputType != "insertCompositionText" || !(t.state.selection instanceof h))
|
|
608
|
-
return !1;
|
|
609
|
-
let { $from: n } = t.state.selection, r = n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);
|
|
610
|
-
if (!r)
|
|
611
|
-
return !1;
|
|
612
|
-
let s = z.empty;
|
|
613
|
-
for (let o = r.length - 1; o >= 0; o--)
|
|
614
|
-
s = z.from(r[o].createAndFill(null, s));
|
|
615
|
-
let i = t.state.tr.replace(n.pos, n.pos, new Y(s, 0, 0));
|
|
616
|
-
return i.setSelection(w.near(i.doc.resolve(n.pos + 1))), t.dispatch(i), !1;
|
|
617
|
-
}
|
|
618
|
-
function Ne(t) {
|
|
619
|
-
if (!(t.selection instanceof h))
|
|
620
|
-
return null;
|
|
621
|
-
let e = document.createElement("div");
|
|
622
|
-
return e.className = "ProseMirror-gapcursor", re.create(t.doc, [se.widget(t.selection.head, e, { key: "gapcursor" })]);
|
|
623
|
-
}
|
|
624
|
-
const _e = B.create({
|
|
625
|
-
name: "gapCursor",
|
|
626
|
-
addProseMirrorPlugins() {
|
|
627
|
-
return [
|
|
628
|
-
Pe()
|
|
629
|
-
];
|
|
630
|
-
},
|
|
631
|
-
extendNodeSchema(t) {
|
|
632
|
-
var e;
|
|
633
|
-
const n = {
|
|
634
|
-
name: t.name,
|
|
635
|
-
options: t.options,
|
|
636
|
-
storage: t.storage
|
|
637
|
-
};
|
|
638
|
-
return {
|
|
639
|
-
allowGapCursor: (e = ie(oe(t, "allowGapCursor", n))) !== null && e !== void 0 ? e : null
|
|
640
|
-
};
|
|
641
|
-
}
|
|
642
|
-
}), De = b.create({
|
|
643
|
-
name: "hardBreak",
|
|
644
|
-
addOptions() {
|
|
645
|
-
return {
|
|
646
|
-
keepMarks: !0,
|
|
647
|
-
HTMLAttributes: {}
|
|
648
|
-
};
|
|
649
|
-
},
|
|
650
|
-
inline: !0,
|
|
651
|
-
group: "inline",
|
|
652
|
-
selectable: !1,
|
|
653
|
-
linebreakReplacement: !0,
|
|
654
|
-
parseHTML() {
|
|
655
|
-
return [
|
|
656
|
-
{ tag: "br" }
|
|
657
|
-
];
|
|
658
|
-
},
|
|
659
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
660
|
-
return ["br", g(this.options.HTMLAttributes, t)];
|
|
661
|
-
},
|
|
662
|
-
renderText() {
|
|
663
|
-
return `
|
|
664
|
-
`;
|
|
665
|
-
},
|
|
666
|
-
addCommands() {
|
|
667
|
-
return {
|
|
668
|
-
setHardBreak: () => ({ commands: t, chain: e, state: n, editor: r }) => t.first([
|
|
669
|
-
() => t.exitCode(),
|
|
670
|
-
() => t.command(() => {
|
|
671
|
-
const { selection: s, storedMarks: i } = n;
|
|
672
|
-
if (s.$from.parent.type.spec.isolating)
|
|
673
|
-
return !1;
|
|
674
|
-
const { keepMarks: o } = this.options, { splittableMarks: a } = r.extensionManager, l = i || s.$to.parentOffset && s.$from.marks();
|
|
675
|
-
return e().insertContent({ type: this.name }).command(({ tr: p, dispatch: c }) => {
|
|
676
|
-
if (c && l && o) {
|
|
677
|
-
const u = l.filter((d) => a.includes(d.type.name));
|
|
678
|
-
p.ensureMarks(u);
|
|
679
|
-
}
|
|
680
|
-
return !0;
|
|
681
|
-
}).run();
|
|
682
|
-
})
|
|
683
|
-
])
|
|
684
|
-
};
|
|
685
|
-
},
|
|
686
|
-
addKeyboardShortcuts() {
|
|
687
|
-
return {
|
|
688
|
-
"Mod-Enter": () => this.editor.commands.setHardBreak(),
|
|
689
|
-
"Shift-Enter": () => this.editor.commands.setHardBreak()
|
|
690
|
-
};
|
|
691
|
-
}
|
|
692
|
-
}), $e = b.create({
|
|
693
|
-
name: "heading",
|
|
694
|
-
addOptions() {
|
|
695
|
-
return {
|
|
696
|
-
levels: [1, 2, 3, 4, 5, 6],
|
|
697
|
-
HTMLAttributes: {}
|
|
698
|
-
};
|
|
699
|
-
},
|
|
700
|
-
content: "inline*",
|
|
701
|
-
group: "block",
|
|
702
|
-
defining: !0,
|
|
703
|
-
addAttributes() {
|
|
704
|
-
return {
|
|
705
|
-
level: {
|
|
706
|
-
default: 1,
|
|
707
|
-
rendered: !1
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
},
|
|
711
|
-
parseHTML() {
|
|
712
|
-
return this.options.levels.map((t) => ({
|
|
713
|
-
tag: `h${t}`,
|
|
714
|
-
attrs: { level: t }
|
|
715
|
-
}));
|
|
716
|
-
},
|
|
717
|
-
renderHTML({ node: t, HTMLAttributes: e }) {
|
|
718
|
-
return [`h${this.options.levels.includes(t.attrs.level) ? t.attrs.level : this.options.levels[0]}`, g(this.options.HTMLAttributes, e), 0];
|
|
719
|
-
},
|
|
720
|
-
addCommands() {
|
|
721
|
-
return {
|
|
722
|
-
setHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.setNode(this.name, t) : !1,
|
|
723
|
-
toggleHeading: (t) => ({ commands: e }) => this.options.levels.includes(t.level) ? e.toggleNode(this.name, "paragraph", t) : !1
|
|
724
|
-
};
|
|
725
|
-
},
|
|
726
|
-
addKeyboardShortcuts() {
|
|
727
|
-
return this.options.levels.reduce((t, e) => ({
|
|
728
|
-
...t,
|
|
729
|
-
[`Mod-Alt-${e}`]: () => this.editor.commands.toggleHeading({ level: e })
|
|
730
|
-
}), {});
|
|
731
|
-
},
|
|
732
|
-
addInputRules() {
|
|
733
|
-
return this.options.levels.map((t) => D({
|
|
734
|
-
find: new RegExp(`^(#{${Math.min(...this.options.levels)},${t}})\\s$`),
|
|
735
|
-
type: this.type,
|
|
736
|
-
getAttributes: {
|
|
737
|
-
level: t
|
|
738
|
-
}
|
|
739
|
-
}));
|
|
740
|
-
}
|
|
741
|
-
});
|
|
742
|
-
var P = 200, m = function() {
|
|
743
|
-
};
|
|
744
|
-
m.prototype.append = function(e) {
|
|
745
|
-
return e.length ? (e = m.from(e), !this.length && e || e.length < P && this.leafAppend(e) || this.length < P && e.leafPrepend(this) || this.appendInner(e)) : this;
|
|
746
|
-
};
|
|
747
|
-
m.prototype.prepend = function(e) {
|
|
748
|
-
return e.length ? m.from(e).append(this) : this;
|
|
749
|
-
};
|
|
750
|
-
m.prototype.appendInner = function(e) {
|
|
751
|
-
return new Ve(this, e);
|
|
752
|
-
};
|
|
753
|
-
m.prototype.slice = function(e, n) {
|
|
754
|
-
return e === void 0 && (e = 0), n === void 0 && (n = this.length), e >= n ? m.empty : this.sliceInner(Math.max(0, e), Math.min(this.length, n));
|
|
755
|
-
};
|
|
756
|
-
m.prototype.get = function(e) {
|
|
757
|
-
if (!(e < 0 || e >= this.length))
|
|
758
|
-
return this.getInner(e);
|
|
759
|
-
};
|
|
760
|
-
m.prototype.forEach = function(e, n, r) {
|
|
761
|
-
n === void 0 && (n = 0), r === void 0 && (r = this.length), n <= r ? this.forEachInner(e, n, r, 0) : this.forEachInvertedInner(e, n, r, 0);
|
|
762
|
-
};
|
|
763
|
-
m.prototype.map = function(e, n, r) {
|
|
764
|
-
n === void 0 && (n = 0), r === void 0 && (r = this.length);
|
|
765
|
-
var s = [];
|
|
766
|
-
return this.forEach(function(i, o) {
|
|
767
|
-
return s.push(e(i, o));
|
|
768
|
-
}, n, r), s;
|
|
769
|
-
};
|
|
770
|
-
m.from = function(e) {
|
|
771
|
-
return e instanceof m ? e : e && e.length ? new U(e) : m.empty;
|
|
772
|
-
};
|
|
773
|
-
var U = /* @__PURE__ */ (function(t) {
|
|
774
|
-
function e(r) {
|
|
775
|
-
t.call(this), this.values = r;
|
|
776
|
-
}
|
|
777
|
-
t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e;
|
|
778
|
-
var n = { length: { configurable: !0 }, depth: { configurable: !0 } };
|
|
779
|
-
return e.prototype.flatten = function() {
|
|
780
|
-
return this.values;
|
|
781
|
-
}, e.prototype.sliceInner = function(s, i) {
|
|
782
|
-
return s == 0 && i == this.length ? this : new e(this.values.slice(s, i));
|
|
783
|
-
}, e.prototype.getInner = function(s) {
|
|
784
|
-
return this.values[s];
|
|
785
|
-
}, e.prototype.forEachInner = function(s, i, o, a) {
|
|
786
|
-
for (var l = i; l < o; l++)
|
|
787
|
-
if (s(this.values[l], a + l) === !1)
|
|
788
|
-
return !1;
|
|
789
|
-
}, e.prototype.forEachInvertedInner = function(s, i, o, a) {
|
|
790
|
-
for (var l = i - 1; l >= o; l--)
|
|
791
|
-
if (s(this.values[l], a + l) === !1)
|
|
792
|
-
return !1;
|
|
793
|
-
}, e.prototype.leafAppend = function(s) {
|
|
794
|
-
if (this.length + s.length <= P)
|
|
795
|
-
return new e(this.values.concat(s.flatten()));
|
|
796
|
-
}, e.prototype.leafPrepend = function(s) {
|
|
797
|
-
if (this.length + s.length <= P)
|
|
798
|
-
return new e(s.flatten().concat(this.values));
|
|
799
|
-
}, n.length.get = function() {
|
|
800
|
-
return this.values.length;
|
|
801
|
-
}, n.depth.get = function() {
|
|
802
|
-
return 0;
|
|
803
|
-
}, Object.defineProperties(e.prototype, n), e;
|
|
804
|
-
})(m);
|
|
805
|
-
m.empty = new U([]);
|
|
806
|
-
var Ve = /* @__PURE__ */ (function(t) {
|
|
807
|
-
function e(n, r) {
|
|
808
|
-
t.call(this), this.left = n, this.right = r, this.length = n.length + r.length, this.depth = Math.max(n.depth, r.depth) + 1;
|
|
809
|
-
}
|
|
810
|
-
return t && (e.__proto__ = t), e.prototype = Object.create(t && t.prototype), e.prototype.constructor = e, e.prototype.flatten = function() {
|
|
811
|
-
return this.left.flatten().concat(this.right.flatten());
|
|
812
|
-
}, e.prototype.getInner = function(r) {
|
|
813
|
-
return r < this.left.length ? this.left.get(r) : this.right.get(r - this.left.length);
|
|
814
|
-
}, e.prototype.forEachInner = function(r, s, i, o) {
|
|
815
|
-
var a = this.left.length;
|
|
816
|
-
if (s < a && this.left.forEachInner(r, s, Math.min(i, a), o) === !1 || i > a && this.right.forEachInner(r, Math.max(s - a, 0), Math.min(this.length, i) - a, o + a) === !1)
|
|
817
|
-
return !1;
|
|
818
|
-
}, e.prototype.forEachInvertedInner = function(r, s, i, o) {
|
|
819
|
-
var a = this.left.length;
|
|
820
|
-
if (s > a && this.right.forEachInvertedInner(r, s - a, Math.max(i, a) - a, o + a) === !1 || i < a && this.left.forEachInvertedInner(r, Math.min(s, a), i, o) === !1)
|
|
821
|
-
return !1;
|
|
822
|
-
}, e.prototype.sliceInner = function(r, s) {
|
|
823
|
-
if (r == 0 && s == this.length)
|
|
824
|
-
return this;
|
|
825
|
-
var i = this.left.length;
|
|
826
|
-
return s <= i ? this.left.slice(r, s) : r >= i ? this.right.slice(r - i, s - i) : this.left.slice(r, i).append(this.right.slice(0, s - i));
|
|
827
|
-
}, e.prototype.leafAppend = function(r) {
|
|
828
|
-
var s = this.right.leafAppend(r);
|
|
829
|
-
if (s)
|
|
830
|
-
return new e(this.left, s);
|
|
831
|
-
}, e.prototype.leafPrepend = function(r) {
|
|
832
|
-
var s = this.left.leafPrepend(r);
|
|
833
|
-
if (s)
|
|
834
|
-
return new e(s, this.right);
|
|
835
|
-
}, e.prototype.appendInner = function(r) {
|
|
836
|
-
return this.left.depth >= Math.max(this.right.depth, r.depth) + 1 ? new e(this.left, new e(this.right, r)) : new e(this, r);
|
|
837
|
-
}, e;
|
|
838
|
-
})(m);
|
|
839
|
-
const Ke = 500;
|
|
840
|
-
class M {
|
|
841
|
-
constructor(e, n) {
|
|
842
|
-
this.items = e, this.eventCount = n;
|
|
843
|
-
}
|
|
844
|
-
// Pop the latest event off the branch's history and apply it
|
|
845
|
-
// to a document transform.
|
|
846
|
-
popEvent(e, n) {
|
|
847
|
-
if (this.eventCount == 0)
|
|
848
|
-
return null;
|
|
849
|
-
let r = this.items.length;
|
|
850
|
-
for (; ; r--)
|
|
851
|
-
if (this.items.get(r - 1).selection) {
|
|
852
|
-
--r;
|
|
853
|
-
break;
|
|
854
|
-
}
|
|
855
|
-
let s, i;
|
|
856
|
-
n && (s = this.remapping(r, this.items.length), i = s.maps.length);
|
|
857
|
-
let o = e.tr, a, l, p = [], c = [];
|
|
858
|
-
return this.items.forEach((u, d) => {
|
|
859
|
-
if (!u.step) {
|
|
860
|
-
s || (s = this.remapping(r, d + 1), i = s.maps.length), i--, c.push(u);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
if (s) {
|
|
864
|
-
c.push(new v(u.map));
|
|
865
|
-
let f = u.step.map(s.slice(i)), y;
|
|
866
|
-
f && o.maybeStep(f).doc && (y = o.mapping.maps[o.mapping.maps.length - 1], p.push(new v(y, void 0, void 0, p.length + c.length))), i--, y && s.appendMap(y, i);
|
|
867
|
-
} else
|
|
868
|
-
o.maybeStep(u.step);
|
|
869
|
-
if (u.selection)
|
|
870
|
-
return a = s ? u.selection.map(s.slice(i)) : u.selection, l = new M(this.items.slice(0, r).append(c.reverse().concat(p)), this.eventCount - 1), !1;
|
|
871
|
-
}, this.items.length, 0), { remaining: l, transform: o, selection: a };
|
|
872
|
-
}
|
|
873
|
-
// Create a new branch with the given transform added.
|
|
874
|
-
addTransform(e, n, r, s) {
|
|
875
|
-
let i = [], o = this.eventCount, a = this.items, l = !s && a.length ? a.get(a.length - 1) : null;
|
|
876
|
-
for (let c = 0; c < e.steps.length; c++) {
|
|
877
|
-
let u = e.steps[c].invert(e.docs[c]), d = new v(e.mapping.maps[c], u, n), f;
|
|
878
|
-
(f = l && l.merge(d)) && (d = f, c ? i.pop() : a = a.slice(0, a.length - 1)), i.push(d), n && (o++, n = void 0), s || (l = d);
|
|
879
|
-
}
|
|
880
|
-
let p = o - r.depth;
|
|
881
|
-
return p > Fe && (a = ze(a, p), o -= p), new M(a.append(i), o);
|
|
882
|
-
}
|
|
883
|
-
remapping(e, n) {
|
|
884
|
-
let r = new ae();
|
|
885
|
-
return this.items.forEach((s, i) => {
|
|
886
|
-
let o = s.mirrorOffset != null && i - s.mirrorOffset >= e ? r.maps.length - s.mirrorOffset : void 0;
|
|
887
|
-
r.appendMap(s.map, o);
|
|
888
|
-
}, e, n), r;
|
|
889
|
-
}
|
|
890
|
-
addMaps(e) {
|
|
891
|
-
return this.eventCount == 0 ? this : new M(this.items.append(e.map((n) => new v(n))), this.eventCount);
|
|
892
|
-
}
|
|
893
|
-
// When the collab module receives remote changes, the history has
|
|
894
|
-
// to know about those, so that it can adjust the steps that were
|
|
895
|
-
// rebased on top of the remote changes, and include the position
|
|
896
|
-
// maps for the remote changes in its array of items.
|
|
897
|
-
rebased(e, n) {
|
|
898
|
-
if (!this.eventCount)
|
|
899
|
-
return this;
|
|
900
|
-
let r = [], s = Math.max(0, this.items.length - n), i = e.mapping, o = e.steps.length, a = this.eventCount;
|
|
901
|
-
this.items.forEach((d) => {
|
|
902
|
-
d.selection && a--;
|
|
903
|
-
}, s);
|
|
904
|
-
let l = n;
|
|
905
|
-
this.items.forEach((d) => {
|
|
906
|
-
let f = i.getMirror(--l);
|
|
907
|
-
if (f == null)
|
|
908
|
-
return;
|
|
909
|
-
o = Math.min(o, f);
|
|
910
|
-
let y = i.maps[f];
|
|
911
|
-
if (d.step) {
|
|
912
|
-
let T = e.steps[f].invert(e.docs[f]), I = d.selection && d.selection.map(i.slice(l + 1, f));
|
|
913
|
-
I && a++, r.push(new v(y, T, I));
|
|
914
|
-
} else
|
|
915
|
-
r.push(new v(y));
|
|
916
|
-
}, s);
|
|
917
|
-
let p = [];
|
|
918
|
-
for (let d = n; d < o; d++)
|
|
919
|
-
p.push(new v(i.maps[d]));
|
|
920
|
-
let c = this.items.slice(0, s).append(p).append(r), u = new M(c, a);
|
|
921
|
-
return u.emptyItemCount() > Ke && (u = u.compress(this.items.length - r.length)), u;
|
|
922
|
-
}
|
|
923
|
-
emptyItemCount() {
|
|
924
|
-
let e = 0;
|
|
925
|
-
return this.items.forEach((n) => {
|
|
926
|
-
n.step || e++;
|
|
927
|
-
}), e;
|
|
928
|
-
}
|
|
929
|
-
// Compressing a branch means rewriting it to push the air (map-only
|
|
930
|
-
// items) out. During collaboration, these naturally accumulate
|
|
931
|
-
// because each remote change adds one. The `upto` argument is used
|
|
932
|
-
// to ensure that only the items below a given level are compressed,
|
|
933
|
-
// because `rebased` relies on a clean, untouched set of items in
|
|
934
|
-
// order to associate old items with rebased steps.
|
|
935
|
-
compress(e = this.items.length) {
|
|
936
|
-
let n = this.remapping(0, e), r = n.maps.length, s = [], i = 0;
|
|
937
|
-
return this.items.forEach((o, a) => {
|
|
938
|
-
if (a >= e)
|
|
939
|
-
s.push(o), o.selection && i++;
|
|
940
|
-
else if (o.step) {
|
|
941
|
-
let l = o.step.map(n.slice(r)), p = l && l.getMap();
|
|
942
|
-
if (r--, p && n.appendMap(p, r), l) {
|
|
943
|
-
let c = o.selection && o.selection.map(n.slice(r));
|
|
944
|
-
c && i++;
|
|
945
|
-
let u = new v(p.invert(), l, c), d, f = s.length - 1;
|
|
946
|
-
(d = s.length && s[f].merge(u)) ? s[f] = d : s.push(u);
|
|
947
|
-
}
|
|
948
|
-
} else o.map && r--;
|
|
949
|
-
}, this.items.length, 0), new M(m.from(s.reverse()), i);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
M.empty = new M(m.empty, 0);
|
|
953
|
-
function ze(t, e) {
|
|
954
|
-
let n;
|
|
955
|
-
return t.forEach((r, s) => {
|
|
956
|
-
if (r.selection && e-- == 0)
|
|
957
|
-
return n = s, !1;
|
|
958
|
-
}), t.slice(n);
|
|
959
|
-
}
|
|
960
|
-
class v {
|
|
961
|
-
constructor(e, n, r, s) {
|
|
962
|
-
this.map = e, this.step = n, this.selection = r, this.mirrorOffset = s;
|
|
963
|
-
}
|
|
964
|
-
merge(e) {
|
|
965
|
-
if (this.step && e.step && !e.selection) {
|
|
966
|
-
let n = e.step.merge(this.step);
|
|
967
|
-
if (n)
|
|
968
|
-
return new v(n.getMap().invert(), n, this.selection);
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
class k {
|
|
973
|
-
constructor(e, n, r, s, i) {
|
|
974
|
-
this.done = e, this.undone = n, this.prevRanges = r, this.prevTime = s, this.prevComposition = i;
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
const Fe = 20;
|
|
978
|
-
function We(t, e, n, r) {
|
|
979
|
-
let s = n.getMeta(A), i;
|
|
980
|
-
if (s)
|
|
981
|
-
return s.historyState;
|
|
982
|
-
n.getMeta(qe) && (t = new k(t.done, t.undone, null, 0, -1));
|
|
983
|
-
let o = n.getMeta("appendedTransaction");
|
|
984
|
-
if (n.steps.length == 0)
|
|
985
|
-
return t;
|
|
986
|
-
if (o && o.getMeta(A))
|
|
987
|
-
return o.getMeta(A).redo ? new k(t.done.addTransform(n, void 0, r, R(e)), t.undone, G(n.mapping.maps), t.prevTime, t.prevComposition) : new k(t.done, t.undone.addTransform(n, void 0, r, R(e)), null, t.prevTime, t.prevComposition);
|
|
988
|
-
if (n.getMeta("addToHistory") !== !1 && !(o && o.getMeta("addToHistory") === !1)) {
|
|
989
|
-
let a = n.getMeta("composition"), l = t.prevTime == 0 || !o && t.prevComposition != a && (t.prevTime < (n.time || 0) - r.newGroupDelay || !Ge(n, t.prevRanges)), p = o ? N(t.prevRanges, n.mapping) : G(n.mapping.maps);
|
|
990
|
-
return new k(t.done.addTransform(n, l ? e.selection.getBookmark() : void 0, r, R(e)), M.empty, p, n.time, a ?? t.prevComposition);
|
|
991
|
-
} else return (i = n.getMeta("rebased")) ? new k(t.done.rebased(n, i), t.undone.rebased(n, i), N(t.prevRanges, n.mapping), t.prevTime, t.prevComposition) : new k(t.done.addMaps(n.mapping.maps), t.undone.addMaps(n.mapping.maps), N(t.prevRanges, n.mapping), t.prevTime, t.prevComposition);
|
|
992
|
-
}
|
|
993
|
-
function Ge(t, e) {
|
|
994
|
-
if (!e)
|
|
995
|
-
return !1;
|
|
996
|
-
if (!t.docChanged)
|
|
997
|
-
return !0;
|
|
998
|
-
let n = !1;
|
|
999
|
-
return t.mapping.maps[0].forEach((r, s) => {
|
|
1000
|
-
for (let i = 0; i < e.length; i += 2)
|
|
1001
|
-
r <= e[i + 1] && s >= e[i] && (n = !0);
|
|
1002
|
-
}), n;
|
|
1003
|
-
}
|
|
1004
|
-
function G(t) {
|
|
1005
|
-
let e = [];
|
|
1006
|
-
for (let n = t.length - 1; n >= 0 && e.length == 0; n--)
|
|
1007
|
-
t[n].forEach((r, s, i, o) => e.push(i, o));
|
|
1008
|
-
return e;
|
|
1009
|
-
}
|
|
1010
|
-
function N(t, e) {
|
|
1011
|
-
if (!t)
|
|
1012
|
-
return null;
|
|
1013
|
-
let n = [];
|
|
1014
|
-
for (let r = 0; r < t.length; r += 2) {
|
|
1015
|
-
let s = e.map(t[r], 1), i = e.map(t[r + 1], -1);
|
|
1016
|
-
s <= i && n.push(s, i);
|
|
1017
|
-
}
|
|
1018
|
-
return n;
|
|
1019
|
-
}
|
|
1020
|
-
function je(t, e, n) {
|
|
1021
|
-
let r = R(e), s = A.get(e).spec.config, i = (n ? t.undone : t.done).popEvent(e, r);
|
|
1022
|
-
if (!i)
|
|
1023
|
-
return null;
|
|
1024
|
-
let o = i.selection.resolve(i.transform.doc), a = (n ? t.done : t.undone).addTransform(i.transform, e.selection.getBookmark(), s, r), l = new k(n ? a : i.remaining, n ? i.remaining : a, null, 0, -1);
|
|
1025
|
-
return i.transform.setSelection(o).setMeta(A, { redo: n, historyState: l });
|
|
1026
|
-
}
|
|
1027
|
-
let _ = !1, j = null;
|
|
1028
|
-
function R(t) {
|
|
1029
|
-
let e = t.plugins;
|
|
1030
|
-
if (j != e) {
|
|
1031
|
-
_ = !1, j = e;
|
|
1032
|
-
for (let n = 0; n < e.length; n++)
|
|
1033
|
-
if (e[n].spec.historyPreserveItems) {
|
|
1034
|
-
_ = !0;
|
|
1035
|
-
break;
|
|
1036
|
-
}
|
|
1037
|
-
}
|
|
1038
|
-
return _;
|
|
1039
|
-
}
|
|
1040
|
-
const A = new $("history"), qe = new $("closeHistory");
|
|
1041
|
-
function Xe(t = {}) {
|
|
1042
|
-
return t = {
|
|
1043
|
-
depth: t.depth || 100,
|
|
1044
|
-
newGroupDelay: t.newGroupDelay || 500
|
|
1045
|
-
}, new O({
|
|
1046
|
-
key: A,
|
|
1047
|
-
state: {
|
|
1048
|
-
init() {
|
|
1049
|
-
return new k(M.empty, M.empty, null, 0, -1);
|
|
1050
|
-
},
|
|
1051
|
-
apply(e, n, r) {
|
|
1052
|
-
return We(n, r, e, t);
|
|
1053
|
-
}
|
|
1054
|
-
},
|
|
1055
|
-
config: t,
|
|
1056
|
-
props: {
|
|
1057
|
-
handleDOMEvents: {
|
|
1058
|
-
beforeinput(e, n) {
|
|
1059
|
-
let r = n.inputType, s = r == "historyUndo" ? Q : r == "historyRedo" ? ee : null;
|
|
1060
|
-
return !s || !e.editable ? !1 : (n.preventDefault(), s(e.state, e.dispatch));
|
|
1061
|
-
}
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
});
|
|
1065
|
-
}
|
|
1066
|
-
function Z(t, e) {
|
|
1067
|
-
return (n, r) => {
|
|
1068
|
-
let s = A.getState(n);
|
|
1069
|
-
if (!s || (t ? s.undone : s.done).eventCount == 0)
|
|
1070
|
-
return !1;
|
|
1071
|
-
if (r) {
|
|
1072
|
-
let i = je(s, n, t);
|
|
1073
|
-
i && r(e ? i.scrollIntoView() : i);
|
|
1074
|
-
}
|
|
1075
|
-
return !0;
|
|
1076
|
-
};
|
|
1077
|
-
}
|
|
1078
|
-
const Q = Z(!1, !0), ee = Z(!0, !0), Ye = B.create({
|
|
1079
|
-
name: "history",
|
|
1080
|
-
addOptions() {
|
|
1081
|
-
return {
|
|
1082
|
-
depth: 100,
|
|
1083
|
-
newGroupDelay: 500
|
|
1084
|
-
};
|
|
1085
|
-
},
|
|
1086
|
-
addCommands() {
|
|
1087
|
-
return {
|
|
1088
|
-
undo: () => ({ state: t, dispatch: e }) => Q(t, e),
|
|
1089
|
-
redo: () => ({ state: t, dispatch: e }) => ee(t, e)
|
|
1090
|
-
};
|
|
1091
|
-
},
|
|
1092
|
-
addProseMirrorPlugins() {
|
|
1093
|
-
return [
|
|
1094
|
-
Xe(this.options)
|
|
1095
|
-
];
|
|
1096
|
-
},
|
|
1097
|
-
addKeyboardShortcuts() {
|
|
1098
|
-
return {
|
|
1099
|
-
"Mod-z": () => this.editor.commands.undo(),
|
|
1100
|
-
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
1101
|
-
"Mod-y": () => this.editor.commands.redo(),
|
|
1102
|
-
// Russian keyboard layouts
|
|
1103
|
-
"Mod-я": () => this.editor.commands.undo(),
|
|
1104
|
-
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
1105
|
-
};
|
|
1106
|
-
}
|
|
1107
|
-
}), Je = b.create({
|
|
1108
|
-
name: "horizontalRule",
|
|
1109
|
-
addOptions() {
|
|
1110
|
-
return {
|
|
1111
|
-
HTMLAttributes: {}
|
|
1112
|
-
};
|
|
1113
|
-
},
|
|
1114
|
-
group: "block",
|
|
1115
|
-
parseHTML() {
|
|
1116
|
-
return [{ tag: "hr" }];
|
|
1117
|
-
},
|
|
1118
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1119
|
-
return ["hr", g(this.options.HTMLAttributes, t)];
|
|
1120
|
-
},
|
|
1121
|
-
addCommands() {
|
|
1122
|
-
return {
|
|
1123
|
-
setHorizontalRule: () => ({ chain: t, state: e }) => {
|
|
1124
|
-
if (!ue(e, e.schema.nodes[this.name]))
|
|
1125
|
-
return !1;
|
|
1126
|
-
const { selection: n } = e, { $from: r, $to: s } = n, i = t();
|
|
1127
|
-
return r.parentOffset === 0 ? i.insertContentAt({
|
|
1128
|
-
from: Math.max(r.pos - 1, 0),
|
|
1129
|
-
to: s.pos
|
|
1130
|
-
}, {
|
|
1131
|
-
type: this.name
|
|
1132
|
-
}) : pe(n) ? i.insertContentAt(s.pos, {
|
|
1133
|
-
type: this.name
|
|
1134
|
-
}) : i.insertContent({ type: this.name }), i.command(({ tr: o, dispatch: a }) => {
|
|
1135
|
-
var l;
|
|
1136
|
-
if (a) {
|
|
1137
|
-
const { $to: p } = o.selection, c = p.end();
|
|
1138
|
-
if (p.nodeAfter)
|
|
1139
|
-
p.nodeAfter.isTextblock ? o.setSelection(w.create(o.doc, p.pos + 1)) : p.nodeAfter.isBlock ? o.setSelection(V.create(o.doc, p.pos)) : o.setSelection(w.create(o.doc, p.pos));
|
|
1140
|
-
else {
|
|
1141
|
-
const u = (l = p.parent.type.contentMatch.defaultType) === null || l === void 0 ? void 0 : l.create();
|
|
1142
|
-
u && (o.insert(c, u), o.setSelection(w.create(o.doc, c + 1)));
|
|
1143
|
-
}
|
|
1144
|
-
o.scrollIntoView();
|
|
1145
|
-
}
|
|
1146
|
-
return !0;
|
|
1147
|
-
}).run();
|
|
1148
|
-
}
|
|
1149
|
-
};
|
|
1150
|
-
},
|
|
1151
|
-
addInputRules() {
|
|
1152
|
-
return [
|
|
1153
|
-
le({
|
|
1154
|
-
find: /^(?:---|—-|___\s|\*\*\*\s)$/,
|
|
1155
|
-
type: this.type
|
|
1156
|
-
})
|
|
1157
|
-
];
|
|
1158
|
-
}
|
|
1159
|
-
}), Ue = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, Ze = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, Qe = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, et = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, tt = E.create({
|
|
1160
|
-
name: "italic",
|
|
1161
|
-
addOptions() {
|
|
1162
|
-
return {
|
|
1163
|
-
HTMLAttributes: {}
|
|
1164
|
-
};
|
|
1165
|
-
},
|
|
1166
|
-
parseHTML() {
|
|
1167
|
-
return [
|
|
1168
|
-
{
|
|
1169
|
-
tag: "em"
|
|
1170
|
-
},
|
|
1171
|
-
{
|
|
1172
|
-
tag: "i",
|
|
1173
|
-
getAttrs: (t) => t.style.fontStyle !== "normal" && null
|
|
1174
|
-
},
|
|
1175
|
-
{
|
|
1176
|
-
style: "font-style=normal",
|
|
1177
|
-
clearMark: (t) => t.type.name === this.name
|
|
1178
|
-
},
|
|
1179
|
-
{
|
|
1180
|
-
style: "font-style=italic"
|
|
1181
|
-
}
|
|
1182
|
-
];
|
|
1183
|
-
},
|
|
1184
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1185
|
-
return ["em", g(this.options.HTMLAttributes, t), 0];
|
|
1186
|
-
},
|
|
1187
|
-
addCommands() {
|
|
1188
|
-
return {
|
|
1189
|
-
setItalic: () => ({ commands: t }) => t.setMark(this.name),
|
|
1190
|
-
toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
1191
|
-
unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
1192
|
-
};
|
|
1193
|
-
},
|
|
1194
|
-
addKeyboardShortcuts() {
|
|
1195
|
-
return {
|
|
1196
|
-
"Mod-i": () => this.editor.commands.toggleItalic(),
|
|
1197
|
-
"Mod-I": () => this.editor.commands.toggleItalic()
|
|
1198
|
-
};
|
|
1199
|
-
},
|
|
1200
|
-
addInputRules() {
|
|
1201
|
-
return [
|
|
1202
|
-
L({
|
|
1203
|
-
find: Ue,
|
|
1204
|
-
type: this.type
|
|
1205
|
-
}),
|
|
1206
|
-
L({
|
|
1207
|
-
find: Qe,
|
|
1208
|
-
type: this.type
|
|
1209
|
-
})
|
|
1210
|
-
];
|
|
1211
|
-
},
|
|
1212
|
-
addPasteRules() {
|
|
1213
|
-
return [
|
|
1214
|
-
C({
|
|
1215
|
-
find: Ze,
|
|
1216
|
-
type: this.type
|
|
1217
|
-
}),
|
|
1218
|
-
C({
|
|
1219
|
-
find: et,
|
|
1220
|
-
type: this.type
|
|
1221
|
-
})
|
|
1222
|
-
];
|
|
1223
|
-
}
|
|
1224
|
-
}), nt = b.create({
|
|
1225
|
-
name: "listItem",
|
|
1226
|
-
addOptions() {
|
|
1227
|
-
return {
|
|
1228
|
-
HTMLAttributes: {},
|
|
1229
|
-
bulletListTypeName: "bulletList",
|
|
1230
|
-
orderedListTypeName: "orderedList"
|
|
1231
|
-
};
|
|
1232
|
-
},
|
|
1233
|
-
content: "paragraph block*",
|
|
1234
|
-
defining: !0,
|
|
1235
|
-
parseHTML() {
|
|
1236
|
-
return [
|
|
1237
|
-
{
|
|
1238
|
-
tag: "li"
|
|
1239
|
-
}
|
|
1240
|
-
];
|
|
1241
|
-
},
|
|
1242
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1243
|
-
return ["li", g(this.options.HTMLAttributes, t), 0];
|
|
1244
|
-
},
|
|
1245
|
-
addKeyboardShortcuts() {
|
|
1246
|
-
return {
|
|
1247
|
-
Enter: () => this.editor.commands.splitListItem(this.name),
|
|
1248
|
-
Tab: () => this.editor.commands.sinkListItem(this.name),
|
|
1249
|
-
"Shift-Tab": () => this.editor.commands.liftListItem(this.name)
|
|
1250
|
-
};
|
|
1251
|
-
}
|
|
1252
|
-
}), rt = "listItem", q = "textStyle", X = /^(\d+)\.\s$/, st = b.create({
|
|
1253
|
-
name: "orderedList",
|
|
1254
|
-
addOptions() {
|
|
1255
|
-
return {
|
|
1256
|
-
itemTypeName: "listItem",
|
|
1257
|
-
HTMLAttributes: {},
|
|
1258
|
-
keepMarks: !1,
|
|
1259
|
-
keepAttributes: !1
|
|
1260
|
-
};
|
|
1261
|
-
},
|
|
1262
|
-
group: "block list",
|
|
1263
|
-
content() {
|
|
1264
|
-
return `${this.options.itemTypeName}+`;
|
|
1265
|
-
},
|
|
1266
|
-
addAttributes() {
|
|
1267
|
-
return {
|
|
1268
|
-
start: {
|
|
1269
|
-
default: 1,
|
|
1270
|
-
parseHTML: (t) => t.hasAttribute("start") ? parseInt(t.getAttribute("start") || "", 10) : 1
|
|
1271
|
-
},
|
|
1272
|
-
type: {
|
|
1273
|
-
default: null,
|
|
1274
|
-
parseHTML: (t) => t.getAttribute("type")
|
|
1275
|
-
}
|
|
1276
|
-
};
|
|
1277
|
-
},
|
|
1278
|
-
parseHTML() {
|
|
1279
|
-
return [
|
|
1280
|
-
{
|
|
1281
|
-
tag: "ol"
|
|
1282
|
-
}
|
|
1283
|
-
];
|
|
1284
|
-
},
|
|
1285
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1286
|
-
const { start: e, ...n } = t;
|
|
1287
|
-
return e === 1 ? ["ol", g(this.options.HTMLAttributes, n), 0] : ["ol", g(this.options.HTMLAttributes, t), 0];
|
|
1288
|
-
},
|
|
1289
|
-
addCommands() {
|
|
1290
|
-
return {
|
|
1291
|
-
toggleOrderedList: () => ({ commands: t, chain: e }) => this.options.keepAttributes ? e().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(rt, this.editor.getAttributes(q)).run() : t.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks)
|
|
1292
|
-
};
|
|
1293
|
-
},
|
|
1294
|
-
addKeyboardShortcuts() {
|
|
1295
|
-
return {
|
|
1296
|
-
"Mod-Shift-7": () => this.editor.commands.toggleOrderedList()
|
|
1297
|
-
};
|
|
1298
|
-
},
|
|
1299
|
-
addInputRules() {
|
|
1300
|
-
let t = x({
|
|
1301
|
-
find: X,
|
|
1302
|
-
type: this.type,
|
|
1303
|
-
getAttributes: (e) => ({ start: +e[1] }),
|
|
1304
|
-
joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1]
|
|
1305
|
-
});
|
|
1306
|
-
return (this.options.keepMarks || this.options.keepAttributes) && (t = x({
|
|
1307
|
-
find: X,
|
|
1308
|
-
type: this.type,
|
|
1309
|
-
keepMarks: this.options.keepMarks,
|
|
1310
|
-
keepAttributes: this.options.keepAttributes,
|
|
1311
|
-
getAttributes: (e) => ({ start: +e[1], ...this.editor.getAttributes(q) }),
|
|
1312
|
-
joinPredicate: (e, n) => n.childCount + n.attrs.start === +e[1],
|
|
1313
|
-
editor: this.editor
|
|
1314
|
-
})), [
|
|
1315
|
-
t
|
|
1316
|
-
];
|
|
1317
|
-
}
|
|
1318
|
-
}), it = b.create({
|
|
1319
|
-
name: "paragraph",
|
|
1320
|
-
priority: 1e3,
|
|
1321
|
-
addOptions() {
|
|
1322
|
-
return {
|
|
1323
|
-
HTMLAttributes: {}
|
|
1324
|
-
};
|
|
1325
|
-
},
|
|
1326
|
-
group: "block",
|
|
1327
|
-
content: "inline*",
|
|
1328
|
-
parseHTML() {
|
|
1329
|
-
return [
|
|
1330
|
-
{ tag: "p" }
|
|
1331
|
-
];
|
|
1332
|
-
},
|
|
1333
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1334
|
-
return ["p", g(this.options.HTMLAttributes, t), 0];
|
|
1335
|
-
},
|
|
1336
|
-
addCommands() {
|
|
1337
|
-
return {
|
|
1338
|
-
setParagraph: () => ({ commands: t }) => t.setNode(this.name)
|
|
1339
|
-
};
|
|
1340
|
-
},
|
|
1341
|
-
addKeyboardShortcuts() {
|
|
1342
|
-
return {
|
|
1343
|
-
"Mod-Alt-0": () => this.editor.commands.setParagraph()
|
|
1344
|
-
};
|
|
1345
|
-
}
|
|
1346
|
-
}), ot = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, at = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, lt = E.create({
|
|
1347
|
-
name: "strike",
|
|
1348
|
-
addOptions() {
|
|
1349
|
-
return {
|
|
1350
|
-
HTMLAttributes: {}
|
|
1351
|
-
};
|
|
1352
|
-
},
|
|
1353
|
-
parseHTML() {
|
|
1354
|
-
return [
|
|
1355
|
-
{
|
|
1356
|
-
tag: "s"
|
|
1357
|
-
},
|
|
1358
|
-
{
|
|
1359
|
-
tag: "del"
|
|
1360
|
-
},
|
|
1361
|
-
{
|
|
1362
|
-
tag: "strike"
|
|
1363
|
-
},
|
|
1364
|
-
{
|
|
1365
|
-
style: "text-decoration",
|
|
1366
|
-
consuming: !1,
|
|
1367
|
-
getAttrs: (t) => t.includes("line-through") ? {} : !1
|
|
1368
|
-
}
|
|
1369
|
-
];
|
|
1370
|
-
},
|
|
1371
|
-
renderHTML({ HTMLAttributes: t }) {
|
|
1372
|
-
return ["s", g(this.options.HTMLAttributes, t), 0];
|
|
1373
|
-
},
|
|
1374
|
-
addCommands() {
|
|
1375
|
-
return {
|
|
1376
|
-
setStrike: () => ({ commands: t }) => t.setMark(this.name),
|
|
1377
|
-
toggleStrike: () => ({ commands: t }) => t.toggleMark(this.name),
|
|
1378
|
-
unsetStrike: () => ({ commands: t }) => t.unsetMark(this.name)
|
|
1379
|
-
};
|
|
1380
|
-
},
|
|
1381
|
-
addKeyboardShortcuts() {
|
|
1382
|
-
return {
|
|
1383
|
-
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
|
|
1384
|
-
};
|
|
1385
|
-
},
|
|
1386
|
-
addInputRules() {
|
|
1387
|
-
return [
|
|
1388
|
-
L({
|
|
1389
|
-
find: ot,
|
|
1390
|
-
type: this.type
|
|
1391
|
-
})
|
|
1392
|
-
];
|
|
1393
|
-
},
|
|
1394
|
-
addPasteRules() {
|
|
1395
|
-
return [
|
|
1396
|
-
C({
|
|
1397
|
-
find: at,
|
|
1398
|
-
type: this.type
|
|
1399
|
-
})
|
|
1400
|
-
];
|
|
1401
|
-
}
|
|
1402
|
-
}), ut = b.create({
|
|
1403
|
-
name: "text",
|
|
1404
|
-
group: "inline"
|
|
1405
|
-
}), dt = B.create({
|
|
1406
|
-
name: "starterKit",
|
|
1407
|
-
addExtensions() {
|
|
1408
|
-
const t = [];
|
|
1409
|
-
return this.options.bold !== !1 && t.push(ye.configure(this.options.bold)), this.options.blockquote !== !1 && t.push(ce.configure(this.options.blockquote)), this.options.bulletList !== !1 && t.push(be.configure(this.options.bulletList)), this.options.code !== !1 && t.push(Ae.configure(this.options.code)), this.options.codeBlock !== !1 && t.push(Ce.configure(this.options.codeBlock)), this.options.document !== !1 && t.push(Le.configure(this.options.document)), this.options.dropcursor !== !1 && t.push(He.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && t.push(_e.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && t.push(De.configure(this.options.hardBreak)), this.options.heading !== !1 && t.push($e.configure(this.options.heading)), this.options.history !== !1 && t.push(Ye.configure(this.options.history)), this.options.horizontalRule !== !1 && t.push(Je.configure(this.options.horizontalRule)), this.options.italic !== !1 && t.push(tt.configure(this.options.italic)), this.options.listItem !== !1 && t.push(nt.configure(this.options.listItem)), this.options.orderedList !== !1 && t.push(st.configure(this.options.orderedList)), this.options.paragraph !== !1 && t.push(it.configure(this.options.paragraph)), this.options.strike !== !1 && t.push(lt.configure(this.options.strike)), this.options.text !== !1 && t.push(ut.configure(this.options.text)), t;
|
|
1410
|
-
}
|
|
1411
|
-
});
|
|
1412
|
-
export {
|
|
1413
|
-
dt as StarterKit,
|
|
1414
|
-
dt as default
|
|
1415
|
-
};
|