@caspeco/casper-ui-library 12.0.0 → 12.1.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 +5 -5
- package/dist/_virtual/builtin_esm-external-require-react.js +1 -1
- package/dist/components/accordion/accordion-item.js +1 -1
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/alert.js +4 -4
- package/dist/components/alert/helper.d.ts +3 -3
- package/dist/components/alert/helper.d.ts.map +1 -1
- package/dist/components/alert/helper.js +1 -1
- package/dist/components/badge/badge.js +1 -1
- package/dist/components/badge/helper.d.ts +3 -3
- package/dist/components/badge/helper.d.ts.map +1 -1
- package/dist/components/badge/helper.js +1 -1
- package/dist/components/box/box.composition.d.ts.map +1 -1
- package/dist/components/breadcrumbs/breadcrumbs.js +4 -4
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +1 -1
- package/dist/components/checkbox/checkbox.js +1 -1
- package/dist/components/collapsible/collapsible.js +1 -1
- package/dist/components/combobox/combobox-button.js +1 -1
- package/dist/components/combobox/combobox-item.js +1 -1
- package/dist/components/combobox/combobox-menu.js +1 -1
- package/dist/components/combobox/combobox-recipe.js +1 -1
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/combobox.js +88 -93
- package/dist/components/date-picker/base-date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/base-date-picker.js +3 -3
- package/dist/components/date-picker/date-picker-date-cell.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker-date-cell.js +1 -1
- package/dist/components/date-picker/date-picker-header.js +3 -3
- package/dist/components/date-picker/date-picker-week-cell.js +1 -1
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/divider.js +1 -1
- package/dist/components/drawer/inline-drawer.js +1 -1
- package/dist/components/form-control/form-label.d.ts.map +1 -1
- package/dist/components/form-control/form-label.js +1 -1
- package/dist/components/heading/heading.d.ts.map +1 -1
- package/dist/components/heading/heading.js +2 -2
- package/dist/components/highlight/highlight.js +1 -1
- package/dist/components/icon/create-icon.d.ts +2 -2
- package/dist/components/icon/create-icon.d.ts.map +1 -1
- package/dist/components/icon/create-icon.js +1 -1
- package/dist/components/icon/icon.composition.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.d.ts.map +1 -1
- package/dist/components/icon-button/icon-button.js +1 -1
- package/dist/components/image-upload/image-cropper.js +1 -1
- package/dist/components/image-upload/image-upload-dropzone.js +3 -7
- package/dist/components/image-upload/image-upload-modal.d.ts.map +1 -1
- package/dist/components/image-upload/image-upload-modal.js +3 -3
- package/dist/components/image-upload/image-upload.js +1 -1
- package/dist/components/input/helper.js +1 -1
- package/dist/components/input/input-recipe.js +1 -1
- package/dist/components/input/input.js +1 -1
- package/dist/components/list/list.d.ts.map +1 -1
- package/dist/components/list/list.js +1 -1
- package/dist/components/menu/menu-divider.js +1 -1
- package/dist/components/menu/menu-group.d.ts.map +1 -1
- package/dist/components/menu/menu-group.js +1 -2
- package/dist/components/menu/menu-item.d.ts.map +1 -1
- package/dist/components/menu/menu-item.js +1 -1
- package/dist/components/menu/menu-recipe.d.ts.map +1 -1
- package/dist/components/menu/menu-recipe.js +1 -1
- package/dist/components/message/message.js +1 -1
- package/dist/components/modal/modal-close-button.js +1 -1
- package/dist/components/modal/modal.composition.d.ts.map +1 -1
- package/dist/components/navigation-list/navigation-list-item.js +3 -3
- package/dist/components/paginator/paginator-recipe.d.ts.map +1 -1
- package/dist/components/paginator/paginator-recipe.js +3 -3
- package/dist/components/phone-input/country-selector.d.ts.map +1 -1
- package/dist/components/phone-input/country-selector.js +1 -1
- package/dist/components/quantity-button/quantity-button.composition.d.ts.map +1 -1
- package/dist/components/quantity-button/quantity-button.d.ts.map +1 -1
- package/dist/components/quantity-button/quantity-button.js +1 -1
- package/dist/components/radio/hover-styles.js +1 -1
- package/dist/components/radio/radio-group-recipe.js +1 -1
- package/dist/components/radio/radio.d.ts.map +1 -1
- package/dist/components/radio/radio.js +1 -1
- package/dist/components/radio-card/hover-styles.js +1 -1
- package/dist/components/radio-card/radio-card-group.d.ts.map +1 -1
- package/dist/components/radio-card/radio-card-group.js +1 -1
- package/dist/components/radio-card/radio-card.js +3 -3
- package/dist/components/rich-text-editor/rich-text-editor-control.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-control.js +3 -7
- package/dist/components/rich-text-editor/rich-text-editor-recipe.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor-recipe.js +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.d.ts.map +1 -1
- package/dist/components/rich-text-editor/rich-text-editor.js +1 -1
- package/dist/components/segmented-control/segmented-control.d.ts.map +1 -1
- package/dist/components/segmented-control/segmented-control.js +1 -1
- package/dist/components/select/select-recipe.js +1 -1
- package/dist/components/select/select.js +1 -1
- package/dist/components/skeleton/skeleton-text.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton-text.js +1 -1
- package/dist/components/skeleton/skeleton.d.ts.map +1 -1
- package/dist/components/skeleton/skeleton.js +1 -1
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spinner/spinner.js +1 -1
- package/dist/components/stepper/step-context.d.ts +4 -4
- package/dist/components/stepper/step-context.d.ts.map +1 -1
- package/dist/components/stepper/step.d.ts.map +1 -1
- package/dist/components/stepper/step.js +3 -3
- package/dist/components/stepper/stepper.js +1 -1
- package/dist/components/stepper/types.d.ts +4 -4
- package/dist/components/stepper/types.d.ts.map +1 -1
- package/dist/components/switch/hover-styles.js +1 -1
- package/dist/components/table/table-cell.js +1 -1
- package/dist/components/table/table-column-resize-handle.js +1 -1
- package/dist/components/table/table-content.d.ts.map +1 -1
- package/dist/components/table/table-content.js +1 -1
- package/dist/components/table/table-filter.js +1 -1
- package/dist/components/table/table-header-dropdown.d.ts.map +1 -1
- package/dist/components/table/table-header-dropdown.js +1 -1
- package/dist/components/table/table-header-row.js +3 -3
- package/dist/components/table/table-recipe.js +1 -1
- package/dist/components/table/table-row-drag-handle.js +1 -1
- package/dist/components/table/table-row-expand-toggle-button.js +1 -1
- package/dist/components/table/table-sorted-reorder-prompt.js +3 -3
- package/dist/components/table/table-toolbar-settings.d.ts.map +1 -1
- package/dist/components/table/table-toolbar-settings.js +1 -1
- package/dist/components/table/table-toolbar.d.ts.map +1 -1
- package/dist/components/table/table-toolbar.js +3 -3
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/table/table.js +1 -1
- package/dist/components/tabs/tab-with-image.js +1 -1
- package/dist/components/tabs/tabs-recipe.js +1 -1
- package/dist/components/tabs/types.d.ts +2 -2
- package/dist/components/tabs/types.d.ts.map +1 -1
- package/dist/components/tag/tag-recipe.js +5 -5
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/text/text.js +2 -2
- package/dist/components/textarea/textarea-recipe.js +1 -1
- package/dist/components/toaster/toast-store.d.ts +2 -2
- package/dist/components/toaster/toast-store.d.ts.map +1 -1
- package/dist/components/toaster/toaster.js +1 -1
- package/dist/components/toggle-button/use-button-children.js +1 -1
- package/dist/components/tooltip/tooltip.js +2 -2
- package/dist/index.js +402 -402
- package/dist/node_modules/@dnd-kit/abstract/index.js +1 -1
- package/dist/node_modules/@dnd-kit/dom/index.js +11 -16
- package/dist/node_modules/@dnd-kit/dom/sortable.js +4 -4
- package/dist/node_modules/@dnd-kit/dom/utilities.js +2 -6
- package/dist/node_modules/@dnd-kit/react/hooks.js +2 -5
- package/dist/node_modules/@dnd-kit/react/sortable.js +4 -4
- package/dist/node_modules/@tanstack/table-core/build/lib/index.js +16 -30
- package/dist/node_modules/@tanstack/virtual-core/dist/esm/index.js +9 -18
- package/dist/node_modules/@tiptap/core/dist/index.js +838 -790
- package/dist/node_modules/@tiptap/extension-code/dist/index.js +14 -3
- package/dist/node_modules/@tiptap/extension-link/dist/index.js +114 -97
- package/dist/node_modules/@tiptap/extension-list/dist/index.js +133 -120
- package/dist/node_modules/@tiptap/extensions/dist/index.js +33 -33
- package/dist/node_modules/country-flag-icons/modules/react/3x2/index.js +1 -2
- package/dist/node_modules/date-fns/_lib/getTimezoneOffsetInMilliseconds.js +1 -1
- package/dist/node_modules/date-fns/getISOWeek.js +1 -1
- package/dist/node_modules/date-fns/getWeek.js +1 -1
- package/dist/node_modules/libphonenumber-js/es6-modern/metadata.js +1 -1
- package/dist/node_modules/prosemirror-commands/dist/index.js +1 -1
- package/dist/node_modules/prosemirror-gapcursor/dist/index.js +2 -6
- package/dist/node_modules/prosemirror-history/dist/index.js +27 -22
- package/dist/node_modules/prosemirror-model/dist/index.js +32 -35
- package/dist/node_modules/prosemirror-view/dist/index.js +10 -11
- package/dist/packages/casper-ui-library/node_modules/@tiptap/react/dist/index.js +74 -57
- package/dist/theme/theme-casper-ui.d.ts.map +1 -1
- package/dist/theme/theme-casper-ui.js +1 -1
- package/dist/theme/theme-style-props.d.ts +25 -25
- package/dist/theme/theme-style-props.d.ts.map +1 -1
- package/dist/theme/theme-types.d.ts +46 -10
- package/dist/theme/theme-types.d.ts.map +1 -1
- package/dist/theme/theme-types.js +2 -2
- package/dist/theme/theme-types.spec.d.ts +2 -0
- package/dist/theme/theme-types.spec.d.ts.map +1 -0
- package/dist/theme/theme.d.ts.map +1 -1
- package/dist/theme/theme.js +1 -1
- package/package.json +13 -13
|
@@ -15,7 +15,13 @@ var i = (e) => {
|
|
|
15
15
|
replaceWith: r[1]
|
|
16
16
|
});
|
|
17
17
|
return n;
|
|
18
|
-
}
|
|
18
|
+
};
|
|
19
|
+
function o(e) {
|
|
20
|
+
let t = new Set((e.match(/`+/g) || []).map((e) => e.length)), n = 1;
|
|
21
|
+
for (; t.has(n);) n += 1;
|
|
22
|
+
return n;
|
|
23
|
+
}
|
|
24
|
+
var s = e.create({
|
|
19
25
|
name: "code",
|
|
20
26
|
addOptions() {
|
|
21
27
|
return { HTMLAttributes: {} };
|
|
@@ -38,7 +44,12 @@ var i = (e) => {
|
|
|
38
44
|
type: "text",
|
|
39
45
|
text: e.text || ""
|
|
40
46
|
}]),
|
|
41
|
-
renderMarkdown: (e, t) =>
|
|
47
|
+
renderMarkdown: (e, t, n) => {
|
|
48
|
+
var r;
|
|
49
|
+
if (!e.content) return "";
|
|
50
|
+
let i = typeof (n == null || (r = n.meta) == null ? void 0 : r.markText) == "string" ? n.meta.markText : "", a = "`".repeat(o(i)), s = i.startsWith("`") || i.endsWith("`") ? " " : "";
|
|
51
|
+
return `${a}${s}${t.renderChildren(e.content)}${s}${a}`;
|
|
52
|
+
},
|
|
42
53
|
addCommands() {
|
|
43
54
|
return {
|
|
44
55
|
setCode: () => ({ commands: e }) => e.setMark(this.name),
|
|
@@ -63,4 +74,4 @@ var i = (e) => {
|
|
|
63
74
|
}
|
|
64
75
|
});
|
|
65
76
|
//#endregion
|
|
66
|
-
export {
|
|
77
|
+
export { s as Code, i as inputRegexMatch, a as pasteRegexMatch };
|
|
@@ -1,82 +1,103 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { ReplaceStep as e } from "../../../prosemirror-transform/dist/index.js";
|
|
2
|
+
import { Plugin as t, PluginKey as n } from "../../../prosemirror-state/dist/index.js";
|
|
3
|
+
import { isHistoryTransaction as r } from "../../../prosemirror-history/dist/index.js";
|
|
4
|
+
import { InputRule as i, Mark as a, PasteRule as o, combineTransactionSteps as s, findChildrenInRange as c, getAttributes as l, getChangedRanges as u, getMarksBetween as d, markInputRule as f, markPasteRule as p, mergeAttributes as m } from "../../core/dist/index.js";
|
|
5
|
+
import { find as h, registerCustomProtocol as g, reset as _, tokenize as v } from "../../../linkifyjs/dist/linkify.js";
|
|
4
6
|
//#region ../../node_modules/@tiptap/extension-link/dist/index.js
|
|
5
|
-
var
|
|
6
|
-
function
|
|
7
|
+
var y = "[\0- \xA0 -\u2029 ]", b = new RegExp(y), x = RegExp(`${y}$`), S = RegExp(`${y}+$`), C = new RegExp(y, "g");
|
|
8
|
+
function w(e, t, n) {
|
|
9
|
+
let r = e.doc.resolve(t.to);
|
|
10
|
+
if (!r.nodeBefore?.isText) return;
|
|
11
|
+
let i = e.doc.textBetween(t.from, t.to, "", "").match(S)?.[0];
|
|
12
|
+
if (!i) return;
|
|
13
|
+
let a = t.to - i.length, o = d(a, t.to, e.doc).filter((e) => e.mark.type === n);
|
|
14
|
+
if (!o.length) return;
|
|
15
|
+
let { nodeAfter: s } = r;
|
|
16
|
+
if (s && o.some((e) => e.mark.isInSet(s.marks))) return;
|
|
17
|
+
let c = e.storedMarks;
|
|
18
|
+
e.removeMark(a, t.to, n), e.setStoredMarks(c), e.selection.empty && e.selection.from === t.to && e.removeStoredMark(n);
|
|
19
|
+
}
|
|
20
|
+
function T(e) {
|
|
7
21
|
return e.length === 1 ? e[0].isLink : e.length === 3 && e[1].isLink ? ["()", "[]"].includes(e[0].value + e[2].value) : !1;
|
|
8
22
|
}
|
|
9
|
-
function
|
|
10
|
-
return new
|
|
11
|
-
key: new
|
|
12
|
-
appendTransaction: (
|
|
13
|
-
let
|
|
14
|
-
if (!
|
|
15
|
-
let { tr:
|
|
16
|
-
if (
|
|
17
|
-
let t =
|
|
18
|
-
|
|
23
|
+
function E(i) {
|
|
24
|
+
return new t({
|
|
25
|
+
key: new n("autolink"),
|
|
26
|
+
appendTransaction: (t, n, a) => {
|
|
27
|
+
let o = t.some((e) => e.docChanged) && !n.doc.eq(a.doc), l = t.some((e) => e.getMeta("preventAutolink"));
|
|
28
|
+
if (!o || l) return;
|
|
29
|
+
let { tr: f } = a, p = s(n.doc, [...t]);
|
|
30
|
+
if (!t.some(r)) {
|
|
31
|
+
let t = [];
|
|
32
|
+
p.steps.forEach((n, r) => {
|
|
33
|
+
if (!(n instanceof e) || !n.slice.size) return;
|
|
34
|
+
let i = p.mapping.slice(r + 1), a = i.map(n.from, 1), o = i.map(n.from + n.slice.size, -1);
|
|
35
|
+
a < o && t.push({
|
|
36
|
+
from: a,
|
|
37
|
+
to: o
|
|
38
|
+
});
|
|
39
|
+
}), t.sort((e, t) => t.to - e.to), t.forEach((e) => w(f, e, i.type));
|
|
40
|
+
}
|
|
41
|
+
if (u(p).forEach(({ newRange: e }) => {
|
|
42
|
+
let t = c(a.doc, e, (e) => e.isTextblock), n, r;
|
|
43
|
+
if (t.length > 1) n = t[0], r = a.doc.textBetween(n.pos, n.pos + n.node.nodeSize, void 0, " ");
|
|
19
44
|
else if (t.length) {
|
|
20
|
-
let
|
|
21
|
-
if (!
|
|
22
|
-
|
|
45
|
+
let i = a.doc.textBetween(e.from, e.to, " ", " ");
|
|
46
|
+
if (!x.test(i)) return;
|
|
47
|
+
n = t[0], r = a.doc.textBetween(n.pos, e.to, void 0, " ");
|
|
23
48
|
}
|
|
24
|
-
if (
|
|
25
|
-
let e =
|
|
49
|
+
if (n && r) {
|
|
50
|
+
let e = r.split(b).filter(Boolean);
|
|
26
51
|
if (e.length <= 0) return !1;
|
|
27
|
-
let t = e[e.length - 1], o =
|
|
52
|
+
let t = e[e.length - 1], o = n.pos + r.lastIndexOf(t);
|
|
28
53
|
if (!t) return !1;
|
|
29
|
-
let s =
|
|
30
|
-
if (!
|
|
54
|
+
let s = v(t).map((e) => e.toObject(i.defaultProtocol));
|
|
55
|
+
if (!T(s)) return !1;
|
|
31
56
|
s.filter((e) => e.isLink).map((e) => ({
|
|
32
57
|
...e,
|
|
33
58
|
from: o + e.start + 1,
|
|
34
59
|
to: o + e.end + 1
|
|
35
|
-
})).filter((e) => !
|
|
36
|
-
|
|
60
|
+
})).filter((e) => !a.schema.marks.code || !a.doc.rangeHasMark(e.from, e.to, a.schema.marks.code)).filter((e) => i.validate(e.value)).filter((e) => i.shouldAutoLink(e.value)).forEach((e) => {
|
|
61
|
+
d(e.from, e.to, a.doc).some((e) => e.mark.type === i.type) || f.addMark(e.from, e.to, i.type.create({ href: e.href }));
|
|
37
62
|
});
|
|
38
63
|
}
|
|
39
|
-
}),
|
|
64
|
+
}), f.steps.length) return f;
|
|
40
65
|
}
|
|
41
66
|
});
|
|
42
67
|
}
|
|
43
|
-
function
|
|
44
|
-
return new
|
|
45
|
-
key: new
|
|
46
|
-
props: { handleClick: (
|
|
47
|
-
if (r.button !== 0 || !
|
|
68
|
+
function D(e) {
|
|
69
|
+
return new t({
|
|
70
|
+
key: new n("handleClickLink"),
|
|
71
|
+
props: { handleClick: (t, n, r) => {
|
|
72
|
+
if (r.button !== 0 || !t.editable) return !1;
|
|
48
73
|
let i = null;
|
|
49
74
|
if (r.target instanceof HTMLAnchorElement) i = r.target;
|
|
50
75
|
else {
|
|
51
|
-
let
|
|
52
|
-
if (!
|
|
53
|
-
let
|
|
54
|
-
i =
|
|
76
|
+
let t = r.target;
|
|
77
|
+
if (!t) return !1;
|
|
78
|
+
let n = e.editor.view.dom;
|
|
79
|
+
i = t.closest("a"), i && !n.contains(i) && (i = null);
|
|
55
80
|
}
|
|
56
81
|
if (!i) return !1;
|
|
57
82
|
let a = !1;
|
|
58
|
-
if (
|
|
59
|
-
let
|
|
83
|
+
if (e.enableClickSelection && (a = e.editor.commands.extendMarkRange(e.type.name)), e.openOnClick) {
|
|
84
|
+
let n = l(t.state, e.type.name), r = i.href ?? n.href, o = i.target ?? n.target;
|
|
60
85
|
r && (window.open(r, o), a = !0);
|
|
61
86
|
}
|
|
62
87
|
return a;
|
|
63
88
|
} }
|
|
64
89
|
});
|
|
65
90
|
}
|
|
66
|
-
var
|
|
67
|
-
function
|
|
91
|
+
var O = /\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)$/, k = /\[([^[\]]+)\]\(((?:[^\s()]|\([^\s()]*\))+)(?:\s+(?:(["'])(.*?)\3|“(.*?)”|‘(.*?)’))?\)/g;
|
|
92
|
+
function A(e, t) {
|
|
68
93
|
let n = 0;
|
|
69
94
|
for (let r = t - 1; r >= 0 && e[r] === "\\"; --r) n += 1;
|
|
70
95
|
return n % 2 == 1;
|
|
71
96
|
}
|
|
72
|
-
function
|
|
97
|
+
function j(e, t) {
|
|
73
98
|
let n = 0, r = 0;
|
|
74
99
|
for (; r < t;) {
|
|
75
|
-
if (e[r] !== "`") {
|
|
76
|
-
r += 1;
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (n === 0 && E(e, r)) {
|
|
100
|
+
if (e[r] !== "`" || n === 0 && A(e, r)) {
|
|
80
101
|
r += 1;
|
|
81
102
|
continue;
|
|
82
103
|
}
|
|
@@ -86,11 +107,11 @@ function D(e, t) {
|
|
|
86
107
|
}
|
|
87
108
|
return n > 0;
|
|
88
109
|
}
|
|
89
|
-
function
|
|
110
|
+
function M(e, t, n) {
|
|
90
111
|
let [, r, i] = t;
|
|
91
|
-
return (t.index ? e[t.index - 1] : void 0) === "!" ||
|
|
112
|
+
return (t.index ? e[t.index - 1] : void 0) === "!" || A(e, t.index ?? 0) || j(e, t.index ?? 0) ? !1 : !!r.trim() && n(i);
|
|
92
113
|
}
|
|
93
|
-
function
|
|
114
|
+
function N(e) {
|
|
94
115
|
let [t, n, r, , i, a, o] = e, s = i ?? a ?? o;
|
|
95
116
|
return {
|
|
96
117
|
index: e.index ?? 0,
|
|
@@ -103,25 +124,25 @@ function k(e) {
|
|
|
103
124
|
}
|
|
104
125
|
};
|
|
105
126
|
}
|
|
106
|
-
function
|
|
127
|
+
function P(e, t) {
|
|
107
128
|
return e.index < t.index + t.text.length && t.index < e.index + e.text.length;
|
|
108
129
|
}
|
|
109
|
-
function
|
|
130
|
+
function F(e) {
|
|
110
131
|
return {
|
|
111
132
|
href: e.data?.href,
|
|
112
133
|
title: e.data?.title ?? null
|
|
113
134
|
};
|
|
114
135
|
}
|
|
115
|
-
function
|
|
116
|
-
let t =
|
|
136
|
+
function I(e) {
|
|
137
|
+
let t = f({
|
|
117
138
|
find: (t) => {
|
|
118
|
-
let n =
|
|
119
|
-
return !n || !
|
|
139
|
+
let n = O.exec(t);
|
|
140
|
+
return !n || !M(t, n, e.isAllowedHref) ? null : N(n);
|
|
120
141
|
},
|
|
121
142
|
type: e.type,
|
|
122
|
-
getAttributes:
|
|
143
|
+
getAttributes: F
|
|
123
144
|
});
|
|
124
|
-
return new
|
|
145
|
+
return new i({
|
|
125
146
|
find: t.find,
|
|
126
147
|
handler: (e) => {
|
|
127
148
|
let n = t.handler(e);
|
|
@@ -129,18 +150,18 @@ function M(e) {
|
|
|
129
150
|
}
|
|
130
151
|
});
|
|
131
152
|
}
|
|
132
|
-
function
|
|
133
|
-
let t =
|
|
153
|
+
function L(e) {
|
|
154
|
+
let t = p({
|
|
134
155
|
find: (t) => {
|
|
135
156
|
let n = [];
|
|
136
|
-
for (let r of t.matchAll(
|
|
137
|
-
let r = (e.findPlainUrls?.call(e, t) ?? []).filter((e) => !n.some((t) =>
|
|
157
|
+
for (let r of t.matchAll(k)) M(t, r, e.isAllowedHref) && n.push(N(r));
|
|
158
|
+
let r = (e.findPlainUrls?.call(e, t) ?? []).filter((e) => !n.some((t) => P(t, e)));
|
|
138
159
|
return [...n, ...r];
|
|
139
160
|
},
|
|
140
161
|
type: e.type,
|
|
141
|
-
getAttributes:
|
|
162
|
+
getAttributes: F
|
|
142
163
|
});
|
|
143
|
-
return new
|
|
164
|
+
return new o({
|
|
144
165
|
find: t.find,
|
|
145
166
|
handler: (e) => {
|
|
146
167
|
let n = t.handler(e);
|
|
@@ -148,22 +169,22 @@ function N(e) {
|
|
|
148
169
|
}
|
|
149
170
|
});
|
|
150
171
|
}
|
|
151
|
-
function
|
|
152
|
-
return new
|
|
153
|
-
key: new
|
|
154
|
-
props: { handlePaste: (
|
|
155
|
-
let { shouldAutoLink: i } =
|
|
172
|
+
function R(e) {
|
|
173
|
+
return new t({
|
|
174
|
+
key: new n("handlePasteLink"),
|
|
175
|
+
props: { handlePaste: (t, n, r) => {
|
|
176
|
+
let { shouldAutoLink: i } = e, { state: a } = t, { selection: o } = a, { empty: s } = o;
|
|
156
177
|
if (s) return !1;
|
|
157
178
|
let c = "";
|
|
158
179
|
r.content.forEach((e) => {
|
|
159
180
|
c += e.textContent;
|
|
160
181
|
});
|
|
161
|
-
let l =
|
|
162
|
-
return !c || !l || i !== void 0 && !i(l.value) ? !1 :
|
|
182
|
+
let l = h(c, { defaultProtocol: e.defaultProtocol }).find((e) => e.isLink && e.value === c);
|
|
183
|
+
return !c || !l || i !== void 0 && !i(l.value) ? !1 : e.editor.commands.setMark(e.type, { href: l.href });
|
|
163
184
|
} }
|
|
164
185
|
});
|
|
165
186
|
}
|
|
166
|
-
function
|
|
187
|
+
function z(e, t) {
|
|
167
188
|
let n = [
|
|
168
189
|
"http",
|
|
169
190
|
"https",
|
|
@@ -179,24 +200,20 @@ function F(e, t) {
|
|
|
179
200
|
return t && t.forEach((e) => {
|
|
180
201
|
let t = typeof e == "string" ? e : e.scheme;
|
|
181
202
|
t && n.push(t);
|
|
182
|
-
}), !e || e.replace(
|
|
203
|
+
}), !e || e.replace(C, "").match(RegExp(`^(?:(?:${n.map((e) => e.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")).join("|")}):|[^a-z]|[a-z0-9+.\\-]+(?:[^a-z+.\\-:]|$))`, "i"));
|
|
183
204
|
}
|
|
184
|
-
var
|
|
205
|
+
var B = a.create({
|
|
185
206
|
name: "link",
|
|
186
207
|
priority: 1e3,
|
|
187
208
|
keepOnSplit: !1,
|
|
188
209
|
exitable: !0,
|
|
189
210
|
onCreate() {
|
|
190
211
|
this.options.validate && !this.options.shouldAutoLink && (this.options.shouldAutoLink = this.options.validate, console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")), this.options.protocols.forEach((e) => {
|
|
191
|
-
|
|
192
|
-
m(e);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
m(e.scheme, e.optionalSlashes);
|
|
212
|
+
typeof e == "string" ? g(e) : g(e.scheme, e.optionalSlashes);
|
|
196
213
|
});
|
|
197
214
|
},
|
|
198
215
|
onDestroy() {
|
|
199
|
-
|
|
216
|
+
_();
|
|
200
217
|
},
|
|
201
218
|
inclusive() {
|
|
202
219
|
return this.options.autolink;
|
|
@@ -215,7 +232,7 @@ var I = r.create({
|
|
|
215
232
|
rel: "noopener noreferrer nofollow",
|
|
216
233
|
class: null
|
|
217
234
|
},
|
|
218
|
-
isAllowedUri: (e, t) => !!
|
|
235
|
+
isAllowedUri: (e, t) => !!z(e, t.protocols),
|
|
219
236
|
validate: (e) => !!e,
|
|
220
237
|
shouldAutoLink: (e) => {
|
|
221
238
|
let t = /^[a-z][a-z0-9+.-]*:\/\//i.test(e), n = /^[a-z][a-z0-9+.-]*:/i.test(e);
|
|
@@ -245,7 +262,7 @@ var I = r.create({
|
|
|
245
262
|
getAttrs: (e) => {
|
|
246
263
|
let t = e.getAttribute("href");
|
|
247
264
|
return !t || !this.options.isAllowedUri(t, {
|
|
248
|
-
defaultValidate: (e) => !!
|
|
265
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
249
266
|
protocols: this.options.protocols,
|
|
250
267
|
defaultProtocol: this.options.defaultProtocol
|
|
251
268
|
}) ? !1 : null;
|
|
@@ -254,16 +271,16 @@ var I = r.create({
|
|
|
254
271
|
},
|
|
255
272
|
renderHTML({ HTMLAttributes: e }) {
|
|
256
273
|
return this.options.isAllowedUri(e.href, {
|
|
257
|
-
defaultValidate: (e) => !!
|
|
274
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
258
275
|
protocols: this.options.protocols,
|
|
259
276
|
defaultProtocol: this.options.defaultProtocol
|
|
260
277
|
}) ? [
|
|
261
278
|
"a",
|
|
262
|
-
|
|
279
|
+
m(this.options.HTMLAttributes, e),
|
|
263
280
|
0
|
|
264
281
|
] : [
|
|
265
282
|
"a",
|
|
266
|
-
|
|
283
|
+
m(this.options.HTMLAttributes, {
|
|
267
284
|
...e,
|
|
268
285
|
href: ""
|
|
269
286
|
}),
|
|
@@ -284,7 +301,7 @@ var I = r.create({
|
|
|
284
301
|
setLink: (e) => ({ chain: t }) => {
|
|
285
302
|
let { href: n } = e;
|
|
286
303
|
return this.options.isAllowedUri(n, {
|
|
287
|
-
defaultValidate: (e) => !!
|
|
304
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
288
305
|
protocols: this.options.protocols,
|
|
289
306
|
defaultProtocol: this.options.defaultProtocol
|
|
290
307
|
}) ? t().setMark(this.name, e).setMeta("preventAutolink", !0).run() : !1;
|
|
@@ -292,7 +309,7 @@ var I = r.create({
|
|
|
292
309
|
toggleLink: (e) => ({ chain: t }) => {
|
|
293
310
|
let { href: n } = e || {};
|
|
294
311
|
return n && !this.options.isAllowedUri(n, {
|
|
295
|
-
defaultValidate: (e) => !!
|
|
312
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
296
313
|
protocols: this.options.protocols,
|
|
297
314
|
defaultProtocol: this.options.defaultProtocol
|
|
298
315
|
}) ? !1 : t().toggleMark(this.name, e, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run();
|
|
@@ -301,10 +318,10 @@ var I = r.create({
|
|
|
301
318
|
};
|
|
302
319
|
},
|
|
303
320
|
addInputRules() {
|
|
304
|
-
return this.options.markdownLinks ? [
|
|
321
|
+
return this.options.markdownLinks ? [I({
|
|
305
322
|
type: this.type,
|
|
306
323
|
isAllowedHref: (e) => this.options.isAllowedUri(e, {
|
|
307
|
-
defaultValidate: (e) => !!
|
|
324
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
308
325
|
protocols: this.options.protocols,
|
|
309
326
|
defaultProtocol: this.options.defaultProtocol
|
|
310
327
|
})
|
|
@@ -315,8 +332,8 @@ var I = r.create({
|
|
|
315
332
|
let t = [];
|
|
316
333
|
if (e) {
|
|
317
334
|
let { protocols: n, defaultProtocol: r } = this.options;
|
|
318
|
-
|
|
319
|
-
defaultValidate: (e) => !!
|
|
335
|
+
h(e).filter((e) => e.isLink && this.options.isAllowedUri(e.value, {
|
|
336
|
+
defaultValidate: (e) => !!z(e, n),
|
|
320
337
|
protocols: n,
|
|
321
338
|
defaultProtocol: r
|
|
322
339
|
})).forEach((e) => {
|
|
@@ -329,15 +346,15 @@ var I = r.create({
|
|
|
329
346
|
}
|
|
330
347
|
return t;
|
|
331
348
|
};
|
|
332
|
-
return this.options.markdownLinks ? [
|
|
349
|
+
return this.options.markdownLinks ? [L({
|
|
333
350
|
type: this.type,
|
|
334
351
|
isAllowedHref: (e) => this.options.isAllowedUri(e, {
|
|
335
|
-
defaultValidate: (e) => !!
|
|
352
|
+
defaultValidate: (e) => !!z(e, this.options.protocols),
|
|
336
353
|
protocols: this.options.protocols,
|
|
337
354
|
defaultProtocol: this.options.defaultProtocol
|
|
338
355
|
}),
|
|
339
356
|
findPlainUrls: e
|
|
340
|
-
})] : [
|
|
357
|
+
})] : [p({
|
|
341
358
|
find: e,
|
|
342
359
|
type: this.type,
|
|
343
360
|
getAttributes: (e) => ({ href: e.data?.href })
|
|
@@ -345,21 +362,21 @@ var I = r.create({
|
|
|
345
362
|
},
|
|
346
363
|
addProseMirrorPlugins() {
|
|
347
364
|
let e = [], { protocols: t, defaultProtocol: n } = this.options;
|
|
348
|
-
return this.options.autolink && e.push(
|
|
365
|
+
return this.options.autolink && e.push(E({
|
|
349
366
|
type: this.type,
|
|
350
367
|
defaultProtocol: this.options.defaultProtocol,
|
|
351
368
|
validate: (e) => this.options.isAllowedUri(e, {
|
|
352
|
-
defaultValidate: (e) => !!
|
|
369
|
+
defaultValidate: (e) => !!z(e, t),
|
|
353
370
|
protocols: t,
|
|
354
371
|
defaultProtocol: n
|
|
355
372
|
}),
|
|
356
373
|
shouldAutoLink: this.options.shouldAutoLink
|
|
357
|
-
})), e.push(
|
|
374
|
+
})), e.push(D({
|
|
358
375
|
type: this.type,
|
|
359
376
|
editor: this.editor,
|
|
360
377
|
openOnClick: this.options.openOnClick === "whenNotEditable" || this.options.openOnClick,
|
|
361
378
|
enableClickSelection: this.options.enableClickSelection
|
|
362
|
-
})), this.options.linkOnPaste && e.push(
|
|
379
|
+
})), this.options.linkOnPaste && e.push(R({
|
|
363
380
|
editor: this.editor,
|
|
364
381
|
defaultProtocol: this.options.defaultProtocol,
|
|
365
382
|
type: this.type,
|
|
@@ -368,4 +385,4 @@ var I = r.create({
|
|
|
368
385
|
}
|
|
369
386
|
});
|
|
370
387
|
//#endregion
|
|
371
|
-
export {
|
|
388
|
+
export { B as Link, z as isAllowedUri };
|