@vizel/core 0.0.1-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +44 -0
  2. package/dist/components.css +1 -0
  3. package/dist/components.css.map +1 -0
  4. package/dist/index.d.ts +2642 -0
  5. package/dist/index.js +150 -0
  6. package/dist/index10.js +118 -0
  7. package/dist/index11.js +174 -0
  8. package/dist/index12.js +78 -0
  9. package/dist/index13.js +141 -0
  10. package/dist/index14.js +150 -0
  11. package/dist/index15.js +20 -0
  12. package/dist/index16.js +17 -0
  13. package/dist/index17.js +308 -0
  14. package/dist/index18.js +52 -0
  15. package/dist/index19.js +29 -0
  16. package/dist/index2.js +93 -0
  17. package/dist/index20.js +268 -0
  18. package/dist/index21.js +72 -0
  19. package/dist/index22.js +360 -0
  20. package/dist/index23.js +87 -0
  21. package/dist/index24.js +39 -0
  22. package/dist/index25.js +95 -0
  23. package/dist/index26.js +104 -0
  24. package/dist/index27.js +136 -0
  25. package/dist/index28.js +56 -0
  26. package/dist/index29.js +69 -0
  27. package/dist/index3.js +69 -0
  28. package/dist/index30.js +40 -0
  29. package/dist/index31.js +26 -0
  30. package/dist/index32.js +15 -0
  31. package/dist/index33.js +12 -0
  32. package/dist/index34.js +19 -0
  33. package/dist/index35.js +60 -0
  34. package/dist/index36.js +17 -0
  35. package/dist/index37.js +66 -0
  36. package/dist/index38.js +6 -0
  37. package/dist/index39.js +125 -0
  38. package/dist/index4.js +89 -0
  39. package/dist/index40.js +329 -0
  40. package/dist/index41.js +489 -0
  41. package/dist/index42.js +50 -0
  42. package/dist/index43.js +676 -0
  43. package/dist/index44.js +6 -0
  44. package/dist/index45.js +6 -0
  45. package/dist/index46.js +240 -0
  46. package/dist/index47.js +84 -0
  47. package/dist/index48.js +288 -0
  48. package/dist/index49.js +1504 -0
  49. package/dist/index5.js +13 -0
  50. package/dist/index50.js +7 -0
  51. package/dist/index51.js +1563 -0
  52. package/dist/index52.js +204 -0
  53. package/dist/index53.js +725 -0
  54. package/dist/index54.js +23 -0
  55. package/dist/index55.js +12 -0
  56. package/dist/index56.js +9 -0
  57. package/dist/index57.js +10 -0
  58. package/dist/index58.js +16 -0
  59. package/dist/index59.js +21 -0
  60. package/dist/index6.js +135 -0
  61. package/dist/index60.js +27 -0
  62. package/dist/index61.js +86 -0
  63. package/dist/index62.js +248 -0
  64. package/dist/index63.js +1234 -0
  65. package/dist/index64.js +736 -0
  66. package/dist/index65.js +5 -0
  67. package/dist/index66.js +1063 -0
  68. package/dist/index67.js +57 -0
  69. package/dist/index68.js +100 -0
  70. package/dist/index69.js +6 -0
  71. package/dist/index7.js +456 -0
  72. package/dist/index70.js +93 -0
  73. package/dist/index8.js +52 -0
  74. package/dist/index9.js +275 -0
  75. package/dist/styles.css +1 -0
  76. package/dist/styles.css.map +1 -0
  77. package/package.json +109 -0
