payload-richtext-tiptap 0.0.163 → 0.0.164
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/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.d.ts +33 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.js +94 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.d.ts +19 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.js +50 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js +11 -44
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/tiptapSchema.d.ts +66 -66
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Node } from "@tiptap/pm/model";
|
|
2
|
+
import { Editor } from "@tiptap/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
interface VideoBlockViewProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
getPos: () => number;
|
|
7
|
+
node: Node & {
|
|
8
|
+
attrs: {
|
|
9
|
+
src: string;
|
|
10
|
+
poster: string;
|
|
11
|
+
assetId: string;
|
|
12
|
+
playlistUrl?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
updateAttributes: (attrs: Record<string, string>) => void;
|
|
16
|
+
}
|
|
17
|
+
export type Playlist = {
|
|
18
|
+
id: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
poster: string;
|
|
22
|
+
items: Item[];
|
|
23
|
+
};
|
|
24
|
+
export type Item = {
|
|
25
|
+
src: string;
|
|
26
|
+
type: string;
|
|
27
|
+
label: string;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
};
|
|
31
|
+
export declare const VideoBlockViewV1: (props: VideoBlockViewProps) => React.JSX.Element;
|
|
32
|
+
export default VideoBlockViewV1;
|
|
33
|
+
//# sourceMappingURL=VideoBlockV1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockV1.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,KAAkD,MAAM,OAAO,CAAC;AAIvE,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;YACZ,MAAM,EAAE,MAAM,CAAC;YACf,OAAO,EAAE,MAAM,CAAC;YAChB,WAAW,CAAC,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;IACF,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC;CAC3D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,IAAI,EAAE,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,mBAAmB,sBAwG1D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { cn } from "../../../lib/utils/index.js";
|
|
5
|
+
import VideoPlayer from "./videojs/VideoPlayer.js";
|
|
6
|
+
export const VideoBlockViewV1 = (props)=>{
|
|
7
|
+
const { editor, getPos, node } = props;
|
|
8
|
+
const videoWrapperRef = useRef(null);
|
|
9
|
+
const { src, poster, playlistUrl, caption, title } = node.attrs;
|
|
10
|
+
const [playlistContent, setPlaylistContent] = React.useState();
|
|
11
|
+
const [error, setError] = React.useState("");
|
|
12
|
+
useEffect(()=>{
|
|
13
|
+
async function getPlaylistContent() {
|
|
14
|
+
try {
|
|
15
|
+
const res = await fetch(playlistUrl, {
|
|
16
|
+
cache: "no-cache"
|
|
17
|
+
});
|
|
18
|
+
return await res.json();
|
|
19
|
+
} catch {
|
|
20
|
+
setError("Issue with getting asset info");
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
if (playlistUrl) {
|
|
25
|
+
try {
|
|
26
|
+
getPlaylistContent().then((data)=>{
|
|
27
|
+
setPlaylistContent(data);
|
|
28
|
+
}).catch((err)=>{
|
|
29
|
+
setError(err);
|
|
30
|
+
});
|
|
31
|
+
} catch (error) {
|
|
32
|
+
setError(error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}, [
|
|
36
|
+
playlistUrl
|
|
37
|
+
]);
|
|
38
|
+
const wrapperClassName = cn(node.attrs.align === "left" ? "ml-0" : "ml-auto", node.attrs.align === "right" ? "mr-0" : "mr-auto", node.attrs.align === "center" && "mx-auto");
|
|
39
|
+
const onClick = useCallback(()=>{
|
|
40
|
+
editor.commands.setNodeSelection(getPos());
|
|
41
|
+
}, [
|
|
42
|
+
getPos,
|
|
43
|
+
editor.commands
|
|
44
|
+
]);
|
|
45
|
+
const videoJsOptions = useMemo(()=>{
|
|
46
|
+
if (playlistContent == undefined) return {};
|
|
47
|
+
if (playlistContent.items.some((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl")) {
|
|
48
|
+
return {
|
|
49
|
+
sources: playlistContent.items.filter((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl").map((item)=>({
|
|
50
|
+
src: item.src,
|
|
51
|
+
type: item.type,
|
|
52
|
+
label: item.label
|
|
53
|
+
})),
|
|
54
|
+
poster: playlistContent.poster
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
sources: playlistContent.items.map((item)=>({
|
|
59
|
+
src: item.src,
|
|
60
|
+
type: item.type,
|
|
61
|
+
label: item.label
|
|
62
|
+
})),
|
|
63
|
+
poster: playlistContent.poster
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
playlistContent
|
|
67
|
+
]);
|
|
68
|
+
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
69
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
70
|
+
className: wrapperClassName,
|
|
71
|
+
style: {
|
|
72
|
+
width: node.attrs.width
|
|
73
|
+
},
|
|
74
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
75
|
+
ref: videoWrapperRef,
|
|
76
|
+
children: [
|
|
77
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
78
|
+
children: error
|
|
79
|
+
}),
|
|
80
|
+
playlistContent && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
81
|
+
options: videoJsOptions
|
|
82
|
+
}),
|
|
83
|
+
caption && playlistContent?.title && /*#__PURE__*/ _jsx("caption", {
|
|
84
|
+
className: "text-center block text-sm text-gray-500",
|
|
85
|
+
children: title || playlistContent?.title
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
export default VideoBlockViewV1;
|
|
93
|
+
|
|
94
|
+
//# sourceMappingURL=VideoBlockV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV1.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\nimport VideoPlayer from \"./videojs/VideoPlayer.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport type Playlist = {\n id: string;\n title: string;\n description: string;\n poster: string;\n items: Item[];\n};\n\nexport type Item = {\n src: string;\n type: string;\n label: string;\n width: number;\n height: number;\n};\n\nexport const VideoBlockViewV1 = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster, playlistUrl, caption, title } = node.attrs;\n const [playlistContent, setPlaylistContent] = React.useState<\n Playlist | undefined\n >();\n const [error, setError] = React.useState(\"\");\n\n useEffect(() => {\n async function getPlaylistContent() {\n try {\n const res = await fetch(playlistUrl, {\n cache: \"no-cache\",\n });\n return await res.json();\n } catch {\n setError(\"Issue with getting asset info\");\n return undefined;\n }\n }\n\n if (playlistUrl) {\n try {\n getPlaylistContent()\n .then((data) => {\n setPlaylistContent(data);\n })\n .catch((err) => {\n setError(err);\n });\n } catch (error) {\n setError(error);\n }\n }\n }, [playlistUrl]);\n\n const wrapperClassName = cn(\n node.attrs.align === \"left\" ? \"ml-0\" : \"ml-auto\",\n node.attrs.align === \"right\" ? \"mr-0\" : \"mr-auto\",\n node.attrs.align === \"center\" && \"mx-auto\"\n );\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos());\n }, [getPos, editor.commands]);\n\n const videoJsOptions = useMemo(() => {\n if (playlistContent == undefined) return {};\n\n if (\n playlistContent.items.some(\n (item) =>\n item.type === \"application/x-mpegURL\" ||\n item.type === \"application/vnd.apple.mpegurl\"\n )\n ) {\n return {\n sources: playlistContent.items\n .filter(\n (item) =>\n item.type === \"application/x-mpegURL\" ||\n item.type === \"application/vnd.apple.mpegurl\"\n )\n .map((item) => ({\n src: item.src,\n type: item.type,\n label: item.label,\n })),\n poster: playlistContent.poster,\n };\n }\n return {\n sources: playlistContent.items.map((item) => ({\n src: item.src,\n type: item.type,\n label: item.label,\n })),\n poster: playlistContent.poster,\n };\n }, [playlistContent]);\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div ref={videoWrapperRef}>\n {error && <div>{error}</div>}\n {/* <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n /> */}\n {playlistContent && <VideoPlayer options={videoJsOptions} />}\n {caption && playlistContent?.title && (\n <caption className=\"text-center block text-sm text-gray-500\">\n {title || playlistContent?.title}\n </caption>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockViewV1;\n"],"names":["NodeViewWrapper","React","useCallback","useEffect","useMemo","useRef","cn","VideoPlayer","VideoBlockViewV1","props","editor","getPos","node","videoWrapperRef","src","poster","playlistUrl","caption","title","attrs","playlistContent","setPlaylistContent","useState","error","setError","getPlaylistContent","res","fetch","cache","json","undefined","then","data","catch","err","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","items","some","item","type","sources","filter","map","label","div","className","style","width","ref","options"],"mappings":"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"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Node } from '@tiptap/pm/model';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
interface VideoBlockViewProps {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
getPos: () => number;
|
|
7
|
+
node: Node & {
|
|
8
|
+
attrs: {
|
|
9
|
+
src: string;
|
|
10
|
+
poster: string;
|
|
11
|
+
assetId: string;
|
|
12
|
+
playlistUrl?: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
updateAttributes: (attrs: Record<string, string>) => void;
|
|
16
|
+
}
|
|
17
|
+
export declare const NewVideoBlockView: (props: VideoBlockViewProps) => React.JSX.Element;
|
|
18
|
+
export default NewVideoBlockView;
|
|
19
|
+
//# sourceMappingURL=VideoBlockV2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockV2.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAA;AACvD,OAAO,KAAkD,MAAM,OAAO,CAAA;AAItE,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,MAAM,CAAA;IACpB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAA;YACX,MAAM,EAAE,MAAM,CAAA;YACd,OAAO,EAAE,MAAM,CAAA;YACf,WAAW,CAAC,EAAE,MAAM,CAAA;SACrB,CAAA;KACF,CAAA;IACD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;CAC1D;AAGD,eAAO,MAAM,iBAAiB,UAAW,mBAAmB,sBA8C3D,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeViewWrapper } from '@tiptap/react';
|
|
3
|
+
import React, { useCallback, useMemo, useRef } from 'react';
|
|
4
|
+
import { cn } from '../../../lib/utils/index.js';
|
|
5
|
+
import VideoPlayer from './videojs/VideoPlayer.js';
|
|
6
|
+
export const NewVideoBlockView = (props)=>{
|
|
7
|
+
const { editor, getPos, node } = props;
|
|
8
|
+
const videoWrapperRef = useRef(null);
|
|
9
|
+
const { src, optimizedImageUrl, playlistUrl, caption, title } = node.attrs;
|
|
10
|
+
const [error, setError] = React.useState('');
|
|
11
|
+
const wrapperClassName = cn(node.attrs.align === 'left' ? 'ml-0' : 'ml-auto', node.attrs.align === 'right' ? 'mr-0' : 'mr-auto', node.attrs.align === 'center' && 'mx-auto');
|
|
12
|
+
const onClick = useCallback(()=>{
|
|
13
|
+
editor.commands.setNodeSelection(getPos());
|
|
14
|
+
}, [
|
|
15
|
+
getPos,
|
|
16
|
+
editor.commands
|
|
17
|
+
]);
|
|
18
|
+
const videoJsOptions = useMemo(()=>{
|
|
19
|
+
return {
|
|
20
|
+
sources: playlistUrl,
|
|
21
|
+
poster: optimizedImageUrl
|
|
22
|
+
};
|
|
23
|
+
}, []);
|
|
24
|
+
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
25
|
+
children: /*#__PURE__*/ _jsx("div", {
|
|
26
|
+
className: wrapperClassName,
|
|
27
|
+
style: {
|
|
28
|
+
width: node.attrs.width
|
|
29
|
+
},
|
|
30
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
31
|
+
ref: videoWrapperRef,
|
|
32
|
+
children: [
|
|
33
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
34
|
+
children: error
|
|
35
|
+
}),
|
|
36
|
+
playlistUrl && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
37
|
+
options: videoJsOptions
|
|
38
|
+
}),
|
|
39
|
+
caption && /*#__PURE__*/ _jsx("caption", {
|
|
40
|
+
className: "text-center block text-sm text-gray-500",
|
|
41
|
+
children: title || caption
|
|
42
|
+
})
|
|
43
|
+
]
|
|
44
|
+
})
|
|
45
|
+
})
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
export default NewVideoBlockView;
|
|
49
|
+
|
|
50
|
+
//# sourceMappingURL=VideoBlockV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.tsx"],"sourcesContent":["import { Node } from '@tiptap/pm/model'\nimport { Editor, NodeViewWrapper } from '@tiptap/react'\nimport React, { useCallback, useEffect, useMemo, useRef } from 'react'\nimport { cn } from '../../../lib/utils/index.js'\nimport VideoPlayer from './videojs/VideoPlayer.js'\n\ninterface VideoBlockViewProps {\n editor: Editor\n getPos: () => number\n node: Node & {\n attrs: {\n src: string\n poster: string\n assetId: string\n playlistUrl?: string\n }\n }\n updateAttributes: (attrs: Record<string, string>) => void\n}\n\n\nexport const NewVideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props\n const videoWrapperRef = useRef<HTMLDivElement>(null)\n const { src, optimizedImageUrl, playlistUrl, caption, title } = node.attrs\n\n const [error, setError] = React.useState('')\n\n const wrapperClassName = cn(\n node.attrs.align === 'left' ? 'ml-0' : 'ml-auto',\n node.attrs.align === 'right' ? 'mr-0' : 'mr-auto',\n node.attrs.align === 'center' && 'mx-auto',\n )\n\n const onClick = useCallback(() => {\n editor.commands.setNodeSelection(getPos())\n }, [getPos, editor.commands])\n\n const videoJsOptions = useMemo(() => {\n return {\n sources: playlistUrl,\n poster: optimizedImageUrl,\n }\n }, [])\n return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div ref={videoWrapperRef}>\n {error && <div>{error}</div>}\n {/* <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n /> */}\n {playlistUrl && <VideoPlayer options={videoJsOptions} />}\n {caption && (\n <caption className=\"text-center block text-sm text-gray-500\">\n {title || caption}\n </caption>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n )\n}\n\nexport default NewVideoBlockView\n"],"names":["NodeViewWrapper","React","useCallback","useMemo","useRef","cn","VideoPlayer","NewVideoBlockView","props","editor","getPos","node","videoWrapperRef","src","optimizedImageUrl","playlistUrl","caption","title","attrs","error","setError","useState","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","sources","poster","div","className","style","width","ref","options"],"mappings":";AACA,SAAiBA,eAAe,QAAQ,gBAAe;AACvD,OAAOC,SAASC,WAAW,EAAaC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AACtE,SAASC,EAAE,QAAQ,8BAA6B;AAChD,OAAOC,iBAAiB,2BAA0B;AAiBlD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACjC,MAAMI,kBAAkBR,OAAuB;IAC/C,MAAM,EAAES,GAAG,EAAEC,iBAAiB,EAAEC,WAAW,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGN,KAAKO,KAAK;IAE1E,MAAM,CAACC,OAAOC,SAAS,GAAGnB,MAAMoB,QAAQ,CAAC;IAEzC,MAAMC,mBAAmBjB,GACvBM,KAAKO,KAAK,CAACK,KAAK,KAAK,SAAS,SAAS,WACvCZ,KAAKO,KAAK,CAACK,KAAK,KAAK,UAAU,SAAS,WACxCZ,KAAKO,KAAK,CAACK,KAAK,KAAK,YAAY;IAGnC,MAAMC,UAAUtB,YAAY;QAC1BO,OAAOgB,QAAQ,CAACC,gBAAgB,CAAChB;IACnC,GAAG;QAACA;QAAQD,OAAOgB,QAAQ;KAAC;IAE5B,MAAME,iBAAiBxB,QAAQ;QAC7B,OAAO;YACLyB,SAASb;YACTc,QAAQf;QACV;IACF,GAAG,EAAE;IACL,qBACE,KAACd;kBACC,cAAA,KAAC8B;YAAIC,WAAWT;YAAkBU,OAAO;gBAAEC,OAAOtB,KAAKO,KAAK,CAACe,KAAK;YAAC;sBACjE,cAAA,MAACH;gBAAII,KAAKtB;;oBACPO,uBAAS,KAACW;kCAAKX;;oBASfJ,6BAAe,KAACT;wBAAY6B,SAASR;;oBACrCX,yBACC,KAACA;wBAAQe,WAAU;kCAChBd,SAASD;;;;;;AAOxB,EAAC;AAED,eAAeT,kBAAiB"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"VideoBlockView.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,MAAM,EAAE,MAAM,MAAM,CAAA;IACpB,IAAI,EAAE,IAAI,GAAG;QACX,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAA;YACX,MAAM,EAAE,MAAM,CAAA;YACd,OAAO,EAAE,MAAM,CAAA;YACf,WAAW,CAAC,EAAE,MAAM,CAAA;SACrB,CAAA;KACF,CAAA;IACD,gBAAgB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,IAAI,CAAA;CAC1D;AAED,MAAM,MAAM,QAAQ,GAAG;IACrB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,IAAI,EAAE,CAAA;CACd,CAAA;AAED,MAAM,MAAM,IAAI,GAAG;IACjB,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,mBAAmB,sBAKxD,CAAA;AAED,eAAe,cAAc,CAAA"}
|
|
@@ -1,48 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import VideoPlayer from './videojs/VideoPlayer.js';
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import NewVideoBlockView from './VideoBlockV2.js';
|
|
4
|
+
import VideoBlockViewV1 from './VideoBlockV1.js';
|
|
6
5
|
export const VideoBlockView = (props)=>{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}, [
|
|
15
|
-
getPos,
|
|
16
|
-
editor.commands
|
|
17
|
-
]);
|
|
18
|
-
const videoJsOptions = useMemo(()=>{
|
|
19
|
-
return {
|
|
20
|
-
sources: playlistUrl,
|
|
21
|
-
poster: optimizedImageUrl
|
|
22
|
-
};
|
|
23
|
-
}, []);
|
|
24
|
-
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
25
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
26
|
-
className: wrapperClassName,
|
|
27
|
-
style: {
|
|
28
|
-
width: node.attrs.width
|
|
29
|
-
},
|
|
30
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
31
|
-
ref: videoWrapperRef,
|
|
32
|
-
children: [
|
|
33
|
-
error && /*#__PURE__*/ _jsx("div", {
|
|
34
|
-
children: error
|
|
35
|
-
}),
|
|
36
|
-
playlistUrl && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
37
|
-
options: videoJsOptions
|
|
38
|
-
}),
|
|
39
|
-
caption && /*#__PURE__*/ _jsx("caption", {
|
|
40
|
-
className: "text-center block text-sm text-gray-500",
|
|
41
|
-
children: title || caption
|
|
42
|
-
})
|
|
43
|
-
]
|
|
44
|
-
})
|
|
45
|
-
})
|
|
6
|
+
if (props.node.attrs.playlistUrl.includes('.json')) {
|
|
7
|
+
/*#__PURE__*/ _jsx(VideoBlockViewV1, {
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return /*#__PURE__*/ _jsx(NewVideoBlockView, {
|
|
12
|
+
...props
|
|
46
13
|
});
|
|
47
14
|
};
|
|
48
15
|
export default VideoBlockView;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from '@tiptap/pm/model'\nimport { Editor
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from '@tiptap/pm/model'\nimport { Editor } from '@tiptap/react'\nimport React from 'react'\nimport NewVideoBlockView from './VideoBlockV2.js'\nimport VideoBlockViewV1 from './VideoBlockV1.js'\n\ninterface VideoBlockViewProps {\n editor: Editor\n getPos: () => number\n node: Node & {\n attrs: {\n src: string\n poster: string\n assetId: string\n playlistUrl?: string\n }\n }\n updateAttributes: (attrs: Record<string, string>) => void\n}\n\nexport type Playlist = {\n id: string\n title: string\n description: string\n poster: string\n items: Item[]\n}\n\nexport type Item = {\n src: string\n type: string\n label: string\n width: number\n height: number\n}\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n if (props.node.attrs.playlistUrl.includes('.json')) {\n <VideoBlockViewV1 {...props}/>\n }\n return <NewVideoBlockView {...props}/>\n}\n\nexport default VideoBlockView\n"],"names":["React","NewVideoBlockView","VideoBlockViewV1","VideoBlockView","props","node","attrs","playlistUrl","includes"],"mappings":";AAEA,OAAOA,WAAW,QAAO;AACzB,OAAOC,uBAAuB,oBAAmB;AACjD,OAAOC,sBAAsB,oBAAmB;AAgChD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,IAAIA,MAAMC,IAAI,CAACC,KAAK,CAACC,WAAW,CAACC,QAAQ,CAAC,UAAU;sBAClD,KAACN;YAAkB,GAAGE,KAAK;;IAC7B;IACA,qBAAO,KAACH;QAAmB,GAAGG,KAAK;;AACrC,EAAC;AAED,eAAeD,eAAc"}
|