@caspeco/casper-ui-library 9.9.0 → 9.11.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/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +68 -66
- 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/@tanstack/react-virtual/dist/esm/index.js +83 -31
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +411 -226
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +33 -0
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/utils.js +29 -28
- package/dist/node_modules/@tiptap/core/dist/index.js +3953 -0
- package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +19 -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 +219 -0
- package/dist/node_modules/@tiptap/extension-document/dist/index.js +12 -0
- package/dist/node_modules/@tiptap/extension-hard-break/dist/index.js +61 -0
- package/dist/node_modules/@tiptap/extension-heading/dist/index.js +67 -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 +341 -0
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +796 -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 +446 -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/dist/packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js +506 -0
- package/package.json +14 -8
|
@@ -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,446 @@
|
|
|
1
|
+
import { Extension as p, callOrReturn as x, getExtensionField as O, isNodeSelection as _, isNodeEmpty as T } from "../../core/dist/index.js";
|
|
2
|
+
import { PluginKey as P, Plugin as C } from "../../../prosemirror-state/dist/index.js";
|
|
3
|
+
import { dropCursor as D } from "../../../prosemirror-dropcursor/dist/index.js";
|
|
4
|
+
import { DecorationSet as w, Decoration as b } from "../../../prosemirror-view/dist/index.js";
|
|
5
|
+
import { gapCursor as L } from "../../../prosemirror-gapcursor/dist/index.js";
|
|
6
|
+
import { history as k, redo as B, undo as F } from "../../../prosemirror-history/dist/index.js";
|
|
7
|
+
p.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 o = t.textBetween(0, t.content.size, void 0, " ");
|
|
29
|
+
return this.options.textCounter(o);
|
|
30
|
+
}
|
|
31
|
+
return t.nodeSize;
|
|
32
|
+
}, this.storage.words = (e) => {
|
|
33
|
+
const t = e?.node || this.editor.state.doc, n = t.textBetween(0, t.content.size, " ", " ");
|
|
34
|
+
return this.options.wordCounter(n);
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
addProseMirrorPlugins() {
|
|
38
|
+
let e = !1;
|
|
39
|
+
return [
|
|
40
|
+
new C({
|
|
41
|
+
key: new P("characterCount"),
|
|
42
|
+
appendTransaction: (t, n, o) => {
|
|
43
|
+
if (e)
|
|
44
|
+
return;
|
|
45
|
+
const r = this.options.limit, i = this.options.autoTrim;
|
|
46
|
+
if (r == null || r === 0 || i === !1) {
|
|
47
|
+
e = !0;
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const a = this.storage.characters({ node: o.doc });
|
|
51
|
+
if (a > r) {
|
|
52
|
+
const l = a - r, s = 0, d = l;
|
|
53
|
+
console.warn(
|
|
54
|
+
`[CharacterCount] Initial content exceeded limit of ${r} characters. Content was automatically trimmed.`
|
|
55
|
+
);
|
|
56
|
+
const c = o.tr.deleteRange(s, d);
|
|
57
|
+
return e = !0, c;
|
|
58
|
+
}
|
|
59
|
+
e = !0;
|
|
60
|
+
},
|
|
61
|
+
filterTransaction: (t, n) => {
|
|
62
|
+
const o = this.options.limit;
|
|
63
|
+
if (!t.docChanged || o === 0 || o === null || o === void 0)
|
|
64
|
+
return !0;
|
|
65
|
+
const r = this.storage.characters({ node: n.doc }), i = this.storage.characters({ node: t.doc });
|
|
66
|
+
if (i <= o || r > o && i > o && i <= r)
|
|
67
|
+
return !0;
|
|
68
|
+
if (r > o && i > o && i > r || !t.getMeta("paste"))
|
|
69
|
+
return !1;
|
|
70
|
+
const l = t.selection.$head.pos, s = i - o, d = l - s, c = l;
|
|
71
|
+
return t.deleteRange(d, c), !(this.storage.characters({ node: t.doc }) > o);
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
var et = p.create({
|
|
78
|
+
name: "dropCursor",
|
|
79
|
+
addOptions() {
|
|
80
|
+
return {
|
|
81
|
+
color: "currentColor",
|
|
82
|
+
width: 1,
|
|
83
|
+
class: void 0
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
addProseMirrorPlugins() {
|
|
87
|
+
return [D(this.options)];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
p.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 P("focus"),
|
|
102
|
+
props: {
|
|
103
|
+
decorations: ({ doc: e, selection: t }) => {
|
|
104
|
+
const { isEditable: n, isFocused: o } = this.editor, { anchor: r } = t, i = [];
|
|
105
|
+
if (!n || !o)
|
|
106
|
+
return w.create(e, []);
|
|
107
|
+
let a = 0;
|
|
108
|
+
this.options.mode === "deepest" && e.descendants((s, d) => {
|
|
109
|
+
if (s.isText)
|
|
110
|
+
return;
|
|
111
|
+
if (!(r >= d && r <= d + s.nodeSize - 1))
|
|
112
|
+
return !1;
|
|
113
|
+
a += 1;
|
|
114
|
+
});
|
|
115
|
+
let l = 0;
|
|
116
|
+
return e.descendants((s, d) => {
|
|
117
|
+
if (s.isText || !(r >= d && r <= d + s.nodeSize - 1))
|
|
118
|
+
return !1;
|
|
119
|
+
if (l += 1, this.options.mode === "deepest" && a - l > 0 || this.options.mode === "shallowest" && l > 1)
|
|
120
|
+
return this.options.mode === "deepest";
|
|
121
|
+
i.push(
|
|
122
|
+
b.node(d, d + s.nodeSize, {
|
|
123
|
+
class: this.options.className
|
|
124
|
+
})
|
|
125
|
+
);
|
|
126
|
+
}), w.create(e, i);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
})
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
var ot = p.create({
|
|
134
|
+
name: "gapCursor",
|
|
135
|
+
addProseMirrorPlugins() {
|
|
136
|
+
return [L()];
|
|
137
|
+
},
|
|
138
|
+
extendNodeSchema(e) {
|
|
139
|
+
var t;
|
|
140
|
+
const n = {
|
|
141
|
+
name: e.name,
|
|
142
|
+
options: e.options,
|
|
143
|
+
storage: e.storage
|
|
144
|
+
};
|
|
145
|
+
return {
|
|
146
|
+
allowGapCursor: (t = x(O(e, "allowGapCursor", n))) != null ? t : null
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
}), M = "placeholder", y = new P("tiptap__placeholder"), A = 200;
|
|
150
|
+
function N(e) {
|
|
151
|
+
const {
|
|
152
|
+
editor: t,
|
|
153
|
+
placeholder: n,
|
|
154
|
+
dataAttribute: o,
|
|
155
|
+
pos: r,
|
|
156
|
+
node: i,
|
|
157
|
+
isEmptyDoc: a,
|
|
158
|
+
hasAnchor: l,
|
|
159
|
+
classes: { emptyNode: s, emptyEditor: d }
|
|
160
|
+
} = e, c = [s];
|
|
161
|
+
return a && c.push(d), b.node(r, r + i.nodeSize, {
|
|
162
|
+
class: c.join(" "),
|
|
163
|
+
[o]: typeof n == "function" ? n({
|
|
164
|
+
editor: t,
|
|
165
|
+
node: i,
|
|
166
|
+
pos: r,
|
|
167
|
+
hasAnchor: l
|
|
168
|
+
}) : n
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function I({
|
|
172
|
+
editor: e,
|
|
173
|
+
options: t,
|
|
174
|
+
dataAttribute: n,
|
|
175
|
+
doc: o,
|
|
176
|
+
selection: r
|
|
177
|
+
}) {
|
|
178
|
+
var i, a;
|
|
179
|
+
if (!(e.isEditable || !t.showOnlyWhenEditable))
|
|
180
|
+
return null;
|
|
181
|
+
const { anchor: s } = r, d = [], c = e.isEmpty, f = {
|
|
182
|
+
emptyEditor: t.emptyEditorClass,
|
|
183
|
+
emptyNode: t.emptyNodeClass
|
|
184
|
+
};
|
|
185
|
+
if (t.showOnlyCurrent && !t.includeChildren) {
|
|
186
|
+
const u = o.resolve(s), m = u.depth > 0 ? u.node(1) : u.nodeAfter, g = u.depth > 0 ? u.before(1) : s;
|
|
187
|
+
if (m && m.type.isTextblock && T(m)) {
|
|
188
|
+
const h = s >= g && s <= g + m.nodeSize;
|
|
189
|
+
d.push(
|
|
190
|
+
N({
|
|
191
|
+
editor: e,
|
|
192
|
+
isEmptyDoc: c,
|
|
193
|
+
dataAttribute: n,
|
|
194
|
+
hasAnchor: h,
|
|
195
|
+
placeholder: t.placeholder,
|
|
196
|
+
classes: f,
|
|
197
|
+
node: m,
|
|
198
|
+
pos: g
|
|
199
|
+
})
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
const u = y.getState(e.state), m = (i = u?.topPos) != null ? i : 0, g = (a = u?.bottomPos) != null ? a : o.content.size;
|
|
204
|
+
o.nodesBetween(m, g, (h, v) => {
|
|
205
|
+
const E = s >= v && s <= v + h.nodeSize, R = !h.isLeaf && T(h);
|
|
206
|
+
return h.type.isTextblock && (E || !t.showOnlyCurrent) && R && d.push(
|
|
207
|
+
N({
|
|
208
|
+
editor: e,
|
|
209
|
+
isEmptyDoc: c,
|
|
210
|
+
dataAttribute: n,
|
|
211
|
+
hasAnchor: E,
|
|
212
|
+
placeholder: t.placeholder,
|
|
213
|
+
classes: f,
|
|
214
|
+
node: h,
|
|
215
|
+
pos: v
|
|
216
|
+
})
|
|
217
|
+
), t.includeChildren;
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
return w.create(o, d);
|
|
221
|
+
}
|
|
222
|
+
function $(e) {
|
|
223
|
+
return e.replace(/\s+/g, "-").replace(/[^a-zA-Z0-9-]/g, "").replace(/^[0-9-]+/, "").replace(/^-+/, "").toLowerCase();
|
|
224
|
+
}
|
|
225
|
+
function V(e) {
|
|
226
|
+
const t = getComputedStyle(e), n = `${t.overflow} ${t.overflowY} ${t.overflowX}`;
|
|
227
|
+
return /auto|scroll|overlay/.test(n);
|
|
228
|
+
}
|
|
229
|
+
function G(e) {
|
|
230
|
+
let t = e;
|
|
231
|
+
for (; t; ) {
|
|
232
|
+
if (V(t))
|
|
233
|
+
return t;
|
|
234
|
+
const n = t.parentElement;
|
|
235
|
+
if (!n) {
|
|
236
|
+
const o = t.getRootNode();
|
|
237
|
+
if (o instanceof ShadowRoot) {
|
|
238
|
+
t = o.host;
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
return window;
|
|
242
|
+
}
|
|
243
|
+
t = n;
|
|
244
|
+
}
|
|
245
|
+
return window;
|
|
246
|
+
}
|
|
247
|
+
function U(e) {
|
|
248
|
+
return e === window ? { top: 0, bottom: window.innerHeight } : e.getBoundingClientRect();
|
|
249
|
+
}
|
|
250
|
+
function W({
|
|
251
|
+
doc: e,
|
|
252
|
+
view: t,
|
|
253
|
+
scrollContainer: n
|
|
254
|
+
}) {
|
|
255
|
+
const o = t.dom.getBoundingClientRect(), r = n ? U(n) : { top: 0, bottom: window.innerHeight }, i = Math.max(o.top, r.top) - A, a = Math.min(o.bottom, r.bottom) + A;
|
|
256
|
+
if (i >= a)
|
|
257
|
+
return { top: 0, bottom: e.content.size };
|
|
258
|
+
const s = getComputedStyle(t.dom).direction === "rtl" ? Math.max(o.right - 2, o.left + 2) : o.left + 2, d = t.posAtCoords({ left: s, top: i + 2 }), c = t.posAtCoords({ left: s, top: a - 2 });
|
|
259
|
+
return {
|
|
260
|
+
top: d ? d.pos : 0,
|
|
261
|
+
bottom: c ? c.pos : e.content.size
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
var q = {
|
|
265
|
+
/**
|
|
266
|
+
* Initialises the viewport state with no known positions.
|
|
267
|
+
* @returns The initial viewport state.
|
|
268
|
+
*/
|
|
269
|
+
init() {
|
|
270
|
+
return { topPos: null, bottomPos: null };
|
|
271
|
+
},
|
|
272
|
+
/**
|
|
273
|
+
* Updates the viewport state from incoming transactions.
|
|
274
|
+
* @param tr - The transaction being applied.
|
|
275
|
+
* @param prev - The previous viewport state.
|
|
276
|
+
* @returns The next viewport state.
|
|
277
|
+
*/
|
|
278
|
+
apply(e, t) {
|
|
279
|
+
const n = e.getMeta(y);
|
|
280
|
+
return n?.positions ? { topPos: n.positions.top, bottomPos: n.positions.bottom } : e.docChanged ? {
|
|
281
|
+
topPos: t.topPos !== null ? e.mapping.map(t.topPos) : null,
|
|
282
|
+
bottomPos: t.bottomPos !== null ? e.mapping.map(t.bottomPos) : null
|
|
283
|
+
} : t;
|
|
284
|
+
}
|
|
285
|
+
};
|
|
286
|
+
function K(e) {
|
|
287
|
+
const t = G(e.dom), n = () => {
|
|
288
|
+
const l = W({
|
|
289
|
+
view: e,
|
|
290
|
+
doc: e.state.doc,
|
|
291
|
+
scrollContainer: t
|
|
292
|
+
}), s = y.getState(e.state);
|
|
293
|
+
if (s?.topPos === l.top && s?.bottomPos === l.bottom)
|
|
294
|
+
return;
|
|
295
|
+
const d = e.state.tr.setMeta(y, { positions: l });
|
|
296
|
+
e.dispatch(d);
|
|
297
|
+
};
|
|
298
|
+
let o = null, r = 0;
|
|
299
|
+
const i = 150, a = () => {
|
|
300
|
+
o === null && (o = requestAnimationFrame(() => {
|
|
301
|
+
o = null;
|
|
302
|
+
const l = performance.now();
|
|
303
|
+
l - r >= i ? (r = l, n()) : a();
|
|
304
|
+
}));
|
|
305
|
+
};
|
|
306
|
+
return t.addEventListener("scroll", a, { passive: !0 }), n(), {
|
|
307
|
+
update(l, s) {
|
|
308
|
+
e.state.doc.content.size !== s.doc.content.size && a();
|
|
309
|
+
},
|
|
310
|
+
destroy: () => {
|
|
311
|
+
o !== null && cancelAnimationFrame(o), t.removeEventListener("scroll", a);
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
function j({ editor: e, options: t }) {
|
|
316
|
+
const n = t.dataAttribute ? `data-${$(t.dataAttribute)}` : `data-${M}`;
|
|
317
|
+
return new C({
|
|
318
|
+
key: y,
|
|
319
|
+
state: q,
|
|
320
|
+
view: K,
|
|
321
|
+
props: {
|
|
322
|
+
decorations: ({ doc: o, selection: r }) => I({ editor: e, options: t, dataAttribute: n, doc: o, selection: r })
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
p.create({
|
|
327
|
+
name: "placeholder",
|
|
328
|
+
addOptions() {
|
|
329
|
+
return {
|
|
330
|
+
emptyEditorClass: "is-editor-empty",
|
|
331
|
+
emptyNodeClass: "is-empty",
|
|
332
|
+
dataAttribute: M,
|
|
333
|
+
placeholder: "Write something …",
|
|
334
|
+
showOnlyWhenEditable: !0,
|
|
335
|
+
showOnlyCurrent: !0,
|
|
336
|
+
includeChildren: !1
|
|
337
|
+
};
|
|
338
|
+
},
|
|
339
|
+
addProseMirrorPlugins() {
|
|
340
|
+
return [j({ editor: this.editor, options: this.options })];
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
p.create({
|
|
344
|
+
name: "selection",
|
|
345
|
+
addOptions() {
|
|
346
|
+
return {
|
|
347
|
+
className: "selection"
|
|
348
|
+
};
|
|
349
|
+
},
|
|
350
|
+
addProseMirrorPlugins() {
|
|
351
|
+
const { editor: e, options: t } = this;
|
|
352
|
+
return [
|
|
353
|
+
new C({
|
|
354
|
+
key: new P("selection"),
|
|
355
|
+
props: {
|
|
356
|
+
decorations(n) {
|
|
357
|
+
return n.selection.empty || e.isFocused || !e.isEditable || _(n.selection) || e.view.dragging ? null : w.create(n.doc, [
|
|
358
|
+
b.inline(n.selection.from, n.selection.to, {
|
|
359
|
+
class: t.className
|
|
360
|
+
})
|
|
361
|
+
]);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
})
|
|
365
|
+
];
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
var H = "skipTrailingNode";
|
|
369
|
+
function z({
|
|
370
|
+
types: e,
|
|
371
|
+
node: t
|
|
372
|
+
}) {
|
|
373
|
+
return t && Array.isArray(e) && e.includes(t.type) || t?.type === e;
|
|
374
|
+
}
|
|
375
|
+
var nt = p.create({
|
|
376
|
+
name: "trailingNode",
|
|
377
|
+
addOptions() {
|
|
378
|
+
return {
|
|
379
|
+
node: void 0,
|
|
380
|
+
notAfter: []
|
|
381
|
+
};
|
|
382
|
+
},
|
|
383
|
+
addProseMirrorPlugins() {
|
|
384
|
+
var e;
|
|
385
|
+
const t = new P(this.name), n = this.options.node || ((e = this.editor.schema.topNodeType.contentMatch.defaultType) == null ? void 0 : e.name) || "paragraph", o = Object.entries(this.editor.schema.nodes).map(([, r]) => r).filter((r) => (this.options.notAfter || []).concat(n).includes(r.name));
|
|
386
|
+
return [
|
|
387
|
+
new C({
|
|
388
|
+
key: t,
|
|
389
|
+
appendTransaction: (r, i, a) => {
|
|
390
|
+
const { doc: l, tr: s, schema: d } = a, c = t.getState(a), f = l.content.size, S = d.nodes[n];
|
|
391
|
+
if (!r.some((u) => u.getMeta(H)) && c)
|
|
392
|
+
return s.insert(f, S.create());
|
|
393
|
+
},
|
|
394
|
+
state: {
|
|
395
|
+
init: (r, i) => {
|
|
396
|
+
const a = i.tr.doc.lastChild;
|
|
397
|
+
return !z({ node: a, types: o });
|
|
398
|
+
},
|
|
399
|
+
apply: (r, i) => {
|
|
400
|
+
if (!r.docChanged || r.getMeta("__uniqueIDTransaction"))
|
|
401
|
+
return i;
|
|
402
|
+
const a = r.doc.lastChild;
|
|
403
|
+
return !z({ node: a, types: o });
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
})
|
|
407
|
+
];
|
|
408
|
+
}
|
|
409
|
+
}), rt = p.create({
|
|
410
|
+
name: "undoRedo",
|
|
411
|
+
addOptions() {
|
|
412
|
+
return {
|
|
413
|
+
depth: 100,
|
|
414
|
+
newGroupDelay: 500
|
|
415
|
+
};
|
|
416
|
+
},
|
|
417
|
+
addCommands() {
|
|
418
|
+
return {
|
|
419
|
+
undo: () => ({ state: e, dispatch: t }) => F(e, t),
|
|
420
|
+
redo: () => ({ state: e, dispatch: t }) => B(e, t)
|
|
421
|
+
};
|
|
422
|
+
},
|
|
423
|
+
addProseMirrorPlugins() {
|
|
424
|
+
return [k(this.options)];
|
|
425
|
+
},
|
|
426
|
+
addKeyboardShortcuts() {
|
|
427
|
+
return {
|
|
428
|
+
"Mod-z": () => this.editor.commands.undo(),
|
|
429
|
+
"Shift-Mod-z": () => this.editor.commands.redo(),
|
|
430
|
+
"Mod-y": () => this.editor.commands.redo(),
|
|
431
|
+
// Russian keyboard layouts
|
|
432
|
+
"Mod-я": () => this.editor.commands.undo(),
|
|
433
|
+
"Shift-Mod-я": () => this.editor.commands.redo()
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
export {
|
|
438
|
+
M as DEFAULT_DATA_ATTRIBUTE,
|
|
439
|
+
et as Dropcursor,
|
|
440
|
+
ot as Gapcursor,
|
|
441
|
+
y as PLUGIN_KEY,
|
|
442
|
+
nt as TrailingNode,
|
|
443
|
+
rt as UndoRedo,
|
|
444
|
+
$ as preparePlaceholderAttribute,
|
|
445
|
+
H as skipTrailingNodeMeta
|
|
446
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Extension as e } from "../../core/dist/index.js";
|
|
2
|
+
import { Blockquote as n } from "../../extension-blockquote/dist/index.js";
|
|
3
|
+
import { Bold as p } from "../../extension-bold/dist/index.js";
|
|
4
|
+
import { Code as f } from "../../extension-code/dist/index.js";
|
|
5
|
+
import { CodeBlock as h } from "../../extension-code-block/dist/index.js";
|
|
6
|
+
import { Document as u } from "../../extension-document/dist/index.js";
|
|
7
|
+
import { HardBreak as l } from "../../extension-hard-break/dist/index.js";
|
|
8
|
+
import { Heading as a } from "../../extension-heading/dist/index.js";
|
|
9
|
+
import { HorizontalRule as c } from "../../extension-horizontal-rule/dist/index.js";
|
|
10
|
+
import { Italic as d } from "../../extension-italic/dist/index.js";
|
|
11
|
+
import { Link as m } from "../../extension-link/dist/index.js";
|
|
12
|
+
import { BulletList as g, ListItem as k, ListKeymap as B, OrderedList as L } from "../../extension-list/dist/index.js";
|
|
13
|
+
import { Paragraph as b } from "../../extension-paragraph/dist/index.js";
|
|
14
|
+
import { Strike as x } from "../../extension-strike/dist/index.js";
|
|
15
|
+
import { Text as v } from "../../extension-text/dist/index.js";
|
|
16
|
+
import { Underline as R } from "../../extension-underline/dist/index.js";
|
|
17
|
+
import { Dropcursor as K, Gapcursor as I, UndoRedo as _, TrailingNode as q } from "../../extensions/dist/index.js";
|
|
18
|
+
var J = e.create({
|
|
19
|
+
name: "starterKit",
|
|
20
|
+
addExtensions() {
|
|
21
|
+
var i, s, t, r;
|
|
22
|
+
const o = [];
|
|
23
|
+
return this.options.bold !== !1 && o.push(p.configure(this.options.bold)), this.options.blockquote !== !1 && o.push(n.configure(this.options.blockquote)), this.options.bulletList !== !1 && o.push(g.configure(this.options.bulletList)), this.options.code !== !1 && o.push(f.configure(this.options.code)), this.options.codeBlock !== !1 && o.push(h.configure(this.options.codeBlock)), this.options.document !== !1 && o.push(u.configure(this.options.document)), this.options.dropcursor !== !1 && o.push(K.configure(this.options.dropcursor)), this.options.gapcursor !== !1 && o.push(I.configure(this.options.gapcursor)), this.options.hardBreak !== !1 && o.push(l.configure(this.options.hardBreak)), this.options.heading !== !1 && o.push(a.configure(this.options.heading)), this.options.undoRedo !== !1 && o.push(_.configure(this.options.undoRedo)), this.options.horizontalRule !== !1 && o.push(c.configure(this.options.horizontalRule)), this.options.italic !== !1 && o.push(d.configure(this.options.italic)), this.options.listItem !== !1 && o.push(k.configure(this.options.listItem)), this.options.listKeymap !== !1 && o.push(B.configure((i = this.options) == null ? void 0 : i.listKeymap)), this.options.link !== !1 && o.push(m.configure((s = this.options) == null ? void 0 : s.link)), this.options.orderedList !== !1 && o.push(L.configure(this.options.orderedList)), this.options.paragraph !== !1 && o.push(b.configure(this.options.paragraph)), this.options.strike !== !1 && o.push(x.configure(this.options.strike)), this.options.text !== !1 && o.push(v.configure(this.options.text)), this.options.underline !== !1 && o.push(R.configure((t = this.options) == null ? void 0 : t.underline)), this.options.trailingNode !== !1 && o.push(q.configure((r = this.options) == null ? void 0 : r.trailingNode)), o;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
J as StarterKit
|
|
28
|
+
};
|