@nocobase/plugin-file-previewer-office 2.1.0-beta.14 → 2.1.0-beta.16

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 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}()});
10
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react"),require("antd"),require("@nocobase/client"),require("file-saver"),require("@nocobase/plugin-file-manager/client")):"function"==typeof define&&define.amd?define("@nocobase/plugin-file-previewer-office",["react","antd","@nocobase/client","file-saver","@nocobase/plugin-file-manager/client"],t):"object"==typeof exports?exports["@nocobase/plugin-file-previewer-office"]=t(require("react"),require("antd"),require("@nocobase/client"),require("file-saver"),require("@nocobase/plugin-file-manager/client")):e["@nocobase/plugin-file-previewer-office"]=t(e.react,e.antd,e["@nocobase/client"],e["file-saver"],e["@nocobase/plugin-file-manager/client"])}(self,function(e,t,n,r,o){return function(){"use strict";var i={342:function(e){e.exports=n},609:function(e){e.exports=o},59:function(e){e.exports=t},506:function(e){e.exports=r},155:function(t){t.exports=e}},c={};function a(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[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.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&&(l=a.g.location+"");var l,u=a.g.document;if(!l&&u&&(u.currentScript&&"SCRIPT"===u.currentScript.tagName.toUpperCase()&&(l=u.currentScript.src),!l)){var p=u.getElementsByTagName("script");if(p.length)for(var f=p.length-1;f>-1&&(!l||!/^http(s?):/.test(l));)l=p[f--].src}if(!l)throw Error("Automatic publicPath is not supported in this browser");a.p=l.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/");var s={};return!function(){var e="",t="u">typeof document?document.currentScript:null;if(t&&t.src&&(e=t.src.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/")),!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/")}if(!e){if(!(e=window.__nocobase_public_path__||"")&&window.location&&window.location.pathname){var r=window.location.pathname||"/",o=r.indexOf("/v2/");e=o>=0?r.slice(0,o+1):"/"}e&&(e=e.replace(/\/v2\/?$/,"/")),e||(e="/"),"/"!==e.charAt(e.length-1)&&(e+="/"),e+="static/plugins/@nocobase/plugin-file-previewer-office/dist/client/"}a.p=e}(),!function(){a.r(s),a.d(s,{default:function(){return P},PluginFilePreviewerOfficeClient:function(){return _}});var e=a(155),t=a.n(e),n=a(59),r=a(506),o=a(342),i=a(609),c=JSON.parse('{"UU":"@nocobase/plugin-file-previewer-office"}');function l(e,t,n,r,o,i,c){try{var a=e[i](c),l=a.value}catch(e){n(e);return}a.done?t(l):Promise.resolve(l).then(r,o)}function u(e,t,n){return(u=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&&f(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 f(e,t){return(f=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 u(e,arguments,p(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),f(n,e)})(e)}function v(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(v=function(){return!!e})()}var b=["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"],h=["docx","xlsx","pptx","odt","doc","xls","ppt"],y=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():""},m=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=m(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)&&b.includes(e.mimetype))return!0;var t=y(e);return!!t&&h.includes(t)};function x(i){var a,l=i.index,u=i.list,p=i.onSwitchIndex,f=(a=(0,o.useApp)(),function(e){return a.i18n.t(e,{ns:[c.UU,"client"]})}),s=u[l],d=(0,e.useMemo)(function(){return w(s)},[s]),v=(0,e.useCallback)(function(e){e.preventDefault(),e.stopPropagation(),window.open(d)},[d]),b=(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]),h=(0,e.useCallback)(function(){p(null)},[p]);return t().createElement(n.Modal,{open:null!=l,title:s.title,onCancel:h,footer:[t().createElement(n.Button,{key:"open",onClick:v},f("Open in new window")),t().createElement(n.Button,{key:"download",onClick:b},f("Download")),t().createElement(n.Button,{key:"close",onClick:h},f("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 _=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)&&"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,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&&f(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:[]},c=Object.create(("function"==typeof Iterator?Iterator:Object).prototype),a=Object.defineProperty;return a(c,"next",{value:l(0)}),a(c,"throw",{value:l(1)}),a(c,"return",{value:l(2)}),"function"==typeof Symbol&&a(c,Symbol.iterator,{value:function(){return this}}),c;function l(a){return function(l){var u=[a,l];if(n)throw TypeError("Generator is already executing.");for(;c&&(c=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: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 c(e){l(i,r,o,c,a,"next",e)}function a(e){l(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)}}(n.prototype,t),n}(d(o.Plugin)),P=_}(),s}()});
@@ -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.14",
15
- "@nocobase/plugin-file-manager": "2.1.0-beta.14",
16
- "@nocobase/server": "2.1.0-beta.14"
14
+ "@nocobase/client": "2.1.0-beta.16",
15
+ "@nocobase/plugin-file-manager": "2.1.0-beta.16",
16
+ "@nocobase/server": "2.1.0-beta.16"
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.14",
9
+ "version": "2.1.0-beta.16",
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": "cd55c9a14596d834c30c83a82c38f1f719f7aac4"
22
+ "gitHead": "b9a191705a440a336c85d82fd877fdf152bec70f"
23
23
  }