@nocobase/plugin-file-previewer-office 2.1.0-beta.6 → 2.1.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,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("file-saver"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office",["react","file-saver","@nocobase/plugin-file-manager/client","@nocobase/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office"]=t(require("react"),require("file-saver"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("antd")):e["@nocobase/plugin-file-previewer-office"]=t(e.react,e["file-saver"],e["@nocobase/plugin-file-manager/client"],e["@nocobase/client"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var i={772:function(e){e.exports=r},183:function(e){e.exports=n},721:function(e){e.exports=o},346:function(e){e.exports=t},156:function(t){t.exports=e}},u={};function a(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](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.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return!function(){a.r(c),a.d(c,{PluginFilePreviewerOfficeClient:function(){return P},default:function(){return j}});var e=a(156),t=a.n(e),n=a(721),r=a(346),o=a(772),i=a(183),u=JSON.parse('{"u2":"@nocobase/plugin-file-previewer-office"}');function l(e,t,n,r,o,i,u){try{var a=e[i](u),c=a.value}catch(e){n(e);return}a.done?t(c):Promise.resolve(c).then(r,o)}function f(e,t,n){return(f=v()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&s(o,n.prototype),o}).apply(null,arguments)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=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 f(e,arguments,p(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)})(e)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}var y=["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"],m=["docx","xlsx","pptx","odt","doc","xls","ppt"],b=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():""},h=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(/^\//,"")):""},w=function(e){var t=h(e);if(!t)return"";var n=new URL("https://view.officeapps.live.com/op/embed.aspx");return n.searchParams.set("src",t),n.href},x=function(e){if((null==e?void 0:e.mimetype)&&y.includes(e.mimetype))return!0;var t=b(e);return!!t&&m.includes(t)};function g(i){var a,c=i.index,l=i.list,f=i.onSwitchIndex,p=(a=(0,o.useApp)(),function(e){return a.i18n.t(e,{ns:[u.u2,"client"]})}),s=l[c],d=(0,e.useMemo)(function(){return w(s)},[s]),v=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),window.open(d)},[d]),y=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),(0,r.saveAs)(s.url,"".concat(s.title).concat(s.extname))},[s.extname,s.title,s.url]),m=(0,e.useCallback)(function(){f(null)},[f]);return t().createElement(n.Modal,{open:null!=c,title:s.title,onCancel:m,footer:[t().createElement(n.Button,{key:"open",onClick:v},p("Open in new window")),t().createElement(n.Button,{key:"download",onClick:y},p("Download")),t().createElement(n.Button,{key:"close",onClick:m},p("Close"))],width:"85vw",centered:!0},t().createElement("div",{style:{maxWidth:"100%",maxHeight:"calc(100vh - 256px)",height:"100%",width:"100%",background:"white",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",overflowY:"auto"}},t().createElement("iframe",{src:d,style:{width:"100%",maxHeight:"100%",flex:"1 1 auto",border:"none"}})))}function O(n){var r=n.file,o=(0,e.useMemo)(function(){return w(r)},["string"==typeof r?r:null==r?void 0:r.url]);return o?t().createElement("iframe",{src:o,width:"100%",height:"100%",style:{border:"none"}}):null}var P=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=p(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,v()?Reflect.construct(e,t||[],p(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&s(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){var c=[i,a];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,r=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===c[0]||2===c[0])){u=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){u.label=c[1];break}if(6===c[0]&&u.label<o[1]){u.label=o[1],o=c;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(c);break}o[2]&&u.ops.pop(),u.trys.pop();continue}c=t.call(e,u)}catch(e){c=[6,e],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}}(this,function(e){return o.attachmentFileTypes.add({match:x,Previewer:g}),i.filePreviewTypes.add({match:x,Previewer:(0,i.wrapWithModalPreviewer)(O)}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){l(i,r,o,u,a,"next",e)}function a(e){l(i,r,o,u,a,"throw",e)}u(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}(d(o.Plugin)),j=P}(),c}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("file-saver"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("antd")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office",["react","file-saver","@nocobase/plugin-file-manager/client","@nocobase/client","antd"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office"]=t(require("react"),require("file-saver"),require("@nocobase/plugin-file-manager/client"),require("@nocobase/client"),require("antd")):e["@nocobase/plugin-file-previewer-office"]=t(e.react,e["file-saver"],e["@nocobase/plugin-file-manager/client"],e["@nocobase/client"],e.antd)}(self,function(e,t,n,r,o){return function(){"use strict";var i={772:function(e){e.exports=r},183:function(e){e.exports=n},721:function(e){e.exports=o},346:function(e){e.exports=t},156:function(t){t.exports=e}},u={};function c(e){var t=u[e];if(void 0!==t)return t.exports;var n=u[e]={exports:{}};return i[e](n,n.exports,c),n.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 n in t)c.o(t,n)&&!c.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},c.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},c.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return!function(){c.r(a),c.d(a,{PluginFilePreviewerOfficeClient:function(){return P},default:function(){return k}});var e=c(156),t=c.n(e),n=c(721),r=c(346),o=c(772),i=c(183),u=JSON.parse('{"u2":"@nocobase/plugin-file-previewer-office"}');function l(e,t,n,r,o,i,u){try{var c=e[i](u),a=c.value}catch(e){n(e);return}c.done?t(a):Promise.resolve(a).then(r,o)}function f(e,t,n){return(f=v()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var o=new(Function.bind.apply(e,r));return n&&s(o,n.prototype),o}).apply(null,arguments)}function p(e){return(p=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function s(e,t){return(s=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function d(e){var t="function"==typeof Map?new Map:void 0;return(d=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 f(e,arguments,p(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),s(n,e)})(e)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}var y=["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"],b=["docx","xlsx","pptx","odt","doc","xls","ppt"],m=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():""},h=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(/^\//,"")):""},w=function(e){var t=h(e);if(!t)return"";var n=new URL("https://view.officeapps.live.com/op/embed.aspx");return n.searchParams.set("src",t),n.href},g=function(e){if((null==e?void 0:e.mimetype)&&y.includes(e.mimetype))return!0;var t=m(e);return!!t&&b.includes(t)};function x(i){var c,a=i.index,l=i.list,f=i.onSwitchIndex,p=(c=(0,o.useApp)(),function(e){return c.i18n.t(e,{ns:[u.u2,"client"]})}),s=l[a],d=(0,e.useMemo)(function(){return w(s)},[s]),v=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),window.open(d)},[d]),y=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),(0,r.saveAs)(s.url,"".concat(s.title).concat(s.extname))},[s.extname,s.title,s.url]),b=(0,e.useCallback)(function(){f(null)},[f]);return t().createElement(n.Modal,{open:null!=a,title:s.title,onCancel:b,footer:[t().createElement(n.Button,{key:"open",onClick:v},p("Open in new window")),t().createElement(n.Button,{key:"download",onClick:y},p("Download")),t().createElement(n.Button,{key:"close",onClick:b},p("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"}})))}function O(n){var r=n.file,o=(0,e.useMemo)(function(){return w(r)},["string"==typeof r?r:null==r?void 0:r.url]);return o?t().createElement("iframe",{src:o,width:"100%",height:"100%",style:{border:"none"}}):null}var P=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=p(e),function(e,t){var n;if(t&&("object"==((n=t)&&"undefined"!=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,v()?Reflect.construct(e,t||[],p(this).constructor):e.apply(this,t))}return n.prototype=Object.create(e&&e.prototype,{constructor:{value:n,writable:!0,configurable:!0}}),e&&s(n,e),t=[{key:"load",value:function(){var e;return(e=function(){return function(e,t){var n,r,o,i,u={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(i){return function(c){var a=[i,c];if(n)throw TypeError("Generator is already executing.");for(;u;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return u.label++,{value:a[1],done:!1};case 5:u.label++,r=a[1],a=[0];continue;case 7:a=u.ops.pop(),u.trys.pop();continue;default:if(!(o=(o=u.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){u=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){u.label=a[1];break}if(6===a[0]&&u.label<o[1]){u.label=o[1],o=a;break}if(o&&u.label<o[2]){u.label=o[2],u.ops.push(a);break}o[2]&&u.ops.pop(),u.trys.pop();continue}a=t.call(e,u)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}}}(this,function(e){return o.attachmentFileTypes.add({match:g,Previewer:x}),i.filePreviewTypes.add({match:g,Previewer:(0,i.wrapWithModalPreviewer)(O)}),[2]})},function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function u(e){l(i,r,o,u,c,"next",e)}function c(e){l(i,r,o,u,c,"throw",e)}u(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}(d(o.Plugin)),k=P}(),a}()});
@@ -11,7 +11,7 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "antd": "5.24.2",
13
13
  "file-saver": "2.0.5",
14
- "@nocobase/client": "2.1.0-beta.6",
15
- "@nocobase/plugin-file-manager": "2.1.0-beta.6",
16
- "@nocobase/server": "2.1.0-beta.6"
14
+ "@nocobase/client": "2.1.0-beta.8",
15
+ "@nocobase/plugin-file-manager": "2.1.0-beta.8",
16
+ "@nocobase/server": "2.1.0-beta.8"
17
17
  };
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.1.0-beta.6",
9
+ "version": "2.1.0-beta.8",
10
10
  "main": "dist/server/index.js",
11
11
  "peerDependencies": {
12
12
  "@nocobase/client": "2.x",
@@ -19,5 +19,5 @@
19
19
  "Collection fields"
20
20
  ],
21
21
  "license": "Apache-2.0",
22
- "gitHead": "439e45f32ee5f34d771e7f4751ef57eb7d4a82a8"
22
+ "gitHead": "5099d561c5467292414c1e77ad6bad3730d97344"
23
23
  }