@lunejs/admin-ui 0.1.4 → 0.2.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.
Files changed (91) hide show
  1. package/dist/_virtual/index10.js +5 -2
  2. package/dist/_virtual/index11.js +4 -0
  3. package/dist/_virtual/index6.js +3 -3
  4. package/dist/_virtual/index8.js +3 -5
  5. package/dist/lib/api/fetchers/gql-fetcher.js +6 -6
  6. package/dist/lib/collections/components/collection-details/cards/general-card.js +20 -14
  7. package/dist/lib/custom-fields/components/fields/color.js +3 -3
  8. package/dist/lib/dashboard/pages/dashboard-page.js +5 -5
  9. package/dist/lib/product/components/product-details/cards/general-product-card.js +18 -12
  10. package/dist/node_modules/@tiptap/core/dist/index.js +3562 -0
  11. package/dist/node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.js +17 -0
  12. package/dist/node_modules/@tiptap/extension-bold/dist/index.js +80 -0
  13. package/dist/node_modules/@tiptap/extension-document/dist/index.js +13 -0
  14. package/dist/node_modules/@tiptap/extension-heading/dist/index.js +64 -0
  15. package/dist/node_modules/@tiptap/extension-italic/dist/index.js +78 -0
  16. package/dist/node_modules/@tiptap/extension-link/dist/index.js +305 -0
  17. package/dist/node_modules/@tiptap/extension-list/dist/index.js +713 -0
  18. package/dist/node_modules/@tiptap/extension-paragraph/dist/index.js +42 -0
  19. package/dist/node_modules/@tiptap/extension-table/dist/index.js +380 -0
  20. package/dist/node_modules/@tiptap/extension-text/dist/index.js +14 -0
  21. package/dist/node_modules/@tiptap/extension-text-style/dist/index.js +240 -0
  22. package/dist/node_modules/@tiptap/extension-underline/dist/index.js +66 -0
  23. package/dist/node_modules/@tiptap/react/dist/index.js +481 -0
  24. package/dist/node_modules/eventemitter3/index.js +1 -1
  25. package/dist/node_modules/eventemitter3/index2.js +1 -1
  26. package/dist/node_modules/fast-equals/dist/es/index.js +324 -0
  27. package/dist/node_modules/linkifyjs/dist/linkify.js +707 -0
  28. package/dist/node_modules/lucide-react/dist/esm/icons/baseline.js +10 -0
  29. package/dist/node_modules/lucide-react/dist/esm/icons/between-horizontal-end.js +10 -0
  30. package/dist/node_modules/lucide-react/dist/esm/icons/between-vertical-end.js +10 -0
  31. package/dist/node_modules/lucide-react/dist/esm/icons/bold.js +11 -0
  32. package/dist/node_modules/lucide-react/dist/esm/icons/grid-2x2-plus.js +16 -0
  33. package/dist/node_modules/lucide-react/dist/esm/icons/grid-2x2-x.js +16 -0
  34. package/dist/node_modules/lucide-react/dist/esm/icons/italic.js +10 -0
  35. package/dist/node_modules/lucide-react/dist/esm/icons/link.js +9 -0
  36. package/dist/node_modules/lucide-react/dist/esm/icons/list-ordered.js +13 -0
  37. package/dist/node_modules/lucide-react/dist/esm/icons/table-columns-split.js +18 -0
  38. package/dist/node_modules/lucide-react/dist/esm/icons/table-rows-split.js +18 -0
  39. package/dist/node_modules/lucide-react/dist/esm/icons/table.js +11 -0
  40. package/dist/node_modules/lucide-react/dist/esm/icons/underline.js +9 -0
  41. package/dist/node_modules/orderedmap/dist/index.js +103 -0
  42. package/dist/node_modules/prosemirror-commands/dist/index.js +388 -0
  43. package/dist/node_modules/prosemirror-keymap/dist/index.js +62 -0
  44. package/dist/node_modules/prosemirror-model/dist/index.js +2733 -0
  45. package/dist/node_modules/prosemirror-schema-list/dist/index.js +88 -0
  46. package/dist/node_modules/prosemirror-state/dist/index.js +822 -0
  47. package/dist/node_modules/prosemirror-tables/dist/index.js +1446 -0
  48. package/dist/node_modules/prosemirror-transform/dist/index.js +1520 -0
  49. package/dist/node_modules/prosemirror-view/dist/index.js +3772 -0
  50. package/dist/node_modules/react-is/index.js +1 -1
  51. package/dist/node_modules/recharts/es6/util/Events.js +1 -1
  52. package/dist/node_modules/recharts/es6/util/ReactUtils.js +1 -1
  53. package/dist/node_modules/use-sync-external-store/shim/index.js +1 -1
  54. package/dist/node_modules/w3c-keyname/index.js +93 -0
  55. package/dist/packages/lune-ui/dist/_virtual/index3.js +2 -5
  56. package/dist/packages/lune-ui/dist/_virtual/index6.js +5 -2
  57. package/dist/packages/lune-ui/dist/components/popover.js +15 -11
  58. package/dist/packages/lune-ui/dist/components/select.js +6 -6
  59. package/dist/packages/lune-ui/dist/form/form-date-picker.js +2 -2
  60. package/dist/packages/lune-ui/dist/form/form.js +4 -4
  61. package/dist/packages/lune-ui/dist/node_modules/@radix-ui/react-popover/dist/index.js +39 -38
  62. package/dist/packages/lune-ui/dist/node_modules/prop-types/index.js +1 -1
  63. package/dist/packages/lune-ui/dist/packages/lune-ui/node_modules/recharts/es6/util/Events.js +1 -1
  64. package/dist/shared/components/color-picker/color-picker.d.ts +2 -1
  65. package/dist/shared/components/color-picker/color-picker.js +11 -11
  66. package/dist/shared/components/data-table/data-table-filter.js +4 -4
  67. package/dist/shared/components/rich-editor/rich-editor.d.ts +6 -0
  68. package/dist/shared/components/rich-editor/rich-editor.js +93 -0
  69. package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.d.ts +1 -0
  70. package/dist/shared/components/rich-editor/toolbar/bold/rich-editor-toolbar-bold.js +65 -0
  71. package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.d.ts +1 -0
  72. package/dist/shared/components/rich-editor/toolbar/color/rich-editor-toolbar-color.js +65 -0
  73. package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.d.ts +1 -0
  74. package/dist/shared/components/rich-editor/toolbar/heading/rich-editor-toolbar-heading.js +114 -0
  75. package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.d.ts +1 -0
  76. package/dist/shared/components/rich-editor/toolbar/italic/rich-editor-toolbar-italic.js +65 -0
  77. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link-form.d.ts +2 -0
  78. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link-form.js +103 -0
  79. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.d.ts +1 -0
  80. package/dist/shared/components/rich-editor/toolbar/link/rich-editor-toolbar-link.js +63 -0
  81. package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.d.ts +1 -0
  82. package/dist/shared/components/rich-editor/toolbar/ol-list/rich-editor-toolbar-ul-list.js +65 -0
  83. package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.d.ts +1 -0
  84. package/dist/shared/components/rich-editor/toolbar/table/rich-editor-toolbar-table.js +107 -0
  85. package/dist/shared/components/rich-editor/toolbar/toolbar.d.ts +1 -0
  86. package/dist/shared/components/rich-editor/toolbar/toolbar.js +64 -0
  87. package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.d.ts +1 -0
  88. package/dist/shared/components/rich-editor/toolbar/ul-list/rich-editor-toolbar-ul-list.js +65 -0
  89. package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.d.ts +1 -0
  90. package/dist/shared/components/rich-editor/toolbar/underline/rich-editor-toolbar-underline.js +65 -0
  91. package/package.json +6 -1