@@ -0,0 +1,57 @@
1
+ import { keyName as c, base as n } from "./index70.js";
2
+ const d = typeof navigator < "u" && /Mac|iP(hone|[oa]d)/.test(navigator.platform), y = typeof navigator < "u" && /Win/.test(navigator.platform);
3
+ function h(e) {
4
+ let r = e.split(/-(?!$)/), t = r[r.length - 1];
5
+ t == "Space" && (t = " ");
6
+ let i, f, o, a;
7
+ for (let l = 0; l < r.length - 1; l++) {
8
+ let s = r[l];
9
+ if (/^(cmd|meta|m)$/i.test(s))
10
+ a = !0;
11
+ else if (/^a(lt)?$/i.test(s))
12
+ i = !0;
13
+ else if (/^(c|ctrl|control)$/i.test(s))
14
+ f = !0;
15
+ else if (/^s(hift)?$/i.test(s))
16
+ o = !0;
17
+ else if (/^mod$/i.test(s))
18
+ d ? a = !0 : f = !0;
19
+ else
20
+ throw new Error("Unrecognized modifier name: " + s);
21
+ }
22
+ return i && (t = "Alt-" + t), f && (t = "Ctrl-" + t), a && (t = "Meta-" + t), o && (t = "Shift-" + t), t;
23
+ }
24
+ function m(e) {
25
+ let r = /* @__PURE__ */ Object.create(null);
26
+ for (let t in e)
27
+ r[h(t)] = e[t];
28
+ return r;
29
+ }
30
+ function u(e, r, t = !0) {
31
+ return r.altKey && (e = "Alt-" + e), r.ctrlKey && (e = "Ctrl-" + e), r.metaKey && (e = "Meta-" + e), t && r.shiftKey && (e = "Shift-" + e), e;
32
+ }
33
+ function K(e) {
34
+ let r = m(e);
35
+ return function(t, i) {
36
+ let f = c(i), o, a = r[u(f, i)];
37
+ if (a && a(t.state, t.dispatch, t))
38
+ return !0;
39
+ if (f.length == 1 && f != " ") {
40
+ if (i.shiftKey) {
41
+ let l = r[u(f, i, !1)];
42
+ if (l && l(t.state, t.dispatch, t))
43
+ return !0;
44
+ }
45
+ if ((i.altKey || i.metaKey || i.ctrlKey) && // Ctrl-Alt may be used for AltGr on Windows
46
+ !(y && i.ctrlKey && i.altKey) && (o = n[i.keyCode]) && o != f) {
47
+ let l = r[u(o, i)];
48
+ if (l && l(t.state, t.dispatch, t))
49
+ return !0;
50
+ }
51
+ }
52
+ return !1;
53
+ };
54
+ }
55
+ export {
56
+ K as keydownHandler
57
+ };
@@ -0,0 +1,100 @@
1
+ var l = 200, p = function() {
2
+ };
3
+ p.prototype.append = function(t) {
4
+ return t.length ? (t = p.from(t), !this.length && t || t.length < l && this.leafAppend(t) || this.length < l && t.leafPrepend(this) || this.appendInner(t)) : this;
5
+ };
6
+ p.prototype.prepend = function(t) {
7
+ return t.length ? p.from(t).append(this) : this;
8
+ };
9
+ p.prototype.appendInner = function(t) {
10
+ return new u(this, t);
11
+ };
12
+ p.prototype.slice = function(t, r) {
13
+ return t === void 0 && (t = 0), r === void 0 && (r = this.length), t >= r ? p.empty : this.sliceInner(Math.max(0, t), Math.min(this.length, r));
14
+ };
15
+ p.prototype.get = function(t) {
16
+ if (!(t < 0 || t >= this.length))
17
+ return this.getInner(t);
18
+ };
19
+ p.prototype.forEach = function(t, r, e) {
20
+ r === void 0 && (r = 0), e === void 0 && (e = this.length), r <= e ? this.forEachInner(t, r, e, 0) : this.forEachInvertedInner(t, r, e, 0);
21
+ };
22
+ p.prototype.map = function(t, r, e) {
23
+ r === void 0 && (r = 0), e === void 0 && (e = this.length);
24
+ var n = [];
25
+ return this.forEach(function(i, s) {
26
+ return n.push(t(i, s));
27
+ }, r, e), n;
28
+ };
29
+ p.from = function(t) {
30
+ return t instanceof p ? t : t && t.length ? new o(t) : p.empty;
31
+ };
32
+ var o = /* @__PURE__ */ (function(h) {
33
+ function t(e) {
34
+ h.call(this), this.values = e;
35
+ }
36
+ h && (t.__proto__ = h), t.prototype = Object.create(h && h.prototype), t.prototype.constructor = t;
37
+ var r = { length: { configurable: !0 }, depth: { configurable: !0 } };
38
+ return t.prototype.flatten = function() {
39
+ return this.values;
40
+ }, t.prototype.sliceInner = function(n, i) {
41
+ return n == 0 && i == this.length ? this : new t(this.values.slice(n, i));
42
+ }, t.prototype.getInner = function(n) {
43
+ return this.values[n];
44
+ }, t.prototype.forEachInner = function(n, i, s, f) {
45
+ for (var a = i; a < s; a++)
46
+ if (n(this.values[a], f + a) === !1)
47
+ return !1;
48
+ }, t.prototype.forEachInvertedInner = function(n, i, s, f) {
49
+ for (var a = i - 1; a >= s; a--)
50
+ if (n(this.values[a], f + a) === !1)
51
+ return !1;
52
+ }, t.prototype.leafAppend = function(n) {
53
+ if (this.length + n.length <= l)
54
+ return new t(this.values.concat(n.flatten()));
55
+ }, t.prototype.leafPrepend = function(n) {
56
+ if (this.length + n.length <= l)
57
+ return new t(n.flatten().concat(this.values));
58
+ }, r.length.get = function() {
59
+ return this.values.length;
60
+ }, r.depth.get = function() {
61
+ return 0;
62
+ }, Object.defineProperties(t.prototype, r), t;
63
+ })(p);
64
+ p.empty = new o([]);
65
+ var u = /* @__PURE__ */ (function(h) {
66
+ function t(r, e) {
67
+ h.call(this), this.left = r, this.right = e, this.length = r.length + e.length, this.depth = Math.max(r.depth, e.depth) + 1;
68
+ }
69
+ return h && (t.__proto__ = h), t.prototype = Object.create(h && h.prototype), t.prototype.constructor = t, t.prototype.flatten = function() {
70
+ return this.left.flatten().concat(this.right.flatten());
71
+ }, t.prototype.getInner = function(e) {
72
+ return e < this.left.length ? this.left.get(e) : this.right.get(e - this.left.length);
73
+ }, t.prototype.forEachInner = function(e, n, i, s) {
74
+ var f = this.left.length;
75
+ if (n < f && this.left.forEachInner(e, n, Math.min(i, f), s) === !1 || i > f && this.right.forEachInner(e, Math.max(n - f, 0), Math.min(this.length, i) - f, s + f) === !1)
76
+ return !1;
77
+ }, t.prototype.forEachInvertedInner = function(e, n, i, s) {
78
+ var f = this.left.length;
79
+ if (n > f && this.right.forEachInvertedInner(e, n - f, Math.max(i, f) - f, s + f) === !1 || i < f && this.left.forEachInvertedInner(e, Math.min(n, f), i, s) === !1)
80
+ return !1;
81
+ }, t.prototype.sliceInner = function(e, n) {
82
+ if (e == 0 && n == this.length)
83
+ return this;
84
+ var i = this.left.length;
85
+ return n <= i ? this.left.slice(e, n) : e >= i ? this.right.slice(e - i, n - i) : this.left.slice(e, i).append(this.right.slice(0, n - i));
86
+ }, t.prototype.leafAppend = function(e) {
87
+ var n = this.right.leafAppend(e);
88
+ if (n)
89
+ return new t(this.left, n);
90
+ }, t.prototype.leafPrepend = function(e) {
91
+ var n = this.left.leafPrepend(e);
92
+ if (n)
93
+ return new t(n, this.right);
94
+ }, t.prototype.appendInner = function(e) {
95
+ return this.left.depth >= Math.max(this.right.depth, e.depth) + 1 ? new t(this.left, new t(this.right, e)) : new t(this, e);
96
+ }, t;
97
+ })(p);
98
+ export {
99
+ p as default
100
+ };
@@ -0,0 +1,6 @@
1
+ function e(t) {
2
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
3
+ }
4
+ export {
5
+ e as getDefaultExportFromCjs
6
+ };
package/dist/index7.js ADDED
@@ -0,0 +1,456 @@
1
+ import { Node as w, mergeAttributes as f } from "@tiptap/core";
2
+ import { PluginKey as b, Plugin as v } from "./index41.js";
3
+ const u = [
4
+ // Video - these providers support CORS on their oEmbed endpoints
5
+ {
6
+ name: "youtube",
7
+ patterns: [
8
+ /^https?:\/\/(www\.)?youtube\.com\/watch\?v=[\w-]+/,
9
+ /^https?:\/\/youtu\.be\/[\w-]+/,
10
+ /^https?:\/\/(www\.)?youtube\.com\/embed\/[\w-]+/,
11
+ /^https?:\/\/(www\.)?youtube\.com\/shorts\/[\w-]+/
12
+ ],
13
+ oEmbedEndpoint: "https://www.youtube.com/oembed",
14
+ supportsCors: !0
15
+ },
16
+ {
17
+ name: "vimeo",
18
+ patterns: [/^https?:\/\/(www\.)?vimeo\.com\/\d+/],
19
+ oEmbedEndpoint: "https://vimeo.com/api/oembed.json",
20
+ supportsCors: !0
21
+ },
22
+ {
23
+ name: "loom",
24
+ patterns: [/^https?:\/\/(www\.)?loom\.com\/share\/[\w-]+/],
25
+ oEmbedEndpoint: "https://www.loom.com/v1/oembed",
26
+ supportsCors: !0
27
+ },
28
+ {
29
+ name: "tiktok",
30
+ patterns: [/^https?:\/\/(www\.)?tiktok\.com\/@[\w.-]+\/video\/\d+/],
31
+ oEmbedEndpoint: "https://www.tiktok.com/oembed",
32
+ supportsCors: !0
33
+ },
34
+ // Social - these do NOT support CORS, require server-side proxy
35
+ {
36
+ name: "twitter",
37
+ patterns: [
38
+ /^https?:\/\/(twitter\.com|x\.com)\/\w+\/status\/\d+/,
39
+ /^https?:\/\/(twitter\.com|x\.com)\/\w+\/moments\/\d+/
40
+ ],
41
+ oEmbedEndpoint: "https://publish.twitter.com/oembed",
42
+ supportsCors: !1
43
+ },
44
+ {
45
+ name: "instagram",
46
+ patterns: [
47
+ /^https?:\/\/(www\.)?instagram\.com\/(p|reel)\/[\w-]+/,
48
+ /^https?:\/\/instagr\.am\/(p|reel)\/[\w-]+/
49
+ ],
50
+ oEmbedEndpoint: "https://graph.facebook.com/v10.0/instagram_oembed",
51
+ supportsCors: !1
52
+ },
53
+ // Dev - CodePen and CodeSandbox support CORS
54
+ {
55
+ name: "codepen",
56
+ patterns: [/^https?:\/\/(www\.)?codepen\.io\/[\w-]+\/pen\/[\w-]+/],
57
+ oEmbedEndpoint: "https://codepen.io/api/oembed",
58
+ supportsCors: !0
59
+ },
60
+ {
61
+ name: "codesandbox",
62
+ patterns: [/^https?:\/\/(www\.)?codesandbox\.io\/s\/[\w-]+/],
63
+ oEmbedEndpoint: "https://codesandbox.io/oembed",
64
+ supportsCors: !0
65
+ },
66
+ {
67
+ name: "github-gist",
68
+ patterns: [/^https?:\/\/gist\.github\.com\/[\w-]+\/[\w]+/],
69
+ supportsCors: !1
70
+ },
71
+ // Design
72
+ {
73
+ name: "figma",
74
+ patterns: [
75
+ /^https?:\/\/(www\.)?figma\.com\/(file|design)\/[\w-]+/,
76
+ /^https?:\/\/(www\.)?figma\.com\/proto\/[\w-]+/
77
+ ],
78
+ oEmbedEndpoint: "https://www.figma.com/api/oembed",
79
+ supportsCors: !0
80
+ },
81
+ {
82
+ name: "dribbble",
83
+ patterns: [/^https?:\/\/(www\.)?dribbble\.com\/shots\/[\w-]+/],
84
+ supportsCors: !1
85
+ },
86
+ // Music - Spotify and SoundCloud support CORS
87
+ {
88
+ name: "spotify",
89
+ patterns: [/^https?:\/\/open\.spotify\.com\/(track|album|playlist|episode|show)\/[\w]+/],
90
+ oEmbedEndpoint: "https://open.spotify.com/oembed",
91
+ supportsCors: !0
92
+ },
93
+ {
94
+ name: "soundcloud",
95
+ patterns: [/^https?:\/\/(www\.)?soundcloud\.com\/[\w-]+\/[\w-]+/],
96
+ oEmbedEndpoint: "https://soundcloud.com/oembed",
97
+ supportsCors: !0
98
+ },
99
+ // Other
100
+ {
101
+ name: "slideshare",
102
+ patterns: [/^https?:\/\/(www\.)?slideshare\.net\/[\w-]+\/[\w-]+/],
103
+ oEmbedEndpoint: "https://www.slideshare.net/api/oembed/2",
104
+ supportsCors: !1
105
+ }
106
+ ];
107
+ function c(t, e = u) {
108
+ for (const n of e)
109
+ for (const r of n.patterns)
110
+ if (r.test(t))
111
+ return n;
112
+ return null;
113
+ }
114
+ function h(t) {
115
+ try {
116
+ return new URL(t), !0;
117
+ } catch {
118
+ return !1;
119
+ }
120
+ }
121
+ async function g(t, e) {
122
+ if (!(e.oEmbedEndpoint && e.supportsCors))
123
+ return null;
124
+ try {
125
+ const n = new URL(e.oEmbedEndpoint);
126
+ n.searchParams.set("url", t), n.searchParams.set("format", "json");
127
+ const r = await fetch(n.toString(), {
128
+ headers: {
129
+ Accept: "application/json"
130
+ }
131
+ });
132
+ return r.ok ? await r.json() : null;
133
+ } catch {
134
+ return null;
135
+ }
136
+ }
137
+ function E(t, e) {
138
+ return t.html ? {
139
+ ...e,
140
+ type: "oembed",
141
+ html: t.html,
142
+ ...t.width !== void 0 && { width: t.width },
143
+ ...t.height !== void 0 && { height: t.height },
144
+ ...t.title !== void 0 && { title: t.title },
145
+ ...t.description !== void 0 && { description: t.description },
146
+ ...t.thumbnail_url !== void 0 && { image: t.thumbnail_url },
147
+ ...t.provider_name !== void 0 && { siteName: t.provider_name }
148
+ } : t.title || t.thumbnail_url ? {
149
+ ...e,
150
+ type: "ogp",
151
+ ...t.title !== void 0 && { title: t.title },
152
+ ...t.description !== void 0 && { description: t.description },
153
+ ...t.thumbnail_url !== void 0 && { image: t.thumbnail_url },
154
+ ...t.provider_name !== void 0 && { siteName: t.provider_name }
155
+ } : null;
156
+ }
157
+ function y(t = u) {
158
+ return async (e) => {
159
+ const n = c(e, t), r = {
160
+ url: e,
161
+ type: "link",
162
+ ...n?.name !== void 0 && { provider: n.name }
163
+ };
164
+ if (!(n?.oEmbedEndpoint && n.supportsCors))
165
+ return r;
166
+ const s = await g(e, n);
167
+ return s ? E(s, r) ?? r : r;
168
+ };
169
+ }
170
+ const C = new b("vizelEmbedPaste");
171
+ function k(t) {
172
+ const e = document.createElement("div");
173
+ e.className = "vizel-embed-loading", e.textContent = "Loading...", t.appendChild(e);
174
+ }
175
+ function z(t, e) {
176
+ t.innerHTML = e;
177
+ }
178
+ function N(t, e) {
179
+ const n = document.createElement("a");
180
+ if (n.href = e.url, n.target = "_blank", n.rel = "noopener noreferrer", n.className = "vizel-embed-card", e.image) {
181
+ const a = document.createElement("img");
182
+ a.src = e.image, a.alt = e.title ?? "", a.className = "vizel-embed-card-image", n.appendChild(a);
183
+ }
184
+ const r = document.createElement("div");
185
+ if (r.className = "vizel-embed-card-content", e.title) {
186
+ const a = document.createElement("div");
187
+ a.className = "vizel-embed-card-title", a.textContent = e.title, r.appendChild(a);
188
+ }
189
+ if (e.description) {
190
+ const a = document.createElement("div");
191
+ a.className = "vizel-embed-card-description", a.textContent = e.description, r.appendChild(a);
192
+ }
193
+ const s = document.createElement("div");
194
+ if (s.className = "vizel-embed-card-meta", e.favicon) {
195
+ const a = document.createElement("img");
196
+ a.src = e.favicon, a.alt = "", a.className = "vizel-embed-card-favicon", s.appendChild(a);
197
+ }
198
+ if (e.siteName) {
199
+ const a = document.createElement("span");
200
+ a.textContent = e.siteName, s.appendChild(a);
201
+ }
202
+ s.hasChildNodes() && r.appendChild(s), n.appendChild(r), t.appendChild(n);
203
+ }
204
+ function D(t, e, n) {
205
+ const r = document.createElement("a");
206
+ r.href = e, r.target = "_blank", r.rel = "noopener noreferrer", r.className = "vizel-embed-link", r.textContent = n ?? e, t.appendChild(r);
207
+ }
208
+ const x = w.create({
209
+ name: "embed",
210
+ group() {
211
+ return this.options.inline ? "inline" : "block";
212
+ },
213
+ inline() {
214
+ return this.options.inline ?? !1;
215
+ },
216
+ atom: !0,
217
+ draggable: !0,
218
+ addOptions() {
219
+ return {
220
+ fetchEmbedData: y(),
221
+ providers: u,
222
+ HTMLAttributes: {
223
+ class: "vizel-embed"
224
+ },
225
+ pasteHandler: !0,
226
+ inline: !1
227
+ };
228
+ },
229
+ addAttributes() {
230
+ return {
231
+ url: {
232
+ default: null
233
+ },
234
+ type: {
235
+ default: "link"
236
+ },
237
+ provider: {
238
+ default: null
239
+ },
240
+ html: {
241
+ default: null
242
+ },
243
+ width: {
244
+ default: null
245
+ },
246
+ height: {
247
+ default: null
248
+ },
249
+ title: {
250
+ default: null
251
+ },
252
+ description: {
253
+ default: null
254
+ },
255
+ image: {
256
+ default: null
257
+ },
258
+ siteName: {
259
+ default: null
260
+ },
261
+ favicon: {
262
+ default: null
263
+ },
264
+ loading: {
265
+ default: !1
266
+ }
267
+ };
268
+ },
269
+ parseHTML() {
270
+ return [
271
+ {
272
+ tag: 'div[data-vizel-embed="true"]'
273
+ }
274
+ ];
275
+ },
276
+ renderHTML({ HTMLAttributes: t }) {
277
+ const e = f(this.options.HTMLAttributes ?? {}, t, {
278
+ "data-vizel-embed": "true",
279
+ "data-embed-type": t.type,
280
+ "data-embed-provider": t.provider
281
+ });
282
+ return t.type === "oembed" && t.html ? ["div", e, ["div", { class: "vizel-embed-content" }]] : t.type === "ogp" ? [
283
+ "div",
284
+ e,
285
+ [
286
+ "a",
287
+ {
288
+ href: t.url,
289
+ target: "_blank",
290
+ rel: "noopener noreferrer",
291
+ class: "vizel-embed-card"
292
+ },
293
+ t.title || t.url
294
+ ]
295
+ ] : [
296
+ "div",
297
+ e,
298
+ [
299
+ "a",
300
+ {
301
+ href: t.url,
302
+ target: "_blank",
303
+ rel: "noopener noreferrer",
304
+ class: "vizel-embed-link"
305
+ },
306
+ t.title || t.url
307
+ ]
308
+ ];
309
+ },
310
+ addCommands() {
311
+ return {
312
+ setEmbed: ({ url: t }) => ({ commands: e, editor: n }) => {
313
+ if (!h(t))
314
+ return !1;
315
+ const r = c(t, this.options.providers), s = {
316
+ url: t,
317
+ type: "link",
318
+ loading: !0
319
+ };
320
+ r && (s.provider = r.name);
321
+ const a = e.insertContent({
322
+ type: this.name,
323
+ attrs: s
324
+ });
325
+ return this.options.fetchEmbedData && this.options.fetchEmbedData(t).then((o) => {
326
+ n.state.doc.descendants((i, p) => i.type.name === this.name && i.attrs.url === t && i.attrs.loading ? (n.chain().focus().command(({ tr: l }) => (l.setNodeMarkup(p, void 0, {
327
+ ...i.attrs,
328
+ ...o,
329
+ loading: !1
330
+ }), !0)).run(), !1) : !0);
331
+ }).catch((o) => {
332
+ console.error("Failed to fetch embed data:", o), n.state.doc.descendants((i, p) => i.type.name === this.name && i.attrs.url === t && i.attrs.loading ? (n.chain().focus().command(({ tr: l }) => (l.setNodeMarkup(p, void 0, {
333
+ ...i.attrs,
334
+ type: "link",
335
+ loading: !1
336
+ }), !0)).run(), !1) : !0);
337
+ }), a;
338
+ },
339
+ updateEmbed: (t) => ({ state: e, tr: n }) => {
340
+ const { selection: r } = e, s = e.doc.nodeAt(r.from);
341
+ return s?.type.name !== this.name ? !1 : (n.setNodeMarkup(r.from, void 0, {
342
+ ...s.attrs,
343
+ ...t
344
+ }), !0);
345
+ }
346
+ };
347
+ },
348
+ addNodeView() {
349
+ return ({ node: t, HTMLAttributes: e }) => {
350
+ const n = document.createElement("div"), r = document.createElement("div");
351
+ r.className = "vizel-embed-content";
352
+ const s = f(this.options.HTMLAttributes ?? {}, e, {
353
+ "data-vizel-embed": "true",
354
+ "data-embed-type": t.attrs.type,
355
+ "data-embed-provider": t.attrs.provider,
356
+ contenteditable: "false",
357
+ draggable: "true"
358
+ });
359
+ for (const [o, i] of Object.entries(s))
360
+ i != null && n.setAttribute(o, String(i));
361
+ n.appendChild(r);
362
+ const a = () => {
363
+ if (r.innerHTML = "", t.attrs.loading) {
364
+ k(r);
365
+ return;
366
+ }
367
+ if (t.attrs.type === "oembed" && t.attrs.html) {
368
+ z(r, t.attrs.html);
369
+ return;
370
+ }
371
+ if (t.attrs.type === "ogp") {
372
+ N(r, {
373
+ url: t.attrs.url,
374
+ image: t.attrs.image,
375
+ title: t.attrs.title,
376
+ description: t.attrs.description,
377
+ favicon: t.attrs.favicon,
378
+ siteName: t.attrs.siteName
379
+ });
380
+ return;
381
+ }
382
+ D(r, t.attrs.url, t.attrs.title);
383
+ };
384
+ return a(), {
385
+ dom: n,
386
+ contentDOM: null,
387
+ // atom node, no editable content
388
+ update(o) {
389
+ return o.type.name !== t.type.name ? !1 : (t = o, n.setAttribute("data-embed-type", t.attrs.type), n.setAttribute("data-embed-provider", t.attrs.provider ?? ""), a(), !0);
390
+ }
391
+ };
392
+ };
393
+ },
394
+ addProseMirrorPlugins() {
395
+ if (!this.options.pasteHandler)
396
+ return [];
397
+ const t = this;
398
+ return [
399
+ new v({
400
+ key: C,
401
+ props: {
402
+ handlePaste(e, n) {
403
+ const r = n.clipboardData?.getData("text/plain");
404
+ if (!r) return !1;
405
+ const s = r.trim();
406
+ if (!h(s)) return !1;
407
+ const a = c(s, t.options.providers);
408
+ if (!a) return !1;
409
+ n.preventDefault();
410
+ const { state: o } = e, { selection: i } = o;
411
+ if (!i.empty)
412
+ return !1;
413
+ const p = o.schema.nodes[t.name];
414
+ return p ? (e.dispatch(
415
+ o.tr.replaceSelectionWith(
416
+ p.create({
417
+ url: s,
418
+ type: "link",
419
+ provider: a.name,
420
+ loading: !0
421
+ })
422
+ )
423
+ ), t.options.fetchEmbedData && t.options.fetchEmbedData(s).then((l) => {
424
+ e.state.doc.descendants((d, m) => d.type.name === t.name && d.attrs.url === s && d.attrs.loading ? (e.dispatch(
425
+ e.state.tr.setNodeMarkup(m, void 0, {
426
+ ...d.attrs,
427
+ ...l,
428
+ loading: !1
429
+ })
430
+ ), !1) : !0);
431
+ }).catch((l) => {
432
+ console.error("Failed to fetch embed data:", l), e.state.doc.descendants((d, m) => d.type.name === t.name && d.attrs.url === s && d.attrs.loading ? (e.dispatch(
433
+ e.state.tr.setNodeMarkup(m, void 0, {
434
+ ...d.attrs,
435
+ type: "link",
436
+ loading: !1
437
+ })
438
+ ), !1) : !0);
439
+ }), !0) : !1;
440
+ }
441
+ }
442
+ })
443
+ ];
444
+ }
445
+ });
446
+ function O(t = {}) {
447
+ return x.configure(t);
448
+ }
449
+ export {
450
+ x as VizelEmbed,
451
+ y as createVizelDefaultFetchEmbedData,
452
+ O as createVizelEmbedExtension,
453
+ c as detectVizelEmbedProvider,
454
+ u as vizelDefaultEmbedProviders,
455
+ C as vizelEmbedPastePluginKey
456
+ };