@teriusu/rich-editor 0.7.0 → 0.7.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MbusVideo.d.ts","sourceRoot":"","sources":["../../src/extensions/MbusVideo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC7B,UAAU,QAAQ,CAAC,UAAU;QAC5B,SAAS,EAAE;YACV,YAAY,EAAE,CAAC,KAAK,EAAE;gBAAE,GAAG,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE,KAAK,UAAU,CAAC;SACrE,CAAC;KACF;CACD;
|
|
1
|
+
{"version":3,"file":"MbusVideo.d.ts","sourceRoot":"","sources":["../../src/extensions/MbusVideo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,MAAM,WAAW,gBAAgB;IAChC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACxC;AAED,OAAO,QAAQ,cAAc,CAAC;IAC7B,UAAU,QAAQ,CAAC,UAAU;QAC5B,SAAS,EAAE;YACV,YAAY,EAAE,CAAC,KAAK,EAAE;gBAAE,GAAG,EAAE,MAAM,CAAC;gBAAC,KAAK,CAAC,EAAE,MAAM,CAAA;aAAE,KAAK,UAAU,CAAC;SACrE,CAAC;KACF;CACD;AAED,eAAO,MAAM,SAAS,6BA0KpB,CAAC"}
|
|
@@ -1,35 +1,4 @@
|
|
|
1
1
|
import { Node, mergeAttributes } from "@tiptap/core";
|
|
2
|
-
function attachHls(video, src) {
|
|
3
|
-
if (video.canPlayType("application/vnd.apple.mpegurl")) {
|
|
4
|
-
video.src = src;
|
|
5
|
-
return { destroy: () => { } };
|
|
6
|
-
}
|
|
7
|
-
let hls = null;
|
|
8
|
-
let cancelled = false;
|
|
9
|
-
import("hls.js")
|
|
10
|
-
.then(({ default: Hls }) => {
|
|
11
|
-
if (cancelled)
|
|
12
|
-
return;
|
|
13
|
-
if (!Hls.isSupported()) {
|
|
14
|
-
video.src = src;
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
const instance = new Hls();
|
|
18
|
-
instance.loadSource(src);
|
|
19
|
-
instance.attachMedia(video);
|
|
20
|
-
hls = instance;
|
|
21
|
-
})
|
|
22
|
-
.catch(() => {
|
|
23
|
-
if (!cancelled)
|
|
24
|
-
video.src = src;
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
destroy: () => {
|
|
28
|
-
cancelled = true;
|
|
29
|
-
hls?.destroy();
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
2
|
export const MbusVideo = Node.create({
|
|
34
3
|
name: "mbusVideo",
|
|
35
4
|
group: "block",
|
|
@@ -76,15 +45,20 @@ export const MbusVideo = Node.create({
|
|
|
76
45
|
dom.style.cssText = "margin:8px 0;position:relative;box-sizing:border-box;max-width:100%;";
|
|
77
46
|
if (node.attrs.width)
|
|
78
47
|
dom.style.width = node.attrs.width;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
48
|
+
const aspect = document.createElement("div");
|
|
49
|
+
aspect.style.cssText =
|
|
50
|
+
"position:relative;width:100%;padding-top:56.25%;background:#0b1020;border-radius:8px;overflow:hidden;";
|
|
51
|
+
dom.appendChild(aspect);
|
|
52
|
+
if (node.attrs.src) {
|
|
53
|
+
const iframe = document.createElement("iframe");
|
|
54
|
+
iframe.src = node.attrs.src;
|
|
55
|
+
iframe.allow = "autoplay; fullscreen; encrypted-media; picture-in-picture";
|
|
56
|
+
iframe.setAttribute("allowfullscreen", "");
|
|
57
|
+
iframe.setAttribute("loading", "lazy");
|
|
58
|
+
iframe.style.cssText =
|
|
59
|
+
"position:absolute;inset:0;width:100%;height:100%;border:0;display:block;";
|
|
60
|
+
aspect.appendChild(iframe);
|
|
61
|
+
}
|
|
88
62
|
if (editor.isEditable) {
|
|
89
63
|
const del = document.createElement("button");
|
|
90
64
|
del.type = "button";
|
|
@@ -171,7 +145,7 @@ export const MbusVideo = Node.create({
|
|
|
171
145
|
dom.style.width = w || "";
|
|
172
146
|
return true;
|
|
173
147
|
},
|
|
174
|
-
destroy: () =>
|
|
148
|
+
destroy: () => { }
|
|
175
149
|
};
|
|
176
150
|
};
|
|
177
151
|
},
|