@nocobase/plugin-file-previewer-office 2.2.0-beta.8 → 2.2.0
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 +1 -1
- package/dist/client-v2/OfficeInlinePreviewer.d.ts +4 -1
- package/dist/client-v2/index.js +1 -1
- package/dist/client-v2/utils.d.ts +21 -0
- package/dist/externalVersion.js +6 -5
- package/dist/locale/en-US.json +6 -1
- package/dist/locale/zh-CN.json +6 -1
- package/package.json +2 -2
package/dist/client/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-file-manager/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office",["react","antd","@nocobase/client","@nocobase/plugin-file-manager/client"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office"]=t(require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/plugin-file-manager/client")):e["@nocobase/plugin-file-previewer-office"]=t(e.react,e.antd,e["@nocobase/client"],e["@nocobase/plugin-file-manager/client"])}(self,function(e,t,n,o){return function(){var r={574:function(e,t,n){var o,r;void 0===(r="function"==typeof(o=function(){"use strict";function t(e,t,n){var o=new XMLHttpRequest;o.open("GET",e),o.responseType="blob",o.onload=function(){c(o.response,t,n)},o.onerror=function(){console.error("could not download file")},o.send()}function o(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function r(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),c=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var c=i.URL||i.webkitURL,l=document.createElement("a");l.download=n=n||e.name||"download",l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?r(l):o(l.href)?t(e,n,a):r(l,l.target="_blank")):(l.href=c.createObjectURL(e),setTimeout(function(){c.revokeObjectURL(l.href)},4e4),setTimeout(function(){r(l)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(o(e))t(e,n,i);else{var c=document.createElement("a");c.href=e,c.target="_blank",setTimeout(function(){r(c)})}}:function(e,n,o,r){if((r=r||open("","_blank"))&&(r.document.title=r.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,o);var c="application/octet-stream"===e.type,l=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||c&&l||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),r?r.location.href=e:location=e,r=null},s.readAsDataURL(e)}else{var p=i.URL||i.webkitURL,f=p.createObjectURL(e);r?r.location=f:location.href=f,r=null,setTimeout(function(){p.revokeObjectURL(f)},4e4)}});i.saveAs=c.saveAs=c,e.exports=c})?o.apply(t,[]):o)||(e.exports=r)},342:function(e){"use strict";e.exports=n},609:function(e){"use strict";e.exports=o},59:function(e){"use strict";e.exports=t},155:function(t){"use strict";t.exports=e}},i={};function a(e){var t=i[e];if(void 0!==t)return t.exports;var n=i[e]={exports:{}};return r[e].call(n.exports,n,n.exports,a),n.exports}a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,{a:t}),t},a.d=function(e,t){for(var n in t)a.o(t,n)&&!a.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.g.importScripts&&(c=a.g.location+"");var c,l=a.g.document;if(!c&&l&&(l.currentScript&&"SCRIPT"===l.currentScript.tagName.toUpperCase()&&(c=l.currentScript.src),!c)){var u=l.getElementsByTagName("script");if(u.length)for(var s=u.length-1;s>-1&&(!c||!/^http(s?):/.test(c));)c=u[s--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");a.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-file-previewer-office/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var o=window.__webpack_public_path__||"";o&&("/"!==o.charAt(o.length-1)&&(o+="/"),e=o+"static/plugins/@nocobase/plugin-file-previewer-office/dist/client/")}if(!e){var r=window.__nocobase_modern_client_prefix__||"v",i="/"+(r=String(r).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var c=window.location.pathname||"/",l=c.indexOf(i);e=l>=0?c.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+r+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-previewer-office/dist/client/"}a.p=e}(),!function(){"use strict";a.r(p),a.d(p,{default:function(){return j},PluginFilePreviewerOfficeClient:function(){return _}});var e=a(155),t=a.n(e),n=a(59),o=a(574),r=a(342),i=a(609),c=["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.text"],l=["docx","xlsx","pptx","odt","doc","xls","ppt"],u=function(e){var t=("string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"").split("?")[0].split("#")[0],n=t.lastIndexOf(".");return -1!==n?t.slice(n+1).toLowerCase():""},s=function(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("https://")||t.startsWith("http://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""},f=function(e){var t=s(e);if(!t)return"";var n=new URL("https://view.officeapps.live.com/op/embed.aspx");return n.searchParams.set("src",t),n.href},d=function(e){if(e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&e.mimetype&&c.includes(e.mimetype))return!0;var t=u(e);return!!t&&l.includes(t)},v=function(n){var o=n.file,r="string"==typeof o?o:null==o?void 0:o.url,i=(0,e.useMemo)(function(){return f(r)},[r]);return i?t().createElement("iframe",{src:i,width:"100%",height:"100%",style:{border:"none"}}):null},b=JSON.parse('{"UU":"@nocobase/plugin-file-previewer-office"}');function m(e,t,n,o,r,i,a){try{var c=e[i](a),l=c.value}catch(e){n(e);return}c.done?t(l):Promise.resolve(l).then(o,r)}function y(e,t,n){return(y=x()?Reflect.construct:function(e,t,n){var o=[null];o.push.apply(o,t);var r=new(Function.bind.apply(e,o));return n&&h(r,n.prototype),r}).apply(null,arguments)}function w(e){return(w=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function g(e){var t="function"==typeof Map?new Map:void 0;return(g=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return y(e,arguments,w(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,e)})(e)}function x(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(x=function(){return!!e})()}function O(i){var a,c=i.index,l=i.list,u=i.onSwitchIndex,s=(a=(0,r.useApp)(),function(e){return a.i18n.t(e,{ns:[b.UU,"client"]})}),p=l[c],d=(0,e.useMemo)(function(){return f(p)},[p]),v=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),window.open(d)},[d]),m=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),(0,o.saveAs)(p.url,"".concat(p.title).concat(p.extname))},[p.extname,p.title,p.url]),y=(0,e.useCallback)(function(){u(null)},[u]);return t().createElement(n.Modal,{open:null!=c,title:p.title,onCancel:y,footer:[t().createElement(n.Button,{key:"open",onClick:v},s("Open in new window")),t().createElement(n.Button,{key:"download",onClick:m},s("Download")),t().createElement(n.Button,{key:"close",onClick:y},s("Close"))],width:"85vw",centered:!0},t().createElement("div",{style:{width:"100%",height:"calc(85vh - 120px)",background:"white",display:"flex",flexDirection:"column"}},t().createElement("iframe",{src:d,style:{width:"100%",height:"100%",flex:"1 1 auto",border:"none"}})))}var _=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=w(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,x()?Reflect.construct(e,t||[],w(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&h(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,o,r,i={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),c=Object.defineProperty;return c(a,"next",{value:l(0)}),c(a,"throw",{value:l(1)}),c(a,"return",{value:l(2)}),"function"==typeof Symbol&&c(a,Symbol.iterator,{value:function(){return this}}),a;function l(c){return function(l){var u=[c,l];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,o&&(r=2&u[0]?o.return:u[0]?o.throw||((r=o.return)&&r.call(o),0):o.next)&&!(r=r.call(o,u[1])).done)return r;switch(o=0,r&&(u=[2&u[0],r.value]),u[0]){case 0:case 1:r=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,o=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(r=(r=i.trys).length>0&&r[r.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!r||u[1]>r[0]&&u[1]<r[3])){i.label=u[1];break}if(6===u[0]&&i.label<r[1]){i.label=r[1],r=u;break}if(r&&i.label<r[2]){i.label=r[2],i.ops.push(u);break}r[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],o=0}finally{n=r=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return r.attachmentFileTypes.add({match:d,Previewer:O}),i.filePreviewTypes.add({match:d,Previewer:(0,i.wrapWithModalPreviewer)(v)}),[2]})},function(){var t=this,n=arguments;return new Promise(function(o,r){var i=e.apply(t,n);function a(e){m(i,o,r,a,c,"next",e)}function c(e){m(i,o,r,a,c,"throw",e)}a(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}(n.prototype,t),n}(g(r.Plugin)),j=_}(),p}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/flow-engine"),require("@ant-design/icons"),require("@nocobase/plugin-file-manager/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office",["@nocobase/client-v2","react","antd","@nocobase/client","@nocobase/flow-engine","@ant-design/icons","@nocobase/plugin-file-manager/client"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office"]=t(require("@nocobase/client-v2"),require("react"),require("antd"),require("@nocobase/client"),require("@nocobase/flow-engine"),require("@ant-design/icons"),require("@nocobase/plugin-file-manager/client")):e["@nocobase/plugin-file-previewer-office"]=t(e["@nocobase/client-v2"],e.react,e.antd,e["@nocobase/client"],e["@nocobase/flow-engine"],e["@ant-design/icons"],e["@nocobase/plugin-file-manager/client"])}(self,function(e,t,n,r,o,i,a){return function(){var l={574:function(e,t,n){var r,o;void 0===(o="function"==typeof(r=function(){"use strict";function t(e,t,n){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,t,n)},r.onerror=function(){console.error("could not download file")},r.send()}function r(e){var t=new XMLHttpRequest;t.open("HEAD",e,!1);try{t.send()}catch(e){}return 200<=t.status&&299>=t.status}function o(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(n){var t=document.createEvent("MouseEvents");t.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(t)}}var i="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof n.g&&n.g.global===n.g?n.g:void 0,a=i.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=i.saveAs||("object"!=typeof window||window!==i?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(e,n,a){var l=i.URL||i.webkitURL,c=document.createElement("a");c.download=n=n||e.name||"download",c.rel="noopener","string"==typeof e?(c.href=e,c.origin===location.origin?o(c):r(c.href)?t(e,n,a):o(c,c.target="_blank")):(c.href=l.createObjectURL(e),setTimeout(function(){l.revokeObjectURL(c.href)},4e4),setTimeout(function(){o(c)},0))}:"msSaveOrOpenBlob"in navigator?function(e,n,i){if(n=n||e.name||"download","string"!=typeof e){var a;navigator.msSaveOrOpenBlob((void 0===(a=i)?a={autoBom:!1}:"object"!=typeof a&&(console.warn("Deprecated: Expected third argument to be a object"),a={autoBom:!a}),a.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\uFEFF",e],{type:e.type}):e),n)}else if(r(e))t(e,n,i);else{var l=document.createElement("a");l.href=e,l.target="_blank",setTimeout(function(){o(l)})}}:function(e,n,r,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return t(e,n,r);var l="application/octet-stream"===e.type,c=/constructor/i.test(i.HTMLElement)||i.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent);if((u||l&&c||a)&&"u">typeof FileReader){var s=new FileReader;s.onloadend=function(){var e=s.result;e=u?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},s.readAsDataURL(e)}else{var f=i.URL||i.webkitURL,p=f.createObjectURL(e);o?o.location=p:location.href=p,o=null,setTimeout(function(){f.revokeObjectURL(p)},4e4)}});i.saveAs=l.saveAs=l,e.exports=l})?r.apply(t,[]):r)||(e.exports=o)},375:function(e){"use strict";e.exports=i},342:function(e){"use strict";e.exports=r},485:function(t){"use strict";t.exports=e},694:function(e){"use strict";e.exports=o},609:function(e){"use strict";e.exports=a},59:function(e){"use strict";e.exports=n},155:function(e){"use strict";e.exports=t}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return l[e].call(n.exports,n,n.exports,u),n.exports}u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},u.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.g.importScripts&&(s=u.g.location+"");var s,f=u.g.document;if(!s&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(s=f.currentScript.src),!s)){var p=f.getElementsByTagName("script");if(p.length)for(var d=p.length-1;d>-1&&(!s||!/^http(s?):/.test(s));)s=p[d--].src}if(!s)throw Error("Automatic publicPath is not supported in this browser");u.p=s.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){"use strict";var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-file-previewer-office/dist/client/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-file-previewer-office/dist/client/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",l=a.indexOf(i);e=l>=0?a.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-previewer-office/dist/client/"}u.p=e}(),!function(){"use strict";u.r(v),u.d(v,{default:function(){return q},PluginFilePreviewerOfficeClient:function(){return M}});var e=u(155),t=u.n(e),n=u(59),r=u(574),o=u(342),i=u(609);function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function l(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function c(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var s=["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.text"],f=["docx","xlsx","pptx","odt","doc","xls","ppt"],p=function(e){var t="string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"",n=t.split("?")[0].split("#")[0].split("/").filter(Boolean),r=n[n.length-1]||t,o=r;try{o=decodeURIComponent(r)}catch(e){}var i=o.lastIndexOf(".");return -1!==i?o.slice(i+1).toLowerCase():""},d=function(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("https://")||t.startsWith("http://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""},y=function(e){var t=d(e);if(!t)return"";var n=new URL("https://view.officeapps.live.com/op/embed.aspx");return n.searchParams.set("src",t),n.href},b=/^[A-Za-z0-9_][A-Za-z0-9_-]*$/,h=function(e){var t,n="string"==typeof e?e:null==e?void 0:e.url;if(!n)return null;try{t=new URL(n,location.origin)}catch(e){return null}if(t.origin!==location.origin||t.searchParams.has("temporaryAccessToken"))return null;var r=t.pathname.split("/").filter(Boolean),o=r.length-5;if(o<0||"files"!==r[o])return null;var i=r.slice(o+1);if(4!==i.length)return null;try{var l,c=(l=i.map(decodeURIComponent),function(e){if(Array.isArray(e))return e}(l)||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),4!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return a(e,4);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return a(e,4)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=c[0],s=c[1],f=c[2],p=c[3];if(!b.test(u)||!b.test(s)||!b.test(f))return null;var d=p.lastIndexOf("."),v=d>0?p.slice(0,d):p;return{appName:u,dataSourceKey:s,collectionName:f,id:v}}catch(e){return null}},m=function(e,t,n){var r;return(r=function(){var r,o,i,a,l,u,s,f;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(p){switch(p.label){case 0:if(n&&t&&(void 0===t?"undefined":c(t))==="object"&&null!=t.id&&null!=t.storageId)l={"X-Data-Source":(a={dataSourceKey:n.dataSourceKey,collectionName:n.collectionName,id:String(t.id)}).dataSourceKey};else{if(!(u=h(t))||n&&u.collectionName!==n.collectionName)return[2,d(t)];a=u,l={"X-App":u.appName,"X-Data-Source":u.dataSourceKey}}return[4,e.request({url:"".concat(encodeURIComponent(a.collectionName),":createTemporaryURL/").concat(encodeURIComponent(a.id)),method:"post",headers:l})];case 1:if(!(f=(null==(o=(s=p.sent()).data)||null==(r=o.data)?void 0:r.url)||(null==(i=s.data)?void 0:i.url)))throw Error("Temporary file URL is missing");return[2,new URL(f,location.origin).href]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function a(e){l(i,n,o,a,c,"next",e)}function c(e){l(i,n,o,a,c,"throw",e)}a(void 0)})})()},w=function(e){if(e&&(void 0===e?"undefined":c(e))==="object"&&e.mimetype&&s.includes(e.mimetype))return!0;var t=p(e);return!!t&&f.includes(t)},g=u(375),x=u(485),S=u(694);function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function j(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function E(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw r}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var A=function(r){var o,i=r.file,a=r.fileCollection,l=r.onDownload,c=r.onPreviewUrlChange,u=(0,x.useApp)(),s=(o=(0,S.useFlowEngine)(),function(e,t){return o.context.t(e,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({ns:["file-previewer-office","client"]},t))}),f="string"==typeof i?i:null==i?void 0:i.url,p=null==a?void 0:a.dataSourceKey,d=null==a?void 0:a.collectionName,v=E((0,e.useState)(""),2),b=v[0],h=v[1],w=E((0,e.useState)(!1),2),O=w[0],A=w[1],k=E((0,e.useState)(!1),2),P=k[0],_=k[1],C=(0,e.useRef)(0),R=(0,e.useRef)(!1),T=(0,e.useCallback)(function(){var e;return(e=function(){var e,t;return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=++C.current,A(!0),_(!1),h(""),null==c||c(""),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,m(u.apiClient,i,p&&d?{dataSourceKey:p,collectionName:d}:void 0)];case 2:if(t=n.sent(),e!==C.current)return[2];return h(t),null==c||c(y(t)),[3,5];case 3:return n.sent(),e===C.current&&(h(""),_(!0),null==c||c("")),[3,5];case 4:return e===C.current&&A(!1),[7];case 5:return[2]}})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){j(i,r,o,a,l,"next",e)}function l(e){j(i,r,o,a,l,"throw",e)}a(void 0)})})()},[u.apiClient,d,p,i,c]);(0,e.useEffect)(function(){return R.current=!1,T(),function(){C.current+=1}},[T,f]);var U=(0,e.useMemo)(function(){return y(b)},[b]),I=(0,e.useCallback)(function(){R.current?_(!0):(R.current=!0,T())},[T]);return O?t().createElement(n.Spin,{tip:s("Loading preview"),"aria-label":s("Loading preview")}):P?t().createElement(n.Alert,{type:"warning",showIcon:!0,message:s("Failed to load Office preview"),action:t().createElement(n.Button,{icon:t().createElement(g.DownloadOutlined,null),onClick:function(){return l(i)}},s("Download"))}):U?t().createElement("iframe",{src:U,title:s("Office file preview"),width:"100%",height:"100%",style:{border:"none"},onError:I}):null},k=JSON.parse('{"UU":"@nocobase/plugin-file-previewer-office"}');function P(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function _(e,t,n,r,o,i,a){try{var l=e[i](a),c=l.value}catch(e){n(e);return}l.done?t(c):Promise.resolve(c).then(r,o)}function C(e,t,n){return(C=I()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&T(o,n.prototype),o}).apply(null,arguments)}function R(e){return(R=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function T(e,t){return(T=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function U(e){var t="function"==typeof Map?new Map:void 0;return(U=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return C(e,arguments,R(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),T(n,e)})(e)}function I(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(I=function(){return!!e})()}function L(i){var a,l,c=i.index,u=i.list,s=i.fileCollection,f=i.onSwitchIndex,p=(a=(0,o.useApp)(),function(e){return a.i18n.t(e,{ns:[k.UU,"client"]})}),d=u[c],v=function(e){if(Array.isArray(e))return e}(l=(0,e.useState)(""))||function(e){var t,n,r=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(t=r.next()).done)&&(o.push(t.value),2!==o.length);i=!0);}catch(e){a=!0,n=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw n}}return o}}(l)||function(e){if(e){if("string"==typeof e)return P(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return P(e,2)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),y=v[0],b=v[1],h=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),y&&window.open(y)},[y]),m=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),(0,r.saveAs)(d.url,"".concat(d.title).concat(d.extname))},[d.extname,d.title,d.url]),w=(0,e.useCallback)(function(){f(null)},[f]);return t().createElement(n.Modal,{open:null!=c,title:d.title,onCancel:w,footer:[t().createElement(n.Button,{key:"open",onClick:h,disabled:!y},p("Open in new window")),t().createElement(n.Button,{key:"download",onClick:m},p("Download")),t().createElement(n.Button,{key:"close",onClick:w},p("Close"))],width:"85vw",centered:!0},t().createElement("div",{style:{width:"100%",height:"calc(85vh - 120px)",background:"white",display:"flex",flexDirection:"column"}},t().createElement(A,{file:d,index:c,list:u,fileCollection:s,onDownload:function(){return(0,r.saveAs)(d.url,"".concat(d.title).concat(d.extname))},onSwitchIndex:f,onPreviewUrlChange:b})))}var M=function(e){var t;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=R(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,I()?Reflect.construct(e,t||[],R(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&T(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(n)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,r=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return o.attachmentFileTypes.add({match:w,Previewer:L}),i.filePreviewTypes.add({match:w,Previewer:(0,i.wrapWithModalPreviewer)(A)}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){_(i,r,o,a,l,"next",e)}function l(e){_(i,r,o,a,l,"throw",e)}a(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(n.prototype,t),n}(U(o.Plugin)),q=M}(),v}()});
|
|
@@ -8,5 +8,8 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import type { FilePreviewerProps } from '@nocobase/plugin-file-manager/client-v2';
|
|
11
|
-
|
|
11
|
+
type OfficeInlinePreviewerProps = FilePreviewerProps & {
|
|
12
|
+
onPreviewUrlChange?: (url: string) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const OfficeInlinePreviewer: React.FC<OfficeInlinePreviewerProps>;
|
|
12
15
|
export default OfficeInlinePreviewer;
|
package/dist/client-v2/index.js
CHANGED
|
@@ -7,4 +7,4 @@
|
|
|
7
7
|
* For more information, please refer to: https://www.nocobase.com/agreement.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office/client-v2",["react","@nocobase/plugin-file-manager/client-v2","@nocobase/client-v2"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office/client-v2"]=t(require("react"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2")):e["@nocobase/plugin-file-previewer-office/client-v2"]=t(e.react,e["@nocobase/plugin-file-manager/client-v2"],e["@nocobase/client-v2"])}(self,function(e,t,n){return function(){"use strict";var r={485:function(e){e.exports=n},936:function(e){e.exports=t},155:function(t){t.exports=e}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return r[e](n,n.exports,i),n.exports}i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,{a:t}),t},i.d=function(e,t){for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.g.importScripts&&(c=i.g.location+"");var c,a=i.g.document;if(!c&&a&&(a.currentScript&&"SCRIPT"===a.currentScript.tagName.toUpperCase()&&(c=a.currentScript.src),!c)){var u=a.getElementsByTagName("script");if(u.length)for(var l=u.length-1;l>-1&&(!c||!/^http(s?):/.test(c));)c=u[l--].src}if(!c)throw Error("Automatic publicPath is not supported in this browser");i.p=c.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var p={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var n=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");n.indexOf("/static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/")>=0&&(e=n.replace(/\/[^\/]+$/,"/"))}if(!e){var r=window.__webpack_public_path__||"";r&&("/"!==r.charAt(r.length-1)&&(r+="/"),e=r+"static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",c="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",u=a.indexOf(c);e=u>=0?a.slice(0,u+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/"}i.p=e}(),!function(){i.r(p),i.d(p,{PluginFilePreviewerOfficeClientV2:function(){return g},default:function(){return w}});var e=i(485),t=i(936),n=["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.text"],r=["docx","xlsx","pptx","odt","doc","xls","ppt"],o=function(e){var t=("string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"").split("?")[0].split("#")[0],n=t.lastIndexOf(".");return -1!==n?t.slice(n+1).toLowerCase():""},c=function(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("https://")||t.startsWith("http://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""},a=function(e){var t=c(e);if(!t)return"";var n=new URL("https://view.officeapps.live.com/op/embed.aspx");return n.searchParams.set("src",t),n.href},u=function(e){if(e&&(void 0===e?"undefined":e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e)=="object"&&e.mimetype&&n.includes(e.mimetype))return!0;var t=o(e);return!!t&&r.includes(t)},l=i(155),f=i.n(l),s=function(e){var t=e.file,n="string"==typeof t?t:null==t?void 0:t.url,r=(0,l.useMemo)(function(){return a(n)},[n]);return r?f().createElement("iframe",{src:r,width:"100%",height:"100%",style:{border:"none"}}):null};function v(e,t,n,r,o,i,c){try{var a=e[i](c),u=a.value}catch(e){n(e);return}a.done?t(u):Promise.resolve(u).then(r,o)}function d(e,t,n){return(d=m()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&y(o,n.prototype),o}).apply(null,arguments)}function b(e){return(b=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function y(e,t){return(y=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return d(e,arguments,b(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),y(n,e)})(e)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}var g=function(e){var n;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");return e=r,t=arguments,e=b(e),function(e,t){var n;if(t&&("object"==((n=t)&&"u">typeof Symbol&&n.constructor===Symbol?"symbol":typeof n)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,m()?Reflect.construct(e,t||[],b(this).constructor):e.apply(this,t))}return r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),e&&y(r,e),n=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:u(0)}),a(c,"throw",{value:u(1)}),a(c,"return",{value:u(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function u(a){return function(u){var l=[a,u];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=0,l[0]&&(i=0)),i;)try{if(n=1,r&&(o=2&l[0]?r.return:l[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,l[1])).done)return o;switch(r=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return i.label++,{value:l[1],done:!1};case 5:i.label++,r=l[1],l=[0];continue;case 7:l=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===l[0]||2===l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){i.label=l[1];break}if(6===l[0]&&i.label<o[1]){i.label=o[1],o=l;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(l);break}o[2]&&i.ops.pop(),i.trys.pop();continue}l=t.call(e,i)}catch(e){l=[6,e],r=0}finally{n=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}}(this,function(e){return t.filePreviewTypes.add({match:u,Previewer:(0,t.wrapWithModalPreviewer)(s)}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function c(e){v(i,r,o,c,a,"next",e)}function a(e){v(i,r,o,c,a,"throw",e)}c(void 0)})})()}}],function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(r.prototype,n),r}(h(e.Plugin)),w=g}(),p}()});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office/client-v2",["react","antd","@nocobase/plugin-file-manager/client-v2","@nocobase/client-v2","@ant-design/icons","@nocobase/flow-engine"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office/client-v2"]=t(require("react"),require("antd"),require("@nocobase/plugin-file-manager/client-v2"),require("@nocobase/client-v2"),require("@ant-design/icons"),require("@nocobase/flow-engine")):e["@nocobase/plugin-file-previewer-office/client-v2"]=t(e.react,e.antd,e["@nocobase/plugin-file-manager/client-v2"],e["@nocobase/client-v2"],e["@ant-design/icons"],e["@nocobase/flow-engine"])}(self,function(e,t,r,n,o,i){return function(){"use strict";var a={375:function(e){e.exports=o},485:function(e){e.exports=n},694:function(e){e.exports=i},936:function(e){e.exports=r},59:function(e){e.exports=t},155:function(t){t.exports=e}},l={};function c(e){var t=l[e];if(void 0!==t)return t.exports;var r=l[e]={exports:{}};return a[e](r,r.exports,c),r.exports}c.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return c.d(t,{a:t}),t},c.d=function(e,t){for(var r in t)c.o(t,r)&&!c.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},c.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||Function("return this")()}catch(e){if("object"==typeof window)return window}}(),c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},c.g.importScripts&&(u=c.g.location+"");var u,f=c.g.document;if(!u&&f&&(f.currentScript&&"SCRIPT"===f.currentScript.tagName.toUpperCase()&&(u=f.currentScript.src),!u)){var s=f.getElementsByTagName("script");if(s.length)for(var p=s.length-1;p>-1&&(!u||!/^http(s?):/.test(u));)u=s[p--].src}if(!u)throw Error("Automatic publicPath is not supported in this browser");c.p=u.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var v={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src){var r=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"");r.indexOf("/static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/")>=0&&(e=r.replace(/\/[^\/]+$/,"/"))}if(!e){var n=window.__webpack_public_path__||"";n&&("/"!==n.charAt(n.length-1)&&(n+="/"),e=n+"static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/")}if(!e){var o=window.__nocobase_modern_client_prefix__||"v",i="/"+(o=String(o).replace(/^\/+|\/+$/g,"")||"v")+"/";if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var a=window.location.pathname||"/",l=a.indexOf(i);e=l>=0?a.slice(0,l+1):"/"}e&&(e=e.replace(RegExp("/"+o+"/?$"),"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-previewer-office/dist/client-v2/"}c.p=e}(),!function(){c.r(v),c.d(v,{PluginFilePreviewerOfficeClientV2:function(){return C},default:function(){return T}});var e=c(485),t=c(936);function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function n(e,t,r,n,o,i,a){try{var l=e[i](a),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function o(e){return e&&"u">typeof Symbol&&e.constructor===Symbol?"symbol":typeof e}var i=["application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/msword","application/vnd.ms-excel","application/vnd.ms-powerpoint","application/vnd.oasis.opendocument.text"],a=["docx","xlsx","pptx","odt","doc","xls","ppt"],l=function(e){var t="string"==typeof e?e:(null==e?void 0:e.extname)||(null==e?void 0:e.name)||(null==e?void 0:e.filename)||(null==e?void 0:e.url)||"",r=t.split("?")[0].split("#")[0].split("/").filter(Boolean),n=r[r.length-1]||t,o=n;try{o=decodeURIComponent(n)}catch(e){}var i=o.lastIndexOf(".");return -1!==i?o.slice(i+1).toLowerCase():""},u=function(e){var t="string"==typeof e?e:null==e?void 0:e.url;return t?t.startsWith("https://")||t.startsWith("http://")?t:"".concat(location.origin,"/").concat(t.replace(/^\//,"")):""},f=function(e){var t=u(e);if(!t)return"";var r=new URL("https://view.officeapps.live.com/op/embed.aspx");return r.searchParams.set("src",t),r.href},s=/^[A-Za-z0-9_][A-Za-z0-9_-]*$/,p=function(e){var t,n="string"==typeof e?e:null==e?void 0:e.url;if(!n)return null;try{t=new URL(n,location.origin)}catch(e){return null}if(t.origin!==location.origin||t.searchParams.has("temporaryAccessToken"))return null;var o=t.pathname.split("/").filter(Boolean),i=o.length-5;if(i<0||"files"!==o[i])return null;var a=o.slice(i+1);if(4!==a.length)return null;try{var l,c=(l=a.map(decodeURIComponent),function(e){if(Array.isArray(e))return e}(l)||function(e){var t,r,n=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o=[],i=!0,a=!1;try{for(n=n.call(e);!(i=(t=n.next()).done)&&(o.push(t.value),4!==o.length);i=!0);}catch(e){a=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(a)throw r}}return o}}(l)||function(e){if(e){if("string"==typeof e)return r(e,4);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r(e,4)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=c[0],f=c[1],p=c[2],v=c[3];if(!s.test(u)||!s.test(f)||!s.test(p))return null;var d=v.lastIndexOf("."),y=d>0?v.slice(0,d):v;return{appName:u,dataSourceKey:f,collectionName:p,id:y}}catch(e){return null}},d=function(e,t,r){var i;return(i=function(){var n,i,a,l,c,f,s,v;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(d){switch(d.label){case 0:if(r&&t&&(void 0===t?"undefined":o(t))==="object"&&null!=t.id&&null!=t.storageId)c={"X-Data-Source":(l={dataSourceKey:r.dataSourceKey,collectionName:r.collectionName,id:String(t.id)}).dataSourceKey};else{if(!(f=p(t))||r&&f.collectionName!==r.collectionName)return[2,u(t)];l=f,c={"X-App":f.appName,"X-Data-Source":f.dataSourceKey}}return[4,e.request({url:"".concat(encodeURIComponent(l.collectionName),":createTemporaryURL/").concat(encodeURIComponent(l.id)),method:"post",headers:c})];case 1:if(!(v=(null==(i=(s=d.sent()).data)||null==(n=i.data)?void 0:n.url)||(null==(a=s.data)?void 0:a.url)))throw Error("Temporary file URL is missing");return[2,new URL(v,location.origin).href]}})},function(){var e=this,t=arguments;return new Promise(function(r,o){var a=i.apply(e,t);function l(e){n(a,r,o,l,c,"next",e)}function c(e){n(a,r,o,l,c,"throw",e)}l(void 0)})})()},y=function(e){if(e&&(void 0===e?"undefined":o(e))==="object"&&e.mimetype&&i.includes(e.mimetype))return!0;var t=l(e);return!!t&&a.includes(t)},b=c(155),h=c.n(b),m=c(375),g=c(59),w=c(694);function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r<t;r++)n[r]=e[r];return n}function x(e,t,r,n,o,i,a){try{var l=e[i](a),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function O(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r,n,o=null==e?null:"u">typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var i=[],a=!0,l=!1;try{for(o=o.call(e);!(a=(r=o.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){l=!0,n=e}finally{try{a||null==o.return||o.return()}finally{if(l)throw n}}return i}}(e,t)||function(e,t){if(e){if("string"==typeof e)return S(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return S(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var j=function(t){var r,n=t.file,o=t.fileCollection,i=t.onDownload,a=t.onPreviewUrlChange,l=(0,e.useApp)(),c=(r=(0,w.useFlowEngine)(),function(e,t){return r.context.t(e,function(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){var n;n=r[t],t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n})}return e}({ns:["file-previewer-office","client"]},t))}),u="string"==typeof n?n:null==n?void 0:n.url,s=null==o?void 0:o.dataSourceKey,p=null==o?void 0:o.collectionName,v=O((0,b.useState)(""),2),y=v[0],S=v[1],j=O((0,b.useState)(!1),2),_=j[0],P=j[1],E=O((0,b.useState)(!1),2),A=E[0],I=E[1],k=(0,b.useRef)(0),C=(0,b.useRef)(!1),T=(0,b.useCallback)(function(){var e;return(e=function(){var e,t;return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:e=++k.current,P(!0),I(!1),S(""),null==a||a(""),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,d(l.apiClient,n,s&&p?{dataSourceKey:s,collectionName:p}:void 0)];case 2:if(t=r.sent(),e!==k.current)return[2];return S(t),null==a||a(f(t)),[3,5];case 3:return r.sent(),e===k.current&&(S(""),I(!0),null==a||a("")),[3,5];case 4:return e===k.current&&P(!1),[7];case 5:return[2]}})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){x(i,n,o,a,l,"next",e)}function l(e){x(i,n,o,a,l,"throw",e)}a(void 0)})})()},[l.apiClient,p,s,n,a]);(0,b.useEffect)(function(){return C.current=!1,T(),function(){k.current+=1}},[T,u]);var R=(0,b.useMemo)(function(){return f(y)},[y]),q=(0,b.useCallback)(function(){C.current?I(!0):(C.current=!0,T())},[T]);return _?h().createElement(g.Spin,{tip:c("Loading preview"),"aria-label":c("Loading preview")}):A?h().createElement(g.Alert,{type:"warning",showIcon:!0,message:c("Failed to load Office preview"),action:h().createElement(g.Button,{icon:h().createElement(m.DownloadOutlined,null),onClick:function(){return i(n)}},c("Download"))}):R?h().createElement("iframe",{src:R,title:c("Office file preview"),width:"100%",height:"100%",style:{border:"none"},onError:q}):null};function _(e,t,r,n,o,i,a){try{var l=e[i](a),c=l.value}catch(e){r(e);return}l.done?t(c):Promise.resolve(c).then(n,o)}function P(e,t,r){return(P=k()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var o=new(Function.bind.apply(e,n));return r&&A(o,r.prototype),o}).apply(null,arguments)}function E(e){return(E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function A(e,t){return(A=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function I(e){var t="function"==typeof Map?new Map:void 0;return(I=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,r)}function r(){return P(e,arguments,E(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),A(r,e)})(e)}function k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(k=function(){return!!e})()}var C=function(e){var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function n(){var e,t;if(!(this instanceof n))throw TypeError("Cannot call a class as a function");return e=n,t=arguments,e=E(e),function(e,t){var r;if(t&&("object"==((r=t)&&"u">typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)||"function"==typeof t))return t;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,k()?Reflect.construct(e,t||[],E(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&A(n,e),r=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var r,n,o,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),l=Object.defineProperty;return l(a,"next",{value:c(0)}),l(a,"throw",{value:c(1)}),l(a,"return",{value:c(2)}),"function"==typeof Symbol&&l(a,Symbol.iterator,{value:function(){return this}}),a;function c(l){return function(c){var u=[l,c];if(r)throw TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(i=0)),i;)try{if(r=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return i.label++,{value:u[1],done:!1};case 5:i.label++,n=u[1],u=[0];continue;case 7:u=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){i=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){i.label=u[1];break}if(6===u[0]&&i.label<o[1]){i.label=o[1],o=u;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(u);break}o[2]&&i.ops.pop(),i.trys.pop();continue}u=t.call(e,i)}catch(e){u=[6,e],n=0}finally{r=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(e){return t.filePreviewTypes.add({match:y,Previewer:(0,t.wrapWithModalPreviewer)(j)}),[2]})},function(){var t=this,r=arguments;return new Promise(function(n,o){var i=e.apply(t,r);function a(e){_(i,n,o,a,l,"next",e)}function l(e){_(i,n,o,a,l,"throw",e)}a(void 0)})})()}}],function(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(n.prototype,r),n}(I(e.Plugin)),T=C}(),v}()});
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
* the helpers stay tolerant of partial records coming from different call sites.
|
|
13
13
|
*/
|
|
14
14
|
export interface OfficePreviewFileObject {
|
|
15
|
+
id?: string | number;
|
|
16
|
+
storageId?: string | number;
|
|
15
17
|
url?: string;
|
|
16
18
|
mimetype?: string;
|
|
17
19
|
extname?: string;
|
|
@@ -20,9 +22,28 @@ export interface OfficePreviewFileObject {
|
|
|
20
22
|
title?: string;
|
|
21
23
|
}
|
|
22
24
|
export type OfficePreviewFile = string | OfficePreviewFileObject | null | undefined;
|
|
25
|
+
export interface FileCollectionReference {
|
|
26
|
+
dataSourceKey: string;
|
|
27
|
+
collectionName: string;
|
|
28
|
+
}
|
|
29
|
+
export interface PermanentFileAccessParams extends FileCollectionReference {
|
|
30
|
+
appName: string;
|
|
31
|
+
id: string;
|
|
32
|
+
}
|
|
33
|
+
export interface OfficePreviewAPIClient {
|
|
34
|
+
request<T>(config: {
|
|
35
|
+
url: string;
|
|
36
|
+
method: 'post';
|
|
37
|
+
headers: Record<string, string>;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
data: T;
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
23
42
|
export declare const OFFICE_MIME_TYPES: string[];
|
|
24
43
|
export declare const OFFICE_EXTS: string[];
|
|
25
44
|
export declare const getOfficeFileExt: (file: OfficePreviewFile) => string;
|
|
26
45
|
export declare const resolveFileUrl: (file: OfficePreviewFile) => string;
|
|
27
46
|
export declare const getOfficePreviewUrl: (file: OfficePreviewFile) => string;
|
|
47
|
+
export declare const parsePermanentFileUrl: (file: OfficePreviewFile) => PermanentFileAccessParams | null;
|
|
48
|
+
export declare const resolveTemporaryOfficeFileUrl: (apiClient: OfficePreviewAPIClient, file: OfficePreviewFile, fileCollection?: FileCollectionReference) => Promise<string>;
|
|
28
49
|
export declare const isOfficeFile: (file: OfficePreviewFile) => boolean;
|
package/dist/externalVersion.js
CHANGED
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
module.exports = {
|
|
11
11
|
"react": "18.2.0",
|
|
12
12
|
"antd": "5.24.2",
|
|
13
|
-
"@nocobase/client": "2.2.0
|
|
14
|
-
"@nocobase/plugin-file-manager": "2.2.0
|
|
15
|
-
"@
|
|
16
|
-
"@nocobase/
|
|
17
|
-
"@nocobase/
|
|
13
|
+
"@nocobase/client": "2.2.0",
|
|
14
|
+
"@nocobase/plugin-file-manager": "2.2.0",
|
|
15
|
+
"@ant-design/icons": "5.6.1",
|
|
16
|
+
"@nocobase/client-v2": "2.2.0",
|
|
17
|
+
"@nocobase/flow-engine": "2.2.0",
|
|
18
|
+
"@nocobase/server": "2.2.0"
|
|
18
19
|
};
|
package/dist/locale/en-US.json
CHANGED
package/dist/locale/zh-CN.json
CHANGED
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"description": "A plugin for previewing office files via Microsoft live preview service.",
|
|
7
7
|
"description.ru-RU": "Плагин для просмотра Office-файлов через Microsoft live preview service.",
|
|
8
8
|
"description.zh-CN": "基于微软在线服务预览 Office 文件的插件。",
|
|
9
|
-
"version": "2.2.0
|
|
9
|
+
"version": "2.2.0",
|
|
10
10
|
"main": "dist/server/index.js",
|
|
11
11
|
"peerDependencies": {
|
|
12
12
|
"@nocobase/client": "2.x",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"Collection fields"
|
|
21
21
|
],
|
|
22
22
|
"license": "Apache-2.0",
|
|
23
|
-
"gitHead": "
|
|
23
|
+
"gitHead": "d5052cae37177054c236f1bf7bba3aed6ef029d0"
|
|
24
24
|
}
|