@nocobase/plugin-block-iframe 1.0.0-alpha.6 → 1.0.0-alpha.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.
@@ -7,8 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- (function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/shared"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","antd","react","react-i18next","@formily/shared","@ant-design/icons"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n["@nocobase/plugin-block-iframe"]={},n["@nocobase/client"],n.jsxRuntime,n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/shared"],n["@ant-design/icons"]))})(this,function(n,t,a,y,q,T,C,B,j){"use strict";var de=Object.defineProperty,pe=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var M=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var z=(n,t,a)=>t in n?de(n,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[t]=a,P=(n,t)=>{for(var a in t||(t={}))A.call(t,a)&&z(n,a,t[a]);if(M)for(var a of M(t))D.call(t,a)&&z(n,a,t[a]);return n},H=(n,t)=>pe(n,fe(t));var L=(n,t)=>{var a={};for(var y in n)A.call(n,y)&&t.indexOf(y)<0&&(a[y]=n[y]);if(n!=null&&M)for(var y of M(n))t.indexOf(y)<0&&D.call(n,y)&&(a[y]=n[y]);return a};var S=(n,t,a)=>new Promise((y,q)=>{var T=j=>{try{B(a.next(j))}catch(F){q(F)}},C=j=>{try{B(a.throw(j))}catch(F){q(F)}},B=j=>j.done?y(j.value):Promise.resolve(j.value).then(T,C);B((a=a.apply(n,t)).next())});function F(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}/*
10
+ (function(n,t){typeof exports=="object"&&typeof module!="undefined"?t(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/react"),require("antd"),require("react"),require("react-i18next"),require("@formily/shared"),require("@ant-design/icons")):typeof define=="function"&&define.amd?define(["exports","@nocobase/client","react/jsx-runtime","@formily/react","antd","react","react-i18next","@formily/shared","@ant-design/icons"],t):(n=typeof globalThis!="undefined"?globalThis:n||self,t(n["@nocobase/plugin-block-iframe"]={},n["@nocobase/client"],n.jsxRuntime,n["@formily/react"],n.antd,n.react,n["react-i18next"],n["@formily/shared"],n["@ant-design/icons"]))})(this,function(n,t,a,y,q,M,C,B,w){"use strict";var de=Object.defineProperty,pe=Object.defineProperties;var fe=Object.getOwnPropertyDescriptors;var T=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable;var G=(n,t,a)=>t in n?de(n,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):n[t]=a,P=(n,t)=>{for(var a in t||(t={}))A.call(t,a)&&G(n,a,t[a]);if(T)for(var a of T(t))D.call(t,a)&&G(n,a,t[a]);return n},H=(n,t)=>pe(n,fe(t));var L=(n,t)=>{var a={};for(var y in n)A.call(n,y)&&t.indexOf(y)<0&&(a[y]=n[y]);if(n!=null&&T)for(var y of T(n))t.indexOf(y)<0&&D.call(n,y)&&(a[y]=n[y]);return a};var S=(n,t,a)=>new Promise((y,q)=>{var M=w=>{try{B(a.next(w))}catch(F){q(F)}},C=w=>{try{B(a.throw(w))}catch(F){q(F)}},B=w=>w.done?y(w.value):Promise.resolve(w.value).then(M,C);B((a=a.apply(n,t)).next())});function F(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}/*
11
11
  object-assign
12
12
  (c) Sindre Sorhus
13
13
  @license MIT
14
- */var N=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;function V(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function J(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var l={},e=0;e<10;e++)l["_"+String.fromCharCode(e)]=e;var f=Object.getOwnPropertyNames(l).map(function(g){return l[g]});if(f.join("")!=="0123456789")return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(g){i[g]=g}),Object.keys(Object.assign({},i)).join("")==="abcdefghijklmnopqrst"}catch(g){return!1}}var K=J()?Object.assign:function(r,l){for(var e,f=V(r),i,g=1;g<arguments.length;g++){e=Object(arguments[g]);for(var b in e)R.call(e,b)&&(f[b]=e[b]);if(N){i=N(e);for(var m=0;m<i.length;m++)_.call(e,i[m])&&(f[i[m]]=e[i[m]])}}return f};const Q=F(K),W=({url:r,allowFullScreen:l,position:e,display:f,height:i,width:g,overflow:b,styles:m,onLoad:k,onMouseOver:O,onMouseOut:w,scrolling:c,id:s,frameBorder:u,ariaHidden:d,sandbox:h,allow:o,className:x,title:p,ariaLabel:re,ariaLabelledby:ne,name:oe,target:ie,loading:ae,importance:le,referrerpolicy:se,allowpaymentrequest:me,src:ce,key:ue})=>{const E=Q({src:ce||r,target:ie||null,style:{position:e||null,display:f||"initial",overflow:b||null},scrolling:c||null,allowpaymentrequest:me||null,importance:le||null,sandbox:h&&[...h].join(" ")||null,loading:ae||null,styles:m||null,name:oe||null,className:x||null,allowFullScreen:"allowFullScreen",referrerpolicy:se||null,title:p||null,allow:o||null,id:s||null,"aria-labelledby":ne||null,"aria-hidden":d||null,"aria-label":re||null,width:g||null,height:i||null,onLoad:k||null,onMouseOver:O||null,onMouseOut:w||null,key:ue||"iframe"});let I=Object.create(null);for(let v of Object.keys(E))E[v]!=null&&(I[v]=E[v]);for(let v of Object.keys(I.style))I.style[v]==null&&delete I.style[v];if(I.styles)for(let v of Object.keys(I.styles))I.styles.hasOwnProperty(v)&&(I.style[v]=I.styles[v]),Object.keys(I.styles).pop()==v&&delete I.styles;if(l)if("allow"in I){const v=I.allow.replace("fullscreen","");I.allow=`fullscreen ${v.trim()}`.trim()}else I.allow="fullscreen";return u>=0&&(I.style.hasOwnProperty("border")||(I.style.border=u)),T.createElement("iframe",Object.assign({},I))},X=()=>{const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:k="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),w=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return a.jsxs(t.GeneralSchemaDesigner,{children:[a.jsx(t.SchemaSettingsModalItem,{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:k};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:w}),a.jsx(t.SchemaSettingsDivider,{}),a.jsx(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};function $(r){return typeof r!="string"?!1:!isNaN(r)&&!isNaN(parseFloat(r))}const U=y.observer(r=>{const s=r,{url:l,htmlId:e,mode:f="url",height:i,html:g}=s,b=L(s,["url","htmlId","mode","height","html"]),m=y.useField(),{t:k}=C.useTranslation(),{loading:O,data:w}=t.useRequest({url:`iframeHtml:getHtml/${e}`},{refreshDeps:[e,m.data],ready:f==="html"&&!!e}),c=T.useMemo(()=>f==="html"?"data:text/html;charset=utf-8,"+encodeURIComponent(w):l,[w,f,l]);return f==="url"&&!l||f==="html"&&!e?a.jsx(q.Card,{style:{marginBottom:24},children:k("Please fill in the iframe URL")}):O?a.jsx("div",{style:{height:$(i)?`${i}px`:i,marginBottom:"24px",border:0},children:a.jsx(q.Spin,{})}):a.jsx(W,P({url:c,width:"100%",display:"block",position:"relative",styles:{height:$(i)?`${i}px`:i,marginBottom:"24px",border:0}},b))},{displayName:"Iframe"});U.Designer=X;const Y=()=>{const{insert:r}=t.useSchemaInitializer(),l=t.useSchemaInitializerItem();return a.jsx(t.SchemaInitializerItem,H(P({},l),{icon:a.jsx(j.FormOutlined,{}),onClick:()=>{r({type:"void","x-settings":"blockSettings:iframe","x-decorator":"BlockItem","x-decorator-props":{name:"iframe"},"x-component":"Iframe","x-component-props":{}})}}))},Z=r=>a.jsx(t.SchemaComponentOptions,{components:{Iframe:U,IframeBlockInitializer:Y},children:r.children}),ee=new t.SchemaSettings({name:"iframeBlockSchemaSettings",items:[{name:"EditIframe",type:"modal",useComponentProps(){const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:k="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),w=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:k};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:w}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),te=new t.SchemaSettings({name:"blockSettings:iframe",items:[{name:"EditIframe",type:"modal",useComponentProps(){const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:k="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),w=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:k};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:w}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]});class G extends t.Plugin{load(){return S(this,null,function*(){this.app.schemaSettingsManager.add(ee),this.app.schemaSettingsManager.add(te),this.app.use(Z);const l=this.app.schemaInitializerManager.get("page:addBlock");l==null||l.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const e=this.app.schemaInitializerManager.get("popup:addNew:addBlock");e==null||e.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const f=this.app.schemaInitializerManager.get("popup:common:addBlock");f==null||f.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const i=this.app.schemaInitializerManager.get("RecordFormBlockInitializers");i==null||i.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"})})}}n.PluginBlockIframeClient=G,n.default=G,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
14
+ */var N=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;function V(r){if(r==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(r)}function J(){try{if(!Object.assign)return!1;var r=new String("abc");if(r[5]="de",Object.getOwnPropertyNames(r)[0]==="5")return!1;for(var l={},e=0;e<10;e++)l["_"+String.fromCharCode(e)]=e;var f=Object.getOwnPropertyNames(l).map(function(g){return l[g]});if(f.join("")!=="0123456789")return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(g){i[g]=g}),Object.keys(Object.assign({},i)).join("")==="abcdefghijklmnopqrst"}catch(g){return!1}}var K=J()?Object.assign:function(r,l){for(var e,f=V(r),i,g=1;g<arguments.length;g++){e=Object(arguments[g]);for(var b in e)R.call(e,b)&&(f[b]=e[b]);if(N){i=N(e);for(var m=0;m<i.length;m++)_.call(e,i[m])&&(f[i[m]]=e[i[m]])}}return f};const Q=F(K),W=({url:r,allowFullScreen:l,position:e,display:f,height:i,width:g,overflow:b,styles:m,onLoad:j,onMouseOver:O,onMouseOut:k,scrolling:c,id:s,frameBorder:u,ariaHidden:d,sandbox:h,allow:o,className:x,title:p,ariaLabel:re,ariaLabelledby:ne,name:oe,target:ie,loading:ae,importance:le,referrerpolicy:se,allowpaymentrequest:me,src:ce,key:ue})=>{const E=Q({src:ce||r,target:ie||null,style:{position:e||null,display:f||"initial",overflow:b||null},scrolling:c||null,allowpaymentrequest:me||null,importance:le||null,sandbox:h&&[...h].join(" ")||null,loading:ae||null,styles:m||null,name:oe||null,className:x||null,allowFullScreen:"allowFullScreen",referrerpolicy:se||null,title:p||null,allow:o||null,id:s||null,"aria-labelledby":ne||null,"aria-hidden":d||null,"aria-label":re||null,width:g||null,height:i||null,onLoad:j||null,onMouseOver:O||null,onMouseOut:k||null,key:ue||"iframe"});let I=Object.create(null);for(let v of Object.keys(E))E[v]!=null&&(I[v]=E[v]);for(let v of Object.keys(I.style))I.style[v]==null&&delete I.style[v];if(I.styles)for(let v of Object.keys(I.styles))I.styles.hasOwnProperty(v)&&(I.style[v]=I.styles[v]),Object.keys(I.styles).pop()==v&&delete I.styles;if(l)if("allow"in I){const v=I.allow.replace("fullscreen","");I.allow=`fullscreen ${v.trim()}`.trim()}else I.allow="fullscreen";return u>=0&&(I.style.hasOwnProperty("border")||(I.style.border=u)),M.createElement("iframe",Object.assign({},I))},X=()=>{const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:j="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),k=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return a.jsxs(t.GeneralSchemaDesigner,{children:[a.jsx(t.SchemaSettingsModalItem,{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:j};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:k}),a.jsx(t.SchemaSettingsDivider,{}),a.jsx(t.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};function $(r){return typeof r!="string"?!1:!isNaN(r)&&!isNaN(parseFloat(r))}const z=y.observer(r=>{const s=r,{url:l,htmlId:e,mode:f="url",height:i,html:g}=s,b=L(s,["url","htmlId","mode","height","html"]),m=y.useField(),{t:j}=C.useTranslation(),{loading:O,data:k}=t.useRequest({url:`iframeHtml:getHtml/${e}`},{refreshDeps:[e,m.data],ready:f==="html"&&!!e}),c=M.useMemo(()=>f==="html"?"data:text/html;charset=utf-8,"+encodeURIComponent(k):l,[k,f,l]);return f==="url"&&!l||f==="html"&&!e?a.jsx(q.Card,{style:{marginBottom:24},children:j("Please fill in the iframe URL")}):O?a.jsx("div",{style:{height:$(i)?`${i}px`:i,marginBottom:"24px",border:0},children:a.jsx(q.Spin,{})}):a.jsx(W,P({url:c,width:"100%",display:"block",position:"relative",styles:{height:$(i)?`${i}px`:i,marginBottom:"24px",border:0}},b))},{displayName:"Iframe"});z.Designer=X;const Y=()=>{const{insert:r}=t.useSchemaInitializer(),l=t.useSchemaInitializerItem();return a.jsx(t.SchemaInitializerItem,H(P({},l),{icon:a.jsx(w.FormOutlined,{}),onClick:()=>{r({type:"void","x-settings":"blockSettings:iframe","x-decorator":"BlockItem","x-decorator-props":{name:"iframe"},"x-component":"Iframe","x-component-props":{}})}}))},Z=r=>a.jsx(t.SchemaComponentOptions,{components:{Iframe:z,IframeBlockInitializer:Y},children:r.children}),ee=new t.SchemaSettings({name:"iframeBlockSchemaSettings",items:[{name:"EditIframe",type:"modal",useComponentProps(){const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:j="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),k=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:j};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:k}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]}),te=new t.SchemaSettings({name:"blockSettings:iframe",items:[{name:"EditIframe",type:"modal",useComponentProps(){const r=y.useField(),l=y.useFieldSchema(),{t:e}=C.useTranslation(),{dn:f}=t.useDesignable(),i=t.useAPIClient(),{mode:g,url:b,htmlId:m,height:j="60vh"}=l["x-component-props"]||{},O=c=>S(this,null,function*(){var u,d,h,o,x;const s={values:{html:c}};if(m){const{data:p}=yield(d=(u=i.resource("iframeHtml")).update)==null?void 0:d.call(u,H(P({},s),{filterByTk:m}));return((h=p==null?void 0:p.data)==null?void 0:h[0])||{id:m}}else{const{data:p}=yield(x=(o=i.resource("iframeHtml")).create)==null?void 0:x.call(o,s);return p==null?void 0:p.data}}),k=h=>S(this,[h],function*({mode:c,url:s,html:u,height:d}){const o=l["x-component-props"]||{};if(o.mode=c,o.height=d,o.url=s,c==="html"){const x=yield O(u);o.htmlId=x.id}l["x-component-props"]=o,r.componentProps=P({},o),r.data={v:B.uid()},f.emit("patch",{schema:{"x-uid":l["x-uid"],"x-component-props":o}})});return{title:e("Edit iframe"),asyncGetInitialValues:()=>S(this,null,function*(){var s,u,d;const c={mode:g,url:b,height:j};if(m){const{data:h}=yield(u=(s=i.resource("iframeHtml")).get)==null?void 0:u.call(s,{filterByTk:m});c.html=((d=h==null?void 0:h.data)==null?void 0:d.html)||""}return c}),schema:{type:"object",title:e("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:e("URL")},{value:"html",label:e("html")}]},url:{title:e("URL"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},html:{title:e("html"),type:"string","x-decorator":"FormItem","x-component":"Input.TextArea",required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:e("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:k}}},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]});class U extends t.Plugin{load(){return S(this,null,function*(){this.app.schemaSettingsManager.add(ee),this.app.schemaSettingsManager.add(te),this.app.use(Z);const l=this.app.schemaInitializerManager.get("page:addBlock");l==null||l.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const e=this.app.schemaInitializerManager.get("popup:addNew:addBlock");e==null||e.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const f=this.app.schemaInitializerManager.get("popup:common:addBlock");f==null||f.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const i=this.app.schemaInitializerManager.get("RecordFormBlockInitializers");i==null||i.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobilePage:addBlock","otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"})})}}n.PluginBlockIframeClient=U,n.default=U,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -10,12 +10,12 @@
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.0",
12
12
  "@formily/shared": "2.3.0",
13
- "@nocobase/client": "1.0.0-alpha.6",
13
+ "@nocobase/client": "1.0.0-alpha.9",
14
14
  "react": "18.2.0",
15
15
  "react-i18next": "11.18.6",
16
16
  "antd": "5.12.8",
17
17
  "@ant-design/icons": "5.2.6",
18
- "@nocobase/server": "1.0.0-alpha.6",
19
- "@nocobase/actions": "1.0.0-alpha.6",
20
- "@nocobase/database": "1.0.0-alpha.6"
18
+ "@nocobase/server": "1.0.0-alpha.9",
19
+ "@nocobase/actions": "1.0.0-alpha.9",
20
+ "@nocobase/database": "1.0.0-alpha.9"
21
21
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "区块:iframe",
5
5
  "description": "Create an iframe block on the page to embed and display external web pages or content.",
6
6
  "description.zh-CN": "在页面上创建和管理iframe,用于嵌入和展示外部网页或内容。",
7
- "version": "1.0.0-alpha.6",
7
+ "version": "1.0.0-alpha.9",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/block-iframe",
@@ -25,7 +25,7 @@
25
25
  "@nocobase/server": "1.x",
26
26
  "@nocobase/test": "1.x"
27
27
  },
28
- "gitHead": "cbba77fb83a4ee114002234a15d339054b092de8",
28
+ "gitHead": "562d6ae965317098df05db756d160e03363dcec5",
29
29
  "keywords": [
30
30
  "Blocks"
31
31
  ]