@nocobase/plugin-block-iframe 1.3.0-alpha.20240807100243 → 1.3.0-alpha.20240814073548
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/client/index.js +2 -2
- package/dist/externalVersion.js +5 -4
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
(function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/antd-v5"),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/antd-v5","@formily/react","antd","react","react-i18next","@formily/shared","@ant-design/icons"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-block-iframe"]={},r["@nocobase/client"],r.jsxRuntime,r["@formily/antd-v5"],r["@formily/react"],r.antd,r.react,r["react-i18next"],r["@formily/shared"],r["@ant-design/icons"]))})(this,function(r,e,n,
|
|
10
|
+
(function(r,e){typeof exports=="object"&&typeof module!="undefined"?e(exports,require("@nocobase/client"),require("react/jsx-runtime"),require("@formily/antd-v5"),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/antd-v5","@formily/react","antd","react","react-i18next","@formily/shared","@ant-design/icons"],e):(r=typeof globalThis!="undefined"?globalThis:r||self,e(r["@nocobase/plugin-block-iframe"]={},r["@nocobase/client"],r.jsxRuntime,r["@formily/antd-v5"],r["@formily/react"],r.antd,r.react,r["react-i18next"],r["@formily/shared"],r["@ant-design/icons"]))})(this,function(r,e,n,S,j,E,N,q,B,z){"use strict";var he=Object.defineProperty,ge=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var K=Object.prototype.hasOwnProperty,Q=Object.prototype.propertyIsEnumerable;var J=(r,e,n)=>e in r?he(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,O=(r,e)=>{for(var n in e||(e={}))K.call(e,n)&&J(r,n,e[n]);if(U)for(var n of U(e))Q.call(e,n)&&J(r,n,e[n]);return r},L=(r,e)=>ge(r,ye(e));var X=(r,e)=>{var n={};for(var S in r)K.call(r,S)&&e.indexOf(S)<0&&(n[S]=r[S]);if(r!=null&&U)for(var S of U(r))e.indexOf(S)<0&&Q.call(r,S)&&(n[S]=r[S]);return n};var H=(r,e,n)=>new Promise((S,j)=>{var E=B=>{try{q(n.next(B))}catch(z){j(z)}},N=B=>{try{q(n.throw(B))}catch(z){j(z)}},q=B=>B.done?S(B.value):Promise.resolve(B.value).then(E,N);q((n=n.apply(r,e)).next())});function Y(o){return o&&o.__esModule&&Object.prototype.hasOwnProperty.call(o,"default")?o.default:o}/*
|
|
11
11
|
object-assign
|
|
12
12
|
(c) Sindre Sorhus
|
|
13
13
|
@license MIT
|
|
14
|
-
*/var G=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;function te(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function re(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var s={},t=0;t<10;t++)s["_"+String.fromCharCode(t)]=t;var l=Object.getOwnPropertyNames(s).map(function(f){return s[f]});if(l.join("")!=="0123456789")return!1;var i={};return"abcdefghijklmnopqrst".split("").forEach(function(f){i[f]=f}),Object.keys(Object.assign({},i)).join("")==="abcdefghijklmnopqrst"}catch(f){return!1}}var ne=re()?Object.assign:function(o,s){for(var t,l=te(o),i,f=1;f<arguments.length;f++){t=Object(arguments[f]);for(var S in t)Z.call(t,S)&&(l[S]=t[S]);if(G){i=G(t);for(var g=0;g<i.length;g++)ee.call(t,i[g])&&(l[i[g]]=t[i[g]])}}return l};const oe=Y(ne),ae=({url:o,allowFullScreen:s,position:t,display:l,height:i,width:f,overflow:S,styles:g,onLoad:k,onMouseOver:T,onMouseOut:q,scrolling:b,id:H,frameBorder:B,ariaHidden:C,sandbox:m,allow:d,className:p,title:u,ariaLabel:c,ariaLabelledby:v,name:y,target:a,loading:A,importance:$,referrerpolicy:V,allowpaymentrequest:ue,src:pe,key:fe})=>{const D=oe({src:pe||o,target:a||null,style:{position:t||null,display:l||"initial",overflow:S||null},scrolling:b||null,allowpaymentrequest:ue||null,importance:$||null,sandbox:m&&[...m].join(" ")||null,loading:A||null,styles:g||null,name:y||null,className:p||null,allowFullScreen:"allowFullScreen",referrerpolicy:V||null,title:u||null,allow:d||null,id:H||null,"aria-labelledby":v||null,"aria-hidden":C||null,"aria-label":c||null,width:f||null,height:i||null,onLoad:k||null,onMouseOver:T||null,onMouseOut:q||null,key:fe||"iframe"});let h=Object.create(null);for(let x of Object.keys(D))D[x]!=null&&(h[x]=D[x]);for(let x of Object.keys(h.style))h.style[x]==null&&delete h.style[x];if(h.styles)for(let x of Object.keys(h.styles))h.styles.hasOwnProperty(x)&&(h.style[x]=h.styles[x]),Object.keys(h.styles).pop()==x&&delete h.styles;if(s)if("allow"in h){const x=h.allow.replace("fullscreen","");h.allow=`fullscreen ${x.trim()}`.trim()}else h.allow="fullscreen";return B>=0&&(h.style.hasOwnProperty("border")||(h.style.border=B)),L.createElement("iframe",Object.assign({},h))},se=()=>{const o=O.useField(),s=O.useFieldSchema(),{t}=F.useTranslation(),{dn:l}=e.useDesignable(),i=e.useAPIClient(),{mode:f,url:S,htmlId:g,height:k="60vh",engine:T}=s["x-component-props"]||{},q=m=>P(this,null,function*(){var p,u,c,v,y;const d={values:{html:m}};if(g){const{data:a}=yield(u=(p=i.resource("iframeHtml")).update)==null?void 0:u.call(p,M(w({},d),{filterByTk:g}));return((c=a==null?void 0:a.data)==null?void 0:c[0])||{id:g}}else{const{data:a}=yield(y=(v=i.resource("iframeHtml")).create)==null?void 0:y.call(v,d);return a==null?void 0:a.data}}),b=v=>P(this,[v],function*({mode:m,url:d,html:p,height:u,engine:c}){const y=s["x-component-props"]||{};if(y.mode=m,y.height=u,y.url=d,y.engine=c||"string",m==="html"){const a=yield q(p);y.htmlId=a.id}s["x-component-props"]=y,o.componentProps=w({},y),o.data={v:j.uid()},l.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":y}})}),{form:H}=e.useFormBlockContext(),B=e.useRecord(),C=e.useVariableOptions({collectionField:{uiSchema:s},form:H,record:B,uiSchema:s,noDisabled:!0});return n.jsxs(e.GeneralSchemaDesigner,{children:[n.jsx(e.SchemaSettingsModalItem,{title:t("Edit iframe"),asyncGetInitialValues:()=>P(this,null,function*(){var d,p,u;const m={mode:f,url:S,height:k};if(g){const{data:c}=yield(p=(d=i.resource("iframeHtml")).get)==null?void 0:p.call(d,{filterByTk:g});m.html=((u=c==null?void 0:c.data)==null?void 0:u.html)||""}return m}),schema:{type:"object",title:t("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:t("URL")},{value:"html",label:t("HTML")}]},url:{title:t("URL"),type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:C},required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},engine:{title:'{{t("Template engine")}}',"x-component":"Radio.Group","x-decorator":"FormItem",enum:[{value:"string",label:t("String template")},{value:"handlebars",label:t("Handlebars")}],"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},html:{title:t("html"),type:"string","x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:C,style:{minHeight:"200px"}},required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:t("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:b}),n.jsx(e.SchemaSettingsDivider,{}),n.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};function U(o){return typeof o!="string"?!1:!isNaN(o)&&!isNaN(parseFloat(o))}const R=O.observer(o=>{const v=o,{url:s,htmlId:t,mode:l="url",height:i,html:f,params:S,engine:g}=v,k=X(v,["url","htmlId","mode","height","html","params","engine"]),T=O.useField(),{t:q}=F.useTranslation(),b=e.useBlockHeight()||i,H=e.useVariables(),B=e.useLocalVariables(),C=e.useCompile(),{loading:m,data:d}=e.useRequest({url:`iframeHtml:getHtml/${t}`},{refreshDeps:[t,T.data],ready:l==="html"&&!!t}),{parseURLAndParams:p}=e.useParseURLAndParams(),[u,c]=L.useState(null);return L.useEffect(()=>{P(this,null,function*(){if(l==="html"){const a=yield e.getRenderContent(g,d,C(H),C(B),V=>V),$="data:text/html;charset=utf-8,"+encodeURIComponent(a);c($)}else try{const a=yield p(s,S||[]);c(a)}catch(a){console.error("Error fetching target URL:",a),c("fallback-url")}})},[d,l,s,H,B,S]),l==="url"&&!s||l==="html"&&!t?n.jsx(z.Card,{style:{marginBottom:24,height:U(b)?`${b}px`:b},children:q("Please fill in the iframe URL")}):m&&!u?n.jsx("div",{style:{height:U(b)?`${b}px`:b||"60vh",marginBottom:"24px",border:0},children:n.jsx(z.Spin,{})}):n.jsx(ae,w({url:u,width:"100%",display:"block",position:"relative",styles:{height:U(b)?`${b}px`:b||"60vh",marginBottom:"24px",border:0}},k))},{displayName:"Iframe"});R.Designer=se;const ie=()=>{const{insert:o}=e.useSchemaInitializer(),s=e.useSchemaInitializerItem();return n.jsx(e.SchemaInitializerItem,M(w({},s),{icon:n.jsx(N.FormOutlined,{}),onClick:()=>{o({type:"void","x-settings":"blockSettings:iframe","x-decorator":"BlockItem","x-decorator-props":{name:"iframe"},"x-component":"Iframe","x-component-props":{}})}}))},le=o=>n.jsx(e.SchemaComponentOptions,{components:{Iframe:R,IframeBlockInitializer:ie,ArrayItems:I.ArrayItems},children:o.children}),ce=o=>s=>{const t=O.useFieldSchema(),{form:l}=e.useFormBlockContext(),i=e.useRecord(),f=e.useVariableOptions({collectionField:{uiSchema:t},form:l,record:i,uiSchema:t,noDisabled:!0});return n.jsx(o,M(w({},s),{scope:f}))},_={items:[{name:"EditIframe",type:"modal",useComponentProps(){const o=O.useField(),s=O.useFieldSchema(),{t}=F.useTranslation(),{dn:l}=e.useDesignable(),i=e.useAPIClient(),{mode:f,url:S,params:g,htmlId:k,height:T="60vh",engine:q}=s["x-component-props"]||{},b=m=>P(this,null,function*(){var p,u,c,v,y;const d={values:{html:m}};if(k){const{data:a}=yield(u=(p=i.resource("iframeHtml")).update)==null?void 0:u.call(p,M(w({},d),{filterByTk:k}));return((c=a==null?void 0:a.data)==null?void 0:c[0])||{id:k}}else{const{data:a}=yield(y=(v=i.resource("iframeHtml")).create)==null?void 0:y.call(v,d);return a==null?void 0:a.data}}),{urlSchema:H,paramsSchema:B}=e.useURLAndHTMLSchema(),C=y=>P(this,[y],function*({mode:m,url:d,html:p,height:u,params:c,engine:v}){const a=s["x-component-props"]||{};if(a.mode=m,a.height=u,a.engine=v||"string",a.params=c,a.url=d,m==="html"){const A=yield b(p);a.htmlId=A.id}s["x-component-props"]=a,o.componentProps=w({},a),o.data={v:j.uid()},l.emit("patch",{schema:{"x-uid":s["x-uid"],"x-component-props":a}})});return{title:t("Edit iframe"),asyncGetInitialValues:()=>P(this,null,function*(){var d,p,u;const m={mode:f,url:S,height:T,engine:q,params:g};if(k){const{data:c}=yield(p=(d=i.resource("iframeHtml")).get)==null?void 0:p.call(d,{filterByTk:k});m.html=((u=c==null?void 0:c.data)==null?void 0:u.html)||""}return m}),schema:{type:"object",title:t("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:t("URL")},{value:"html",label:t("HTML")}]},url:M(w({},H),{required:!0}),params:B,engine:{title:'{{t("Template engine")}}',"x-component":"Radio.Group","x-decorator":"FormItem",enum:[{value:"string",label:t("String template")},{value:"handlebars",label:t("Handlebars")}],"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},html:{title:t("html"),type:"string","x-decorator":"FormItem","x-component":ce(e.Variable.RawTextArea),"x-component-props":{rows:10},required:!0,description:n.jsxs(n.Fragment,{children:[n.jsxs("span",{style:{marginLeft:".25em"},className:"ant-formily-item-extra",children:[t("Syntax references"),":"]}),n.jsx("a",{href:"https://handlebarsjs.com/guide/",target:"_blank",rel:"noreferrer",children:"Handlebars.js"})]}),"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}}}},onSubmit:C,noRecord:!0}}},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]},me=new e.SchemaSettings(w({name:"iframeBlockSchemaSettings"},_)),de=new e.SchemaSettings(w({name:"blockSettings:iframe"},_));class W extends e.Plugin{load(){return P(this,null,function*(){this.app.schemaSettingsManager.add(me),this.app.schemaSettingsManager.add(de),this.app.use(le);const s=this.app.schemaInitializerManager.get("page:addBlock");s==null||s.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const t=this.app.schemaInitializerManager.get("popup:addNew:addBlock");t==null||t.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const l=this.app.schemaInitializerManager.get("popup:common:addBlock");l==null||l.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"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"})})}}r.PluginBlockIframeClient=W,r.default=W,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
14
|
+
*/var G=Object.getOwnPropertySymbols,Z=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;function te(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function re(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var a={},t=0;t<10;t++)a["_"+String.fromCharCode(t)]=t;var l=Object.getOwnPropertyNames(a).map(function(h){return a[h]});if(l.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(h){s[h]=h}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch(h){return!1}}var ne=re()?Object.assign:function(o,a){for(var t,l=te(o),s,h=1;h<arguments.length;h++){t=Object(arguments[h]);for(var k in t)Z.call(t,k)&&(l[k]=t[k]);if(G){s=G(t);for(var y=0;y<s.length;y++)ee.call(t,s[y])&&(l[s[y]]=t[s[y]])}}return l};const oe=Y(ne),ae=({url:o,allowFullScreen:a,position:t,display:l,height:s,width:h,overflow:k,styles:y,onLoad:w,onMouseOver:M,onMouseOut:T,scrolling:I,id:F,frameBorder:C,ariaHidden:P,sandbox:x,allow:i,className:m,title:u,ariaLabel:c,ariaLabelledby:b,name:f,target:d,loading:p,importance:A,referrerpolicy:V,allowpaymentrequest:ue,src:pe,key:fe})=>{const D=oe({src:pe||o,target:d||null,style:{position:t||null,display:l||"initial",overflow:k||null},scrolling:I||null,allowpaymentrequest:ue||null,importance:A||null,sandbox:x&&[...x].join(" ")||null,loading:p||null,styles:y||null,name:f||null,className:m||null,allowFullScreen:"allowFullScreen",referrerpolicy:V||null,title:u||null,allow:i||null,id:F||null,"aria-labelledby":b||null,"aria-hidden":P||null,"aria-label":c||null,width:h||null,height:s||null,onLoad:w||null,onMouseOver:M||null,onMouseOut:T||null,key:fe||"iframe"});let g=Object.create(null);for(let v of Object.keys(D))D[v]!=null&&(g[v]=D[v]);for(let v of Object.keys(g.style))g.style[v]==null&&delete g.style[v];if(g.styles)for(let v of Object.keys(g.styles))g.styles.hasOwnProperty(v)&&(g.style[v]=g.styles[v]),Object.keys(g.styles).pop()==v&&delete g.styles;if(a)if("allow"in g){const v=g.allow.replace("fullscreen","");g.allow=`fullscreen ${v.trim()}`.trim()}else g.allow="fullscreen";return C>=0&&(g.style.hasOwnProperty("border")||(g.style.border=C)),N.createElement("iframe",Object.assign({},g))},se=()=>{const o=j.useField(),a=j.useFieldSchema(),{t}=q.useTranslation(),{dn:l}=e.useDesignable(),s=e.useAPIClient(),{mode:h,url:k,htmlId:y,height:w="60vh",engine:M}=a["x-component-props"]||{},T=x=>H(this,null,function*(){var m,u,c,b,f;const i={values:{html:x}};if(y){const{data:d}=yield(u=(m=s.resource("iframeHtml")).update)==null?void 0:u.call(m,L(O({},i),{filterByTk:y}));return((c=d==null?void 0:d.data)==null?void 0:c[0])||{id:y}}else{const{data:d}=yield(f=(b=s.resource("iframeHtml")).create)==null?void 0:f.call(b,i);return d==null?void 0:d.data}}),I=b=>H(this,[b],function*({mode:x,url:i,html:m,height:u,engine:c}){const f=a["x-component-props"]||{};if(f.mode=x,f.height=u,f.url=i,f.engine=c||"string",x==="html"){const d=yield T(m);f.htmlId=d.id}a["x-component-props"]=f,o.componentProps=O({},f),o.data={v:B.uid()},l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":f}})}),{form:F}=e.useFormBlockContext(),C=e.useRecord(),P=e.useVariableOptions({collectionField:{uiSchema:a},form:F,record:C,uiSchema:a,noDisabled:!0});return n.jsxs(e.GeneralSchemaDesigner,{children:[n.jsx(e.SchemaSettingsModalItem,{title:t("Edit iframe"),asyncGetInitialValues:()=>H(this,null,function*(){var i,m,u;const x={mode:h,url:k,height:w};if(y){const{data:c}=yield(m=(i=s.resource("iframeHtml")).get)==null?void 0:m.call(i,{filterByTk:y});x.html=((u=c==null?void 0:c.data)==null?void 0:u.html)||""}return x}),schema:{type:"object",title:t("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:t("URL")},{value:"html",label:t("HTML")}]},url:{title:t("URL"),type:"string","x-decorator":"FormItem","x-component":"Variable.TextArea","x-component-props":{scope:P},required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "html"}}'}}}},engine:{title:'{{t("Template engine")}}',"x-component":"Radio.Group","x-decorator":"FormItem",enum:[{value:"string",label:t("String template")},{value:"handlebars",label:t("Handlebars")}],"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},html:{title:t("html"),type:"string","x-decorator":"FormItem","x-component":"Variable.RawTextArea","x-component-props":{scope:P,style:{minHeight:"200px"}},required:!0,"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},height:{title:t("Height"),type:"string","x-decorator":"FormItem","x-component":"Input",required:!0}}},onSubmit:I}),n.jsx(e.SchemaSettingsDivider,{}),n.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};function $(o){return typeof o!="string"?!1:!isNaN(o)&&!isNaN(parseFloat(o))}const R=j.observer(o=>{const b=o,{url:a,htmlId:t,mode:l="url",height:s,html:h,params:k,engine:y}=b,w=X(b,["url","htmlId","mode","height","html","params","engine"]),M=j.useField(),{t:T}=q.useTranslation(),I=e.useBlockHeight()||s,F=e.useVariables(),C=e.useLocalVariables(),P=e.useCompile(),{loading:x,data:i}=e.useRequest({url:`iframeHtml:getHtml/${t}`},{refreshDeps:[t,M.data],ready:l==="html"&&!!t}),{parseURLAndParams:m}=e.useParseURLAndParams(),[u,c]=N.useState(null);return N.useEffect(()=>{H(this,null,function*(){if(l==="html"){const d=yield e.getRenderContent(y,i,P(F),P(C),V=>V);if(d===void 0)return;const A="data:text/html;charset=utf-8,"+encodeURIComponent(d);c(A)}else try{const d=yield m(a,k||[]);c(d)}catch(d){console.error("Error fetching target URL:",d),c("fallback-url")}})},[i,l,a,F,C,k]),l==="url"&&!a||l==="html"&&!t?n.jsx(E.Card,{style:{marginBottom:24,height:$(I)?`${I}px`:I},children:T("Please fill in the iframe URL")}):x&&!u?n.jsx("div",{style:{height:$(I)?`${I}px`:I||"60vh",marginBottom:"24px",border:0},children:n.jsx(E.Spin,{})}):n.jsx(ae,O({url:u,width:"100%",display:"block",position:"relative",styles:{height:$(I)?`${I}px`:I||"60vh",marginBottom:"24px",border:0}},w))},{displayName:"Iframe"});R.Designer=se;const ie=()=>{const{insert:o}=e.useSchemaInitializer(),a=e.useSchemaInitializerItem();return n.jsx(e.SchemaInitializerItem,L(O({},a),{icon:n.jsx(z.FormOutlined,{}),onClick:()=>{o({type:"void","x-settings":"blockSettings:iframe","x-decorator":"BlockItem","x-decorator-props":{name:"iframe"},"x-component":"Iframe","x-component-props":{}})}}))},le=o=>n.jsx(e.SchemaComponentOptions,{components:{Iframe:R,IframeBlockInitializer:ie,ArrayItems:S.ArrayItems},children:o.children}),ce=o=>a=>{const t=j.useFieldSchema(),{form:l}=e.useFormBlockContext(),s=e.useRecord(),h=e.useVariableOptions({collectionField:{uiSchema:t},form:l,record:s,uiSchema:t,noDisabled:!0});return n.jsx(o,L(O({},a),{scope:h}))},_={items:[{name:"EditIframe",type:"modal",useComponentProps(){const o=j.useField(),a=j.useFieldSchema(),{t}=q.useTranslation(),{dn:l}=e.useDesignable(),s=e.useAPIClient(),{mode:h,url:k,params:y,htmlId:w,height:M="60vh",engine:T}=a["x-component-props"]||{},I=i=>H(this,null,function*(){var u,c,b,f,d;const m={values:{html:i}};if(w){const{data:p}=yield(c=(u=s.resource("iframeHtml")).update)==null?void 0:c.call(u,L(O({},m),{filterByTk:w}));return((b=p==null?void 0:p.data)==null?void 0:b[0])||{id:w}}else{const{data:p}=yield(d=(f=s.resource("iframeHtml")).create)==null?void 0:d.call(f,m);return p==null?void 0:p.data}}),{urlSchema:F,paramsSchema:C}=e.useURLAndHTMLSchema(),P=d=>H(this,[d],function*({mode:i,url:m,html:u,height:c,params:b,engine:f}){const p=a["x-component-props"]||{};if(p.mode=i,p.height=c,p.engine=f||"string",p.params=b,p.url=m,i==="html"){const A=yield I(u);p.htmlId=A.id}a["x-component-props"]=p,o.componentProps=O({},p),o.data={v:B.uid()},l.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":p}})}),x=n.jsxs(n.Fragment,{children:[n.jsxs("span",{style:{marginLeft:".25em"},className:"ant-formily-item-extra",children:[t("Syntax references"),":"]}),n.jsx("a",{href:"https://handlebarsjs.com/guide/",target:"_blank",rel:"noreferrer",children:"Handlebars.js"})]});return{title:t("Edit iframe"),asyncGetInitialValues:()=>H(this,null,function*(){var m,u,c;const i={mode:h,url:k,height:M,engine:T,params:y};if(w){const{data:b}=yield(u=(m=s.resource("iframeHtml")).get)==null?void 0:u.call(m,{filterByTk:w});i.html=((c=b==null?void 0:b.data)==null?void 0:c.html)||""}return i}),schema:{type:"object",title:t("Edit iframe"),properties:{mode:{title:'{{t("Mode")}}',"x-component":"Radio.Group","x-decorator":"FormItem",required:!0,default:"url",enum:[{value:"url",label:t("URL")},{value:"html",label:t("HTML")}]},url:L(O({},F),{required:!0}),params:C,engine:{title:'{{t("Template engine")}}',"x-component":"Radio.Group","x-decorator":"FormItem",default:"string",enum:[{value:"string",label:t("String template")},{value:"handlebars",label:t("Handlebars")}],"x-reactions":{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}}},html:{title:t("html"),type:"string","x-decorator":"FormItem","x-component":ce(e.Variable.RawTextArea),"x-component-props":{rows:10},required:!0,description:x,"x-reactions":[{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}},i=>{const{engine:m}=i.form.values;m==="handlebars"?i.description=x:i.description=null}]}}},onSubmit:P,noRecord:!0}}},{name:"setTheBlockHeight",Component:e.SchemaSettingsBlockHeightItem},{name:"divider",type:"divider"},{name:"delete",type:"remove",useComponentProps(){return{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}}}}]},me=new e.SchemaSettings(O({name:"iframeBlockSchemaSettings"},_)),de=new e.SchemaSettings(O({name:"blockSettings:iframe"},_));class W extends e.Plugin{load(){return H(this,null,function*(){this.app.schemaSettingsManager.add(me),this.app.schemaSettingsManager.add(de),this.app.use(le);const a=this.app.schemaInitializerManager.get("page:addBlock");a==null||a.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const t=this.app.schemaInitializerManager.get("popup:addNew:addBlock");t==null||t.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const l=this.app.schemaInitializerManager.get("popup:common:addBlock");l==null||l.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"});const s=this.app.schemaInitializerManager.get("RecordFormBlockInitializers");s==null||s.add("otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobilePage:addBlock","otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"}),this.app.schemaInitializerManager.addItem("mobile:addBlock","otherBlocks.iframe",{title:'{{t("Iframe")}}',Component:"IframeBlockInitializer"})})}}r.PluginBlockIframeClient=W,r.default=W,Object.defineProperties(r,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,13 +10,14 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
12
|
"@formily/shared": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.3.0-alpha.
|
|
13
|
+
"@nocobase/client": "1.3.0-alpha.20240814073548",
|
|
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
18
|
"@formily/antd-v5": "1.1.9",
|
|
19
|
-
"@nocobase/server": "1.3.0-alpha.
|
|
20
|
-
"@nocobase/
|
|
21
|
-
"@nocobase/
|
|
19
|
+
"@nocobase/server": "1.3.0-alpha.20240814073548",
|
|
20
|
+
"@nocobase/test": "1.3.0-alpha.20240814073548",
|
|
21
|
+
"@nocobase/actions": "1.3.0-alpha.20240814073548",
|
|
22
|
+
"@nocobase/database": "1.3.0-alpha.20240814073548"
|
|
22
23
|
};
|
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.3.0-alpha.
|
|
7
|
+
"version": "1.3.0-alpha.20240814073548",
|
|
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": "
|
|
28
|
+
"gitHead": "cb195a2da766088e2a368f60ee2e933579d0987c",
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Blocks"
|
|
31
31
|
]
|