@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.2
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/LICENSE +21 -0
- package/dist/index.d.ts +13 -13
- package/dist/index.js +141 -141
- package/dist/index10.js +70 -110
- package/dist/index11.js +135 -168
- package/dist/index12.js +83 -74
- package/dist/index13.js +13 -134
- package/dist/index14.js +13 -146
- package/dist/index15.js +303 -15
- package/dist/index16.js +69 -14
- package/dist/index17.js +26 -295
- package/dist/index18.js +2 -2
- package/dist/index19.js +355 -24
- package/dist/index20.js +25 -264
- package/dist/index21.js +85 -68
- package/dist/index22.js +97 -353
- package/dist/index23.js +66 -84
- package/dist/index24.js +12 -36
- package/dist/index25.js +53 -92
- package/dist/index26.js +132 -96
- package/dist/index27.js +59 -126
- package/dist/index28.js +37 -53
- package/dist/index29.js +19 -62
- package/dist/index3.js +165 -60
- package/dist/index30.js +9 -37
- package/dist/index31.js +143 -19
- package/dist/index32.js +264 -11
- package/dist/index33.js +92 -9
- package/dist/index36.js +1 -1
- package/dist/index37.js +41 -57
- package/dist/index38.js +64 -4
- package/dist/index39.js +4 -123
- package/dist/index4.js +10 -86
- package/dist/index40.js +111 -315
- package/dist/index41.js +321 -481
- package/dist/index42.js +481 -42
- package/dist/index43.js +143 -138
- package/dist/index44.js +1 -1
- package/dist/index45.js +1 -1
- package/dist/index46.js +1 -1
- package/dist/index48.js +3 -3
- package/dist/index49.js +158 -1458
- package/dist/index5.js +132 -10
- package/dist/index50.js +1561 -5
- package/dist/index51.js +1408 -1467
- package/dist/index52.js +704 -183
- package/dist/index53.js +5 -723
- package/dist/index6.js +48 -131
- package/dist/index61.js +1 -1
- package/dist/index62.js +1 -1
- package/dist/index65.js +1 -1
- package/dist/index66.js +53 -1059
- package/dist/index67.js +1059 -53
- package/dist/index69.js +90 -3
- package/dist/index7.js +228 -409
- package/dist/index70.js +3 -90
- package/dist/index8.js +111 -45
- package/dist/index9.js +409 -228
- package/package.json +54 -80
package/dist/index9.js
CHANGED
|
@@ -1,275 +1,456 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
1
|
+
import { Node as w, mergeAttributes as f } from "@tiptap/core";
|
|
2
|
+
import { PluginKey as b, Plugin as v } from "./index42.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
|
|
37
105
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
fontFamily: "var(--vizel-font-sans)",
|
|
46
|
-
...e
|
|
47
|
-
}), A = !0);
|
|
48
|
-
}
|
|
49
|
-
let L = null, C = !1, h = null;
|
|
50
|
-
function R() {
|
|
51
|
-
return L ? Promise.resolve(L) : (C && h || (C = !0, h = H.load().then((e) => (L = e, C = !1, e))), h);
|
|
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;
|
|
52
113
|
}
|
|
53
|
-
|
|
54
|
-
if (!e.trim())
|
|
55
|
-
return { svg: "", error: null };
|
|
114
|
+
function h(t) {
|
|
56
115
|
try {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
svg: "",
|
|
62
|
-
error: a instanceof Error ? a.message : "Invalid Mermaid syntax"
|
|
63
|
-
};
|
|
116
|
+
return new URL(t), !0;
|
|
117
|
+
} catch {
|
|
118
|
+
return !1;
|
|
64
119
|
}
|
|
65
120
|
}
|
|
66
|
-
async function
|
|
67
|
-
if (!e.
|
|
68
|
-
return
|
|
121
|
+
async function g(t, e) {
|
|
122
|
+
if (!(e.oEmbedEndpoint && e.supportsCors))
|
|
123
|
+
return null;
|
|
69
124
|
try {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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;
|
|
76
135
|
}
|
|
77
136
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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);
|
|
101
201
|
}
|
|
202
|
+
s.hasChildNodes() && r.appendChild(s), n.appendChild(r), t.appendChild(n);
|
|
102
203
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
+
},
|
|
106
216
|
atom: !0,
|
|
107
|
-
selectable: !0,
|
|
108
217
|
draggable: !0,
|
|
109
|
-
// Higher priority than codeBlock to ensure diagram code blocks are parsed first
|
|
110
|
-
priority: 200,
|
|
111
218
|
addOptions() {
|
|
112
219
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
220
|
+
fetchEmbedData: y(),
|
|
221
|
+
providers: u,
|
|
222
|
+
HTMLAttributes: {
|
|
223
|
+
class: "vizel-embed"
|
|
224
|
+
},
|
|
225
|
+
pasteHandler: !0,
|
|
226
|
+
inline: !1
|
|
118
227
|
};
|
|
119
228
|
},
|
|
120
229
|
addAttributes() {
|
|
121
230
|
return {
|
|
122
|
-
|
|
123
|
-
default:
|
|
124
|
-
parseHTML: (e) => e.getAttribute("data-code") || "",
|
|
125
|
-
renderHTML: (e) => ({
|
|
126
|
-
"data-code": e.code
|
|
127
|
-
})
|
|
231
|
+
url: {
|
|
232
|
+
default: null
|
|
128
233
|
},
|
|
129
234
|
type: {
|
|
130
|
-
default: "
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
|
135
266
|
}
|
|
136
267
|
};
|
|
137
268
|
},
|
|
138
269
|
parseHTML() {
|
|
139
270
|
return [
|
|
140
271
|
{
|
|
141
|
-
tag: 'div[data-
|
|
272
|
+
tag: 'div[data-vizel-embed="true"]'
|
|
142
273
|
}
|
|
143
274
|
];
|
|
144
275
|
},
|
|
145
|
-
renderHTML({ HTMLAttributes:
|
|
146
|
-
|
|
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" ? [
|
|
147
283
|
"div",
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return ({ node: e, getPos: a, editor: i }) => {
|
|
157
|
-
P(this.options.mermaidConfig);
|
|
158
|
-
const r = document.createElement("div");
|
|
159
|
-
r.classList.add("vizel-diagram"), r.setAttribute("data-type", "diagram"), r.setAttribute("data-vizel-diagram", ""), r.setAttribute("contenteditable", "false");
|
|
160
|
-
const m = document.createElement("div");
|
|
161
|
-
m.classList.add("vizel-diagram-type"), m.textContent = x(e.attrs.type), r.appendChild(m);
|
|
162
|
-
const l = document.createElement("div");
|
|
163
|
-
l.classList.add("vizel-diagram-render"), r.appendChild(l);
|
|
164
|
-
const o = document.createElement("div");
|
|
165
|
-
o.classList.add("vizel-diagram-edit-container"), o.style.display = "none";
|
|
166
|
-
const n = document.createElement("textarea");
|
|
167
|
-
n.classList.add("vizel-diagram-textarea"), n.value = e.attrs.code, n.placeholder = "Enter diagram code...", n.spellcheck = !1, o.appendChild(n);
|
|
168
|
-
const f = document.createElement("div");
|
|
169
|
-
f.classList.add("vizel-diagram-preview"), o.appendChild(f);
|
|
170
|
-
const z = document.createElement("div");
|
|
171
|
-
z.classList.add("vizel-diagram-error"), z.style.display = "none", o.appendChild(z), r.appendChild(o);
|
|
172
|
-
let u = !1, s = e.attrs.code, c = e.attrs.type;
|
|
173
|
-
const y = async (t, d, g) => {
|
|
174
|
-
if (!t.trim()) {
|
|
175
|
-
g.innerHTML = '<div class="vizel-diagram-placeholder">Click to add diagram code</div>';
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
let v;
|
|
179
|
-
d === "graphviz" ? v = await K(t, this.options.graphvizEngine) : v = await V(t), v.error ? g.innerHTML = `<div class="vizel-diagram-error-display">${v.error}</div>` : g.innerHTML = v.svg;
|
|
180
|
-
}, T = () => {
|
|
181
|
-
i.isEditable && (u = !0, r.classList.add("vizel-diagram-editing"), l.style.display = "none", m.style.display = "none", o.style.display = "", n.value = s, y(s, c, f), n.focus());
|
|
182
|
-
}, E = () => {
|
|
183
|
-
if (!u) return;
|
|
184
|
-
u = !1, r.classList.remove("vizel-diagram-editing"), l.style.display = "", m.style.display = "", o.style.display = "none";
|
|
185
|
-
const t = n.value.trim(), d = typeof a == "function" ? a() : null;
|
|
186
|
-
d != null && (t === "" && s !== "" ? i.chain().focus().deleteRange({ from: d, to: d + e.nodeSize }).run() : t !== s && (s = t, i.chain().focus().updateAttributes("diagram", { code: t }).run()));
|
|
187
|
-
}, M = (t) => {
|
|
188
|
-
!u && t.target === r && (t.preventDefault(), t.stopPropagation(), T());
|
|
189
|
-
}, D = (t) => {
|
|
190
|
-
t.preventDefault(), t.stopPropagation(), T();
|
|
191
|
-
}, w = (t) => {
|
|
192
|
-
const d = t.relatedTarget;
|
|
193
|
-
d instanceof HTMLElement && o.contains(d) || E();
|
|
194
|
-
}, b = (t) => {
|
|
195
|
-
t.key === "Escape" && (t.preventDefault(), n.value = s, E()), t.key === "Enter" && (t.ctrlKey || t.metaKey) && (t.preventDefault(), E());
|
|
196
|
-
};
|
|
197
|
-
let p = null;
|
|
198
|
-
const k = () => {
|
|
199
|
-
p && clearTimeout(p), p = setTimeout(() => {
|
|
200
|
-
y(n.value, c, f);
|
|
201
|
-
}, 300);
|
|
202
|
-
};
|
|
203
|
-
return r.addEventListener("click", M), l.addEventListener("click", D), n.addEventListener("blur", w), n.addEventListener("keydown", b), n.addEventListener("input", k), y(s, c, l), {
|
|
204
|
-
dom: r,
|
|
205
|
-
update(t) {
|
|
206
|
-
if (t.type.name !== "diagram")
|
|
207
|
-
return !1;
|
|
208
|
-
const d = t.attrs.type !== c, g = t.attrs.code !== s;
|
|
209
|
-
return d && (c = t.attrs.type, m.textContent = x(c)), !u && (g || d) && (s = t.attrs.code, y(s, c, l)), !0;
|
|
210
|
-
},
|
|
211
|
-
selectNode() {
|
|
212
|
-
r.classList.add("vizel-diagram-selected");
|
|
284
|
+
e,
|
|
285
|
+
[
|
|
286
|
+
"a",
|
|
287
|
+
{
|
|
288
|
+
href: t.url,
|
|
289
|
+
target: "_blank",
|
|
290
|
+
rel: "noopener noreferrer",
|
|
291
|
+
class: "vizel-embed-card"
|
|
213
292
|
},
|
|
214
|
-
|
|
215
|
-
|
|
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"
|
|
216
305
|
},
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
};
|
|
221
|
-
};
|
|
306
|
+
t.title || t.url
|
|
307
|
+
]
|
|
308
|
+
];
|
|
222
309
|
},
|
|
223
310
|
addCommands() {
|
|
224
311
|
return {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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({
|
|
228
322
|
type: this.name,
|
|
229
|
-
attrs:
|
|
230
|
-
code: e || r,
|
|
231
|
-
type: a
|
|
232
|
-
}
|
|
323
|
+
attrs: s
|
|
233
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);
|
|
234
345
|
}
|
|
235
346
|
};
|
|
236
347
|
},
|
|
237
|
-
|
|
238
|
-
return {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
+
};
|
|
255
392
|
};
|
|
256
393
|
},
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
+
];
|
|
266
444
|
}
|
|
267
445
|
});
|
|
268
|
-
function
|
|
269
|
-
return
|
|
446
|
+
function O(t = {}) {
|
|
447
|
+
return x.configure(t);
|
|
270
448
|
}
|
|
271
449
|
export {
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
450
|
+
x as VizelEmbed,
|
|
451
|
+
y as createVizelDefaultFetchEmbedData,
|
|
452
|
+
O as createVizelEmbedExtension,
|
|
453
|
+
c as detectVizelEmbedProvider,
|
|
454
|
+
u as vizelDefaultEmbedProviders,
|
|
455
|
+
C as vizelEmbedPastePluginKey
|
|
275
456
|
};
|