@@ -0,0 +1,17 @@
1
+ var t = (e, n) => {
2
+ if (e === "slot")
3
+ return 0;
4
+ if (e instanceof Function)
5
+ return e(n);
6
+ const { children: r, ...s } = n ?? {};
7
+ if (e === "svg")
8
+ throw new Error("SVG elements are not supported in the JSX syntax, use the array syntax instead");
9
+ return [e, s, r];
10
+ };
11
+ export {
12
+ t as createElement,
13
+ t as h,
14
+ t as jsx,
15
+ t as jsxDEV,
16
+ t as jsxs
17
+ };
@@ -0,0 +1,80 @@
1
+ import { Mark as a, markPasteRule as r, markInputRule as s, mergeAttributes as d } from "../../core/dist/index.js";
2
+ import { createElement as n } from "../../core/dist/jsx-runtime/jsx-runtime.js";
3
+ var o = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/, l = /(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g, u = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/, i = /(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g, g = a.create({
4
+ name: "bold",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ parseHTML() {
11
+ return [
12
+ {
13
+ tag: "strong"
14
+ },
15
+ {
16
+ tag: "b",
17
+ getAttrs: (e) => e.style.fontWeight !== "normal" && null
18
+ },
19
+ {
20
+ style: "font-weight=400",
21
+ clearMark: (e) => e.type.name === this.name
22
+ },
23
+ {
24
+ style: "font-weight",
25
+ getAttrs: (e) => /^(bold(er)?|[5-9]\d{2,})$/.test(e) && null
26
+ }
27
+ ];
28
+ },
29
+ renderHTML({ HTMLAttributes: e }) {
30
+ return /* @__PURE__ */ n("strong", { ...d(this.options.HTMLAttributes, e), children: /* @__PURE__ */ n("slot", {}) });
31
+ },
32
+ markdownTokenName: "strong",
33
+ parseMarkdown: (e, t) => t.applyMark("bold", t.parseInline(e.tokens || [])),
34
+ renderMarkdown: (e, t) => `**${t.renderChildren(e)}**`,
35
+ addCommands() {
36
+ return {
37
+ setBold: () => ({ commands: e }) => e.setMark(this.name),
38
+ toggleBold: () => ({ commands: e }) => e.toggleMark(this.name),
39
+ unsetBold: () => ({ commands: e }) => e.unsetMark(this.name)
40
+ };
41
+ },
42
+ addKeyboardShortcuts() {
43
+ return {
44
+ "Mod-b": () => this.editor.commands.toggleBold(),
45
+ "Mod-B": () => this.editor.commands.toggleBold()
46
+ };
47
+ },
48
+ addInputRules() {
49
+ return [
50
+ s({
51
+ find: o,
52
+ type: this.type
53
+ }),
54
+ s({
55
+ find: u,
56
+ type: this.type
57
+ })
58
+ ];
59
+ },
60
+ addPasteRules() {
61
+ return [
62
+ r({
63
+ find: l,
64
+ type: this.type
65
+ }),
66
+ r({
67
+ find: i,
68
+ type: this.type
69
+ })
70
+ ];
71
+ }
72
+ }), _ = g;
73
+ export {
74
+ g as Bold,
75
+ _ as default,
76
+ o as starInputRegex,
77
+ l as starPasteRegex,
78
+ u as underscoreInputRegex,
79
+ i as underscorePasteRegex
80
+ };
@@ -0,0 +1,13 @@
1
+ import { Node as n } from "../../core/dist/index.js";
2
+ var t = n.create({
3
+ name: "doc",
4
+ topNode: !0,
5
+ content: "block+",
6
+ renderMarkdown: (e, r) => e.content ? r.renderChildren(e.content, `
7
+
8
+ `) : ""
9
+ }), d = t;
10
+ export {
11
+ t as Document,
12
+ d as default
13
+ };
@@ -0,0 +1,64 @@
1
+ import { Node as l, textblockTypeInputRule as a, mergeAttributes as i } from "../../core/dist/index.js";
2
+ var o = l.create({
3
+ name: "heading",
4
+ addOptions() {
5
+ return {
6
+ levels: [1, 2, 3, 4, 5, 6],
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ content: "inline*",
11
+ group: "block",
12
+ defining: !0,
13
+ addAttributes() {
14
+ return {
15
+ level: {
16
+ default: 1,
17
+ rendered: !1
18
+ }
19
+ };
20
+ },
21
+ parseHTML() {
22
+ return this.options.levels.map((e) => ({
23
+ tag: `h${e}`,
24
+ attrs: { level: e }
25
+ }));
26
+ },
27
+ renderHTML({ node: e, HTMLAttributes: t }) {
28
+ return [`h${this.options.levels.includes(e.attrs.level) ? e.attrs.level : this.options.levels[0]}`, i(this.options.HTMLAttributes, t), 0];
29
+ },
30
+ parseMarkdown: (e, t) => t.createNode("heading", { level: e.depth || 1 }, t.parseInline(e.tokens || [])),
31
+ renderMarkdown: (e, t) => {
32
+ var r;
33
+ const n = (r = e.attrs) != null && r.level ? parseInt(e.attrs.level, 10) : 1, s = "#".repeat(n);
34
+ return e.content ? `${s} ${t.renderChildren(e.content)}` : "";
35
+ },
36
+ addCommands() {
37
+ return {
38
+ setHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.setNode(this.name, e) : !1,
39
+ toggleHeading: (e) => ({ commands: t }) => this.options.levels.includes(e.level) ? t.toggleNode(this.name, "paragraph", e) : !1
40
+ };
41
+ },
42
+ addKeyboardShortcuts() {
43
+ return this.options.levels.reduce(
44
+ (e, t) => ({
45
+ ...e,
46
+ [`Mod-Alt-${t}`]: () => this.editor.commands.toggleHeading({ level: t })
47
+ }),
48
+ {}
49
+ );
50
+ },
51
+ addInputRules() {
52
+ return this.options.levels.map((e) => a({
53
+ find: new RegExp(`^(#{${Math.min(...this.options.levels)},${e}})\\s$`),
54
+ type: this.type,
55
+ getAttributes: {
56
+ level: e
57
+ }
58
+ }));
59
+ }
60
+ }), u = o;
61
+ export {
62
+ o as Heading,
63
+ u as default
64
+ };
@@ -0,0 +1,78 @@
1
+ import { Mark as s, markPasteRule as r, markInputRule as a, mergeAttributes as n } from "../../core/dist/index.js";
2
+ var i = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/, d = /(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g, l = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/, o = /(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g, u = s.create({
3
+ name: "italic",
4
+ addOptions() {
5
+ return {
6
+ HTMLAttributes: {}
7
+ };
8
+ },
9
+ parseHTML() {
10
+ return [
11
+ {
12
+ tag: "em"
13
+ },
14
+ {
15
+ tag: "i",
16
+ getAttrs: (t) => t.style.fontStyle !== "normal" && null
17
+ },
18
+ {
19
+ style: "font-style=normal",
20
+ clearMark: (t) => t.type.name === this.name
21
+ },
22
+ {
23
+ style: "font-style=italic"
24
+ }
25
+ ];
26
+ },
27
+ renderHTML({ HTMLAttributes: t }) {
28
+ return ["em", n(this.options.HTMLAttributes, t), 0];
29
+ },
30
+ addCommands() {
31
+ return {
32
+ setItalic: () => ({ commands: t }) => t.setMark(this.name),
33
+ toggleItalic: () => ({ commands: t }) => t.toggleMark(this.name),
34
+ unsetItalic: () => ({ commands: t }) => t.unsetMark(this.name)
35
+ };
36
+ },
37
+ markdownTokenName: "em",
38
+ parseMarkdown: (t, e) => e.applyMark("italic", e.parseInline(t.tokens || [])),
39
+ renderMarkdown: (t, e) => `*${e.renderChildren(t)}*`,
40
+ addKeyboardShortcuts() {
41
+ return {
42
+ "Mod-i": () => this.editor.commands.toggleItalic(),
43
+ "Mod-I": () => this.editor.commands.toggleItalic()
44
+ };
45
+ },
46
+ addInputRules() {
47
+ return [
48
+ a({
49
+ find: i,
50
+ type: this.type
51
+ }),
52
+ a({
53
+ find: l,
54
+ type: this.type
55
+ })
56
+ ];
57
+ },
58
+ addPasteRules() {
59
+ return [
60
+ r({
61
+ find: d,
62
+ type: this.type
63
+ }),
64
+ r({
65
+ find: o,
66
+ type: this.type
67
+ })
68
+ ];
69
+ }
70
+ }), p = u;
71
+ export {
72
+ u as Italic,
73
+ p as default,
74
+ i as starInputRegex,
75
+ d as starPasteRegex,
76
+ l as underscoreInputRegex,
77
+ o as underscorePasteRegex
78
+ };
@@ -0,0 +1,305 @@
1
+ import { Mark as y, markPasteRule as b, mergeAttributes as v, combineTransactionSteps as w, getChangedRanges as T, findChildrenInRange as O, getMarksBetween as _, getAttributes as R } from "../../core/dist/index.js";
2
+ import { find as M, registerCustomProtocol as C, tokenize as H, reset as I } from "../../../linkifyjs/dist/linkify.js";
3
+ import { Plugin as g, PluginKey as A } from "../../../prosemirror-state/dist/index.js";
4
+ var P = "[\0-   ᠎ -\u2029  ]", B = new RegExp(P), U = new RegExp(`${P}$`), N = new RegExp(P, "g");
5
+ function V(t) {
6
+ return t.length === 1 ? t[0].isLink : t.length === 3 && t[1].isLink ? ["()", "[]"].includes(t[0].value + t[2].value) : !1;
7
+ }
8
+ function W(t) {
9
+ return new g({
10
+ key: new A("autolink"),
11
+ appendTransaction: (e, r, o) => {
12
+ const i = e.some((s) => s.docChanged) && !r.doc.eq(o.doc), l = e.some((s) => s.getMeta("preventAutolink"));
13
+ if (!i || l)
14
+ return;
15
+ const { tr: d } = o, a = w(r.doc, [...e]);
16
+ if (T(a).forEach(({ newRange: s }) => {
17
+ const f = O(o.doc, s, (c) => c.isTextblock);
18
+ let u, p;
19
+ if (f.length > 1)
20
+ u = f[0], p = o.doc.textBetween(
21
+ u.pos,
22
+ u.pos + u.node.nodeSize,
23
+ void 0,
24
+ " "
25
+ );
26
+ else if (f.length) {
27
+ const c = o.doc.textBetween(s.from, s.to, " ", " ");
28
+ if (!U.test(c))
29
+ return;
30
+ u = f[0], p = o.doc.textBetween(u.pos, s.to, void 0, " ");
31
+ }
32
+ if (u && p) {
33
+ const c = p.split(B).filter(Boolean);
34
+ if (c.length <= 0)
35
+ return !1;
36
+ const m = c[c.length - 1], E = u.pos + p.lastIndexOf(m);
37
+ if (!m)
38
+ return !1;
39
+ const L = H(m).map((n) => n.toObject(t.defaultProtocol));
40
+ if (!V(L))
41
+ return !1;
42
+ L.filter((n) => n.isLink).map((n) => ({
43
+ ...n,
44
+ from: E + n.start + 1,
45
+ to: E + n.end + 1
46
+ })).filter((n) => o.schema.marks.code ? !o.doc.rangeHasMark(n.from, n.to, o.schema.marks.code) : !0).filter((n) => t.validate(n.value)).filter((n) => t.shouldAutoLink(n.value)).forEach((n) => {
47
+ _(n.from, n.to, o.doc).some((x) => x.mark.type === t.type) || d.addMark(
48
+ n.from,
49
+ n.to,
50
+ t.type.create({
51
+ href: n.href
52
+ })
53
+ );
54
+ });
55
+ }
56
+ }), !!d.steps.length)
57
+ return d;
58
+ }
59
+ });
60
+ }
61
+ function D(t) {
62
+ return new g({
63
+ key: new A("handleClickLink"),
64
+ props: {
65
+ handleClick: (e, r, o) => {
66
+ var i, l;
67
+ if (o.button !== 0 || !e.editable)
68
+ return !1;
69
+ let d = !1;
70
+ if (t.enableClickSelection && (d = t.editor.commands.extendMarkRange(t.type.name)), t.openOnClick) {
71
+ let a = null;
72
+ if (o.target instanceof HTMLAnchorElement)
73
+ a = o.target;
74
+ else {
75
+ let u = o.target;
76
+ const p = [];
77
+ for (; u.nodeName !== "DIV"; )
78
+ p.push(u), u = u.parentNode;
79
+ a = p.find((c) => c.nodeName === "A");
80
+ }
81
+ if (!a)
82
+ return d;
83
+ const h = R(e.state, t.type.name), s = (i = a?.href) != null ? i : h.href, f = (l = a?.target) != null ? l : h.target;
84
+ a && s && (window.open(s, f), d = !0);
85
+ }
86
+ return d;
87
+ }
88
+ }
89
+ });
90
+ }
91
+ function $(t) {
92
+ return new g({
93
+ key: new A("handlePasteLink"),
94
+ props: {
95
+ handlePaste: (e, r, o) => {
96
+ const { shouldAutoLink: i } = t, { state: l } = e, { selection: d } = l, { empty: a } = d;
97
+ if (a)
98
+ return !1;
99
+ let h = "";
100
+ o.content.forEach((f) => {
101
+ h += f.textContent;
102
+ });
103
+ const s = M(h, { defaultProtocol: t.defaultProtocol }).find(
104
+ (f) => f.isLink && f.value === h
105
+ );
106
+ return !h || !s || i !== void 0 && !i(s.href) ? !1 : t.editor.commands.setMark(t.type, {
107
+ href: s.href
108
+ });
109
+ }
110
+ }
111
+ });
112
+ }
113
+ function k(t, e) {
114
+ const r = ["http", "https", "ftp", "ftps", "mailto", "tel", "callto", "sms", "cid", "xmpp"];
115
+ return e && e.forEach((o) => {
116
+ const i = typeof o == "string" ? o : o.scheme;
117
+ i && r.push(i);
118
+ }), !t || t.replace(N, "").match(
119
+ new RegExp(
120
+ // eslint-disable-next-line no-useless-escape
121
+ `^(?:(?:${r.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,
122
+ "i"
123
+ )
124
+ );
125
+ }
126
+ var z = y.create({
127
+ name: "link",
128
+ priority: 1e3,
129
+ keepOnSplit: !1,
130
+ exitable: !0,
131
+ onCreate() {
132
+ 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((t) => {
133
+ if (typeof t == "string") {
134
+ C(t);
135
+ return;
136
+ }
137
+ C(t.scheme, t.optionalSlashes);
138
+ });
139
+ },
140
+ onDestroy() {
141
+ I();
142
+ },
143
+ inclusive() {
144
+ return this.options.autolink;
145
+ },
146
+ addOptions() {
147
+ return {
148
+ openOnClick: !0,
149
+ enableClickSelection: !1,
150
+ linkOnPaste: !0,
151
+ autolink: !0,
152
+ protocols: [],
153
+ defaultProtocol: "http",
154
+ HTMLAttributes: {
155
+ target: "_blank",
156
+ rel: "noopener noreferrer nofollow",
157
+ class: null
158
+ },
159
+ isAllowedUri: (t, e) => !!k(t, e.protocols),
160
+ validate: (t) => !!t,
161
+ shouldAutoLink: (t) => !!t
162
+ };
163
+ },
164
+ addAttributes() {
165
+ return {
166
+ href: {
167
+ default: null,
168
+ parseHTML(t) {
169
+ return t.getAttribute("href");
170
+ }
171
+ },
172
+ target: {
173
+ default: this.options.HTMLAttributes.target
174
+ },
175
+ rel: {
176
+ default: this.options.HTMLAttributes.rel
177
+ },
178
+ class: {
179
+ default: this.options.HTMLAttributes.class
180
+ }
181
+ };
182
+ },
183
+ parseHTML() {
184
+ return [
185
+ {
186
+ tag: "a[href]",
187
+ getAttrs: (t) => {
188
+ const e = t.getAttribute("href");
189
+ return !e || !this.options.isAllowedUri(e, {
190
+ defaultValidate: (r) => !!k(r, this.options.protocols),
191
+ protocols: this.options.protocols,
192
+ defaultProtocol: this.options.defaultProtocol
193
+ }) ? !1 : null;
194
+ }
195
+ }
196
+ ];
197
+ },
198
+ renderHTML({ HTMLAttributes: t }) {
199
+ return this.options.isAllowedUri(t.href, {
200
+ defaultValidate: (e) => !!k(e, this.options.protocols),
201
+ protocols: this.options.protocols,
202
+ defaultProtocol: this.options.defaultProtocol
203
+ }) ? ["a", v(this.options.HTMLAttributes, t), 0] : ["a", v(this.options.HTMLAttributes, { ...t, href: "" }), 0];
204
+ },
205
+ markdownTokenName: "link",
206
+ parseMarkdown: (t, e) => e.applyMark("link", e.parseInline(t.tokens || []), {
207
+ href: t.href,
208
+ title: t.title || null
209
+ }),
210
+ renderMarkdown: (t, e) => {
211
+ var r;
212
+ const o = ((r = t.attrs) == null ? void 0 : r.href) || "";
213
+ return `[${e.renderChildren(t)}](${o})`;
214
+ },
215
+ addCommands() {
216
+ return {
217
+ setLink: (t) => ({ chain: e }) => {
218
+ const { href: r } = t;
219
+ return this.options.isAllowedUri(r, {
220
+ defaultValidate: (o) => !!k(o, this.options.protocols),
221
+ protocols: this.options.protocols,
222
+ defaultProtocol: this.options.defaultProtocol
223
+ }) ? e().setMark(this.name, t).setMeta("preventAutolink", !0).run() : !1;
224
+ },
225
+ toggleLink: (t) => ({ chain: e }) => {
226
+ const { href: r } = t || {};
227
+ return r && !this.options.isAllowedUri(r, {
228
+ defaultValidate: (o) => !!k(o, this.options.protocols),
229
+ protocols: this.options.protocols,
230
+ defaultProtocol: this.options.defaultProtocol
231
+ }) ? !1 : e().toggleMark(this.name, t, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run();
232
+ },
233
+ unsetLink: () => ({ chain: t }) => t().unsetMark(this.name, { extendEmptyMarkRange: !0 }).setMeta("preventAutolink", !0).run()
234
+ };
235
+ },
236
+ addPasteRules() {
237
+ return [
238
+ b({
239
+ find: (t) => {
240
+ const e = [];
241
+ if (t) {
242
+ const { protocols: r, defaultProtocol: o } = this.options, i = M(t).filter(
243
+ (l) => l.isLink && this.options.isAllowedUri(l.value, {
244
+ defaultValidate: (d) => !!k(d, r),
245
+ protocols: r,
246
+ defaultProtocol: o
247
+ })
248
+ );
249
+ i.length && i.forEach((l) => {
250
+ this.options.shouldAutoLink(l.value) && e.push({
251
+ text: l.value,
252
+ data: {
253
+ href: l.href
254
+ },
255
+ index: l.start
256
+ });
257
+ });
258
+ }
259
+ return e;
260
+ },
261
+ type: this.type,
262
+ getAttributes: (t) => {
263
+ var e;
264
+ return {
265
+ href: (e = t.data) == null ? void 0 : e.href
266
+ };
267
+ }
268
+ })
269
+ ];
270
+ },
271
+ addProseMirrorPlugins() {
272
+ const t = [], { protocols: e, defaultProtocol: r } = this.options;
273
+ return this.options.autolink && t.push(
274
+ W({
275
+ type: this.type,
276
+ defaultProtocol: this.options.defaultProtocol,
277
+ validate: (o) => this.options.isAllowedUri(o, {
278
+ defaultValidate: (i) => !!k(i, e),
279
+ protocols: e,
280
+ defaultProtocol: r
281
+ }),
282
+ shouldAutoLink: this.options.shouldAutoLink
283
+ })
284
+ ), t.push(
285
+ D({
286
+ type: this.type,
287
+ editor: this.editor,
288
+ openOnClick: this.options.openOnClick === "whenNotEditable" ? !0 : this.options.openOnClick,
289
+ enableClickSelection: this.options.enableClickSelection
290
+ })
291
+ ), this.options.linkOnPaste && t.push(
292
+ $({
293
+ editor: this.editor,
294
+ defaultProtocol: this.options.defaultProtocol,
295
+ type: this.type,
296
+ shouldAutoLink: this.options.shouldAutoLink
297
+ })
298
+ ), t;
299
+ }
300
+ }), j = z;
301
+ export {
302
+ z as Link,
303
+ j as default,
304
+ k as isAllowedUri
305
+ };