diff --git a/src/components/Preview_onlyoffice/fun.js b/src/components/Preview_onlyoffice/fun.js new file mode 100644 index 00000000..75a62a67 --- /dev/null +++ b/src/components/Preview_onlyoffice/fun.js @@ -0,0 +1,23 @@ +import Vue from "vue"; +import OnlyOffice from "./index.vue"; + +const PreviewConstructor = Vue.extend(OnlyOffice); + +const onlyOffice = options => { + const { path, type, title } = options; + if (!path) throw `path is requred.but ${path}` + const id = `OnlyOffice_${new Date().getTime()}`; + const instance = new PreviewConstructor(); + instance.id = id; + instance.vm = instance.$mount(); + if (instance.vm.visible) return; + document.body.appendChild(instance.vm.$el); + instance.vm.open(path, type, title); + instance.vm.$on("closed", () => { + instance.vm.docEditor = null + document.body.removeChild(instance.vm.$el); + instance.vm.$destroy(); + }); + return instance.vm; +} +export default onlyOffice; \ No newline at end of file diff --git a/src/components/Preview_onlyoffice/index.js b/src/components/Preview_onlyoffice/index.js new file mode 100644 index 00000000..b549c70f --- /dev/null +++ b/src/components/Preview_onlyoffice/index.js @@ -0,0 +1,7 @@ +import OnlyOffice from "./index.vue"; +import onlyOffice from "./fun"; + +export default Vue => { + Vue.component(OnlyOffice.name, OnlyOffice); + Vue.prototype.$onlyOffice = onlyOffice; +}; \ No newline at end of file diff --git a/src/components/Preview_onlyoffice/index.vue b/src/components/Preview_onlyoffice/index.vue new file mode 100644 index 00000000..ae94ac95 --- /dev/null +++ b/src/components/Preview_onlyoffice/index.vue @@ -0,0 +1,45 @@ +