@yoopta/video 6.0.0-beta.8 → 6.0.0-beta.9
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/hooks/use-upload.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EAGpB,kBAAkB,EAIlB,wBAAwB,EAIxB,kBAAkB,EAClB,kBAAkB,EAInB,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"use-upload.d.ts","sourceRoot":"","sources":["../../src/hooks/use-upload.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EACpB,0BAA0B,EAC1B,oBAAoB,EAGpB,kBAAkB,EAIlB,wBAAwB,EAIxB,kBAAkB,EAClB,kBAAkB,EAInB,MAAM,UAAU,CAAC;AA2IlB,eAAO,MAAM,cAAc,YAAa,kBAAkB,GAAG,SAAS,KAAG,oBAgHxE,CAAC;AAEF,eAAO,MAAM,cAAc,YAAa,kBAAkB,GAAG,SAAS,KAAG,oBAoHxE,CAAC;AAEF,eAAO,MAAM,oBAAoB,YACtB,wBAAwB,GAAG,SAAS,KAC5C,0BAiHF,CAAC;AAEF,eAAO,MAAM,kBAAkB;0BACA,IAAI,KAAG,QAAQ;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAuBjG,CAAC;AAEF,eAAO,MAAM,eAAe;;4BAGK,IAAI,KAAG,kBAAkB;;CAwBzD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{generateId as o,Blocks as n,Elements as i,YooptaPlugin as r}from"@yoopta/editor";import{useState as s,useRef as l,useCallback as a}from"react";const d={buildVideoElements:(e,t={})=>{const n=Object.assign(Object.assign({},t.props),{nodeType:"void"});return{id:o(),type:"video",children:[{text:""}],props:n}},insertVideo:(e,t={})=>{const{at:o,focus:i,props:r}=t,s=d.buildVideoElements(e,{props:r}),l=n.buildBlockData({value:[s],type:"Video",meta:{align:"center",depth:0}});n.insertBlock(e,l.type,{focus:i,at:o,blockData:l})},deleteVideo:(e,t)=>{n.deleteBlock(e,{blockId:t})},updateVideo:(e,t,o)=>{i.updateElement(e,{blockId:t,type:"video",props:o})}},u=e=>"number"==typeof e?e:parseInt(e.replace(/[^\d]/g,""),10),c={left:"flex-start",center:"center",right:"flex-end"},p=new r({type:"Video",elements:e("video",{render:o=>t("div",Object.assign({},o.attributes,{children:[e("video",{src:o.element.props.src,width:o.element.props.sizes.width,height:o.element.props.sizes.height,objectFit:o.element.props.fit,controls:o.element.props.settings.controls,loop:o.element.props.settings.loop,muted:o.element.props.settings.muted,autoPlay:o.element.props.settings.autoPlay}),o.children]})),props:{src:null,srcSet:null,bgColor:null,sizes:{width:0,height:0},nodeType:"void",fit:null,settings:{controls:!1,loop:!1,muted:!1,autoPlay:!1},provider:null},nodeType:"void"}),options:{accept:"video/*",maxSizes:{maxWidth:650,maxHeight:550},display:{title:"Video",description:"Upload from device, insert from Youtube, Vimeo, DailyMotion, Loom, Wistia"}},commands:d,parsers:{html:{deserialize:{nodeNames:["VIDEO"],parse:(e,t)=>{var n;if("VIDEO"===e.nodeName){const i=e.getAttribute("src"),r=e.getAttribute("srcset"),s=e.getAttribute("bgcolor"),l={width:e.getAttribute("width")?parseInt(e.getAttribute("width")||"650",10):650,height:e.getAttribute("height")?parseInt(e.getAttribute("height")||"500",10):500},a=null===(n=t.plugins.Image.options)||void 0===n?void 0:n.maxSizes,d=((e,t)=>{const o=u(e.width),n=u(e.height),i=u(t.width),r=u(t.height);if(o<=i&&n<=r)return{width:o,height:n};const s=o/i,l=n/r,a=Math.max(s,l),d=Math.round(o/a),c=Math.round(n/a);return{width:Math.min(d,i),height:Math.min(c,r)}})(l,{width:a.maxWidth,height:a.maxHeight}),c=e.getAttribute("controls"),p=e.getAttribute("loop"),g=e.getAttribute("muted"),m=e.getAttribute("autoplay"),h={src:i,srcSet:r,bgColor:s,sizes:d,fit:e.getAttribute("objectFit")||"cover",settings:{controls:!!c,loop:!!p,muted:!!g,autoPlay:!!m}};return{id:o(),type:"video",children:[{text:""}],props:h}}}},serialize:(e,t,o)=>{const{align:n="center",depth:i=0}=o||{};return`\n <div style="margin-left: ${20*i}px; display: flex; width: 100%; justify-content: ${c[n]||"center"};">\n <video data-meta-align="${n}" data-meta-depth="${i}" src="${e.props.src}" width="${e.props.sizes.width}" height="${e.props.sizes.height}" controls="${e.props.settings.controls}" loop="${e.props.settings.loop}" muted="${e.props.settings.muted}" autoplay="${e.props.settings.autoPlay}" style="margin: 0 auto;" objectFit="${e.props.fit}" />\n </div>`}},markdown:{serialize:e=>`\n`},email:{serialize:(e,t,o)=>{const{align:n="center",depth:i=0}=o||{};return`\n <table style="width: 100%;">\n <tbody style="width: 100%;">\n <tr>\n <td\n style="\n margin-left: ${i}px;\n display: flex;\n width: 100%;\n justify-content: ${c[n]||"center"};\n padding: 1rem 0rem;\n position: relative;\n "\n >\n <a\n href="${e.props.src}"\n target="_blank"\n rel="noreferrer noopener"\n style="\n position: relative;\n display: block;\n width: ${e.props.sizes.width}px;\n height: ${e.props.sizes.height}px;\n background-color: #999999;\n min-height: 300px;\n border-radius: 12px;\n border: none;\n overflow: hidden;\n "\n >\n <img\n data-meta-align="${n}"\n data-meta-depth="${i}"\n src="${e.props.poster}"\n width="${e.props.sizes.width}"\n height="${e.props.sizes.height}"\n objectfit="${e.props.fit}"\n alt="Poster"\n style="\n object-fit: ${e.props.fit};\n height: 100%;\n "\n />\n <span\n style="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n "\n >\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="50"\n height="50"\n >\n <circle cx="12" cy="12" r="10" fill="rgba(0, 0, 0, 0.6)" />\n <polygon points="10,8 16,12 10,16" fill="white" />\n </svg>\n </span>\n </a>\n </td>\n </tr>\n </tbody>\n </table>\n `}}}});function g(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{a(n.next(e))}catch(e){r(e)}}function l(e){try{a(n.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,l)}a((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const m=({onError:e,onSuccess:t,onProgress:o,accept:n,maxSize:i,method:r="POST",endpoint:d,headers:u})=>{const[c,p]=s({loading:!1,progress:null,error:null,result:null}),g=l(null),m=a(()=>{g.current&&(g.current.abort(),g.current=null)},[]),h=a(()=>{p({loading:!1,progress:null,error:null,result:null})},[]);return Object.assign(Object.assign({},c),{xhrFetch:s=>new Promise((l,a)=>{if(s instanceof File){const t=((e,t,o)=>{if(t&&!t.includes(e.type))return{message:`Invalid file type. Allowed types: ${t}`,code:"INVALID_TYPE"};if(o&&e.size>o)return{message:`File size exceeds ${(o/1024/1024).toFixed(2)}MB`,code:"FILE_TOO_LARGE"};return null})(s,n,i);if(t)return p(e=>Object.assign(Object.assign({},e),{error:t})),null==e||e(t),void a(t)}p({loading:!0,progress:{loaded:0,total:s instanceof File?s.size:0,percentage:0},error:null,result:null});const c=new XMLHttpRequest;g.current=c,c.upload.addEventListener("progress",e=>{if(e.lengthComputable){const t={loaded:e.loaded,total:e.total,percentage:Math.round(e.loaded/e.total*100)};p(e=>Object.assign(Object.assign({},e),{progress:t})),null==o||o(t)}}),c.addEventListener("load",()=>{if(c.status>=200&&c.status<300)try{const e=JSON.parse(c.responseText);p(t=>Object.assign(Object.assign({},t),{loading:!1,result:e})),null==t||t(e),l(e)}catch(t){const o={message:"Failed to parse server response",code:"PARSE_ERROR",status:c.status};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:o})),null==e||e(o),a(o)}else{const t={message:`Upload failed with status ${c.status}`,code:"HTTP_ERROR",status:c.status};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}}),c.addEventListener("error",()=>{const t={message:"Network error occurred",code:"NETWORK_ERROR"};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}),c.addEventListener("abort",()=>{const e={message:"Upload cancelled",code:"ABORT"};p(t=>Object.assign(Object.assign({},t),{loading:!1,error:e})),a(e)}),c.addEventListener("timeout",()=>{const t={message:"Upload timeout",code:"TIMEOUT"};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}),c.open(r,d),u&&Object.entries(u).forEach(([e,t])=>{c.setRequestHeader(e,t)}),c.timeout=3e5,c.send(s)}),cancel:m,reset:h})},h="https://yoopta.dev/docs/plugins/video",b=e=>{var t,o,n;(e=>{if(null==e)throw new Error(`[Yoopta Video] Delete options are not configured. Please provide 'delete' option when extending the Video plugin.\n\nExample:\nVideo.extend({\n options: {\n delete: async (element) => {\n // Delete file from your storage\n },\n },\n})\n\nSee documentation: ${h}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid delete options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in delete options. When using endpoint-based delete, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n delete: {\n endpoint: '/api/delete-video',\n },\n },\n})\n\nSee documentation: ${h}`)})(e);const i=e,r=(e=>"function"==typeof e)(i),[l,d]=s({loading:!1,progress:null,error:null,result:null}),u=r?{endpoint:""}:i,c=m({endpoint:u.endpoint,method:null!==(t=u.method)&&void 0!==t?t:"DELETE",headers:null!==(o=u.headers)&&void 0!==o?o:{},fieldName:null!==(n=u.fieldName)&&void 0!==n?n:"file",onSuccess:u.onSuccess,onError:u.onError,onProgress:u.onProgress}),p=a(e=>g(void 0,void 0,void 0,function*(){var t,o,n;if(!r)throw new Error("Custom delete called but options is not a function");const s=null===(t=e.props)||void 0===t?void 0:t.src;if(!s)throw new Error("Video src is required");d(e=>Object.assign(Object.assign({},e),{loading:!0,error:null}));try{yield i(e);const t={id:null!==(n=null===(o=e.props)||void 0===o?void 0:o.id)&&void 0!==n?n:"",url:s};return d(e=>Object.assign(Object.assign({},e),{loading:!1,result:t})),t}catch(e){const t={message:e instanceof Error?e.message:"Delete failed",code:"CUSTOM_DELETE_ERROR"};throw d(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[i,r]),b=a(()=>{d({loading:!1,progress:null,error:null,result:null})},[]),f=a(e=>{var t;const o=null===(t=e.props)||void 0===t?void 0:t.id;if(!o)throw new Error("Video id is required");return c.xhrFetch(JSON.stringify({fileId:o}))},[c]);return r?Object.assign(Object.assign({},l),{deleteVideo:p,cancel:()=>{},reset:b}):{loading:c.loading,progress:c.progress,error:c.error,result:c.result,deleteVideo:f,cancel:c.cancel,reset:c.reset}},f=e=>{var t,o,n,i;(e=>{if(null==e)throw new Error(`[Yoopta Video] Upload options are not configured. Please provide 'upload' option when extending the Video plugin.\n\nExample:\nVideo.extend({\n options: {\n upload: async (file) => {\n // Upload file to your storage and return video props\n return { id: '...', src: '...' };\n },\n },\n})\n\nSee documentation: ${h}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid upload options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in upload options. When using endpoint-based upload, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n upload: {\n endpoint: '/api/upload-video',\n },\n },\n})\n\nSee documentation: ${h}`)})(e);const r=e,l=(e=>"function"==typeof e)(r),[d,u]=s({loading:!1,progress:null,error:null,result:null}),c=l?{endpoint:""}:r,p=m({endpoint:c.endpoint,method:null!==(t=c.method)&&void 0!==t?t:"POST",headers:null!==(o=c.headers)&&void 0!==o?o:{},fieldName:null!==(n=c.fieldName)&&void 0!==n?n:"file",maxSize:c.maxSize,accept:null!==(i=c.accept)&&void 0!==i?i:"video/mp4, video/webm, video/ogg, video/quicktime",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),b=a(e=>g(void 0,void 0,void 0,function*(){var t,o,n,i;if(!l)throw new Error("Custom upload called but options is not a function");u(t=>Object.assign(Object.assign({},t),{loading:!0,progress:{loaded:0,total:e.size,percentage:0},error:null}));try{const s=e=>{u(t=>Object.assign(Object.assign({},t),{progress:e}))},l=yield r(e,s),a={id:null!==(t=l.id)&&void 0!==t?t:"",url:null!==(o=l.src)&&void 0!==o?o:"",poster:l.poster,width:"number"==typeof(null===(n=l.sizes)||void 0===n?void 0:n.width)?l.sizes.width:void 0,height:"number"==typeof(null===(i=l.sizes)||void 0===i?void 0:i.height)?l.sizes.height:void 0,provider:l.provider};return u(t=>Object.assign(Object.assign({},t),{loading:!1,progress:{loaded:e.size,total:e.size,percentage:100},result:a})),a}catch(e){const t={message:e instanceof Error?e.message:"Upload failed",code:"CUSTOM_UPLOAD_ERROR"};throw u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[r,l]),f=a(()=>{u({loading:!1,progress:null,error:null,result:null})},[]),v=a(e=>{var t;const o=new FormData;return o.append(null!==(t=c.fieldName)&&void 0!==t?t:"yoopta-video-file",e),p.xhrFetch(o)},[c.fieldName,p]);return l?Object.assign(Object.assign({},d),{upload:b,cancel:()=>{},reset:f}):{loading:p.loading,progress:p.progress,error:p.error,result:p.result,upload:v,cancel:p.cancel,reset:p.reset}},v=e=>{var t,o,n,i;(e=>{if(null==e)throw new Error(`[Yoopta Video] Poster upload options are not configured. Please provide 'uploadPoster' option when extending the Video plugin.\n\nExample:\nVideo.extend({\n options: {\n uploadPoster: async (file) => {\n // Upload poster image and return URL\n return 'https://...';\n },\n },\n})\n\nSee documentation: ${h}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid poster upload options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in poster upload options. When using endpoint-based upload, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n uploadPoster: {\n endpoint: '/api/upload-poster',\n },\n },\n})\n\nSee documentation: ${h}`)})(e);const r=e,l=(e=>"function"==typeof e)(r),[d,u]=s({loading:!1,progress:null,error:null,result:null}),c=l?{endpoint:""}:r,p=m({endpoint:c.endpoint,method:null!==(t=c.method)&&void 0!==t?t:"POST",headers:null!==(o=c.headers)&&void 0!==o?o:{},fieldName:null!==(n=c.fieldName)&&void 0!==n?n:"file",maxSize:c.maxSize,accept:null!==(i=c.accept)&&void 0!==i?i:"image/jpeg, image/jpg, image/png, image/gif, image/webp",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),b=a(e=>g(void 0,void 0,void 0,function*(){if(!l)throw new Error("Custom upload called but options is not a function");u(t=>Object.assign(Object.assign({},t),{loading:!0,progress:{loaded:0,total:e.size,percentage:0},error:null}));try{const t=e=>{u(t=>Object.assign(Object.assign({},t),{progress:e}))},o=yield r(e,t),n={id:"",url:o};return u(t=>Object.assign(Object.assign({},t),{loading:!1,progress:{loaded:e.size,total:e.size,percentage:100},result:n})),o}catch(e){const t={message:e instanceof Error?e.message:"Poster upload failed",code:"CUSTOM_UPLOAD_ERROR"};throw u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[r,l]),f=a(()=>{u({loading:!1,progress:null,error:null,result:null})},[]),v=a(e=>g(void 0,void 0,void 0,function*(){var t;const o=new FormData;o.append(null!==(t=c.fieldName)&&void 0!==t?t:"yoopta-poster-file",e);return(yield p.xhrFetch(o)).url}),[c.fieldName,p]);return l?Object.assign(Object.assign({},d),{uploadPoster:b,cancel:()=>{},reset:f}):{loading:p.loading,progress:p.progress,error:p.error,result:p.result,uploadPoster:v,cancel:p.cancel,reset:p.reset}},w=()=>({getDimensions:e=>new Promise((t,o)=>{const n=document.createElement("video"),i=URL.createObjectURL(e);n.onloadedmetadata=()=>{URL.revokeObjectURL(i),t({width:n.videoWidth,height:n.videoHeight,duration:n.duration})},n.onerror=()=>{URL.revokeObjectURL(i),o(new Error("Failed to load video"))},n.src=i})}),y=()=>{const[e,t]=s(null);return{preview:e,generatePreview:o=>{e&&URL.revokeObjectURL(e.url);const n={url:URL.createObjectURL(o)};return t(n),n},clearPreview:()=>{e&&(URL.revokeObjectURL(e.url),t(null))}}},O=e=>{const t=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=|shorts\/)([^#&?]*).*/);return t&&11===t[2].length?t[2]:null},j=e=>{try{const t=new URL(e).pathname.split("/").filter(Boolean);return"video"===t[0]?t[1]||null:t[0]||null}catch(e){return null}},E=e=>{const t=e.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);if(null!==t)return void 0!==t[4]?t[4]:t[2];const o=e.match(/dai\.ly\/([a-zA-Z0-9]+)/);return o?o[1]:null},x=e=>{try{const t=e.match(/(?:https?:\/\/)?(?:fast\.)?wistia\.(?:com|net)\/embed\/iframe\/([a-zA-Z0-9]+)/);if(t)return t[1];const o=e.match(/(?:https?:\/\/)?(?:www\.)?wistia\.com\/medias\/([a-zA-Z0-9]+)/);return o?o[1]:null}catch(e){return console.error("Error extracting Wistia ID:",e),null}},U=e=>{try{const t=e.match(/(?:https?:\/\/)?(?:www\.)?loom\.com\/(?:share|embed)\/([a-zA-Z0-9]+)/);return t?t[1]:null}catch(e){return console.error("Error extracting Loom ID:",e),null}};function $(e){return e.includes("youtube.com")||e.includes("youtu.be")?"youtube":e.includes("vimeo.com")?"vimeo":e.includes("dailymotion.com")||e.includes("dai.ly")?"dailymotion":e.includes("loom.com")?"loom":e.includes("wistia.com")||e.includes("wistia.net")?"wistia":null}const V={youtube:O,vimeo:j,dailymotion:E,loom:U,wistia:x},z=e=>`https://www.youtube.com/embed/${e}`,R=e=>`https://player.vimeo.com/video/${e}`,P=e=>`https://www.dailymotion.com/embed/video/${e}`,S=e=>`https://www.loom.com/embed/${e}`,L=e=>`https://fast.wistia.net/embed/iframe/${e}`,A={youtube:z,vimeo:R,dailymotion:P,loom:S,wistia:L},T=(e,t)=>{if(!e||!t)return null;const o=A[e];return o?o(t):null},I=(e,t="hq")=>`https://img.youtube.com/vi/${e}/${{default:"default",hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"}[t]}.jpg`,D=e=>`https://vumbnail.com/${e}.jpg`,k=e=>`https://www.dailymotion.com/thumbnail/video/${e}`,N=e=>`https://cdn.loom.com/sessions/thumbnails/${e}-with-play.gif`,F=e=>`https://fast.wistia.net/embed/medias/${e}/swatch`,M={youtube:I,vimeo:D,dailymotion:k,loom:N,wistia:F},_={youtube:{name:"YouTube",patterns:[/(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^&]+)/,/(?:https?:\/\/)?(?:www\.)?youtube\.com\/embed\/([^?]+)/,/(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^?]+)/,/(?:https?:\/\/)?youtu\.be\/([^?]+)/],getVideoId:O,getEmbedUrl:z,getThumbnailUrl:I},vimeo:{name:"Vimeo",patterns:[/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/,/(?:https?:\/\/)?player\.vimeo\.com\/video\/(\d+)/],getVideoId:j,getEmbedUrl:R,getThumbnailUrl:D},dailymotion:{name:"Dailymotion",patterns:[/(?:https?:\/\/)?(?:www\.)?dailymotion\.com\/video\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?dai\.ly\/([a-zA-Z0-9]+)/],getVideoId:E,getEmbedUrl:P,getThumbnailUrl:k},loom:{name:"Loom",patterns:[/(?:https?:\/\/)?(?:www\.)?loom\.com\/share\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?(?:www\.)?loom\.com\/embed\/([a-zA-Z0-9]+)/],getVideoId:U,getEmbedUrl:S,getThumbnailUrl:N},wistia:{name:"Wistia",patterns:[/(?:https?:\/\/)?(?:www\.)?wistia\.com\/medias\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?(?:fast\.)?wistia\.(?:com|net)\/embed\/iframe\/([a-zA-Z0-9]+)/],getVideoId:x,getEmbedUrl:L,getThumbnailUrl:F}},Y=e=>{const t=$(e);if(!t)return{provider:null,id:"",originalUrl:e,embedUrl:"",thumbnailUrl:void 0,isValid:!1};const o=V[t],n=o?o(e):null;if(!n)return{provider:t,id:"",originalUrl:e,embedUrl:"",thumbnailUrl:void 0,isValid:!1};const i=T(t,n)||"",r=((e,t)=>{if(!e||!t)return null;const o=M[e];return o?o(t):null})(t,n)||void 0;return{provider:t,id:n,originalUrl:e,embedUrl:i,thumbnailUrl:r,isValid:!0}},q=e=>Y(e).isValid,W=(e,t)=>{const o=Y(e);return o.provider===t&&o.isValid},Z=e=>{const t=Y(e);return t.isValid?{type:t.provider,id:t.id,url:t.originalUrl}:null},C=()=>Object.keys(_),B=e=>!!e&&e in _;export{d as VideoCommands,Z as buildVideoProvider,p as default,T as getEmbedUrl,$ as getProvider,C as getSupportedProviders,B as isProviderSupported,W as isProviderUrl,q as isValidVideoUrl,Y as parseVideoUrl,b as useVideoDelete,w as useVideoDimensions,v as useVideoPosterUpload,y as useVideoPreview,f as useVideoUpload};
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{generateId as o,Blocks as n,Elements as i,YooptaPlugin as r}from"@yoopta/editor";import{useState as s,useRef as l,useCallback as a}from"react";const d={buildVideoElements:(e,t={})=>{const n=Object.assign(Object.assign({},t.props),{nodeType:"void"});return{id:o(),type:"video",children:[{text:""}],props:n}},insertVideo:(e,t={})=>{const{at:o,focus:i,props:r}=t,s=d.buildVideoElements(e,{props:r}),l=n.buildBlockData({value:[s],type:"Video",meta:{align:"center",depth:0}});n.insertBlock(e,l.type,{focus:i,at:o,blockData:l})},deleteVideo:(e,t)=>{n.deleteBlock(e,{blockId:t})},updateVideo:(e,t,o)=>{i.updateElement(e,{blockId:t,type:"video",props:o})}},u=e=>"number"==typeof e?e:parseInt(e.replace(/[^\d]/g,""),10),c={left:"flex-start",center:"center",right:"flex-end"},p=new r({type:"Video",elements:e("video",{render:o=>t("div",Object.assign({},o.attributes,{children:[e("video",{src:o.element.props.src,width:o.element.props.sizes.width,height:o.element.props.sizes.height,objectFit:o.element.props.fit,controls:o.element.props.settings.controls,loop:o.element.props.settings.loop,muted:o.element.props.settings.muted,autoPlay:o.element.props.settings.autoPlay}),o.children]})),props:{src:null,srcSet:null,bgColor:null,sizes:{width:0,height:0},nodeType:"void",fit:null,settings:{controls:!1,loop:!1,muted:!1,autoPlay:!1},provider:null},nodeType:"void"}),options:{accept:"video/*",maxSizes:{maxWidth:650,maxHeight:550},display:{title:"Video",description:"Upload from device, insert from Youtube, Vimeo, DailyMotion, Loom, Wistia"}},commands:d,parsers:{html:{deserialize:{nodeNames:["VIDEO"],parse:(e,t)=>{var n;if("VIDEO"===e.nodeName){const i=e.getAttribute("src"),r=e.getAttribute("srcset"),s=e.getAttribute("bgcolor"),l={width:e.getAttribute("width")?parseInt(e.getAttribute("width")||"650",10):650,height:e.getAttribute("height")?parseInt(e.getAttribute("height")||"500",10):500},a=null===(n=t.plugins.Image.options)||void 0===n?void 0:n.maxSizes,d=((e,t)=>{const o=u(e.width),n=u(e.height),i=u(t.width),r=u(t.height);if(o<=i&&n<=r)return{width:o,height:n};const s=o/i,l=n/r,a=Math.max(s,l),d=Math.round(o/a),c=Math.round(n/a);return{width:Math.min(d,i),height:Math.min(c,r)}})(l,{width:a.maxWidth,height:a.maxHeight}),c=e.getAttribute("controls"),p=e.getAttribute("loop"),g=e.getAttribute("muted"),m=e.getAttribute("autoplay"),h={src:i,srcSet:r,bgColor:s,sizes:d,fit:e.getAttribute("objectFit")||"cover",settings:{controls:!!c,loop:!!p,muted:!!g,autoPlay:!!m}};return{id:o(),type:"video",children:[{text:""}],props:h}}}},serialize:(e,t,o)=>{const{align:n="center",depth:i=0}=o||{};return`\n <div style="margin-left: ${20*i}px; display: flex; width: 100%; justify-content: ${c[n]||"center"};">\n <video data-meta-align="${n}" data-meta-depth="${i}" src="${e.props.src}" width="${e.props.sizes.width}" height="${e.props.sizes.height}" controls="${e.props.settings.controls}" loop="${e.props.settings.loop}" muted="${e.props.settings.muted}" autoplay="${e.props.settings.autoPlay}" style="margin: 0 auto;" objectFit="${e.props.fit}" />\n </div>`}},markdown:{serialize:e=>`\n`},email:{serialize:(e,t,o)=>{const{align:n="center",depth:i=0}=o||{};return`\n <table style="width: 100%;">\n <tbody style="width: 100%;">\n <tr>\n <td\n style="\n margin-left: ${i}px;\n display: flex;\n width: 100%;\n justify-content: ${c[n]||"center"};\n padding: 1rem 0rem;\n position: relative;\n "\n >\n <a\n href="${e.props.src}"\n target="_blank"\n rel="noreferrer noopener"\n style="\n position: relative;\n display: block;\n width: ${e.props.sizes.width}px;\n height: ${e.props.sizes.height}px;\n background-color: #999999;\n min-height: 300px;\n border-radius: 12px;\n border: none;\n overflow: hidden;\n "\n >\n <img\n data-meta-align="${n}"\n data-meta-depth="${i}"\n src="${e.props.poster}"\n width="${e.props.sizes.width}"\n height="${e.props.sizes.height}"\n objectfit="${e.props.fit}"\n alt="Poster"\n style="\n object-fit: ${e.props.fit};\n height: 100%;\n "\n />\n <span\n style="\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n pointer-events: none;\n "\n >\n <svg\n xmlns="http://www.w3.org/2000/svg"\n viewBox="0 0 24 24"\n width="50"\n height="50"\n >\n <circle cx="12" cy="12" r="10" fill="rgba(0, 0, 0, 0.6)" />\n <polygon points="10,8 16,12 10,16" fill="white" />\n </svg>\n </span>\n </a>\n </td>\n </tr>\n </tbody>\n </table>\n `}}}});function g(e,t,o,n){return new(o||(o=Promise))(function(i,r){function s(e){try{a(n.next(e))}catch(e){r(e)}}function l(e){try{a(n.throw(e))}catch(e){r(e)}}function a(e){var t;e.done?i(e.value):(t=e.value,t instanceof o?t:new o(function(e){e(t)})).then(s,l)}a((n=n.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;const m=({onError:e,onSuccess:t,onProgress:o,accept:n,maxSize:i,method:r="POST",endpoint:d,headers:u})=>{const[c,p]=s({loading:!1,progress:null,error:null,result:null}),g=l(null),m=a(()=>{g.current&&(g.current.abort(),g.current=null)},[]),h=a(()=>{p({loading:!1,progress:null,error:null,result:null})},[]);return Object.assign(Object.assign({},c),{xhrFetch:s=>new Promise((l,a)=>{if(s instanceof File){const t=((e,t,o)=>{if(t&&!t.includes(e.type))return{message:`Invalid file type. Allowed types: ${t}`,code:"INVALID_TYPE"};if(o&&e.size>o)return{message:`File size exceeds ${(o/1024/1024).toFixed(2)}MB`,code:"FILE_TOO_LARGE"};return null})(s,n,i);if(t)return p(e=>Object.assign(Object.assign({},e),{error:t})),null==e||e(t),void a(t)}p({loading:!0,progress:{loaded:0,total:s instanceof File?s.size:0,percentage:0},error:null,result:null});const c=new XMLHttpRequest;g.current=c,c.upload.addEventListener("progress",e=>{if(e.lengthComputable){const t={loaded:e.loaded,total:e.total,percentage:Math.round(e.loaded/e.total*100)};p(e=>Object.assign(Object.assign({},e),{progress:t})),null==o||o(t)}}),c.addEventListener("load",()=>{if(c.status>=200&&c.status<300)try{const e=JSON.parse(c.responseText);p(t=>Object.assign(Object.assign({},t),{loading:!1,result:e})),null==t||t(e),l(e)}catch(t){const o={message:"Failed to parse server response",code:"PARSE_ERROR",status:c.status};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:o})),null==e||e(o),a(o)}else{const t={message:`Upload failed with status ${c.status}`,code:"HTTP_ERROR",status:c.status};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}}),c.addEventListener("error",()=>{const t={message:"Network error occurred",code:"NETWORK_ERROR"};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}),c.addEventListener("abort",()=>{const e={message:"Upload cancelled",code:"ABORT"};p(t=>Object.assign(Object.assign({},t),{loading:!1,error:e})),a(e)}),c.addEventListener("timeout",()=>{const t={message:"Upload timeout",code:"TIMEOUT"};p(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),null==e||e(t),a(t)}),c.open(r,d),u&&Object.entries(u).forEach(([e,t])=>{c.setRequestHeader(e,t)}),c.timeout=3e5,c.send(s)}),cancel:m,reset:h})},h="https://yoopta.dev/docs/plugins/video",b=e=>{var t,o,n;const i=(e=>{if(null==e)return!1;if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid delete options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in delete options. When using endpoint-based delete, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n delete: {\n endpoint: '/api/delete-video',\n },\n },\n})\n\nSee documentation: ${h}`);return!0})(e),r=i?e:null,l=!!r&&(e=>"function"==typeof e)(r),[d,u]=s({loading:!1,progress:null,error:null,result:null}),c=!r||l?{endpoint:""}:r,p=m({endpoint:c.endpoint,method:null!==(t=c.method)&&void 0!==t?t:"DELETE",headers:null!==(o=c.headers)&&void 0!==o?o:{},fieldName:null!==(n=c.fieldName)&&void 0!==n?n:"file",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),b=a(e=>g(void 0,void 0,void 0,function*(){var t,o,n,i,s,a,d;if(!r){const r=null!==(o=null===(t=e.props)||void 0===t?void 0:t.src)&&void 0!==o?o:"";return{id:null!==(i=null===(n=e.props)||void 0===n?void 0:n.id)&&void 0!==i?i:"",url:r}}if(!l)throw new Error("Custom delete called but options is not a function");const c=null===(s=e.props)||void 0===s?void 0:s.src;if(!c)throw new Error("Video src is required");u(e=>Object.assign(Object.assign({},e),{loading:!0,error:null}));try{yield r(e);const t={id:null!==(d=null===(a=e.props)||void 0===a?void 0:a.id)&&void 0!==d?d:"",url:c};return u(e=>Object.assign(Object.assign({},e),{loading:!1,result:t})),t}catch(e){const t={message:e instanceof Error?e.message:"Delete failed",code:"CUSTOM_DELETE_ERROR"};throw u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[r,l]),v=a(()=>{u({loading:!1,progress:null,error:null,result:null})},[]),f=a(e=>{var t;const o=null===(t=e.props)||void 0===t?void 0:t.id;if(!o)throw new Error("Video id is required");return p.xhrFetch(JSON.stringify({fileId:o}))},[p]);return i?l?Object.assign(Object.assign({},d),{deleteVideo:b,cancel:()=>{},reset:v}):{loading:p.loading,progress:p.progress,error:p.error,result:p.result,deleteVideo:f,cancel:p.cancel,reset:p.reset}:Object.assign(Object.assign({},d),{deleteVideo:b,cancel:()=>{},reset:v})},v=e=>{var t,o,n,i;(e=>{if(null==e)throw new Error(`[Yoopta Video] Upload options are not configured. Please provide 'upload' option when extending the Video plugin.\n\nExample:\nVideo.extend({\n options: {\n upload: async (file) => {\n // Upload file to your storage and return video props\n return { id: '...', src: '...' };\n },\n },\n})\n\nSee documentation: ${h}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid upload options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in upload options. When using endpoint-based upload, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n upload: {\n endpoint: '/api/upload-video',\n },\n },\n})\n\nSee documentation: ${h}`)})(e);const r=e,l=(e=>"function"==typeof e)(r),[d,u]=s({loading:!1,progress:null,error:null,result:null}),c=l?{endpoint:""}:r,p=m({endpoint:c.endpoint,method:null!==(t=c.method)&&void 0!==t?t:"POST",headers:null!==(o=c.headers)&&void 0!==o?o:{},fieldName:null!==(n=c.fieldName)&&void 0!==n?n:"file",maxSize:c.maxSize,accept:null!==(i=c.accept)&&void 0!==i?i:"video/mp4, video/webm, video/ogg, video/quicktime",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),b=a(e=>g(void 0,void 0,void 0,function*(){var t,o,n,i;if(!l)throw new Error("Custom upload called but options is not a function");u(t=>Object.assign(Object.assign({},t),{loading:!0,progress:{loaded:0,total:e.size,percentage:0},error:null}));try{const s=e=>{u(t=>Object.assign(Object.assign({},t),{progress:e}))},l=yield r(e,s),a={id:null!==(t=l.id)&&void 0!==t?t:"",url:null!==(o=l.src)&&void 0!==o?o:"",poster:l.poster,width:"number"==typeof(null===(n=l.sizes)||void 0===n?void 0:n.width)?l.sizes.width:void 0,height:"number"==typeof(null===(i=l.sizes)||void 0===i?void 0:i.height)?l.sizes.height:void 0,provider:l.provider};return u(t=>Object.assign(Object.assign({},t),{loading:!1,progress:{loaded:e.size,total:e.size,percentage:100},result:a})),a}catch(e){const t={message:e instanceof Error?e.message:"Upload failed",code:"CUSTOM_UPLOAD_ERROR"};throw u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[r,l]),v=a(()=>{u({loading:!1,progress:null,error:null,result:null})},[]),f=a(e=>{var t;const o=new FormData;return o.append(null!==(t=c.fieldName)&&void 0!==t?t:"yoopta-video-file",e),p.xhrFetch(o)},[c.fieldName,p]);return l?Object.assign(Object.assign({},d),{upload:b,cancel:()=>{},reset:v}):{loading:p.loading,progress:p.progress,error:p.error,result:p.result,upload:f,cancel:p.cancel,reset:p.reset}},f=e=>{var t,o,n,i;(e=>{if(null==e)throw new Error(`[Yoopta Video] Poster upload options are not configured. Please provide 'uploadPoster' option when extending the Video plugin.\n\nExample:\nVideo.extend({\n options: {\n uploadPoster: async (file) => {\n // Upload poster image and return URL\n return 'https://...';\n },\n },\n})\n\nSee documentation: ${h}`);if("function"!=typeof e&&"object"!=typeof e)throw new Error(`[Yoopta Video] Invalid poster upload options. Expected a function or endpoint configuration object.\n\nSee documentation: ${h}`);if("object"==typeof e&&!e.endpoint)throw new Error(`[Yoopta Video] Missing 'endpoint' in poster upload options. When using endpoint-based upload, you must provide an 'endpoint' URL.\n\nExample:\nVideo.extend({\n options: {\n uploadPoster: {\n endpoint: '/api/upload-poster',\n },\n },\n})\n\nSee documentation: ${h}`)})(e);const r=e,l=(e=>"function"==typeof e)(r),[d,u]=s({loading:!1,progress:null,error:null,result:null}),c=l?{endpoint:""}:r,p=m({endpoint:c.endpoint,method:null!==(t=c.method)&&void 0!==t?t:"POST",headers:null!==(o=c.headers)&&void 0!==o?o:{},fieldName:null!==(n=c.fieldName)&&void 0!==n?n:"file",maxSize:c.maxSize,accept:null!==(i=c.accept)&&void 0!==i?i:"image/jpeg, image/jpg, image/png, image/gif, image/webp",onSuccess:c.onSuccess,onError:c.onError,onProgress:c.onProgress}),b=a(e=>g(void 0,void 0,void 0,function*(){if(!l)throw new Error("Custom upload called but options is not a function");u(t=>Object.assign(Object.assign({},t),{loading:!0,progress:{loaded:0,total:e.size,percentage:0},error:null}));try{const t=e=>{u(t=>Object.assign(Object.assign({},t),{progress:e}))},o=yield r(e,t),n={id:"",url:o};return u(t=>Object.assign(Object.assign({},t),{loading:!1,progress:{loaded:e.size,total:e.size,percentage:100},result:n})),o}catch(e){const t={message:e instanceof Error?e.message:"Poster upload failed",code:"CUSTOM_UPLOAD_ERROR"};throw u(e=>Object.assign(Object.assign({},e),{loading:!1,error:t})),t}}),[r,l]),v=a(()=>{u({loading:!1,progress:null,error:null,result:null})},[]),f=a(e=>g(void 0,void 0,void 0,function*(){var t;const o=new FormData;o.append(null!==(t=c.fieldName)&&void 0!==t?t:"yoopta-poster-file",e);return(yield p.xhrFetch(o)).url}),[c.fieldName,p]);return l?Object.assign(Object.assign({},d),{uploadPoster:b,cancel:()=>{},reset:v}):{loading:p.loading,progress:p.progress,error:p.error,result:p.result,uploadPoster:f,cancel:p.cancel,reset:p.reset}},w=()=>({getDimensions:e=>new Promise((t,o)=>{const n=document.createElement("video"),i=URL.createObjectURL(e);n.onloadedmetadata=()=>{URL.revokeObjectURL(i),t({width:n.videoWidth,height:n.videoHeight,duration:n.duration})},n.onerror=()=>{URL.revokeObjectURL(i),o(new Error("Failed to load video"))},n.src=i})}),y=()=>{const[e,t]=s(null);return{preview:e,generatePreview:o=>{e&&URL.revokeObjectURL(e.url);const n={url:URL.createObjectURL(o)};return t(n),n},clearPreview:()=>{e&&(URL.revokeObjectURL(e.url),t(null))}}},O=e=>{const t=e.match(/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=|shorts\/)([^#&?]*).*/);return t&&11===t[2].length?t[2]:null},j=e=>{try{const t=new URL(e).pathname.split("/").filter(Boolean);return"video"===t[0]?t[1]||null:t[0]||null}catch(e){return null}},E=e=>{const t=e.match(/^.+dailymotion.com\/(video|hub)\/([^_]+)[^#]*(#video=([^_&]+))?/);if(null!==t)return void 0!==t[4]?t[4]:t[2];const o=e.match(/dai\.ly\/([a-zA-Z0-9]+)/);return o?o[1]:null},x=e=>{try{const t=e.match(/(?:https?:\/\/)?(?:fast\.)?wistia\.(?:com|net)\/embed\/iframe\/([a-zA-Z0-9]+)/);if(t)return t[1];const o=e.match(/(?:https?:\/\/)?(?:www\.)?wistia\.com\/medias\/([a-zA-Z0-9]+)/);return o?o[1]:null}catch(e){return console.error("Error extracting Wistia ID:",e),null}},U=e=>{try{const t=e.match(/(?:https?:\/\/)?(?:www\.)?loom\.com\/(?:share|embed)\/([a-zA-Z0-9]+)/);return t?t[1]:null}catch(e){return console.error("Error extracting Loom ID:",e),null}};function $(e){return e.includes("youtube.com")||e.includes("youtu.be")?"youtube":e.includes("vimeo.com")?"vimeo":e.includes("dailymotion.com")||e.includes("dai.ly")?"dailymotion":e.includes("loom.com")?"loom":e.includes("wistia.com")||e.includes("wistia.net")?"wistia":null}const z={youtube:O,vimeo:j,dailymotion:E,loom:U,wistia:x},V=e=>`https://www.youtube.com/embed/${e}`,R=e=>`https://player.vimeo.com/video/${e}`,P=e=>`https://www.dailymotion.com/embed/video/${e}`,S=e=>`https://www.loom.com/embed/${e}`,L=e=>`https://fast.wistia.net/embed/iframe/${e}`,A={youtube:V,vimeo:R,dailymotion:P,loom:S,wistia:L},T=(e,t)=>{if(!e||!t)return null;const o=A[e];return o?o(t):null},I=(e,t="hq")=>`https://img.youtube.com/vi/${e}/${{default:"default",hq:"hqdefault",mq:"mqdefault",sd:"sddefault",maxres:"maxresdefault"}[t]}.jpg`,k=e=>`https://vumbnail.com/${e}.jpg`,D=e=>`https://www.dailymotion.com/thumbnail/video/${e}`,N=e=>`https://cdn.loom.com/sessions/thumbnails/${e}-with-play.gif`,F=e=>`https://fast.wistia.net/embed/medias/${e}/swatch`,M={youtube:I,vimeo:k,dailymotion:D,loom:N,wistia:F},_={youtube:{name:"YouTube",patterns:[/(?:https?:\/\/)?(?:www\.)?youtube\.com\/watch\?v=([^&]+)/,/(?:https?:\/\/)?(?:www\.)?youtube\.com\/embed\/([^?]+)/,/(?:https?:\/\/)?(?:www\.)?youtube\.com\/shorts\/([^?]+)/,/(?:https?:\/\/)?youtu\.be\/([^?]+)/],getVideoId:O,getEmbedUrl:V,getThumbnailUrl:I},vimeo:{name:"Vimeo",patterns:[/(?:https?:\/\/)?(?:www\.)?vimeo\.com\/(\d+)/,/(?:https?:\/\/)?player\.vimeo\.com\/video\/(\d+)/],getVideoId:j,getEmbedUrl:R,getThumbnailUrl:k},dailymotion:{name:"Dailymotion",patterns:[/(?:https?:\/\/)?(?:www\.)?dailymotion\.com\/video\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?dai\.ly\/([a-zA-Z0-9]+)/],getVideoId:E,getEmbedUrl:P,getThumbnailUrl:D},loom:{name:"Loom",patterns:[/(?:https?:\/\/)?(?:www\.)?loom\.com\/share\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?(?:www\.)?loom\.com\/embed\/([a-zA-Z0-9]+)/],getVideoId:U,getEmbedUrl:S,getThumbnailUrl:N},wistia:{name:"Wistia",patterns:[/(?:https?:\/\/)?(?:www\.)?wistia\.com\/medias\/([a-zA-Z0-9]+)/,/(?:https?:\/\/)?(?:fast\.)?wistia\.(?:com|net)\/embed\/iframe\/([a-zA-Z0-9]+)/],getVideoId:x,getEmbedUrl:L,getThumbnailUrl:F}},Y=e=>{const t=$(e);if(!t)return{provider:null,id:"",originalUrl:e,embedUrl:"",thumbnailUrl:void 0,isValid:!1};const o=z[t],n=o?o(e):null;if(!n)return{provider:t,id:"",originalUrl:e,embedUrl:"",thumbnailUrl:void 0,isValid:!1};const i=T(t,n)||"",r=((e,t)=>{if(!e||!t)return null;const o=M[e];return o?o(t):null})(t,n)||void 0;return{provider:t,id:n,originalUrl:e,embedUrl:i,thumbnailUrl:r,isValid:!0}},q=e=>Y(e).isValid,W=(e,t)=>{const o=Y(e);return o.provider===t&&o.isValid},Z=e=>{const t=Y(e);return t.isValid?{type:t.provider,id:t.id,url:t.originalUrl}:null},C=()=>Object.keys(_),B=e=>!!e&&e in _;export{d as VideoCommands,Z as buildVideoProvider,p as default,T as getEmbedUrl,$ as getProvider,C as getSupportedProviders,B as isProviderSupported,W as isProviderUrl,q as isValidVideoUrl,Y as parseVideoUrl,b as useVideoDelete,w as useVideoDimensions,f as useVideoPosterUpload,y as useVideoPreview,v as useVideoUpload};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yoopta/video",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.9",
|
|
4
4
|
"description": "Video plugin for Yoopta Editor",
|
|
5
5
|
"author": "Darginec05 <devopsbanda@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/Darginec05/Yoopta-Editor#readme",
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/Darginec05/Yoopta-Editor/issues"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "4a55643c3f8ffc0d0373ff2643cf12099976c28e"
|
|
39
39
|
}
|