spire.officejs-vue-test 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,162 @@
1
+ # spire.officejs-vue
2
+
3
+ 一个可以打开`spire-officejs`产品的vue3组件
4
+
5
+ # 安装
6
+
7
+ ```bash
8
+ npm install spire.officejs-vue
9
+ ```
10
+
11
+ # 使用方式
12
+
13
+ ```js
14
+ // main.ts
15
+ import { createApp } from 'vue'
16
+ import App from './App.vue'
17
+ import officejs-editor from 'spire.officejs-vue'
18
+
19
+ const app = createApp(App)
20
+
21
+ app.use(officejs-editor)
22
+ app.mount('#app')
23
+ ```
24
+
25
+ ```vue
26
+ // *.vue
27
+ <template>
28
+ <div>
29
+ <spire-officejs-Editor :config="config" :serverUrl="serverUrl"></spire-officejs-Editor>
30
+ </div>
31
+ </template>
32
+ <script setup>
33
+ import { ref, onMounted, onBeforeMount } from "vue";
34
+
35
+ let serverUrl;
36
+ let originUrl;
37
+ let config;
38
+ const file = file; // 此处需要替换为真实的File数据, 通过用户手动选择的文件
39
+ const fileUint8Data = fileUint8Data; // 此处需要替换为真实的File的Uint8Array数据
40
+ const editorTypes = {
41
+ document: "document",
42
+ pdf: "pdf",
43
+ spreadsheet: "spreadsheet",
44
+ presentation: "presentation"
45
+ };
46
+ const exts_document = ["docx", "docm", "doc", "dotx", "dotm", "dot", "odt", "fodt", "ott", "txt", "wps", "wpt"];
47
+ const exts_spreadsheet = ["xlsx", "csv", "xlsm", "xls", "xltx", "xltm", "xlt", "et", "ett"];
48
+ const exts_presentation = ["pptx", "pptm", "ppt", "ppsx", "ppsm", "pps", "potx", "potm", "dps", "dpt"];
49
+ const exts_pdf = ["pdf", "xps"];
50
+
51
+ onBeforeMount(() => {
52
+ initConfig();
53
+ })
54
+
55
+ function initConfig() {
56
+ var tempUrl = new URL(import.meta.url);
57
+ var editorType = '';
58
+ var ext = getFileExtension();
59
+ if (import.meta.env.DEV) {
60
+ serverUrl = `http://127.0.0.1:3001`;
61
+ originUrl = `http://127.0.0.1:3001`;
62
+ } else if (import.meta.env.PROD) {
63
+ serverUrl = `${tempUrl.origin}/spireOfficejs`;
64
+ originUrl = `${tempUrl.origin}/spireOfficejs`;
65
+ }
66
+
67
+ if(exts_document.includes(ext))
68
+ editorType = editorTypes.document;
69
+ else if(exts_spreadsheet.includes(ext))
70
+ editorType = editorTypes.spreadsheet;
71
+ else if(exts_presentation.includes(ext))
72
+ editorType = editorTypes.presentation;
73
+ else if(exts_pdf.includes(ext))
74
+ editorType = editorTypes.pdf;
75
+
76
+ config = {
77
+ fileAttrs: {
78
+ fileInfo: {
79
+ name: file.name,
80
+ ext: ext,
81
+ primary: String(new Date().getTime()),
82
+ creator: "Jonn",
83
+ createTime: "2022-04-18 11:30:43"
84
+ },
85
+ sourceUrl: originUrl + "/files/__ffff_192.168.2.134/" + file.name,
86
+ createUrl: originUrl + "/open",
87
+ mergeFolderUrl: "",
88
+ fileChoiceUrl: "",
89
+ templates: {}
90
+ },
91
+ user: {
92
+ id: "uid-1",
93
+ name: "Jonn",
94
+ canSave: true
95
+ },
96
+ editorAttrs: {
97
+ editorMode: file.name.endsWith(".pdf") ? "view" : "edit",
98
+ editorWidth: "100%",
99
+ editorHeight: "100%",
100
+ editorType: editorType,
101
+ platform: "desktop",
102
+ viewLanguage: "zh",
103
+ isReadOnly: false,
104
+ canChat: true,
105
+ canComment: true,
106
+ canReview: true,
107
+ canDownload: true,
108
+ canEdit: file.name.endsWith(".pdf") ? false : true,
109
+ canForcesave: true,
110
+ embedded: {
111
+ saveUrl: "",
112
+ embedUrl: "",
113
+ shareUrl: "",
114
+ toolbarDocked: "top"
115
+ },
116
+ useWebAssemblyDoc: true,
117
+ useWebAssemblyExcel: true,
118
+ useWebAssemblyPpt: true,
119
+ useWebAssemblyPdf: true,
120
+ spireDocJsLicense: "",
121
+ spireXlsJsLicense: "",
122
+ spirePresentationJsLicense: "",
123
+ spirePdfJsLicense: "",
124
+ serverless: {
125
+ useServerless: true,
126
+ baseUrl: originUrl,
127
+ fileData: fileUint8Data
128
+ },
129
+ events: {
130
+ onSave: onFileSave
131
+ },
132
+ plugins: {
133
+ pluginsData: []
134
+ }
135
+ }
136
+ };
137
+ }
138
+
139
+ function getFileExtension() {
140
+ const filename = file.name.split(/[\\/]/).pop();
141
+ return filename.substring(filename.lastIndexOf(".") + 1).toLowerCase() || "";
142
+ }
143
+
144
+ function onFileSave(data) {
145
+ // 自定义保存逻辑
146
+ console.log("save data", data);
147
+ }
148
+ <script>
149
+ ```
150
+
151
+ # 参数
152
+ | 属性 | 说明 | 类型 | 默认 |
153
+ | --------- | ------------ | -------- | ------------------------ |
154
+ | id | editor容器id | `string` | `'SpireofficejsEditor'` |
155
+ | config | 配置参数 | `object` | —— |
156
+ | serverUrl | 服务地址 | `string` | `'http://127.0.0.1:3001` |
157
+
158
+ # ⚠️ 注意事项
159
+ 该vue组件需要搭配spire.officejs插件使用
160
+ | 构建工具 | 插件名称 | 对应地址 |
161
+ | -------- | -------------------------- | ----------------------------------------------------------------------- |
162
+ | vite | vite-plugin-spire.officejs | [跳转](https://www.npmjs.com/package/vite-plugin-spire.officejs) |
package/es/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./src/index";
2
+ import type { App } from "vue";
3
+ declare const _default: {
4
+ install: (app: App) => void;
5
+ };
6
+ export default _default;
package/es/index.mjs ADDED
@@ -0,0 +1,13 @@
1
+ import * as t from "./src/index.mjs";
2
+ import { SpireEditor as s } from "./src/officeJs-editor/index.mjs";
3
+ const i = {
4
+ install: (r) => {
5
+ Object.entries(t).forEach(([o, e]) => {
6
+ r.component(e.name, e);
7
+ });
8
+ }
9
+ };
10
+ export {
11
+ s as SpireEditor,
12
+ i as default
13
+ };
@@ -0,0 +1,8 @@
1
+ import * as components from "./index";
2
+ declare module "@vue/runtime-core" {
3
+ export interface GlobalComponents {
4
+ EaButton: typeof components.Button;
5
+ EaIcon: typeof components.Icon;
6
+ }
7
+ }
8
+ export { };
@@ -0,0 +1 @@
1
+ export * from './officeJs-editor';
@@ -0,0 +1,4 @@
1
+ import { SpireEditor as e } from "./officeJs-editor/index.mjs";
2
+ export {
3
+ e as SpireEditor
4
+ };
@@ -0,0 +1,9 @@
1
+ import e from "./officeJs-editor.vue.mjs";
2
+ const r = (t) => (t.install = (n) => {
3
+ const a = t.name;
4
+ n.component(a, t);
5
+ }, t), i = r(e);
6
+ export {
7
+ i as SpireEditor,
8
+ i as default
9
+ };
@@ -0,0 +1,61 @@
1
+ import { defineComponent as g, onMounted as m, openBlock as h, createElementBlock as E, createElementVNode as v } from "vue";
2
+ import "./style/index.css";
3
+ import r from "spireofficejs-editors";
4
+ const w = { class: "spire-officejs-EditorWarpper" }, S = ["id"], A = /* @__PURE__ */ g({
5
+ name: "spire-officejs-Editor",
6
+ __name: "officeJs-editor",
7
+ props: {
8
+ id: {
9
+ type: String,
10
+ default: "SpireofficejsEditor"
11
+ },
12
+ config: {
13
+ type: Object,
14
+ required: !0
15
+ },
16
+ serverUrl: {
17
+ type: String,
18
+ default: "http://127.0.0.1:3001"
19
+ }
20
+ },
21
+ setup(n) {
22
+ let o, t, s;
23
+ const i = n;
24
+ m(() => {
25
+ l();
26
+ });
27
+ function l() {
28
+ i.config && i.config.editorAttrs ? (f(), a(), d()) : setTimeout(() => {
29
+ l();
30
+ }, 100);
31
+ }
32
+ function c() {
33
+ if (r && r.OpenApi) {
34
+ const e = r.OpenApi;
35
+ o = new e(i.id, s), window.Api = o.GetOpenApi(), u();
36
+ }
37
+ }
38
+ function d() {
39
+ var e = document.createElement("script"), p = `${t}/editors/spireapi/SpireCloudEditor.js`;
40
+ e.setAttribute("src", p), e.onload = () => c(), document.body.appendChild(e);
41
+ }
42
+ function f() {
43
+ s = i.config;
44
+ }
45
+ function a() {
46
+ i.serverUrl ? i.serverUrl.endsWith("/") ? t = i.serverUrl.substring(0, i.serverUrl.length - 1) : t = i.serverUrl : t = window.location.origin;
47
+ }
48
+ function u() {
49
+ let e = document.getElementsByClassName(
50
+ "spire-officejs-EditorWarpper"
51
+ );
52
+ e.length && (e[0] && (e[0].style.height = screen.availHeight + "px"), window.scrollTo(0, -1), e[0] && (e[0].style.height = window.innerHeight + "px"));
53
+ }
54
+ return (e, p) => (h(), E("div", w, [
55
+ v("div", { id: n.id }, null, 8, S)
56
+ ]));
57
+ }
58
+ });
59
+ export {
60
+ A as default
61
+ };
@@ -0,0 +1,4 @@
1
+ import f from "./officeJs-editor.vue.mjs";
2
+ export {
3
+ f as default
4
+ };
@@ -0,0 +1,5 @@
1
+ .spire-officejs-EditorWarpper,
2
+ iframe {
3
+ min-height: 100%;
4
+ min-width: 100%;
5
+ }
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./src/index";
2
+ import type { App } from "vue";
3
+ declare const _default: {
4
+ install: (app: App) => void;
5
+ };
6
+ export default _default;
package/lib/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("./src/index.js"),r=require("./src/officeJs-editor/index.js"),n={install:t=>{Object.entries(i).forEach(([o,e])=>{t.component(e.name,e)})}};exports.SpireEditor=r.SpireEditor;exports.default=n;
@@ -0,0 +1,8 @@
1
+ import * as components from "./index";
2
+ declare module "@vue/runtime-core" {
3
+ export interface GlobalComponents {
4
+ EaButton: typeof components.Button;
5
+ EaIcon: typeof components.Icon;
6
+ }
7
+ }
8
+ export { };
@@ -0,0 +1 @@
1
+ export * from './officeJs-editor';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./officeJs-editor/index.js");exports.SpireEditor=e.SpireEditor;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const n=require("./officeJs-editor.vue.js"),u=e=>(e.install=r=>{const i=e.name;r.component(i,e)},e),t=u(n.default);exports.SpireEditor=t;exports.default=t;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue");require("./style/index.css");const n=require("spireofficejs-editors"),v={class:"spire-officejs-EditorWarpper"},h=["id"],m=t.defineComponent({name:"spire-officejs-Editor",__name:"officeJs-editor",props:{id:{type:String,default:"SpireofficejsEditor"},config:{type:Object,required:!0},serverUrl:{type:String,default:"http://127.0.0.1:3001"}},setup(o){let s,r,l;const i=o;t.onMounted(()=>{c()});function c(){i.config&&i.config.editorAttrs?(u(),a(),f()):setTimeout(()=>{c()},100)}function p(){if(n&&n.OpenApi){const e=n.OpenApi;s=new e(i.id,l),window.Api=s.GetOpenApi(),g()}}function f(){var e=document.createElement("script"),d=`${r}/editors/spireapi/SpireCloudEditor.js`;e.setAttribute("src",d),e.onload=()=>p(),document.body.appendChild(e)}function u(){l=i.config}function a(){i.serverUrl?i.serverUrl.endsWith("/")?r=i.serverUrl.substring(0,i.serverUrl.length-1):r=i.serverUrl:r=window.location.origin}function g(){let e=document.getElementsByClassName("spire-officejs-EditorWarpper");e.length&&(e[0]&&(e[0].style.height=screen.availHeight+"px"),window.scrollTo(0,-1),e[0]&&(e[0].style.height=window.innerHeight+"px"))}return(e,d)=>(t.openBlock(),t.createElementBlock("div",v,[t.createElementVNode("div",{id:o.id},null,8,h)]))}});exports.default=m;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./officeJs-editor.vue.js");exports.default=e.default;
@@ -0,0 +1,5 @@
1
+ .spire-officejs-EditorWarpper,
2
+ iframe {
3
+ min-height: 100%;
4
+ min-width: 100%;
5
+ }
package/package.json ADDED
@@ -0,0 +1,34 @@
1
+ {
2
+ "name": "spire.officejs-vue-test",
3
+ "version": "1.0.1",
4
+ "main": "lib/index.js",
5
+ "module": "es/index.mjs",
6
+ "scripts": {
7
+ "release": "release-it"
8
+ },
9
+ "files": [
10
+ "es",
11
+ "lib"
12
+ ],
13
+ "keywords": [
14
+ "spire.officejs",
15
+ "vue3"
16
+ ],
17
+ "sideEffects": [
18
+ "**/*.css"
19
+ ],
20
+ "dependencies": {
21
+ "spire.officejs-editors": "*",
22
+ "spire.officejs-externs": "*",
23
+ "spire.officejs-fonts": "*",
24
+ "spire.officejs-document": "*",
25
+ "spire.officejs-pdf": "*",
26
+ "spire.officejs-presentation": "*",
27
+ "spire.officejs-common": "*",
28
+ "spire.officejs-spreadsheet": "*"
29
+ },
30
+ "author": "e-iceblue",
31
+ "license": "MIT",
32
+ "description": "",
33
+ "typings": "lib/index.d.ts"
34
+ }