@caspeco/casper-ui-library 9.9.0 → 9.10.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/dist/_virtual/index.js +5 -0
- package/dist/_virtual/index2.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.development.js +4 -0
- package/dist/_virtual/use-sync-external-store-shim.production.js +4 -0
- package/dist/_virtual/with-selector.development.js +4 -0
- package/dist/_virtual/with-selector.js +5 -0
- package/dist/_virtual/with-selector.production.js +4 -0
- package/dist/_virtual/with-selector2.js +4 -0
- package/dist/components/button/button-recipe.d.ts.map +1 -1
- package/dist/components/button/button-recipe.js +80 -39
- package/dist/components/input/input.d.ts +1 -0
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/input/types.d.ts +1 -1
- package/dist/components/input/types.d.ts.map +1 -1
- package/dist/components/rich-text-editor/boolean-control.d.ts +3 -0
- package/dist/components/rich-text-editor/boolean-control.d.ts.map +1 -0
- package/dist/components/rich-text-editor/boolean-control.js +35 -0
- package/dist/components/rich-text-editor/extensions.d.ts +4 -0
- package/dist/components/rich-text-editor/extensions.d.ts.map +1 -0
- package/dist/components/rich-text-editor/extensions.js +37 -0
- package/dist/components/rich-text-editor/index.d.ts +26 -0
- package/dist/components/rich-text-editor/index.d.ts.map +1 -0
- package/dist/components/rich-text-editor/index.js +23 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.d.ts +10 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-context.js +13 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts +11 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-control.js +202 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts +4 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor-recipe.js +58 -0
- package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts +6 -0
- package/dist/components/rich-text-editor/rich-text-editor.composition.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.d.ts +11 -0
- package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.js +60 -0
- package/dist/components/rich-text-editor/rich-text-editor.test.d.ts +2 -0
- package/dist/components/rich-text-editor/rich-text-editor.test.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts +2 -0
- package/dist/components/rich-text-editor/rich-text-editor.visual.test.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-renderer.d.ts +3 -0
- package/dist/components/rich-text-editor/rich-text-renderer.d.ts.map +1 -0
- package/dist/components/rich-text-editor/rich-text-renderer.js +21 -0
- package/dist/components/rich-text-editor/translations.d.ts +23 -0
- package/dist/components/rich-text-editor/translations.d.ts.map +1 -0
- package/dist/components/rich-text-editor/translations.js +120 -0
- package/dist/components/rich-text-editor/types.d.ts +30 -0
- package/dist/components/rich-text-editor/types.d.ts.map +1 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.d.ts +3 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.d.ts.map +1 -0
- package/dist/components/rich-text-editor/use-rich-text-editor.js +17 -0
- package/dist/components/toggle-button/toggle-button.d.ts.map +1 -1
- package/dist/components/toggle-button/toggle-button.js +11 -11
- package/dist/components/toggle-button/types.d.ts +2 -0
- package/dist/components/toggle-button/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +774 -763
- package/dist/node_modules/@tiptap/core/dist/index.js +3792 -0
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +17 -0
- package/dist/node_modules/@tiptap/extension-blockquote/dist/index.js +62 -0
- package/dist/node_modules/@tiptap/extension-bold/dist/index.js +85 -0
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +54 -0
- package/dist/node_modules/@tiptap/extension-code-block/dist/index.js +217 -0
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +12 -0
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +59 -0
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +63 -0
- package/dist/node_modules/@tiptap/extension-horizontal-rule/dist/index.js +56 -0
- package/dist/node_modules/@tiptap/extension-italic/dist/index.js +83 -0
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +313 -0
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +785 -0
- package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +49 -0
- package/dist/node_modules/@tiptap/extension-strike/dist/index.js +66 -0
- package/dist/node_modules/@tiptap/extension-text/dist/index.js +13 -0
- package/dist/node_modules/@tiptap/extension-underline/dist/index.js +65 -0
- package/dist/node_modules/@tiptap/extensions/dist/index.js +439 -0
- package/dist/node_modules/@tiptap/react/dist/index.js +501 -0
- package/dist/node_modules/@tiptap/starter-kit/dist/index.js +28 -0
- package/dist/node_modules/fast-equals/dist/es/index.js +324 -0
- package/dist/node_modules/linkifyjs/dist/linkify.js +705 -0
- package/dist/node_modules/orderedmap/dist/index.js +103 -0
- package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
- package/dist/node_modules/prosemirror-dropcursor/dist/index.js +86 -0
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +204 -0
- package/dist/node_modules/prosemirror-history/dist/index.js +248 -0
- package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
- package/dist/node_modules/prosemirror-model/dist/index.js +2736 -0
- package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
- package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
- package/dist/node_modules/prosemirror-transform/dist/index.js +1552 -0
- package/dist/node_modules/prosemirror-view/dist/index.js +3802 -0
- package/dist/node_modules/rope-sequence/dist/index.js +100 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js +58 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js +57 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js +58 -0
- package/dist/node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js +46 -0
- package/dist/node_modules/use-sync-external-store/shim/index.js +10 -0
- package/dist/node_modules/use-sync-external-store/shim/with-selector.js +10 -0
- package/dist/node_modules/w3c-keyname/index.js +93 -0
- package/package.json +7 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Node as d, mergeAttributes as u } from "../../core/dist/index.js";
|
|
2
|
+
var n = " ", p = " ", l = d.create({
|
|
3
|
+
name: "paragraph",
|
|
4
|
+
priority: 1e3,
|
|
5
|
+
addOptions() {
|
|
6
|
+
return {
|
|
7
|
+
HTMLAttributes: {}
|
|
8
|
+
};
|
|
9
|
+
},
|
|
10
|
+
group: "block",
|
|
11
|
+
content: "inline*",
|
|
12
|
+
parseHTML() {
|
|
13
|
+
return [{ tag: "p" }];
|
|
14
|
+
},
|
|
15
|
+
renderHTML({ HTMLAttributes: t }) {
|
|
16
|
+
return ["p", u(this.options.HTMLAttributes, t), 0];
|
|
17
|
+
},
|
|
18
|
+
parseMarkdown: (t, a) => {
|
|
19
|
+
const r = t.tokens || [];
|
|
20
|
+
if (r.length === 1 && r[0].type === "image")
|
|
21
|
+
return a.parseChildren([r[0]]);
|
|
22
|
+
const e = a.parseInline(r);
|
|
23
|
+
return r.length === 1 && r[0].type === "text" && (r[0].raw === n || r[0].text === n || r[0].raw === p || r[0].text === p) && e.length === 1 && e[0].type === "text" && (e[0].text === n || e[0].text === p) ? a.createNode("paragraph", void 0, []) : a.createNode("paragraph", void 0, e);
|
|
24
|
+
},
|
|
25
|
+
renderMarkdown: (t, a, r) => {
|
|
26
|
+
var e, o;
|
|
27
|
+
if (!t)
|
|
28
|
+
return "";
|
|
29
|
+
const i = Array.isArray(t.content) ? t.content : [];
|
|
30
|
+
if (i.length === 0) {
|
|
31
|
+
const s = Array.isArray((e = r?.previousNode) == null ? void 0 : e.content) ? r.previousNode.content : [];
|
|
32
|
+
return ((o = r?.previousNode) == null ? void 0 : o.type) === "paragraph" && s.length === 0 ? n : "";
|
|
33
|
+
}
|
|
34
|
+
return a.renderChildren(i);
|
|
35
|
+
},
|
|
36
|
+
addCommands() {
|
|
37
|
+
return {
|
|
38
|
+
setParagraph: () => ({ commands: t }) => t.setNode(this.name)
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
addKeyboardShortcuts() {
|
|
42
|
+
return {
|
|
43
|
+
"Mod-Alt-0": () => this.editor.commands.setParagraph()
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
l as Paragraph
|
|
49
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { Mark as r, markPasteRule as s, markInputRule as n, mergeAttributes as a } from "../../core/dist/index.js";
|
|
2
|
+
var i = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/, d = /(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g, o = r.create({
|
|
3
|
+
name: "strike",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
HTMLAttributes: {}
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
parseHTML() {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
tag: "s"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
tag: "del"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
tag: "strike"
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
style: "text-decoration",
|
|
22
|
+
consuming: !1,
|
|
23
|
+
getAttrs: (e) => e.includes("line-through") ? {} : !1
|
|
24
|
+
}
|
|
25
|
+
];
|
|
26
|
+
},
|
|
27
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
28
|
+
return ["s", a(this.options.HTMLAttributes, e), 0];
|
|
29
|
+
},
|
|
30
|
+
markdownTokenName: "del",
|
|
31
|
+
parseMarkdown: (e, t) => t.applyMark("strike", t.parseInline(e.tokens || [])),
|
|
32
|
+
renderMarkdown: (e, t) => `~~${t.renderChildren(e)}~~`,
|
|
33
|
+
addCommands() {
|
|
34
|
+
return {
|
|
35
|
+
setStrike: () => ({ commands: e }) => e.setMark(this.name),
|
|
36
|
+
toggleStrike: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
37
|
+
unsetStrike: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
addKeyboardShortcuts() {
|
|
41
|
+
return {
|
|
42
|
+
"Mod-Shift-s": () => this.editor.commands.toggleStrike()
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
addInputRules() {
|
|
46
|
+
return [
|
|
47
|
+
n({
|
|
48
|
+
find: i,
|
|
49
|
+
type: this.type
|
|
50
|
+
})
|
|
51
|
+
];
|
|
52
|
+
},
|
|
53
|
+
addPasteRules() {
|
|
54
|
+
return [
|
|
55
|
+
s({
|
|
56
|
+
find: d,
|
|
57
|
+
type: this.type
|
|
58
|
+
})
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
export {
|
|
63
|
+
o as Strike,
|
|
64
|
+
i as inputRegex,
|
|
65
|
+
d as pasteRegex
|
|
66
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Node as t } from "../../core/dist/index.js";
|
|
2
|
+
var o = t.create({
|
|
3
|
+
name: "text",
|
|
4
|
+
group: "inline",
|
|
5
|
+
parseMarkdown: (e) => ({
|
|
6
|
+
type: "text",
|
|
7
|
+
text: e.text || ""
|
|
8
|
+
}),
|
|
9
|
+
renderMarkdown: (e) => e.text || ""
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
o as Text
|
|
13
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Mark as s, mergeAttributes as d } from "../../core/dist/index.js";
|
|
2
|
+
var u = s.create({
|
|
3
|
+
name: "underline",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
HTMLAttributes: {}
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
parseHTML() {
|
|
10
|
+
return [
|
|
11
|
+
{
|
|
12
|
+
tag: "u"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
style: "text-decoration",
|
|
16
|
+
consuming: !1,
|
|
17
|
+
getAttrs: (e) => e.includes("underline") ? {} : !1
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
},
|
|
21
|
+
renderHTML({ HTMLAttributes: e }) {
|
|
22
|
+
return ["u", d(this.options.HTMLAttributes, e), 0];
|
|
23
|
+
},
|
|
24
|
+
parseMarkdown(e, n) {
|
|
25
|
+
return n.applyMark(this.name || "underline", n.parseInline(e.tokens || []));
|
|
26
|
+
},
|
|
27
|
+
renderMarkdown(e, n) {
|
|
28
|
+
return `++${n.renderChildren(e)}++`;
|
|
29
|
+
},
|
|
30
|
+
markdownTokenizer: {
|
|
31
|
+
name: "underline",
|
|
32
|
+
level: "inline",
|
|
33
|
+
start(e) {
|
|
34
|
+
return e.indexOf("++");
|
|
35
|
+
},
|
|
36
|
+
tokenize(e, n, i) {
|
|
37
|
+
const r = /^(\+\+)([\s\S]+?)(\+\+)/.exec(e);
|
|
38
|
+
if (!r)
|
|
39
|
+
return;
|
|
40
|
+
const t = r[2].trim();
|
|
41
|
+
return {
|
|
42
|
+
type: "underline",
|
|
43
|
+
raw: r[0],
|
|
44
|
+
text: t,
|
|
45
|
+
tokens: i.inlineTokens(t)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
addCommands() {
|
|
50
|
+
return {
|
|
51
|
+
setUnderline: () => ({ commands: e }) => e.setMark(this.name),
|
|
52
|
+
toggleUnderline: () => ({ commands: e }) => e.toggleMark(this.name),
|
|
53
|
+
unsetUnderline: () => ({ commands: e }) => e.unsetMark(this.name)
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
addKeyboardShortcuts() {
|
|
57
|
+
return {
|
|
58
|
+
"Mod-u": () => this.editor.commands.toggleUnderline(),
|
|
59
|
+
"Mod-U": () => this.editor.commands.toggleUnderline()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
export {
|
|
64
|
+
u as Underline
|
|
65
|
+
};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { Extension as h, callOrReturn as M, getExtensionField as A, isNodeEmpty as v, isNodeSelection as x } from "../../core/dist/index.js";
|
|
2
|
+
import { PluginKey as y, Plugin as C } from "../../../prosemirror-state/dist/index.js";
|
|
3
|
+
import { dropCursor as R } from "../../../prosemirror-dropcursor/dist/index.js";
|
|
4
|
+
import { DecorationSet as P, Decoration as w } from "../../../prosemirror-view/dist/index.js";
|
|
5
|
+
import { gapCursor as _ } from "../../../prosemirror-gapcursor/dist/index.js";
|
|
6
|
+
import { history as O, redo as D, undo as L } from "../../../prosemirror-history/dist/index.js";
|
|
7
|
+
h.create({
|
|
8
|
+
name: "characterCount",
|
|
9
|
+
addOptions() {
|
|
10
|
+
return {
|
|
11
|
+
limit: null,
|
|
12
|
+
autoTrim: !0,
|
|
13
|
+
mode: "textSize",
|
|
14
|
+
textCounter: (e) => e.length,
|
|
15
|
+
wordCounter: (e) => e.split(" ").filter((t) => t !== "").length
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
addStorage() {
|
|
19
|
+
return {
|
|
20
|
+
characters: () => 0,
|
|
21
|
+
words: () => 0
|
|
22
|
+
};
|
|
23
|
+
},
|
|
24
|
+
onBeforeCreate() {
|
|
25
|
+
this.storage.characters = (e) => {
|
|
26
|
+
const t = e?.node || this.editor.state.doc;
|
|
27
|
+
if ((e?.mode || this.options.mode) === "textSize") {
|
|
28
|
+
const n = t.textBetween(0, t.content.size, void 0, " ");
|
|
29
|
+
return this.options.textCounter(n);
|
|
30
|
+
}
|
|
31
|
+
return t.nodeSize;
|
|
32
|
+
}, this.storage.words = (e) => {
|
|
33
|
+
const t = e?.node || this.editor.state.doc, o = t.textBetween(0, t.content.size, " ", " ");
|
|
34
|
+
return this.options.wordCounter(o);
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
addProseMirrorPlugins() {
|
|
38
|
+
let e = !1;
|
|
39
|
+
return [
|
|
40
|
+
new C({
|
|
41
|
+
key: new y("characterCount"),
|
|
42
|
+
appendTransaction: (t, o, n) => {
|
|
43
|
+
if (e)
|
|
44
|
+
return;
|
|
45
|
+
const r = this.options.limit, s = this.options.autoTrim;
|
|
46
|
+
if (r == null || r === 0 || s === !1) {
|
|
47
|
+
e = !0;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const i = this.storage.characters({ node: n.doc });
|
|
51
|
+
if (i > r) {
|
|
52
|
+
const d = i - r, a = 0, c = d;
|
|
53
|
+
console.warn(
|
|
54
|
+
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
55
|
+
);
|
|
56
|
+
const l = n.tr.deleteRange(a, c);
|
|
57
|
+
return e = !0, l;
|
|
58
|
+
}
|
|
59
|
+
e = !0;
|
|
60
|
+
},
|
|
61
|
+
filterTransaction: (t, o) => {
|
|
62
|
+
const n = this.options.limit;
|
|
63
|
+
if (!t.docChanged || n === 0 || n === null || n === void 0)
|
|
64
|
+
return !0;
|
|
65
|
+
const r = this.storage.characters({ node: o.doc }), s = this.storage.characters({ node: t.doc });
|
|
66
|
+
if (s <= n || r > n && s > n && s <= r)
|
|
67
|
+
return !0;
|
|
68
|
+
if (r > n && s > n && s > r || !t.getMeta("paste"))
|
|
69
|
+
return !1;
|
|
70
|
+
const d = t.selection.$head.pos, a = s - n, c = d - a, l = d;
|
|
71
|
+
return t.deleteRange(c, l), !(this.storage.characters({ node: t.doc }) > n);
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
var V = h.create({
|
|
78
|
+
name: "dropCursor",
|
|
79
|
+
addOptions() {
|
|
80
|
+
return {
|
|
81
|
+
color: "currentColor",
|
|
82
|
+
width: 1,
|
|
83
|
+
class: void 0
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
addProseMirrorPlugins() {
|
|
87
|
+
return [R(this.options)];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
h.create({
|
|
91
|
+
name: "focus",
|
|
92
|
+
addOptions() {
|
|
93
|
+
return {
|
|
94
|
+
className: "has-focus",
|
|
95
|
+
mode: "all"
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
addProseMirrorPlugins() {
|
|
99
|
+
return [
|
|
100
|
+
new C({
|
|
101
|
+
key: new y("focus"),
|
|
102
|
+
props: {
|
|
103
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
104
|
+
const { isEditable: o, isFocused: n } = this.editor, { anchor: r } = t, s = [];
|
|
105
|
+
if (!o || !n)
|
|
106
|
+
return P.create(e, []);
|
|
107
|
+
let i = 0;
|
|
108
|
+
this.options.mode === "deepest" && e.descendants((a, c) => {
|
|
109
|
+
if (a.isText)
|
|
110
|
+
return;
|
|
111
|
+
if (!(r >= c && r <= c + a.nodeSize - 1))
|
|
112
|
+
return !1;
|
|
113
|
+
i += 1;
|
|
114
|
+
});
|
|
115
|
+
let d = 0;
|
|
116
|
+
return e.descendants((a, c) => {
|
|
117
|
+
if (a.isText || !(r >= c && r <= c + a.nodeSize - 1))
|
|
118
|
+
return !1;
|
|
119
|
+
if (d += 1, this.options.mode === "deepest" && i - d > 0 || this.options.mode === "shallowest" && d > 1)
|
|
120
|
+
return this.options.mode === "deepest";
|
|
121
|
+
s.push(
|
|
122
|
+
w.node(c, c + a.nodeSize, {
|
|
123
|
+
class: this.options.className
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}), P.create(e, s);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
var X = h.create({
|
|
134
|
+
name: "gapCursor",
|
|
135
|
+
addProseMirrorPlugins() {
|
|
136
|
+
return [_()];
|
|
137
|
+
},
|
|
138
|
+
extendNodeSchema(e) {
|
|
139
|
+
var t;
|
|
140
|
+
const o = {
|
|
141
|
+
name: e.name,
|
|
142
|
+
options: e.options,
|
|
143
|
+
storage: e.storage
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
allowGapCursor: (t = M(A(e, "allowGapCursor", o))) != null ? t : null
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
function S(e) {
|
|
151
|
+
const {
|
|
152
|
+
editor: t,
|
|
153
|
+
placeholder: o,
|
|
154
|
+
dataAttribute: n,
|
|
155
|
+
pos: r,
|
|
156
|
+
node: s,
|
|
157
|
+
isEmptyDoc: i,
|
|
158
|
+
hasAnchor: d,
|
|
159
|
+
classes: { emptyNode: a, emptyEditor: c }
|
|
160
|
+
} = e, l = [a];
|
|
161
|
+
return i && l.push(c), w.node(r, r + s.nodeSize, {
|
|
162
|
+
class: l.join(" "),
|
|
163
|
+
[n]: typeof o == "function" ? o({
|
|
164
|
+
editor: t,
|
|
165
|
+
node: s,
|
|
166
|
+
pos: r,
|
|
167
|
+
hasAnchor: d
|
|
168
|
+
}) : o
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function k(e) {
|
|
172
|
+
const t = getComputedStyle(e), o = `${t.overflow} ${t.overflowY} ${t.overflowX}`;
|
|
173
|
+
return /auto|scroll|overlay/.test(o);
|
|
174
|
+
}
|
|
175
|
+
function B(e) {
|
|
176
|
+
let t = e;
|
|
177
|
+
for (; t; ) {
|
|
178
|
+
if (k(t))
|
|
179
|
+
return t;
|
|
180
|
+
const o = t.parentElement;
|
|
181
|
+
if (!o) {
|
|
182
|
+
const n = t.getRootNode();
|
|
183
|
+
if (n instanceof ShadowRoot) {
|
|
184
|
+
t = n.host;
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
return window;
|
|
188
|
+
}
|
|
189
|
+
t = o;
|
|
190
|
+
}
|
|
191
|
+
return window;
|
|
192
|
+
}
|
|
193
|
+
function $(e) {
|
|
194
|
+
return e === window ? { top: 0, bottom: window.innerHeight } : e.getBoundingClientRect();
|
|
195
|
+
}
|
|
196
|
+
function F({
|
|
197
|
+
doc: e,
|
|
198
|
+
view: t,
|
|
199
|
+
scrollContainer: o
|
|
200
|
+
}) {
|
|
201
|
+
const n = t.dom.getBoundingClientRect(), r = o ? $(o) : { top: 0, bottom: window.innerHeight }, s = Math.max(n.top, r.top), i = Math.min(n.bottom, r.bottom);
|
|
202
|
+
if (s >= i)
|
|
203
|
+
return { top: 0, bottom: e.content.size };
|
|
204
|
+
const a = getComputedStyle(t.dom).direction === "rtl" ? Math.max(n.right - 2, n.left + 2) : n.left + 2, c = t.posAtCoords({ left: a, top: s + 2 }), l = t.posAtCoords({ left: a, top: i - 2 });
|
|
205
|
+
return {
|
|
206
|
+
top: c ? c.pos : 0,
|
|
207
|
+
bottom: l ? l.pos : e.content.size
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
function U(e, t) {
|
|
211
|
+
let o = null;
|
|
212
|
+
return { call: ((...s) => {
|
|
213
|
+
o || (e(...s), o = setTimeout(() => {
|
|
214
|
+
o = null;
|
|
215
|
+
}, t));
|
|
216
|
+
}), cancel: () => {
|
|
217
|
+
o && (clearTimeout(o), o = null);
|
|
218
|
+
} };
|
|
219
|
+
}
|
|
220
|
+
var T = "placeholder";
|
|
221
|
+
function G(e) {
|
|
222
|
+
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
223
|
+
}
|
|
224
|
+
var g = new y("tiptap__placeholder");
|
|
225
|
+
h.create({
|
|
226
|
+
name: "placeholder",
|
|
227
|
+
addOptions() {
|
|
228
|
+
return {
|
|
229
|
+
emptyEditorClass: "is-editor-empty",
|
|
230
|
+
emptyNodeClass: "is-empty",
|
|
231
|
+
dataAttribute: T,
|
|
232
|
+
placeholder: "Write something …",
|
|
233
|
+
showOnlyWhenEditable: !0,
|
|
234
|
+
showOnlyCurrent: !0,
|
|
235
|
+
includeChildren: !1
|
|
236
|
+
};
|
|
237
|
+
},
|
|
238
|
+
addProseMirrorPlugins() {
|
|
239
|
+
const e = this.options.dataAttribute ? `data-${G(this.options.dataAttribute)}` : `data-${T}`;
|
|
240
|
+
return [
|
|
241
|
+
new C({
|
|
242
|
+
state: {
|
|
243
|
+
init() {
|
|
244
|
+
return {
|
|
245
|
+
// null means "no viewport info yet" — decoration callback falls
|
|
246
|
+
// back to full document scan until the scroll handler fires.
|
|
247
|
+
topPos: null,
|
|
248
|
+
bottomPos: null
|
|
249
|
+
};
|
|
250
|
+
},
|
|
251
|
+
apply(t, o) {
|
|
252
|
+
const n = t.getMeta(g);
|
|
253
|
+
return n?.positions ? {
|
|
254
|
+
topPos: n.positions.top,
|
|
255
|
+
bottomPos: n.positions.bottom
|
|
256
|
+
} : t.docChanged ? {
|
|
257
|
+
topPos: o.topPos !== null ? t.mapping.map(o.topPos) : null,
|
|
258
|
+
bottomPos: o.bottomPos !== null ? t.mapping.map(o.bottomPos) : null
|
|
259
|
+
} : o;
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
key: g,
|
|
263
|
+
view(t) {
|
|
264
|
+
const o = B(t.dom), n = () => {
|
|
265
|
+
const d = F({
|
|
266
|
+
view: t,
|
|
267
|
+
doc: t.state.doc,
|
|
268
|
+
scrollContainer: o
|
|
269
|
+
}), a = g.getState(t.state);
|
|
270
|
+
if (a.topPos === d.top && a.bottomPos === d.bottom)
|
|
271
|
+
return;
|
|
272
|
+
const c = t.state.tr.setMeta(g, { positions: d }).setMeta("tiptap__viewportUpdate", !0);
|
|
273
|
+
t.dispatch(c);
|
|
274
|
+
}, { call: r, cancel: s } = U(n, 250), i = o;
|
|
275
|
+
return i.addEventListener("scroll", r, { passive: !0 }), n(), {
|
|
276
|
+
update(d, a) {
|
|
277
|
+
t.state.doc.content.size !== a.doc.content.size && n();
|
|
278
|
+
},
|
|
279
|
+
destroy: () => {
|
|
280
|
+
s(), i.removeEventListener("scroll", r);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
},
|
|
284
|
+
props: {
|
|
285
|
+
decorations: ({ doc: t, selection: o }) => {
|
|
286
|
+
var n, r;
|
|
287
|
+
if (!(this.editor.isEditable || !this.options.showOnlyWhenEditable))
|
|
288
|
+
return null;
|
|
289
|
+
const { anchor: i } = o, d = [], a = this.editor.isEmpty;
|
|
290
|
+
if (this.options.showOnlyCurrent && !this.options.includeChildren) {
|
|
291
|
+
const l = t.resolve(i);
|
|
292
|
+
if (l.depth > 0) {
|
|
293
|
+
const u = l.node(1), m = l.before(1);
|
|
294
|
+
if (u.type.isTextblock && v(u)) {
|
|
295
|
+
const p = i >= m && i <= m + u.nodeSize, f = S({
|
|
296
|
+
node: u,
|
|
297
|
+
dataAttribute: e,
|
|
298
|
+
hasAnchor: p,
|
|
299
|
+
placeholder: this.options.placeholder,
|
|
300
|
+
classes: {
|
|
301
|
+
emptyEditor: this.options.emptyEditorClass,
|
|
302
|
+
emptyNode: this.options.emptyNodeClass
|
|
303
|
+
},
|
|
304
|
+
editor: this.editor,
|
|
305
|
+
isEmptyDoc: a,
|
|
306
|
+
pos: l.before(1)
|
|
307
|
+
});
|
|
308
|
+
d.push(f);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
} else {
|
|
312
|
+
const l = g.getState(this.editor.state), u = (n = l.topPos) != null ? n : 0, m = (r = l.bottomPos) != null ? r : t.content.size;
|
|
313
|
+
t.nodesBetween(u, m, (p, f) => {
|
|
314
|
+
const b = i >= f && i <= f + p.nodeSize, z = !p.isLeaf && v(p);
|
|
315
|
+
if (!p.type.isTextblock)
|
|
316
|
+
return this.options.includeChildren;
|
|
317
|
+
if ((b || !this.options.showOnlyCurrent) && z) {
|
|
318
|
+
const N = S({
|
|
319
|
+
classes: { emptyEditor: this.options.emptyEditorClass, emptyNode: this.options.emptyNodeClass },
|
|
320
|
+
editor: this.editor,
|
|
321
|
+
isEmptyDoc: a,
|
|
322
|
+
dataAttribute: e,
|
|
323
|
+
hasAnchor: b,
|
|
324
|
+
placeholder: this.options.placeholder,
|
|
325
|
+
node: p,
|
|
326
|
+
pos: f
|
|
327
|
+
});
|
|
328
|
+
d.push(N);
|
|
329
|
+
}
|
|
330
|
+
return this.options.includeChildren;
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
return P.create(t, d);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
})
|
|
337
|
+
];
|
|
338
|
+
}
|
|
339
|
+
});
|
|
340
|
+
h.create({
|
|
341
|
+
name: "selection",
|
|
342
|
+
addOptions() {
|
|
343
|
+
return {
|
|
344
|
+
className: "selection"
|
|
345
|
+
};
|
|
346
|
+
},
|
|
347
|
+
addProseMirrorPlugins() {
|
|
348
|
+
const { editor: e, options: t } = this;
|
|
349
|
+
return [
|
|
350
|
+
new C({
|
|
351
|
+
key: new y("selection"),
|
|
352
|
+
props: {
|
|
353
|
+
decorations(o) {
|
|
354
|
+
return o.selection.empty || e.isFocused || !e.isEditable || x(o.selection) || e.view.dragging ? null : P.create(o.doc, [
|
|
355
|
+
w.inline(o.selection.from, o.selection.to, {
|
|
356
|
+
class: t.className
|
|
357
|
+
})
|
|
358
|
+
]);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
})
|
|
362
|
+
];
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
var I = "skipTrailingNode";
|
|
366
|
+
function E({ types: e, node: t }) {
|
|
367
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
368
|
+
}
|
|
369
|
+
var Z = h.create({
|
|
370
|
+
name: "trailingNode",
|
|
371
|
+
addOptions() {
|
|
372
|
+
return {
|
|
373
|
+
node: void 0,
|
|
374
|
+
notAfter: []
|
|
375
|
+
};
|
|
376
|
+
},
|
|
377
|
+
addProseMirrorPlugins() {
|
|
378
|
+
var e;
|
|
379
|
+
const t = new y(this.name), o = this.options.node || ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || "paragraph", n = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(o).includes(r.name));
|
|
380
|
+
return [
|
|
381
|
+
new C({
|
|
382
|
+
key: t,
|
|
383
|
+
appendTransaction: (r, s, i) => {
|
|
384
|
+
const { doc: d, tr: a, schema: c } = i, l = t.getState(i), u = d.content.size, m = c.nodes[o];
|
|
385
|
+
if (!r.some((p) => p.getMeta(I)) && l)
|
|
386
|
+
return a.insert(u, m.create());
|
|
387
|
+
},
|
|
388
|
+
state: {
|
|
389
|
+
init: (r, s) => {
|
|
390
|
+
const i = s.tr.doc.lastChild;
|
|
391
|
+
return !E({ node: i, types: n });
|
|
392
|
+
},
|
|
393
|
+
apply: (r, s) => {
|
|
394
|
+
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
395
|
+
return s;
|
|
396
|
+
const i = r.doc.lastChild;
|
|
397
|
+
return !E({ node: i, types: n });
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
})
|
|
401
|
+
];
|
|
402
|
+
}
|
|
403
|
+
}), J = h.create({
|
|
404
|
+
name: "undoRedo",
|
|
405
|
+
addOptions() {
|
|
406
|
+
return {
|
|
407
|
+
depth: 100,
|
|
408
|
+
newGroupDelay: 500
|
|
409
|
+
};
|
|
410
|
+
},
|
|
411
|
+
addCommands() {
|
|
412
|
+
return {
|
|
413
|
+
undo: () => ({ state: e, dispatch: t }) => L(e, t),
|
|
414
|
+
redo: () => ({ state: e, dispatch: t }) => D(e, t)
|
|
415
|
+
};
|
|
416
|
+
},
|
|
417
|
+
addProseMirrorPlugins() {
|
|
418
|
+
return [O(this.options)];
|
|
419
|
+
},
|
|
420
|
+
addKeyboardShortcuts() {
|
|
421
|
+
return {
|
|
422
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
423
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
424
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
425
|
+
// Russian keyboard layouts
|
|
426
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
427
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
});
|
|
431
|
+
export {
|
|
432
|
+
V as Dropcursor,
|
|
433
|
+
X as Gapcursor,
|
|
434
|
+
g as PLUGIN_KEY,
|
|
435
|
+
Z as TrailingNode,
|
|
436
|
+
J as UndoRedo,
|
|
437
|
+
G as preparePlaceholderAttribute,
|
|
438
|
+
I as skipTrailingNodeMeta
|
|
439
|
+
};
|