@vizel/core 0.0.1-alpha.1 → 0.0.1-alpha.3
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/index34.js +63 -16
- package/dist/index35.js +4 -58
- package/dist/index36.js +123 -15
- package/dist/index37.js +305 -42
- package/dist/index38.js +487 -4
- package/dist/index39.js +37 -112
- package/dist/index4.js +10 -86
- package/dist/index40.js +653 -301
- package/dist/index41.js +4 -487
- package/dist/index42.js +4 -48
- package/dist/index43.js +206 -642
- package/dist/index44.js +82 -4
- package/dist/index45.js +17 -4
- package/dist/index46.js +57 -237
- package/dist/index47.js +15 -82
- package/dist/index48.js +190 -274
- package/dist/index49.js +281 -1497
- package/dist/index5.js +132 -10
- package/dist/index50.js +1502 -5
- package/dist/index51.js +5 -1561
- package/dist/index52.js +1551 -192
- package/dist/index53.js +1 -1
- package/dist/index54.js +84 -21
- package/dist/index55.js +246 -10
- package/dist/index56.js +3 -7
- package/dist/index57.js +1231 -7
- package/dist/index58.js +731 -11
- package/dist/index59.js +21 -19
- package/dist/index6.js +48 -131
- package/dist/index60.js +10 -25
- package/dist/index61.js +6 -83
- package/dist/index62.js +7 -245
- package/dist/index63.js +11 -1229
- package/dist/index64.js +17 -732
- package/dist/index65.js +25 -3
- 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/index11.js
CHANGED
|
@@ -1,174 +1,141 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import { createVizelCharacterCountExtension as B } from "./index5.js";
|
|
22
|
-
import { createVizelCodeBlockExtension as a } from "./index6.js";
|
|
23
|
-
import { createVizelDetailsExtensions as L } from "./index8.js";
|
|
24
|
-
import { createVizelDiagramExtension as v } from "./index9.js";
|
|
25
|
-
import { createVizelDragHandleExtensions as w } from "./index10.js";
|
|
26
|
-
import { createVizelEmbedExtension as H } from "./index7.js";
|
|
27
|
-
import { vizelDefaultBase64Upload as T, createVizelImageUploadExtensions as D, defaultImageResizeOptions as S } from "./index13.js";
|
|
28
|
-
import { createVizelLinkExtension as U } from "./index15.js";
|
|
29
|
-
import { createVizelMarkdownExtension as I } from "./index16.js";
|
|
30
|
-
import { createVizelMathematicsExtensions as M } from "./index17.js";
|
|
31
|
-
import { VizelSlashCommand as F } from "./index24.js";
|
|
32
|
-
import { createVizelTableExtensions as P } from "./index18.js";
|
|
33
|
-
import { createVizelTaskListExtensions as R } from "./index19.js";
|
|
34
|
-
import { createVizelTextColorExtensions as q } from "./index4.js";
|
|
35
|
-
import { defaultSlashCommands as G } from "./index20.js";
|
|
36
|
-
function K(e = {}) {
|
|
37
|
-
const { headingLevels: o = [1, 2, 3] } = e;
|
|
38
|
-
return [
|
|
39
|
-
// Nodes
|
|
40
|
-
c,
|
|
41
|
-
y,
|
|
42
|
-
O,
|
|
43
|
-
h.configure({ levels: o }),
|
|
44
|
-
s,
|
|
45
|
-
l,
|
|
46
|
-
z,
|
|
47
|
-
b,
|
|
48
|
-
// CodeBlock is added separately based on feature options
|
|
49
|
-
u,
|
|
50
|
-
E,
|
|
51
|
-
// Marks
|
|
52
|
-
m,
|
|
53
|
-
d,
|
|
54
|
-
g,
|
|
55
|
-
V,
|
|
56
|
-
j,
|
|
57
|
-
// Functionality
|
|
58
|
-
p.configure({ color: "#3b82f6", width: 2 }),
|
|
59
|
-
f,
|
|
60
|
-
x,
|
|
61
|
-
k
|
|
62
|
-
];
|
|
63
|
-
}
|
|
64
|
-
function N(e, o) {
|
|
65
|
-
if (o.slashCommand === !1) return;
|
|
66
|
-
const t = typeof o.slashCommand == "object" ? o.slashCommand : {}, i = t.items ?? G;
|
|
67
|
-
e.push(
|
|
68
|
-
F.configure({
|
|
69
|
-
items: i,
|
|
70
|
-
...t.suggestion !== void 0 && {
|
|
71
|
-
suggestion: t.suggestion
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
function _(e, o) {
|
|
77
|
-
if (o.image === !1) return;
|
|
78
|
-
const t = typeof o.image == "object" ? o.image : {}, i = t.onUpload ?? T, n = t.resize !== !1;
|
|
79
|
-
e.push(
|
|
80
|
-
...D({
|
|
81
|
-
upload: {
|
|
82
|
-
onUpload: i,
|
|
83
|
-
...t.maxFileSize !== void 0 && { maxFileSize: t.maxFileSize },
|
|
84
|
-
...t.allowedTypes !== void 0 && { allowedTypes: t.allowedTypes },
|
|
85
|
-
...t.onValidationError !== void 0 && {
|
|
86
|
-
onValidationError: t.onValidationError
|
|
87
|
-
},
|
|
88
|
-
...t.onUploadError !== void 0 && {
|
|
89
|
-
onUploadError: t.onUploadError
|
|
90
|
-
}
|
|
91
|
-
},
|
|
92
|
-
resize: n ? S : !1
|
|
93
|
-
})
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
function A(e, o) {
|
|
97
|
-
if (o.markdown === !1) return;
|
|
98
|
-
const t = typeof o.markdown == "object" ? o.markdown : {};
|
|
99
|
-
e.push(I(t));
|
|
100
|
-
}
|
|
101
|
-
function J(e, o) {
|
|
102
|
-
if (o.taskList === !1) return;
|
|
103
|
-
const t = typeof o.taskList == "object" ? o.taskList : {};
|
|
104
|
-
e.push(...R(t));
|
|
105
|
-
}
|
|
106
|
-
function Q(e, o) {
|
|
107
|
-
if (o.characterCount === !1) return;
|
|
108
|
-
const t = typeof o.characterCount == "object" ? o.characterCount : {};
|
|
109
|
-
e.push(B(t));
|
|
110
|
-
}
|
|
111
|
-
function W(e, o) {
|
|
112
|
-
if (o.textColor === !1) return;
|
|
113
|
-
const t = typeof o.textColor == "object" ? o.textColor : {};
|
|
114
|
-
e.push(...q(t));
|
|
115
|
-
}
|
|
116
|
-
function X(e, o) {
|
|
117
|
-
if (o.codeBlock !== !1)
|
|
118
|
-
if (o.codeBlock === !0 || typeof o.codeBlock == "object") {
|
|
119
|
-
const t = typeof o.codeBlock == "object" ? o.codeBlock : {};
|
|
120
|
-
e.push(...a(t));
|
|
121
|
-
} else
|
|
122
|
-
e.push(...a());
|
|
123
|
-
}
|
|
124
|
-
function Y(e, o) {
|
|
125
|
-
if (o.mathematics === !1) return;
|
|
126
|
-
const t = typeof o.mathematics == "object" ? o.mathematics : {};
|
|
127
|
-
e.push(...M(t));
|
|
128
|
-
}
|
|
129
|
-
function Z(e, o) {
|
|
130
|
-
if (o.dragHandle === !1) return;
|
|
131
|
-
const t = typeof o.dragHandle == "object" ? o.dragHandle : {};
|
|
132
|
-
e.push(...w(t));
|
|
133
|
-
}
|
|
134
|
-
function $(e, o) {
|
|
135
|
-
if (o.details === !1) return;
|
|
136
|
-
const t = typeof o.details == "object" ? o.details : {};
|
|
137
|
-
e.push(...L(t));
|
|
1
|
+
import { Extension as p } from "@tiptap/core";
|
|
2
|
+
import { FileHandler as V } from "./index39.js";
|
|
3
|
+
import W from "@tiptap/extension-image";
|
|
4
|
+
import { default as k } from "@tiptap/extension-image";
|
|
5
|
+
import { Plugin as U } from "./index38.js";
|
|
6
|
+
import { createVizelImageUploader as M, createVizelImageUploadPlugin as v, handleVizelImageDrop as T, handleVizelImagePaste as y, validateVizelImageFile as E } from "./index31.js";
|
|
7
|
+
import { getVizelImageUploadPluginKey as C } from "./index31.js";
|
|
8
|
+
import { VizelResizableImage as P } from "./index12.js";
|
|
9
|
+
const j = {
|
|
10
|
+
enabled: !0,
|
|
11
|
+
minWidth: 100,
|
|
12
|
+
minHeight: 100
|
|
13
|
+
};
|
|
14
|
+
function O(e) {
|
|
15
|
+
return new Promise((t, a) => {
|
|
16
|
+
const i = new FileReader();
|
|
17
|
+
i.onload = () => {
|
|
18
|
+
typeof i.result == "string" && t(i.result);
|
|
19
|
+
}, i.onerror = () => a(new Error("Failed to read file")), i.readAsDataURL(e);
|
|
20
|
+
});
|
|
138
21
|
}
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
22
|
+
function w(e = {}) {
|
|
23
|
+
return W.configure({
|
|
24
|
+
inline: e.inline ?? !1,
|
|
25
|
+
allowBase64: e.allowBase64 ?? !0,
|
|
26
|
+
HTMLAttributes: {
|
|
27
|
+
class: "vizel-image",
|
|
28
|
+
...e.HTMLAttributes
|
|
29
|
+
}
|
|
30
|
+
});
|
|
143
31
|
}
|
|
144
|
-
function
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
32
|
+
function K(e) {
|
|
33
|
+
const t = M(e.upload), a = e.resize !== !1, i = typeof e.resize == "object" ? e.resize : {}, d = a ? P.configure({
|
|
34
|
+
inline: e.inline ?? !1,
|
|
35
|
+
allowBase64: e.allowBase64 ?? !0,
|
|
36
|
+
minWidth: i.minWidth ?? 100,
|
|
37
|
+
minHeight: i.minHeight ?? 100,
|
|
38
|
+
...i.maxWidth !== void 0 && { maxWidth: i.maxWidth },
|
|
39
|
+
HTMLAttributes: {
|
|
40
|
+
class: "vizel-image",
|
|
41
|
+
...e.HTMLAttributes
|
|
42
|
+
}
|
|
43
|
+
}) : w(e), c = p.create({
|
|
44
|
+
name: "imageUpload",
|
|
45
|
+
addProseMirrorPlugins() {
|
|
46
|
+
return [v(e.upload)];
|
|
47
|
+
}
|
|
48
|
+
}), g = p.create({
|
|
49
|
+
name: "imageDropPaste",
|
|
50
|
+
addProseMirrorPlugins() {
|
|
51
|
+
return [
|
|
52
|
+
new U({
|
|
53
|
+
props: {
|
|
54
|
+
handlePaste: (r, o) => y(r, o, t),
|
|
55
|
+
handleDrop: (r, o, z, u) => T(r, o, u, t)
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
return [d, c, g];
|
|
148
62
|
}
|
|
149
|
-
function
|
|
150
|
-
const {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
...
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
63
|
+
function N(e) {
|
|
64
|
+
const { onUpload: t, maxFileSize: a, allowedTypes: i, onValidationError: d, onUploadError: c } = e.upload, g = e.resize !== !1, r = typeof e.resize == "object" ? e.resize : {}, o = g ? P.configure({
|
|
65
|
+
inline: e.inline ?? !1,
|
|
66
|
+
allowBase64: e.allowBase64 ?? !0,
|
|
67
|
+
minWidth: r.minWidth ?? 100,
|
|
68
|
+
minHeight: r.minHeight ?? 100,
|
|
69
|
+
...r.maxWidth !== void 0 && { maxWidth: r.maxWidth },
|
|
70
|
+
HTMLAttributes: {
|
|
71
|
+
class: "vizel-image",
|
|
72
|
+
...e.HTMLAttributes
|
|
73
|
+
}
|
|
74
|
+
}) : w(e), z = p.create({
|
|
75
|
+
name: "imageUpload",
|
|
76
|
+
addProseMirrorPlugins() {
|
|
77
|
+
return [v(e.upload)];
|
|
78
|
+
}
|
|
79
|
+
}), u = i ?? [
|
|
80
|
+
"image/jpeg",
|
|
81
|
+
"image/png",
|
|
82
|
+
"image/gif",
|
|
83
|
+
"image/webp",
|
|
84
|
+
"image/svg+xml"
|
|
85
|
+
], H = V.configure({
|
|
86
|
+
allowedMimeTypes: u,
|
|
87
|
+
onPaste: (s, f) => {
|
|
88
|
+
for (const m of f) {
|
|
89
|
+
const n = E(m, {
|
|
90
|
+
...a !== void 0 && { maxFileSize: a },
|
|
91
|
+
...i !== void 0 && { allowedTypes: i }
|
|
92
|
+
});
|
|
93
|
+
if (n) {
|
|
94
|
+
d?.(n);
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
t(m).then((l) => {
|
|
98
|
+
s.chain().focus().setImage({ src: l }).run();
|
|
99
|
+
}).catch((l) => {
|
|
100
|
+
c?.(l, m);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
onDrop: (s, f, m) => {
|
|
105
|
+
for (const n of f) {
|
|
106
|
+
const l = E(n, {
|
|
107
|
+
...a !== void 0 && { maxFileSize: a },
|
|
108
|
+
...i !== void 0 && { allowedTypes: i }
|
|
109
|
+
});
|
|
110
|
+
if (l) {
|
|
111
|
+
d?.(l);
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
t(n).then((h) => {
|
|
115
|
+
const { schema: I } = s.state, x = I.nodes.image?.create({ src: h });
|
|
116
|
+
if (x) {
|
|
117
|
+
const b = s.state.tr.insert(m, x);
|
|
118
|
+
s.view.dispatch(b);
|
|
119
|
+
}
|
|
120
|
+
}).catch((h) => {
|
|
121
|
+
c?.(h, n);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return [o, z, H];
|
|
171
127
|
}
|
|
172
128
|
export {
|
|
173
|
-
|
|
129
|
+
k as VizelImage,
|
|
130
|
+
w as createVizelImageExtension,
|
|
131
|
+
K as createVizelImageUploadExtensions,
|
|
132
|
+
v as createVizelImageUploadPlugin,
|
|
133
|
+
N as createVizelImageUploadWithFileHandler,
|
|
134
|
+
M as createVizelImageUploader,
|
|
135
|
+
j as defaultImageResizeOptions,
|
|
136
|
+
C as getVizelImageUploadPluginKey,
|
|
137
|
+
T as handleVizelImageDrop,
|
|
138
|
+
y as handleVizelImagePaste,
|
|
139
|
+
E as validateVizelImageFile,
|
|
140
|
+
O as vizelDefaultBase64Upload
|
|
174
141
|
};
|
package/dist/index12.js
CHANGED
|
@@ -1,78 +1,87 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
"image
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return i.type.startsWith(`${n}/`);
|
|
14
|
-
}
|
|
15
|
-
return !1;
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
function p(l = {}) {
|
|
19
|
-
const { allowedMimeTypes: r = g, onPaste: i, onDrop: a, onError: t } = l;
|
|
20
|
-
return d.configure({
|
|
21
|
-
allowedMimeTypes: r,
|
|
22
|
-
onPaste: (n, e, o) => {
|
|
23
|
-
if (e.length === 0)
|
|
24
|
-
return;
|
|
25
|
-
const s = c(e, r);
|
|
26
|
-
if (s.length === 0) {
|
|
27
|
-
t?.({
|
|
28
|
-
type: "invalid_mime_type",
|
|
29
|
-
message: `No files with allowed MIME types. Allowed: ${r.join(", ")}`,
|
|
30
|
-
files: e
|
|
31
|
-
});
|
|
32
|
-
return;
|
|
1
|
+
import x from "@tiptap/extension-image";
|
|
2
|
+
const T = x.extend({
|
|
3
|
+
name: "image",
|
|
4
|
+
addOptions() {
|
|
5
|
+
return {
|
|
6
|
+
...this.parent?.(),
|
|
7
|
+
minWidth: 100,
|
|
8
|
+
minHeight: 100,
|
|
9
|
+
inline: !1,
|
|
10
|
+
allowBase64: !0,
|
|
11
|
+
HTMLAttributes: {
|
|
12
|
+
class: "vizel-image"
|
|
33
13
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
14
|
+
};
|
|
15
|
+
},
|
|
16
|
+
addAttributes() {
|
|
17
|
+
return {
|
|
18
|
+
...this.parent?.(),
|
|
19
|
+
width: {
|
|
20
|
+
default: null,
|
|
21
|
+
parseHTML: (n) => {
|
|
22
|
+
const s = n.getAttribute("width") || n.style.width;
|
|
23
|
+
return s ? Number.parseInt(s, 10) : null;
|
|
24
|
+
},
|
|
25
|
+
renderHTML: (n) => n.width ? { width: n.width } : {}
|
|
26
|
+
},
|
|
27
|
+
height: {
|
|
28
|
+
default: null,
|
|
29
|
+
parseHTML: (n) => {
|
|
30
|
+
const s = n.getAttribute("height") || n.style.height;
|
|
31
|
+
return s ? Number.parseInt(s, 10) : null;
|
|
32
|
+
},
|
|
33
|
+
renderHTML: (n) => n.height ? { height: n.height } : {}
|
|
47
34
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
35
|
+
};
|
|
36
|
+
},
|
|
37
|
+
addNodeView() {
|
|
38
|
+
return ({ node: n, editor: s, getPos: m }) => {
|
|
39
|
+
const { minWidth: b = 100, maxWidth: E } = this.options, r = document.createElement("div");
|
|
40
|
+
r.setAttribute("data-resize-wrapper", "true");
|
|
41
|
+
const t = document.createElement("img");
|
|
42
|
+
t.src = n.attrs.src, t.alt = n.attrs.alt || "", t.title = n.attrs.title || "", t.className = "vizel-image", t.draggable = !1, n.attrs.width && (t.style.width = `${n.attrs.width}px`, t.style.height = "auto"), r.appendChild(t);
|
|
43
|
+
const i = document.createElement("div");
|
|
44
|
+
i.setAttribute("data-resize-handle", "left"), i.contentEditable = "false", i.style.position = "absolute", i.style.left = "4px", i.style.top = "50%", i.style.transform = "translateY(-50%)";
|
|
45
|
+
const o = document.createElement("div");
|
|
46
|
+
o.setAttribute("data-resize-handle", "right"), o.contentEditable = "false", o.style.position = "absolute", o.style.right = "4px", o.style.top = "50%", o.style.transform = "translateY(-50%)";
|
|
47
|
+
const l = document.createElement("div");
|
|
48
|
+
l.setAttribute("data-resize-tooltip", "true"), l.style.position = "absolute", l.style.display = "none", r.appendChild(i), r.appendChild(o), r.appendChild(l);
|
|
49
|
+
let u = 0, p = 0, d = !1, f = "right";
|
|
50
|
+
const g = (e, a) => {
|
|
51
|
+
l.textContent = `${Math.round(e)} × ${Math.round(a)}`;
|
|
52
|
+
}, M = () => {
|
|
53
|
+
l.style.display = "block", g(t.offsetWidth, t.offsetHeight);
|
|
54
|
+
}, L = () => {
|
|
55
|
+
l.style.display = "none";
|
|
56
|
+
}, y = (e, a) => {
|
|
57
|
+
e.preventDefault(), e.stopPropagation(), s.isEditable && (d = !0, f = a, u = e.clientX, p = t.offsetWidth, M(), document.addEventListener("mousemove", h), document.addEventListener("mouseup", c), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none");
|
|
58
|
+
}, h = (e) => {
|
|
59
|
+
if (!d) return;
|
|
60
|
+
const a = f === "right" ? e.clientX - u : u - e.clientX, W = r.parentElement?.clientWidth ?? Number.POSITIVE_INFINITY, z = Math.min(E ?? W, Math.max(b, p + a));
|
|
61
|
+
t.style.width = `${z}px`, t.style.height = "auto", g(t.offsetWidth, t.offsetHeight);
|
|
62
|
+
}, c = () => {
|
|
63
|
+
if (!d) return;
|
|
64
|
+
if (d = !1, L(), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c), document.body.style.cursor = "", document.body.style.userSelect = "", (typeof m == "function" ? m() : null) != null && s.isEditable) {
|
|
65
|
+
const a = Math.round(t.offsetWidth);
|
|
66
|
+
s.commands.updateAttributes("image", {
|
|
67
|
+
width: a,
|
|
68
|
+
height: null
|
|
69
|
+
// Clear height to use auto
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}, w = (e) => y(e, "left"), v = (e) => y(e, "right");
|
|
73
|
+
return i.addEventListener("mousedown", w), o.addEventListener("mousedown", v), {
|
|
74
|
+
dom: r,
|
|
75
|
+
contentDOM: null,
|
|
76
|
+
update: (e) => e.type.name !== "image" ? !1 : (t.src = e.attrs.src, t.alt = e.attrs.alt || "", t.title = e.attrs.title || "", e.attrs.width ? (t.style.width = `${e.attrs.width}px`, t.style.height = "auto") : (t.style.width = "", t.style.height = ""), !0),
|
|
77
|
+
destroy: () => {
|
|
78
|
+
i.removeEventListener("mousedown", w), o.removeEventListener("mousedown", v), document.removeEventListener("mousemove", h), document.removeEventListener("mouseup", c);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
});
|
|
71
84
|
export {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
m as VIZEL_DEFAULT_IMAGE_MAX_FILE_SIZE,
|
|
75
|
-
p as createVizelFileHandlerExtension,
|
|
76
|
-
f as createVizelImageFileHandlers,
|
|
77
|
-
c as filterVizelFilesByMimeType
|
|
85
|
+
T as VizelImageResize,
|
|
86
|
+
T as VizelResizableImage
|
|
78
87
|
};
|
package/dist/index13.js
CHANGED
|
@@ -1,141 +1,20 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const j = {
|
|
10
|
-
enabled: !0,
|
|
11
|
-
minWidth: 100,
|
|
12
|
-
minHeight: 100
|
|
13
|
-
};
|
|
14
|
-
function O(e) {
|
|
15
|
-
return new Promise((t, a) => {
|
|
16
|
-
const i = new FileReader();
|
|
17
|
-
i.onload = () => {
|
|
18
|
-
typeof i.result == "string" && t(i.result);
|
|
19
|
-
}, i.onerror = () => a(new Error("Failed to read file")), i.readAsDataURL(e);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
function w(e = {}) {
|
|
23
|
-
return W.configure({
|
|
24
|
-
inline: e.inline ?? !1,
|
|
25
|
-
allowBase64: e.allowBase64 ?? !0,
|
|
1
|
+
import t from "@tiptap/extension-link";
|
|
2
|
+
import { default as i } from "@tiptap/extension-link";
|
|
3
|
+
function n(e = {}) {
|
|
4
|
+
return t.configure({
|
|
5
|
+
openOnClick: e.openOnClick ?? !0,
|
|
6
|
+
autolink: e.autolink ?? !0,
|
|
7
|
+
linkOnPaste: e.linkOnPaste ?? !0,
|
|
8
|
+
defaultProtocol: e.defaultProtocol ?? "https",
|
|
26
9
|
HTMLAttributes: {
|
|
27
|
-
class: "vizel-
|
|
10
|
+
class: "vizel-link",
|
|
11
|
+
rel: "noopener noreferrer nofollow",
|
|
12
|
+
target: "_blank",
|
|
28
13
|
...e.HTMLAttributes
|
|
29
14
|
}
|
|
30
15
|
});
|
|
31
16
|
}
|
|
32
|
-
function K(e) {
|
|
33
|
-
const t = M(e.upload), a = e.resize !== !1, i = typeof e.resize == "object" ? e.resize : {}, d = a ? P.configure({
|
|
34
|
-
inline: e.inline ?? !1,
|
|
35
|
-
allowBase64: e.allowBase64 ?? !0,
|
|
36
|
-
minWidth: i.minWidth ?? 100,
|
|
37
|
-
minHeight: i.minHeight ?? 100,
|
|
38
|
-
...i.maxWidth !== void 0 && { maxWidth: i.maxWidth },
|
|
39
|
-
HTMLAttributes: {
|
|
40
|
-
class: "vizel-image",
|
|
41
|
-
...e.HTMLAttributes
|
|
42
|
-
}
|
|
43
|
-
}) : w(e), c = p.create({
|
|
44
|
-
name: "imageUpload",
|
|
45
|
-
addProseMirrorPlugins() {
|
|
46
|
-
return [v(e.upload)];
|
|
47
|
-
}
|
|
48
|
-
}), g = p.create({
|
|
49
|
-
name: "imageDropPaste",
|
|
50
|
-
addProseMirrorPlugins() {
|
|
51
|
-
return [
|
|
52
|
-
new U({
|
|
53
|
-
props: {
|
|
54
|
-
handlePaste: (r, o) => y(r, o, t),
|
|
55
|
-
handleDrop: (r, o, z, u) => T(r, o, u, t)
|
|
56
|
-
}
|
|
57
|
-
})
|
|
58
|
-
];
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return [d, c, g];
|
|
62
|
-
}
|
|
63
|
-
function N(e) {
|
|
64
|
-
const { onUpload: t, maxFileSize: a, allowedTypes: i, onValidationError: d, onUploadError: c } = e.upload, g = e.resize !== !1, r = typeof e.resize == "object" ? e.resize : {}, o = g ? P.configure({
|
|
65
|
-
inline: e.inline ?? !1,
|
|
66
|
-
allowBase64: e.allowBase64 ?? !0,
|
|
67
|
-
minWidth: r.minWidth ?? 100,
|
|
68
|
-
minHeight: r.minHeight ?? 100,
|
|
69
|
-
...r.maxWidth !== void 0 && { maxWidth: r.maxWidth },
|
|
70
|
-
HTMLAttributes: {
|
|
71
|
-
class: "vizel-image",
|
|
72
|
-
...e.HTMLAttributes
|
|
73
|
-
}
|
|
74
|
-
}) : w(e), z = p.create({
|
|
75
|
-
name: "imageUpload",
|
|
76
|
-
addProseMirrorPlugins() {
|
|
77
|
-
return [v(e.upload)];
|
|
78
|
-
}
|
|
79
|
-
}), u = i ?? [
|
|
80
|
-
"image/jpeg",
|
|
81
|
-
"image/png",
|
|
82
|
-
"image/gif",
|
|
83
|
-
"image/webp",
|
|
84
|
-
"image/svg+xml"
|
|
85
|
-
], H = V.configure({
|
|
86
|
-
allowedMimeTypes: u,
|
|
87
|
-
onPaste: (s, f) => {
|
|
88
|
-
for (const m of f) {
|
|
89
|
-
const n = E(m, {
|
|
90
|
-
...a !== void 0 && { maxFileSize: a },
|
|
91
|
-
...i !== void 0 && { allowedTypes: i }
|
|
92
|
-
});
|
|
93
|
-
if (n) {
|
|
94
|
-
d?.(n);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
t(m).then((l) => {
|
|
98
|
-
s.chain().focus().setImage({ src: l }).run();
|
|
99
|
-
}).catch((l) => {
|
|
100
|
-
c?.(l, m);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
},
|
|
104
|
-
onDrop: (s, f, m) => {
|
|
105
|
-
for (const n of f) {
|
|
106
|
-
const l = E(n, {
|
|
107
|
-
...a !== void 0 && { maxFileSize: a },
|
|
108
|
-
...i !== void 0 && { allowedTypes: i }
|
|
109
|
-
});
|
|
110
|
-
if (l) {
|
|
111
|
-
d?.(l);
|
|
112
|
-
continue;
|
|
113
|
-
}
|
|
114
|
-
t(n).then((h) => {
|
|
115
|
-
const { schema: I } = s.state, x = I.nodes.image?.create({ src: h });
|
|
116
|
-
if (x) {
|
|
117
|
-
const b = s.state.tr.insert(m, x);
|
|
118
|
-
s.view.dispatch(b);
|
|
119
|
-
}
|
|
120
|
-
}).catch((h) => {
|
|
121
|
-
c?.(h, n);
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return [o, z, H];
|
|
127
|
-
}
|
|
128
17
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
K as createVizelImageUploadExtensions,
|
|
132
|
-
v as createVizelImageUploadPlugin,
|
|
133
|
-
N as createVizelImageUploadWithFileHandler,
|
|
134
|
-
M as createVizelImageUploader,
|
|
135
|
-
j as defaultImageResizeOptions,
|
|
136
|
-
C as getVizelImageUploadPluginKey,
|
|
137
|
-
T as handleVizelImageDrop,
|
|
138
|
-
y as handleVizelImagePaste,
|
|
139
|
-
E as validateVizelImageFile,
|
|
140
|
-
O as vizelDefaultBase64Upload
|
|
18
|
+
i as Link,
|
|
19
|
+
n as createVizelLinkExtension
|
|
141
20
|
};
|