@chao194/office 1.0.9 → 1.1.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.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("vue"),t=require("eventemitter3"),o=require("axios");const i=e.defineComponent({name:"OnlyOfficeEditor",props:{officeApiUrl:{type:String,required:!0},document:{type:Object,required:!0},auth:{type:Object,default:void 0},verifyFunction:{type:Function,default:void 0},skipVerification:{type:Boolean,default:!1},height:{type:String,default:"100%"},width:{type:String,default:"100%"}},emits:["ready","error","documentStateChange","requestHistory","requestHistoryData","requestHistoryClose","requestRestore"],setup(t,{emit:o}){const i=`onlyoffice-${Date.now().toString(36)}`,r=e.ref(!1),n=e.ref(null);let s=null;const l=e=>({doc:"word",docx:"word",odt:"word",rtf:"word",txt:"word",html:"word",epub:"word",xls:"cell",xlsx:"cell",ods:"cell",csv:"cell",ppt:"slide",pptx:"slide",odp:"slide",pdf:"word"}[e]||"word");return e.onMounted(()=>{console.log("[OnlyOffice Component] onMounted called"),console.log("[OnlyOffice Component] Props:",{officeApiUrl:t.officeApiUrl,document:t.document,skipVerification:t.skipVerification}),setTimeout(()=>{(()=>{console.log("[OnlyOffice Component] initEditor called");const e=document.getElementById(i);if(console.log("[OnlyOffice Component] Container element:",e),!e)return console.error("[OnlyOffice Component] Cannot find container element with id:",i),void(n.value="无法找到编辑器容器");if(!window.DocsAPI||!window.DocsAPI.DocEditor)return console.error("[OnlyOffice Component] window.DocsAPI is not available"),void(n.value="OnlyOffice API 未加载");try{console.log("[OnlyOffice Component] Creating editor with config:",{key:t.document.key,url:t.document.url,title:t.document.title,fileType:t.document.fileType});const e={width:t.width,height:t.height,documentType:l(t.document.fileType),document:{fileType:t.document.fileType,key:t.document.key,url:t.document.url,title:t.document.title,permissions:t.document.permissions||{edit:!0,download:!0,review:!0}},editorConfig:{lang:"zh",mode:"edit",callbackUrl:t.document.callbackUrl,user:{id:t.document.userId||"",name:t.document.userName||""}},events:{onDocumentReady:()=>{console.log("[OnlyOffice] Document ready"),r.value=!0,o("ready",s)},onDocumentStateChange:e=>{o("documentStateChange",e)},onError:e=>{var t;console.error("[OnlyOffice] Error:",e),n.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误",o("error",e)},onRequestHistory:e=>{o("requestHistory",{event:e,editor:s})},onRequestHistoryData:e=>{o("requestHistoryData",{event:e,editor:s})},onRequestHistoryClose:e=>{o("requestHistoryClose",{event:e,editor:s})},onRequestRestore:e=>{o("requestRestore",{event:e,editor:s})}}};s=new window.DocsAPI.DocEditor(i,e),console.log("[OnlyOffice] Editor created successfully")}catch(e){console.error("[OnlyOffice] Error creating editor:",e),n.value=e.message||"初始化失败",o("error",e)}})()},0)}),e.onBeforeUnmount(()=>{(()=>{if(s){try{s.destroyEditor()}catch(e){console.warn("[OnlyOffice] Error destroying editor:",e)}s=null,r.value=!1}})()}),{editorId:i,isReady:r,error:n}},render(){return e.h("div",{class:"onlyoffice-editor-container",style:{width:this.width,height:this.height,position:"relative",minHeight:"400px"}},[e.h("div",{id:this.editorId,style:{width:"100%",height:"100%"}}),this.error?e.h("div",{class:"onlyoffice-error",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"red",zIndex:10}},this.error):null])}});function r(e){const t=e.toLowerCase();if(["doc","docx","odt","rtf","txt","html","epub"].includes(t))return"word";if(["xls","xlsx","ods","csv"].includes(t))return"cell";return["ppt","pptx","odp"].includes(t)?"slide":"pdf"===t?"pdf":"other"}class n{constructor(e=""){this.baseUrl=e}async post(e,t,i){const r=this.baseUrl?`${this.baseUrl}${e}`:e;return o.post(r,t,i)}async get(e,t){const i=this.baseUrl?`${this.baseUrl}${e}`:e;return o.get(i,t)}}async function s(e,t){var o;try{const i=new n(e);return!0===(null===(o=(await i.post("/onlyoffice/token/verifyTokenSign",t)).data)||void 0===o?void 0:o.data)}catch(e){return console.error("验签请求失败:",e),!1}}async function l(e,t){try{await o.post(e,t)}catch(e){console.error("保存操作信息失败:",e)}}var c=Object.freeze({__proto__:null,HttpClient:n,saveSuccessInfo:l,verifyTokenSign:s});const d={comment:!1,download:!1,edit:!1,print:!0,review:!1,editCommentAuthorOnly:!1,fillForms:!1,modifyContentControl:!1};class a{constructor(){this.editor=null,this.callback=null,this.height="100%",this.width="100%",this.editorId=`editor-${Date.now().toString(32)}`,this.emitter=new t,this.documentConfig={fileType:"docx",key:"",url:"",title:"",permissions:{...d}},this.editorConfig={lang:"zh",user:{id:"",name:""}}}configure(e){if(e.height&&(this.height=e.height),e.width&&(this.width=e.width),e.fileType){if("other"===r(e.fileType))throw new Error(`不支持的文件类型: ${e.fileType}`);"other"!==r(e.fileType)&&(this.documentConfig.fileType=e.fileType)}e.key&&(this.documentConfig.key=e.key),e.url&&(this.documentConfig.url=e.url),e.title&&(this.documentConfig.title=e.title),e.permissions&&(this.documentConfig.permissions={...this.documentConfig.permissions,...e.permissions},"pdf"===this.documentConfig.fileType&&(this.documentConfig.permissions.edit=!1,this.documentConfig.permissions.review=!1,this.editorConfig.mode="view")),e.callbackUrl&&(this.editorConfig.callbackUrl=e.callbackUrl),e.userId&&(this.editorConfig.user={...this.editorConfig.user,id:e.userId}),e.userName&&(this.editorConfig.user={...this.editorConfig.user,name:e.userName}),e.userGroup&&(this.editorConfig.user={...this.editorConfig.user,group:e.userGroup})}async initOffice(e){const{dom:t,officeApiUrl:o,callback:i,auth:r,verifyFunction:n}=e;if(i&&(this.callback=i),r){let e=!1;if(n)e=await n(r);else{if(!r.verifyUrl)throw new Error("使用验签配置时,必须提供 verifyFunction 或 verifyUrl");e=await s(r.verifyUrl,{appId:r.appId,sign:r.sign,timestamp:r.timestamp})}if(!e)throw new Error("验签失败,请检查验签配置")}return this.createEditor(t,o)}init(e,t,o){return o&&(this.callback=o),this.createEditor(e,t)}createEditor(e,t){if(console.log("[OnlyOffice] createEditor called",{dom:e,officeApiUrl:t}),!e)throw new Error("必须提供挂载的 DOM 元素");if(!t)throw new Error("必须提供 OnlyOffice API 脚本地址");e.style.position="relative",console.log("[OnlyOffice] DOM dimensions:",{width:e.offsetWidth,height:e.offsetHeight});const o=document.createElement("div");o.id=this.editorId,o.style.height="100%",o.style.width="100%",e.appendChild(o);const i=`script-${this.editorId}`;if(document.querySelector(`#${i}`))console.log("[OnlyOffice] Script already loaded"),this.instantiateEditor();else{console.log("[OnlyOffice] Loading script:",t);const e=document.createElement("script");e.id=i,e.src=t,e.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),this.instantiateEditor()},e.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e)},document.head.appendChild(e)}return this}instantiateEditor(){if(console.log("[OnlyOffice] instantiateEditor called"),this.editor&&(this.editor.destroyEditor(),this.editor=null),!window.DocsAPI||!window.DocsAPI.DocEditor)return void console.error("[OnlyOffice] window.DocsAPI.DocEditor is not available");const e={width:this.width,height:this.height,documentType:this.getDocumentType(),document:this.documentConfig,editorConfig:this.editorConfig,events:this.createEventHandlers()};console.log("[OnlyOffice] Creating editor with config:",e),console.log("[OnlyOffice] Editor container ID:",this.editorId),console.log("[OnlyOffice] Container element:",document.getElementById(this.editorId));try{this.editor=new window.DocsAPI.DocEditor(this.editorId,e),console.log("[OnlyOffice] Editor created successfully:",this.editor)}catch(e){console.error("[OnlyOffice] Error creating editor:",e)}}getDocumentType(){const e=r(this.documentConfig.fileType);return"other"===e?"word":e}createEventHandlers(){return{onDocumentStateChange:e=>{this.emitter.emit("documentStateChange",e)},onDocumentReady:()=>{var e,t;console.log("Document is loaded"),this.editorConfig.callbackUrl&&l(this.editorConfig.callbackUrl,{status:8,key:this.documentConfig.key,userdata:JSON.stringify({appUserId:null===(e=this.editorConfig.user)||void 0===e?void 0:e.id})}),null===(t=this.callback)||void 0===t||t.call(this,"onDocumentReady"),this.emitter.emit("onDocumentReady")},onInfo:e=>{var t;console.log("ONLYOFFICE Document Editor is opened in mode",e.data.mode),null===(t=this.callback)||void 0===t||t.call(this,"onInfo",e.data),this.emitter.emit("onInfo",e)},onError:e=>{console.error("ONLYOFFICE Error:",e.data.errorCode,e.data.errorDescription),this.emitter.emit("onError",e)},onRequestHistory:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistory",e,this.editor),this.emitter.emit("onRequestHistory",{event:e,editor:this.editor})},onRequestHistoryData:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryData",e,this.editor),this.emitter.emit("onRequestHistoryData",{event:e,editor:this.editor})},onRequestHistoryClose:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryClose",e,this.editor),this.emitter.emit("onRequestHistoryClose",{event:e,editor:this.editor})},onRequestRestore:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestRestore",e,this.editor),this.emitter.emit("onRequestRestore",{event:e,editor:this.editor})},onRequestSendNotify:e=>{console.log("onRequestSendNotify",e),this.emitter.emit("onRequestSendNotify",e)},onRequestUsers:e=>{console.log("onRequestUsers",e),this.emitter.emit("onRequestUsers",e)}}}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getConfig(){return{...this.documentConfig,...this.editorConfig}}getEditor(){return this.editor}destroy(){this.editor&&(this.editor.destroyEditor(),this.editor=null),this.emitter.removeAllListeners(),this.callback=null}}exports.OnlyOfficeEditor=i,exports.createOfficeEditor=function(){return new a},exports.downloadSave=async function(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return c});await i(e,{status:9,key:t,userdata:JSON.stringify({appUserId:o})})},exports.init=function(e,t,o){return(new a).init(e,t,o)},exports.initOffice=async function(e){return(new a).initOffice(e)},exports.shareSave=async function(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return c});await i(e,{status:10,key:t,userdata:JSON.stringify({appUserId:o})})},exports.useOnlyOffice=function(t){const{officeApiUrl:o,document:i,auth:r,verifyFunction:n,height:s="100%",width:l="100%",autoInit:c=!0}=t,d=e.ref(null),u=e.ref(null),f=e.ref(!1),h=e.ref(null);let y=null;const m=async()=>{if(d.value)try{p(),y=new a,y.configure({...i,height:s,width:l});const e=(e,t,o)=>{if("onDocumentReady"===e)f.value=!0},t={dom:d.value,officeApiUrl:o,callback:e,auth:r,verifyFunction:n};u.value=await y.initOffice(t),y.on("onError",e=>{var t;h.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误"})}catch(e){h.value=e.message||"初始化失败"}else h.value="容器元素未找到"},p=()=>{y&&(y.destroy(),y=null,u.value=null,f.value=!1)},g=async()=>{p(),await m()};return e.watch(()=>i,async e=>{y&&e&&await g()},{deep:!0}),e.onMounted(()=>{c&&m()}),e.onBeforeUnmount(()=>{p()}),{containerRef:d,editorInstance:u,isReady:f,error:h,init:m,destroy:p,reinit:g,on:(e,t)=>{y&&y.on(e,t)},off:(e,t)=>{y&&y.off(e,t)}}};
1
+ "use strict";var e=require("vue"),t=require("eventemitter3"),o=require("axios");const i=e.defineComponent({name:"OnlyOfficeEditor",props:{officeApiUrl:{type:String,required:!0},document:{type:Object,required:!0},auth:{type:Object,default:void 0},verifyFunction:{type:Function,default:void 0},skipVerification:{type:Boolean,default:!1},height:{type:String,default:"100%"},width:{type:String,default:"100%"}},emits:["ready","error","documentStateChange","requestHistory","requestHistoryData","requestHistoryClose","requestRestore"],setup(t,{emit:o}){const i=`onlyoffice-${Date.now().toString(36)}`,n=e.ref(!1),r=e.ref(null);let s=null;const l=async()=>{console.log("[OnlyOffice Component] initEditor called");try{await new Promise((e,o)=>{if(window.DocsAPI&&window.DocsAPI.DocEditor)return console.log("[OnlyOffice] Script already loaded"),void e();const i="onlyoffice-api-script";if(document.getElementById(i)){console.log("[OnlyOffice] Script element exists, waiting for load");const t=()=>{window.DocsAPI&&window.DocsAPI.DocEditor?e():setTimeout(t,100)};return void t()}console.log("[OnlyOffice] Loading script:",t.officeApiUrl);const n=document.createElement("script");n.id=i,n.src=t.officeApiUrl,n.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),e()},n.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e),o(new Error("OnlyOffice API 脚本加载失败"))},document.head.appendChild(n)});const e=document.getElementById(i);if(console.log("[OnlyOffice Component] Container element:",e),!e)return console.error("[OnlyOffice Component] Cannot find container element with id:",i),void(r.value="无法找到编辑器容器");console.log("[OnlyOffice Component] Creating editor with config:",{key:t.document.key,url:t.document.url,title:t.document.title,fileType:t.document.fileType});const l={width:t.width,height:t.height,documentType:c(t.document.fileType),document:{fileType:t.document.fileType,key:t.document.key,url:t.document.url,title:t.document.title,permissions:t.document.permissions||{edit:!0,download:!0,review:!0}},editorConfig:{lang:"zh",mode:"edit",callbackUrl:t.document.callbackUrl,user:{id:t.document.userId||"",name:t.document.userName||""}},events:{onDocumentReady:()=>{console.log("[OnlyOffice] Document ready"),n.value=!0,o("ready",s)},onDocumentStateChange:e=>{o("documentStateChange",e)},onError:e=>{var t;console.error("[OnlyOffice] Error:",e),r.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误",o("error",e)},onRequestHistory:e=>{o("requestHistory",{event:e,editor:s})},onRequestHistoryData:e=>{o("requestHistoryData",{event:e,editor:s})},onRequestHistoryClose:e=>{o("requestHistoryClose",{event:e,editor:s})},onRequestRestore:e=>{o("requestRestore",{event:e,editor:s})}}};s=new window.DocsAPI.DocEditor(i,l),console.log("[OnlyOffice] Editor created successfully")}catch(e){console.error("[OnlyOffice] Error creating editor:",e),r.value=e.message||"初始化失败",o("error",e)}},c=e=>({doc:"word",docx:"word",odt:"word",rtf:"word",txt:"word",html:"word",epub:"word",xls:"cell",xlsx:"cell",ods:"cell",csv:"cell",ppt:"slide",pptx:"slide",odp:"slide",pdf:"word"}[e]||"word");return e.onMounted(()=>{console.log("[OnlyOffice Component] onMounted called"),console.log("[OnlyOffice Component] Props:",{officeApiUrl:t.officeApiUrl,document:t.document,skipVerification:t.skipVerification}),setTimeout(()=>{l()},0)}),e.onBeforeUnmount(()=>{(()=>{if(s){try{s.destroyEditor()}catch(e){console.warn("[OnlyOffice] Error destroying editor:",e)}s=null,n.value=!1}})()}),{editorId:i,isReady:n,error:r}},render(){return e.h("div",{class:"onlyoffice-editor-container",style:{width:this.width,height:this.height,position:"relative",minHeight:"400px"}},[e.h("div",{id:this.editorId,style:{width:"100%",height:"100%"}}),this.error?e.h("div",{class:"onlyoffice-error",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"red",zIndex:10}},this.error):null])}});function n(e){const t=e.toLowerCase();if(["doc","docx","odt","rtf","txt","html","epub"].includes(t))return"word";if(["xls","xlsx","ods","csv"].includes(t))return"cell";return["ppt","pptx","odp"].includes(t)?"slide":"pdf"===t?"pdf":"other"}class r{constructor(e=""){this.baseUrl=e}async post(e,t,i){const n=this.baseUrl?`${this.baseUrl}${e}`:e;return o.post(n,t,i)}async get(e,t){const i=this.baseUrl?`${this.baseUrl}${e}`:e;return o.get(i,t)}}async function s(e,t){var o;try{const i=new r(e);return!0===(null===(o=(await i.post("/onlyoffice/token/verifyTokenSign",t)).data)||void 0===o?void 0:o.data)}catch(e){return console.error("验签请求失败:",e),!1}}async function l(e,t){try{await o.post(e,t)}catch(e){console.error("保存操作信息失败:",e)}}var c=Object.freeze({__proto__:null,HttpClient:r,saveSuccessInfo:l,verifyTokenSign:s});const d={comment:!1,download:!1,edit:!1,print:!0,review:!1,editCommentAuthorOnly:!1,fillForms:!1,modifyContentControl:!1};class a{constructor(){this.editor=null,this.callback=null,this.height="100%",this.width="100%",this.editorId=`editor-${Date.now().toString(32)}`,this.emitter=new t,this.documentConfig={fileType:"docx",key:"",url:"",title:"",permissions:{...d}},this.editorConfig={lang:"zh",user:{id:"",name:""}}}configure(e){if(e.height&&(this.height=e.height),e.width&&(this.width=e.width),e.fileType){if("other"===n(e.fileType))throw new Error(`不支持的文件类型: ${e.fileType}`);"other"!==n(e.fileType)&&(this.documentConfig.fileType=e.fileType)}e.key&&(this.documentConfig.key=e.key),e.url&&(this.documentConfig.url=e.url),e.title&&(this.documentConfig.title=e.title),e.permissions&&(this.documentConfig.permissions={...this.documentConfig.permissions,...e.permissions},"pdf"===this.documentConfig.fileType&&(this.documentConfig.permissions.edit=!1,this.documentConfig.permissions.review=!1,this.editorConfig.mode="view")),e.callbackUrl&&(this.editorConfig.callbackUrl=e.callbackUrl),e.userId&&(this.editorConfig.user={...this.editorConfig.user,id:e.userId}),e.userName&&(this.editorConfig.user={...this.editorConfig.user,name:e.userName}),e.userGroup&&(this.editorConfig.user={...this.editorConfig.user,group:e.userGroup})}async initOffice(e){const{dom:t,officeApiUrl:o,callback:i,auth:n,verifyFunction:r}=e;if(i&&(this.callback=i),n){let e=!1;if(r)e=await r(n);else{if(!n.verifyUrl)throw new Error("使用验签配置时,必须提供 verifyFunction 或 verifyUrl");e=await s(n.verifyUrl,{appId:n.appId,sign:n.sign,timestamp:n.timestamp})}if(!e)throw new Error("验签失败,请检查验签配置")}return this.createEditor(t,o)}init(e,t,o){return o&&(this.callback=o),this.createEditor(e,t)}createEditor(e,t){if(console.log("[OnlyOffice] createEditor called",{dom:e,officeApiUrl:t}),!e)throw new Error("必须提供挂载的 DOM 元素");if(!t)throw new Error("必须提供 OnlyOffice API 脚本地址");e.style.position="relative",console.log("[OnlyOffice] DOM dimensions:",{width:e.offsetWidth,height:e.offsetHeight});const o=document.createElement("div");o.id=this.editorId,o.style.height="100%",o.style.width="100%",e.appendChild(o);const i=`script-${this.editorId}`;if(document.querySelector(`#${i}`))console.log("[OnlyOffice] Script already loaded"),this.instantiateEditor();else{console.log("[OnlyOffice] Loading script:",t);const e=document.createElement("script");e.id=i,e.src=t,e.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),this.instantiateEditor()},e.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e)},document.head.appendChild(e)}return this}instantiateEditor(){if(console.log("[OnlyOffice] instantiateEditor called"),this.editor&&(this.editor.destroyEditor(),this.editor=null),!window.DocsAPI||!window.DocsAPI.DocEditor)return void console.error("[OnlyOffice] window.DocsAPI.DocEditor is not available");const e={width:this.width,height:this.height,documentType:this.getDocumentType(),document:this.documentConfig,editorConfig:this.editorConfig,events:this.createEventHandlers()};console.log("[OnlyOffice] Creating editor with config:",e),console.log("[OnlyOffice] Editor container ID:",this.editorId),console.log("[OnlyOffice] Container element:",document.getElementById(this.editorId));try{this.editor=new window.DocsAPI.DocEditor(this.editorId,e),console.log("[OnlyOffice] Editor created successfully:",this.editor)}catch(e){console.error("[OnlyOffice] Error creating editor:",e)}}getDocumentType(){const e=n(this.documentConfig.fileType);return"other"===e?"word":e}createEventHandlers(){return{onDocumentStateChange:e=>{this.emitter.emit("documentStateChange",e)},onDocumentReady:()=>{var e,t;console.log("Document is loaded"),this.editorConfig.callbackUrl&&l(this.editorConfig.callbackUrl,{status:8,key:this.documentConfig.key,userdata:JSON.stringify({appUserId:null===(e=this.editorConfig.user)||void 0===e?void 0:e.id})}),null===(t=this.callback)||void 0===t||t.call(this,"onDocumentReady"),this.emitter.emit("onDocumentReady")},onInfo:e=>{var t;console.log("ONLYOFFICE Document Editor is opened in mode",e.data.mode),null===(t=this.callback)||void 0===t||t.call(this,"onInfo",e.data),this.emitter.emit("onInfo",e)},onError:e=>{console.error("ONLYOFFICE Error:",e.data.errorCode,e.data.errorDescription),this.emitter.emit("onError",e)},onRequestHistory:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistory",e,this.editor),this.emitter.emit("onRequestHistory",{event:e,editor:this.editor})},onRequestHistoryData:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryData",e,this.editor),this.emitter.emit("onRequestHistoryData",{event:e,editor:this.editor})},onRequestHistoryClose:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryClose",e,this.editor),this.emitter.emit("onRequestHistoryClose",{event:e,editor:this.editor})},onRequestRestore:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestRestore",e,this.editor),this.emitter.emit("onRequestRestore",{event:e,editor:this.editor})},onRequestSendNotify:e=>{console.log("onRequestSendNotify",e),this.emitter.emit("onRequestSendNotify",e)},onRequestUsers:e=>{console.log("onRequestUsers",e),this.emitter.emit("onRequestUsers",e)}}}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getConfig(){return{...this.documentConfig,...this.editorConfig}}getEditor(){return this.editor}destroy(){this.editor&&(this.editor.destroyEditor(),this.editor=null),this.emitter.removeAllListeners(),this.callback=null}}exports.OnlyOfficeEditor=i,exports.createOfficeEditor=function(){return new a},exports.downloadSave=async function(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return c});await i(e,{status:9,key:t,userdata:JSON.stringify({appUserId:o})})},exports.init=function(e,t,o){return(new a).init(e,t,o)},exports.initOffice=async function(e){return(new a).initOffice(e)},exports.shareSave=async function(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return c});await i(e,{status:10,key:t,userdata:JSON.stringify({appUserId:o})})},exports.useOnlyOffice=function(t){const{officeApiUrl:o,document:i,auth:n,verifyFunction:r,height:s="100%",width:l="100%",autoInit:c=!0}=t,d=e.ref(null),f=e.ref(null),u=e.ref(!1),h=e.ref(null);let y=null;const m=async()=>{if(d.value)try{p(),y=new a,y.configure({...i,height:s,width:l});const e=(e,t,o)=>{if("onDocumentReady"===e)u.value=!0},t={dom:d.value,officeApiUrl:o,callback:e,auth:n,verifyFunction:r};f.value=await y.initOffice(t),y.on("onError",e=>{var t;h.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误"})}catch(e){h.value=e.message||"初始化失败"}else h.value="容器元素未找到"},p=()=>{y&&(y.destroy(),y=null,f.value=null,u.value=!1)},g=async()=>{p(),await m()};return e.watch(()=>i,async e=>{y&&e&&await g()},{deep:!0}),e.onMounted(()=>{c&&m()}),e.onBeforeUnmount(()=>{p()}),{containerRef:d,editorInstance:f,isReady:u,error:h,init:m,destroy:p,reinit:g,on:(e,t)=>{y&&y.on(e,t)},off:(e,t)=>{y&&y.off(e,t)}}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/vue3/component.ts","../../../src/core/utils/fileType.ts","../../../src/core/utils/http.ts","../../../src/core/editor.ts","../../../src/core/index.ts","../../../src/vue3/useOnlyOffice.ts"],"sourcesContent":["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n h,\n type PropType,\n type Ref,\n} from 'vue';\nimport type {\n OfficeDocumentConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\n\n/**\n * OnlyOffice 编辑器 Vue 3 组件\n */\nexport const OnlyOfficeEditor = defineComponent({\n name: 'OnlyOfficeEditor',\n\n props: {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: {\n type: String,\n required: true,\n },\n /** 文档配置 */\n document: {\n type: Object as PropType<OfficeDocumentConfig>,\n required: true,\n },\n /** 验签配置 */\n auth: {\n type: Object as PropType<AuthConfig>,\n default: undefined,\n },\n /** 自定义验签函数 */\n verifyFunction: {\n type: Function as PropType<VerifyTokenSignFunction>,\n default: undefined,\n },\n /** 是否跳过验签(当 auth 已通过外部验签时使用) */\n skipVerification: {\n type: Boolean,\n default: false,\n },\n /** 编辑器高度 */\n height: {\n type: String,\n default: '100%',\n },\n /** 编辑器宽度 */\n width: {\n type: String,\n default: '100%',\n },\n },\n\n emits: [\n 'ready',\n 'error',\n 'documentStateChange',\n 'requestHistory',\n 'requestHistoryData',\n 'requestHistoryClose',\n 'requestRestore',\n ],\n\n setup(props: any, { emit }: any) {\n const editorId = `onlyoffice-${Date.now().toString(36)}`;\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n let editor: any = null;\n\n /**\n * 初始化编辑器\n */\n const initEditor = () => {\n console.log('[OnlyOffice Component] initEditor called');\n\n // 获取容器元素\n const dom = document.getElementById(editorId);\n console.log('[OnlyOffice Component] Container element:', dom);\n\n if (!dom) {\n console.error('[OnlyOffice Component] Cannot find container element with id:', editorId);\n error.value = '无法找到编辑器容器';\n return;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice Component] window.DocsAPI is not available');\n error.value = 'OnlyOffice API 未加载';\n return;\n }\n\n try {\n console.log('[OnlyOffice Component] Creating editor with config:', {\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n fileType: props.document.fileType\n });\n\n // 构建编辑器配置\n const config: any = {\n width: props.width,\n height: props.height,\n documentType: getDocumentType(props.document.fileType),\n document: {\n fileType: props.document.fileType,\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n permissions: props.document.permissions || {\n edit: true,\n download: true,\n review: true\n }\n },\n editorConfig: {\n lang: 'zh',\n mode: 'edit',\n callbackUrl: props.document.callbackUrl,\n user: {\n id: props.document.userId || '',\n name: props.document.userName || ''\n }\n },\n events: {\n onDocumentReady: () => {\n console.log('[OnlyOffice] Document ready');\n isReady.value = true;\n emit('ready', editor);\n },\n onDocumentStateChange: (event: any) => {\n emit('documentStateChange', event);\n },\n onError: (event: any) => {\n console.error('[OnlyOffice] Error:', event);\n error.value = event.data?.errorDescription || '编辑器错误';\n emit('error', event);\n },\n onRequestHistory: (event: any) => {\n emit('requestHistory', { event, editor });\n },\n onRequestHistoryData: (event: any) => {\n emit('requestHistoryData', { event, editor });\n },\n onRequestHistoryClose: (event: any) => {\n emit('requestHistoryClose', { event, editor });\n },\n onRequestRestore: (event: any) => {\n emit('requestRestore', { event, editor });\n }\n }\n };\n\n // 创建编辑器实例\n editor = new window.DocsAPI.DocEditor(editorId, config);\n console.log('[OnlyOffice] Editor created successfully');\n } catch (err: any) {\n console.error('[OnlyOffice] Error creating editor:', err);\n error.value = err.message || '初始化失败';\n emit('error', err);\n }\n };\n\n /**\n * 获取文档类型\n */\n const getDocumentType = (fileType: string): string => {\n const typeMap: Record<string, string> = {\n 'doc': 'word',\n 'docx': 'word',\n 'odt': 'word',\n 'rtf': 'word',\n 'txt': 'word',\n 'html': 'word',\n 'epub': 'word',\n 'xls': 'cell',\n 'xlsx': 'cell',\n 'ods': 'cell',\n 'csv': 'cell',\n 'ppt': 'slide',\n 'pptx': 'slide',\n 'odp': 'slide',\n 'pdf': 'word'\n };\n return typeMap[fileType] || 'word';\n };\n\n /**\n * 销毁编辑器\n */\n const destroyEditor = () => {\n if (editor) {\n try {\n editor.destroyEditor();\n } catch (e) {\n console.warn('[OnlyOffice] Error destroying editor:', e);\n }\n editor = null;\n isReady.value = false;\n }\n };\n\n // 组件挂载时初始化\n onMounted(() => {\n console.log('[OnlyOffice Component] onMounted called');\n console.log('[OnlyOffice Component] Props:', {\n officeApiUrl: props.officeApiUrl,\n document: props.document,\n skipVerification: props.skipVerification\n });\n\n // 使用 setTimeout 确保 DOM 已经完全渲染\n setTimeout(() => {\n initEditor();\n }, 0);\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroyEditor();\n });\n\n return {\n editorId,\n isReady,\n error,\n };\n },\n\n render() {\n return h('div', {\n class: 'onlyoffice-editor-container',\n style: {\n width: this.width,\n height: this.height,\n position: 'relative',\n minHeight: '400px'\n }\n }, [\n h('div', {\n id: this.editorId,\n style: { width: '100%', height: '100%' }\n }),\n this.error ? h('div', {\n class: 'onlyoffice-error',\n style: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n color: 'red',\n zIndex: 10\n }\n }, this.error) : null\n ]);\n }\n});\n\nexport default OnlyOfficeEditor;\n","import type { DocumentType, FileType } from '../../types';\n\n/**\n * 根据文件扩展名获取 OnlyOffice 文档类型\n * @param fileType 文件扩展名\n * @returns 文档类型\n */\nexport function getDocumentType(fileType: FileType | string): DocumentType | 'other' {\n const type = fileType.toLowerCase();\n\n // 文档类型\n const wordTypes = ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'epub'];\n if (wordTypes.includes(type)) {\n return 'word';\n }\n\n // 表格类型\n const cellTypes = ['xls', 'xlsx', 'ods', 'csv'];\n if (cellTypes.includes(type)) {\n return 'cell';\n }\n\n // 演示类型\n const slideTypes = ['ppt', 'pptx', 'odp'];\n if (slideTypes.includes(type)) {\n return 'slide';\n }\n\n // PDF 类型\n if (type === 'pdf') {\n return 'pdf';\n }\n\n return 'other';\n}\n\n/**\n * 检查文件类型是否受支持\n * @param fileType 文件扩展名\n * @returns 是否支持\n */\nexport function isSupportedFileType(fileType: string): boolean {\n return getDocumentType(fileType) !== 'other';\n}","import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';\n\n/**\n * HTTP 请求工具\n */\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string = '') {\n this.baseUrl = baseUrl;\n }\n\n /**\n * 发送 POST 请求\n * @param url 请求地址\n * @param data 请求数据\n * @param config 额外配置\n * @returns Promise\n */\n async post<T = any>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.post<T>(fullUrl, data, config);\n }\n\n /**\n * 发送 GET 请求\n * @param url 请求地址\n * @param config 额外配置\n * @returns Promise\n */\n async get<T = any>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.get<T>(fullUrl, config);\n }\n}\n\n/**\n * 验签接口请求\n * @param baseUrl 基础 URL\n * @param data 验签数据\n * @returns 验签结果\n */\nexport async function verifyTokenSign(\n baseUrl: string,\n data: {\n appId: string;\n sign: string;\n timestamp: number;\n }\n): Promise<boolean> {\n try {\n const client = new HttpClient(baseUrl);\n const response = await client.post<{ data: boolean }>(\n '/onlyoffice/token/verifyTokenSign',\n data\n );\n return response.data?.data === true;\n } catch (error) {\n console.error('验签请求失败:', error);\n return false;\n }\n}\n\n/**\n * 保存操作信息\n * @param callbackUrl 回调地址\n * @param data 操作数据\n */\nexport async function saveSuccessInfo(\n callbackUrl: string,\n data: {\n status: number;\n key: string;\n userdata: string;\n }\n): Promise<void> {\n try {\n await axios.post(callbackUrl, data);\n } catch (error) {\n console.error('保存操作信息失败:', error);\n }\n}","import EventEmitter from 'eventemitter3';\nimport type {\n DocumentConfig,\n EditorConfig,\n DocumentPermissions,\n OfficeEventType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeDocumentConfig,\n OfficeInitConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\nimport { getDocumentType, isSupportedFileType } from './utils/fileType';\nimport { verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n/**\n * 默认文档权限\n */\nconst DEFAULT_PERMISSIONS: DocumentPermissions = {\n comment: false,\n download: false,\n edit: false,\n print: true,\n review: false,\n editCommentAuthorOnly: false,\n fillForms: false,\n modifyContentControl: false,\n};\n\n/**\n * OnlyOffice 编辑器管理类\n */\nexport class OfficeEditor implements OfficeEditorInstance {\n private editor: any = null;\n private editorId: string;\n private emitter: EventEmitter;\n private documentConfig: DocumentConfig;\n private editorConfig: EditorConfig;\n private callback: OfficeCallback | null = null;\n private height: string = '100%';\n private width: string = '100%';\n\n constructor() {\n this.editorId = `editor-${Date.now().toString(32)}`;\n this.emitter = new EventEmitter();\n this.documentConfig = {\n fileType: 'docx',\n key: '',\n url: '',\n title: '',\n permissions: { ...DEFAULT_PERMISSIONS },\n };\n this.editorConfig = {\n lang: 'zh',\n user: { id: '', name: '' },\n };\n }\n\n /**\n * 配置文档参数\n */\n configure(config: OfficeDocumentConfig): void {\n if (config.height) this.height = config.height;\n if (config.width) this.width = config.width;\n\n if (config.fileType) {\n if (!isSupportedFileType(config.fileType)) {\n throw new Error(`不支持的文件类型: ${config.fileType}`);\n }\n const docType = getDocumentType(config.fileType);\n if (docType !== 'other') {\n this.documentConfig.fileType = config.fileType;\n }\n }\n\n if (config.key) this.documentConfig.key = config.key;\n if (config.url) this.documentConfig.url = config.url;\n if (config.title) this.documentConfig.title = config.title;\n\n if (config.permissions) {\n this.documentConfig.permissions = {\n ...this.documentConfig.permissions,\n ...config.permissions,\n };\n\n // PDF 文件特殊处理\n if (this.documentConfig.fileType === 'pdf') {\n this.documentConfig.permissions.edit = false;\n this.documentConfig.permissions.review = false;\n this.editorConfig.mode = 'view';\n }\n }\n\n if (config.callbackUrl) this.editorConfig.callbackUrl = config.callbackUrl;\n if (config.userId) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n id: config.userId,\n };\n }\n if (config.userName) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n name: config.userName,\n };\n }\n if (config.userGroup) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n group: config.userGroup,\n };\n }\n }\n\n /**\n * 初始化编辑器(带验签)\n */\n async initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const { dom, officeApiUrl, callback, auth, verifyFunction } = config;\n\n if (callback) this.callback = callback;\n\n // 验签逻辑\n if (auth) {\n let verified = false;\n\n if (verifyFunction) {\n // 使用自定义验签函数\n verified = await verifyFunction(auth);\n } else if (auth.verifyUrl) {\n // 使用自定义验签地址\n verified = await verifyTokenSign(auth.verifyUrl, {\n appId: auth.appId,\n sign: auth.sign,\n timestamp: auth.timestamp,\n });\n } else {\n throw new Error('使用验签配置时,必须提供 verifyFunction 或 verifyUrl');\n }\n\n if (!verified) {\n throw new Error('验签失败,请检查验签配置');\n }\n }\n\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 简化初始化(无验签)\n */\n init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n ): OfficeEditorInstance {\n if (callback) this.callback = callback;\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 创建编辑器实例\n */\n private createEditor(dom: HTMLElement, officeApiUrl: string): OfficeEditorInstance {\n console.log('[OnlyOffice] createEditor called', { dom, officeApiUrl });\n\n if (!dom) {\n throw new Error('必须提供挂载的 DOM 元素');\n }\n\n if (!officeApiUrl) {\n throw new Error('必须提供 OnlyOffice API 脚本地址');\n }\n\n // 设置容器样式\n dom.style.position = 'relative';\n console.log('[OnlyOffice] DOM dimensions:', { width: dom.offsetWidth, height: dom.offsetHeight });\n\n // 创建编辑器容器\n const mainDiv = document.createElement('div');\n mainDiv.id = this.editorId;\n mainDiv.style.height = '100%';\n mainDiv.style.width = '100%';\n dom.appendChild(mainDiv);\n\n // 动态加载 OnlyOffice API 脚本\n const scriptId = `script-${this.editorId}`;\n const existingScript = document.querySelector(`#${scriptId}`);\n\n if (!existingScript) {\n console.log('[OnlyOffice] Loading script:', officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n this.instantiateEditor();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n };\n document.head.appendChild(script);\n } else {\n console.log('[OnlyOffice] Script already loaded');\n this.instantiateEditor();\n }\n\n return this;\n }\n\n /**\n * 实例化编辑器\n */\n private instantiateEditor(): void {\n console.log('[OnlyOffice] instantiateEditor called');\n\n // 销毁现有实例\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice] window.DocsAPI.DocEditor is not available');\n return;\n }\n\n // 构建配置对象\n const config = {\n width: this.width,\n height: this.height,\n documentType: this.getDocumentType(),\n document: this.documentConfig,\n editorConfig: this.editorConfig,\n events: this.createEventHandlers(),\n };\n\n console.log('[OnlyOffice] Creating editor with config:', config);\n console.log('[OnlyOffice] Editor container ID:', this.editorId);\n console.log('[OnlyOffice] Container element:', document.getElementById(this.editorId));\n\n // 创建编辑器实例\n try {\n this.editor = new window.DocsAPI.DocEditor(this.editorId, config);\n console.log('[OnlyOffice] Editor created successfully:', this.editor);\n } catch (err) {\n console.error('[OnlyOffice] Error creating editor:', err);\n }\n }\n\n /**\n * 获取文档类型\n */\n private getDocumentType(): string {\n const type = getDocumentType(this.documentConfig.fileType);\n return type === 'other' ? 'word' : type;\n }\n\n /**\n * 创建事件处理器\n */\n private createEventHandlers(): Record<string, (event: any) => void> {\n return {\n onDocumentStateChange: (event: any) => {\n this.emitter.emit('documentStateChange', event);\n },\n onDocumentReady: () => {\n console.log('Document is loaded');\n // 通知后端文档加载成功\n if (this.editorConfig.callbackUrl) {\n saveSuccessInfo(this.editorConfig.callbackUrl, {\n status: 8,\n key: this.documentConfig.key,\n userdata: JSON.stringify({\n appUserId: this.editorConfig.user?.id,\n }),\n });\n }\n this.callback?.('onDocumentReady');\n this.emitter.emit('onDocumentReady');\n },\n onInfo: (event: any) => {\n console.log('ONLYOFFICE Document Editor is opened in mode', event.data.mode);\n this.callback?.('onInfo', event.data);\n this.emitter.emit('onInfo', event);\n },\n onError: (event: any) => {\n console.error('ONLYOFFICE Error:', event.data.errorCode, event.data.errorDescription);\n this.emitter.emit('onError', event);\n },\n onRequestHistory: (event: any) => {\n this.callback?.('onRequestHistory', event, this.editor);\n this.emitter.emit('onRequestHistory', { event, editor: this.editor });\n },\n onRequestHistoryData: (event: any) => {\n this.callback?.('onRequestHistoryData', event, this.editor);\n this.emitter.emit('onRequestHistoryData', { event, editor: this.editor });\n },\n onRequestHistoryClose: (event: any) => {\n this.callback?.('onRequestHistoryClose', event, this.editor);\n this.emitter.emit('onRequestHistoryClose', { event, editor: this.editor });\n },\n onRequestRestore: (event: any) => {\n this.callback?.('onRequestRestore', event, this.editor);\n this.emitter.emit('onRequestRestore', { event, editor: this.editor });\n },\n onRequestSendNotify: (event: any) => {\n console.log('onRequestSendNotify', event);\n this.emitter.emit('onRequestSendNotify', event);\n },\n onRequestUsers: (event: any) => {\n console.log('onRequestUsers', event);\n this.emitter.emit('onRequestUsers', event);\n },\n };\n }\n\n /**\n * 监听事件\n */\n on(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.on(event, callback);\n }\n\n /**\n * 移除事件监听\n */\n off(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.off(event, callback);\n }\n\n /**\n * 获取当前配置\n */\n getConfig(): DocumentConfig & EditorConfig {\n return {\n ...this.documentConfig,\n ...this.editorConfig,\n };\n }\n\n /**\n * 获取内部编辑器实例\n */\n getEditor(): any {\n return this.editor;\n }\n\n /**\n * 销毁编辑器\n */\n destroy(): void {\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n this.emitter.removeAllListeners();\n this.callback = null;\n }\n}","export { OfficeEditor } from './editor';\nexport { getDocumentType, isSupportedFileType } from './utils/fileType';\nexport { HttpClient, verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n// 导出类型\nexport type {\n DocumentType,\n FileType,\n DocumentPermissions,\n UserInfo,\n DocumentConfig,\n EditorConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeInitConfig,\n OfficeDocumentConfig,\n OfficeEventType,\n OfficeCallbackType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeSDK,\n} from '../types';\n\nimport { OfficeEditor } from './editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * 创建 Office 编辑器实例\n * @returns OfficeEditor 实例\n */\nexport function createOfficeEditor(): OfficeEditor {\n return new OfficeEditor();\n}\n\n/**\n * 快速初始化 Office 编辑器\n * @param config 初始化配置\n * @returns Promise<OfficeEditorInstance>\n */\nexport async function initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const editor = new OfficeEditor();\n return editor.initOffice(config);\n}\n\n/**\n * 简化初始化(无验签)\n * @param dom 挂载的 DOM 元素\n * @param officeApiUrl OnlyOffice API 地址\n * @param callback 事件回调\n * @returns OfficeEditorInstance\n */\nexport function init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n): OfficeEditorInstance {\n const editor = new OfficeEditor();\n return editor.init(dom, officeApiUrl, callback);\n}\n\n/**\n * 配置文档参数(全局配置,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.configure() 方法\n */\nexport function config(_config: OfficeDocumentConfig): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.configure() 方法');\n}\n\n/**\n * 销毁编辑器(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.destroy() 方法\n */\nexport function destroy(): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.destroy() 方法');\n}\n\n/**\n * 监听事件(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.on() 方法\n */\nexport function on(_event: OfficeEventType, _callback: (...args: any[]) => void): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.on() 方法');\n}\n\n/**\n * 记录分享动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function shareSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 10,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}\n\n/**\n * 记录下载动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function downloadSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 9,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}","import { ref, onMounted, onBeforeUnmount, watch, type Ref } from 'vue';\nimport { OfficeEditor } from '../core/editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * useOnlyOffice 配置选项\n */\nexport interface UseOnlyOfficeOptions {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: string;\n /** 文档配置 */\n document: OfficeDocumentConfig;\n /** 验签配置 */\n auth?: AuthConfig;\n /** 自定义验签函数 */\n verifyFunction?: VerifyTokenSignFunction;\n /** 编辑器高度 */\n height?: string;\n /** 编辑器宽度 */\n width?: string;\n /** 是否自动初始化 */\n autoInit?: boolean;\n}\n\n/**\n * useOnlyOffice 返回值\n */\nexport interface UseOnlyOfficeReturn {\n /** 容器元素引用 */\n containerRef: Ref<HTMLElement | null>;\n /** 编辑器实例 */\n editorInstance: Ref<OfficeEditorInstance | null>;\n /** 是否已就绪 */\n isReady: Ref<boolean>;\n /** 错误信息 */\n error: Ref<string | null>;\n /** 初始化编辑器 */\n init: () => Promise<void>;\n /** 销毁编辑器 */\n destroy: () => void;\n /** 重新初始化 */\n reinit: () => Promise<void>;\n /** 监听事件 */\n on: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n /** 移除事件监听 */\n off: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n}\n\n/**\n * OnlyOffice Vue 3 组合式函数\n * @param options 配置选项\n * @returns 编辑器状态和方法\n */\nexport function useOnlyOffice(options: UseOnlyOfficeOptions): UseOnlyOfficeReturn {\n const {\n officeApiUrl,\n document: documentConfig,\n auth,\n verifyFunction,\n height = '100%',\n width = '100%',\n autoInit = true,\n } = options;\n\n const containerRef: Ref<HTMLElement | null> = ref(null);\n const editorInstance: Ref<OfficeEditorInstance | null> = ref(null);\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n\n let editor: OfficeEditor | null = null;\n\n /**\n * 初始化编辑器\n */\n const init = async () => {\n if (!containerRef.value) {\n error.value = '容器元素未找到';\n return;\n }\n\n try {\n // 销毁现有实例\n destroy();\n\n editor = new OfficeEditor();\n\n // 配置文档参数\n editor.configure({\n ...documentConfig,\n height,\n width,\n });\n\n // 事件回调\n const callback: OfficeCallback = (type, _event, _editorInst) => {\n switch (type) {\n case 'onDocumentReady':\n isReady.value = true;\n break;\n case 'onInfo':\n break;\n }\n };\n\n // 初始化配置\n const initConfig: OfficeInitConfig = {\n dom: containerRef.value,\n officeApiUrl,\n callback,\n auth,\n verifyFunction,\n };\n\n // 初始化编辑器\n editorInstance.value = await editor.initOffice(initConfig);\n\n // 监听错误事件\n editor.on('onError' as OfficeEventType, (event: any) => {\n error.value = event.data?.errorDescription || '编辑器错误';\n });\n } catch (err: any) {\n error.value = err.message || '初始化失败';\n }\n };\n\n /**\n * 销毁编辑器\n */\n const destroy = () => {\n if (editor) {\n editor.destroy();\n editor = null;\n editorInstance.value = null;\n isReady.value = false;\n }\n };\n\n /**\n * 重新初始化\n */\n const reinit = async () => {\n destroy();\n await init();\n };\n\n /**\n * 监听事件\n */\n const on = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.on(event, callback);\n }\n };\n\n /**\n * 移除事件监听\n */\n const off = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.off(event, callback);\n }\n };\n\n // 监听文档配置变化\n watch(\n () => documentConfig,\n async (newDoc: any) => {\n if (editor && newDoc) {\n await reinit();\n }\n },\n { deep: true }\n );\n\n // 组件挂载时初始化\n onMounted(() => {\n if (autoInit) {\n init();\n }\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroy();\n });\n\n return {\n containerRef,\n editorInstance,\n isReady,\n error,\n init,\n destroy,\n reinit,\n on,\n off,\n };\n}\n\nexport default useOnlyOffice;"],"names":["OnlyOfficeEditor","defineComponent","name","props","officeApiUrl","type","String","required","document","Object","auth","default","undefined","verifyFunction","Function","skipVerification","Boolean","height","width","emits","setup","emit","editorId","Date","now","toString","isReady","ref","error","editor","getDocumentType","fileType","doc","docx","odt","rtf","txt","html","epub","xls","xlsx","ods","csv","ppt","pptx","odp","pdf","onMounted","console","log","setTimeout","dom","getElementById","value","window","DocsAPI","DocEditor","key","url","title","config","documentType","permissions","edit","download","review","editorConfig","lang","mode","callbackUrl","user","id","userId","userName","events","onDocumentReady","onDocumentStateChange","event","onError","_a","data","errorDescription","onRequestHistory","onRequestHistoryData","onRequestHistoryClose","onRequestRestore","err","message","initEditor","onBeforeUnmount","destroyEditor","e","warn","render","h","class","style","this","position","minHeight","top","left","transform","color","zIndex","toLowerCase","includes","HttpClient","constructor","baseUrl","post","fullUrl","axios","get","async","verifyTokenSign","client","saveSuccessInfo","DEFAULT_PERMISSIONS","comment","print","editCommentAuthorOnly","fillForms","modifyContentControl","OfficeEditor","callback","emitter","EventEmitter","documentConfig","configure","Error","userGroup","group","initOffice","verified","verifyUrl","appId","sign","timestamp","createEditor","init","offsetWidth","offsetHeight","mainDiv","createElement","appendChild","scriptId","querySelector","instantiateEditor","script","src","onload","onerror","head","createEventHandlers","status","userdata","JSON","stringify","appUserId","_b","call","onInfo","errorCode","onRequestSendNotify","onRequestUsers","on","off","getConfig","getEditor","destroy","removeAllListeners","fileKey","Promise","resolve","then","http","options","autoInit","containerRef","editorInstance","_event","_editorInst","initConfig","reinit","watch","newDoc","deep"],"mappings":"gFAkBO,MAAMA,EAAmBC,EAAAA,gBAAgB,CAC9CC,KAAM,mBAENC,MAAO,CAELC,aAAc,CACZC,KAAMC,OACNC,UAAU,GAGZC,SAAU,CACRH,KAAMI,OACNF,UAAU,GAGZG,KAAM,CACJL,KAAMI,OACNE,aAASC,GAGXC,eAAgB,CACdR,KAAMS,SACNH,aAASC,GAGXG,iBAAkB,CAChBV,KAAMW,QACNL,SAAS,GAGXM,OAAQ,CACNZ,KAAMC,OACNK,QAAS,QAGXO,MAAO,CACLb,KAAMC,OACNK,QAAS,SAIbQ,MAAO,CACL,QACA,QACA,sBACA,iBACA,qBACA,sBACA,kBAGF,KAAAC,CAAMjB,GAAYkB,KAAEA,IAClB,MAAMC,EAAW,cAAcC,KAAKC,MAAMC,SAAS,MAC7CC,EAAwBC,EAAAA,KAAI,GAC5BC,EAA4BD,EAAAA,IAAI,MACtC,IAAIE,EAAc,KAKlB,MA+FMC,EAAmBC,IACiB,CAC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QACE,IAAMzD,EACNd,MAAOwE,IACD7J,GAAU6J,SACNF,KAGV,CAAEG,MAAM,IAIV5I,EAAAA,UAAU,KACJmI,GACFtC,MAKJnD,EAAAA,gBAAgB,KACdiF,MAGK,CACLS,eACAC,iBACA1J,UACAE,QACAgH,OACA8B,UACAc,SACAlB,GA9CS,CAACzF,EAAwBgD,KAC9BhG,GACFA,EAAOyI,GAAGzF,EAAOgD,IA6CnB0C,IAtCU,CAAC1F,EAAwBgD,KAC/BhG,GACFA,EAAO0I,IAAI1F,EAAOgD,IAsCxB"}
1
+ {"version":3,"file":"index.cjs","sources":["../../../src/vue3/component.ts","../../../src/core/utils/fileType.ts","../../../src/core/utils/http.ts","../../../src/core/editor.ts","../../../src/core/index.ts","../../../src/vue3/useOnlyOffice.ts"],"sourcesContent":["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n h,\n type PropType,\n type Ref,\n} from 'vue';\nimport type {\n OfficeDocumentConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\n\n/**\n * OnlyOffice 编辑器 Vue 3 组件\n */\nexport const OnlyOfficeEditor = defineComponent({\n name: 'OnlyOfficeEditor',\n\n props: {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: {\n type: String,\n required: true,\n },\n /** 文档配置 */\n document: {\n type: Object as PropType<OfficeDocumentConfig>,\n required: true,\n },\n /** 验签配置 */\n auth: {\n type: Object as PropType<AuthConfig>,\n default: undefined,\n },\n /** 自定义验签函数 */\n verifyFunction: {\n type: Function as PropType<VerifyTokenSignFunction>,\n default: undefined,\n },\n /** 是否跳过验签(当 auth 已通过外部验签时使用) */\n skipVerification: {\n type: Boolean,\n default: false,\n },\n /** 编辑器高度 */\n height: {\n type: String,\n default: '100%',\n },\n /** 编辑器宽度 */\n width: {\n type: String,\n default: '100%',\n },\n },\n\n emits: [\n 'ready',\n 'error',\n 'documentStateChange',\n 'requestHistory',\n 'requestHistoryData',\n 'requestHistoryClose',\n 'requestRestore',\n ],\n\n setup(props: any, { emit }: any) {\n const editorId = `onlyoffice-${Date.now().toString(36)}`;\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n let editor: any = null;\n\n /**\n * 加载 OnlyOffice API 脚本\n */\n const loadScript = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n // 检查是否已经加载\n if (window.DocsAPI && window.DocsAPI.DocEditor) {\n console.log('[OnlyOffice] Script already loaded');\n resolve();\n return;\n }\n\n // 检查是否已经有相同的脚本正在加载\n const scriptId = 'onlyoffice-api-script';\n const existingScript = document.getElementById(scriptId) as HTMLScriptElement;\n if (existingScript) {\n console.log('[OnlyOffice] Script element exists, waiting for load');\n // 等待脚本加载完成\n const checkLoaded = () => {\n if (window.DocsAPI && window.DocsAPI.DocEditor) {\n resolve();\n } else {\n setTimeout(checkLoaded, 100);\n }\n };\n checkLoaded();\n return;\n }\n\n console.log('[OnlyOffice] Loading script:', props.officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = props.officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n resolve();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n reject(new Error('OnlyOffice API 脚本加载失败'));\n };\n document.head.appendChild(script);\n });\n };\n\n /**\n * 初始化编辑器\n */\n const initEditor = async () => {\n console.log('[OnlyOffice Component] initEditor called');\n\n try {\n // 先加载脚本\n await loadScript();\n\n // 获取容器元素\n const dom = document.getElementById(editorId);\n console.log('[OnlyOffice Component] Container element:', dom);\n\n if (!dom) {\n console.error('[OnlyOffice Component] Cannot find container element with id:', editorId);\n error.value = '无法找到编辑器容器';\n return;\n }\n\n console.log('[OnlyOffice Component] Creating editor with config:', {\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n fileType: props.document.fileType\n });\n\n // 构建编辑器配置\n const config: any = {\n width: props.width,\n height: props.height,\n documentType: getDocumentType(props.document.fileType),\n document: {\n fileType: props.document.fileType,\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n permissions: props.document.permissions || {\n edit: true,\n download: true,\n review: true\n }\n },\n editorConfig: {\n lang: 'zh',\n mode: 'edit',\n callbackUrl: props.document.callbackUrl,\n user: {\n id: props.document.userId || '',\n name: props.document.userName || ''\n }\n },\n events: {\n onDocumentReady: () => {\n console.log('[OnlyOffice] Document ready');\n isReady.value = true;\n emit('ready', editor);\n },\n onDocumentStateChange: (event: any) => {\n emit('documentStateChange', event);\n },\n onError: (event: any) => {\n console.error('[OnlyOffice] Error:', event);\n error.value = event.data?.errorDescription || '编辑器错误';\n emit('error', event);\n },\n onRequestHistory: (event: any) => {\n emit('requestHistory', { event, editor });\n },\n onRequestHistoryData: (event: any) => {\n emit('requestHistoryData', { event, editor });\n },\n onRequestHistoryClose: (event: any) => {\n emit('requestHistoryClose', { event, editor });\n },\n onRequestRestore: (event: any) => {\n emit('requestRestore', { event, editor });\n }\n }\n };\n\n // 创建编辑器实例\n editor = new window.DocsAPI.DocEditor(editorId, config);\n console.log('[OnlyOffice] Editor created successfully');\n } catch (err: any) {\n console.error('[OnlyOffice] Error creating editor:', err);\n error.value = err.message || '初始化失败';\n emit('error', err);\n }\n };\n\n /**\n * 获取文档类型\n */\n const getDocumentType = (fileType: string): string => {\n const typeMap: Record<string, string> = {\n 'doc': 'word',\n 'docx': 'word',\n 'odt': 'word',\n 'rtf': 'word',\n 'txt': 'word',\n 'html': 'word',\n 'epub': 'word',\n 'xls': 'cell',\n 'xlsx': 'cell',\n 'ods': 'cell',\n 'csv': 'cell',\n 'ppt': 'slide',\n 'pptx': 'slide',\n 'odp': 'slide',\n 'pdf': 'word'\n };\n return typeMap[fileType] || 'word';\n };\n\n /**\n * 销毁编辑器\n */\n const destroyEditor = () => {\n if (editor) {\n try {\n editor.destroyEditor();\n } catch (e) {\n console.warn('[OnlyOffice] Error destroying editor:', e);\n }\n editor = null;\n isReady.value = false;\n }\n };\n\n // 组件挂载时初始化\n onMounted(() => {\n console.log('[OnlyOffice Component] onMounted called');\n console.log('[OnlyOffice Component] Props:', {\n officeApiUrl: props.officeApiUrl,\n document: props.document,\n skipVerification: props.skipVerification\n });\n\n // 使用 setTimeout 确保 DOM 已经完全渲染\n setTimeout(() => {\n initEditor();\n }, 0);\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroyEditor();\n });\n\n return {\n editorId,\n isReady,\n error,\n };\n },\n\n render() {\n return h('div', {\n class: 'onlyoffice-editor-container',\n style: {\n width: this.width,\n height: this.height,\n position: 'relative',\n minHeight: '400px'\n }\n }, [\n h('div', {\n id: this.editorId,\n style: { width: '100%', height: '100%' }\n }),\n this.error ? h('div', {\n class: 'onlyoffice-error',\n style: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n color: 'red',\n zIndex: 10\n }\n }, this.error) : null\n ]);\n }\n});\n\nexport default OnlyOfficeEditor;\n","import type { DocumentType, FileType } from '../../types';\n\n/**\n * 根据文件扩展名获取 OnlyOffice 文档类型\n * @param fileType 文件扩展名\n * @returns 文档类型\n */\nexport function getDocumentType(fileType: FileType | string): DocumentType | 'other' {\n const type = fileType.toLowerCase();\n\n // 文档类型\n const wordTypes = ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'epub'];\n if (wordTypes.includes(type)) {\n return 'word';\n }\n\n // 表格类型\n const cellTypes = ['xls', 'xlsx', 'ods', 'csv'];\n if (cellTypes.includes(type)) {\n return 'cell';\n }\n\n // 演示类型\n const slideTypes = ['ppt', 'pptx', 'odp'];\n if (slideTypes.includes(type)) {\n return 'slide';\n }\n\n // PDF 类型\n if (type === 'pdf') {\n return 'pdf';\n }\n\n return 'other';\n}\n\n/**\n * 检查文件类型是否受支持\n * @param fileType 文件扩展名\n * @returns 是否支持\n */\nexport function isSupportedFileType(fileType: string): boolean {\n return getDocumentType(fileType) !== 'other';\n}","import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';\n\n/**\n * HTTP 请求工具\n */\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string = '') {\n this.baseUrl = baseUrl;\n }\n\n /**\n * 发送 POST 请求\n * @param url 请求地址\n * @param data 请求数据\n * @param config 额外配置\n * @returns Promise\n */\n async post<T = any>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.post<T>(fullUrl, data, config);\n }\n\n /**\n * 发送 GET 请求\n * @param url 请求地址\n * @param config 额外配置\n * @returns Promise\n */\n async get<T = any>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.get<T>(fullUrl, config);\n }\n}\n\n/**\n * 验签接口请求\n * @param baseUrl 基础 URL\n * @param data 验签数据\n * @returns 验签结果\n */\nexport async function verifyTokenSign(\n baseUrl: string,\n data: {\n appId: string;\n sign: string;\n timestamp: number;\n }\n): Promise<boolean> {\n try {\n const client = new HttpClient(baseUrl);\n const response = await client.post<{ data: boolean }>(\n '/onlyoffice/token/verifyTokenSign',\n data\n );\n return response.data?.data === true;\n } catch (error) {\n console.error('验签请求失败:', error);\n return false;\n }\n}\n\n/**\n * 保存操作信息\n * @param callbackUrl 回调地址\n * @param data 操作数据\n */\nexport async function saveSuccessInfo(\n callbackUrl: string,\n data: {\n status: number;\n key: string;\n userdata: string;\n }\n): Promise<void> {\n try {\n await axios.post(callbackUrl, data);\n } catch (error) {\n console.error('保存操作信息失败:', error);\n }\n}","import EventEmitter from 'eventemitter3';\nimport type {\n DocumentConfig,\n EditorConfig,\n DocumentPermissions,\n OfficeEventType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeDocumentConfig,\n OfficeInitConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\nimport { getDocumentType, isSupportedFileType } from './utils/fileType';\nimport { verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n/**\n * 默认文档权限\n */\nconst DEFAULT_PERMISSIONS: DocumentPermissions = {\n comment: false,\n download: false,\n edit: false,\n print: true,\n review: false,\n editCommentAuthorOnly: false,\n fillForms: false,\n modifyContentControl: false,\n};\n\n/**\n * OnlyOffice 编辑器管理类\n */\nexport class OfficeEditor implements OfficeEditorInstance {\n private editor: any = null;\n private editorId: string;\n private emitter: EventEmitter;\n private documentConfig: DocumentConfig;\n private editorConfig: EditorConfig;\n private callback: OfficeCallback | null = null;\n private height: string = '100%';\n private width: string = '100%';\n\n constructor() {\n this.editorId = `editor-${Date.now().toString(32)}`;\n this.emitter = new EventEmitter();\n this.documentConfig = {\n fileType: 'docx',\n key: '',\n url: '',\n title: '',\n permissions: { ...DEFAULT_PERMISSIONS },\n };\n this.editorConfig = {\n lang: 'zh',\n user: { id: '', name: '' },\n };\n }\n\n /**\n * 配置文档参数\n */\n configure(config: OfficeDocumentConfig): void {\n if (config.height) this.height = config.height;\n if (config.width) this.width = config.width;\n\n if (config.fileType) {\n if (!isSupportedFileType(config.fileType)) {\n throw new Error(`不支持的文件类型: ${config.fileType}`);\n }\n const docType = getDocumentType(config.fileType);\n if (docType !== 'other') {\n this.documentConfig.fileType = config.fileType;\n }\n }\n\n if (config.key) this.documentConfig.key = config.key;\n if (config.url) this.documentConfig.url = config.url;\n if (config.title) this.documentConfig.title = config.title;\n\n if (config.permissions) {\n this.documentConfig.permissions = {\n ...this.documentConfig.permissions,\n ...config.permissions,\n };\n\n // PDF 文件特殊处理\n if (this.documentConfig.fileType === 'pdf') {\n this.documentConfig.permissions.edit = false;\n this.documentConfig.permissions.review = false;\n this.editorConfig.mode = 'view';\n }\n }\n\n if (config.callbackUrl) this.editorConfig.callbackUrl = config.callbackUrl;\n if (config.userId) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n id: config.userId,\n };\n }\n if (config.userName) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n name: config.userName,\n };\n }\n if (config.userGroup) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n group: config.userGroup,\n };\n }\n }\n\n /**\n * 初始化编辑器(带验签)\n */\n async initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const { dom, officeApiUrl, callback, auth, verifyFunction } = config;\n\n if (callback) this.callback = callback;\n\n // 验签逻辑\n if (auth) {\n let verified = false;\n\n if (verifyFunction) {\n // 使用自定义验签函数\n verified = await verifyFunction(auth);\n } else if (auth.verifyUrl) {\n // 使用自定义验签地址\n verified = await verifyTokenSign(auth.verifyUrl, {\n appId: auth.appId,\n sign: auth.sign,\n timestamp: auth.timestamp,\n });\n } else {\n throw new Error('使用验签配置时,必须提供 verifyFunction 或 verifyUrl');\n }\n\n if (!verified) {\n throw new Error('验签失败,请检查验签配置');\n }\n }\n\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 简化初始化(无验签)\n */\n init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n ): OfficeEditorInstance {\n if (callback) this.callback = callback;\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 创建编辑器实例\n */\n private createEditor(dom: HTMLElement, officeApiUrl: string): OfficeEditorInstance {\n console.log('[OnlyOffice] createEditor called', { dom, officeApiUrl });\n\n if (!dom) {\n throw new Error('必须提供挂载的 DOM 元素');\n }\n\n if (!officeApiUrl) {\n throw new Error('必须提供 OnlyOffice API 脚本地址');\n }\n\n // 设置容器样式\n dom.style.position = 'relative';\n console.log('[OnlyOffice] DOM dimensions:', { width: dom.offsetWidth, height: dom.offsetHeight });\n\n // 创建编辑器容器\n const mainDiv = document.createElement('div');\n mainDiv.id = this.editorId;\n mainDiv.style.height = '100%';\n mainDiv.style.width = '100%';\n dom.appendChild(mainDiv);\n\n // 动态加载 OnlyOffice API 脚本\n const scriptId = `script-${this.editorId}`;\n const existingScript = document.querySelector(`#${scriptId}`);\n\n if (!existingScript) {\n console.log('[OnlyOffice] Loading script:', officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n this.instantiateEditor();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n };\n document.head.appendChild(script);\n } else {\n console.log('[OnlyOffice] Script already loaded');\n this.instantiateEditor();\n }\n\n return this;\n }\n\n /**\n * 实例化编辑器\n */\n private instantiateEditor(): void {\n console.log('[OnlyOffice] instantiateEditor called');\n\n // 销毁现有实例\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice] window.DocsAPI.DocEditor is not available');\n return;\n }\n\n // 构建配置对象\n const config = {\n width: this.width,\n height: this.height,\n documentType: this.getDocumentType(),\n document: this.documentConfig,\n editorConfig: this.editorConfig,\n events: this.createEventHandlers(),\n };\n\n console.log('[OnlyOffice] Creating editor with config:', config);\n console.log('[OnlyOffice] Editor container ID:', this.editorId);\n console.log('[OnlyOffice] Container element:', document.getElementById(this.editorId));\n\n // 创建编辑器实例\n try {\n this.editor = new window.DocsAPI.DocEditor(this.editorId, config);\n console.log('[OnlyOffice] Editor created successfully:', this.editor);\n } catch (err) {\n console.error('[OnlyOffice] Error creating editor:', err);\n }\n }\n\n /**\n * 获取文档类型\n */\n private getDocumentType(): string {\n const type = getDocumentType(this.documentConfig.fileType);\n return type === 'other' ? 'word' : type;\n }\n\n /**\n * 创建事件处理器\n */\n private createEventHandlers(): Record<string, (event: any) => void> {\n return {\n onDocumentStateChange: (event: any) => {\n this.emitter.emit('documentStateChange', event);\n },\n onDocumentReady: () => {\n console.log('Document is loaded');\n // 通知后端文档加载成功\n if (this.editorConfig.callbackUrl) {\n saveSuccessInfo(this.editorConfig.callbackUrl, {\n status: 8,\n key: this.documentConfig.key,\n userdata: JSON.stringify({\n appUserId: this.editorConfig.user?.id,\n }),\n });\n }\n this.callback?.('onDocumentReady');\n this.emitter.emit('onDocumentReady');\n },\n onInfo: (event: any) => {\n console.log('ONLYOFFICE Document Editor is opened in mode', event.data.mode);\n this.callback?.('onInfo', event.data);\n this.emitter.emit('onInfo', event);\n },\n onError: (event: any) => {\n console.error('ONLYOFFICE Error:', event.data.errorCode, event.data.errorDescription);\n this.emitter.emit('onError', event);\n },\n onRequestHistory: (event: any) => {\n this.callback?.('onRequestHistory', event, this.editor);\n this.emitter.emit('onRequestHistory', { event, editor: this.editor });\n },\n onRequestHistoryData: (event: any) => {\n this.callback?.('onRequestHistoryData', event, this.editor);\n this.emitter.emit('onRequestHistoryData', { event, editor: this.editor });\n },\n onRequestHistoryClose: (event: any) => {\n this.callback?.('onRequestHistoryClose', event, this.editor);\n this.emitter.emit('onRequestHistoryClose', { event, editor: this.editor });\n },\n onRequestRestore: (event: any) => {\n this.callback?.('onRequestRestore', event, this.editor);\n this.emitter.emit('onRequestRestore', { event, editor: this.editor });\n },\n onRequestSendNotify: (event: any) => {\n console.log('onRequestSendNotify', event);\n this.emitter.emit('onRequestSendNotify', event);\n },\n onRequestUsers: (event: any) => {\n console.log('onRequestUsers', event);\n this.emitter.emit('onRequestUsers', event);\n },\n };\n }\n\n /**\n * 监听事件\n */\n on(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.on(event, callback);\n }\n\n /**\n * 移除事件监听\n */\n off(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.off(event, callback);\n }\n\n /**\n * 获取当前配置\n */\n getConfig(): DocumentConfig & EditorConfig {\n return {\n ...this.documentConfig,\n ...this.editorConfig,\n };\n }\n\n /**\n * 获取内部编辑器实例\n */\n getEditor(): any {\n return this.editor;\n }\n\n /**\n * 销毁编辑器\n */\n destroy(): void {\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n this.emitter.removeAllListeners();\n this.callback = null;\n }\n}","export { OfficeEditor } from './editor';\nexport { getDocumentType, isSupportedFileType } from './utils/fileType';\nexport { HttpClient, verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n// 导出类型\nexport type {\n DocumentType,\n FileType,\n DocumentPermissions,\n UserInfo,\n DocumentConfig,\n EditorConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeInitConfig,\n OfficeDocumentConfig,\n OfficeEventType,\n OfficeCallbackType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeSDK,\n} from '../types';\n\nimport { OfficeEditor } from './editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * 创建 Office 编辑器实例\n * @returns OfficeEditor 实例\n */\nexport function createOfficeEditor(): OfficeEditor {\n return new OfficeEditor();\n}\n\n/**\n * 快速初始化 Office 编辑器\n * @param config 初始化配置\n * @returns Promise<OfficeEditorInstance>\n */\nexport async function initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const editor = new OfficeEditor();\n return editor.initOffice(config);\n}\n\n/**\n * 简化初始化(无验签)\n * @param dom 挂载的 DOM 元素\n * @param officeApiUrl OnlyOffice API 地址\n * @param callback 事件回调\n * @returns OfficeEditorInstance\n */\nexport function init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n): OfficeEditorInstance {\n const editor = new OfficeEditor();\n return editor.init(dom, officeApiUrl, callback);\n}\n\n/**\n * 配置文档参数(全局配置,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.configure() 方法\n */\nexport function config(_config: OfficeDocumentConfig): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.configure() 方法');\n}\n\n/**\n * 销毁编辑器(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.destroy() 方法\n */\nexport function destroy(): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.destroy() 方法');\n}\n\n/**\n * 监听事件(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.on() 方法\n */\nexport function on(_event: OfficeEventType, _callback: (...args: any[]) => void): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.on() 方法');\n}\n\n/**\n * 记录分享动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function shareSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 10,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}\n\n/**\n * 记录下载动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function downloadSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 9,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}","import { ref, onMounted, onBeforeUnmount, watch, type Ref } from 'vue';\nimport { OfficeEditor } from '../core/editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * useOnlyOffice 配置选项\n */\nexport interface UseOnlyOfficeOptions {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: string;\n /** 文档配置 */\n document: OfficeDocumentConfig;\n /** 验签配置 */\n auth?: AuthConfig;\n /** 自定义验签函数 */\n verifyFunction?: VerifyTokenSignFunction;\n /** 编辑器高度 */\n height?: string;\n /** 编辑器宽度 */\n width?: string;\n /** 是否自动初始化 */\n autoInit?: boolean;\n}\n\n/**\n * useOnlyOffice 返回值\n */\nexport interface UseOnlyOfficeReturn {\n /** 容器元素引用 */\n containerRef: Ref<HTMLElement | null>;\n /** 编辑器实例 */\n editorInstance: Ref<OfficeEditorInstance | null>;\n /** 是否已就绪 */\n isReady: Ref<boolean>;\n /** 错误信息 */\n error: Ref<string | null>;\n /** 初始化编辑器 */\n init: () => Promise<void>;\n /** 销毁编辑器 */\n destroy: () => void;\n /** 重新初始化 */\n reinit: () => Promise<void>;\n /** 监听事件 */\n on: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n /** 移除事件监听 */\n off: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n}\n\n/**\n * OnlyOffice Vue 3 组合式函数\n * @param options 配置选项\n * @returns 编辑器状态和方法\n */\nexport function useOnlyOffice(options: UseOnlyOfficeOptions): UseOnlyOfficeReturn {\n const {\n officeApiUrl,\n document: documentConfig,\n auth,\n verifyFunction,\n height = '100%',\n width = '100%',\n autoInit = true,\n } = options;\n\n const containerRef: Ref<HTMLElement | null> = ref(null);\n const editorInstance: Ref<OfficeEditorInstance | null> = ref(null);\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n\n let editor: OfficeEditor | null = null;\n\n /**\n * 初始化编辑器\n */\n const init = async () => {\n if (!containerRef.value) {\n error.value = '容器元素未找到';\n return;\n }\n\n try {\n // 销毁现有实例\n destroy();\n\n editor = new OfficeEditor();\n\n // 配置文档参数\n editor.configure({\n ...documentConfig,\n height,\n width,\n });\n\n // 事件回调\n const callback: OfficeCallback = (type, _event, _editorInst) => {\n switch (type) {\n case 'onDocumentReady':\n isReady.value = true;\n break;\n case 'onInfo':\n break;\n }\n };\n\n // 初始化配置\n const initConfig: OfficeInitConfig = {\n dom: containerRef.value,\n officeApiUrl,\n callback,\n auth,\n verifyFunction,\n };\n\n // 初始化编辑器\n editorInstance.value = await editor.initOffice(initConfig);\n\n // 监听错误事件\n editor.on('onError' as OfficeEventType, (event: any) => {\n error.value = event.data?.errorDescription || '编辑器错误';\n });\n } catch (err: any) {\n error.value = err.message || '初始化失败';\n }\n };\n\n /**\n * 销毁编辑器\n */\n const destroy = () => {\n if (editor) {\n editor.destroy();\n editor = null;\n editorInstance.value = null;\n isReady.value = false;\n }\n };\n\n /**\n * 重新初始化\n */\n const reinit = async () => {\n destroy();\n await init();\n };\n\n /**\n * 监听事件\n */\n const on = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.on(event, callback);\n }\n };\n\n /**\n * 移除事件监听\n */\n const off = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.off(event, callback);\n }\n };\n\n // 监听文档配置变化\n watch(\n () => documentConfig,\n async (newDoc: any) => {\n if (editor && newDoc) {\n await reinit();\n }\n },\n { deep: true }\n );\n\n // 组件挂载时初始化\n onMounted(() => {\n if (autoInit) {\n init();\n }\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroy();\n });\n\n return {\n containerRef,\n editorInstance,\n isReady,\n error,\n init,\n destroy,\n reinit,\n on,\n off,\n };\n}\n\nexport default useOnlyOffice;"],"names":["OnlyOfficeEditor","defineComponent","name","props","officeApiUrl","type","String","required","document","Object","auth","default","undefined","verifyFunction","Function","skipVerification","Boolean","height","width","emits","setup","emit","editorId","Date","now","toString","isReady","ref","error","editor","initEditor","async","console","log","Promise","resolve","reject","window","DocsAPI","DocEditor","scriptId","getElementById","checkLoaded","setTimeout","script","createElement","id","src","onload","onerror","err","Error","head","appendChild","dom","value","key","url","title","fileType","config","documentType","getDocumentType","permissions","edit","download","review","editorConfig","lang","mode","callbackUrl","user","userId","userName","events","onDocumentReady","onDocumentStateChange","event","onError","_a","data","errorDescription","onRequestHistory","onRequestHistoryData","onRequestHistoryClose","onRequestRestore","message","doc","docx","odt","rtf","txt","html","epub","xls","xlsx","ods","csv","ppt","pptx","odp","pdf","onMounted","onBeforeUnmount","destroyEditor","e","warn","render","h","class","style","this","position","minHeight","top","left","transform","color","zIndex","toLowerCase","includes","HttpClient","constructor","baseUrl","post","fullUrl","axios","get","verifyTokenSign","client","saveSuccessInfo","DEFAULT_PERMISSIONS","comment","print","editCommentAuthorOnly","fillForms","modifyContentControl","OfficeEditor","callback","emitter","EventEmitter","documentConfig","configure","userGroup","group","initOffice","verified","verifyUrl","appId","sign","timestamp","createEditor","init","offsetWidth","offsetHeight","mainDiv","querySelector","instantiateEditor","createEventHandlers","status","userdata","JSON","stringify","appUserId","_b","call","onInfo","errorCode","onRequestSendNotify","onRequestUsers","on","off","getConfig","getEditor","destroy","removeAllListeners","fileKey","then","http","options","autoInit","containerRef","editorInstance","_event","_editorInst","initConfig","reinit","watch","newDoc","deep"],"mappings":"gFAkBO,MAAMA,EAAmBC,EAAAA,gBAAgB,CAC9CC,KAAM,mBAENC,MAAO,CAELC,aAAc,CACZC,KAAMC,OACNC,UAAU,GAGZC,SAAU,CACRH,KAAMI,OACNF,UAAU,GAGZG,KAAM,CACJL,KAAMI,OACNE,aAASC,GAGXC,eAAgB,CACdR,KAAMS,SACNH,aAASC,GAGXG,iBAAkB,CAChBV,KAAMW,QACNL,SAAS,GAGXM,OAAQ,CACNZ,KAAMC,OACNK,QAAS,QAGXO,MAAO,CACLb,KAAMC,OACNK,QAAS,SAIbQ,MAAO,CACL,QACA,QACA,sBACA,iBACA,qBACA,sBACA,kBAGF,KAAAC,CAAMjB,GAAYkB,KAAEA,IAClB,MAAMC,EAAW,cAAcC,KAAKC,MAAMC,SAAS,MAC7CC,EAAwBC,EAAAA,KAAI,GAC5BC,EAA4BD,EAAAA,IAAI,MACtC,IAAIE,EAAc,KAKlB,MA8CMC,EAAaC,UACjBC,QAAQC,IAAI,4CAEZ,UAhDO,IAAIC,QAAQ,CAACC,EAASC,KAE3B,GAAIC,OAAOC,SAAWD,OAAOC,QAAQC,UAGnC,OAFAP,QAAQC,IAAI,2CACZE,IAKF,MAAMK,EAAW,wBAEjB,GADuBhC,SAASiC,eAAeD,GAC3B,CAClBR,QAAQC,IAAI,wDAEZ,MAAMS,EAAc,KACdL,OAAOC,SAAWD,OAAOC,QAAQC,UACnCJ,IAEAQ,WAAWD,EAAa,MAI5B,YADAA,GAEF,CAEAV,QAAQC,IAAI,+BAAgC9B,EAAMC,cAClD,MAAMwC,EAASpC,SAASqC,cAAc,UACtCD,EAAOE,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U,KACVjJ,IACFA,EAAOiJ,UACPjJ,EAAS,KACTyJ,EAAe/H,MAAQ,KACvB7B,EAAQ6B,OAAQ,IAOdmI,EAAS3J,UACb+I,UACMtB,KA4CR,OAtBAmC,QACE,IAAM9C,EACN9G,MAAO6J,IACD/J,GAAU+J,SACNF,KAGV,CAAEG,MAAM,IAIVvF,EAAAA,UAAU,KACJ8E,GACF5B,MAKJjD,EAAAA,gBAAgB,KACduE,MAGK,CACLO,eACAC,iBACA5J,UACAE,QACA4H,OACAsB,UACAY,SACAhB,GA9CS,CAAC7F,EAAwB6D,KAC9B7G,GACFA,EAAO6I,GAAG7F,EAAO6D,IA6CnBiC,IAtCU,CAAC9F,EAAwB6D,KAC/B7G,GACFA,EAAO8I,IAAI9F,EAAO6D,IAsCxB"}
@@ -1,2 +1,2 @@
1
- import{defineComponent as e,h as t,ref as o,onMounted as i,onBeforeUnmount as r,watch as n}from"vue";import s from"eventemitter3";import l from"axios";const c=e({name:"OnlyOfficeEditor",props:{officeApiUrl:{type:String,required:!0},document:{type:Object,required:!0},auth:{type:Object,default:void 0},verifyFunction:{type:Function,default:void 0},skipVerification:{type:Boolean,default:!1},height:{type:String,default:"100%"},width:{type:String,default:"100%"}},emits:["ready","error","documentStateChange","requestHistory","requestHistoryData","requestHistoryClose","requestRestore"],setup(e,{emit:t}){const n=`onlyoffice-${Date.now().toString(36)}`,s=o(!1),l=o(null);let c=null;const d=e=>({doc:"word",docx:"word",odt:"word",rtf:"word",txt:"word",html:"word",epub:"word",xls:"cell",xlsx:"cell",ods:"cell",csv:"cell",ppt:"slide",pptx:"slide",odp:"slide",pdf:"word"}[e]||"word");return i(()=>{console.log("[OnlyOffice Component] onMounted called"),console.log("[OnlyOffice Component] Props:",{officeApiUrl:e.officeApiUrl,document:e.document,skipVerification:e.skipVerification}),setTimeout(()=>{(()=>{console.log("[OnlyOffice Component] initEditor called");const o=document.getElementById(n);if(console.log("[OnlyOffice Component] Container element:",o),!o)return console.error("[OnlyOffice Component] Cannot find container element with id:",n),void(l.value="无法找到编辑器容器");if(!window.DocsAPI||!window.DocsAPI.DocEditor)return console.error("[OnlyOffice Component] window.DocsAPI is not available"),void(l.value="OnlyOffice API 未加载");try{console.log("[OnlyOffice Component] Creating editor with config:",{key:e.document.key,url:e.document.url,title:e.document.title,fileType:e.document.fileType});const o={width:e.width,height:e.height,documentType:d(e.document.fileType),document:{fileType:e.document.fileType,key:e.document.key,url:e.document.url,title:e.document.title,permissions:e.document.permissions||{edit:!0,download:!0,review:!0}},editorConfig:{lang:"zh",mode:"edit",callbackUrl:e.document.callbackUrl,user:{id:e.document.userId||"",name:e.document.userName||""}},events:{onDocumentReady:()=>{console.log("[OnlyOffice] Document ready"),s.value=!0,t("ready",c)},onDocumentStateChange:e=>{t("documentStateChange",e)},onError:e=>{var o;console.error("[OnlyOffice] Error:",e),l.value=(null===(o=e.data)||void 0===o?void 0:o.errorDescription)||"编辑器错误",t("error",e)},onRequestHistory:e=>{t("requestHistory",{event:e,editor:c})},onRequestHistoryData:e=>{t("requestHistoryData",{event:e,editor:c})},onRequestHistoryClose:e=>{t("requestHistoryClose",{event:e,editor:c})},onRequestRestore:e=>{t("requestRestore",{event:e,editor:c})}}};c=new window.DocsAPI.DocEditor(n,o),console.log("[OnlyOffice] Editor created successfully")}catch(e){console.error("[OnlyOffice] Error creating editor:",e),l.value=e.message||"初始化失败",t("error",e)}})()},0)}),r(()=>{(()=>{if(c){try{c.destroyEditor()}catch(e){console.warn("[OnlyOffice] Error destroying editor:",e)}c=null,s.value=!1}})()}),{editorId:n,isReady:s,error:l}},render(){return t("div",{class:"onlyoffice-editor-container",style:{width:this.width,height:this.height,position:"relative",minHeight:"400px"}},[t("div",{id:this.editorId,style:{width:"100%",height:"100%"}}),this.error?t("div",{class:"onlyoffice-error",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"red",zIndex:10}},this.error):null])}});function d(e){const t=e.toLowerCase();if(["doc","docx","odt","rtf","txt","html","epub"].includes(t))return"word";if(["xls","xlsx","ods","csv"].includes(t))return"cell";return["ppt","pptx","odp"].includes(t)?"slide":"pdf"===t?"pdf":"other"}class a{constructor(e=""){this.baseUrl=e}async post(e,t,o){const i=this.baseUrl?`${this.baseUrl}${e}`:e;return l.post(i,t,o)}async get(e,t){const o=this.baseUrl?`${this.baseUrl}${e}`:e;return l.get(o,t)}}async function u(e,t){var o;try{const i=new a(e);return!0===(null===(o=(await i.post("/onlyoffice/token/verifyTokenSign",t)).data)||void 0===o?void 0:o.data)}catch(e){return console.error("验签请求失败:",e),!1}}async function f(e,t){try{await l.post(e,t)}catch(e){console.error("保存操作信息失败:",e)}}var h=Object.freeze({__proto__:null,HttpClient:a,saveSuccessInfo:f,verifyTokenSign:u});const y={comment:!1,download:!1,edit:!1,print:!0,review:!1,editCommentAuthorOnly:!1,fillForms:!1,modifyContentControl:!1};class m{constructor(){this.editor=null,this.callback=null,this.height="100%",this.width="100%",this.editorId=`editor-${Date.now().toString(32)}`,this.emitter=new s,this.documentConfig={fileType:"docx",key:"",url:"",title:"",permissions:{...y}},this.editorConfig={lang:"zh",user:{id:"",name:""}}}configure(e){if(e.height&&(this.height=e.height),e.width&&(this.width=e.width),e.fileType){if("other"===d(e.fileType))throw new Error(`不支持的文件类型: ${e.fileType}`);"other"!==d(e.fileType)&&(this.documentConfig.fileType=e.fileType)}e.key&&(this.documentConfig.key=e.key),e.url&&(this.documentConfig.url=e.url),e.title&&(this.documentConfig.title=e.title),e.permissions&&(this.documentConfig.permissions={...this.documentConfig.permissions,...e.permissions},"pdf"===this.documentConfig.fileType&&(this.documentConfig.permissions.edit=!1,this.documentConfig.permissions.review=!1,this.editorConfig.mode="view")),e.callbackUrl&&(this.editorConfig.callbackUrl=e.callbackUrl),e.userId&&(this.editorConfig.user={...this.editorConfig.user,id:e.userId}),e.userName&&(this.editorConfig.user={...this.editorConfig.user,name:e.userName}),e.userGroup&&(this.editorConfig.user={...this.editorConfig.user,group:e.userGroup})}async initOffice(e){const{dom:t,officeApiUrl:o,callback:i,auth:r,verifyFunction:n}=e;if(i&&(this.callback=i),r){let e=!1;if(n)e=await n(r);else{if(!r.verifyUrl)throw new Error("使用验签配置时,必须提供 verifyFunction 或 verifyUrl");e=await u(r.verifyUrl,{appId:r.appId,sign:r.sign,timestamp:r.timestamp})}if(!e)throw new Error("验签失败,请检查验签配置")}return this.createEditor(t,o)}init(e,t,o){return o&&(this.callback=o),this.createEditor(e,t)}createEditor(e,t){if(console.log("[OnlyOffice] createEditor called",{dom:e,officeApiUrl:t}),!e)throw new Error("必须提供挂载的 DOM 元素");if(!t)throw new Error("必须提供 OnlyOffice API 脚本地址");e.style.position="relative",console.log("[OnlyOffice] DOM dimensions:",{width:e.offsetWidth,height:e.offsetHeight});const o=document.createElement("div");o.id=this.editorId,o.style.height="100%",o.style.width="100%",e.appendChild(o);const i=`script-${this.editorId}`;if(document.querySelector(`#${i}`))console.log("[OnlyOffice] Script already loaded"),this.instantiateEditor();else{console.log("[OnlyOffice] Loading script:",t);const e=document.createElement("script");e.id=i,e.src=t,e.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),this.instantiateEditor()},e.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e)},document.head.appendChild(e)}return this}instantiateEditor(){if(console.log("[OnlyOffice] instantiateEditor called"),this.editor&&(this.editor.destroyEditor(),this.editor=null),!window.DocsAPI||!window.DocsAPI.DocEditor)return void console.error("[OnlyOffice] window.DocsAPI.DocEditor is not available");const e={width:this.width,height:this.height,documentType:this.getDocumentType(),document:this.documentConfig,editorConfig:this.editorConfig,events:this.createEventHandlers()};console.log("[OnlyOffice] Creating editor with config:",e),console.log("[OnlyOffice] Editor container ID:",this.editorId),console.log("[OnlyOffice] Container element:",document.getElementById(this.editorId));try{this.editor=new window.DocsAPI.DocEditor(this.editorId,e),console.log("[OnlyOffice] Editor created successfully:",this.editor)}catch(e){console.error("[OnlyOffice] Error creating editor:",e)}}getDocumentType(){const e=d(this.documentConfig.fileType);return"other"===e?"word":e}createEventHandlers(){return{onDocumentStateChange:e=>{this.emitter.emit("documentStateChange",e)},onDocumentReady:()=>{var e,t;console.log("Document is loaded"),this.editorConfig.callbackUrl&&f(this.editorConfig.callbackUrl,{status:8,key:this.documentConfig.key,userdata:JSON.stringify({appUserId:null===(e=this.editorConfig.user)||void 0===e?void 0:e.id})}),null===(t=this.callback)||void 0===t||t.call(this,"onDocumentReady"),this.emitter.emit("onDocumentReady")},onInfo:e=>{var t;console.log("ONLYOFFICE Document Editor is opened in mode",e.data.mode),null===(t=this.callback)||void 0===t||t.call(this,"onInfo",e.data),this.emitter.emit("onInfo",e)},onError:e=>{console.error("ONLYOFFICE Error:",e.data.errorCode,e.data.errorDescription),this.emitter.emit("onError",e)},onRequestHistory:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistory",e,this.editor),this.emitter.emit("onRequestHistory",{event:e,editor:this.editor})},onRequestHistoryData:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryData",e,this.editor),this.emitter.emit("onRequestHistoryData",{event:e,editor:this.editor})},onRequestHistoryClose:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryClose",e,this.editor),this.emitter.emit("onRequestHistoryClose",{event:e,editor:this.editor})},onRequestRestore:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestRestore",e,this.editor),this.emitter.emit("onRequestRestore",{event:e,editor:this.editor})},onRequestSendNotify:e=>{console.log("onRequestSendNotify",e),this.emitter.emit("onRequestSendNotify",e)},onRequestUsers:e=>{console.log("onRequestUsers",e),this.emitter.emit("onRequestUsers",e)}}}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getConfig(){return{...this.documentConfig,...this.editorConfig}}getEditor(){return this.editor}destroy(){this.editor&&(this.editor.destroyEditor(),this.editor=null),this.emitter.removeAllListeners(),this.callback=null}}function p(e){const{officeApiUrl:t,document:s,auth:l,verifyFunction:c,height:d="100%",width:a="100%",autoInit:u=!0}=e,f=o(null),h=o(null),y=o(!1),p=o(null);let g=null;const w=async()=>{if(f.value)try{v(),g=new m,g.configure({...s,height:d,width:a});const e=(e,t,o)=>{if("onDocumentReady"===e)y.value=!0},o={dom:f.value,officeApiUrl:t,callback:e,auth:l,verifyFunction:c};h.value=await g.initOffice(o),g.on("onError",e=>{var t;p.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误"})}catch(e){p.value=e.message||"初始化失败"}else p.value="容器元素未找到"},v=()=>{g&&(g.destroy(),g=null,h.value=null,y.value=!1)},O=async()=>{v(),await w()};return n(()=>s,async e=>{g&&e&&await O()},{deep:!0}),i(()=>{u&&w()}),r(()=>{v()}),{containerRef:f,editorInstance:h,isReady:y,error:p,init:w,destroy:v,reinit:O,on:(e,t)=>{g&&g.on(e,t)},off:(e,t)=>{g&&g.off(e,t)}}}function g(){return new m}async function w(e){return(new m).initOffice(e)}function v(e,t,o){return(new m).init(e,t,o)}async function O(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return h});await i(e,{status:10,key:t,userdata:JSON.stringify({appUserId:o})})}async function C(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return h});await i(e,{status:9,key:t,userdata:JSON.stringify({appUserId:o})})}export{c as OnlyOfficeEditor,g as createOfficeEditor,C as downloadSave,v as init,w as initOffice,O as shareSave,p as useOnlyOffice};
1
+ import{defineComponent as e,h as t,ref as o,onMounted as i,onBeforeUnmount as n,watch as r}from"vue";import s from"eventemitter3";import l from"axios";const c=e({name:"OnlyOfficeEditor",props:{officeApiUrl:{type:String,required:!0},document:{type:Object,required:!0},auth:{type:Object,default:void 0},verifyFunction:{type:Function,default:void 0},skipVerification:{type:Boolean,default:!1},height:{type:String,default:"100%"},width:{type:String,default:"100%"}},emits:["ready","error","documentStateChange","requestHistory","requestHistoryData","requestHistoryClose","requestRestore"],setup(e,{emit:t}){const r=`onlyoffice-${Date.now().toString(36)}`,s=o(!1),l=o(null);let c=null;const d=async()=>{console.log("[OnlyOffice Component] initEditor called");try{await new Promise((t,o)=>{if(window.DocsAPI&&window.DocsAPI.DocEditor)return console.log("[OnlyOffice] Script already loaded"),void t();const i="onlyoffice-api-script";if(document.getElementById(i)){console.log("[OnlyOffice] Script element exists, waiting for load");const e=()=>{window.DocsAPI&&window.DocsAPI.DocEditor?t():setTimeout(e,100)};return void e()}console.log("[OnlyOffice] Loading script:",e.officeApiUrl);const n=document.createElement("script");n.id=i,n.src=e.officeApiUrl,n.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),t()},n.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e),o(new Error("OnlyOffice API 脚本加载失败"))},document.head.appendChild(n)});const o=document.getElementById(r);if(console.log("[OnlyOffice Component] Container element:",o),!o)return console.error("[OnlyOffice Component] Cannot find container element with id:",r),void(l.value="无法找到编辑器容器");console.log("[OnlyOffice Component] Creating editor with config:",{key:e.document.key,url:e.document.url,title:e.document.title,fileType:e.document.fileType});const i={width:e.width,height:e.height,documentType:a(e.document.fileType),document:{fileType:e.document.fileType,key:e.document.key,url:e.document.url,title:e.document.title,permissions:e.document.permissions||{edit:!0,download:!0,review:!0}},editorConfig:{lang:"zh",mode:"edit",callbackUrl:e.document.callbackUrl,user:{id:e.document.userId||"",name:e.document.userName||""}},events:{onDocumentReady:()=>{console.log("[OnlyOffice] Document ready"),s.value=!0,t("ready",c)},onDocumentStateChange:e=>{t("documentStateChange",e)},onError:e=>{var o;console.error("[OnlyOffice] Error:",e),l.value=(null===(o=e.data)||void 0===o?void 0:o.errorDescription)||"编辑器错误",t("error",e)},onRequestHistory:e=>{t("requestHistory",{event:e,editor:c})},onRequestHistoryData:e=>{t("requestHistoryData",{event:e,editor:c})},onRequestHistoryClose:e=>{t("requestHistoryClose",{event:e,editor:c})},onRequestRestore:e=>{t("requestRestore",{event:e,editor:c})}}};c=new window.DocsAPI.DocEditor(r,i),console.log("[OnlyOffice] Editor created successfully")}catch(e){console.error("[OnlyOffice] Error creating editor:",e),l.value=e.message||"初始化失败",t("error",e)}},a=e=>({doc:"word",docx:"word",odt:"word",rtf:"word",txt:"word",html:"word",epub:"word",xls:"cell",xlsx:"cell",ods:"cell",csv:"cell",ppt:"slide",pptx:"slide",odp:"slide",pdf:"word"}[e]||"word");return i(()=>{console.log("[OnlyOffice Component] onMounted called"),console.log("[OnlyOffice Component] Props:",{officeApiUrl:e.officeApiUrl,document:e.document,skipVerification:e.skipVerification}),setTimeout(()=>{d()},0)}),n(()=>{(()=>{if(c){try{c.destroyEditor()}catch(e){console.warn("[OnlyOffice] Error destroying editor:",e)}c=null,s.value=!1}})()}),{editorId:r,isReady:s,error:l}},render(){return t("div",{class:"onlyoffice-editor-container",style:{width:this.width,height:this.height,position:"relative",minHeight:"400px"}},[t("div",{id:this.editorId,style:{width:"100%",height:"100%"}}),this.error?t("div",{class:"onlyoffice-error",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:"red",zIndex:10}},this.error):null])}});function d(e){const t=e.toLowerCase();if(["doc","docx","odt","rtf","txt","html","epub"].includes(t))return"word";if(["xls","xlsx","ods","csv"].includes(t))return"cell";return["ppt","pptx","odp"].includes(t)?"slide":"pdf"===t?"pdf":"other"}class a{constructor(e=""){this.baseUrl=e}async post(e,t,o){const i=this.baseUrl?`${this.baseUrl}${e}`:e;return l.post(i,t,o)}async get(e,t){const o=this.baseUrl?`${this.baseUrl}${e}`:e;return l.get(o,t)}}async function u(e,t){var o;try{const i=new a(e);return!0===(null===(o=(await i.post("/onlyoffice/token/verifyTokenSign",t)).data)||void 0===o?void 0:o.data)}catch(e){return console.error("验签请求失败:",e),!1}}async function f(e,t){try{await l.post(e,t)}catch(e){console.error("保存操作信息失败:",e)}}var h=Object.freeze({__proto__:null,HttpClient:a,saveSuccessInfo:f,verifyTokenSign:u});const y={comment:!1,download:!1,edit:!1,print:!0,review:!1,editCommentAuthorOnly:!1,fillForms:!1,modifyContentControl:!1};class m{constructor(){this.editor=null,this.callback=null,this.height="100%",this.width="100%",this.editorId=`editor-${Date.now().toString(32)}`,this.emitter=new s,this.documentConfig={fileType:"docx",key:"",url:"",title:"",permissions:{...y}},this.editorConfig={lang:"zh",user:{id:"",name:""}}}configure(e){if(e.height&&(this.height=e.height),e.width&&(this.width=e.width),e.fileType){if("other"===d(e.fileType))throw new Error(`不支持的文件类型: ${e.fileType}`);"other"!==d(e.fileType)&&(this.documentConfig.fileType=e.fileType)}e.key&&(this.documentConfig.key=e.key),e.url&&(this.documentConfig.url=e.url),e.title&&(this.documentConfig.title=e.title),e.permissions&&(this.documentConfig.permissions={...this.documentConfig.permissions,...e.permissions},"pdf"===this.documentConfig.fileType&&(this.documentConfig.permissions.edit=!1,this.documentConfig.permissions.review=!1,this.editorConfig.mode="view")),e.callbackUrl&&(this.editorConfig.callbackUrl=e.callbackUrl),e.userId&&(this.editorConfig.user={...this.editorConfig.user,id:e.userId}),e.userName&&(this.editorConfig.user={...this.editorConfig.user,name:e.userName}),e.userGroup&&(this.editorConfig.user={...this.editorConfig.user,group:e.userGroup})}async initOffice(e){const{dom:t,officeApiUrl:o,callback:i,auth:n,verifyFunction:r}=e;if(i&&(this.callback=i),n){let e=!1;if(r)e=await r(n);else{if(!n.verifyUrl)throw new Error("使用验签配置时,必须提供 verifyFunction 或 verifyUrl");e=await u(n.verifyUrl,{appId:n.appId,sign:n.sign,timestamp:n.timestamp})}if(!e)throw new Error("验签失败,请检查验签配置")}return this.createEditor(t,o)}init(e,t,o){return o&&(this.callback=o),this.createEditor(e,t)}createEditor(e,t){if(console.log("[OnlyOffice] createEditor called",{dom:e,officeApiUrl:t}),!e)throw new Error("必须提供挂载的 DOM 元素");if(!t)throw new Error("必须提供 OnlyOffice API 脚本地址");e.style.position="relative",console.log("[OnlyOffice] DOM dimensions:",{width:e.offsetWidth,height:e.offsetHeight});const o=document.createElement("div");o.id=this.editorId,o.style.height="100%",o.style.width="100%",e.appendChild(o);const i=`script-${this.editorId}`;if(document.querySelector(`#${i}`))console.log("[OnlyOffice] Script already loaded"),this.instantiateEditor();else{console.log("[OnlyOffice] Loading script:",t);const e=document.createElement("script");e.id=i,e.src=t,e.onload=()=>{console.log("[OnlyOffice] Script loaded successfully"),console.log("[OnlyOffice] window.DocsAPI:",window.DocsAPI),this.instantiateEditor()},e.onerror=e=>{console.error("[OnlyOffice] Script load failed:",e)},document.head.appendChild(e)}return this}instantiateEditor(){if(console.log("[OnlyOffice] instantiateEditor called"),this.editor&&(this.editor.destroyEditor(),this.editor=null),!window.DocsAPI||!window.DocsAPI.DocEditor)return void console.error("[OnlyOffice] window.DocsAPI.DocEditor is not available");const e={width:this.width,height:this.height,documentType:this.getDocumentType(),document:this.documentConfig,editorConfig:this.editorConfig,events:this.createEventHandlers()};console.log("[OnlyOffice] Creating editor with config:",e),console.log("[OnlyOffice] Editor container ID:",this.editorId),console.log("[OnlyOffice] Container element:",document.getElementById(this.editorId));try{this.editor=new window.DocsAPI.DocEditor(this.editorId,e),console.log("[OnlyOffice] Editor created successfully:",this.editor)}catch(e){console.error("[OnlyOffice] Error creating editor:",e)}}getDocumentType(){const e=d(this.documentConfig.fileType);return"other"===e?"word":e}createEventHandlers(){return{onDocumentStateChange:e=>{this.emitter.emit("documentStateChange",e)},onDocumentReady:()=>{var e,t;console.log("Document is loaded"),this.editorConfig.callbackUrl&&f(this.editorConfig.callbackUrl,{status:8,key:this.documentConfig.key,userdata:JSON.stringify({appUserId:null===(e=this.editorConfig.user)||void 0===e?void 0:e.id})}),null===(t=this.callback)||void 0===t||t.call(this,"onDocumentReady"),this.emitter.emit("onDocumentReady")},onInfo:e=>{var t;console.log("ONLYOFFICE Document Editor is opened in mode",e.data.mode),null===(t=this.callback)||void 0===t||t.call(this,"onInfo",e.data),this.emitter.emit("onInfo",e)},onError:e=>{console.error("ONLYOFFICE Error:",e.data.errorCode,e.data.errorDescription),this.emitter.emit("onError",e)},onRequestHistory:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistory",e,this.editor),this.emitter.emit("onRequestHistory",{event:e,editor:this.editor})},onRequestHistoryData:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryData",e,this.editor),this.emitter.emit("onRequestHistoryData",{event:e,editor:this.editor})},onRequestHistoryClose:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestHistoryClose",e,this.editor),this.emitter.emit("onRequestHistoryClose",{event:e,editor:this.editor})},onRequestRestore:e=>{var t;null===(t=this.callback)||void 0===t||t.call(this,"onRequestRestore",e,this.editor),this.emitter.emit("onRequestRestore",{event:e,editor:this.editor})},onRequestSendNotify:e=>{console.log("onRequestSendNotify",e),this.emitter.emit("onRequestSendNotify",e)},onRequestUsers:e=>{console.log("onRequestUsers",e),this.emitter.emit("onRequestUsers",e)}}}on(e,t){this.emitter.on(e,t)}off(e,t){this.emitter.off(e,t)}getConfig(){return{...this.documentConfig,...this.editorConfig}}getEditor(){return this.editor}destroy(){this.editor&&(this.editor.destroyEditor(),this.editor=null),this.emitter.removeAllListeners(),this.callback=null}}function p(e){const{officeApiUrl:t,document:s,auth:l,verifyFunction:c,height:d="100%",width:a="100%",autoInit:u=!0}=e,f=o(null),h=o(null),y=o(!1),p=o(null);let g=null;const w=async()=>{if(f.value)try{v(),g=new m,g.configure({...s,height:d,width:a});const e=(e,t,o)=>{if("onDocumentReady"===e)y.value=!0},o={dom:f.value,officeApiUrl:t,callback:e,auth:l,verifyFunction:c};h.value=await g.initOffice(o),g.on("onError",e=>{var t;p.value=(null===(t=e.data)||void 0===t?void 0:t.errorDescription)||"编辑器错误"})}catch(e){p.value=e.message||"初始化失败"}else p.value="容器元素未找到"},v=()=>{g&&(g.destroy(),g=null,h.value=null,y.value=!1)},O=async()=>{v(),await w()};return r(()=>s,async e=>{g&&e&&await O()},{deep:!0}),i(()=>{u&&w()}),n(()=>{v()}),{containerRef:f,editorInstance:h,isReady:y,error:p,init:w,destroy:v,reinit:O,on:(e,t)=>{g&&g.on(e,t)},off:(e,t)=>{g&&g.off(e,t)}}}function g(){return new m}async function w(e){return(new m).initOffice(e)}function v(e,t,o){return(new m).init(e,t,o)}async function O(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return h});await i(e,{status:10,key:t,userdata:JSON.stringify({appUserId:o})})}async function C(e,t,o){const{saveSuccessInfo:i}=await Promise.resolve().then(function(){return h});await i(e,{status:9,key:t,userdata:JSON.stringify({appUserId:o})})}export{c as OnlyOfficeEditor,g as createOfficeEditor,C as downloadSave,v as init,w as initOffice,O as shareSave,p as useOnlyOffice};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../../src/vue3/component.ts","../../../src/core/utils/fileType.ts","../../../src/core/utils/http.ts","../../../src/core/editor.ts","../../../src/vue3/useOnlyOffice.ts","../../../src/core/index.ts"],"sourcesContent":["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n h,\n type PropType,\n type Ref,\n} from 'vue';\nimport type {\n OfficeDocumentConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\n\n/**\n * OnlyOffice 编辑器 Vue 3 组件\n */\nexport const OnlyOfficeEditor = defineComponent({\n name: 'OnlyOfficeEditor',\n\n props: {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: {\n type: String,\n required: true,\n },\n /** 文档配置 */\n document: {\n type: Object as PropType<OfficeDocumentConfig>,\n required: true,\n },\n /** 验签配置 */\n auth: {\n type: Object as PropType<AuthConfig>,\n default: undefined,\n },\n /** 自定义验签函数 */\n verifyFunction: {\n type: Function as PropType<VerifyTokenSignFunction>,\n default: undefined,\n },\n /** 是否跳过验签(当 auth 已通过外部验签时使用) */\n skipVerification: {\n type: Boolean,\n default: false,\n },\n /** 编辑器高度 */\n height: {\n type: String,\n default: '100%',\n },\n /** 编辑器宽度 */\n width: {\n type: String,\n default: '100%',\n },\n },\n\n emits: [\n 'ready',\n 'error',\n 'documentStateChange',\n 'requestHistory',\n 'requestHistoryData',\n 'requestHistoryClose',\n 'requestRestore',\n ],\n\n setup(props: any, { emit }: any) {\n const editorId = `onlyoffice-${Date.now().toString(36)}`;\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n let editor: any = null;\n\n /**\n * 初始化编辑器\n */\n const initEditor = () => {\n console.log('[OnlyOffice Component] initEditor called');\n\n // 获取容器元素\n const dom = document.getElementById(editorId);\n console.log('[OnlyOffice Component] Container element:', dom);\n\n if (!dom) {\n console.error('[OnlyOffice Component] Cannot find container element with id:', editorId);\n error.value = '无法找到编辑器容器';\n return;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice Component] window.DocsAPI is not available');\n error.value = 'OnlyOffice API 未加载';\n return;\n }\n\n try {\n console.log('[OnlyOffice Component] Creating editor with config:', {\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n fileType: props.document.fileType\n });\n\n // 构建编辑器配置\n const config: any = {\n width: props.width,\n height: props.height,\n documentType: getDocumentType(props.document.fileType),\n document: {\n fileType: props.document.fileType,\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n permissions: props.document.permissions || {\n edit: true,\n download: true,\n review: true\n }\n },\n editorConfig: {\n lang: 'zh',\n mode: 'edit',\n callbackUrl: props.document.callbackUrl,\n user: {\n id: props.document.userId || '',\n name: props.document.userName || ''\n }\n },\n events: {\n onDocumentReady: () => {\n console.log('[OnlyOffice] Document ready');\n isReady.value = true;\n emit('ready', editor);\n },\n onDocumentStateChange: (event: any) => {\n emit('documentStateChange', event);\n },\n onError: (event: any) => {\n console.error('[OnlyOffice] Error:', event);\n error.value = event.data?.errorDescription || '编辑器错误';\n emit('error', event);\n },\n onRequestHistory: (event: any) => {\n emit('requestHistory', { event, editor });\n },\n onRequestHistoryData: (event: any) => {\n emit('requestHistoryData', { event, editor });\n },\n onRequestHistoryClose: (event: any) => {\n emit('requestHistoryClose', { event, editor });\n },\n onRequestRestore: (event: any) => {\n emit('requestRestore', { event, editor });\n }\n }\n };\n\n // 创建编辑器实例\n editor = new window.DocsAPI.DocEditor(editorId, config);\n console.log('[OnlyOffice] Editor created successfully');\n } catch (err: any) {\n console.error('[OnlyOffice] Error creating editor:', err);\n error.value = err.message || '初始化失败';\n emit('error', err);\n }\n };\n\n /**\n * 获取文档类型\n */\n const getDocumentType = (fileType: string): string => {\n const typeMap: Record<string, string> = {\n 'doc': 'word',\n 'docx': 'word',\n 'odt': 'word',\n 'rtf': 'word',\n 'txt': 'word',\n 'html': 'word',\n 'epub': 'word',\n 'xls': 'cell',\n 'xlsx': 'cell',\n 'ods': 'cell',\n 'csv': 'cell',\n 'ppt': 'slide',\n 'pptx': 'slide',\n 'odp': 'slide',\n 'pdf': 'word'\n };\n return typeMap[fileType] || 'word';\n };\n\n /**\n * 销毁编辑器\n */\n const destroyEditor = () => {\n if (editor) {\n try {\n editor.destroyEditor();\n } catch (e) {\n console.warn('[OnlyOffice] Error destroying editor:', e);\n }\n editor = null;\n isReady.value = false;\n }\n };\n\n // 组件挂载时初始化\n onMounted(() => {\n console.log('[OnlyOffice Component] onMounted called');\n console.log('[OnlyOffice Component] Props:', {\n officeApiUrl: props.officeApiUrl,\n document: props.document,\n skipVerification: props.skipVerification\n });\n\n // 使用 setTimeout 确保 DOM 已经完全渲染\n setTimeout(() => {\n initEditor();\n }, 0);\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroyEditor();\n });\n\n return {\n editorId,\n isReady,\n error,\n };\n },\n\n render() {\n return h('div', {\n class: 'onlyoffice-editor-container',\n style: {\n width: this.width,\n height: this.height,\n position: 'relative',\n minHeight: '400px'\n }\n }, [\n h('div', {\n id: this.editorId,\n style: { width: '100%', height: '100%' }\n }),\n this.error ? h('div', {\n class: 'onlyoffice-error',\n style: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n color: 'red',\n zIndex: 10\n }\n }, this.error) : null\n ]);\n }\n});\n\nexport default OnlyOfficeEditor;\n","import type { DocumentType, FileType } from '../../types';\n\n/**\n * 根据文件扩展名获取 OnlyOffice 文档类型\n * @param fileType 文件扩展名\n * @returns 文档类型\n */\nexport function getDocumentType(fileType: FileType | string): DocumentType | 'other' {\n const type = fileType.toLowerCase();\n\n // 文档类型\n const wordTypes = ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'epub'];\n if (wordTypes.includes(type)) {\n return 'word';\n }\n\n // 表格类型\n const cellTypes = ['xls', 'xlsx', 'ods', 'csv'];\n if (cellTypes.includes(type)) {\n return 'cell';\n }\n\n // 演示类型\n const slideTypes = ['ppt', 'pptx', 'odp'];\n if (slideTypes.includes(type)) {\n return 'slide';\n }\n\n // PDF 类型\n if (type === 'pdf') {\n return 'pdf';\n }\n\n return 'other';\n}\n\n/**\n * 检查文件类型是否受支持\n * @param fileType 文件扩展名\n * @returns 是否支持\n */\nexport function isSupportedFileType(fileType: string): boolean {\n return getDocumentType(fileType) !== 'other';\n}","import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';\n\n/**\n * HTTP 请求工具\n */\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string = '') {\n this.baseUrl = baseUrl;\n }\n\n /**\n * 发送 POST 请求\n * @param url 请求地址\n * @param data 请求数据\n * @param config 额外配置\n * @returns Promise\n */\n async post<T = any>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.post<T>(fullUrl, data, config);\n }\n\n /**\n * 发送 GET 请求\n * @param url 请求地址\n * @param config 额外配置\n * @returns Promise\n */\n async get<T = any>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.get<T>(fullUrl, config);\n }\n}\n\n/**\n * 验签接口请求\n * @param baseUrl 基础 URL\n * @param data 验签数据\n * @returns 验签结果\n */\nexport async function verifyTokenSign(\n baseUrl: string,\n data: {\n appId: string;\n sign: string;\n timestamp: number;\n }\n): Promise<boolean> {\n try {\n const client = new HttpClient(baseUrl);\n const response = await client.post<{ data: boolean }>(\n '/onlyoffice/token/verifyTokenSign',\n data\n );\n return response.data?.data === true;\n } catch (error) {\n console.error('验签请求失败:', error);\n return false;\n }\n}\n\n/**\n * 保存操作信息\n * @param callbackUrl 回调地址\n * @param data 操作数据\n */\nexport async function saveSuccessInfo(\n callbackUrl: string,\n data: {\n status: number;\n key: string;\n userdata: string;\n }\n): Promise<void> {\n try {\n await axios.post(callbackUrl, data);\n } catch (error) {\n console.error('保存操作信息失败:', error);\n }\n}","import EventEmitter from 'eventemitter3';\nimport type {\n DocumentConfig,\n EditorConfig,\n DocumentPermissions,\n OfficeEventType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeDocumentConfig,\n OfficeInitConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\nimport { getDocumentType, isSupportedFileType } from './utils/fileType';\nimport { verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n/**\n * 默认文档权限\n */\nconst DEFAULT_PERMISSIONS: DocumentPermissions = {\n comment: false,\n download: false,\n edit: false,\n print: true,\n review: false,\n editCommentAuthorOnly: false,\n fillForms: false,\n modifyContentControl: false,\n};\n\n/**\n * OnlyOffice 编辑器管理类\n */\nexport class OfficeEditor implements OfficeEditorInstance {\n private editor: any = null;\n private editorId: string;\n private emitter: EventEmitter;\n private documentConfig: DocumentConfig;\n private editorConfig: EditorConfig;\n private callback: OfficeCallback | null = null;\n private height: string = '100%';\n private width: string = '100%';\n\n constructor() {\n this.editorId = `editor-${Date.now().toString(32)}`;\n this.emitter = new EventEmitter();\n this.documentConfig = {\n fileType: 'docx',\n key: '',\n url: '',\n title: '',\n permissions: { ...DEFAULT_PERMISSIONS },\n };\n this.editorConfig = {\n lang: 'zh',\n user: { id: '', name: '' },\n };\n }\n\n /**\n * 配置文档参数\n */\n configure(config: OfficeDocumentConfig): void {\n if (config.height) this.height = config.height;\n if (config.width) this.width = config.width;\n\n if (config.fileType) {\n if (!isSupportedFileType(config.fileType)) {\n throw new Error(`不支持的文件类型: ${config.fileType}`);\n }\n const docType = getDocumentType(config.fileType);\n if (docType !== 'other') {\n this.documentConfig.fileType = config.fileType;\n }\n }\n\n if (config.key) this.documentConfig.key = config.key;\n if (config.url) this.documentConfig.url = config.url;\n if (config.title) this.documentConfig.title = config.title;\n\n if (config.permissions) {\n this.documentConfig.permissions = {\n ...this.documentConfig.permissions,\n ...config.permissions,\n };\n\n // PDF 文件特殊处理\n if (this.documentConfig.fileType === 'pdf') {\n this.documentConfig.permissions.edit = false;\n this.documentConfig.permissions.review = false;\n this.editorConfig.mode = 'view';\n }\n }\n\n if (config.callbackUrl) this.editorConfig.callbackUrl = config.callbackUrl;\n if (config.userId) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n id: config.userId,\n };\n }\n if (config.userName) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n name: config.userName,\n };\n }\n if (config.userGroup) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n group: config.userGroup,\n };\n }\n }\n\n /**\n * 初始化编辑器(带验签)\n */\n async initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const { dom, officeApiUrl, callback, auth, verifyFunction } = config;\n\n if (callback) this.callback = callback;\n\n // 验签逻辑\n if (auth) {\n let verified = false;\n\n if (verifyFunction) {\n // 使用自定义验签函数\n verified = await verifyFunction(auth);\n } else if (auth.verifyUrl) {\n // 使用自定义验签地址\n verified = await verifyTokenSign(auth.verifyUrl, {\n appId: auth.appId,\n sign: auth.sign,\n timestamp: auth.timestamp,\n });\n } else {\n throw new Error('使用验签配置时,必须提供 verifyFunction 或 verifyUrl');\n }\n\n if (!verified) {\n throw new Error('验签失败,请检查验签配置');\n }\n }\n\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 简化初始化(无验签)\n */\n init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n ): OfficeEditorInstance {\n if (callback) this.callback = callback;\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 创建编辑器实例\n */\n private createEditor(dom: HTMLElement, officeApiUrl: string): OfficeEditorInstance {\n console.log('[OnlyOffice] createEditor called', { dom, officeApiUrl });\n\n if (!dom) {\n throw new Error('必须提供挂载的 DOM 元素');\n }\n\n if (!officeApiUrl) {\n throw new Error('必须提供 OnlyOffice API 脚本地址');\n }\n\n // 设置容器样式\n dom.style.position = 'relative';\n console.log('[OnlyOffice] DOM dimensions:', { width: dom.offsetWidth, height: dom.offsetHeight });\n\n // 创建编辑器容器\n const mainDiv = document.createElement('div');\n mainDiv.id = this.editorId;\n mainDiv.style.height = '100%';\n mainDiv.style.width = '100%';\n dom.appendChild(mainDiv);\n\n // 动态加载 OnlyOffice API 脚本\n const scriptId = `script-${this.editorId}`;\n const existingScript = document.querySelector(`#${scriptId}`);\n\n if (!existingScript) {\n console.log('[OnlyOffice] Loading script:', officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n this.instantiateEditor();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n };\n document.head.appendChild(script);\n } else {\n console.log('[OnlyOffice] Script already loaded');\n this.instantiateEditor();\n }\n\n return this;\n }\n\n /**\n * 实例化编辑器\n */\n private instantiateEditor(): void {\n console.log('[OnlyOffice] instantiateEditor called');\n\n // 销毁现有实例\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice] window.DocsAPI.DocEditor is not available');\n return;\n }\n\n // 构建配置对象\n const config = {\n width: this.width,\n height: this.height,\n documentType: this.getDocumentType(),\n document: this.documentConfig,\n editorConfig: this.editorConfig,\n events: this.createEventHandlers(),\n };\n\n console.log('[OnlyOffice] Creating editor with config:', config);\n console.log('[OnlyOffice] Editor container ID:', this.editorId);\n console.log('[OnlyOffice] Container element:', document.getElementById(this.editorId));\n\n // 创建编辑器实例\n try {\n this.editor = new window.DocsAPI.DocEditor(this.editorId, config);\n console.log('[OnlyOffice] Editor created successfully:', this.editor);\n } catch (err) {\n console.error('[OnlyOffice] Error creating editor:', err);\n }\n }\n\n /**\n * 获取文档类型\n */\n private getDocumentType(): string {\n const type = getDocumentType(this.documentConfig.fileType);\n return type === 'other' ? 'word' : type;\n }\n\n /**\n * 创建事件处理器\n */\n private createEventHandlers(): Record<string, (event: any) => void> {\n return {\n onDocumentStateChange: (event: any) => {\n this.emitter.emit('documentStateChange', event);\n },\n onDocumentReady: () => {\n console.log('Document is loaded');\n // 通知后端文档加载成功\n if (this.editorConfig.callbackUrl) {\n saveSuccessInfo(this.editorConfig.callbackUrl, {\n status: 8,\n key: this.documentConfig.key,\n userdata: JSON.stringify({\n appUserId: this.editorConfig.user?.id,\n }),\n });\n }\n this.callback?.('onDocumentReady');\n this.emitter.emit('onDocumentReady');\n },\n onInfo: (event: any) => {\n console.log('ONLYOFFICE Document Editor is opened in mode', event.data.mode);\n this.callback?.('onInfo', event.data);\n this.emitter.emit('onInfo', event);\n },\n onError: (event: any) => {\n console.error('ONLYOFFICE Error:', event.data.errorCode, event.data.errorDescription);\n this.emitter.emit('onError', event);\n },\n onRequestHistory: (event: any) => {\n this.callback?.('onRequestHistory', event, this.editor);\n this.emitter.emit('onRequestHistory', { event, editor: this.editor });\n },\n onRequestHistoryData: (event: any) => {\n this.callback?.('onRequestHistoryData', event, this.editor);\n this.emitter.emit('onRequestHistoryData', { event, editor: this.editor });\n },\n onRequestHistoryClose: (event: any) => {\n this.callback?.('onRequestHistoryClose', event, this.editor);\n this.emitter.emit('onRequestHistoryClose', { event, editor: this.editor });\n },\n onRequestRestore: (event: any) => {\n this.callback?.('onRequestRestore', event, this.editor);\n this.emitter.emit('onRequestRestore', { event, editor: this.editor });\n },\n onRequestSendNotify: (event: any) => {\n console.log('onRequestSendNotify', event);\n this.emitter.emit('onRequestSendNotify', event);\n },\n onRequestUsers: (event: any) => {\n console.log('onRequestUsers', event);\n this.emitter.emit('onRequestUsers', event);\n },\n };\n }\n\n /**\n * 监听事件\n */\n on(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.on(event, callback);\n }\n\n /**\n * 移除事件监听\n */\n off(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.off(event, callback);\n }\n\n /**\n * 获取当前配置\n */\n getConfig(): DocumentConfig & EditorConfig {\n return {\n ...this.documentConfig,\n ...this.editorConfig,\n };\n }\n\n /**\n * 获取内部编辑器实例\n */\n getEditor(): any {\n return this.editor;\n }\n\n /**\n * 销毁编辑器\n */\n destroy(): void {\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n this.emitter.removeAllListeners();\n this.callback = null;\n }\n}","import { ref, onMounted, onBeforeUnmount, watch, type Ref } from 'vue';\nimport { OfficeEditor } from '../core/editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * useOnlyOffice 配置选项\n */\nexport interface UseOnlyOfficeOptions {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: string;\n /** 文档配置 */\n document: OfficeDocumentConfig;\n /** 验签配置 */\n auth?: AuthConfig;\n /** 自定义验签函数 */\n verifyFunction?: VerifyTokenSignFunction;\n /** 编辑器高度 */\n height?: string;\n /** 编辑器宽度 */\n width?: string;\n /** 是否自动初始化 */\n autoInit?: boolean;\n}\n\n/**\n * useOnlyOffice 返回值\n */\nexport interface UseOnlyOfficeReturn {\n /** 容器元素引用 */\n containerRef: Ref<HTMLElement | null>;\n /** 编辑器实例 */\n editorInstance: Ref<OfficeEditorInstance | null>;\n /** 是否已就绪 */\n isReady: Ref<boolean>;\n /** 错误信息 */\n error: Ref<string | null>;\n /** 初始化编辑器 */\n init: () => Promise<void>;\n /** 销毁编辑器 */\n destroy: () => void;\n /** 重新初始化 */\n reinit: () => Promise<void>;\n /** 监听事件 */\n on: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n /** 移除事件监听 */\n off: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n}\n\n/**\n * OnlyOffice Vue 3 组合式函数\n * @param options 配置选项\n * @returns 编辑器状态和方法\n */\nexport function useOnlyOffice(options: UseOnlyOfficeOptions): UseOnlyOfficeReturn {\n const {\n officeApiUrl,\n document: documentConfig,\n auth,\n verifyFunction,\n height = '100%',\n width = '100%',\n autoInit = true,\n } = options;\n\n const containerRef: Ref<HTMLElement | null> = ref(null);\n const editorInstance: Ref<OfficeEditorInstance | null> = ref(null);\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n\n let editor: OfficeEditor | null = null;\n\n /**\n * 初始化编辑器\n */\n const init = async () => {\n if (!containerRef.value) {\n error.value = '容器元素未找到';\n return;\n }\n\n try {\n // 销毁现有实例\n destroy();\n\n editor = new OfficeEditor();\n\n // 配置文档参数\n editor.configure({\n ...documentConfig,\n height,\n width,\n });\n\n // 事件回调\n const callback: OfficeCallback = (type, _event, _editorInst) => {\n switch (type) {\n case 'onDocumentReady':\n isReady.value = true;\n break;\n case 'onInfo':\n break;\n }\n };\n\n // 初始化配置\n const initConfig: OfficeInitConfig = {\n dom: containerRef.value,\n officeApiUrl,\n callback,\n auth,\n verifyFunction,\n };\n\n // 初始化编辑器\n editorInstance.value = await editor.initOffice(initConfig);\n\n // 监听错误事件\n editor.on('onError' as OfficeEventType, (event: any) => {\n error.value = event.data?.errorDescription || '编辑器错误';\n });\n } catch (err: any) {\n error.value = err.message || '初始化失败';\n }\n };\n\n /**\n * 销毁编辑器\n */\n const destroy = () => {\n if (editor) {\n editor.destroy();\n editor = null;\n editorInstance.value = null;\n isReady.value = false;\n }\n };\n\n /**\n * 重新初始化\n */\n const reinit = async () => {\n destroy();\n await init();\n };\n\n /**\n * 监听事件\n */\n const on = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.on(event, callback);\n }\n };\n\n /**\n * 移除事件监听\n */\n const off = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.off(event, callback);\n }\n };\n\n // 监听文档配置变化\n watch(\n () => documentConfig,\n async (newDoc: any) => {\n if (editor && newDoc) {\n await reinit();\n }\n },\n { deep: true }\n );\n\n // 组件挂载时初始化\n onMounted(() => {\n if (autoInit) {\n init();\n }\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroy();\n });\n\n return {\n containerRef,\n editorInstance,\n isReady,\n error,\n init,\n destroy,\n reinit,\n on,\n off,\n };\n}\n\nexport default useOnlyOffice;","export { OfficeEditor } from './editor';\nexport { getDocumentType, isSupportedFileType } from './utils/fileType';\nexport { HttpClient, verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n// 导出类型\nexport type {\n DocumentType,\n FileType,\n DocumentPermissions,\n UserInfo,\n DocumentConfig,\n EditorConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeInitConfig,\n OfficeDocumentConfig,\n OfficeEventType,\n OfficeCallbackType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeSDK,\n} from '../types';\n\nimport { OfficeEditor } from './editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * 创建 Office 编辑器实例\n * @returns OfficeEditor 实例\n */\nexport function createOfficeEditor(): OfficeEditor {\n return new OfficeEditor();\n}\n\n/**\n * 快速初始化 Office 编辑器\n * @param config 初始化配置\n * @returns Promise<OfficeEditorInstance>\n */\nexport async function initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const editor = new OfficeEditor();\n return editor.initOffice(config);\n}\n\n/**\n * 简化初始化(无验签)\n * @param dom 挂载的 DOM 元素\n * @param officeApiUrl OnlyOffice API 地址\n * @param callback 事件回调\n * @returns OfficeEditorInstance\n */\nexport function init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n): OfficeEditorInstance {\n const editor = new OfficeEditor();\n return editor.init(dom, officeApiUrl, callback);\n}\n\n/**\n * 配置文档参数(全局配置,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.configure() 方法\n */\nexport function config(_config: OfficeDocumentConfig): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.configure() 方法');\n}\n\n/**\n * 销毁编辑器(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.destroy() 方法\n */\nexport function destroy(): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.destroy() 方法');\n}\n\n/**\n * 监听事件(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.on() 方法\n */\nexport function on(_event: OfficeEventType, _callback: (...args: any[]) => void): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.on() 方法');\n}\n\n/**\n * 记录分享动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function shareSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 10,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}\n\n/**\n * 记录下载动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function downloadSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 9,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}"],"names":["OnlyOfficeEditor","defineComponent","name","props","officeApiUrl","type","String","required","document","Object","auth","default","undefined","verifyFunction","Function","skipVerification","Boolean","height","width","emits","setup","emit","editorId","Date","now","toString","isReady","ref","error","editor","getDocumentType","fileType","doc","docx","odt","rtf","txt","html","epub","xls","xlsx","ods","csv","ppt","pptx","odp","pdf","onMounted","console","log","setTimeout","dom","getElementById","value","window","DocsAPI","DocEditor","key","url","title","config","documentType","permissions","edit","download","review","editorConfig","lang","mode","callbackUrl","user","id","userId","userName","events","onDocumentReady","onDocumentStateChange","event","onError","_a","data","errorDescription","onRequestHistory","onRequestHistoryData","onRequestHistoryClose","onRequestRestore","err","message","initEditor","onBeforeUnmount","destroyEditor","e","warn","render","h","class","style","this","position","minHeight","top","left","transform","color","zIndex","toLowerCase","includes","HttpClient","constructor","baseUrl","post","fullUrl","axios","get","async","verifyTokenSign","client","saveSuccessInfo","DEFAULT_PERMISSIONS","comment","print","editCommentAuthorOnly","fillForms","modifyContentControl","OfficeEditor","callback","emitter","EventEmitter","documentConfig","configure","Error","userGroup","group","initOffice","verified","verifyUrl","appId","sign","timestamp","createEditor","init","offsetWidth","offsetHeight","mainDiv","createElement","appendChild","scriptId","querySelector","instantiateEditor","script","src","onload","onerror","head","createEventHandlers","status","userdata","JSON","stringify","appUserId","_b","call","onInfo","errorCode","onRequestSendNotify","onRequestUsers","on","off","getConfig","getEditor","destroy","removeAllListeners","useOnlyOffice","options","autoInit","containerRef","editorInstance","_event","_editorInst","initConfig","reinit","watch","newDoc","deep","createOfficeEditor","shareSave","fileKey","Promise","resolve","then","http","downloadSave"],"mappings":"uJAkBO,MAAMA,EAAmBC,EAAgB,CAC9CC,KAAM,mBAENC,MAAO,CAELC,aAAc,CACZC,KAAMC,OACNC,UAAU,GAGZC,SAAU,CACRH,KAAMI,OACNF,UAAU,GAGZG,KAAM,CACJL,KAAMI,OACNE,aAASC,GAGXC,eAAgB,CACdR,KAAMS,SACNH,aAASC,GAGXG,iBAAkB,CAChBV,KAAMW,QACNL,SA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AAI1F,EAAOgD,IAsCxB,UCzKgB2D,IACd,OAAO,IAAI5D,CACb,CAOOV,eAAemB,EAAWzE,GAE/B,OADe,IAAIgE,GACLS,WAAWzE,EAC3B,UASgBgF,EACdzF,EACA/C,EACAyH,GAGA,OADe,IAAID,GACLgB,KAAKzF,EAAK/C,EAAcyH,EACxC,CAgCOX,eAAeuE,EACpBpH,EACAqH,EACA3B,GAEA,MAAM1C,gBAAEA,SAA0BsE,QAAAC,UAAAC,KAAA,WAAA,OAAAC,CAAA,SAC5BzE,EAAgBhD,EAAa,CACjCsF,OAAQ,GACRlG,IAAKiI,EACL9B,SAAUC,KAAKC,UAAU,CAAEC,eAE/B,CAQO7C,eAAe6E,EACpB1H,EACAqH,EACA3B,GAEA,MAAM1C,gBAAEA,SAA0BsE,QAAAC,UAAAC,KAAA,WAAA,OAAAC,CAAA,SAC5BzE,EAAgBhD,EAAa,CACjCsF,OAAQ,EACRlG,IAAKiI,EACL9B,SAAUC,KAAKC,UAAU,CAAEC,eAE/B"}
1
+ {"version":3,"file":"index.mjs","sources":["../../../src/vue3/component.ts","../../../src/core/utils/fileType.ts","../../../src/core/utils/http.ts","../../../src/core/editor.ts","../../../src/vue3/useOnlyOffice.ts","../../../src/core/index.ts"],"sourcesContent":["import {\n defineComponent,\n ref,\n onMounted,\n onBeforeUnmount,\n h,\n type PropType,\n type Ref,\n} from 'vue';\nimport type {\n OfficeDocumentConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\n\n/**\n * OnlyOffice 编辑器 Vue 3 组件\n */\nexport const OnlyOfficeEditor = defineComponent({\n name: 'OnlyOfficeEditor',\n\n props: {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: {\n type: String,\n required: true,\n },\n /** 文档配置 */\n document: {\n type: Object as PropType<OfficeDocumentConfig>,\n required: true,\n },\n /** 验签配置 */\n auth: {\n type: Object as PropType<AuthConfig>,\n default: undefined,\n },\n /** 自定义验签函数 */\n verifyFunction: {\n type: Function as PropType<VerifyTokenSignFunction>,\n default: undefined,\n },\n /** 是否跳过验签(当 auth 已通过外部验签时使用) */\n skipVerification: {\n type: Boolean,\n default: false,\n },\n /** 编辑器高度 */\n height: {\n type: String,\n default: '100%',\n },\n /** 编辑器宽度 */\n width: {\n type: String,\n default: '100%',\n },\n },\n\n emits: [\n 'ready',\n 'error',\n 'documentStateChange',\n 'requestHistory',\n 'requestHistoryData',\n 'requestHistoryClose',\n 'requestRestore',\n ],\n\n setup(props: any, { emit }: any) {\n const editorId = `onlyoffice-${Date.now().toString(36)}`;\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n let editor: any = null;\n\n /**\n * 加载 OnlyOffice API 脚本\n */\n const loadScript = (): Promise<void> => {\n return new Promise((resolve, reject) => {\n // 检查是否已经加载\n if (window.DocsAPI && window.DocsAPI.DocEditor) {\n console.log('[OnlyOffice] Script already loaded');\n resolve();\n return;\n }\n\n // 检查是否已经有相同的脚本正在加载\n const scriptId = 'onlyoffice-api-script';\n const existingScript = document.getElementById(scriptId) as HTMLScriptElement;\n if (existingScript) {\n console.log('[OnlyOffice] Script element exists, waiting for load');\n // 等待脚本加载完成\n const checkLoaded = () => {\n if (window.DocsAPI && window.DocsAPI.DocEditor) {\n resolve();\n } else {\n setTimeout(checkLoaded, 100);\n }\n };\n checkLoaded();\n return;\n }\n\n console.log('[OnlyOffice] Loading script:', props.officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = props.officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n resolve();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n reject(new Error('OnlyOffice API 脚本加载失败'));\n };\n document.head.appendChild(script);\n });\n };\n\n /**\n * 初始化编辑器\n */\n const initEditor = async () => {\n console.log('[OnlyOffice Component] initEditor called');\n\n try {\n // 先加载脚本\n await loadScript();\n\n // 获取容器元素\n const dom = document.getElementById(editorId);\n console.log('[OnlyOffice Component] Container element:', dom);\n\n if (!dom) {\n console.error('[OnlyOffice Component] Cannot find container element with id:', editorId);\n error.value = '无法找到编辑器容器';\n return;\n }\n\n console.log('[OnlyOffice Component] Creating editor with config:', {\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n fileType: props.document.fileType\n });\n\n // 构建编辑器配置\n const config: any = {\n width: props.width,\n height: props.height,\n documentType: getDocumentType(props.document.fileType),\n document: {\n fileType: props.document.fileType,\n key: props.document.key,\n url: props.document.url,\n title: props.document.title,\n permissions: props.document.permissions || {\n edit: true,\n download: true,\n review: true\n }\n },\n editorConfig: {\n lang: 'zh',\n mode: 'edit',\n callbackUrl: props.document.callbackUrl,\n user: {\n id: props.document.userId || '',\n name: props.document.userName || ''\n }\n },\n events: {\n onDocumentReady: () => {\n console.log('[OnlyOffice] Document ready');\n isReady.value = true;\n emit('ready', editor);\n },\n onDocumentStateChange: (event: any) => {\n emit('documentStateChange', event);\n },\n onError: (event: any) => {\n console.error('[OnlyOffice] Error:', event);\n error.value = event.data?.errorDescription || '编辑器错误';\n emit('error', event);\n },\n onRequestHistory: (event: any) => {\n emit('requestHistory', { event, editor });\n },\n onRequestHistoryData: (event: any) => {\n emit('requestHistoryData', { event, editor });\n },\n onRequestHistoryClose: (event: any) => {\n emit('requestHistoryClose', { event, editor });\n },\n onRequestRestore: (event: any) => {\n emit('requestRestore', { event, editor });\n }\n }\n };\n\n // 创建编辑器实例\n editor = new window.DocsAPI.DocEditor(editorId, config);\n console.log('[OnlyOffice] Editor created successfully');\n } catch (err: any) {\n console.error('[OnlyOffice] Error creating editor:', err);\n error.value = err.message || '初始化失败';\n emit('error', err);\n }\n };\n\n /**\n * 获取文档类型\n */\n const getDocumentType = (fileType: string): string => {\n const typeMap: Record<string, string> = {\n 'doc': 'word',\n 'docx': 'word',\n 'odt': 'word',\n 'rtf': 'word',\n 'txt': 'word',\n 'html': 'word',\n 'epub': 'word',\n 'xls': 'cell',\n 'xlsx': 'cell',\n 'ods': 'cell',\n 'csv': 'cell',\n 'ppt': 'slide',\n 'pptx': 'slide',\n 'odp': 'slide',\n 'pdf': 'word'\n };\n return typeMap[fileType] || 'word';\n };\n\n /**\n * 销毁编辑器\n */\n const destroyEditor = () => {\n if (editor) {\n try {\n editor.destroyEditor();\n } catch (e) {\n console.warn('[OnlyOffice] Error destroying editor:', e);\n }\n editor = null;\n isReady.value = false;\n }\n };\n\n // 组件挂载时初始化\n onMounted(() => {\n console.log('[OnlyOffice Component] onMounted called');\n console.log('[OnlyOffice Component] Props:', {\n officeApiUrl: props.officeApiUrl,\n document: props.document,\n skipVerification: props.skipVerification\n });\n\n // 使用 setTimeout 确保 DOM 已经完全渲染\n setTimeout(() => {\n initEditor();\n }, 0);\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroyEditor();\n });\n\n return {\n editorId,\n isReady,\n error,\n };\n },\n\n render() {\n return h('div', {\n class: 'onlyoffice-editor-container',\n style: {\n width: this.width,\n height: this.height,\n position: 'relative',\n minHeight: '400px'\n }\n }, [\n h('div', {\n id: this.editorId,\n style: { width: '100%', height: '100%' }\n }),\n this.error ? h('div', {\n class: 'onlyoffice-error',\n style: {\n position: 'absolute',\n top: '50%',\n left: '50%',\n transform: 'translate(-50%, -50%)',\n color: 'red',\n zIndex: 10\n }\n }, this.error) : null\n ]);\n }\n});\n\nexport default OnlyOfficeEditor;\n","import type { DocumentType, FileType } from '../../types';\n\n/**\n * 根据文件扩展名获取 OnlyOffice 文档类型\n * @param fileType 文件扩展名\n * @returns 文档类型\n */\nexport function getDocumentType(fileType: FileType | string): DocumentType | 'other' {\n const type = fileType.toLowerCase();\n\n // 文档类型\n const wordTypes = ['doc', 'docx', 'odt', 'rtf', 'txt', 'html', 'epub'];\n if (wordTypes.includes(type)) {\n return 'word';\n }\n\n // 表格类型\n const cellTypes = ['xls', 'xlsx', 'ods', 'csv'];\n if (cellTypes.includes(type)) {\n return 'cell';\n }\n\n // 演示类型\n const slideTypes = ['ppt', 'pptx', 'odp'];\n if (slideTypes.includes(type)) {\n return 'slide';\n }\n\n // PDF 类型\n if (type === 'pdf') {\n return 'pdf';\n }\n\n return 'other';\n}\n\n/**\n * 检查文件类型是否受支持\n * @param fileType 文件扩展名\n * @returns 是否支持\n */\nexport function isSupportedFileType(fileType: string): boolean {\n return getDocumentType(fileType) !== 'other';\n}","import axios, { type AxiosRequestConfig, type AxiosResponse } from 'axios';\n\n/**\n * HTTP 请求工具\n */\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string = '') {\n this.baseUrl = baseUrl;\n }\n\n /**\n * 发送 POST 请求\n * @param url 请求地址\n * @param data 请求数据\n * @param config 额外配置\n * @returns Promise\n */\n async post<T = any>(\n url: string,\n data?: any,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.post<T>(fullUrl, data, config);\n }\n\n /**\n * 发送 GET 请求\n * @param url 请求地址\n * @param config 额外配置\n * @returns Promise\n */\n async get<T = any>(\n url: string,\n config?: AxiosRequestConfig\n ): Promise<AxiosResponse<T>> {\n const fullUrl = this.baseUrl ? `${this.baseUrl}${url}` : url;\n return axios.get<T>(fullUrl, config);\n }\n}\n\n/**\n * 验签接口请求\n * @param baseUrl 基础 URL\n * @param data 验签数据\n * @returns 验签结果\n */\nexport async function verifyTokenSign(\n baseUrl: string,\n data: {\n appId: string;\n sign: string;\n timestamp: number;\n }\n): Promise<boolean> {\n try {\n const client = new HttpClient(baseUrl);\n const response = await client.post<{ data: boolean }>(\n '/onlyoffice/token/verifyTokenSign',\n data\n );\n return response.data?.data === true;\n } catch (error) {\n console.error('验签请求失败:', error);\n return false;\n }\n}\n\n/**\n * 保存操作信息\n * @param callbackUrl 回调地址\n * @param data 操作数据\n */\nexport async function saveSuccessInfo(\n callbackUrl: string,\n data: {\n status: number;\n key: string;\n userdata: string;\n }\n): Promise<void> {\n try {\n await axios.post(callbackUrl, data);\n } catch (error) {\n console.error('保存操作信息失败:', error);\n }\n}","import EventEmitter from 'eventemitter3';\nimport type {\n DocumentConfig,\n EditorConfig,\n DocumentPermissions,\n OfficeEventType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeDocumentConfig,\n OfficeInitConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n} from '../types';\nimport { getDocumentType, isSupportedFileType } from './utils/fileType';\nimport { verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n/**\n * 默认文档权限\n */\nconst DEFAULT_PERMISSIONS: DocumentPermissions = {\n comment: false,\n download: false,\n edit: false,\n print: true,\n review: false,\n editCommentAuthorOnly: false,\n fillForms: false,\n modifyContentControl: false,\n};\n\n/**\n * OnlyOffice 编辑器管理类\n */\nexport class OfficeEditor implements OfficeEditorInstance {\n private editor: any = null;\n private editorId: string;\n private emitter: EventEmitter;\n private documentConfig: DocumentConfig;\n private editorConfig: EditorConfig;\n private callback: OfficeCallback | null = null;\n private height: string = '100%';\n private width: string = '100%';\n\n constructor() {\n this.editorId = `editor-${Date.now().toString(32)}`;\n this.emitter = new EventEmitter();\n this.documentConfig = {\n fileType: 'docx',\n key: '',\n url: '',\n title: '',\n permissions: { ...DEFAULT_PERMISSIONS },\n };\n this.editorConfig = {\n lang: 'zh',\n user: { id: '', name: '' },\n };\n }\n\n /**\n * 配置文档参数\n */\n configure(config: OfficeDocumentConfig): void {\n if (config.height) this.height = config.height;\n if (config.width) this.width = config.width;\n\n if (config.fileType) {\n if (!isSupportedFileType(config.fileType)) {\n throw new Error(`不支持的文件类型: ${config.fileType}`);\n }\n const docType = getDocumentType(config.fileType);\n if (docType !== 'other') {\n this.documentConfig.fileType = config.fileType;\n }\n }\n\n if (config.key) this.documentConfig.key = config.key;\n if (config.url) this.documentConfig.url = config.url;\n if (config.title) this.documentConfig.title = config.title;\n\n if (config.permissions) {\n this.documentConfig.permissions = {\n ...this.documentConfig.permissions,\n ...config.permissions,\n };\n\n // PDF 文件特殊处理\n if (this.documentConfig.fileType === 'pdf') {\n this.documentConfig.permissions.edit = false;\n this.documentConfig.permissions.review = false;\n this.editorConfig.mode = 'view';\n }\n }\n\n if (config.callbackUrl) this.editorConfig.callbackUrl = config.callbackUrl;\n if (config.userId) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n id: config.userId,\n };\n }\n if (config.userName) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n name: config.userName,\n };\n }\n if (config.userGroup) {\n this.editorConfig.user = {\n ...this.editorConfig.user,\n group: config.userGroup,\n };\n }\n }\n\n /**\n * 初始化编辑器(带验签)\n */\n async initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const { dom, officeApiUrl, callback, auth, verifyFunction } = config;\n\n if (callback) this.callback = callback;\n\n // 验签逻辑\n if (auth) {\n let verified = false;\n\n if (verifyFunction) {\n // 使用自定义验签函数\n verified = await verifyFunction(auth);\n } else if (auth.verifyUrl) {\n // 使用自定义验签地址\n verified = await verifyTokenSign(auth.verifyUrl, {\n appId: auth.appId,\n sign: auth.sign,\n timestamp: auth.timestamp,\n });\n } else {\n throw new Error('使用验签配置时,必须提供 verifyFunction 或 verifyUrl');\n }\n\n if (!verified) {\n throw new Error('验签失败,请检查验签配置');\n }\n }\n\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 简化初始化(无验签)\n */\n init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n ): OfficeEditorInstance {\n if (callback) this.callback = callback;\n return this.createEditor(dom, officeApiUrl);\n }\n\n /**\n * 创建编辑器实例\n */\n private createEditor(dom: HTMLElement, officeApiUrl: string): OfficeEditorInstance {\n console.log('[OnlyOffice] createEditor called', { dom, officeApiUrl });\n\n if (!dom) {\n throw new Error('必须提供挂载的 DOM 元素');\n }\n\n if (!officeApiUrl) {\n throw new Error('必须提供 OnlyOffice API 脚本地址');\n }\n\n // 设置容器样式\n dom.style.position = 'relative';\n console.log('[OnlyOffice] DOM dimensions:', { width: dom.offsetWidth, height: dom.offsetHeight });\n\n // 创建编辑器容器\n const mainDiv = document.createElement('div');\n mainDiv.id = this.editorId;\n mainDiv.style.height = '100%';\n mainDiv.style.width = '100%';\n dom.appendChild(mainDiv);\n\n // 动态加载 OnlyOffice API 脚本\n const scriptId = `script-${this.editorId}`;\n const existingScript = document.querySelector(`#${scriptId}`);\n\n if (!existingScript) {\n console.log('[OnlyOffice] Loading script:', officeApiUrl);\n const script = document.createElement('script');\n script.id = scriptId;\n script.src = officeApiUrl;\n script.onload = () => {\n console.log('[OnlyOffice] Script loaded successfully');\n console.log('[OnlyOffice] window.DocsAPI:', window.DocsAPI);\n this.instantiateEditor();\n };\n script.onerror = (err) => {\n console.error('[OnlyOffice] Script load failed:', err);\n };\n document.head.appendChild(script);\n } else {\n console.log('[OnlyOffice] Script already loaded');\n this.instantiateEditor();\n }\n\n return this;\n }\n\n /**\n * 实例化编辑器\n */\n private instantiateEditor(): void {\n console.log('[OnlyOffice] instantiateEditor called');\n\n // 销毁现有实例\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n\n // 检查 DocsAPI 是否可用\n if (!window.DocsAPI || !window.DocsAPI.DocEditor) {\n console.error('[OnlyOffice] window.DocsAPI.DocEditor is not available');\n return;\n }\n\n // 构建配置对象\n const config = {\n width: this.width,\n height: this.height,\n documentType: this.getDocumentType(),\n document: this.documentConfig,\n editorConfig: this.editorConfig,\n events: this.createEventHandlers(),\n };\n\n console.log('[OnlyOffice] Creating editor with config:', config);\n console.log('[OnlyOffice] Editor container ID:', this.editorId);\n console.log('[OnlyOffice] Container element:', document.getElementById(this.editorId));\n\n // 创建编辑器实例\n try {\n this.editor = new window.DocsAPI.DocEditor(this.editorId, config);\n console.log('[OnlyOffice] Editor created successfully:', this.editor);\n } catch (err) {\n console.error('[OnlyOffice] Error creating editor:', err);\n }\n }\n\n /**\n * 获取文档类型\n */\n private getDocumentType(): string {\n const type = getDocumentType(this.documentConfig.fileType);\n return type === 'other' ? 'word' : type;\n }\n\n /**\n * 创建事件处理器\n */\n private createEventHandlers(): Record<string, (event: any) => void> {\n return {\n onDocumentStateChange: (event: any) => {\n this.emitter.emit('documentStateChange', event);\n },\n onDocumentReady: () => {\n console.log('Document is loaded');\n // 通知后端文档加载成功\n if (this.editorConfig.callbackUrl) {\n saveSuccessInfo(this.editorConfig.callbackUrl, {\n status: 8,\n key: this.documentConfig.key,\n userdata: JSON.stringify({\n appUserId: this.editorConfig.user?.id,\n }),\n });\n }\n this.callback?.('onDocumentReady');\n this.emitter.emit('onDocumentReady');\n },\n onInfo: (event: any) => {\n console.log('ONLYOFFICE Document Editor is opened in mode', event.data.mode);\n this.callback?.('onInfo', event.data);\n this.emitter.emit('onInfo', event);\n },\n onError: (event: any) => {\n console.error('ONLYOFFICE Error:', event.data.errorCode, event.data.errorDescription);\n this.emitter.emit('onError', event);\n },\n onRequestHistory: (event: any) => {\n this.callback?.('onRequestHistory', event, this.editor);\n this.emitter.emit('onRequestHistory', { event, editor: this.editor });\n },\n onRequestHistoryData: (event: any) => {\n this.callback?.('onRequestHistoryData', event, this.editor);\n this.emitter.emit('onRequestHistoryData', { event, editor: this.editor });\n },\n onRequestHistoryClose: (event: any) => {\n this.callback?.('onRequestHistoryClose', event, this.editor);\n this.emitter.emit('onRequestHistoryClose', { event, editor: this.editor });\n },\n onRequestRestore: (event: any) => {\n this.callback?.('onRequestRestore', event, this.editor);\n this.emitter.emit('onRequestRestore', { event, editor: this.editor });\n },\n onRequestSendNotify: (event: any) => {\n console.log('onRequestSendNotify', event);\n this.emitter.emit('onRequestSendNotify', event);\n },\n onRequestUsers: (event: any) => {\n console.log('onRequestUsers', event);\n this.emitter.emit('onRequestUsers', event);\n },\n };\n }\n\n /**\n * 监听事件\n */\n on(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.on(event, callback);\n }\n\n /**\n * 移除事件监听\n */\n off(event: OfficeEventType, callback: (...args: any[]) => void): void {\n this.emitter.off(event, callback);\n }\n\n /**\n * 获取当前配置\n */\n getConfig(): DocumentConfig & EditorConfig {\n return {\n ...this.documentConfig,\n ...this.editorConfig,\n };\n }\n\n /**\n * 获取内部编辑器实例\n */\n getEditor(): any {\n return this.editor;\n }\n\n /**\n * 销毁编辑器\n */\n destroy(): void {\n if (this.editor) {\n this.editor.destroyEditor();\n this.editor = null;\n }\n this.emitter.removeAllListeners();\n this.callback = null;\n }\n}","import { ref, onMounted, onBeforeUnmount, watch, type Ref } from 'vue';\nimport { OfficeEditor } from '../core/editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * useOnlyOffice 配置选项\n */\nexport interface UseOnlyOfficeOptions {\n /** OnlyOffice API 脚本地址 */\n officeApiUrl: string;\n /** 文档配置 */\n document: OfficeDocumentConfig;\n /** 验签配置 */\n auth?: AuthConfig;\n /** 自定义验签函数 */\n verifyFunction?: VerifyTokenSignFunction;\n /** 编辑器高度 */\n height?: string;\n /** 编辑器宽度 */\n width?: string;\n /** 是否自动初始化 */\n autoInit?: boolean;\n}\n\n/**\n * useOnlyOffice 返回值\n */\nexport interface UseOnlyOfficeReturn {\n /** 容器元素引用 */\n containerRef: Ref<HTMLElement | null>;\n /** 编辑器实例 */\n editorInstance: Ref<OfficeEditorInstance | null>;\n /** 是否已就绪 */\n isReady: Ref<boolean>;\n /** 错误信息 */\n error: Ref<string | null>;\n /** 初始化编辑器 */\n init: () => Promise<void>;\n /** 销毁编辑器 */\n destroy: () => void;\n /** 重新初始化 */\n reinit: () => Promise<void>;\n /** 监听事件 */\n on: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n /** 移除事件监听 */\n off: (event: OfficeEventType, callback: (...args: any[]) => void) => void;\n}\n\n/**\n * OnlyOffice Vue 3 组合式函数\n * @param options 配置选项\n * @returns 编辑器状态和方法\n */\nexport function useOnlyOffice(options: UseOnlyOfficeOptions): UseOnlyOfficeReturn {\n const {\n officeApiUrl,\n document: documentConfig,\n auth,\n verifyFunction,\n height = '100%',\n width = '100%',\n autoInit = true,\n } = options;\n\n const containerRef: Ref<HTMLElement | null> = ref(null);\n const editorInstance: Ref<OfficeEditorInstance | null> = ref(null);\n const isReady: Ref<boolean> = ref(false);\n const error: Ref<string | null> = ref(null);\n\n let editor: OfficeEditor | null = null;\n\n /**\n * 初始化编辑器\n */\n const init = async () => {\n if (!containerRef.value) {\n error.value = '容器元素未找到';\n return;\n }\n\n try {\n // 销毁现有实例\n destroy();\n\n editor = new OfficeEditor();\n\n // 配置文档参数\n editor.configure({\n ...documentConfig,\n height,\n width,\n });\n\n // 事件回调\n const callback: OfficeCallback = (type, _event, _editorInst) => {\n switch (type) {\n case 'onDocumentReady':\n isReady.value = true;\n break;\n case 'onInfo':\n break;\n }\n };\n\n // 初始化配置\n const initConfig: OfficeInitConfig = {\n dom: containerRef.value,\n officeApiUrl,\n callback,\n auth,\n verifyFunction,\n };\n\n // 初始化编辑器\n editorInstance.value = await editor.initOffice(initConfig);\n\n // 监听错误事件\n editor.on('onError' as OfficeEventType, (event: any) => {\n error.value = event.data?.errorDescription || '编辑器错误';\n });\n } catch (err: any) {\n error.value = err.message || '初始化失败';\n }\n };\n\n /**\n * 销毁编辑器\n */\n const destroy = () => {\n if (editor) {\n editor.destroy();\n editor = null;\n editorInstance.value = null;\n isReady.value = false;\n }\n };\n\n /**\n * 重新初始化\n */\n const reinit = async () => {\n destroy();\n await init();\n };\n\n /**\n * 监听事件\n */\n const on = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.on(event, callback);\n }\n };\n\n /**\n * 移除事件监听\n */\n const off = (event: OfficeEventType, callback: (...args: any[]) => void) => {\n if (editor) {\n editor.off(event, callback);\n }\n };\n\n // 监听文档配置变化\n watch(\n () => documentConfig,\n async (newDoc: any) => {\n if (editor && newDoc) {\n await reinit();\n }\n },\n { deep: true }\n );\n\n // 组件挂载时初始化\n onMounted(() => {\n if (autoInit) {\n init();\n }\n });\n\n // 组件销毁前清理\n onBeforeUnmount(() => {\n destroy();\n });\n\n return {\n containerRef,\n editorInstance,\n isReady,\n error,\n init,\n destroy,\n reinit,\n on,\n off,\n };\n}\n\nexport default useOnlyOffice;","export { OfficeEditor } from './editor';\nexport { getDocumentType, isSupportedFileType } from './utils/fileType';\nexport { HttpClient, verifyTokenSign, saveSuccessInfo } from './utils/http';\n\n// 导出类型\nexport type {\n DocumentType,\n FileType,\n DocumentPermissions,\n UserInfo,\n DocumentConfig,\n EditorConfig,\n AuthConfig,\n VerifyTokenSignFunction,\n OfficeInitConfig,\n OfficeDocumentConfig,\n OfficeEventType,\n OfficeCallbackType,\n OfficeCallback,\n OfficeEditorInstance,\n OfficeSDK,\n} from '../types';\n\nimport { OfficeEditor } from './editor';\nimport type {\n OfficeDocumentConfig,\n OfficeInitConfig,\n OfficeCallback,\n OfficeEventType,\n OfficeEditorInstance,\n} from '../types';\n\n/**\n * 创建 Office 编辑器实例\n * @returns OfficeEditor 实例\n */\nexport function createOfficeEditor(): OfficeEditor {\n return new OfficeEditor();\n}\n\n/**\n * 快速初始化 Office 编辑器\n * @param config 初始化配置\n * @returns Promise<OfficeEditorInstance>\n */\nexport async function initOffice(config: OfficeInitConfig): Promise<OfficeEditorInstance> {\n const editor = new OfficeEditor();\n return editor.initOffice(config);\n}\n\n/**\n * 简化初始化(无验签)\n * @param dom 挂载的 DOM 元素\n * @param officeApiUrl OnlyOffice API 地址\n * @param callback 事件回调\n * @returns OfficeEditorInstance\n */\nexport function init(\n dom: HTMLElement,\n officeApiUrl: string,\n callback?: OfficeCallback\n): OfficeEditorInstance {\n const editor = new OfficeEditor();\n return editor.init(dom, officeApiUrl, callback);\n}\n\n/**\n * 配置文档参数(全局配置,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.configure() 方法\n */\nexport function config(_config: OfficeDocumentConfig): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.configure() 方法');\n}\n\n/**\n * 销毁编辑器(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.destroy() 方法\n */\nexport function destroy(): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.destroy() 方法');\n}\n\n/**\n * 监听事件(全局方法,需要先创建编辑器实例)\n * @deprecated 建议使用 OfficeEditor.on() 方法\n */\nexport function on(_event: OfficeEventType, _callback: (...args: any[]) => void): void {\n console.warn('此方法已废弃,请使用 OfficeEditor.on() 方法');\n}\n\n/**\n * 记录分享动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function shareSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 10,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}\n\n/**\n * 记录下载动作\n * @param callbackUrl 回调地址\n * @param fileKey 文件标识\n * @param appUserId 用户 ID\n */\nexport async function downloadSave(\n callbackUrl: string,\n fileKey: string,\n appUserId: string\n): Promise<void> {\n const { saveSuccessInfo } = await import('./utils/http');\n await saveSuccessInfo(callbackUrl, {\n status: 9,\n key: fileKey,\n userdata: JSON.stringify({ appUserId }),\n });\n}"],"names":["OnlyOfficeEditor","defineComponent","name","props","officeApiUrl","type","String","required","document","Object","auth","default","undefined","verifyFunction","Function","skipVerification","Boolean","height","width","emits","setup","emit","editorId","Date","now","toString","isReady","ref","error","editor","initEditor","async","console","log","Promise","resolve","reject","window","DocsAPI","DocEditor","scriptId","getElementById","checkLoaded","setTimeout","script","createElement","id","src","onload","onerror","err","Error","head","appendChild","dom","value","key","url","title","fileType","config","documentType","getDocumentType","permissions","edit","download","review","editorConfig","lang","mode","callbackUrl","user","userId","userName","events","onDocumentReady","onDocumentStateChange","event","onError","_a","data","errorDescription","onRequestHistory","onRequestHistoryData","onRequestHistoryClose","onRequestRestore","message","doc","docx","odt","rtf","txt","html","epub","xls","xlsx","ods","csv","ppt","pptx","odp","pdf","onMounted","onBeforeUnmount","destroyEditor","e","warn","render","h","class","style","this","position","minHeight","top","left","transform","color","zIndex","toLowerCase","includes","HttpClient","constructor","baseUrl","post","fullUrl","axios","get","verifyTokenSign","client","saveSuccessInfo","DEFAULT_PERMISSIONS","comment","print","editCommentAuthorOnly","fillForms","modifyContentControl","OfficeEditor","callback","emitter","EventEmitter","documentConfig","configure","userGroup","group","initOffice","verified","verifyUrl","appId","sign","timestamp","createEditor","init","offsetWidth","offsetHeight","mainDiv","querySelector","instantiateEditor","createEventHandlers","status","userdata","JSON","stringify","appUserId","_b","call","onInfo","errorCode","onRequestSendNotify","onRequestUsers","on","off","getConfig","getEditor","destroy","removeAllListeners","useOnlyOffice","options","autoInit","containerRef","editorInstance","_event","_editorInst","initConfig","reinit","watch","newDoc","deep","createOfficeEditor","shareSave","fileKey","then","http","downloadSave"],"mappings":"uJAkBO,MAAMA,EAAmBC,EAAgB,CAC9CC,KAAM,mBAENC,MAAO,CAELC,aAAc,CACZC,KAAMC,OACNC,UAAU,GAGZC,SAAU,CACRH,KAAMI,OACNF,UAAU,GAGZG,KAAM,CACJL,KAAMI,OACNE,aAASC,GAGXC,eAAgB,CACdR,KAAMS,SACNH,aAASC,GAGXG,iBAAkB,CAChBV,KAAMW,QACNL,SAAS,GAGXM,OAAQ,CACNZ,KAAMC,OACNK,QAAS,QAGXO,MAAO,CACLb,KAAMC,OACNK,QAAS,SAIbQ,MAAO,CACL,QACA,QACA,sBACA,iBACA,qBACA,sBACA,kBAGF,KAAAC,CAAMjB,GAAYkB,KAAEA,IAClB,MAAMC,EAAW,cAAcC,KAAKC,MAAMC,SAAS,MAC7CC,EAAwBC,GAAI,GAC5BC,EAA4BD,EAAI,MACtC,IAAIE,EAAc,KAKlB,MA8CMC,EAAaC,UACjBC,QAAQC,IAAI,4CAEZ,UAhDO,IAAIC,QAAQ,CAACC,EAASC,KAE3B,GAAIC,OAAOC,SAAWD,OAAOC,QAAQC,UAGnC,OAF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Z,YAAY;;;;;;;;;;IA9BZ,0BAA0B;;;;;IAK1B,WAAW;;cAEO,QAAQ,CAAC,oBAAoB,CAAC;;;IAGhD,WAAW;;cAEO,QAAQ,CAAC,UAAU,CAAC;;;IAGtC,cAAc;;cAEM,QAAQ,CAAC,uBAAuB,CAAC;;;IAGrD,gCAAgC;;;;;IAKhC,YAAY;;;;;IAKZ,YAAY;;;;;;;;;;;;;;;;;;;4EAmNd,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../../src/vue3/component.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,QAAQ,EACb,KAAK,GAAG,EACT,MAAM,KAAK,CAAC;AACb,OAAO,KAAK,EACV,oBAAoB,EACpB,UAAU,EACV,uBAAuB,EACxB,MAAM,UAAU,CAAC;AAElB;;GAEG;AACH,eAAO,MAAM,gBAAgB;IAIzB,0BAA0B;;;;;IAK1B,WAAW;;cAEO,QAAQ,CAAC,oBAAoB,CAAC;;;IAGhD,WAAW;;cAEO,QAAQ,CAAC,UAAU,CAAC;;;IAGtC,cAAc;;cAEM,QAAQ,CAAC,uBAAuB,CAAC;;;IAGrD,gCAAgC;;;;;IAKhC,YAAY;;;;;IAKZ,YAAY;;;;;;;;;;IA9BZ,0BAA0B;;;;;IAK1B,WAAW;;cAEO,QAAQ,CAAC,oBAAoB,CAAC;;;IAGhD,WAAW;;cAEO,QAAQ,CAAC,UAAU,CAAC;;;IAGtC,cAAc;;cAEM,QAAQ,CAAC,uBAAuB,CAAC;;;IAGrD,gCAAgC;;;;;IAKhC,YAAY;;;;;IAKZ,YAAY;;;;;;;;;;;;;;;;;;;4EA6Pd,CAAC;AAEH,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chao194/office",
3
- "version": "1.0.9",
3
+ "version": "1.1.0",
4
4
  "description": "即插即用的 OnlyOffice 前端集成方案,支持 Vue、React 和原生 JavaScript",
5
5
  "type": "module",
6
6
  "main": "./dist/cjs/index.cjs",