payload-richtext-tiptap 0.0.134 → 0.0.136
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/body/ArticleBody.d.ts +2 -1
- package/dist/src/body/ArticleBody.d.ts.map +1 -1
- package/dist/src/body/ArticleBody.js +12 -11
- package/dist/src/body/ArticleBody.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.d.ts +4 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.js +28 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.js.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.js +5 -1
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.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 +6 -3
- package/dist/src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.js +0 -1
- package/dist/src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts +4 -0
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js +21 -3
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/VideoBlock.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts +2 -5
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js +24 -4
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts +4 -2
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js +3 -2
- package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js +2 -2
- package/dist/src/fields/TiptapEditor/extensions/extension-kit.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.js +5 -4
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.js +5 -4
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSideRenderer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.d.ts +2 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.js +2 -3
- package/dist/src/fields/TiptapEditor/extensions/serverside/EmbedContentSidebarRenderer.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/RenderEmbedClientSide.d.ts +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/RenderEmbedClientSide.d.ts.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/RenderEmbedClientSide.js +7 -29
- package/dist/src/fields/TiptapEditor/extensions/serverside/RenderEmbedClientSide.js.map +1 -1
- package/dist/src/fields/TiptapEditor/extensions/serverside/getAssetsAspectRatio.d.ts +5 -0
- package/dist/src/fields/TiptapEditor/extensions/serverside/getAssetsAspectRatio.d.ts.map +1 -0
- package/dist/src/fields/TiptapEditor/extensions/serverside/getAssetsAspectRatio.js +31 -0
- package/dist/src/fields/TiptapEditor/extensions/serverside/getAssetsAspectRatio.js.map +1 -0
- package/dist/src/mobile.css +1 -1
- package/dist/src/styles.css +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,8 @@ type Props = {
|
|
|
2
2
|
body: any;
|
|
3
3
|
wrapperClassName?: string;
|
|
4
4
|
articleClassName?: string;
|
|
5
|
+
getVideoAspect?: () => void;
|
|
5
6
|
};
|
|
6
|
-
export declare const ArticleBody: import("react").MemoExoticComponent<({ body, wrapperClassName, articleClassName }: Props) => import("react").JSX.Element>;
|
|
7
|
+
export declare const ArticleBody: import("react").MemoExoticComponent<({ body, wrapperClassName, articleClassName, getVideoAspect, }: Props) => import("react").JSX.Element>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=ArticleBody.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ArticleBody.d.ts","sourceRoot":"","sources":["../../../src/body/ArticleBody.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ArticleBody.d.ts","sourceRoot":"","sources":["../../../src/body/ArticleBody.tsx"],"names":[],"mappings":"AAYA,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,GAAG,CAAC;IACV,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B,CAAC;AACF,eAAO,MAAM,WAAW,sGAMnB,KAAK,iCA6BT,CAAC"}
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { memo } from
|
|
3
|
+
import { memo } from "react";
|
|
4
4
|
// import './article-custom.scss';
|
|
5
|
-
import { appendRequiredBlocksMarkerClient } from
|
|
6
|
-
import { ServersideTiptapBody } from
|
|
7
|
-
import { EmbedContentInlineRenderer } from
|
|
8
|
-
import { cn } from
|
|
9
|
-
const TRT_ARTICLE_BODY_ID =
|
|
10
|
-
export const ArticleBody = /*#__PURE__*/ memo(({ body, wrapperClassName, articleClassName })=>{
|
|
5
|
+
import { appendRequiredBlocksMarkerClient } from "../fields/TiptapEditor/extensions/serverside/useAppendRequiredBlocksMarkerClient.js";
|
|
6
|
+
import { ServersideTiptapBody } from "../fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.js";
|
|
7
|
+
import { EmbedContentInlineRenderer } from "../fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.js";
|
|
8
|
+
import { cn } from "../fields/TiptapEditor/lib/utils/index.js";
|
|
9
|
+
const TRT_ARTICLE_BODY_ID = "TRT-ARTICLE-BODY-ID";
|
|
10
|
+
export const ArticleBody = /*#__PURE__*/ memo(({ body, wrapperClassName, articleClassName, getVideoAspect })=>{
|
|
11
11
|
const json = appendRequiredBlocksMarkerClient(body);
|
|
12
12
|
if (!json) return null;
|
|
13
13
|
return /*#__PURE__*/ _jsxs("div", {
|
|
14
|
-
className: cn(
|
|
14
|
+
className: cn("text-grey-12 lg:grid trt-article-body-wrapper trt-article-page-wrapper w-full", wrapperClassName),
|
|
15
15
|
children: [
|
|
16
16
|
/*#__PURE__*/ _jsx("div", {}),
|
|
17
17
|
/*#__PURE__*/ _jsx("div", {
|
|
18
18
|
id: TRT_ARTICLE_BODY_ID,
|
|
19
19
|
className: "w-full flex flex-col",
|
|
20
20
|
children: /*#__PURE__*/ _jsx("div", {
|
|
21
|
-
className: cn(
|
|
21
|
+
className: cn("!selection:text-purple-900 font-notosans lg:text-xl lg:leading-8 md:text-lg md:leading-[30px] text-base", articleClassName),
|
|
22
22
|
children: /*#__PURE__*/ _jsx(ServersideTiptapBody, {
|
|
23
23
|
body: json
|
|
24
24
|
})
|
|
25
25
|
})
|
|
26
26
|
}),
|
|
27
27
|
/*#__PURE__*/ _jsx(EmbedContentInlineRenderer, {
|
|
28
|
-
body: json
|
|
28
|
+
body: json,
|
|
29
|
+
getVideoAspect: getVideoAspect
|
|
29
30
|
})
|
|
30
31
|
]
|
|
31
32
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/body/ArticleBody.tsx"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/body/ArticleBody.tsx"],"sourcesContent":["\"use client\";\r\n\r\nimport { memo } from \"react\";\r\n// import './article-custom.scss';\r\n\r\nimport { appendRequiredBlocksMarkerClient } from \"../fields/TiptapEditor/extensions/serverside/useAppendRequiredBlocksMarkerClient.js\";\r\nimport { ServersideTiptapBody } from \"../fields/TiptapEditor/extensions/serverside/ServersideTiptapBody.js\";\r\nimport { EmbedContentInlineRenderer } from \"../fields/TiptapEditor/extensions/serverside/EmbedContentInlineRenderer.js\";\r\nimport { cn } from \"../fields/TiptapEditor/lib/utils/index.js\";\r\n\r\nconst TRT_ARTICLE_BODY_ID = \"TRT-ARTICLE-BODY-ID\";\r\n\r\ntype Props = {\r\n body: any;\r\n wrapperClassName?: string;\r\n articleClassName?: string;\r\n getVideoAspect?: () => void;\r\n};\r\nexport const ArticleBody = memo(\r\n ({\r\n body,\r\n wrapperClassName,\r\n articleClassName,\r\n getVideoAspect,\r\n }: Props) => {\r\n const json = appendRequiredBlocksMarkerClient(body);\r\n if (!json) return null;\r\n return (\r\n <div\r\n className={cn(\r\n \"text-grey-12 lg:grid trt-article-body-wrapper trt-article-page-wrapper w-full\",\r\n wrapperClassName\r\n )}\r\n >\r\n <div />\r\n <div id={TRT_ARTICLE_BODY_ID} className=\"w-full flex flex-col\">\r\n <div\r\n className={cn(\r\n \"!selection:text-purple-900 font-notosans lg:text-xl lg:leading-8 md:text-lg md:leading-[30px] text-base\",\r\n articleClassName\r\n )}\r\n >\r\n <ServersideTiptapBody body={json} />\r\n </div>\r\n </div>\r\n <EmbedContentInlineRenderer\r\n body={json}\r\n getVideoAspect={getVideoAspect}\r\n />\r\n </div>\r\n );\r\n },\r\n (prev, next) => prev.body?.content?.length === next.body?.content?.length\r\n);\r\n"],"names":["memo","appendRequiredBlocksMarkerClient","ServersideTiptapBody","EmbedContentInlineRenderer","cn","TRT_ARTICLE_BODY_ID","ArticleBody","body","wrapperClassName","articleClassName","getVideoAspect","json","div","className","id","prev","next","content","length"],"mappings":"AAAA;;AAEA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,kCAAkC;AAElC,SAASC,gCAAgC,QAAQ,sFAAsF;AACvI,SAASC,oBAAoB,QAAQ,uEAAuE;AAC5G,SAASC,0BAA0B,QAAQ,6EAA6E;AACxH,SAASC,EAAE,QAAQ,4CAA4C;AAE/D,MAAMC,sBAAsB;AAQ5B,OAAO,MAAMC,4BAAcN,KACzB,CAAC,EACCO,IAAI,EACJC,gBAAgB,EAChBC,gBAAgB,EAChBC,cAAc,EACR;IACN,MAAMC,OAAOV,iCAAiCM;IAC9C,IAAI,CAACI,MAAM,OAAO;IAClB,qBACE,MAACC;QACCC,WAAWT,GACT,iFACAI;;0BAGF,KAACI;0BACD,KAACA;gBAAIE,IAAIT;gBAAqBQ,WAAU;0BACtC,cAAA,KAACD;oBACCC,WAAWT,GACT,2GACAK;8BAGF,cAAA,KAACP;wBAAqBK,MAAMI;;;;0BAGhC,KAACR;gBACCI,MAAMI;gBACND,gBAAgBA;;;;AAIxB,GACA,CAACK,MAAMC,OAASD,KAAKR,IAAI,EAAEU,SAASC,WAAWF,KAAKT,IAAI,EAAEU,SAASC,QACnE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageBlockViewClientside.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.tsx"],"names":[],"mappings":"AAKA,eAAO,MAAM,wBAAwB;;iCA+BpC,CAAC"}
|
package/dist/src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../../../lib/utils/index.js";
|
|
3
|
+
import Image from "next/image.js";
|
|
4
|
+
export const ImageBlockViewClientside = ({ content })=>{
|
|
5
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
6
|
+
children: [
|
|
7
|
+
/*#__PURE__*/ _jsx("div", {
|
|
8
|
+
className: cn("relative object-cover", {}),
|
|
9
|
+
style: {
|
|
10
|
+
width: content.attrs.width || "100%"
|
|
11
|
+
},
|
|
12
|
+
children: /*#__PURE__*/ _jsx(Image, {
|
|
13
|
+
className: "rounded object-cover",
|
|
14
|
+
src: content.attrs.src,
|
|
15
|
+
alt: content.attrs.alt || content.attrs.caption,
|
|
16
|
+
width: 800,
|
|
17
|
+
height: 600
|
|
18
|
+
})
|
|
19
|
+
}),
|
|
20
|
+
content.attrs?.caption ? /*#__PURE__*/ _jsx("p", {
|
|
21
|
+
className: cn("tiptap-image-caption", "pt-2 font-sf text-sm font-light text-grey-7 mx-6 sm:mx-0 line-clamp-2"),
|
|
22
|
+
children: content.attrs?.caption
|
|
23
|
+
}) : null
|
|
24
|
+
]
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=ImageBlockViewClientside.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageBlock/components/ImageBlockViewClientside.tsx"],"sourcesContent":["import { cn } from \"../../../lib/utils/index.js\";\nimport { useGetAssetsAspectRatio } from \"../../serverside/getAssetsAspectRatio.js\";\nimport { useEffect } from \"react\";\nimport Image from \"next/image.js\";\n\nexport const ImageBlockViewClientside = ({ content }) => {\n return (\n <>\n <div\n className={cn(\"relative object-cover\", {\n })}\n style={{\n width: content.attrs.width || \"100%\",\n }}\n >\n {/* @ts-ignore */}\n <Image\n className=\"rounded object-cover\"\n src={content.attrs.src}\n alt={content.attrs.alt || content.attrs.caption}\n width={800}\n height={600}\n />\n </div>\n {content.attrs?.caption ? (\n <p\n className={cn(\n \"tiptap-image-caption\",\n \"pt-2 font-sf text-sm font-light text-grey-7 mx-6 sm:mx-0 line-clamp-2\"\n )}\n >\n {content.attrs?.caption}\n </p>\n ) : null}\n </>\n );\n};\n"],"names":["cn","Image","ImageBlockViewClientside","content","div","className","style","width","attrs","src","alt","caption","height","p"],"mappings":";AAAA,SAASA,EAAE,QAAQ,8BAA8B;AAGjD,OAAOC,WAAW,gBAAgB;AAElC,OAAO,MAAMC,2BAA2B,CAAC,EAAEC,OAAO,EAAE;IAClD,qBACE;;0BACE,KAACC;gBACCC,WAAWL,GAAG,yBAAyB,CACvC;gBACAM,OAAO;oBACLC,OAAOJ,QAAQK,KAAK,CAACD,KAAK,IAAI;gBAChC;0BAGA,cAAA,KAACN;oBACCI,WAAU;oBACVI,KAAKN,QAAQK,KAAK,CAACC,GAAG;oBACtBC,KAAKP,QAAQK,KAAK,CAACE,GAAG,IAAIP,QAAQK,KAAK,CAACG,OAAO;oBAC/CJ,OAAO;oBACPK,QAAQ;;;YAGXT,QAAQK,KAAK,EAAEG,wBACd,KAACE;gBACCR,WAAWL,GACT,wBACA;0BAGDG,QAAQK,KAAK,EAAEG;iBAEhB;;;AAGV,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getImageActualSize.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe;;;
|
|
1
|
+
{"version":3,"file":"getImageActualSize.d.ts","sourceRoot":"","sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAEjD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe;;;EAQxD"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export function
|
|
1
|
+
export function getAssetActualSize(asset) {
|
|
2
2
|
if (asset.width && asset.height) {
|
|
3
3
|
return {
|
|
4
4
|
actualWidth: asset.width,
|
|
5
5
|
actualHeight: asset.height
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
return {
|
|
9
|
+
actualWidth: 0,
|
|
10
|
+
actualHeight: 0
|
|
11
|
+
};
|
|
8
12
|
}
|
|
9
13
|
|
|
10
14
|
//# sourceMappingURL=getImageActualSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.ts"],"sourcesContent":["import { AssetReturnType } from \"../../types.js\";\n\nexport function
|
|
1
|
+
{"version":3,"sources":["../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/getImageActualSize.ts"],"sourcesContent":["import { AssetReturnType } from \"../../types.js\";\n\nexport function getAssetActualSize(asset: AssetReturnType) {\n if (asset.width && asset.height) {\n return {\n actualWidth: asset.width,\n actualHeight: asset.height,\n };\n }\n return { actualWidth: 0, actualHeight: 0 };\n}\n"],"names":["getAssetActualSize","asset","width","height","actualWidth","actualHeight"],"mappings":"AAEA,OAAO,SAASA,mBAAmBC,KAAsB;IACvD,IAAIA,MAAMC,KAAK,IAAID,MAAME,MAAM,EAAE;QAC/B,OAAO;YACLC,aAAaH,MAAMC,KAAK;YACxBG,cAAcJ,MAAME,MAAM;QAC5B;IACF;IACA,OAAO;QAAEC,aAAa;QAAGC,cAAc;IAAE;AAC3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAIxD,OAAO,EAEL,SAAS,EACT,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAE1C,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,iCAKjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,CAAC,EAAE,SAAS,CAAA;SAAE,CAAA;KAAE,CAAC;CACvC,
|
|
1
|
+
{"version":3,"file":"ImageUpload.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAmB,MAAM,eAAe,CAAC;AAIxD,OAAO,EAEL,SAAS,EACT,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAE1C,eAAO,MAAM,kBAAkB,uBAAwB,eAAe,iCAKjE;IACD,MAAM,EAAE,MAAM,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE;QAAE,KAAK,EAAE;YAAE,IAAI,CAAC,EAAE,SAAS,CAAA;SAAE,CAAA;KAAE,CAAC;CACvC,gCAkFF,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { NodeViewWrapper } from "@tiptap/react";
|
|
|
4
4
|
import i18next from "i18next";
|
|
5
5
|
import { ImagePlus } from "lucide-react";
|
|
6
6
|
import { useCallback, useState } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { getAssetActualSize } from "../getImageActualSize.js";
|
|
8
8
|
export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
9
9
|
const ImageUpload = ({ getPos, editor, node })=>{
|
|
10
10
|
const [done, setDone] = useState(false);
|
|
@@ -14,7 +14,7 @@ export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
|
14
14
|
if (i18next.language !== "en" && !!asset.title_locale[i18next.language.toUpperCase()]) {
|
|
15
15
|
title = asset.title_locale[i18next.language.toUpperCase()];
|
|
16
16
|
}
|
|
17
|
-
const { actualWidth, actualHeight } =
|
|
17
|
+
const { actualWidth, actualHeight } = getAssetActualSize(asset);
|
|
18
18
|
if (asset.type === "IMAGE") {
|
|
19
19
|
editor.chain().focus().setImageBlock({
|
|
20
20
|
src: asset?.optimizedImageUrl || asset.fullUrl,
|
|
@@ -34,12 +34,15 @@ export const ImageUploadBuilder = (openAssetHQHandler)=>{
|
|
|
34
34
|
assetId: asset.id,
|
|
35
35
|
playlistUrl: asset.playlistUrl
|
|
36
36
|
});
|
|
37
|
+
const { actualHeight, actualWidth } = getAssetActualSize(asset);
|
|
37
38
|
editor.chain().focus().setVideoBlock({
|
|
38
39
|
src: asset.videoUrl,
|
|
39
40
|
poster: asset.fullUrl,
|
|
40
41
|
assetId: asset.id,
|
|
41
42
|
playlistUrl: asset.playlistUrl,
|
|
42
|
-
title: title
|
|
43
|
+
title: title,
|
|
44
|
+
actualHeight,
|
|
45
|
+
actualWidth
|
|
43
46
|
}).deleteRange({
|
|
44
47
|
from: getPos(),
|
|
45
48
|
to: getPos()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["\"use client\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport i18next from \"i18next\";\nimport { ImagePlus } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport {\n AssetReturnType,\n AssetType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/ImageUpload/view/ImageUpload.tsx"],"sourcesContent":["\"use client\";\nimport { Editor, NodeViewWrapper } from \"@tiptap/react\";\nimport i18next from \"i18next\";\nimport { ImagePlus } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport {\n AssetReturnType,\n AssetType,\n openAssetHQType,\n} from \"src/fields/TiptapEditor/types.js\";\nimport { getAssetActualSize } from \"../getImageActualSize.js\";\nexport const ImageUploadBuilder = (openAssetHQHandler: openAssetHQType) => {\n const ImageUpload = ({\n getPos,\n editor,\n node,\n }: {\n getPos: () => number;\n editor: Editor;\n node: { attrs: { type?: AssetType } };\n }) => {\n const [done, setDone] = useState(false);\n const onUpload = useCallback(\n (asset: AssetReturnType) => {\n if (asset && !done) {\n let title = asset.title;\n if (\n i18next.language !== \"en\" &&\n !!asset.title_locale[i18next.language.toUpperCase()]\n ) {\n title = asset.title_locale[i18next.language.toUpperCase()];\n }\n const { actualWidth, actualHeight } = getAssetActualSize(asset);\n if (asset.type === \"IMAGE\") {\n editor\n .chain()\n .focus()\n .setImageBlock({\n src: asset?.optimizedImageUrl || asset.fullUrl,\n assetId: asset.id,\n caption: title,\n actualWidth: actualWidth,\n actualHeight: actualHeight,\n })\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 const { actualHeight, actualWidth } = getAssetActualSize(asset);\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 title: title,\n actualHeight,\n actualWidth,\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, null, node?.attrs?.type ?? \"image\");\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","i18next","ImagePlus","useCallback","useState","getAssetActualSize","ImageUploadBuilder","openAssetHQHandler","ImageUpload","getPos","editor","node","done","setDone","onUpload","asset","title","language","title_locale","toUpperCase","actualWidth","actualHeight","type","chain","focus","setImageBlock","src","optimizedImageUrl","fullUrl","assetId","id","caption","deleteRange","from","to","run","console","log","videoUrl","poster","playlistUrl","setVideoBlock","info","div","className","data-drag-handle","a","href","onClick","e","preventDefault","attrs"],"mappings":"AAAA;;AACA,SAAiBA,eAAe,QAAQ,gBAAgB;AACxD,OAAOC,aAAa,UAAU;AAC9B,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,WAAW,EAAEC,QAAQ,QAAQ,QAAQ;AAM9C,SAASC,kBAAkB,QAAQ,2BAA2B;AAC9D,OAAO,MAAMC,qBAAqB,CAACC;IACjC,MAAMC,cAAc,CAAC,EAC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B;wBAAUyB,IAAIzB;oBAAS,GAC3Ce,KAAK,GACLW,GAAG;oBACNtB,QAAQ;gBACV;YACF,OAAO;gBACLuB,QAAQM,IAAI,CACV;YAEJ;QACF,GACA;YAACjC;YAAQC;SAAO;QAGlB,qBACE,KAACV;sBACC,cAAA,KAAC2C;gBAAIC,WAAU;gBAAUC,kBAAgB;0BACvC,cAAA,MAACC;oBACCC,MAAK;oBACLH,WAAU;oBACVI,SAAS,CAACC;wBACRA,EAAEC,cAAc;wBAChB3C,mBAAmBO,UAAU,MAAMH,MAAMwC,OAAO7B,QAAQ;oBAC1D;;sCAEA,KAACpB;4BAAU0C,WAAU;;wBAAS;;;;;IAMxC;IAEA,OAAOpC;AACT,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linkPreviewMenu.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAI7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAE/F,eAAO,MAAM,gBAAgB,6CAI1B,SAAS,GAAG;IAAE,iBAAiB,EAAE,qBAAqB,CAAA;CAAE,
|
|
1
|
+
{"version":3,"file":"linkPreviewMenu.d.ts","sourceRoot":"","sources":["../../../../../../../src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAI3C,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAI7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,wDAAwD,CAAC;AAE/F,eAAO,MAAM,gBAAgB,6CAI1B,SAAS,GAAG;IAAE,iBAAiB,EAAE,qBAAqB,CAAA;CAAE,sBAkC1D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -13,7 +13,6 @@ export const ILinkPreviewMenu = ({ editor, appendTo, fetchSiteMetadata })=>{
|
|
|
13
13
|
const onSetLink = useCallback(async (src)=>{
|
|
14
14
|
if (fetchSiteMetadata) {
|
|
15
15
|
const metadata = await fetchSiteMetadata(src);
|
|
16
|
-
console.log(src, metadata);
|
|
17
16
|
editor.chain().focus().setLinkPreview(src, metadata).run();
|
|
18
17
|
}
|
|
19
18
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport React, { useCallback } from \"react\";\nimport { sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport i18next from \"i18next\";\nimport { LinkPreviewEditorPanel } from \"../LinkPreviewEditorPanel.js\";\nimport { FetchSiteMetadataType } from \"src/fields/TiptapEditor/features/BlockEditor/types.jsx\";\n\nexport const ILinkPreviewMenu = ({\n editor,\n appendTo,\n fetchSiteMetadata,\n}: MenuProps & { fetchSiteMetadata: FetchSiteMetadataType }) => {\n const shouldShow = useCallback(() => {\n const isLinkPreview = editor.isActive(\"linkPreview\");\n return isLinkPreview;\n }, [editor]);\n\n const onSetLink = useCallback(\n async (src: string) => {\n if (fetchSiteMetadata) {\n const metadata = await fetchSiteMetadata(src);\n
|
|
1
|
+
{"version":3,"sources":["../../../../../../../src/fields/TiptapEditor/extensions/LinkPreview/menus/linkPreviewMenu.tsx"],"sourcesContent":["import { BubbleMenu as BaseBubbleMenu } from \"@tiptap/react\";\nimport React, { useCallback } from \"react\";\nimport { sticky } from \"tippy.js\";\nimport { v4 as uuid } from \"uuid\";\n\nimport { MenuProps } from \"../../../features/menus/types.js\";\nimport { Toolbar } from \"../../../features/ui/Toolbar.js\";\nimport i18next from \"i18next\";\nimport { LinkPreviewEditorPanel } from \"../LinkPreviewEditorPanel.js\";\nimport { FetchSiteMetadataType } from \"src/fields/TiptapEditor/features/BlockEditor/types.jsx\";\n\nexport const ILinkPreviewMenu = ({\n editor,\n appendTo,\n fetchSiteMetadata,\n}: MenuProps & { fetchSiteMetadata: FetchSiteMetadataType }) => {\n const shouldShow = useCallback(() => {\n const isLinkPreview = editor.isActive(\"linkPreview\");\n return isLinkPreview;\n }, [editor]);\n\n const onSetLink = useCallback(\n async (src: string) => {\n if (fetchSiteMetadata) {\n const metadata = await fetchSiteMetadata(src);\n editor.chain().focus().setLinkPreview(src, metadata).run();\n }\n },\n [editor]\n );\n return (\n <BaseBubbleMenu\n editor={editor}\n pluginKey=\"linkPreview\"\n shouldShow={shouldShow}\n tippyOptions={{ popperOptions: { placement: \"top-start\" } }}\n updateDelay={100}\n >\n <Toolbar.Button type=\"button\">\n <LinkPreviewEditorPanel\n onSetLink={onSetLink}\n // @ts-ignore\n initialSrcLink={\n editor?.getAttributes(\"linkPreview\")?.editorValue ?? \"\"\n }\n />\n </Toolbar.Button>\n </BaseBubbleMenu>\n );\n};\n\nexport default ILinkPreviewMenu;\n"],"names":["BubbleMenu","BaseBubbleMenu","React","useCallback","Toolbar","LinkPreviewEditorPanel","ILinkPreviewMenu","editor","appendTo","fetchSiteMetadata","shouldShow","isLinkPreview","isActive","onSetLink","src","metadata","chain","focus","setLinkPreview","run","pluginKey","tippyOptions","popperOptions","placement","updateDelay","Button","type","initialSrcLink","getAttributes","editorValue"],"mappings":";AAAA,SAASA,cAAcC,cAAc,QAAQ,gBAAgB;AAC7D,OAAOC,SAASC,WAAW,QAAQ,QAAQ;AAK3C,SAASC,OAAO,QAAQ,kCAAkC;AAE1D,SAASC,sBAAsB,QAAQ,+BAA+B;AAGtE,OAAO,MAAMC,mBAAmB,CAAC,EAC/BC,MAAM,EACNC,QAAQ,EACRC,iBAAiB,EACwC;IACzD,MAAMC,aAAaP,YAAY;QAC7B,MAAMQ,gBAAgBJ,OAAOK,QAAQ,CAAC;QACtC,OAAOD;IACT,GAAG;QAACJ;KAAO;IAEX,MAAMM,YAAYV,YAChB,OAAOW;QACL,IAAIL,mBAAmB;YACrB,MAAMM,WAAW,MAAMN,kBAAkBK;YACzCP,OAAOS,KAAK,GAAGC,KAAK,GAAGC,cAAc,CAACJ,KAAKC,UAAUI,GAAG;QAC1D;IACF,GACA;QAACZ;KAAO;IAEV,qBACE,KAACN;QACCM,QAAQA;QACRa,WAAU;QACVV,YAAYA;QACZW,cAAc;YAAEC,eAAe;gBAAEC,WAAW;YAAY;QAAE;QAC1DC,aAAa;kBAEb,cAAA,KAACpB,QAAQqB,MAAM;YAACC,MAAK;sBACnB,cAAA,KAACrB;gBACCQ,WAAWA;gBACX,aAAa;gBACbc,gBACEpB,QAAQqB,cAAc,gBAAgBC,eAAe;;;;AAMjE,EAAE;AAEF,eAAevB,iBAAiB"}
|
|
@@ -8,6 +8,8 @@ declare module "@tiptap/core" {
|
|
|
8
8
|
assetId: string;
|
|
9
9
|
playlistUrl?: string;
|
|
10
10
|
title: string;
|
|
11
|
+
actualWidth?: number;
|
|
12
|
+
actualHeight?: number;
|
|
11
13
|
}) => ReturnType;
|
|
12
14
|
setVideoBlockAt: (attributes: {
|
|
13
15
|
src: string;
|
|
@@ -16,6 +18,8 @@ declare module "@tiptap/core" {
|
|
|
16
18
|
playlistUrl?: string;
|
|
17
19
|
title: string;
|
|
18
20
|
pos: number | Range;
|
|
21
|
+
actualWidth?: number;
|
|
22
|
+
actualHeight?: number;
|
|
19
23
|
}) => ReturnType;
|
|
20
24
|
setVideoBlockAlign: (align: "left" | "center" | "right") => ReturnType;
|
|
21
25
|
setVideoBlockWidth: (width: number) => ReturnType;
|
|
@@ -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;gBACf,OAAO,EAAE,MAAM,CAAC;gBAChB,WAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,KAAK,EAAE,MAAM,
|
|
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;gBACrB,KAAK,EAAE,MAAM,CAAC;gBACd,WAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,YAAY,CAAC,EAAE,MAAM,CAAC;aACvB,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;gBACrB,KAAK,EAAE,MAAM,CAAC;gBACd,GAAG,EAAE,MAAM,GAAG,KAAK,CAAC;gBACpB,WAAW,CAAC,EAAE,MAAM,CAAC;gBACrB,YAAY,CAAC,EAAE,MAAM,CAAC;aACvB,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,6EA0KrB,CAAC;AAEH,eAAe,UAAU,CAAC"}
|
|
@@ -45,6 +45,20 @@ export const VideoBlock = Video.extend({
|
|
|
45
45
|
"data-width": attributes.width
|
|
46
46
|
})
|
|
47
47
|
},
|
|
48
|
+
actualWidth: {
|
|
49
|
+
default: 0,
|
|
50
|
+
parseHTML: (element)=>element.getAttribute("data-actual-width"),
|
|
51
|
+
renderHTML: (attributes)=>({
|
|
52
|
+
"data-actual-width": attributes.actualWidth
|
|
53
|
+
})
|
|
54
|
+
},
|
|
55
|
+
actualHeight: {
|
|
56
|
+
default: 0,
|
|
57
|
+
parseHTML: (element)=>element.getAttribute("data-actual-height"),
|
|
58
|
+
renderHTML: (attributes)=>({
|
|
59
|
+
"data-actual-height": attributes.actualHeight
|
|
60
|
+
})
|
|
61
|
+
},
|
|
48
62
|
align: {
|
|
49
63
|
default: "center",
|
|
50
64
|
parseHTML: (element)=>element.getAttribute("data-align"),
|
|
@@ -77,7 +91,7 @@ export const VideoBlock = Video.extend({
|
|
|
77
91
|
},
|
|
78
92
|
renderHTML ({ HTMLAttributes }) {
|
|
79
93
|
return [
|
|
80
|
-
|
|
94
|
+
"div",
|
|
81
95
|
{
|
|
82
96
|
class: "imageBlock"
|
|
83
97
|
},
|
|
@@ -106,7 +120,9 @@ export const VideoBlock = Video.extend({
|
|
|
106
120
|
poster: attrs.poster,
|
|
107
121
|
assetId: attrs.assetId,
|
|
108
122
|
playlistUrl: attrs.playlistUrl,
|
|
109
|
-
title: attrs.title
|
|
123
|
+
title: attrs.title,
|
|
124
|
+
actualWidth: attrs.actualWidth,
|
|
125
|
+
actualHeight: attrs.actualHeight
|
|
110
126
|
}
|
|
111
127
|
});
|
|
112
128
|
},
|
|
@@ -118,7 +134,9 @@ export const VideoBlock = Video.extend({
|
|
|
118
134
|
poster: attrs.poster,
|
|
119
135
|
assetId: attrs.assetId,
|
|
120
136
|
playlistUrl: attrs.playlistUrl,
|
|
121
|
-
title: attrs.title
|
|
137
|
+
title: attrs.title,
|
|
138
|
+
actualWidth: attrs.actualWidth,
|
|
139
|
+
actualHeight: attrs.actualHeight
|
|
122
140
|
}
|
|
123
141
|
});
|
|
124
142
|
},
|
|
@@ -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 assetId: string;\n playlistUrl?: string;\n title: string
|
|
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 title: string;\n actualWidth?: number;\n actualHeight?: number;\n }) => ReturnType;\n setVideoBlockAt: (attributes: {\n src: string;\n poster: string;\n assetId: string;\n playlistUrl?: string;\n title: string;\n pos: number | Range;\n actualWidth?: number;\n actualHeight?: number;\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 title: {\n default: \"\",\n parseHTML: (element) => element.getAttribute(\"title\"),\n renderHTML: (attributes) => ({\n title: attributes.title,\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 actualWidth: {\n default: 0,\n parseHTML: (element) => element.getAttribute(\"data-actual-width\"),\n renderHTML: (attributes) => ({\n \"data-actual-width\": attributes.actualWidth,\n }),\n },\n actualHeight: {\n default: 0,\n parseHTML: (element) => element.getAttribute(\"data-actual-height\"),\n renderHTML: (attributes) => ({\n \"data-actual-height\": attributes.actualHeight,\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 \"div\",\n { class: \"imageBlock\" },\n [\"video\", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)],\n [\n \"caption\",\n mergeAttributes(\n {\n class:\n \"text-center text-gray-400 w-full h-16 mb-2 placeholder-black p-1 text-sm border-0 rounded appearance-none\",\n },\n { defaultValue: HTMLAttributes.title || HTMLAttributes.caption }\n ),\n HTMLAttributes.title || HTMLAttributes.caption,\n ],\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 title: attrs.title,\n actualWidth: attrs.actualWidth,\n actualHeight: attrs.actualHeight,\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 title: attrs.title,\n actualWidth: attrs.actualWidth,\n actualHeight: attrs.actualHeight,\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 //@ts-ignore\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","title","poster","playlistUrl","width","actualWidth","actualHeight","align","alt","undefined","caption","tag","HTMLAttributes","class","options","defaultValue","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;AA+B1C,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;wBAC3BC,OAAOD,WAAWC,KAAK;oBACzB,CAAA;YACF;YACAC,QAAQ;gBACNP,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3BE,QAAQF,WAAWE,MAAM;oBAC3B,CAAA;YACF;YACAC,aAAa;gBACXR,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,CAAA;wBAC3B,qBAAqBA,WAAWG,WAAW;oBAC7C,CAAA;YACF;YACAC,OAAO;gBACLT,SAAS;gBACTC,WAAW,CAACC,UAAYA,QAAQC,YAAY,CAAC;gBAC7CC,YAAY,CAACC,aAAgB,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/extensions/VideoBlock/components/VideoBlockViewClientside.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Node } from "@tiptap/pm/model";
|
|
2
|
-
import { Editor } from "@tiptap/react";
|
|
3
2
|
import React from "react";
|
|
4
3
|
interface VideoBlockViewProps {
|
|
5
|
-
editor: Editor;
|
|
6
|
-
getPos: () => number;
|
|
7
4
|
node: Node & {
|
|
8
5
|
attrs: {
|
|
9
6
|
src: string;
|
|
@@ -12,8 +9,8 @@ interface VideoBlockViewProps {
|
|
|
12
9
|
playlistUrl?: string;
|
|
13
10
|
};
|
|
14
11
|
};
|
|
15
|
-
updateAttributes: (attrs: Record<string, string>) => void;
|
|
16
12
|
className?: string;
|
|
13
|
+
getVideoAspect?: () => void;
|
|
17
14
|
}
|
|
18
15
|
export type Playlist = {
|
|
19
16
|
id: string;
|
|
@@ -29,6 +26,6 @@ export type Item = {
|
|
|
29
26
|
width: number;
|
|
30
27
|
height: number;
|
|
31
28
|
};
|
|
32
|
-
export declare const VideoBlockViewClientside: ({ className, ...props }: VideoBlockViewProps) => React.JSX.Element;
|
|
29
|
+
export declare const VideoBlockViewClientside: ({ className, getVideoAspect, ...props }: VideoBlockViewProps) => React.JSX.Element;
|
|
33
30
|
export default VideoBlockViewClientside;
|
|
34
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;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,wBAAwB,4CAIlC,mBAAmB,sBAuHrB,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/VideoBlockViewClientside.js
CHANGED
|
@@ -3,10 +3,12 @@ import { NodeViewWrapper } from "@tiptap/react";
|
|
|
3
3
|
import React, { useEffect, useMemo, useRef } from "react";
|
|
4
4
|
import { cn } from "../../../lib/utils/index.js";
|
|
5
5
|
import VideoPlayer from "./videojs/VideoPlayer.js";
|
|
6
|
-
|
|
6
|
+
import { useGetAssetsAspectRatio } from "../../serverside/getAssetsAspectRatio.js";
|
|
7
|
+
export const VideoBlockViewClientside = ({ className, getVideoAspect, ...props })=>{
|
|
7
8
|
const { node } = props;
|
|
8
9
|
const videoWrapperRef = useRef(null);
|
|
9
|
-
const { src, poster, playlistUrl, caption } = node.attrs;
|
|
10
|
+
const { src, poster, playlistUrl, caption, actualWidth, actualHeight } = node.attrs;
|
|
11
|
+
const { aspectRatio, calculateAspectRatio } = useGetAssetsAspectRatio();
|
|
10
12
|
const [playlistContent, setPlaylistContent] = React.useState();
|
|
11
13
|
const [error, setError] = React.useState();
|
|
12
14
|
useEffect(()=>{
|
|
@@ -40,7 +42,8 @@ export const VideoBlockViewClientside = ({ className, ...props })=>{
|
|
|
40
42
|
type: item.type,
|
|
41
43
|
label: item.label
|
|
42
44
|
})),
|
|
43
|
-
poster: playlistContent.poster
|
|
45
|
+
poster: playlistContent.poster,
|
|
46
|
+
preload: "auto"
|
|
44
47
|
};
|
|
45
48
|
}
|
|
46
49
|
return {
|
|
@@ -49,11 +52,25 @@ export const VideoBlockViewClientside = ({ className, ...props })=>{
|
|
|
49
52
|
type: item.type,
|
|
50
53
|
label: item.label
|
|
51
54
|
})),
|
|
52
|
-
poster: playlistContent.poster
|
|
55
|
+
poster: playlistContent.poster,
|
|
56
|
+
preload: "auto"
|
|
53
57
|
};
|
|
54
58
|
}, [
|
|
55
59
|
playlistContent
|
|
56
60
|
]);
|
|
61
|
+
useEffect(()=>{
|
|
62
|
+
const anySrc = playlistContent?.items?.some((item)=>item.src);
|
|
63
|
+
if (!aspectRatio && anySrc) {
|
|
64
|
+
const source = playlistContent.items.find((item)=>item.src && item.width && item.height);
|
|
65
|
+
calculateAspectRatio({
|
|
66
|
+
src,
|
|
67
|
+
actualWidth: actualWidth || source?.width,
|
|
68
|
+
actualHeight: actualHeight || source?.height
|
|
69
|
+
}, "VIDEO", getVideoAspect);
|
|
70
|
+
}
|
|
71
|
+
}, [
|
|
72
|
+
playlistContent
|
|
73
|
+
]);
|
|
57
74
|
return /*#__PURE__*/ _jsx(NodeViewWrapper, {
|
|
58
75
|
className: className,
|
|
59
76
|
children: /*#__PURE__*/ _jsx("div", {
|
|
@@ -63,6 +80,9 @@ export const VideoBlockViewClientside = ({ className, ...props })=>{
|
|
|
63
80
|
},
|
|
64
81
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
65
82
|
ref: videoWrapperRef,
|
|
83
|
+
style: {
|
|
84
|
+
aspectRatio
|
|
85
|
+
},
|
|
66
86
|
children: [
|
|
67
87
|
error && /*#__PURE__*/ _jsx("div", {
|
|
68
88
|
children: error
|
|
@@ -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 { 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 VideoBlockViewClientside = ({\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 } = 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 const anySrc = playlistContent?.items?.some((item) => item.src);\n\n if (!aspectRatio && anySrc) {\n const source = playlistContent.items.find(\n (item) => item.src && item.width && item.height\n );\n calculateAspectRatio(\n {\n src,\n actualWidth: actualWidth || source?.width,\n actualHeight: actualHeight || source?.height,\n },\n \"VIDEO\",\n getVideoAspect\n );\n }\n }, [playlistContent]);\n\n return (\n <NodeViewWrapper className={className}>\n <div className={wrapperClassName} style={{ width: node.attrs.width }}>\n <div ref={videoWrapperRef} style={{ aspectRatio }}>\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 <div className=\"text-center block text-sm text-gray-500\">\n {playlistContent?.title}\n </div>\n )}\n </div>\n </div>\n </NodeViewWrapper>\n );\n};\n\nexport default VideoBlockViewClientside;\n"],"names":["NodeViewWrapper","React","useEffect","useMemo","useRef","cn","VideoPlayer","useGetAssetsAspectRatio","VideoBlockViewClientside","className","getVideoAspect","props","node","videoWrapperRef","src","poster","playlistUrl","caption","actualWidth","actualHeight","attrs","aspectRatio","calculateAspectRatio","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","anySrc","source","find","width","height","div","style","ref","options","title"],"mappings":";AACA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAQ;AAC1D,SAASC,EAAE,QAAQ,8BAA8B;AACjD,OAAOC,iBAAiB,2BAA2B;AACnD,SAASC,uBAAuB,QAAQ,2CAA2C;AA+BnF,OAAO,MAAMC,2BAA2B,CAAC,EACvCC,SAAS,EACTC,cAAc,EACd,GAAGC,OACiB;IACpB,MAAM,EAAEC,IAAI,EAAE,GAAGD;IACjB,MAAME,kBAAkBT,OAAuB;IAC/C,MAAM,EAAEU,GAAG,EAAEC,MAAM,EAAEC,WAAW,EAAEC,OAAO,EAAEC,WAAW,EAAEC,YAAY,EAAE,GACpEP,KAAKQ,KAAK;IACZ,MAAM,EAAEC,WAAW,EAAEC,oBAAoB,EAAE,GAAGf;IAC9C,MAAM,CAACgB,iBAAiBC,mBAAmB,GAAGvB,MAAMwB,QAAQ;IAG5D,MAAM,CAACC,OAAOC,SAAS,GAAG1B,MAAMwB,QAAQ;IAExCvB,UAAU;QACR,eAAe0B;YACb,MAAMC,MAAM,MAAMC,MAAMd,aAAa;gBACnCe,OAAO;YACT;YACA,OAAO,MAAMF,IAAIG,IAAI;QACvB;QAEA,IAAIhB,aAAa;YACf,IAAI;gBACFY,qBACGK,IAAI,CAAC,CAACC;oBACLV,mBA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gBkB,KAAK,CAACW,IAAI,CACvC,CAACT,OAASA,KAAK7B,GAAG,IAAI6B,KAAKU,KAAK,IAAIV,KAAKW,MAAM;YAEjDhC,qBACE;gBACER;gBACAI,aAAaA,eAAeiC,QAAQE;gBACpClC,cAAcA,gBAAgBgC,QAAQG;YACxC,GACA,SACA5C;QAEJ;IACF,GAAG;QAACa;KAAgB;IAEpB,qBACE,KAACvB;QAAgBS,WAAWA;kBAC1B,cAAA,KAAC8C;YAAI9C,WAAW4B;YAAkBmB,OAAO;gBAAEH,OAAOzC,KAAKQ,KAAK,CAACiC,KAAK;YAAC;sBACjE,cAAA,MAACE;gBAAIE,KAAK5C;gBAAiB2C,OAAO;oBAAEnC;gBAAY;;oBAC7CK,uBAAS,KAAC6B;kCAAK7B;;oBASfH,iCAAmB,KAACjB;wBAAYoD,SAASnB;;oBACzCtB,WAAWM,iBAAiBoC,uBAC3B,KAACJ;wBAAI9C,WAAU;kCACZc,iBAAiBoC;;;;;;AAOhC,EAAE;AAEF,eAAenD,yBAAyB"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import React from "react";
|
|
1
|
+
import React, { CSSProperties } from "react";
|
|
2
2
|
import { VideoJsPlayerOptions } from "video.js/dist/video.js";
|
|
3
3
|
import "video.js/dist/video-js.css";
|
|
4
4
|
import "video.js/dist/video-js.css";
|
|
5
5
|
interface IVideoPlayerProps {
|
|
6
6
|
options: VideoJsPlayerOptions;
|
|
7
7
|
}
|
|
8
|
-
declare const VideoPlayer: React.FC<IVideoPlayerProps
|
|
8
|
+
declare const VideoPlayer: React.FC<IVideoPlayerProps & {
|
|
9
|
+
style?: CSSProperties;
|
|
10
|
+
}>;
|
|
9
11
|
export default VideoPlayer;
|
|
10
12
|
//# sourceMappingURL=VideoPlayer.d.ts.map
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.d.ts.map
CHANGED
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"VideoPlayer.d.ts","sourceRoot":"","sources":["../../../../../../../../src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,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,GAAG;IAAE,KAAK,CAAC,EAAE,aAAa,CAAA;CAAE,CA8BxE,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
package/dist/src/fields/TiptapEditor/extensions/VideoBlock/components/videojs/VideoPlayer.js
CHANGED
|
@@ -14,7 +14,7 @@ const initialOptions = {
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
};
|
|
17
|
-
const VideoPlayer = ({ options })=>{
|
|
17
|
+
const VideoPlayer = ({ options, style })=>{
|
|
18
18
|
const videoNode = React.useRef(null);
|
|
19
19
|
const player = React.useRef(null);
|
|
20
20
|
React.useEffect(()=>{
|
|
@@ -37,7 +37,8 @@ const VideoPlayer = ({ options })=>{
|
|
|
37
37
|
]);
|
|
38
38
|
return /*#__PURE__*/ _jsx("video", {
|
|
39
39
|
ref: videoNode,
|
|
40
|
-
className: "video-js"
|
|
40
|
+
className: "video-js",
|
|
41
|
+
style: style
|
|
41
42
|
});
|
|
42
43
|
};
|
|
43
44
|
export default VideoPlayer;
|