@nocobase/plugin-block-iframe 1.3.38-beta → 1.4.0-alpha
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 -5
- 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,S,
|
|
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,O,$,z,q,j,L){"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,w=(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},N=(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,O)=>{var $=j=>{try{q(n.next(j))}catch(L){O(L)}},z=j=>{try{q(n.throw(j))}catch(L){O(L)}},q=j=>j.done?S(j.value):Promise.resolve(j.value).then($,z);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 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"}})});
|
|
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 i=Object.getOwnPropertyNames(a).map(function(f){return a[f]});if(i.join("")!=="0123456789")return!1;var s={};return"abcdefghijklmnopqrst".split("").forEach(function(f){s[f]=f}),Object.keys(Object.assign({},s)).join("")==="abcdefghijklmnopqrst"}catch(f){return!1}}var ne=re()?Object.assign:function(o,a){for(var t,i=te(o),s,f=1;f<arguments.length;f++){t=Object(arguments[f]);for(var k in t)Z.call(t,k)&&(i[k]=t[k]);if(G){s=G(t);for(var g=0;g<s.length;g++)ee.call(t,s[g])&&(i[s[g]]=t[s[g]])}}return i};const oe=Y(ne),ae=({url:o,allowFullScreen:a,position:t,display:i,height:s,width:f,overflow:k,styles:g,onLoad:T,onMouseOver:B,onMouseOut:M,scrolling:y,id:F,frameBorder:C,ariaHidden:P,sandbox:x,allow:b,className:l,title:d,ariaLabel:u,ariaLabelledby:I,name:c,target:m,loading:A,importance:p,referrerpolicy:E,allowpaymentrequest:ue,src:pe,key:fe})=>{const D=oe({src:pe||o,target:m||null,style:{position:t||null,display:i||"initial",overflow:k||null},scrolling:y||null,allowpaymentrequest:ue||null,importance:p||null,sandbox:x&&[...x].join(" ")||null,loading:A||null,styles:g||null,name:c||null,className:l||null,allowFullScreen:"allowFullScreen",referrerpolicy:E||null,title:d||null,allow:b||null,id:F||null,"aria-labelledby":I||null,"aria-hidden":P||null,"aria-label":u||null,width:f||null,height:s||null,onLoad:T||null,onMouseOver:B||null,onMouseOut:M||null,key:fe||"iframe"});let h=Object.create(null);for(let v of Object.keys(D))D[v]!=null&&(h[v]=D[v]);for(let v of Object.keys(h.style))h.style[v]==null&&delete h.style[v];if(h.styles)for(let v of Object.keys(h.styles))h.styles.hasOwnProperty(v)&&(h.style[v]=h.styles[v]),Object.keys(h.styles).pop()==v&&delete h.styles;if(a)if("allow"in h){const v=h.allow.replace("fullscreen","");h.allow=`fullscreen ${v.trim()}`.trim()}else h.allow="fullscreen";return C>=0&&(h.style.hasOwnProperty("border")||(h.style.border=C)),z.createElement("iframe",Object.assign({},h))},se=()=>{const o=O.useField(),a=O.useFieldSchema(),{t}=q.useTranslation(),{dn:i}=e.useDesignable(),s=e.useAPIClient(),{mode:f,url:k,htmlId:g,height:T="60vh",engine:B}=a["x-component-props"]||{},M=x=>H(this,null,function*(){var l,d,u,I,c;const b={values:{html:x}};if(g){const{data:m}=yield(d=(l=s.resource("iframeHtml")).update)==null?void 0:d.call(l,N(w({},b),{filterByTk:g}));return((u=m==null?void 0:m.data)==null?void 0:u[0])||{id:g}}else{const{data:m}=yield(c=(I=s.resource("iframeHtml")).create)==null?void 0:c.call(I,b);return m==null?void 0:m.data}}),y=I=>H(this,[I],function*({mode:x,url:b,html:l,height:d,engine:u}){const c=a["x-component-props"]||{};if(c.mode=x,c.height=d,c.url=b,c.engine=u||"string",x==="html"){const m=yield M(l);c.htmlId=m.id}a["x-component-props"]=c,o.componentProps=w({},c),o.data={v:j.uid()},i.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":c}})}),{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 b,l,d;const x={mode:f,url:k,height:T};if(g){const{data:u}=yield(l=(b=s.resource("iframeHtml")).get)==null?void 0:l.call(b,{filterByTk:g});x.html=((d=u==null?void 0:u.data)==null?void 0:d.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:y}),n.jsx(e.SchemaSettingsDivider,{}),n.jsx(e.SchemaSettingsRemove,{removeParentsIfNoChildren:!0,breakRemoveOn:{"x-component":"Grid"}})]})};function V(o){return typeof o!="string"?!1:!isNaN(o)&&!isNaN(parseFloat(o))}const R=O.observer(o=>{const I=o,{url:a,htmlId:t,mode:i="url",height:s,html:f,params:k,engine:g}=I,T=X(I,["url","htmlId","mode","height","html","params","engine"]),B=O.useField(),{t:M}=q.useTranslation(),y=e.useBlockHeight()||s,F=e.useVariables(),C=e.useLocalVariables(),P=e.useCompile(),{loading:x,data:b}=e.useRequest({url:`iframeHtml:getHtml/${t}`},{refreshDeps:[t,B.data],ready:i==="html"&&!!t}),{parseURLAndParams:l}=e.useParseURLAndParams(),[d,u]=z.useState(null);return z.useEffect(()=>{H(this,null,function*(){if(i==="html"){const m=yield e.getRenderContent(g,b,P(F),P(C),E=>E);if(m===void 0)return;const p="data:text/html;charset=utf-8,"+encodeURIComponent(m);u(p)}else try{const m=yield l(a,k||[]);u(m)}catch(m){console.error("Error fetching target URL:",m),u("fallback-url")}})},[b,i,a,F,C,k]),i==="url"&&!a||i==="html"&&!t?n.jsx($.Card,{style:{marginBottom:24,height:V(y)?`${y}px`:y},children:M("Please fill in the iframe URL")}):x&&!d?n.jsx("div",{style:{height:V(y)?`${y}px`:y||"60vh",marginBottom:"24px",border:0},children:n.jsx($.Spin,{})}):n.jsx(ae,w({url:d,width:"100%",display:"block",position:"relative",styles:{height:V(y)?`${y}px`:y||"60vh",marginBottom:"24px",border:0}},T))},{displayName:"Iframe"});R.Designer=se;const ie=()=>{const{insert:o}=e.useSchemaInitializer(),a=e.useSchemaInitializerItem();return n.jsx(e.SchemaInitializerItem,N(w({},a),{icon:n.jsx(L.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=O.useFieldSchema(),{form:i}=e.useFormBlockContext(),s=e.useRecord(),f=e.useVariableOptions({collectionField:{uiSchema:t},form:i,record:s,uiSchema:t,noDisabled:!0});return n.jsx(o,N(w({},a),{scope:f}))},_={items:[{name:"EditIframe",type:"modal",useComponentProps(){const o=O.useField(),a=O.useFieldSchema(),{t,i18n:i}=q.useTranslation(),{dn:s}=e.useDesignable(),f=e.useAPIClient(),{mode:k,url:g,params:T,htmlId:B,height:M="60vh",engine:y}=a["x-component-props"]||{},F=l=>H(this,null,function*(){var u,I,c,m,A;const d={values:{html:l}};if(B){const{data:p}=yield(I=(u=f.resource("iframeHtml")).update)==null?void 0:I.call(u,N(w({},d),{filterByTk:B}));return((c=p==null?void 0:p.data)==null?void 0:c[0])||{id:B}}else{const{data:p}=yield(A=(m=f.resource("iframeHtml")).create)==null?void 0:A.call(m,d);return p==null?void 0:p.data}}),{urlSchema:C,paramsSchema:P}=e.useURLAndHTMLSchema(),x=A=>H(this,[A],function*({mode:l,url:d,html:u,height:I,params:c,engine:m}){const p=a["x-component-props"]||{};if(p.mode=l,p.height=I,p.engine=m||"string",p.params=c,p.url=d,l==="html"){const E=yield F(u);p.htmlId=E.id}a["x-component-props"]=p,o.componentProps=w({},p),o.data={v:j.uid()},s.emit("patch",{schema:{"x-uid":a["x-uid"],"x-component-props":p}})}),b=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://${i.language==="zh-CN"?"docs-cn":"docs"}.nocobase.com/handbook/template-handlebars`,target:"_blank",rel:"noreferrer",children:"Handlebars.js"})]});return{title:t("Edit iframe"),asyncGetInitialValues:()=>H(this,null,function*(){var d,u,I;const l={mode:k,url:g,height:M,engine:y,params:T};if(B){const{data:c}=yield(u=(d=f.resource("iframeHtml")).get)==null?void 0:u.call(d,{filterByTk:B});l.html=((I=c==null?void 0:c.data)==null?void 0:I.html)||""}return l}),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:N(w({},C),{required:!0}),params:P,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:b,"x-reactions":[{dependencies:["mode"],fulfill:{state:{hidden:'{{$deps[0] === "url"}}'}}},l=>{const{engine:d}=l.form.values;d==="handlebars"?l.description=b:l.description=null}]}}},onSubmit:x,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 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 i=this.app.schemaInitializerManager.get("popup:common:addBlock");i==null||i.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,14 +10,14 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"@formily/react": "2.3.0",
|
|
12
12
|
"@formily/shared": "2.3.0",
|
|
13
|
-
"@nocobase/client": "1.
|
|
13
|
+
"@nocobase/client": "1.4.0-alpha",
|
|
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.
|
|
20
|
-
"@nocobase/test": "1.
|
|
21
|
-
"@nocobase/actions": "1.
|
|
22
|
-
"@nocobase/database": "1.
|
|
19
|
+
"@nocobase/server": "1.4.0-alpha",
|
|
20
|
+
"@nocobase/test": "1.4.0-alpha",
|
|
21
|
+
"@nocobase/actions": "1.4.0-alpha",
|
|
22
|
+
"@nocobase/database": "1.4.0-alpha"
|
|
23
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.
|
|
7
|
+
"version": "1.4.0-alpha",
|
|
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": "f097a2bddec152522b5645bd5d451f4c866d2060",
|
|
29
29
|
"keywords": [
|
|
30
30
|
"Blocks"
|
|
31
31
|
]
|