@paroicms/platform-video-plugin 0.37.1 → 0.37.2
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
import{delegateEvents as D,template as p,insert as s,createComponent as g,effect as h,setAttribute as $,memo as U,className as E}from"https://esm.sh/solid-js@1.9.9/web";import{createMemo as T,createSignal as m,createEffect as I,Show as b,createRoot as _}from"https://esm.sh/solid-js@1.9.9";function k(e){return typeof e=="object"&&e!==null&&"j"in e}const S=/^(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)?([a-zA-Z0-9_-]{11})$/;function L(e){return`https://i.ytimg.com/vi/${e}/default.jpg`}function R(e){const t=e.match(S);if(t?.[1])return t[1]}const j=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function w(e,t,i){for(const[o,n]of Object.entries(t)){const d=`${i}.${o}`;e[d]=n,j(n)&&w(e,n,d)}}function B(e){const t={...e};for(const[i,o]of Object.entries(e))j(o)&&w(t,o,i);return t}const O=e=>e;function Y(e,t=O){return(i,...o)=>{i[0]==="."&&(i=i.slice(1));const n=e()?.[i];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const x={placeholder:"Fügen Sie hier die Video-URL oder -ID ein…",identifier:"Bezeichner:",invalid:"Ungültige YouTube-Video-URL"},M={title:"Ein Video auswählen",done:"Fertig"},A={VideoInput:x,VideoDialog:M},F={placeholder:"Paste the video URL or ID here…",identifier:"Identifier:",invalid:"Invalid youtube video URL"},H={title:"Choose a video",done:"Done"},z={VideoInput:F,VideoDialog:H},q={placeholder:"Pegue aquí la URL o ID del video…",identifier:"Identificador:",invalid:"URL de video de YouTube inválida"},G={title:"Elegir un video",done:"Hecho"},J={VideoInput:q,VideoDialog:G},N={placeholder:"Collez ici l'URL ou l'identifiant de la vidéo…",identifier:"Identifiant :",invalid:"L'URL de la video Youtube est invalide"},Z={title:"Choisir une vidéo",done:"Terminé"},K={VideoInput:N,VideoDialog:Z},Q={placeholder:"Incolla qui l'URL o l'ID del video…",identifier:"Identificatore:",invalid:"URL del video YouTube non valido"},W={title:"Scegli un video",done:"Fatto"},X={VideoInput:Q,VideoDialog:W},ee={placeholder:"Cole aqui a URL ou ID do vídeo…",identifier:"Identificador:",invalid:"URL de vídeo do YouTube inválida"},te={title:"Escolher um vídeo",done:"Concluído"},ie={VideoInput:ee,VideoDialog:te},y={en:z,fr:K,es:J,de:A,it:X,pt:ie};function C(e){const t=T(()=>{const o=e()in y?e():"en";return B(y[o])});return{t:Y(t)}}var oe=p("<small class=BPVideoInput-errorMessage>"),ne=p("<p> <strong>"),re=p('<iframe class=BPVideoInput-iframe width=420 height=315 title="youtube video">'),de=p("<div class=BPVideoInput><label class=BPVideoInput-inputGroup><input type=text>");function P({value:e,language:t,setValue:i}){const{t:o}=C(t),[n,d]=m(),[u,a]=m();return I(()=>{d(e()?.videoId??"")}),I(()=>{a(void 0);const l=n()?.trim();if(!l){i(void 0);return}const f=R(l);if(!f){a(o("VideoInput.invalid"));return}i({videoId:f,platform:"youtube"})}),(()=>{var l=de(),f=l.firstChild,c=f.firstChild;return c.$$input=r=>d(r.currentTarget.value),s(f,g(b,{get when(){return u()},get children(){var r=oe();return s(r,u),r}}),null),s(l,g(b,{get when(){return U(()=>!!e()?.videoId)()&&n()},get children(){return[(()=>{var r=ne(),v=r.firstChild,V=v.nextSibling;return s(r,()=>o("VideoInput.identifier"),v),s(V,()=>e()?.videoId),r})(),(()=>{var r=re();return h(()=>$(r,"src",`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e()?.videoId)}`)),r})()]}}),null),h(r=>{var v=`BPVideoInput-input ${u()?"invalid":""}`,V=o("VideoInput.placeholder");return v!==r.e&&E(c,r.e=v),V!==r.t&&$(c,"placeholder",r.t=V),r},{e:void 0,t:void 0}),h(()=>c.value=n()),l})()}D(["input"]);var le=p("<div><button class=VPDialog-button type=button>"),ue=p("<button class=VPDialog-button type=button>"),ae=p("<img width=100% alt>"),ce=p("<span>");function se({service:e,setValue:t,value:i,language:o}){const{t:n}=C(o),d=e.createModalDialog({content:g(P,{language:o,value:i,setValue:t}),footer:(()=>{var u=le(),a=u.firstChild;return a.$$click=()=>{d.hide()},s(a,()=>n("VideoDialog.done")),u})(),header:n("VideoDialog.title")});return(()=>{var u=ue();return u.$$click=()=>d.show(),s(u,(()=>{var a=U(()=>!!i()?.videoId);return()=>a()?(()=>{var l=ae();return h(()=>$(l,"src",L(i()?.videoId))),l})():(()=>{var l=ce();return s(l,()=>n("VideoDialog.title")),l})()})()),u})()}D(["click"]);const he={create:ge,init:ve};function pe(e){e.executeHook("htmlEditorServiceProvider").forEach(i=>{i.registerVideoPlugin(fe())})}function fe(){return{getThumbnailUrl(e){return L(e.videoId)},recognizeUrl(e){const t=R(e);if(t)return{videoId:t,platform:"youtube"}},createComponent(e,t){const[i,o]=m(e);return _(n=>({dispose:n,element:g(P,{get language(){return t.getLanguage},value:i,setValue:d=>{d!==void 0&&(t.onChange(d??null),o(d))}})}))}}}function ve(e){const t=`${e.pluginBaseUrl}/admin-ui-plugin.css`,i=document.createElement("link");i.rel="stylesheet",i.href=t,document.head.appendChild(i),e.addAfterInitListener(pe)}function ge(e){const{fieldType:t,setModifiedValue:i,initialValue:o}=e;if(t.dataType!=="json")throw new Error(`field type '${t.name}' is incompatible with video plugin, needs data type 'json'`);if(o!==void 0&&!k(o))throw new Error(`field type '${t.name}' is incompatible, should be a json, got '${typeof o}'`);return _(n=>{const d=o?o.j:void 0,[u,a]=m(d),[l,f]=m(e.language);return{element:g(se,{language:l,value:u,setValue:c=>{a(c),i(c?{j:c}:null)},service:e}),setLanguage:f,setValue(c){a(c===void 0?void 0:c.j)},getValue(){return{j:u()}},dispose:n}})}export{he as default};
|
|
1
|
+
import{delegateEvents as D,template as p,insert as s,createComponent as g,effect as h,setAttribute as $,memo as U,className as E}from"https://esm.sh/solid-js@1.9.9/web";import{createMemo as T,createSignal as m,createEffect as I,Show as b,createRoot as _}from"https://esm.sh/solid-js@1.9.9";function k(e){return typeof e=="object"&&e!==null&&"j"in e}const S=/^(?:https?:\/\/)?(?:(?:www|m)\.)?(?:youtube\.com\/(?:[^/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)?([a-zA-Z0-9_-]{11})$/;function L(e){return`https://i.ytimg.com/vi/${e}/default.jpg`}function R(e){const t=e.match(S);if(t?.[1])return t[1]}const j=e=>e!=null&&(e=Object.getPrototypeOf(e),e===Array.prototype||e===Object.prototype);function w(e,t,i){for(const[o,n]of Object.entries(t)){const d=`${i}.${o}`;e[d]=n,j(n)&&w(e,n,d)}}function B(e){const t={...e};for(const[i,o]of Object.entries(e))j(o)&&w(t,o,i);return t}const O=e=>e;function Y(e,t=O){return(i,...o)=>{i[0]==="."&&(i=i.slice(1));const n=e()?.[i];switch(typeof n){case"function":return n(...o);case"string":return t(n,o[0]);default:return n}}}const x={placeholder:"Fügen Sie hier die Video-URL oder -ID ein…",identifier:"Bezeichner:",invalid:"Ungültige YouTube-Video-URL"},M={title:"Ein Video auswählen",done:"Fertig"},A={VideoInput:x,VideoDialog:M},F={placeholder:"Paste the video URL or ID here…",identifier:"Identifier:",invalid:"Invalid youtube video URL"},H={title:"Choose a video",done:"Done"},z={VideoInput:F,VideoDialog:H},q={placeholder:"Pegue aquí la URL o ID del video…",identifier:"Identificador:",invalid:"URL de video de YouTube inválida"},G={title:"Elegir un video",done:"Hecho"},J={VideoInput:q,VideoDialog:G},N={placeholder:"Collez ici l'URL ou l'identifiant de la vidéo…",identifier:"Identifiant :",invalid:"L'URL de la video Youtube est invalide"},Z={title:"Choisir une vidéo",done:"Terminé"},K={VideoInput:N,VideoDialog:Z},Q={placeholder:"Incolla qui l'URL o l'ID del video…",identifier:"Identificatore:",invalid:"URL del video YouTube non valido"},W={title:"Scegli un video",done:"Fatto"},X={VideoInput:Q,VideoDialog:W},ee={placeholder:"Cole aqui a URL ou ID do vídeo…",identifier:"Identificador:",invalid:"URL de vídeo do YouTube inválida"},te={title:"Escolher um vídeo",done:"Concluído"},ie={VideoInput:ee,VideoDialog:te},y={en:z,fr:K,es:J,de:A,it:X,pt:ie};function C(e){const t=T(()=>{const o=e()in y?e():"en";return B(y[o])});return{t:Y(t)}}var oe=p("<small class=BPVideoInput-errorMessage>"),ne=p("<p> <strong>"),re=p('<iframe class=BPVideoInput-iframe width=420 height=315 title="youtube video">'),de=p("<div class=BPVideoInput><label class=BPVideoInput-inputGroup><input type=text>");function P({value:e,language:t,setValue:i}){const{t:o}=C(t),[n,d]=m(),[u,a]=m();return I(()=>{d(e()?.videoId??"")}),I(()=>{a(void 0);const l=n()?.trim();if(!l){i(void 0);return}const f=R(l);if(!f){a(o("VideoInput.invalid"));return}i({videoId:f,platform:"youtube"})}),(()=>{var l=de(),f=l.firstChild,c=f.firstChild;return c.$$input=r=>d(r.currentTarget.value),s(f,g(b,{get when(){return u()},get children(){var r=oe();return s(r,u),r}}),null),s(l,g(b,{get when(){return U(()=>!!e()?.videoId)()&&n()},get children(){return[(()=>{var r=ne(),v=r.firstChild,V=v.nextSibling;return s(r,()=>o("VideoInput.identifier"),v),s(V,()=>e()?.videoId),r})(),(()=>{var r=re();return h(()=>$(r,"src",`https://www.youtube-nocookie.com/embed/${encodeURIComponent(e()?.videoId)}`)),r})()]}}),null),h(r=>{var v=`BPVideoInput-input ${u()?"invalid":""}`,V=o("VideoInput.placeholder");return v!==r.e&&E(c,r.e=v),V!==r.t&&$(c,"placeholder",r.t=V),r},{e:void 0,t:void 0}),h(()=>c.value=n()),l})()}D(["input"]);var le=p("<div><button class=VPDialog-button type=button>"),ue=p("<button class=VPDialog-button type=button>"),ae=p("<img width=100% alt>"),ce=p("<span>");function se({service:e,setValue:t,value:i,language:o}){const{t:n}=C(o),d=e.createModalDialog({content:g(P,{language:o,value:i,setValue:t}),footer:(()=>{var u=le(),a=u.firstChild;return a.$$click=()=>{d.hide()},s(a,()=>n("VideoDialog.done")),u})(),header:n("VideoDialog.title")});return(()=>{var u=ue();return u.$$click=()=>d.show(),s(u,(()=>{var a=U(()=>!!i()?.videoId);return()=>a()?(()=>{var l=ae();return h(()=>$(l,"src",L(i()?.videoId))),l})():(()=>{var l=ce();return s(l,()=>n("VideoDialog.title")),l})()})()),u})()}D(["click"]);const he={create:ge,init:ve};function pe(e){e.executeHook("htmlEditorServiceProvider").forEach(i=>{i.registerVideoPlugin(fe())})}function fe(){return{getThumbnailUrl(e){return L(e.videoId)},recognizeUrl(e){const t=R(e);if(t)return{videoId:t,platform:"youtube"}},createComponent(e,t){const[i,o]=m(e);return _(n=>({dispose:n,element:g(P,{get language(){return t.getLanguage},value:i,setValue:d=>{d!==void 0&&(t.onChange(d??null),o(d))}})}))}}}function ve(e){const t=`${e.pluginBaseUrl}/admin-ui-plugin.css`,i=document.createElement("link");i.rel="stylesheet",i.href=t,document.head.appendChild(i),e.addAfterInitListener(pe)}function ge(e){const{fieldType:t,setModifiedValue:i,initialValue:o}=e;if(t.dataType!=="json")throw new Error(`field type '${t.name}' is incompatible with video plugin, needs data type 'json'`);if(o!==void 0&&!k(o))throw new Error(`field type '${t.name}' is incompatible, should be a json, got '${typeof o}'`);return _(n=>{const d=o?o.j:void 0,[u,a]=m(d),[l,f]=m(e.language);return{element:g(se,{language:l,value:u,setValue:c=>{a(c),i(c?{j:c}:null)},service:e}),setLanguage:f,setValue(c){a(c===void 0?void 0:c.j)},getValue(){return{j:u()}},dispose:n}})}export{he as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paroicms/platform-video-plugin",
|
|
3
|
-
"version": "0.37.
|
|
3
|
+
"version": "0.37.2",
|
|
4
4
|
"description": "Platform video plugin (Youtube) for ParoiCMS",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"paroicms",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@paroicms/public-anywhere-lib": "0.37.1",
|
|
36
|
-
"@paroicms/public-server-lib": "0.47.
|
|
36
|
+
"@paroicms/public-server-lib": "0.47.2",
|
|
37
37
|
"rimraf": "~6.0.1",
|
|
38
38
|
"typescript": "~5.9.3"
|
|
39
39
|
},
|