payload-richtext-tiptap 0.0.164 → 0.0.165
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/ImageUpload/ImageUpload.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.js +1 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.js +4 -2
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockV2.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js +12 -115
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.d.ts +31 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.js +120 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.d.ts +31 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.js +78 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAyB,MAAM,eAAe,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAmB,MAAM,gBAAgB,CAAC;AAG5D,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,WAAW,EAAE;YACX,cAAc,EAAE,CAAC,IAAI,CAAC,EAAE,SAAS,KAAK,UAAU,CAAC;SAClD,CAAC;KACH;CACF;AAED,eAAO,MAAM,WAAW,gBAoDtB,CAAC;AAEH,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/ImageUpload.ts"],"sourcesContent":["'use client';\nimport { Node, ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { AssetType, openAssetHQType } from \"../../types.js\";\nimport { ImageUploadBuilder } from \"./view/ImageUpload.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n imageUpload: {\n setImageUpload: (type?: AssetType) => ReturnType;\n };\n }\n}\n\nexport const ImageUpload = Node.create({\n name: \"imageUpload\",\n\n isolating: true,\n\n defining: true,\n\n group: \"block\",\n\n draggable: true,\n\n selectable: true,\n\n inline: false,\n\n parseHTML() {\n return [\n {\n tag: `div[data-type=\"${this.name}\"]`,\n },\n ];\n },\n\n renderHTML() {\n return [\"div\", { \"data-type\": this.name }];\n },\n\n addAttributes() {\n return {\n type: { default: null },\n };\n },\n addCommands() {\n return {\n setImageUpload:\n (type?: AssetType) =>\n ({ commands }) => {\n return commands.insertContent({\n type: \"imageUpload\",\n attrs: {\n type,\n },\n });\n },\n };\n },\n\n addNodeView() {\n const openAssetHQHandler = this.options\n .openAssetHQHandler as openAssetHQType;\n return ReactNodeViewRenderer(ImageUploadBuilder(openAssetHQHandler));\n },\n});\n\nexport default ImageUpload;\n"],"names":["Node","ReactNodeViewRenderer","ImageUploadBuilder","ImageUpload","create","name","isolating","defining","group","draggable","selectable","inline","parseHTML","tag","renderHTML","addAttributes","type","default","addCommands","setImageUpload","commands","insertContent","attrs","addNodeView","openAssetHQHandler","options"],"mappings":"AAAA;AACA,SAASA,IAAI,EAAEC,qBAAqB,QAAQ,gBAAgB;AAE5D,SAASC,kBAAkB,QAAQ,wBAAwB;AAU3D,OAAO,MAAMC,cAAcH,KAAKI,MAAM,CAAC;IACrCC,MAAM;IAENC,WAAW;IAEXC,UAAU;IAEVC,OAAO;IAEPC,WAAW;IAEXC,YAAY;IAEZC,QAAQ;IAERC;QACE,OAAO;YACL;gBACEC,KAAK,CAAC,eAAe,EAAE,IAAI,CAACR,IAAI,CAAC,EAAE,CAAC;YACtC;SACD;IACH;IAEAS;QACE,OAAO;YAAC;YAAO;gBAAE,aAAa,IAAI,CAACT,IAAI;YAAC;SAAE;IAC5C;IAEAU;QACE,OAAO;YACLC,MAAM;gBAAEC,SAAS;YAAK;QACxB;IACF;IACAC;QACE,OAAO;YACLC,gBACE,CAACH,OACD,CAAC,EAAEI,QAAQ,EAAE;oBACX,OAAOA,SAASC,aAAa,CAAC;wBAC5BL,MAAM;wBACNM,OAAO;4BACLN;wBACF;oBACF;gBACF;QACJ;IACF;IAEAO;QACE,MAAMC,qBAAqB,IAAI,CAACC,OAAO,CACpCD,kBAAkB;QACrB,OAAOvB,sBAAsBC,mBAAmBsB;IAClD;AACF,GAAG;AAEH,eAAerB,YAAY"}
|
|
@@ -1 +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;
|
|
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;AAED,eAAO,MAAM,iBAAiB,UAAW,mBAAmB,sBA8C3D,CAAA;AAED,eAAe,iBAAiB,CAAA"}
|
|
@@ -6,7 +6,7 @@ import VideoPlayer from './videojs/VideoPlayer.js';
|
|
|
6
6
|
export const NewVideoBlockView = (props)=>{
|
|
7
7
|
const { editor, getPos, node } = props;
|
|
8
8
|
const videoWrapperRef = useRef(null);
|
|
9
|
-
const { src, optimizedImageUrl, playlistUrl, caption, title } = node.attrs;
|
|
9
|
+
const { src, poster, optimizedImageUrl, playlistUrl, caption, title } = node.attrs;
|
|
10
10
|
const [error, setError] = React.useState('');
|
|
11
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
12
|
const onClick = useCallback(()=>{
|
|
@@ -18,7 +18,9 @@ export const NewVideoBlockView = (props)=>{
|
|
|
18
18
|
const videoJsOptions = useMemo(()=>{
|
|
19
19
|
return {
|
|
20
20
|
sources: playlistUrl,
|
|
21
|
-
poster
|
|
21
|
+
...(poster || optimizedImageUrl) && {
|
|
22
|
+
poster: poster || optimizedImageUrl
|
|
23
|
+
}
|
|
22
24
|
};
|
|
23
25
|
}, []);
|
|
24
26
|
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
@@ -1 +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\
|
|
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\nexport const NewVideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props\n const videoWrapperRef = useRef<HTMLDivElement>(null)\n const { src, poster, 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) && { poster: 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","poster","optimizedImageUrl","playlistUrl","caption","title","attrs","error","setError","useState","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","sources","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;AAgBlD,OAAO,MAAMC,oBAAoB,CAACC;IAChC,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACjC,MAAMI,kBAAkBR,OAAuB;IAC/C,MAAM,EAAES,GAAG,EAAEC,MAAM,EAAEC,iBAAiB,EAAEC,WAAW,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGP,KAAKQ,KAAK;IAElF,MAAM,CAACC,OAAOC,SAAS,GAAGpB,MAAMqB,QAAQ,CAAC;IAEzC,MAAMC,mBAAmBlB,GACvBM,KAAKQ,KAAK,CAACK,KAAK,KAAK,SAAS,SAAS,WACvCb,KAAKQ,KAAK,CAACK,KAAK,KAAK,UAAU,SAAS,WACxCb,KAAKQ,KAAK,CAACK,KAAK,KAAK,YAAY;IAGnC,MAAMC,UAAUvB,YAAY;QAC1BO,OAAOiB,QAAQ,CAACC,gBAAgB,CAACjB;IACnC,GAAG;QAACA;QAAQD,OAAOiB,QAAQ;KAAC;IAE5B,MAAME,iBAAiBzB,QAAQ;QAC7B,OAAO;YACL0B,SAASb;YACT,GAAI,AAACF,CAAAA,UAAUC,iBAAgB,KAAM;gBAAED,QAAQA,UAAUC;YAAkB,CAAC;QAC9E;IACF,GAAG,EAAE;IACL,qBACE,KAACf;kBACC,cAAA,KAAC8B;YAAIC,WAAWR;YAAkBS,OAAO;gBAAEC,OAAOtB,KAAKQ,KAAK,CAACc,KAAK;YAAC;sBACjE,cAAA,MAACH;gBAAII,KAAKtB;;oBACPQ,uBAAS,KAACU;kCAAKV;;oBASfJ,6BAAe,KAACV;wBAAY6B,SAASP;;oBACrCX,yBACC,KAACA;wBAAQc,WAAU;kCAChBb,SAASD;;;;;;AAOxB,EAAC;AAED,eAAeV,kBAAiB"}
|
|
@@ -4,7 +4,7 @@ import NewVideoBlockView from './VideoBlockV2.js';
|
|
|
4
4
|
import VideoBlockViewV1 from './VideoBlockV1.js';
|
|
5
5
|
export const VideoBlockView = (props)=>{
|
|
6
6
|
if (props.node.attrs.playlistUrl.includes('.json')) {
|
|
7
|
-
/*#__PURE__*/ _jsx(VideoBlockViewV1, {
|
|
7
|
+
return /*#__PURE__*/ _jsx(VideoBlockViewV1, {
|
|
8
8
|
...props
|
|
9
9
|
});
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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 return <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;QAClD,qBAAO,KAACN;YAAkB,GAAGE,KAAK;;IACpC;IACA,qBAAO,KAACH;QAAmB,GAAGG,KAAK;;AACrC,EAAC;AAED,eAAeD,eAAc"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts
CHANGED
|
@@ -26,6 +26,6 @@ export type Item = {
|
|
|
26
26
|
width: number;
|
|
27
27
|
height: number;
|
|
28
28
|
};
|
|
29
|
-
export declare const VideoBlockViewClientside: (
|
|
29
|
+
export declare const VideoBlockViewClientside: (props: VideoBlockViewProps) => React.JSX.Element;
|
|
30
30
|
export default VideoBlockViewClientside;
|
|
31
31
|
//# sourceMappingURL=VideoBlockViewClientside.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockViewClientside.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoBlockViewClientside.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,UAAU,mBAAmB;IAC3B,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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;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,wBAAwB,UAAW,mBAAmB,sBAKlE,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js
CHANGED
|
@@ -1,118 +1,15 @@
|
|
|
1
|
-
import { jsx as _jsx
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const [error, setError] = React.useState();
|
|
14
|
-
useEffect(()=>{
|
|
15
|
-
async function getPlaylistContent() {
|
|
16
|
-
const res = await fetch(playlistUrl, {
|
|
17
|
-
cache: "no-cache"
|
|
18
|
-
});
|
|
19
|
-
return await res.json();
|
|
20
|
-
}
|
|
21
|
-
if (playlistUrl) {
|
|
22
|
-
try {
|
|
23
|
-
getPlaylistContent().then((data)=>{
|
|
24
|
-
setPlaylistContent(data);
|
|
25
|
-
}).catch((err)=>{
|
|
26
|
-
setError(err);
|
|
27
|
-
});
|
|
28
|
-
} catch (error) {
|
|
29
|
-
setError(error);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}, [
|
|
33
|
-
playlistUrl
|
|
34
|
-
]);
|
|
35
|
-
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");
|
|
36
|
-
const videoJsOptions = useMemo(()=>{
|
|
37
|
-
if (playlistContent == undefined) return {};
|
|
38
|
-
if (playlistContent.items.some((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl")) {
|
|
39
|
-
return {
|
|
40
|
-
sources: playlistContent.items.filter((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl").map((item)=>({
|
|
41
|
-
src: item.src,
|
|
42
|
-
type: item.type,
|
|
43
|
-
label: item.label
|
|
44
|
-
})),
|
|
45
|
-
poster: playlistContent.poster,
|
|
46
|
-
preload: "auto"
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return {
|
|
50
|
-
sources: playlistContent.items.map((item)=>({
|
|
51
|
-
src: item.src,
|
|
52
|
-
type: item.type,
|
|
53
|
-
label: item.label
|
|
54
|
-
})),
|
|
55
|
-
poster: playlistContent.poster,
|
|
56
|
-
preload: "auto"
|
|
57
|
-
};
|
|
58
|
-
}, [
|
|
59
|
-
playlistContent
|
|
60
|
-
]);
|
|
61
|
-
useEffect(()=>{
|
|
62
|
-
if (!playlistContent?.items?.length) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const source = playlistContent.items.find((item)=>item.src);
|
|
66
|
-
if (!aspectRatio && source?.src) {
|
|
67
|
-
calculateAspectRatio({
|
|
68
|
-
src: source.src,
|
|
69
|
-
actualWidth: actualWidth || source?.width,
|
|
70
|
-
actualHeight: actualHeight || source?.height
|
|
71
|
-
}, "VIDEO", getVideoAspect);
|
|
72
|
-
}
|
|
73
|
-
}, [
|
|
74
|
-
playlistContent
|
|
75
|
-
]);
|
|
76
|
-
const style = useMemo(()=>{
|
|
77
|
-
if (aspectRatio) {
|
|
78
|
-
return {
|
|
79
|
-
aspectRatio,
|
|
80
|
-
width: node.attrs.width
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
return {
|
|
84
|
-
width: node.attrs.width
|
|
85
|
-
};
|
|
86
|
-
}, [
|
|
87
|
-
aspectRatio
|
|
88
|
-
]);
|
|
89
|
-
return /*#__PURE__*/ _jsxs(NodeViewWrapper, {
|
|
90
|
-
className: className,
|
|
91
|
-
children: [
|
|
92
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
-
className: cn(wrapperClassName, "main-videojs-wrapper aspect-square h-full"),
|
|
94
|
-
...isVertical && {
|
|
95
|
-
"data-vertical": isVertical
|
|
96
|
-
},
|
|
97
|
-
ref: videoWrapperRef,
|
|
98
|
-
style: style,
|
|
99
|
-
children: [
|
|
100
|
-
error && /*#__PURE__*/ _jsx("div", {
|
|
101
|
-
children: error
|
|
102
|
-
}),
|
|
103
|
-
playlistContent && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
104
|
-
options: videoJsOptions
|
|
105
|
-
})
|
|
106
|
-
]
|
|
107
|
-
}),
|
|
108
|
-
caption && playlistContent?.title && /*#__PURE__*/ _jsx("div", {
|
|
109
|
-
className: "block mx-auto text-sm text-gray-500 text-center mt-1",
|
|
110
|
-
style: {
|
|
111
|
-
width: node.attrs.width
|
|
112
|
-
},
|
|
113
|
-
children: playlistContent?.title
|
|
114
|
-
})
|
|
115
|
-
]
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import VideoBlockViewClientsideV1 from "./VideoBlockViewClientsideV1.js";
|
|
4
|
+
import VideoBlockViewClientsideV2 from "./VideoBlockViewClientsideV2.js";
|
|
5
|
+
export const VideoBlockViewClientside = (props)=>{
|
|
6
|
+
if (props.node.attrs.playlistUrl.includes('.json')) {
|
|
7
|
+
return /*#__PURE__*/ _jsx(VideoBlockViewClientsideV1, {
|
|
8
|
+
...props
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return /*#__PURE__*/ _jsx(VideoBlockViewClientsideV2, {
|
|
12
|
+
...props
|
|
116
13
|
});
|
|
117
14
|
};
|
|
118
15
|
export default VideoBlockViewClientside;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport React from \"react\";\nimport VideoBlockViewClientsideV1 from \"./VideoBlockViewClientsideV1.js\";\nimport VideoBlockViewClientsideV2 from \"./VideoBlockViewClientsideV2.js\";\n\ninterface VideoBlockViewProps {\n node: Node & {\n attrs: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n };\n };\n className?: string;\n getVideoAspect?: () => 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 VideoBlockViewClientside = (props: VideoBlockViewProps) => {\n if (props.node.attrs.playlistUrl.includes('.json')) {\n return <VideoBlockViewClientsideV1 {...props}/>\n }\n return <VideoBlockViewClientsideV2 {...props}/>\n};\n\nexport default VideoBlockViewClientside;\n"],"names":["React","VideoBlockViewClientsideV1","VideoBlockViewClientsideV2","VideoBlockViewClientside","props","node","attrs","playlistUrl","includes"],"mappings":";AACA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,gCAAgC,kCAAkC;AACzE,OAAOC,gCAAgC,kCAAkC;AA+BzE,OAAO,MAAMC,2BAA2B,CAACC;IACvC,IAAIA,MAAMC,IAAI,CAACC,KAAK,CAACC,WAAW,CAACC,QAAQ,CAAC,UAAU;QACjD,qBAAO,KAACP;YAA4B,GAAGG,KAAK;;IAC9C;IACA,qBAAO,KAACF;QAA4B,GAAGE,KAAK;;AAC/C,EAAE;AAEF,eAAeD,yBAAyB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Node } from "@tiptap/pm/model";
|
|
2
|
+
import React from "react";
|
|
3
|
+
interface VideoBlockViewProps {
|
|
4
|
+
node: Node & {
|
|
5
|
+
attrs: {
|
|
6
|
+
src: string;
|
|
7
|
+
poster: string;
|
|
8
|
+
assetId: string;
|
|
9
|
+
playlistUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
className?: string;
|
|
13
|
+
getVideoAspect?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type Playlist = {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
poster: string;
|
|
20
|
+
items: Item[];
|
|
21
|
+
};
|
|
22
|
+
export type Item = {
|
|
23
|
+
src: string;
|
|
24
|
+
type: string;
|
|
25
|
+
label: string;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const VideoBlockViewClientsideV1: ({ className, getVideoAspect, ...props }: VideoBlockViewProps) => React.JSX.Element;
|
|
30
|
+
export default VideoBlockViewClientsideV1;
|
|
31
|
+
//# sourceMappingURL=VideoBlockViewClientsideV1.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockViewClientsideV1.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAExC,OAAO,KAAqC,MAAM,OAAO,CAAC;AAK1D,UAAU,mBAAmB;IAC3B,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,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;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,0BAA0B,4CAIpC,mBAAmB,sBAmIrB,CAAC;AAEF,eAAe,0BAA0B,CAAC"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
|
+
import React, { useEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { cn } from "../../../lib/utils/index.js";
|
|
5
|
+
import VideoPlayer from "./videojs/VideoPlayer.js";
|
|
6
|
+
import { useGetAssetsAspectRatio } from "../../serverside/getAssetsAspectRatio.js";
|
|
7
|
+
export const VideoBlockViewClientsideV1 = ({ className, getVideoAspect, ...props })=>{
|
|
8
|
+
const { node } = props;
|
|
9
|
+
const videoWrapperRef = useRef(null);
|
|
10
|
+
const { src, poster, playlistUrl, caption, actualWidth, actualHeight } = node.attrs;
|
|
11
|
+
const { aspectRatio, calculateAspectRatio, isVertical } = useGetAssetsAspectRatio();
|
|
12
|
+
const [playlistContent, setPlaylistContent] = React.useState();
|
|
13
|
+
const [error, setError] = React.useState();
|
|
14
|
+
useEffect(()=>{
|
|
15
|
+
async function getPlaylistContent() {
|
|
16
|
+
const res = await fetch(playlistUrl, {
|
|
17
|
+
cache: "no-cache"
|
|
18
|
+
});
|
|
19
|
+
return await res.json();
|
|
20
|
+
}
|
|
21
|
+
if (playlistUrl) {
|
|
22
|
+
try {
|
|
23
|
+
getPlaylistContent().then((data)=>{
|
|
24
|
+
setPlaylistContent(data);
|
|
25
|
+
}).catch((err)=>{
|
|
26
|
+
setError(err);
|
|
27
|
+
});
|
|
28
|
+
} catch (error) {
|
|
29
|
+
setError(error);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}, [
|
|
33
|
+
playlistUrl
|
|
34
|
+
]);
|
|
35
|
+
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");
|
|
36
|
+
const videoJsOptions = useMemo(()=>{
|
|
37
|
+
if (playlistContent == undefined) return {};
|
|
38
|
+
if (playlistContent.items.some((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl")) {
|
|
39
|
+
return {
|
|
40
|
+
sources: playlistContent.items.filter((item)=>item.type === "application/x-mpegURL" || item.type === "application/vnd.apple.mpegurl").map((item)=>({
|
|
41
|
+
src: item.src,
|
|
42
|
+
type: item.type,
|
|
43
|
+
label: item.label
|
|
44
|
+
})),
|
|
45
|
+
poster: playlistContent.poster,
|
|
46
|
+
preload: "auto"
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
sources: playlistContent.items.map((item)=>({
|
|
51
|
+
src: item.src,
|
|
52
|
+
type: item.type,
|
|
53
|
+
label: item.label
|
|
54
|
+
})),
|
|
55
|
+
poster: playlistContent.poster,
|
|
56
|
+
preload: "auto"
|
|
57
|
+
};
|
|
58
|
+
}, [
|
|
59
|
+
playlistContent
|
|
60
|
+
]);
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
if (!playlistContent?.items?.length) {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const source = playlistContent.items.find((item)=>item.src);
|
|
66
|
+
if (!aspectRatio && source?.src) {
|
|
67
|
+
calculateAspectRatio({
|
|
68
|
+
src: source.src,
|
|
69
|
+
actualWidth: actualWidth || source?.width,
|
|
70
|
+
actualHeight: actualHeight || source?.height
|
|
71
|
+
}, "VIDEO", getVideoAspect);
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
playlistContent
|
|
75
|
+
]);
|
|
76
|
+
const style = useMemo(()=>{
|
|
77
|
+
if (aspectRatio) {
|
|
78
|
+
return {
|
|
79
|
+
aspectRatio,
|
|
80
|
+
width: node.attrs.width
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
width: node.attrs.width
|
|
85
|
+
};
|
|
86
|
+
}, [
|
|
87
|
+
aspectRatio
|
|
88
|
+
]);
|
|
89
|
+
return /*#__PURE__*/ _jsxs(NodeViewWrapper, {
|
|
90
|
+
className: className,
|
|
91
|
+
children: [
|
|
92
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
93
|
+
className: cn(wrapperClassName, "main-videojs-wrapper aspect-square h-full"),
|
|
94
|
+
...isVertical && {
|
|
95
|
+
"data-vertical": isVertical
|
|
96
|
+
},
|
|
97
|
+
ref: videoWrapperRef,
|
|
98
|
+
style: style,
|
|
99
|
+
children: [
|
|
100
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
101
|
+
children: error
|
|
102
|
+
}),
|
|
103
|
+
playlistContent && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
104
|
+
options: videoJsOptions
|
|
105
|
+
})
|
|
106
|
+
]
|
|
107
|
+
}),
|
|
108
|
+
caption && playlistContent?.title && /*#__PURE__*/ _jsx("div", {
|
|
109
|
+
className: "block mx-auto text-sm text-gray-500 text-center mt-1",
|
|
110
|
+
style: {
|
|
111
|
+
width: node.attrs.width
|
|
112
|
+
},
|
|
113
|
+
children: playlistContent?.title
|
|
114
|
+
})
|
|
115
|
+
]
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
export default VideoBlockViewClientsideV1;
|
|
119
|
+
|
|
120
|
+
//# sourceMappingURL=VideoBlockViewClientsideV1.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV1.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useEffect, useMemo, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\nimport VideoPlayer from \"./videojs/VideoPlayer.js\";\nimport { useGetAssetsAspectRatio } from \"../../serverside/getAssetsAspectRatio.js\";\n\ninterface VideoBlockViewProps {\n node: Node & {\n attrs: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n };\n };\n className?: string;\n getVideoAspect?: () => 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 VideoBlockViewClientsideV1 = ({\n className,\n getVideoAspect,\n ...props\n}: VideoBlockViewProps) => {\n const { node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster, playlistUrl, caption, actualWidth, actualHeight } =\n node.attrs;\n const { aspectRatio, calculateAspectRatio, isVertical } =\n useGetAssetsAspectRatio();\n const [playlistContent, setPlaylistContent] = React.useState<\n Playlist | undefined\n >();\n const [error, setError] = React.useState();\n\n useEffect(() => {\n async function getPlaylistContent() {\n const res = await fetch(playlistUrl, {\n cache: \"no-cache\",\n });\n return await res.json();\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 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 preload: \"auto\",\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 preload: \"auto\",\n };\n }, [playlistContent]);\n\n useEffect(() => {\n if (!playlistContent?.items?.length) {\n return;\n }\n const source = playlistContent.items.find((item) => item.src);\n if (!aspectRatio && source?.src) {\n calculateAspectRatio(\n {\n src: source.src,\n actualWidth: actualWidth || source?.width,\n actualHeight: actualHeight || source?.height,\n },\n \"VIDEO\",\n getVideoAspect\n );\n }\n }, [playlistContent]);\n const style = useMemo(() => {\n if (aspectRatio) {\n return {\n aspectRatio,\n width: node.attrs.width,\n };\n }\n return {\n width: node.attrs.width,\n };\n }, [aspectRatio]);\n return (\n <NodeViewWrapper className={className}>\n <div\n className={cn(\n wrapperClassName,\n \"main-videojs-wrapper aspect-square h-full\"\n )}\n {...(isVertical && { \"data-vertical\": isVertical })}\n ref={videoWrapperRef}\n style={style}\n >\n {error && <div>{error}</div>}\n\n {playlistContent && <VideoPlayer options={videoJsOptions} />}\n </div>\n {caption && playlistContent?.title && (\n <div\n className=\"block mx-auto text-sm text-gray-500 text-center mt-1\"\n style={{ width: node.attrs.width }}\n >\n {playlistContent?.title}\n </div>\n )}\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockViewClientsideV1;\n"],"names":["NodeViewWrapper","React","useEffect","useMemo","useRef","cn","VideoPlayer","useGetAssetsAspectRatio","VideoBlockViewClientsideV1","className","getVideoAspect","props","node","videoWrapperRef","src","poster","playlistUrl","caption","actualWidth","actualHeight","attrs","aspectRatio","calculateAspectRatio","isVertical","playlistContent","setPlaylistContent","useState","error","setError","getPlaylistContent","res","fetch","cache","json","then","data","catch","err","wrapperClassName","align","videoJsOptions","undefined","items","some","item","type","sources","filter","map","label","preload","length","source","find","width","height","style","div","ref","options","title"],"mappings":"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"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Node } from '@tiptap/pm/model';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
interface VideoBlockViewProps {
|
|
4
|
+
node: Node & {
|
|
5
|
+
attrs: {
|
|
6
|
+
src: string;
|
|
7
|
+
poster: string;
|
|
8
|
+
assetId: string;
|
|
9
|
+
playlistUrl?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
className?: string;
|
|
13
|
+
getVideoAspect?: () => void;
|
|
14
|
+
}
|
|
15
|
+
export type Playlist = {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
poster: string;
|
|
20
|
+
items: Item[];
|
|
21
|
+
};
|
|
22
|
+
export type Item = {
|
|
23
|
+
src: string;
|
|
24
|
+
type: string;
|
|
25
|
+
label: string;
|
|
26
|
+
width: number;
|
|
27
|
+
height: number;
|
|
28
|
+
};
|
|
29
|
+
export declare const VideoBlockViewClientsideV2: ({ className, getVideoAspect, ...props }: VideoBlockViewProps) => React.JSX.Element;
|
|
30
|
+
export default VideoBlockViewClientsideV2;
|
|
31
|
+
//# sourceMappingURL=VideoBlockViewClientsideV2.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoBlockViewClientsideV2.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAEvC,OAAO,KAAqC,MAAM,OAAO,CAAA;AAKzD,UAAU,mBAAmB;IAC3B,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,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;CAC5B;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,0BAA0B,4CAIpC,mBAAmB,sBAwErB,CAAA;AAED,eAAe,0BAA0B,CAAA"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { NodeViewWrapper } from '@tiptap/react';
|
|
3
|
+
import React, { useEffect, useMemo, useRef } from 'react';
|
|
4
|
+
import { cn } from '../../../lib/utils/index.js';
|
|
5
|
+
import VideoPlayer from './videojs/VideoPlayer.js';
|
|
6
|
+
import { useGetAssetsAspectRatio } from '../../serverside/getAssetsAspectRatio.js';
|
|
7
|
+
export const VideoBlockViewClientsideV2 = ({ className, getVideoAspect, ...props })=>{
|
|
8
|
+
const { node } = props;
|
|
9
|
+
const videoWrapperRef = useRef(null);
|
|
10
|
+
const { src, optimizedImageUrl, playlistUrl, caption, actualWidth, actualHeight, title } = node.attrs;
|
|
11
|
+
const { aspectRatio, calculateAspectRatio, isVertical } = useGetAssetsAspectRatio();
|
|
12
|
+
const [error, setError] = React.useState();
|
|
13
|
+
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');
|
|
14
|
+
const videoJsOptions = useMemo(()=>{
|
|
15
|
+
return {
|
|
16
|
+
sources: playlistUrl,
|
|
17
|
+
poster: optimizedImageUrl
|
|
18
|
+
};
|
|
19
|
+
}, []);
|
|
20
|
+
useEffect(()=>{
|
|
21
|
+
if (!playlistUrl) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (!aspectRatio) {
|
|
25
|
+
calculateAspectRatio({
|
|
26
|
+
src: '',
|
|
27
|
+
actualWidth: actualWidth,
|
|
28
|
+
actualHeight: actualHeight
|
|
29
|
+
}, 'VIDEO', getVideoAspect);
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
playlistUrl
|
|
33
|
+
]);
|
|
34
|
+
const style = useMemo(()=>{
|
|
35
|
+
if (aspectRatio) {
|
|
36
|
+
return {
|
|
37
|
+
aspectRatio,
|
|
38
|
+
width: node.attrs.width
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
width: node.attrs.width
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
aspectRatio
|
|
46
|
+
]);
|
|
47
|
+
return /*#__PURE__*/ _jsxs(NodeViewWrapper, {
|
|
48
|
+
className: className,
|
|
49
|
+
children: [
|
|
50
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
51
|
+
className: cn(wrapperClassName, 'main-videojs-wrapper aspect-square h-full'),
|
|
52
|
+
...isVertical && {
|
|
53
|
+
'data-vertical': isVertical
|
|
54
|
+
},
|
|
55
|
+
ref: videoWrapperRef,
|
|
56
|
+
style: style,
|
|
57
|
+
children: [
|
|
58
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
59
|
+
children: error
|
|
60
|
+
}),
|
|
61
|
+
playlistUrl && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
62
|
+
options: videoJsOptions
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
}),
|
|
66
|
+
(caption || title) && /*#__PURE__*/ _jsx("div", {
|
|
67
|
+
className: "block mx-auto text-sm text-gray-500 text-center mt-1",
|
|
68
|
+
style: {
|
|
69
|
+
width: node.attrs.width
|
|
70
|
+
},
|
|
71
|
+
children: title || caption
|
|
72
|
+
})
|
|
73
|
+
]
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
export default VideoBlockViewClientsideV2;
|
|
77
|
+
|
|
78
|
+
//# sourceMappingURL=VideoBlockViewClientsideV2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientsideV2.tsx"],"sourcesContent":["import { Node } from '@tiptap/pm/model'\nimport { NodeViewWrapper } from '@tiptap/react'\nimport React, { useEffect, useMemo, useRef } from 'react'\nimport { cn } from '../../../lib/utils/index.js'\nimport VideoPlayer from './videojs/VideoPlayer.js'\nimport { useGetAssetsAspectRatio } from '../../serverside/getAssetsAspectRatio.js'\n\ninterface VideoBlockViewProps {\n node: Node & {\n attrs: {\n src: string\n poster: string\n assetId: string\n playlistUrl?: string\n }\n }\n className?: string\n getVideoAspect?: () => 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 VideoBlockViewClientsideV2 = ({\n className,\n getVideoAspect,\n ...props\n}: VideoBlockViewProps) => {\n const { node } = props\n const videoWrapperRef = useRef<HTMLDivElement>(null)\n const { src, optimizedImageUrl, playlistUrl, caption, actualWidth, actualHeight, title } =\n node.attrs\n const { aspectRatio, calculateAspectRatio, isVertical } = useGetAssetsAspectRatio()\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 videoJsOptions = useMemo(() => {\n return {\n sources: playlistUrl,\n poster: optimizedImageUrl,\n }\n }, [])\n\n useEffect(() => {\n if (!playlistUrl) {\n return\n }\n if (!aspectRatio) {\n calculateAspectRatio(\n {\n src: '',\n actualWidth: actualWidth,\n actualHeight: actualHeight,\n },\n 'VIDEO',\n getVideoAspect,\n )\n }\n }, [playlistUrl])\n\n const style = useMemo(() => {\n if (aspectRatio) {\n return {\n aspectRatio,\n width: node.attrs.width,\n }\n }\n return {\n width: node.attrs.width,\n }\n }, [aspectRatio])\n return (\n <NodeViewWrapper className={className}>\n <div\n className={cn(wrapperClassName, 'main-videojs-wrapper aspect-square h-full')}\n {...(isVertical && { 'data-vertical': isVertical })}\n ref={videoWrapperRef}\n style={style}\n >\n {error && <div>{error}</div>}\n\n {playlistUrl && <VideoPlayer options={videoJsOptions} />}\n </div>\n {(caption || title) && (\n <div\n className=\"block mx-auto text-sm text-gray-500 text-center mt-1\"\n style={{ width: node.attrs.width }}\n >\n {title || caption}\n </div>\n )}\n </NodeViewWrapper>\n )\n}\n\nexport default VideoBlockViewClientsideV2\n"],"names":["NodeViewWrapper","React","useEffect","useMemo","useRef","cn","VideoPlayer","useGetAssetsAspectRatio","VideoBlockViewClientsideV2","className","getVideoAspect","props","node","videoWrapperRef","src","optimizedImageUrl","playlistUrl","caption","actualWidth","actualHeight","title","attrs","aspectRatio","calculateAspectRatio","isVertical","error","setError","useState","wrapperClassName","align","videoJsOptions","sources","poster","style","width","div","ref","options"],"mappings":";AACA,SAASA,eAAe,QAAQ,gBAAe;AAC/C,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AACzD,SAASC,EAAE,QAAQ,8BAA6B;AAChD,OAAOC,iBAAiB,2BAA0B;AAClD,SAASC,uBAAuB,QAAQ,2CAA0C;AA+BlF,OAAO,MAAMC,6BAA6B,CAAC,EACzCC,SAAS,EACTC,cAAc,EACd,GAAGC,OACiB;IACpB,MAAM,EAAEC,IAAI,EAAE,GAAGD;IACjB,MAAME,kBAAkBT,OAAuB;IAC/C,MAAM,EAAEU,GAAG,EAAEC,iBAAiB,EAAEC,WAAW,EAAEC,OAAO,EAAEC,WAAW,EAAEC,YAAY,EAAEC,KAAK,EAAE,GACtFR,KAAKS,KAAK;IACZ,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,EAAEC,UAAU,EAAE,GAAGjB;IAE1D,MAAM,CAACkB,OAAOC,SAAS,GAAGzB,MAAM0B,QAAQ;IAExC,MAAMC,mBAAmBvB,GACvBO,KAAKS,KAAK,CAACQ,KAAK,KAAK,SAAS,SAAS,WACvCjB,KAAKS,KAAK,CAACQ,KAAK,KAAK,UAAU,SAAS,WACxCjB,KAAKS,KAAK,CAACQ,KAAK,KAAK,YAAY;IAGnC,MAAMC,iBAAiB3B,QAAQ;QAC7B,OAAO;YACL4B,SAASf;YACTgB,QAAQjB;QACV;IACF,GAAG,EAAE;IAELb,UAAU;QACR,IAAI,CAACc,aAAa;YAChB;QACF;QACA,IAAI,CAACM,aAAa;YAChBC,qBACE;gBACET,KAAK;gBACLI,aAAaA;gBACbC,cAAcA;YAChB,GACA,SACAT;QAEJ;IACF,GAAG;QAACM;KAAY;IAEhB,MAAMiB,QAAQ9B,QAAQ;QACpB,IAAImB,aAAa;YACf,OAAO;gBACLA;gBACAY,OAAOtB,KAAKS,KAAK,CAACa,KAAK;YACzB;QACF;QACA,OAAO;YACLA,OAAOtB,KAAKS,KAAK,CAACa,KAAK;QACzB;IACF,GAAG;QAACZ;KAAY;IAChB,qBACE,MAACtB;QAAgBS,WAAWA;;0BAC1B,MAAC0B;gBACC1B,WAAWJ,GAAGuB,kBAAkB;gBAC/B,GAAIJ,cAAc;oBAAE,iBAAiBA;gBAAW,CAAC;gBAClDY,KAAKvB;gBACLoB,OAAOA;;oBAENR,uBAAS,KAACU;kCAAKV;;oBAEfT,6BAAe,KAACV;wBAAY+B,SAASP;;;;YAEtCb,CAAAA,WAAWG,KAAI,mBACf,KAACe;gBACC1B,WAAU;gBACVwB,OAAO;oBAAEC,OAAOtB,KAAKS,KAAK,CAACa,KAAK;gBAAC;0BAEhCd,SAASH;;;;AAKpB,EAAC;AAED,eAAeT,2BAA0B"}
|