payload-richtext-tiptap 0.0.51 → 0.0.53
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/ImageBlock/ImageBlock.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js +29 -16
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts +5 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js +23 -2
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js +23 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.d.ts +17 -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 +47 -12
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts +10 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js +45 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualityOption.d.ts +12 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualityOption.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualityOption.js +34 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualityOption.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualitySelector.d.ts +22 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualitySelector.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualitySelector.js +78 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/components/QualitySelector.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.d.ts +10 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.js +10 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/events.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/index.d.ts +3 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/index.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/index.js +52 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/index.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/middleware/SourceInterceptor.d.ts +2 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/middleware/SourceInterceptor.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/middleware/SourceInterceptor.js +35 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/middleware/SourceInterceptor.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/util/SafeSeek.d.ts +16 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/util/SafeSeek.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/util/SafeSeek.js +72 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/quality-selector/util/SafeSeek.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js +5 -0
- package/dist/src/fields/TiptapEditor/features/BlockEditor/BlockEditor.js.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-draft-selector-commands.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js +3 -3
- package/dist/src/fields/TiptapEditor/features/menus/TextMenu/components/ai-selector-commands.js.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.d.ts +1 -0
- package/dist/src/fields/TiptapEditor/lib/extract.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/lib/extract.js +8 -1
- package/dist/src/fields/TiptapEditor/lib/extract.js.map +1 -1
- package/dist/src/fields/TiptapEditor/types.d.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/styles.css +63 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +196 -189
|
@@ -4,10 +4,12 @@ declare module "@tiptap/core" {
|
|
|
4
4
|
imageBlock: {
|
|
5
5
|
setImageBlock: (attributes: {
|
|
6
6
|
src: string;
|
|
7
|
+
assetId?: string;
|
|
7
8
|
}) => ReturnType;
|
|
8
9
|
setImageBlockAt: (attributes: {
|
|
9
10
|
src: string;
|
|
10
11
|
pos: number | Range;
|
|
12
|
+
assetId?: string;
|
|
11
13
|
}) => ReturnType;
|
|
12
14
|
setImageBlockAlign: (align: "left" | "center" | "right") => ReturnType;
|
|
13
15
|
setImageBlockWidth: (width: number) => ReturnType;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;
|
|
1
|
+
{"version":3,"file":"ImageBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;gBAC1B,GAAG,EAAE,MAAM,CAAC;gBACZ,OAAO,CAAC,EAAE,MAAM,CAAC;aAClB,KAAK,UAAU,CAAC;YACjB,eAAe,EAAE,CAAC,UAAU,EAAE;gBAC5B,GAAG,EAAE,MAAM,CAAC;gBACZ,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;gBACpB,OAAO,CAAC,EAAE,MAAM,CAAC;aAClB,KAAK,UAAU,CAAC;YACjB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,KAAK,UAAU,CAAC;YACvE,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;SACnD,CAAC;KACH;CACF;AAED,eAAO,MAAM,UAAU,mFA8FrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.ts"],"sourcesContent":["\"use client\";\n\nimport { ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { mergeAttributes, Range } from \"@tiptap/core\";\n\nimport { ImageBlockView } from \"./components/ImageBlockView.js\";\nimport { Image } from \"../Image/Image.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n imageBlock: {\n setImageBlock: (attributes: {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/ImageBlock.ts"],"sourcesContent":["\"use client\";\n\nimport { ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { mergeAttributes, Range } from \"@tiptap/core\";\n\nimport { ImageBlockView } from \"./components/ImageBlockView.js\";\nimport { Image } from \"../Image/Image.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n imageBlock: {\n setImageBlock: (attributes: {\n src: string;\n assetId?: string;\n }) => ReturnType;\n setImageBlockAt: (attributes: {\n src: string;\n pos: number | Range;\n assetId?: string;\n }) => ReturnType;\n setImageBlockAlign: (align: \"left\" | \"center\" | \"right\") => ReturnType;\n setImageBlockWidth: (width: number) => ReturnType;\n };\n }\n}\n\nexport const ImageBlock = Image.extend({\n name: \"imageBlock\",\n\n group: \"block\",\n\n defining: true,\n\n isolating: true,\n\n addAttributes() {\n return {\n src: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"src\"),\n renderHTML: (attributes) => ({\n src: attributes.src,\n }),\n },\n width: {\n default: \"100%\",\n parseHTML: (element) => element.getAttribute(\"data-width\"),\n renderHTML: (attributes) => ({\n \"data-width\": attributes.width,\n }),\n },\n align: {\n default: \"center\",\n parseHTML: (element) => element.getAttribute(\"data-align\"),\n renderHTML: (attributes) => ({\n \"data-align\": attributes.align,\n }),\n },\n alt: {\n default: undefined,\n parseHTML: (element) => element.getAttribute(\"alt\"),\n renderHTML: (attributes) => ({\n alt: attributes.alt,\n }),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'img[src*=\"tiptap.dev\"]:not([src^=\"data:\"]), img[src*=\"windows.net\"]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"img\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setImageBlock:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContent({\n type: \"imageBlock\",\n attrs: { src: attrs.src },\n });\n },\n\n setImageBlockAt:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContentAt(attrs.pos, {\n type: \"imageBlock\",\n attrs: { src: attrs.src },\n });\n },\n\n setImageBlockAlign:\n (align) =>\n ({ commands }) =>\n commands.updateAttributes(\"imageBlock\", { align }),\n\n setImageBlockWidth:\n (width) =>\n ({ commands }) =>\n commands.updateAttributes(\"imageBlock\", {\n width: `${Math.max(0, Math.min(100, width))}%`,\n }),\n };\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(ImageBlockView);\n },\n});\n\nexport default ImageBlock;\n"],"names":["ReactNodeViewRenderer","mergeAttributes","ImageBlockView","Image","ImageBlock","extend","name","group","defining","isolating","addAttributes","src","default","parseHTML","element","getAttribute","renderHTML","attributes","width","align","alt","undefined","tag","HTMLAttributes","options","addCommands","setImageBlock","attrs","commands","insertContent","type","setImageBlockAt","insertContentAt","pos","setImageBlockAlign","updateAttributes","setImageBlockWidth","Math","max","min","addNodeView"],"mappings":"AAAA;AAEA,SAASA,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,eAAe,QAAe,eAAe;AAEtD,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AAoB1C,OAAO,MAAMC,aAAaD,MAAME,MAAM,CAAC;IACrCC,MAAM;IAENC,OAAO;IAEPC,UAAU;IAEVC,WAAW;IAEXC;QACE,OAAO;YACLC,KAAK;gBACHC,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BN,KAAKM,WAAWN,GAAG;oBACrB,CAAA;YACF;YACAO,OAAO;gBACLN,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3B,cAAcA,WAAWC,KAAK;oBAChC,CAAA;YACF;YACAC,OAAO;gBACLP,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3B,cAAcA,WAAWE,KAAK;oBAChC,CAAA;YACF;YACAC,KAAK;gBACHR,SAASS;gBACTR,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BG,KAAKH,WAAWG,GAAG;oBACrB,CAAA;YACF;QACF;IACF;IAEAP;QACE,OAAO;YACL;gBACES,KAAK;YACP;SACD;IACH;IAEAN,YAAW,EAAEO,cAAc,EAAE;QAC3B,OAAO;YACL;YACAtB,gBAAgB,IAAI,CAACuB,OAAO,CAACD,cAAc,EAAEA;SAC9C;IACH;IAEAE;QACE,OAAO;YACLC,eACE,CAACC,QACD,CAAC,EAAEC,QAAQ,EAAE;oBACX,OAAOA,SAASC,aAAa,CAAC;wBAC5BC,MAAM;wBACNH,OAAO;4BAAEhB,KAAKgB,MAAMhB,GAAG;wBAAC;oBAC1B;gBACF;YAEFoB,iBACE,CAACJ,QACD,CAAC,EAAEC,QAAQ,EAAE;oBACX,OAAOA,SAASI,eAAe,CAACL,MAAMM,GAAG,EAAE;wBACzCH,MAAM;wBACNH,OAAO;4BAAEhB,KAAKgB,MAAMhB,GAAG;wBAAC;oBAC1B;gBACF;YAEFuB,oBACE,CAACf,QACD,CAAC,EAAES,QAAQ,EAAE,GACXA,SAASO,gBAAgB,CAAC,cAAc;wBAAEhB;oBAAM;YAEpDiB,oBACE,CAAClB,QACD,CAAC,EAAEU,QAAQ,EAAE,GACXA,SAASO,gBAAgB,CAAC,cAAc;wBACtCjB,OAAO,CAAC,EAAEmB,KAAKC,GAAG,CAAC,GAAGD,KAAKE,GAAG,CAAC,KAAKrB,QAAQ,CAAC,CAAC;oBAChD;QACN;IACF;IAEAsB;QACE,OAAOxC,sBAAsBE;IAC/B;AACF,GAAG;AAEH,eAAeE,WAAW"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAGxD,OAAO,EAEL,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAC1C,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,2BAIjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,gCAiEF,CAAC"}
|
|
@@ -1,28 +1,42 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
|
-
import {
|
|
3
|
+
import { ImagePlus } from "lucide-react";
|
|
4
|
+
import { useCallback, useState } from "react";
|
|
4
5
|
export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
5
6
|
const ImageUpload = ({ getPos, editor })=>{
|
|
7
|
+
const [done, setDone] = useState(false);
|
|
6
8
|
const onUpload = useCallback((asset)=>{
|
|
7
|
-
if (asset) {
|
|
9
|
+
if (asset && !done) {
|
|
8
10
|
console.log("asset in ImageUpload itself:", asset);
|
|
9
11
|
if (asset.type === "IMAGE") {
|
|
10
12
|
editor.chain().focus().setImageBlock({
|
|
11
|
-
src: asset.fullUrl
|
|
12
|
-
|
|
13
|
-
.deleteRange({
|
|
13
|
+
src: asset.fullUrl,
|
|
14
|
+
assetId: asset.id
|
|
15
|
+
}).deleteRange({
|
|
14
16
|
from: getPos(),
|
|
15
17
|
to: getPos()
|
|
16
18
|
}).focus().run();
|
|
19
|
+
setDone(true);
|
|
17
20
|
} else {
|
|
21
|
+
console.log("calling editor setVideoBlock.", {
|
|
22
|
+
src: asset.videoUrl,
|
|
23
|
+
poster: asset.fullUrl,
|
|
24
|
+
assetId: asset.id,
|
|
25
|
+
playlistUrl: asset.playlistUrl
|
|
26
|
+
});
|
|
18
27
|
editor.chain().focus().setVideoBlock({
|
|
19
28
|
src: asset.videoUrl,
|
|
20
|
-
poster: asset.fullUrl
|
|
29
|
+
poster: asset.fullUrl,
|
|
30
|
+
assetId: asset.id,
|
|
31
|
+
playlistUrl: asset.playlistUrl
|
|
21
32
|
}).deleteRange({
|
|
22
33
|
from: getPos(),
|
|
23
34
|
to: getPos()
|
|
24
35
|
}).focus().run();
|
|
36
|
+
setDone(true);
|
|
25
37
|
}
|
|
38
|
+
} else {
|
|
39
|
+
console.info("ImageUpload onUpload called but this is a finished component.");
|
|
26
40
|
}
|
|
27
41
|
}, [
|
|
28
42
|
getPos,
|
|
@@ -32,20 +46,19 @@ export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
|
32
46
|
children: /*#__PURE__*/ _jsx("div", {
|
|
33
47
|
className: "p-0 m-0",
|
|
34
48
|
"data-drag-handle": true,
|
|
35
|
-
children: /*#__PURE__*/
|
|
49
|
+
children: /*#__PURE__*/ _jsxs("a", {
|
|
36
50
|
href: "#",
|
|
37
|
-
|
|
38
|
-
padding: 5,
|
|
39
|
-
borderRadius: 5,
|
|
40
|
-
backgroundColor: "blue",
|
|
41
|
-
color: "white",
|
|
42
|
-
cursor: "pointer"
|
|
43
|
-
},
|
|
51
|
+
className: "text-black text-sm font-medium uppercase hover:cursor-pointer p-2.5 bg-white rounded-[7px] transition ease-in-out delay-150 hover:scale-110 hover:bg-amber-600 shadow justify-between items-center flex flex-row",
|
|
44
52
|
onClick: (e)=>{
|
|
45
53
|
e.preventDefault();
|
|
46
54
|
openAssetHQHandler(onUpload);
|
|
47
55
|
},
|
|
48
|
-
children:
|
|
56
|
+
children: [
|
|
57
|
+
/*#__PURE__*/ _jsx(ImagePlus, {
|
|
58
|
+
className: "mr-2"
|
|
59
|
+
}),
|
|
60
|
+
"Select an asset"
|
|
61
|
+
]
|
|
49
62
|
})
|
|
50
63
|
})
|
|
51
64
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { useCallback } from \"react\";\nimport {\n AssetReturnType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n }: {\n getPos: () => number;\n editor: Editor;\n }) => {\n const onUpload = useCallback(\n (asset: AssetReturnType) => {\n if (asset) {\n console.log(\"asset in ImageUpload itself:\", asset);\n if (asset.type === \"IMAGE\") {\n editor\n .chain()\n .focus()\n .setImageBlock({ src: asset.fullUrl
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["import { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport { ImagePlus } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport {\n AssetReturnType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n }: {\n getPos: () => number;\n editor: Editor;\n }) => {\n const [done, setDone] = useState(false);\n const onUpload = useCallback(\n (asset: AssetReturnType) => {\n if (asset && !done) {\n console.log(\"asset in ImageUpload itself:\", asset);\n if (asset.type === \"IMAGE\") {\n editor\n .chain()\n .focus()\n .setImageBlock({ src: asset.fullUrl, assetId: asset.id })\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n setDone(true);\n } else {\n console.log(\"calling editor setVideoBlock.\", {\n src: asset.videoUrl,\n poster: asset.fullUrl,\n assetId: asset.id,\n playlistUrl: asset.playlistUrl,\n });\n editor\n .chain()\n .focus()\n .setVideoBlock({\n src: asset.videoUrl,\n poster: asset.fullUrl,\n assetId: asset.id,\n playlistUrl: asset.playlistUrl,\n })\n .deleteRange({ from: getPos(), to: getPos() })\n .focus()\n .run();\n setDone(true);\n }\n } else {\n console.info(\n \"ImageUpload onUpload called but this is a finished component.\"\n );\n }\n },\n [getPos, editor]\n );\n\n return (\n <NodeViewWrapper>\n <div className=\"p-0 m-0\" data-drag-handle>\n <a\n href=\"#\"\n className=\"text-black text-sm font-medium uppercase hover:cursor-pointer p-2.5 bg-white rounded-[7px] transition ease-in-out delay-150 hover:scale-110 hover:bg-amber-600 shadow justify-between items-center flex flex-row\"\n onClick={(e) => {\n e.preventDefault();\n openAssetHQHandler(onUpload);\n }}\n >\n <ImagePlus className=\"mr-2\" />\n Select an asset\n </a>\n </div>\n </NodeViewWrapper>\n );\n };\n\n return ImageUpload;\n};\n"],"names":["NodeViewWrapper","ImagePlus","useCallback","useState","ImageUploadBuilder","openAssetHQHandler","ImageUpload","getPos","editor","done","setDone","onUpload","asset","console","log","type","chain","focus","setImageBlock","src","fullUrl","assetId","id","deleteRange","from","to","run","videoUrl","poster","playlistUrl","setVideoBlock","info","div","className","data-drag-handle","a","href","onClick","e","preventDefault"],"mappings":";AAAA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAK9C,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAc,CAAC,EACnBC,MAAM,EACNC,MAAM,EAIP;QACC,MAAM,CAACC,MAAMC,QAAQ,GAAGP,SAAS;QACjC,MAAMQ,WAAWT,YACf,CAACU;YACC,IAAIA,SAAS,CAACH,MAAM;gBAClBI,QAAQC,GAAG,CAAC,gCAAgCF;gBAC5C,IAAIA,MAAMG,IAAI,KAAK,SAAS;oBAC1BP,OACGQ,KAAK,GACLC,KAAK,GACLC,aAAa,CAAC;wBAAEC,KAAKP,MAAMQ,OAAO;wBAAEC,SAAST,MAAMU,EAAE;oBAAC,GACtDC,WAAW,CAAC;wBAAEC,MAAMjB;wBAAUkB,IAAIlB;oBAAS,GAC3CU,KAAK,GACLS,GAAG;oBACNhB,QAAQ;gBACV,OAAO;oBACLG,QAAQC,GAAG,CAAC,iCAAiC;wBAC3CK,KAAKP,MAAMe,QAAQ;wBACnBC,QAAQhB,MAAMQ,OAAO;wBACrBC,SAAST,MAAMU,EAAE;wBACjBO,aAAajB,MAAMiB,WAAW;oBAChC;oBACArB,OACGQ,KAAK,GACLC,KAAK,GACLa,aAAa,CAAC;wBACbX,KAAKP,MAAMe,QAAQ;wBACnBC,QAAQhB,MAAMQ,OAAO;wBACrBC,SAAST,MAAMU,EAAE;wBACjBO,aAAajB,MAAMiB,WAAW;oBAChC,GACCN,WAAW,CAAC;wBAAEC,MAAMjB;wBAAUkB,IAAIlB;oBAAS,GAC3CU,KAAK,GACLS,GAAG;oBACNhB,QAAQ;gBACV;YACF,OAAO;gBACLG,QAAQkB,IAAI,CACV;YAEJ;QACF,GACA;YAACxB;YAAQC;SAAO;QAGlB,qBACE,KAACR;sBACC,cAAA,KAACgC;gBAAIC,WAAU;gBAAUC,kBAAgB;0BACvC,cAAA,MAACC;oBACCC,MAAK;oBACLH,WAAU;oBACVI,SAAS,CAACC;wBACRA,EAAEC,cAAc;wBAChBlC,mBAAmBM;oBACrB;;sCAEA,KAACV;4BAAUgC,WAAU;;wBAAS;;;;;IAMxC;IAEA,OAAO3B;AACT,EAAE"}
|
|
@@ -5,14 +5,19 @@ declare module "@tiptap/core" {
|
|
|
5
5
|
setVideoBlock: (attributes: {
|
|
6
6
|
src: string;
|
|
7
7
|
poster: string;
|
|
8
|
+
assetId: string;
|
|
9
|
+
playlistUrl?: string;
|
|
8
10
|
}) => ReturnType;
|
|
9
11
|
setVideoBlockAt: (attributes: {
|
|
10
12
|
src: string;
|
|
11
13
|
poster: string;
|
|
14
|
+
assetId: string;
|
|
15
|
+
playlistUrl?: string;
|
|
12
16
|
pos: number | Range;
|
|
13
17
|
}) => ReturnType;
|
|
14
18
|
setVideoBlockAlign: (align: "left" | "center" | "right") => ReturnType;
|
|
15
19
|
setVideoBlockWidth: (width: number) => ReturnType;
|
|
20
|
+
setVideoBlockCaption: (caption: boolean) => ReturnType;
|
|
16
21
|
};
|
|
17
22
|
}
|
|
18
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;gBAC1B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoBlock.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,KAAK,EAAE,MAAM,cAAc,CAAC;AAKtD,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,UAAU,EAAE;YACV,aAAa,EAAE,CAAC,UAAU,EAAE;gBAC1B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,OAAO,EAAE,MAAM,CAAC;gBAChB,WAAW,CAAC,EAAE,MAAM,CAAC;aACtB,KAAK,UAAU,CAAC;YACjB,eAAe,EAAE,CAAC,UAAU,EAAE;gBAC5B,GAAG,EAAE,MAAM,CAAC;gBACZ,MAAM,EAAE,MAAM,CAAC;gBACf,OAAO,EAAE,MAAM,CAAC;gBAChB,WAAW,CAAC,EAAE,MAAM,CAAC;gBAErB,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;aACrB,KAAK,UAAU,CAAC;YACjB,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,KAAK,UAAU,CAAC;YACvE,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,UAAU,CAAC;YAClD,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,UAAU,CAAC;SACxD,CAAC;KACH;CACF;AAED,eAAO,MAAM,UAAU,6EAkIrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -24,6 +24,13 @@ export const VideoBlock = Video.extend({
|
|
|
24
24
|
poster: attributes.poster
|
|
25
25
|
})
|
|
26
26
|
},
|
|
27
|
+
playlistUrl: {
|
|
28
|
+
default: "",
|
|
29
|
+
parseHTML: (element)=>element.getAttribute("data-playlist-url"),
|
|
30
|
+
renderHTML: (attributes)=>({
|
|
31
|
+
"data-playlist-url": attributes.playlistUrl
|
|
32
|
+
})
|
|
33
|
+
},
|
|
27
34
|
width: {
|
|
28
35
|
default: "100%",
|
|
29
36
|
parseHTML: (element)=>element.getAttribute("data-width"),
|
|
@@ -44,6 +51,13 @@ export const VideoBlock = Video.extend({
|
|
|
44
51
|
renderHTML: (attributes)=>({
|
|
45
52
|
alt: attributes.alt
|
|
46
53
|
})
|
|
54
|
+
},
|
|
55
|
+
caption: {
|
|
56
|
+
default: true,
|
|
57
|
+
parseHTML: (element)=>element.getAttribute("data-caption") === "true",
|
|
58
|
+
renderHTML: (attributes)=>({
|
|
59
|
+
"data-caption": attributes.caption
|
|
60
|
+
})
|
|
47
61
|
}
|
|
48
62
|
};
|
|
49
63
|
},
|
|
@@ -67,7 +81,9 @@ export const VideoBlock = Video.extend({
|
|
|
67
81
|
type: "videoBlock",
|
|
68
82
|
attrs: {
|
|
69
83
|
src: attrs.src,
|
|
70
|
-
poster: attrs.poster
|
|
84
|
+
poster: attrs.poster,
|
|
85
|
+
assetId: attrs.assetId,
|
|
86
|
+
playlistUrl: attrs.playlistUrl
|
|
71
87
|
}
|
|
72
88
|
});
|
|
73
89
|
},
|
|
@@ -76,7 +92,9 @@ export const VideoBlock = Video.extend({
|
|
|
76
92
|
type: "videoBlock",
|
|
77
93
|
attrs: {
|
|
78
94
|
src: attrs.src,
|
|
79
|
-
poster: attrs.poster
|
|
95
|
+
poster: attrs.poster,
|
|
96
|
+
assetId: attrs.assetId,
|
|
97
|
+
playlistUrl: attrs.playlistUrl
|
|
80
98
|
}
|
|
81
99
|
});
|
|
82
100
|
},
|
|
@@ -85,6 +103,9 @@ export const VideoBlock = Video.extend({
|
|
|
85
103
|
}),
|
|
86
104
|
setVideoBlockWidth: (width)=>({ commands })=>commands.updateAttributes("videoBlock", {
|
|
87
105
|
width: `${Math.max(0, Math.min(100, width))}%`
|
|
106
|
+
}),
|
|
107
|
+
setVideoBlockCaption: (caption)=>({ commands })=>commands.updateAttributes("videoBlock", {
|
|
108
|
+
caption
|
|
88
109
|
})
|
|
89
110
|
};
|
|
90
111
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"sourcesContent":["\"use client\";\n\nimport { ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { mergeAttributes, Range } from \"@tiptap/core\";\n\nimport { VideoBlockView } from \"./components/VideoBlockView.js\";\nimport { Video } from \"../Video/Video.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n videoBlock: {\n setVideoBlock: (attributes: {\n src: string;\n poster: string;\n }) => ReturnType;\n setVideoBlockAt: (attributes: {\n src: string;\n poster: string;\n pos: number | Range;\n }) => ReturnType;\n setVideoBlockAlign: (align: \"left\" | \"center\" | \"right\") => ReturnType;\n setVideoBlockWidth: (width: number) => ReturnType;\n };\n }\n}\n\nexport const VideoBlock = Video.extend({\n name: \"videoBlock\",\n\n group: \"block\",\n\n defining: true,\n\n isolating: true,\n\n addAttributes() {\n return {\n src: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"src\"),\n renderHTML: (attributes) => ({\n src: attributes.src,\n }),\n },\n poster: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"poster\"),\n renderHTML: (attributes) => ({\n poster: attributes.poster,\n }),\n },\n width: {\n default: \"100%\",\n parseHTML: (element) => element.getAttribute(\"data-width\"),\n renderHTML: (attributes) => ({\n \"data-width\": attributes.width,\n }),\n },\n align: {\n default: \"center\",\n parseHTML: (element) => element.getAttribute(\"data-align\"),\n renderHTML: (attributes) => ({\n \"data-align\": attributes.align,\n }),\n },\n alt: {\n default: undefined,\n parseHTML: (element) => element.getAttribute(\"alt\"),\n renderHTML: (attributes) => ({\n alt: attributes.alt,\n }),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'video[src*=\"tiptap.dev\"]:not([src^=\"data:\"]), video[src*=\"windows.net\"]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"video\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setVideoBlock:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContent({\n type: \"videoBlock\",\n attrs: {
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.ts"],"sourcesContent":["\"use client\";\n\nimport { ReactNodeViewRenderer } from \"@tiptap/react\";\nimport { mergeAttributes, Range } from \"@tiptap/core\";\n\nimport { VideoBlockView } from \"./components/VideoBlockView.js\";\nimport { Video } from \"../Video/Video.js\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n videoBlock: {\n setVideoBlock: (attributes: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n }) => ReturnType;\n setVideoBlockAt: (attributes: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n\n pos: number | Range;\n }) => ReturnType;\n setVideoBlockAlign: (align: \"left\" | \"center\" | \"right\") => ReturnType;\n setVideoBlockWidth: (width: number) => ReturnType;\n setVideoBlockCaption: (caption: boolean) => ReturnType;\n };\n }\n}\n\nexport const VideoBlock = Video.extend({\n name: \"videoBlock\",\n\n group: \"block\",\n\n defining: true,\n\n isolating: true,\n\n addAttributes() {\n return {\n src: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"src\"),\n renderHTML: (attributes) => ({\n src: attributes.src,\n }),\n },\n poster: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"poster\"),\n renderHTML: (attributes) => ({\n poster: attributes.poster,\n }),\n },\n playlistUrl: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"data-playlist-url\"),\n renderHTML: (attributes) => ({\n \"data-playlist-url\": attributes.playlistUrl,\n }),\n },\n width: {\n default: \"100%\",\n parseHTML: (element) => element.getAttribute(\"data-width\"),\n renderHTML: (attributes) => ({\n \"data-width\": attributes.width,\n }),\n },\n align: {\n default: \"center\",\n parseHTML: (element) => element.getAttribute(\"data-align\"),\n renderHTML: (attributes) => ({\n \"data-align\": attributes.align,\n }),\n },\n alt: {\n default: undefined,\n parseHTML: (element) => element.getAttribute(\"alt\"),\n renderHTML: (attributes) => ({\n alt: attributes.alt,\n }),\n },\n caption: {\n default: true,\n parseHTML: (element) => element.getAttribute(\"data-caption\") === \"true\",\n renderHTML: (attributes) => ({\n \"data-caption\": attributes.caption,\n }),\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'video[src*=\"tiptap.dev\"]:not([src^=\"data:\"]), video[src*=\"windows.net\"]:not([src^=\"data:\"])',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"video\",\n mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n ];\n },\n\n addCommands() {\n return {\n setVideoBlock:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContent({\n type: \"videoBlock\",\n attrs: {\n src: attrs.src,\n poster: attrs.poster,\n assetId: attrs.assetId,\n playlistUrl: attrs.playlistUrl,\n },\n });\n },\n\n setVideoBlockAt:\n (attrs) =>\n ({ commands }) => {\n return commands.insertContentAt(attrs.pos, {\n type: \"videoBlock\",\n attrs: {\n src: attrs.src,\n poster: attrs.poster,\n assetId: attrs.assetId,\n playlistUrl: attrs.playlistUrl,\n },\n });\n },\n\n setVideoBlockAlign:\n (align) =>\n ({ commands }) =>\n commands.updateAttributes(\"videoBlock\", { align }),\n\n setVideoBlockWidth:\n (width) =>\n ({ commands }) =>\n commands.updateAttributes(\"videoBlock\", {\n width: `${Math.max(0, Math.min(100, width))}%`,\n }),\n\n setVideoBlockCaption:\n (caption) =>\n ({ commands }) =>\n commands.updateAttributes(\"videoBlock\", { caption }),\n };\n },\n\n addNodeView() {\n return ReactNodeViewRenderer(VideoBlockView);\n },\n});\n\nexport default VideoBlock;\n"],"names":["ReactNodeViewRenderer","mergeAttributes","VideoBlockView","Video","VideoBlock","extend","name","group","defining","isolating","addAttributes","src","default","parseHTML","element","getAttribute","renderHTML","attributes","poster","playlistUrl","width","align","alt","undefined","caption","tag","HTMLAttributes","options","addCommands","setVideoBlock","attrs","commands","insertContent","type","assetId","setVideoBlockAt","insertContentAt","pos","setVideoBlockAlign","updateAttributes","setVideoBlockWidth","Math","max","min","setVideoBlockCaption","addNodeView"],"mappings":"AAAA;AAEA,SAASA,qBAAqB,QAAQ,gBAAgB;AACtD,SAASC,eAAe,QAAe,eAAe;AAEtD,SAASC,cAAc,QAAQ,iCAAiC;AAChE,SAASC,KAAK,QAAQ,oBAAoB;AA0B1C,OAAO,MAAMC,aAAaD,MAAME,MAAM,CAAC;IACrCC,MAAM;IAENC,OAAO;IAEPC,UAAU;IAEVC,WAAW;IAEXC;QACE,OAAO;YACLC,KAAK;gBACHC,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BN,KAAKM,WAAWN,GAAG;oBACrB,CAAA;YACF;YACAO,QAAQ;gBACNN,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BC,QAAQD,WAAWC,MAAM;oBAC3B,CAAA;YACF;YACAC,aAAa;gBACXP,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3B,qBAAqBA,WAAWE,WAAW;oBAC7C,CAAA;YACF;YACAC,OAAO;gBACLR,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA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AEFmB,oBACE,CAACjB,QACD,CAAC,EAAEU,QAAQ,EAAE,GACXA,SAASQ,gBAAgB,CAAC,cAAc;wBAAElB;oBAAM;YAEpDmB,oBACE,CAACpB,QACD,CAAC,EAAEW,QAAQ,EAAE,GACXA,SAASQ,gBAAgB,CAAC,cAAc;wBACtCnB,OAAO,CAAC,EAAEqB,KAAKC,GAAG,CAAC,GAAGD,KAAKE,GAAG,CAAC,KAAKvB,QAAQ,CAAC,CAAC;oBAChD;YAEJwB,sBACE,CAACpB,UACD,CAAC,EAAEO,QAAQ,EAAE,GACXA,SAASQ,gBAAgB,CAAC,cAAc;wBAAEf;oBAAQ;QACxD;IACF;IAEAqB;QACE,OAAO7C,sBAAsBE;IAC/B;AACF,GAAG;AAEH,eAAeE,WAAW"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VideoBlockMenu.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"VideoBlockMenu.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAuB,MAAM,OAAO,CAAC;AAWvD,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAM7D,eAAO,MAAM,cAAc,yBAA0B,SAAS,KAAG,SAqIhE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { BubbleMenu as BaseBubbleMenu } from "@tiptap/react";
|
|
|
3
3
|
import { useCallback, useRef } from "react";
|
|
4
4
|
import { sticky } from "tippy.js";
|
|
5
5
|
import { v4 as uuid } from "uuid";
|
|
6
|
-
import { AlignHorizontalDistributeCenter, AlignHorizontalDistributeEnd, AlignHorizontalDistributeStart } from "lucide-react";
|
|
6
|
+
import { AlignHorizontalDistributeCenter, AlignHorizontalDistributeEnd, AlignHorizontalDistributeStart, Pencil, PencilOff } from "lucide-react";
|
|
7
7
|
import { Icon } from "../../../features/ui/Icon.js";
|
|
8
8
|
import { Toolbar } from "../../../features/ui/Toolbar.js";
|
|
9
9
|
import { getRenderContainer } from "../../../lib/utils/index.js";
|
|
@@ -45,6 +45,15 @@ export const VideoBlockMenu = ({ editor, appendTo })=>{
|
|
|
45
45
|
}, [
|
|
46
46
|
editor
|
|
47
47
|
]);
|
|
48
|
+
const onHideCaption = useCallback(()=>{
|
|
49
|
+
editor.chain().focus(undefined, {
|
|
50
|
+
scrollIntoView: false
|
|
51
|
+
}).setVideoBlockCaption(editor.isActive("videoBlock", {
|
|
52
|
+
caption: false
|
|
53
|
+
}) ? true : false).run();
|
|
54
|
+
}, [
|
|
55
|
+
editor
|
|
56
|
+
]);
|
|
48
57
|
const onWidthChange = useCallback((value)=>{
|
|
49
58
|
editor.chain().focus(undefined, {
|
|
50
59
|
scrollIntoView: false
|
|
@@ -86,6 +95,19 @@ export const VideoBlockMenu = ({ editor, appendTo })=>{
|
|
|
86
95
|
shouldShowContent: shouldShow(),
|
|
87
96
|
ref: menuRef,
|
|
88
97
|
children: [
|
|
98
|
+
/*#__PURE__*/ _jsx(Toolbar.Button, {
|
|
99
|
+
type: "button",
|
|
100
|
+
tooltip: "Hide/Show caption",
|
|
101
|
+
active: editor.isActive("videoBlock", {
|
|
102
|
+
caption: false
|
|
103
|
+
}),
|
|
104
|
+
onClick: onHideCaption,
|
|
105
|
+
children: /*#__PURE__*/ _jsx(Icon, {
|
|
106
|
+
icon: editor.isActive("videoBlock", {
|
|
107
|
+
caption: false
|
|
108
|
+
}) ? PencilOff : Pencil
|
|
109
|
+
})
|
|
110
|
+
}),
|
|
89
111
|
/*#__PURE__*/ _jsx(Toolbar.Button, {
|
|
90
112
|
type: "button",
|
|
91
113
|
tooltip: "Align video left",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { ReactNode, useCallback, useRef } from \"react\";\nimport { Instance, sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n AlignHorizontalDistributeCenter,\n AlignHorizontalDistributeEnd,\n AlignHorizontalDistributeStart,\n} from \"lucide-react\";\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Icon } from \"../../../features/ui/Icon.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport { getRenderContainer } from \"../../../lib/utils/index.js\";\nimport { VideoBlockWidth } from \"./VideoBlockWidth.js\";\n\nexport const VideoBlockMenu = ({ editor, appendTo }: MenuProps): ReactNode => {\n const menuRef = useRef<HTMLDivElement>(null);\n const tippyInstance = useRef<Instance | null>(null);\n\n const getReferenceClientRect = useCallback(() => {\n const renderContainer = getRenderContainer(editor, \"node-videoBlock\");\n const rect =\n renderContainer?.getBoundingClientRect() ||\n new DOMRect(-1000, -1000, 0, 0);\n\n return rect;\n }, [editor]);\n\n const shouldShow = useCallback(() => {\n const isActive = editor.isActive(\"videoBlock\");\n\n return isActive;\n }, [editor]);\n\n const onAlignVideoLeft = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"left\")\n .run();\n }, [editor]);\n\n const onAlignVideoCenter = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"center\")\n .run();\n }, [editor]);\n\n const onAlignVideoRight = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"right\")\n .run();\n }, [editor]);\n\n const onWidthChange = useCallback(\n (value: number) => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockWidth(value)\n .run();\n },\n [editor]\n );\n\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey={`videoBlockMenu-${uuid()}`}\n shouldShow={shouldShow}\n updateDelay={0}\n tippyOptions={{\n offset: [0, 8],\n popperOptions: {\n modifiers: [{ name: \"flip\", enabled: false }],\n },\n getReferenceClientRect,\n onCreate: (instance: Instance) => {\n tippyInstance.current = instance;\n },\n appendTo: () => {\n return appendTo?.current;\n },\n plugins: [sticky],\n sticky: \"popper\",\n }}\n >\n <Toolbar.Wrapper shouldShowContent={shouldShow()} ref={menuRef}>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video left\"\n active={editor.isActive(\"videoBlock\", { align: \"left\" })}\n onClick={onAlignVideoLeft}\n >\n <Icon icon={AlignHorizontalDistributeStart} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video center\"\n active={editor.isActive(\"videoBlock\", { align: \"center\" })}\n onClick={onAlignVideoCenter}\n >\n <Icon icon={AlignHorizontalDistributeCenter} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video right\"\n active={editor.isActive(\"videoBlock\", { align: \"right\" })}\n onClick={onAlignVideoRight}\n >\n <Icon icon={AlignHorizontalDistributeEnd} />\n </Toolbar.Button>\n <Toolbar.Divider />\n <VideoBlockWidth\n onChange={onWidthChange}\n value={parseInt(editor.getAttributes(\"videoBlock\").width)}\n />\n </Toolbar.Wrapper>\n </BaseBubbleMenu>\n );\n};\n\nexport default VideoBlockMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","useCallback","useRef","sticky","v4","uuid","AlignHorizontalDistributeCenter","AlignHorizontalDistributeEnd","AlignHorizontalDistributeStart","Icon","Toolbar","getRenderContainer","VideoBlockWidth","VideoBlockMenu","editor","appendTo","menuRef","tippyInstance","getReferenceClientRect","renderContainer","rect","getBoundingClientRect","DOMRect","shouldShow","isActive","onAlignVideoLeft","chain","focus","undefined","scrollIntoView","setVideoBlockAlign","run","onAlignVideoCenter","onAlignVideoRight","onWidthChange","value","setVideoBlockWidth","pluginKey","updateDelay","tippyOptions","offset","popperOptions","modifiers","name","enabled","onCreate","instance","current","plugins","Wrapper","shouldShowContent","ref","Button","type","tooltip","active","
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport { ReactNode, useCallback, useRef } from \"react\";\nimport { Instance, sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport {\n AlignHorizontalDistributeCenter,\n AlignHorizontalDistributeEnd,\n AlignHorizontalDistributeStart,\n Pencil,\n PencilOff,\n} from \"lucide-react\";\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Icon } from \"../../../features/ui/Icon.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport { getRenderContainer } from \"../../../lib/utils/index.js\";\nimport { VideoBlockWidth } from \"./VideoBlockWidth.js\";\n\nexport const VideoBlockMenu = ({ editor, appendTo }: MenuProps): ReactNode => {\n const menuRef = useRef<HTMLDivElement>(null);\n const tippyInstance = useRef<Instance | null>(null);\n\n const getReferenceClientRect = useCallback(() => {\n const renderContainer = getRenderContainer(editor, \"node-videoBlock\");\n const rect =\n renderContainer?.getBoundingClientRect() ||\n new DOMRect(-1000, -1000, 0, 0);\n\n return rect;\n }, [editor]);\n\n const shouldShow = useCallback(() => {\n const isActive = editor.isActive(\"videoBlock\");\n\n return isActive;\n }, [editor]);\n\n const onAlignVideoLeft = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"left\")\n .run();\n }, [editor]);\n\n const onAlignVideoCenter = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"center\")\n .run();\n }, [editor]);\n\n const onAlignVideoRight = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockAlign(\"right\")\n .run();\n }, [editor]);\n\n const onHideCaption = useCallback(() => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockCaption(\n editor.isActive(\"videoBlock\", { caption: false }) ? true : false\n )\n .run();\n }, [editor]);\n\n const onWidthChange = useCallback(\n (value: number) => {\n editor\n .chain()\n .focus(undefined, { scrollIntoView: false })\n .setVideoBlockWidth(value)\n .run();\n },\n [editor]\n );\n\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey={`videoBlockMenu-${uuid()}`}\n shouldShow={shouldShow}\n updateDelay={0}\n tippyOptions={{\n offset: [0, 8],\n popperOptions: {\n modifiers: [{ name: \"flip\", enabled: false }],\n },\n getReferenceClientRect,\n onCreate: (instance: Instance) => {\n tippyInstance.current = instance;\n },\n appendTo: () => {\n return appendTo?.current;\n },\n plugins: [sticky],\n sticky: \"popper\",\n }}\n >\n <Toolbar.Wrapper shouldShowContent={shouldShow()} ref={menuRef}>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Hide/Show caption\"\n active={editor.isActive(\"videoBlock\", { caption: false })}\n onClick={onHideCaption}\n >\n <Icon\n icon={\n editor.isActive(\"videoBlock\", { caption: false })\n ? PencilOff\n : Pencil\n }\n />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video left\"\n active={editor.isActive(\"videoBlock\", { align: \"left\" })}\n onClick={onAlignVideoLeft}\n >\n <Icon icon={AlignHorizontalDistributeStart} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video center\"\n active={editor.isActive(\"videoBlock\", { align: \"center\" })}\n onClick={onAlignVideoCenter}\n >\n <Icon icon={AlignHorizontalDistributeCenter} />\n </Toolbar.Button>\n <Toolbar.Button\n type=\"button\"\n tooltip=\"Align video right\"\n active={editor.isActive(\"videoBlock\", { align: \"right\" })}\n onClick={onAlignVideoRight}\n >\n <Icon icon={AlignHorizontalDistributeEnd} />\n </Toolbar.Button>\n <Toolbar.Divider />\n <VideoBlockWidth\n onChange={onWidthChange}\n value={parseInt(editor.getAttributes(\"videoBlock\").width)}\n />\n </Toolbar.Wrapper>\n </BaseBubbleMenu>\n );\n};\n\nexport default VideoBlockMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","useCallback","useRef","sticky","v4","uuid","AlignHorizontalDistributeCenter","AlignHorizontalDistributeEnd","AlignHorizontalDistributeStart","Pencil","PencilOff","Icon","Toolbar","getRenderContainer","VideoBlockWidth","VideoBlockMenu","editor","appendTo","menuRef","tippyInstance","getReferenceClientRect","renderContainer","rect","getBoundingClientRect","DOMRect","shouldShow","isActive","onAlignVideoLeft","chain","focus","undefined","scrollIntoView","setVideoBlockAlign","run","onAlignVideoCenter","onAlignVideoRight","onHideCaption","setVideoBlockCaption","caption","onWidthChange","value","setVideoBlockWidth","pluginKey","updateDelay","tippyOptions","offset","popperOptions","modifiers","name","enabled","onCreate","instance","current","plugins","Wrapper","shouldShowContent","ref","Button","type","tooltip","active","onClick","icon","align","Divider","onChange","parseInt","getAttributes","width"],"mappings":";AAAA,SAASA,cAAcC,cAAc,QAAQ,gBAAgB;AAC7D,SAAoBC,WAAW,EAAEC,MAAM,QAAQ,QAAQ;AACvD,SAAmBC,MAAM,QAAQ,WAAW;AAC5C,SAASC,MAAMC,IAAI,QAAQ,OAAO;AAElC,SACEC,+BAA+B,EAC/BC,4BAA4B,EAC5BC,8BAA8B,EAC9BC,MAAM,EACNC,SAAS,QACJ,eAAe;AAEtB,SAASC,IAAI,QAAQ,+BAA+B;AACpD,SAASC,OAAO,QAAQ,kCAAkC;AAC1D,SAASC,kBAAkB,QAAQ,8BAA8B;AACjE,SAASC,eAAe,QAAQ,uBAAuB;AAEvD,OAAO,MAAMC,iBAAiB,CAAC,EAAEC,MAAM,EAAEC,QAAQ,EAAa;IAC5D,MAAMC,UAAUhB,OAAuB;IACvC,MA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AAO0B,SAASlD,OAAOmD,aAAa,CAAC,cAAcC,KAAK;;;;;AAKlE,EAAE;AAEF,eAAerD,eAAe"}
|
|
@@ -7,10 +7,27 @@ interface VideoBlockViewProps {
|
|
|
7
7
|
node: Node & {
|
|
8
8
|
attrs: {
|
|
9
9
|
src: string;
|
|
10
|
+
poster: string;
|
|
11
|
+
assetId: string;
|
|
12
|
+
playlistUrl?: string;
|
|
10
13
|
};
|
|
11
14
|
};
|
|
12
15
|
updateAttributes: (attrs: Record<string, string>) => void;
|
|
13
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
|
+
};
|
|
14
31
|
export declare const VideoBlockView: (props: VideoBlockViewProps) => React.JSX.Element;
|
|
15
32
|
export default VideoBlockView;
|
|
16
33
|
//# sourceMappingURL=VideoBlockView.d.ts.map
|
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,CAAC;AACxC,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AACxD,OAAO,
|
|
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,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,cAAc,UAAW,mBAAmB,sBAsExD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { NodeViewWrapper } from "@tiptap/react";
|
|
3
|
-
import React, { useCallback, useRef } from "react";
|
|
3
|
+
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { cn } from "../../../lib/utils/index.js";
|
|
5
|
+
import VideoPlayer from "./videojs/VideoPlayer.js";
|
|
5
6
|
export const VideoBlockView = (props)=>{
|
|
6
7
|
const { editor, getPos, node } = props;
|
|
7
8
|
const videoWrapperRef = useRef(null);
|
|
8
|
-
const { src, poster } = node.attrs;
|
|
9
|
+
const { src, poster, playlistUrl, caption } = node.attrs;
|
|
10
|
+
const [playlistContent, setPlaylistContent] = React.useState();
|
|
11
|
+
const [error, setError] = React.useState();
|
|
12
|
+
useEffect(()=>{
|
|
13
|
+
async function getPlaylistContent() {
|
|
14
|
+
const res = await fetch(playlistUrl);
|
|
15
|
+
return await res.json();
|
|
16
|
+
}
|
|
17
|
+
if (playlistUrl) {
|
|
18
|
+
getPlaylistContent().then((data)=>{
|
|
19
|
+
setPlaylistContent(data);
|
|
20
|
+
}).catch((err)=>{
|
|
21
|
+
setError(err);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}, [
|
|
25
|
+
playlistUrl
|
|
26
|
+
]);
|
|
9
27
|
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");
|
|
10
28
|
const onClick = useCallback(()=>{
|
|
11
29
|
editor.commands.setNodeSelection(getPos());
|
|
@@ -13,23 +31,40 @@ export const VideoBlockView = (props)=>{
|
|
|
13
31
|
getPos,
|
|
14
32
|
editor.commands
|
|
15
33
|
]);
|
|
34
|
+
const videoJsOptions = useMemo(()=>{
|
|
35
|
+
if (playlistContent == undefined) return {};
|
|
36
|
+
return {
|
|
37
|
+
sources: playlistContent.items.map((item)=>({
|
|
38
|
+
src: item.src,
|
|
39
|
+
type: item.type,
|
|
40
|
+
label: item.label
|
|
41
|
+
})),
|
|
42
|
+
poster: playlistContent.poster
|
|
43
|
+
};
|
|
44
|
+
}, [
|
|
45
|
+
playlistContent
|
|
46
|
+
]);
|
|
16
47
|
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
17
48
|
children: /*#__PURE__*/ _jsx("div", {
|
|
18
49
|
className: wrapperClassName,
|
|
19
50
|
style: {
|
|
20
51
|
width: node.attrs.width
|
|
21
52
|
},
|
|
22
|
-
children: /*#__PURE__*/
|
|
53
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
23
54
|
contentEditable: false,
|
|
24
55
|
ref: videoWrapperRef,
|
|
25
|
-
children:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
56
|
+
children: [
|
|
57
|
+
error && /*#__PURE__*/ _jsx("div", {
|
|
58
|
+
children: error
|
|
59
|
+
}),
|
|
60
|
+
playlistContent && /*#__PURE__*/ _jsx(VideoPlayer, {
|
|
61
|
+
options: videoJsOptions
|
|
62
|
+
}),
|
|
63
|
+
caption && playlistContent?.title && /*#__PURE__*/ _jsx("caption", {
|
|
64
|
+
className: "text-center block text-sm text-gray-500",
|
|
65
|
+
children: playlistContent?.title
|
|
66
|
+
})
|
|
67
|
+
]
|
|
33
68
|
})
|
|
34
69
|
})
|
|
35
70
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.tsx"],"sourcesContent":["import { Node } from \"@tiptap/pm/model\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport React, { useCallback, useRef } from \"react\";\nimport { cn } from \"../../../lib/utils/index.js\";\n\ninterface VideoBlockViewProps {\n editor: Editor;\n getPos: () => number;\n node: Node & {\n attrs: {\n src: string;\n };\n };\n updateAttributes: (attrs: Record<string, string>) => void;\n}\n\nexport const VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster } = node.attrs;\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 return (\n <NodeViewWrapper>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div contentEditable={false} ref={videoWrapperRef}>\n <video\n controls\n className=\"block\"\n src={src}\n poster={poster}\n title=\"\"\n onClick={onClick}\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockView.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 VideoBlockView = (props: VideoBlockViewProps) => {\n const { editor, getPos, node } = props;\n const videoWrapperRef = useRef<HTMLDivElement>(null);\n const { src, poster, playlistUrl, caption } = 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 const res = await fetch(playlistUrl);\n return await res.json();\n }\n\n if (playlistUrl) {\n getPlaylistContent()\n .then((data) => {\n setPlaylistContent(data);\n })\n .catch((err) => {\n setError(err);\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 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 contentEditable={false} 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 {playlistContent?.title}\n </caption>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockView;\n"],"names":["NodeViewWrapper","React","useCallback","useEffect","useMemo","useRef","cn","VideoPlayer","VideoBlockView","props","editor","getPos","node","videoWrapperRef","src","poster","playlistUrl","caption","attrs","playlistContent","setPlaylistContent","useState","error","setError","getPlaylistContent","res","fetch","json","then","data","catch","err","wrapperClassName","align","onClick","commands","setNodeSelection","videoJsOptions","undefined","sources","items","map","item","type","label","div","className","style","width","contentEditable","ref","options","title"],"mappings":";AACA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,OAAOC,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AACvE,SAASC,EAAE,QAAQ,8BAA8B;AACjD,OAAOC,iBAAiB,2BAA2B;AAgCnD,OAAO,MAAMC,iBAAiB,CAACC;IAC7B,MAAM,EAAEC,MAAM,EAAEC,MAAM,EAAEC,IAAI,EAAE,GAAGH;IACjC,MAAMI,kBAAkBR,OAAuB;IAC/C,MAAM,EAAES,GAAG,EAAEC,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAAGL,KAAKM,KAAK;IACxD,MAAM,CAACC,iBAAiB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B,KAACnC;wBAAQ6B,WAAU;kCAChB3B,iBAAiBiC;;;;;;AAOhC,EAAE;AAEF,eAAe5C,eAAe"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { VideoJsPlayerOptions } from "video.js/dist/video.js";
|
|
3
|
+
import "video.js/dist/video-js.css";
|
|
4
|
+
import "video.js/dist/video-js.css";
|
|
5
|
+
interface IVideoPlayerProps {
|
|
6
|
+
options: VideoJsPlayerOptions;
|
|
7
|
+
}
|
|
8
|
+
declare const VideoPlayer: React.FC<IVideoPlayerProps>;
|
|
9
|
+
export default VideoPlayer;
|
|
10
|
+
//# sourceMappingURL=VideoPlayer.d.ts.map
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAgB,EAEd,oBAAoB,EACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,4BAA4B,CAAC;AAGpC,OAAO,4BAA4B,CAAC;AAIpC,UAAU,iBAAiB;IACzB,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAYD,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA2B5C,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import videojs from "video.js/dist/video.js";
|
|
4
|
+
import "video.js/dist/video-js.css";
|
|
5
|
+
// Styles
|
|
6
|
+
import "video.js/dist/video-js.css";
|
|
7
|
+
import { QualitySelector } from "./quality-selector/index.js";
|
|
8
|
+
const initialOptions = {
|
|
9
|
+
controls: true,
|
|
10
|
+
fluid: true,
|
|
11
|
+
controlBar: {
|
|
12
|
+
volumePanel: {
|
|
13
|
+
inline: false
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const VideoPlayer = ({ options })=>{
|
|
18
|
+
const videoNode = React.useRef(null);
|
|
19
|
+
const player = React.useRef(null);
|
|
20
|
+
React.useEffect(()=>{
|
|
21
|
+
QualitySelector(videojs);
|
|
22
|
+
player.current = videojs(videoNode.current, {
|
|
23
|
+
...initialOptions,
|
|
24
|
+
...options
|
|
25
|
+
}).ready(function() {
|
|
26
|
+
if (!this.controlBar.children().some((c)=>c.name_ === "QualitySelector")) {
|
|
27
|
+
this.controlBar.addChild("QualitySelector");
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return ()=>{
|
|
31
|
+
if (player.current) {
|
|
32
|
+
player.current.dispose();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}, [
|
|
36
|
+
options
|
|
37
|
+
]);
|
|
38
|
+
return /*#__PURE__*/ _jsx("video", {
|
|
39
|
+
ref: videoNode,
|
|
40
|
+
className: "video-js"
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export default VideoPlayer;
|
|
44
|
+
|
|
45
|
+
//# sourceMappingURL=VideoPlayer.js.map
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.tsx"],"sourcesContent":["import React from \"react\";\nimport videojs, {\n VideoJsPlayer,\n VideoJsPlayerOptions,\n} from \"video.js/dist/video.js\";\nimport \"video.js/dist/video-js.css\";\n\n// Styles\nimport \"video.js/dist/video-js.css\";\n\nimport { QualitySelector } from \"./quality-selector/index.js\";\n\ninterface IVideoPlayerProps {\n options: VideoJsPlayerOptions;\n}\n\nconst initialOptions: VideoJsPlayerOptions = {\n controls: true,\n fluid: true,\n controlBar: {\n volumePanel: {\n inline: false,\n },\n },\n};\n\nconst VideoPlayer: React.FC<IVideoPlayerProps> = ({ options }) => {\n const videoNode = React.useRef<HTMLVideoElement>(null);\n const player = React.useRef<videojs.Player>(null);\n\n React.useEffect(() => {\n QualitySelector(videojs);\n\n player.current = videojs(videoNode.current, {\n ...initialOptions,\n ...options,\n }).ready(function () {\n if (\n !this.controlBar\n .children()\n .some((c: { name_: string }) => c.name_ === \"QualitySelector\")\n ) {\n this.controlBar.addChild(\"QualitySelector\");\n }\n });\n return () => {\n if (player.current) {\n player.current.dispose();\n }\n };\n }, [options]);\n\n return <video ref={videoNode} className=\"video-js\" />;\n};\n\nexport default VideoPlayer;\n"],"names":["React","videojs","QualitySelector","initialOptions","controls","fluid","controlBar","volumePanel","inline","VideoPlayer","options","videoNode","useRef","player","useEffect","current","ready","children","some","c","name_","addChild","dispose","video","ref","className"],"mappings":";AAAA,OAAOA,WAAW,QAAQ;AAC1B,OAAOC,aAGA,yBAAyB;AAChC,OAAO,6BAA6B;AAEpC,SAAS;AACT,OAAO,6BAA6B;AAEpC,SAASC,eAAe,QAAQ,8BAA8B;AAM9D,MAAMC,iBAAuC;IAC3CC,UAAU;IACVC,OAAO;IACPC,YAAY;QACVC,aAAa;YACXC,QAAQ;QACV;IACF;AACF;AAEA,MAAMC,cAA2C,CAAC,EAAEC,OAAO,EAAE;IAC3D,MAAMC,YAAYX,MAAMY,MAAM,CAAmB;IACjD,MAAMC,SAASb,MAAMY,MAAM,CAAiB;IAE5CZ,MAAMc,SAAS,CAAC;QACdZ,gBAAgBD;QAEhBY,OAAOE,OAAO,GAAGd,QAAQU,UAAUI,OAAO,EAAE;YAC1C,GAAGZ,cAAc;YACjB,GAAGO,OAAO;QACZ,GAAGM,KAAK,CAAC;YACP,IACE,CAAC,IAAI,CAACV,UAAU,CACbW,QAAQ,GACRC,IAAI,CAAC,CAACC,IAAyBA,EAAEC,KAAK,KAAK,oBAC9C;gBACA,IAAI,CAACd,UAAU,CAACe,QAAQ,CAAC;YAC3B;QACF;QACA,OAAO;YACL,IAAIR,OAAOE,OAAO,EAAE;gBAClBF,OAAOE,OAAO,CAACO,OAAO;YACxB;QACF;IACF,GAAG;QAACZ;KAAQ;IAEZ,qBAAO,KAACa;QAAMC,KAAKb;QAAWc,WAAU;;AAC1C;AAEA,eAAehB,YAAY"}
|