spire.officejs-vue 10.11.4

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,163 @@
1
+ # spire.officejs-vue
2
+
3
+ A Vue package is one of the plugins that use to operate the `spire-officejs` product
4
+
5
+ # Installation
6
+
7
+ ```bash
8
+ npm install spire.officejs-vue
9
+ ```
10
+
11
+ # The instructions for the usage:
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; //Should be replaced with actual file data, selected manually by the user
39
+ const fileUint8Data = fileUint8Data; //Should be replaced with the actual Uint8Array data from the file
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:7000`;
61
+ originUrl = `http://127.0.0.1:7000`;
62
+ } else if (import.meta.env.PROD) {
63
+ serverUrl = `${tempUrl.origin}/spire.officejs`;
64
+ originUrl = `${tempUrl.origin}/spire.officejs`;
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
+ //Custom Save Logic
146
+ console.log("save data", data);
147
+ }
148
+ <script>
149
+ ```
150
+
151
+ # Key Parameters
152
+ | Properties| Explanation | Type | Default |
153
+ | --------- | ------------ | -------- | ------------------------ |
154
+ | id | editor dockerid | `string` | `'SpireofficejsEditor'` |
155
+ | config | config Para | `object` | —— |
156
+ | serverUrl | Server URL | `string` | `'http://127.0.0.1:7000` |
157
+
158
+ # ⚠️ Notice
159
+ This Vue component requires the spire.officejs plugin in order to function.
160
+
161
+ | Build Tools | Plugin Name | Corresponding Address |
162
+ | -------- | -------------------------- | ----------------------------------------------------------------------- |
163
+ | vite | vite-plugin-spire.officejs | [Jump to](https://www.npmjs.com/package/vite-plugin-spire.officejs) |
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,50 @@
1
+ import type { Plugin } from "vue";
2
+ type SFCWithInstall<T> = T & Plugin;
3
+ export declare const SpireEditor: SFCWithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ id: {
5
+ type: StringConstructor;
6
+ default: string;
7
+ };
8
+ config: {
9
+ type: ObjectConstructor;
10
+ required: true;
11
+ };
12
+ serverUrl: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ }>, {
17
+ editorType: {
18
+ document: string;
19
+ pdf: string;
20
+ spreadsheet: string;
21
+ presentation: string;
22
+ };
23
+ SpireEditor: any;
24
+ baseUrl: string;
25
+ realConfig: object;
26
+ props: any;
27
+ init: () => void;
28
+ initEditor: () => void;
29
+ loadScript: () => void;
30
+ initConfig: () => void;
31
+ initServerUrl: () => void;
32
+ OnWindowReSize: () => void;
33
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
34
+ id: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ config: {
39
+ type: ObjectConstructor;
40
+ required: true;
41
+ };
42
+ serverUrl: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ }>> & Readonly<{}>, {
47
+ id: string;
48
+ serverUrl: string;
49
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
50
+ export default SpireEditor;
@@ -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,59 @@
1
+ declare global {
2
+ interface Window {
3
+ SpireofficejsEditors?: {
4
+ OpenApi: (id: string, config: any) => void;
5
+ };
6
+ SpireofficeEditor?: {
7
+ OpenApi?: (id: string, config: any) => void;
8
+ };
9
+ Api: any;
10
+ }
11
+ }
12
+ declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
+ id: {
14
+ type: StringConstructor;
15
+ default: string;
16
+ };
17
+ config: {
18
+ type: ObjectConstructor;
19
+ required: true;
20
+ };
21
+ serverUrl: {
22
+ type: StringConstructor;
23
+ default: string;
24
+ };
25
+ }>, {
26
+ editorType: {
27
+ document: string;
28
+ pdf: string;
29
+ spreadsheet: string;
30
+ presentation: string;
31
+ };
32
+ SpireEditor: any;
33
+ baseUrl: string;
34
+ realConfig: object;
35
+ props: any;
36
+ init: () => void;
37
+ initEditor: () => void;
38
+ loadScript: () => void;
39
+ initConfig: () => void;
40
+ initServerUrl: () => void;
41
+ OnWindowReSize: () => void;
42
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
43
+ id: {
44
+ type: StringConstructor;
45
+ default: string;
46
+ };
47
+ config: {
48
+ type: ObjectConstructor;
49
+ required: true;
50
+ };
51
+ serverUrl: {
52
+ type: StringConstructor;
53
+ default: string;
54
+ };
55
+ }>> & Readonly<{}>, {
56
+ id: string;
57
+ serverUrl: string;
58
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
59
+ export default _sfc_main;
@@ -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 "spire.officejs-web-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:7000"
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.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,50 @@
1
+ import type { Plugin } from "vue";
2
+ type SFCWithInstall<T> = T & Plugin;
3
+ export declare const SpireEditor: SFCWithInstall<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
4
+ id: {
5
+ type: StringConstructor;
6
+ default: string;
7
+ };
8
+ config: {
9
+ type: ObjectConstructor;
10
+ required: true;
11
+ };
12
+ serverUrl: {
13
+ type: StringConstructor;
14
+ default: string;
15
+ };
16
+ }>, {
17
+ editorType: {
18
+ document: string;
19
+ pdf: string;
20
+ spreadsheet: string;
21
+ presentation: string;
22
+ };
23
+ SpireEditor: any;
24
+ baseUrl: string;
25
+ realConfig: object;
26
+ props: any;
27
+ init: () => void;
28
+ initEditor: () => void;
29
+ loadScript: () => void;
30
+ initConfig: () => void;
31
+ initServerUrl: () => void;
32
+ OnWindowReSize: () => void;
33
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
34
+ id: {
35
+ type: StringConstructor;
36
+ default: string;
37
+ };
38
+ config: {
39
+ type: ObjectConstructor;
40
+ required: true;
41
+ };
42
+ serverUrl: {
43
+ type: StringConstructor;
44
+ default: string;
45
+ };
46
+ }>> & Readonly<{}>, {
47
+ id: string;
48
+ serverUrl: string;
49
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>>;
50
+ export default 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,59 @@
1
+ declare global {
2
+ interface Window {
3
+ SpireofficejsEditors?: {
4
+ OpenApi: (id: string, config: any) => void;
5
+ };
6
+ SpireofficeEditor?: {
7
+ OpenApi?: (id: string, config: any) => void;
8
+ };
9
+ Api: any;
10
+ }
11
+ }
12
+ declare const _sfc_main: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
13
+ id: {
14
+ type: StringConstructor;
15
+ default: string;
16
+ };
17
+ config: {
18
+ type: ObjectConstructor;
19
+ required: true;
20
+ };
21
+ serverUrl: {
22
+ type: StringConstructor;
23
+ default: string;
24
+ };
25
+ }>, {
26
+ editorType: {
27
+ document: string;
28
+ pdf: string;
29
+ spreadsheet: string;
30
+ presentation: string;
31
+ };
32
+ SpireEditor: any;
33
+ baseUrl: string;
34
+ realConfig: object;
35
+ props: any;
36
+ init: () => void;
37
+ initEditor: () => void;
38
+ loadScript: () => void;
39
+ initConfig: () => void;
40
+ initServerUrl: () => void;
41
+ OnWindowReSize: () => void;
42
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
43
+ id: {
44
+ type: StringConstructor;
45
+ default: string;
46
+ };
47
+ config: {
48
+ type: ObjectConstructor;
49
+ required: true;
50
+ };
51
+ serverUrl: {
52
+ type: StringConstructor;
53
+ default: string;
54
+ };
55
+ }>> & Readonly<{}>, {
56
+ id: string;
57
+ serverUrl: string;
58
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
59
+ export default _sfc_main;
@@ -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("spire.officejs-web-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:7000"}},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,26 @@
1
+ {
2
+ "name": "spire.officejs-vue",
3
+ "version": "10.11.4",
4
+ "main": "lib/index.js",
5
+ "module": "es/index.mjs",
6
+ "files": [
7
+ "es",
8
+ "lib"
9
+ ],
10
+ "keywords": [
11
+ "spire.officejs",
12
+ "vue3",
13
+ "TypeScript"
14
+ ],
15
+ "sideEffects": [
16
+ "**/*.css"
17
+ ],
18
+ "dependencies": {
19
+ "spire.officejs": "^1.0.0",
20
+ "vite-plugin-spire.officejs": "^1.0.0"
21
+ },
22
+ "author": "e-iceblue",
23
+ "license": "MIT",
24
+ "description": "",
25
+ "typings": "lib/index.d.ts"
26
+ }