@vizel/core 0.0.1-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -0
- package/dist/components.css +1 -0
- package/dist/components.css.map +1 -0
- package/dist/index.d.ts +2642 -0
- package/dist/index.js +150 -0
- package/dist/index10.js +118 -0
- package/dist/index11.js +174 -0
- package/dist/index12.js +78 -0
- package/dist/index13.js +141 -0
- package/dist/index14.js +150 -0
- package/dist/index15.js +20 -0
- package/dist/index16.js +17 -0
- package/dist/index17.js +308 -0
- package/dist/index18.js +52 -0
- package/dist/index19.js +29 -0
- package/dist/index2.js +93 -0
- package/dist/index20.js +268 -0
- package/dist/index21.js +72 -0
- package/dist/index22.js +360 -0
- package/dist/index23.js +87 -0
- package/dist/index24.js +39 -0
- package/dist/index25.js +95 -0
- package/dist/index26.js +104 -0
- package/dist/index27.js +136 -0
- package/dist/index28.js +56 -0
- package/dist/index29.js +69 -0
- package/dist/index3.js +69 -0
- package/dist/index30.js +40 -0
- package/dist/index31.js +26 -0
- package/dist/index32.js +15 -0
- package/dist/index33.js +12 -0
- package/dist/index34.js +19 -0
- package/dist/index35.js +60 -0
- package/dist/index36.js +17 -0
- package/dist/index37.js +66 -0
- package/dist/index38.js +6 -0
- package/dist/index39.js +125 -0
- package/dist/index4.js +89 -0
- package/dist/index40.js +329 -0
- package/dist/index41.js +489 -0
- package/dist/index42.js +50 -0
- package/dist/index43.js +676 -0
- package/dist/index44.js +6 -0
- package/dist/index45.js +6 -0
- package/dist/index46.js +240 -0
- package/dist/index47.js +84 -0
- package/dist/index48.js +288 -0
- package/dist/index49.js +1504 -0
- package/dist/index5.js +13 -0
- package/dist/index50.js +7 -0
- package/dist/index51.js +1563 -0
- package/dist/index52.js +204 -0
- package/dist/index53.js +725 -0
- package/dist/index54.js +23 -0
- package/dist/index55.js +12 -0
- package/dist/index56.js +9 -0
- package/dist/index57.js +10 -0
- package/dist/index58.js +16 -0
- package/dist/index59.js +21 -0
- package/dist/index6.js +135 -0
- package/dist/index60.js +27 -0
- package/dist/index61.js +86 -0
- package/dist/index62.js +248 -0
- package/dist/index63.js +1234 -0
- package/dist/index64.js +736 -0
- package/dist/index65.js +5 -0
- package/dist/index66.js +1063 -0
- package/dist/index67.js +57 -0
- package/dist/index68.js +100 -0
- package/dist/index69.js +6 -0
- package/dist/index7.js +456 -0
- package/dist/index70.js +93 -0
- package/dist/index8.js +52 -0
- package/dist/index9.js +275 -0
- package/dist/styles.css +1 -0
- package/dist/styles.css.map +1 -0
- package/package.json +109 -0
package/dist/index46.js
ADDED
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
import { Mark as y, Extension as l, mergeAttributes as p } from "@tiptap/core";
|
|
2
|
+
var d = 20, u = (t, e = 0) => {
|
|
3
|
+
const r = [];
|
|
4
|
+
return !t.children.length || e > d || Array.from(t.children).forEach((o) => {
|
|
5
|
+
o.tagName === "SPAN" ? r.push(o) : o.children.length && r.push(...u(o, e + 1));
|
|
6
|
+
}), r;
|
|
7
|
+
}, f = (t) => {
|
|
8
|
+
if (!t.children.length)
|
|
9
|
+
return;
|
|
10
|
+
const e = u(t);
|
|
11
|
+
e && e.forEach((r) => {
|
|
12
|
+
var o, n;
|
|
13
|
+
const s = r.getAttribute("style"), i = (n = (o = r.parentElement) == null ? void 0 : o.closest("span")) == null ? void 0 : n.getAttribute("style");
|
|
14
|
+
r.setAttribute("style", `${i};${s}`);
|
|
15
|
+
});
|
|
16
|
+
}, c = y.create({
|
|
17
|
+
name: "textStyle",
|
|
18
|
+
priority: 101,
|
|
19
|
+
addOptions() {
|
|
20
|
+
return {
|
|
21
|
+
HTMLAttributes: {},
|
|
22
|
+
mergeNestedSpanStyles: !0
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
parseHTML() {
|
|
26
|
+
return [
|
|
27
|
+
{
|
|
28
|
+
tag: "span",
|
|
29
|
+
consuming: !1,
|
|
30
|
+
getAttrs: (t) => t.hasAttribute("style") ? (this.options.mergeNestedSpanStyles && f(t), {}) : !1
|
|
31
|
+
}
|
|
32
|
+
];
|
|
33
|
+
},
|
|
34
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
35
|
+
return ["span", p(this.options.HTMLAttributes, t), 0];
|
|
36
|
+
},
|
|
37
|
+
addCommands() {
|
|
38
|
+
return {
|
|
39
|
+
toggleTextStyle: (t) => ({ commands: e }) => e.toggleMark(this.name, t),
|
|
40
|
+
removeEmptyTextStyle: () => ({ tr: t }) => {
|
|
41
|
+
const { selection: e } = t;
|
|
42
|
+
return t.doc.nodesBetween(e.from, e.to, (r, o) => {
|
|
43
|
+
if (r.isTextblock)
|
|
44
|
+
return !0;
|
|
45
|
+
r.marks.filter((n) => n.type === this.type).some((n) => Object.values(n.attrs).some((s) => !!s)) || t.removeMark(o, o + r.nodeSize, this.type);
|
|
46
|
+
}), !0;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
}), m = l.create({
|
|
51
|
+
name: "backgroundColor",
|
|
52
|
+
addOptions() {
|
|
53
|
+
return {
|
|
54
|
+
types: ["textStyle"]
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
addGlobalAttributes() {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
types: this.options.types,
|
|
61
|
+
attributes: {
|
|
62
|
+
backgroundColor: {
|
|
63
|
+
default: null,
|
|
64
|
+
parseHTML: (t) => {
|
|
65
|
+
var e;
|
|
66
|
+
const r = t.getAttribute("style");
|
|
67
|
+
if (r) {
|
|
68
|
+
const o = r.split(";").map((n) => n.trim()).filter(Boolean);
|
|
69
|
+
for (let n = o.length - 1; n >= 0; n -= 1) {
|
|
70
|
+
const s = o[n].split(":");
|
|
71
|
+
if (s.length >= 2) {
|
|
72
|
+
const i = s[0].trim().toLowerCase(), a = s.slice(1).join(":").trim();
|
|
73
|
+
if (i === "background-color")
|
|
74
|
+
return a.replace(/['"]+/g, "");
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return (e = t.style.backgroundColor) == null ? void 0 : e.replace(/['"]+/g, "");
|
|
79
|
+
},
|
|
80
|
+
renderHTML: (t) => t.backgroundColor ? {
|
|
81
|
+
style: `background-color: ${t.backgroundColor}`
|
|
82
|
+
} : {}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
];
|
|
87
|
+
},
|
|
88
|
+
addCommands() {
|
|
89
|
+
return {
|
|
90
|
+
setBackgroundColor: (t) => ({ chain: e }) => e().setMark("textStyle", { backgroundColor: t }).run(),
|
|
91
|
+
unsetBackgroundColor: () => ({ chain: t }) => t().setMark("textStyle", { backgroundColor: null }).removeEmptyTextStyle().run()
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}), g = l.create({
|
|
95
|
+
name: "color",
|
|
96
|
+
addOptions() {
|
|
97
|
+
return {
|
|
98
|
+
types: ["textStyle"]
|
|
99
|
+
};
|
|
100
|
+
},
|
|
101
|
+
addGlobalAttributes() {
|
|
102
|
+
return [
|
|
103
|
+
{
|
|
104
|
+
types: this.options.types,
|
|
105
|
+
attributes: {
|
|
106
|
+
color: {
|
|
107
|
+
default: null,
|
|
108
|
+
parseHTML: (t) => {
|
|
109
|
+
var e;
|
|
110
|
+
const r = t.getAttribute("style");
|
|
111
|
+
if (r) {
|
|
112
|
+
const o = r.split(";").map((n) => n.trim()).filter(Boolean);
|
|
113
|
+
for (let n = o.length - 1; n >= 0; n -= 1) {
|
|
114
|
+
const s = o[n].split(":");
|
|
115
|
+
if (s.length >= 2) {
|
|
116
|
+
const i = s[0].trim().toLowerCase(), a = s.slice(1).join(":").trim();
|
|
117
|
+
if (i === "color")
|
|
118
|
+
return a.replace(/['"]+/g, "");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return (e = t.style.color) == null ? void 0 : e.replace(/['"]+/g, "");
|
|
123
|
+
},
|
|
124
|
+
renderHTML: (t) => t.color ? {
|
|
125
|
+
style: `color: ${t.color}`
|
|
126
|
+
} : {}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
},
|
|
132
|
+
addCommands() {
|
|
133
|
+
return {
|
|
134
|
+
setColor: (t) => ({ chain: e }) => e().setMark("textStyle", { color: t }).run(),
|
|
135
|
+
unsetColor: () => ({ chain: t }) => t().setMark("textStyle", { color: null }).removeEmptyTextStyle().run()
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}), h = l.create({
|
|
139
|
+
name: "fontFamily",
|
|
140
|
+
addOptions() {
|
|
141
|
+
return {
|
|
142
|
+
types: ["textStyle"]
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
addGlobalAttributes() {
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
types: this.options.types,
|
|
149
|
+
attributes: {
|
|
150
|
+
fontFamily: {
|
|
151
|
+
default: null,
|
|
152
|
+
parseHTML: (t) => t.style.fontFamily,
|
|
153
|
+
renderHTML: (t) => t.fontFamily ? {
|
|
154
|
+
style: `font-family: ${t.fontFamily}`
|
|
155
|
+
} : {}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
},
|
|
161
|
+
addCommands() {
|
|
162
|
+
return {
|
|
163
|
+
setFontFamily: (t) => ({ chain: e }) => e().setMark("textStyle", { fontFamily: t }).run(),
|
|
164
|
+
unsetFontFamily: () => ({ chain: t }) => t().setMark("textStyle", { fontFamily: null }).removeEmptyTextStyle().run()
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
}), S = l.create({
|
|
168
|
+
name: "fontSize",
|
|
169
|
+
addOptions() {
|
|
170
|
+
return {
|
|
171
|
+
types: ["textStyle"]
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
addGlobalAttributes() {
|
|
175
|
+
return [
|
|
176
|
+
{
|
|
177
|
+
types: this.options.types,
|
|
178
|
+
attributes: {
|
|
179
|
+
fontSize: {
|
|
180
|
+
default: null,
|
|
181
|
+
parseHTML: (t) => t.style.fontSize,
|
|
182
|
+
renderHTML: (t) => t.fontSize ? {
|
|
183
|
+
style: `font-size: ${t.fontSize}`
|
|
184
|
+
} : {}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
];
|
|
189
|
+
},
|
|
190
|
+
addCommands() {
|
|
191
|
+
return {
|
|
192
|
+
setFontSize: (t) => ({ chain: e }) => e().setMark("textStyle", { fontSize: t }).run(),
|
|
193
|
+
unsetFontSize: () => ({ chain: t }) => t().setMark("textStyle", { fontSize: null }).removeEmptyTextStyle().run()
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
}), b = l.create({
|
|
197
|
+
name: "lineHeight",
|
|
198
|
+
addOptions() {
|
|
199
|
+
return {
|
|
200
|
+
types: ["textStyle"]
|
|
201
|
+
};
|
|
202
|
+
},
|
|
203
|
+
addGlobalAttributes() {
|
|
204
|
+
return [
|
|
205
|
+
{
|
|
206
|
+
types: this.options.types,
|
|
207
|
+
attributes: {
|
|
208
|
+
lineHeight: {
|
|
209
|
+
default: null,
|
|
210
|
+
parseHTML: (t) => t.style.lineHeight,
|
|
211
|
+
renderHTML: (t) => t.lineHeight ? {
|
|
212
|
+
style: `line-height: ${t.lineHeight}`
|
|
213
|
+
} : {}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
];
|
|
218
|
+
},
|
|
219
|
+
addCommands() {
|
|
220
|
+
return {
|
|
221
|
+
setLineHeight: (t) => ({ chain: e }) => e().setMark("textStyle", { lineHeight: t }).run(),
|
|
222
|
+
unsetLineHeight: () => ({ chain: t }) => t().setMark("textStyle", { lineHeight: null }).removeEmptyTextStyle().run()
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
l.create({
|
|
227
|
+
name: "textStyleKit",
|
|
228
|
+
addExtensions() {
|
|
229
|
+
const t = [];
|
|
230
|
+
return this.options.backgroundColor !== !1 && t.push(m.configure(this.options.backgroundColor)), this.options.color !== !1 && t.push(g.configure(this.options.color)), this.options.fontFamily !== !1 && t.push(h.configure(this.options.fontFamily)), this.options.fontSize !== !1 && t.push(S.configure(this.options.fontSize)), this.options.lineHeight !== !1 && t.push(b.configure(this.options.lineHeight)), this.options.textStyle !== !1 && t.push(c.configure(this.options.textStyle)), t;
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
export {
|
|
234
|
+
m as BackgroundColor,
|
|
235
|
+
g as Color,
|
|
236
|
+
h as FontFamily,
|
|
237
|
+
S as FontSize,
|
|
238
|
+
b as LineHeight,
|
|
239
|
+
c as TextStyle
|
|
240
|
+
};
|
package/dist/index47.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Mark as a, markPasteRule as s, markInputRule as l, mergeAttributes as u } from "@tiptap/core";
|
|
2
|
+
var h = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/, d = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g, m = a.create({
|
|
3
|
+
name: "highlight",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
multicolor: !1,
|
|
7
|
+
HTMLAttributes: {}
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
addAttributes() {
|
|
11
|
+
return this.options.multicolor ? {
|
|
12
|
+
color: {
|
|
13
|
+
default: null,
|
|
14
|
+
parseHTML: (r) => r.getAttribute("data-color") || r.style.backgroundColor,
|
|
15
|
+
renderHTML: (r) => r.color ? {
|
|
16
|
+
"data-color": r.color,
|
|
17
|
+
style: `background-color: ${r.color}; color: inherit`
|
|
18
|
+
} : {}
|
|
19
|
+
}
|
|
20
|
+
} : {};
|
|
21
|
+
},
|
|
22
|
+
parseHTML() {
|
|
23
|
+
return [
|
|
24
|
+
{
|
|
25
|
+
tag: "mark"
|
|
26
|
+
}
|
|
27
|
+
];
|
|
28
|
+
},
|
|
29
|
+
renderHTML({ HTMLAttributes: r }) {
|
|
30
|
+
return ["mark", u(this.options.HTMLAttributes, r), 0];
|
|
31
|
+
},
|
|
32
|
+
renderMarkdown: (r, t) => `==${t.renderChildren(r)}==`,
|
|
33
|
+
parseMarkdown: (r, t) => t.applyMark("highlight", t.parseInline(r.tokens || [])),
|
|
34
|
+
markdownTokenizer: {
|
|
35
|
+
name: "highlight",
|
|
36
|
+
level: "inline",
|
|
37
|
+
start: (r) => r.indexOf("=="),
|
|
38
|
+
tokenize(r, t, i) {
|
|
39
|
+
const e = /^(==)([^=]+)(==)/.exec(r);
|
|
40
|
+
if (e) {
|
|
41
|
+
const n = e[2].trim(), o = i.inlineTokens(n);
|
|
42
|
+
return {
|
|
43
|
+
type: "highlight",
|
|
44
|
+
raw: e[0],
|
|
45
|
+
text: n,
|
|
46
|
+
tokens: o
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
addCommands() {
|
|
52
|
+
return {
|
|
53
|
+
setHighlight: (r) => ({ commands: t }) => t.setMark(this.name, r),
|
|
54
|
+
toggleHighlight: (r) => ({ commands: t }) => t.toggleMark(this.name, r),
|
|
55
|
+
unsetHighlight: () => ({ commands: r }) => r.unsetMark(this.name)
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
addKeyboardShortcuts() {
|
|
59
|
+
return {
|
|
60
|
+
"Mod-Shift-h": () => this.editor.commands.toggleHighlight()
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
addInputRules() {
|
|
64
|
+
return [
|
|
65
|
+
l({
|
|
66
|
+
find: h,
|
|
67
|
+
type: this.type
|
|
68
|
+
})
|
|
69
|
+
];
|
|
70
|
+
},
|
|
71
|
+
addPasteRules() {
|
|
72
|
+
return [
|
|
73
|
+
s({
|
|
74
|
+
find: d,
|
|
75
|
+
type: this.type
|
|
76
|
+
})
|
|
77
|
+
];
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export {
|
|
81
|
+
m as Highlight,
|
|
82
|
+
h as inputRegex,
|
|
83
|
+
d as pasteRegex
|
|
84
|
+
};
|
package/dist/index48.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { Extension as u, callOrReturn as w, getExtensionField as S, isNodeEmpty as P, isNodeSelection as v } from "@tiptap/core";
|
|
2
|
+
import { Plugin as p, PluginKey as m } from "./index41.js";
|
|
3
|
+
import { dropCursor as z } from "./index61.js";
|
|
4
|
+
import { DecorationSet as f, Decoration as g } from "./index49.js";
|
|
5
|
+
import { gapCursor as E } from "./index52.js";
|
|
6
|
+
import { history as M, redo as N, undo as O } from "./index62.js";
|
|
7
|
+
var k = u.create({
|
|
8
|
+
name: "characterCount",
|
|
9
|
+
addOptions() {
|
|
10
|
+
return {
|
|
11
|
+
limit: null,
|
|
12
|
+
mode: "textSize",
|
|
13
|
+
textCounter: (e) => e.length,
|
|
14
|
+
wordCounter: (e) => e.split(" ").filter((t) => t !== "").length
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
addStorage() {
|
|
18
|
+
return {
|
|
19
|
+
characters: () => 0,
|
|
20
|
+
words: () => 0
|
|
21
|
+
};
|
|
22
|
+
},
|
|
23
|
+
onBeforeCreate() {
|
|
24
|
+
this.storage.characters = (e) => {
|
|
25
|
+
const t = e?.node || this.editor.state.doc;
|
|
26
|
+
if ((e?.mode || this.options.mode) === "textSize") {
|
|
27
|
+
const r = t.textBetween(0, t.content.size, void 0, " ");
|
|
28
|
+
return this.options.textCounter(r);
|
|
29
|
+
}
|
|
30
|
+
return t.nodeSize;
|
|
31
|
+
}, this.storage.words = (e) => {
|
|
32
|
+
const t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
33
|
+
return this.options.wordCounter(n);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
addProseMirrorPlugins() {
|
|
37
|
+
let e = !1;
|
|
38
|
+
return [
|
|
39
|
+
new p({
|
|
40
|
+
key: new m("characterCount"),
|
|
41
|
+
appendTransaction: (t, n, r) => {
|
|
42
|
+
if (e)
|
|
43
|
+
return;
|
|
44
|
+
const o = this.options.limit;
|
|
45
|
+
if (o == null || o === 0) {
|
|
46
|
+
e = !0;
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const s = this.storage.characters({ node: r.doc });
|
|
50
|
+
if (s > o) {
|
|
51
|
+
const i = s - o, d = 0, a = i;
|
|
52
|
+
console.warn(
|
|
53
|
+
`[CharacterCount] Initial content exceeded limit of ${o} characters. Content was automatically trimmed.`
|
|
54
|
+
);
|
|
55
|
+
const c = r.tr.deleteRange(d, a);
|
|
56
|
+
return e = !0, c;
|
|
57
|
+
}
|
|
58
|
+
e = !0;
|
|
59
|
+
},
|
|
60
|
+
filterTransaction: (t, n) => {
|
|
61
|
+
const r = this.options.limit;
|
|
62
|
+
if (!t.docChanged || r === 0 || r === null || r === void 0)
|
|
63
|
+
return !0;
|
|
64
|
+
const o = this.storage.characters({ node: n.doc }), s = this.storage.characters({ node: t.doc });
|
|
65
|
+
if (s <= r || o > r && s > r && s <= o)
|
|
66
|
+
return !0;
|
|
67
|
+
if (o > r && s > r && s > o || !t.getMeta("paste"))
|
|
68
|
+
return !1;
|
|
69
|
+
const d = t.selection.$head.pos, a = s - r, c = d - a, l = d;
|
|
70
|
+
return t.deleteRange(c, l), !(this.storage.characters({ node: t.doc }) > r);
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
u.create({
|
|
77
|
+
name: "dropCursor",
|
|
78
|
+
addOptions() {
|
|
79
|
+
return {
|
|
80
|
+
color: "currentColor",
|
|
81
|
+
width: 1,
|
|
82
|
+
class: void 0
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
addProseMirrorPlugins() {
|
|
86
|
+
return [z(this.options)];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
u.create({
|
|
90
|
+
name: "focus",
|
|
91
|
+
addOptions() {
|
|
92
|
+
return {
|
|
93
|
+
className: "has-focus",
|
|
94
|
+
mode: "all"
|
|
95
|
+
};
|
|
96
|
+
},
|
|
97
|
+
addProseMirrorPlugins() {
|
|
98
|
+
return [
|
|
99
|
+
new p({
|
|
100
|
+
key: new m("focus"),
|
|
101
|
+
props: {
|
|
102
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
103
|
+
const { isEditable: n, isFocused: r } = this.editor, { anchor: o } = t, s = [];
|
|
104
|
+
if (!n || !r)
|
|
105
|
+
return f.create(e, []);
|
|
106
|
+
let i = 0;
|
|
107
|
+
this.options.mode === "deepest" && e.descendants((a, c) => {
|
|
108
|
+
if (a.isText)
|
|
109
|
+
return;
|
|
110
|
+
if (!(o >= c && o <= c + a.nodeSize - 1))
|
|
111
|
+
return !1;
|
|
112
|
+
i += 1;
|
|
113
|
+
});
|
|
114
|
+
let d = 0;
|
|
115
|
+
return e.descendants((a, c) => {
|
|
116
|
+
if (a.isText || !(o >= c && o <= c + a.nodeSize - 1))
|
|
117
|
+
return !1;
|
|
118
|
+
if (d += 1, this.options.mode === "deepest" && i - d > 0 || this.options.mode === "shallowest" && d > 1)
|
|
119
|
+
return this.options.mode === "deepest";
|
|
120
|
+
s.push(
|
|
121
|
+
g.node(c, c + a.nodeSize, {
|
|
122
|
+
class: this.options.className
|
|
123
|
+
})
|
|
124
|
+
);
|
|
125
|
+
}), f.create(e, s);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
u.create({
|
|
133
|
+
name: "gapCursor",
|
|
134
|
+
addProseMirrorPlugins() {
|
|
135
|
+
return [E()];
|
|
136
|
+
},
|
|
137
|
+
extendNodeSchema(e) {
|
|
138
|
+
var t;
|
|
139
|
+
const n = {
|
|
140
|
+
name: e.name,
|
|
141
|
+
options: e.options,
|
|
142
|
+
storage: e.storage
|
|
143
|
+
};
|
|
144
|
+
return {
|
|
145
|
+
allowGapCursor: (t = w(S(e, "allowGapCursor", n))) != null ? t : null
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
u.create({
|
|
150
|
+
name: "placeholder",
|
|
151
|
+
addOptions() {
|
|
152
|
+
return {
|
|
153
|
+
emptyEditorClass: "is-editor-empty",
|
|
154
|
+
emptyNodeClass: "is-empty",
|
|
155
|
+
placeholder: "Write something …",
|
|
156
|
+
showOnlyWhenEditable: !0,
|
|
157
|
+
showOnlyCurrent: !0,
|
|
158
|
+
includeChildren: !1
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
addProseMirrorPlugins() {
|
|
162
|
+
return [
|
|
163
|
+
new p({
|
|
164
|
+
key: new m("placeholder"),
|
|
165
|
+
props: {
|
|
166
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
167
|
+
const n = this.editor.isEditable || !this.options.showOnlyWhenEditable, { anchor: r } = t, o = [];
|
|
168
|
+
if (!n)
|
|
169
|
+
return null;
|
|
170
|
+
const s = this.editor.isEmpty;
|
|
171
|
+
return e.descendants((i, d) => {
|
|
172
|
+
const a = r >= d && r <= d + i.nodeSize, c = !i.isLeaf && P(i);
|
|
173
|
+
if ((a || !this.options.showOnlyCurrent) && c) {
|
|
174
|
+
const l = [this.options.emptyNodeClass];
|
|
175
|
+
s && l.push(this.options.emptyEditorClass);
|
|
176
|
+
const h = g.node(d, d + i.nodeSize, {
|
|
177
|
+
class: l.join(" "),
|
|
178
|
+
"data-placeholder": typeof this.options.placeholder == "function" ? this.options.placeholder({
|
|
179
|
+
editor: this.editor,
|
|
180
|
+
node: i,
|
|
181
|
+
pos: d,
|
|
182
|
+
hasAnchor: a
|
|
183
|
+
}) : this.options.placeholder
|
|
184
|
+
});
|
|
185
|
+
o.push(h);
|
|
186
|
+
}
|
|
187
|
+
return this.options.includeChildren;
|
|
188
|
+
}), f.create(e, o);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
];
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
u.create({
|
|
196
|
+
name: "selection",
|
|
197
|
+
addOptions() {
|
|
198
|
+
return {
|
|
199
|
+
className: "selection"
|
|
200
|
+
};
|
|
201
|
+
},
|
|
202
|
+
addProseMirrorPlugins() {
|
|
203
|
+
const { editor: e, options: t } = this;
|
|
204
|
+
return [
|
|
205
|
+
new p({
|
|
206
|
+
key: new m("selection"),
|
|
207
|
+
props: {
|
|
208
|
+
decorations(n) {
|
|
209
|
+
return n.selection.empty || e.isFocused || !e.isEditable || v(n.selection) || e.view.dragging ? null : f.create(n.doc, [
|
|
210
|
+
g.inline(n.selection.from, n.selection.to, {
|
|
211
|
+
class: t.className
|
|
212
|
+
})
|
|
213
|
+
]);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
})
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
function C({ types: e, node: t }) {
|
|
221
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
222
|
+
}
|
|
223
|
+
u.create({
|
|
224
|
+
name: "trailingNode",
|
|
225
|
+
addOptions() {
|
|
226
|
+
return {
|
|
227
|
+
node: void 0,
|
|
228
|
+
notAfter: []
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
addProseMirrorPlugins() {
|
|
232
|
+
var e;
|
|
233
|
+
const t = new m(this.name), n = this.options.node || ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || "paragraph", r = Object.entries(this.editor.schema.nodes).map(([, o]) => o).filter((o) => (this.options.notAfter || []).concat(n).includes(o.name));
|
|
234
|
+
return [
|
|
235
|
+
new p({
|
|
236
|
+
key: t,
|
|
237
|
+
appendTransaction: (o, s, i) => {
|
|
238
|
+
const { doc: d, tr: a, schema: c } = i, l = t.getState(i), h = d.content.size, y = c.nodes[n];
|
|
239
|
+
if (l)
|
|
240
|
+
return a.insert(h, y.create());
|
|
241
|
+
},
|
|
242
|
+
state: {
|
|
243
|
+
init: (o, s) => {
|
|
244
|
+
const i = s.tr.doc.lastChild;
|
|
245
|
+
return !C({ node: i, types: r });
|
|
246
|
+
},
|
|
247
|
+
apply: (o, s) => {
|
|
248
|
+
if (!o.docChanged || o.getMeta("__uniqueIDTransaction"))
|
|
249
|
+
return s;
|
|
250
|
+
const i = o.doc.lastChild;
|
|
251
|
+
return !C({ node: i, types: r });
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
})
|
|
255
|
+
];
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
u.create({
|
|
259
|
+
name: "undoRedo",
|
|
260
|
+
addOptions() {
|
|
261
|
+
return {
|
|
262
|
+
depth: 100,
|
|
263
|
+
newGroupDelay: 500
|
|
264
|
+
};
|
|
265
|
+
},
|
|
266
|
+
addCommands() {
|
|
267
|
+
return {
|
|
268
|
+
undo: () => ({ state: e, dispatch: t }) => O(e, t),
|
|
269
|
+
redo: () => ({ state: e, dispatch: t }) => N(e, t)
|
|
270
|
+
};
|
|
271
|
+
},
|
|
272
|
+
addProseMirrorPlugins() {
|
|
273
|
+
return [M(this.options)];
|
|
274
|
+
},
|
|
275
|
+
addKeyboardShortcuts() {
|
|
276
|
+
return {
|
|
277
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
278
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
279
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
280
|
+
// Russian keyboard layouts
|
|
281
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
282
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
export {
|
|
287
|
+
k as CharacterCount
|
|
288
|
+
};
|