sur-onlyoffice 1.0.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.
- package/.history/package_20251218095321.json +12 -0
- package/.history/package_20251218095342.json +12 -0
- package/.history/package_20251218100409.json +12 -0
- package/.history/package_20251218100517.json +15 -0
- package/.history/package_20251218100518.json +15 -0
- package/package.json +15 -0
- package/src/components/DocumentEditor.stories.js +151 -0
- package/src/components/DocumentEditor.vue +264 -0
- package/src/components/DocumentsEditor.spec.ts +41 -0
- package/src/index.ts +20 -0
- package/src/model/config.ts +267 -0
- package/src/shims-vue.d.ts +22 -0
- package/src/utils/loadScript.ts +82 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sur-onlyoffice",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "文档",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.esm.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"vue": "^2.6.0 || ^3.0.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sur-onlyoffice",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "文档",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.esm.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"vue": "^2.6.0 || ^3.0.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sur-onlyoffice",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "文档",
|
|
5
|
+
"main": "lib/index.js",
|
|
6
|
+
"module": "lib/index.esm.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
|
+
},
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"vue": "^2.6.0 || ^3.0.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC"
|
|
15
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import DocumentEditor from "./DocumentEditor.vue";
|
|
18
|
+
import config from "../../config/default.json";
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
title: 'DocumentEditor',
|
|
22
|
+
component: DocumentEditor,
|
|
23
|
+
tags: ["autodocs"],
|
|
24
|
+
argTypes: {
|
|
25
|
+
documentType: {
|
|
26
|
+
options: ["word", "cell", "slide", "pdf", "diagram"],
|
|
27
|
+
control: { type: "select" },
|
|
28
|
+
},
|
|
29
|
+
editorConfig_lang: {
|
|
30
|
+
options: [
|
|
31
|
+
"en", "az", "be", "bg", "ca", "zh", "cs", "da", "nl", "fi",
|
|
32
|
+
"fr", "gl", "de", "el", "hu", "id", "it", "ja", "ko", "lv",
|
|
33
|
+
"lo", "nb", "pl", "pt", "ro", "ru", "sk", "sl", "es", "sv",
|
|
34
|
+
"tr", "uk", "vi"
|
|
35
|
+
],
|
|
36
|
+
control: { type: "select" },
|
|
37
|
+
},
|
|
38
|
+
type: {
|
|
39
|
+
options: ["desktop", "mobile"],
|
|
40
|
+
control: { type: "select" },
|
|
41
|
+
},
|
|
42
|
+
events_onAppReady: { action: "onAppReady" },
|
|
43
|
+
events_onDocumentStateChange: { action: "onDocumentStateChange" },
|
|
44
|
+
events_onMetaChange: { action: "onMetaChange" },
|
|
45
|
+
events_onDocumentReady: { action: "onDocumentReady" },
|
|
46
|
+
events_onInfo: { action: "onInfo" },
|
|
47
|
+
events_onWarning: { action: "onWarning" },
|
|
48
|
+
events_onError: { action: "onError" },
|
|
49
|
+
events_onRequestSharingSettings: { action: "onRequestSharingSettings" },
|
|
50
|
+
events_onRequestSendNotify: { action: "onRequestSendNotify" },
|
|
51
|
+
events_onRequestRename: { action: "onRequestRename" },
|
|
52
|
+
events_onMakeActionLink: { action: "onMakeActionLink" },
|
|
53
|
+
events_onRequestInsertImage: { action: "onRequestInsertImage" },
|
|
54
|
+
events_onRequestSaveAs: { action: "onRequestSaveAs" },
|
|
55
|
+
events_onRequestMailMergeRecipients: { action: "onRequestMailMergeRecipients" },
|
|
56
|
+
events_onRequestCompareFile: { action: "onRequestCompareFile" },
|
|
57
|
+
events_onRequestEditRights: { action: "onRequestEditRights" },
|
|
58
|
+
events_onRequestHistory: { action: "onRequestHistory" },
|
|
59
|
+
events_onRequestHistoryClose: { action: "onRequestHistoryClose" },
|
|
60
|
+
events_onRequestHistoryData: { action: "onRequestHistoryData" },
|
|
61
|
+
events_onRequestRestore: { action: "onRequestRestore" }
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const Template = (args) => ({
|
|
66
|
+
components: { DocumentEditor },
|
|
67
|
+
setup() {
|
|
68
|
+
return { args };
|
|
69
|
+
},
|
|
70
|
+
template: '<DocumentEditor v-bind="args" />',
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
export const DocumentTemplate = Template.bind({});
|
|
74
|
+
DocumentTemplate.storyName = "Document";
|
|
75
|
+
DocumentTemplate.args = {
|
|
76
|
+
id: "docxEditor",
|
|
77
|
+
documentServerUrl: config.documentServerUrl,
|
|
78
|
+
config: {
|
|
79
|
+
document: {
|
|
80
|
+
fileType: "docx",
|
|
81
|
+
key: "docx" + Math.random(),
|
|
82
|
+
title: "demo.docx",
|
|
83
|
+
url: config.demoStorage + "demo.docx",
|
|
84
|
+
},
|
|
85
|
+
documentType: "word",
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const SpreadsheetTemplate = Template.bind({});
|
|
90
|
+
SpreadsheetTemplate.storyName = "Spreadsheet";
|
|
91
|
+
SpreadsheetTemplate.args = {
|
|
92
|
+
id: "xlsxEditor",
|
|
93
|
+
documentServerUrl: config.documentServerUrl,
|
|
94
|
+
config: {
|
|
95
|
+
document: {
|
|
96
|
+
fileType: "xlsx",
|
|
97
|
+
key: "xlsx" + Math.random(),
|
|
98
|
+
title: "demo.xlsx",
|
|
99
|
+
url: config.demoStorage + "demo.xlsx",
|
|
100
|
+
},
|
|
101
|
+
documentType: "cell",
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const PresentationTemplate = Template.bind({});
|
|
106
|
+
PresentationTemplate.storyName = "Presentation";
|
|
107
|
+
PresentationTemplate.args = {
|
|
108
|
+
id: "pptxEditor",
|
|
109
|
+
documentServerUrl: config.documentServerUrl,
|
|
110
|
+
config: {
|
|
111
|
+
document: {
|
|
112
|
+
fileType: "pptx",
|
|
113
|
+
key: "pptx" + Math.random(),
|
|
114
|
+
title: "demo.pptx",
|
|
115
|
+
url: config.demoStorage + "demo.pptx",
|
|
116
|
+
},
|
|
117
|
+
documentType: "slide",
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export const FormTemplate = Template.bind({});
|
|
122
|
+
FormTemplate.storyName = "Form";
|
|
123
|
+
FormTemplate.args = {
|
|
124
|
+
id: "pdfEditor",
|
|
125
|
+
documentServerUrl: config.documentServerUrl,
|
|
126
|
+
config: {
|
|
127
|
+
document: {
|
|
128
|
+
fileType: "pdf",
|
|
129
|
+
key: "pdf" + Math.random(),
|
|
130
|
+
title: "oform.pdf",
|
|
131
|
+
url: config.demoStorage + "oform.pdf",
|
|
132
|
+
},
|
|
133
|
+
documentType: "word",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
export const DiagramTemplate = Template.bind({});
|
|
138
|
+
DiagramTemplate.storyName = "Diagram";
|
|
139
|
+
DiagramTemplate.args = {
|
|
140
|
+
id: "diagramEditor",
|
|
141
|
+
documentServerUrl: config.documentServerUrl,
|
|
142
|
+
config: {
|
|
143
|
+
document: {
|
|
144
|
+
fileType: "vsdx",
|
|
145
|
+
key: "vsdx" + Math.random(),
|
|
146
|
+
title: "demo.vsdx",
|
|
147
|
+
url: config.demoStorage + "demo.vsdx",
|
|
148
|
+
},
|
|
149
|
+
documentType: "diagram",
|
|
150
|
+
},
|
|
151
|
+
};
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<div :id="id"></div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts">
|
|
22
|
+
import { defineComponent, PropType } from 'vue';
|
|
23
|
+
import loadScript from "../utils/loadScript";
|
|
24
|
+
import { IConfig } from "../model/config";
|
|
25
|
+
import cloneDeep from "lodash/cloneDeep";
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
interface Window {
|
|
29
|
+
DocsAPI?: any;
|
|
30
|
+
DocEditor?: any;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default defineComponent({
|
|
35
|
+
name: 'DocumentEditor',
|
|
36
|
+
props: {
|
|
37
|
+
id: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
documentServerUrl: {
|
|
42
|
+
type: String,
|
|
43
|
+
required: true
|
|
44
|
+
},
|
|
45
|
+
shardkey: {
|
|
46
|
+
type: [String, Boolean],
|
|
47
|
+
default: true
|
|
48
|
+
},
|
|
49
|
+
config: {
|
|
50
|
+
type: Object as PropType<IConfig>,
|
|
51
|
+
required: true
|
|
52
|
+
},
|
|
53
|
+
document_fileType: String,
|
|
54
|
+
document_title: String,
|
|
55
|
+
documentType: String,
|
|
56
|
+
editorConfig_lang: String,
|
|
57
|
+
height: String,
|
|
58
|
+
type: String,
|
|
59
|
+
width: String,
|
|
60
|
+
|
|
61
|
+
onLoadComponentError: Function,
|
|
62
|
+
|
|
63
|
+
events_onAppReady: Function,
|
|
64
|
+
events_onDocumentStateChange: Function,
|
|
65
|
+
events_onMetaChange: Function,
|
|
66
|
+
events_onDocumentReady: Function,
|
|
67
|
+
events_onInfo: Function,
|
|
68
|
+
events_onWarning: Function,
|
|
69
|
+
events_onError: Function,
|
|
70
|
+
events_onRequestSharingSettings: Function,
|
|
71
|
+
events_onRequestSendNotify: Function,
|
|
72
|
+
events_onRequestRename: Function,
|
|
73
|
+
events_onMakeActionLink: Function,
|
|
74
|
+
events_onRequestInsertImage: Function,
|
|
75
|
+
events_onRequestSaveAs: Function,
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Deprecated since version 7.5, please use events_onRequestSelectSpreadsheet instead.
|
|
78
|
+
*/
|
|
79
|
+
events_onRequestMailMergeRecipients: Function,
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated Deprecated since version 7.5, please use events_onRequestSelectDocument instead.
|
|
82
|
+
*/
|
|
83
|
+
events_onRequestCompareFile: Function,
|
|
84
|
+
events_onRequestEditRights: Function,
|
|
85
|
+
events_onRequestHistory: Function,
|
|
86
|
+
events_onRequestHistoryClose: Function,
|
|
87
|
+
events_onRequestHistoryData: Function,
|
|
88
|
+
events_onRequestRestore: Function,
|
|
89
|
+
events_onRequestSelectSpreadsheet: Function,
|
|
90
|
+
events_onRequestSelectDocument: Function,
|
|
91
|
+
events_onRequestUsers: Function,
|
|
92
|
+
},
|
|
93
|
+
mounted() {
|
|
94
|
+
let url = this.documentServerUrl;
|
|
95
|
+
if (!url!.endsWith("/")) url += "/";
|
|
96
|
+
|
|
97
|
+
let docsApiUrl = `${url}web-apps/apps/api/documents/api.js`;
|
|
98
|
+
if (this.shardkey) {
|
|
99
|
+
if (typeof this.shardkey === "boolean") {
|
|
100
|
+
docsApiUrl += `?shardkey=${this.config.document?.key}`;
|
|
101
|
+
} else {
|
|
102
|
+
docsApiUrl += `?shardkey=${this.shardkey}`;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
loadScript(docsApiUrl, "onlyoffice-api-script")
|
|
107
|
+
.then(() => this.onLoad())
|
|
108
|
+
.catch(()=> {this.onError(-2)});
|
|
109
|
+
},
|
|
110
|
+
unmounted() {
|
|
111
|
+
const id = this.id || "";
|
|
112
|
+
|
|
113
|
+
if (window?.DocEditor?.instances[id]) {
|
|
114
|
+
window.DocEditor.instances[id].destroyEditor();
|
|
115
|
+
window.DocEditor.instances[id] = undefined;
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
watch: {
|
|
119
|
+
config: {
|
|
120
|
+
handler: function (newVal, oldVal) {
|
|
121
|
+
this.onChangeProps()
|
|
122
|
+
},
|
|
123
|
+
deep: true
|
|
124
|
+
},
|
|
125
|
+
document_fileType: function(newVal, oldVal) { this.onChangeProps() },
|
|
126
|
+
document_title: function(newVal, oldVal) { this.onChangeProps() },
|
|
127
|
+
documentType: function(newVal, oldVal) { this.onChangeProps() },
|
|
128
|
+
editorConfig_lang: function(newVal, oldVal) { this.onChangeProps() },
|
|
129
|
+
height: function(newVal, oldVal) { this.onChangeProps() },
|
|
130
|
+
type: function(newVal, oldVal) { this.onChangeProps() },
|
|
131
|
+
width: function(newVal, oldVal) { this.onChangeProps() }
|
|
132
|
+
},
|
|
133
|
+
methods: {
|
|
134
|
+
onLoad () {
|
|
135
|
+
try {
|
|
136
|
+
const id = this.id || "";
|
|
137
|
+
|
|
138
|
+
if (!window.DocsAPI) this.onError(-3);
|
|
139
|
+
if (window?.DocEditor?.instances[id]) {
|
|
140
|
+
console.log("Skip loading. Instance already exists", id);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (!window?.DocEditor?.instances) {
|
|
145
|
+
window.DocEditor = { instances: {} };
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
var cloneConfig = cloneDeep(this.config);
|
|
149
|
+
|
|
150
|
+
var propsConfig: any = {
|
|
151
|
+
documentType: this.documentType,
|
|
152
|
+
events: {
|
|
153
|
+
onAppReady: this.onAppReady,
|
|
154
|
+
onDocumentStateChange: this.events_onDocumentStateChange,
|
|
155
|
+
onMetaChange: this.events_onMetaChange,
|
|
156
|
+
onDocumentReady: this.events_onDocumentReady,
|
|
157
|
+
onInfo: this.events_onInfo,
|
|
158
|
+
onWarning: this.events_onWarning,
|
|
159
|
+
onError: this.events_onError,
|
|
160
|
+
onRequestSharingSettings: this.events_onRequestSharingSettings,
|
|
161
|
+
onRequestSendNotify: this.events_onRequestSendNotify,
|
|
162
|
+
onRequestRename: this.events_onRequestRename,
|
|
163
|
+
onMakeActionLink: this.events_onMakeActionLink,
|
|
164
|
+
onRequestInsertImage: this.events_onRequestInsertImage,
|
|
165
|
+
onRequestSaveAs: this.events_onRequestSaveAs,
|
|
166
|
+
onRequestMailMergeRecipients: this.events_onRequestMailMergeRecipients,
|
|
167
|
+
onRequestCompareFile: this.events_onRequestCompareFile,
|
|
168
|
+
onRequestEditRights: this.events_onRequestEditRights,
|
|
169
|
+
onRequestHistory: this.events_onRequestHistory,
|
|
170
|
+
onRequestHistoryClose: this.events_onRequestHistoryClose,
|
|
171
|
+
onRequestHistoryData: this.events_onRequestHistoryData,
|
|
172
|
+
onRequestRestore: this.events_onRequestRestore,
|
|
173
|
+
onRequestSelectSpreadsheet: this.events_onRequestSelectSpreadsheet,
|
|
174
|
+
onRequestSelectDocument: this.events_onRequestSelectDocument,
|
|
175
|
+
onRequestUsers: this.events_onRequestUsers
|
|
176
|
+
},
|
|
177
|
+
height: this.height,
|
|
178
|
+
type: this.type,
|
|
179
|
+
width: this.width,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const document = this.getDocument();
|
|
183
|
+
const editorConfig = this.getEditorConfig();
|
|
184
|
+
|
|
185
|
+
if (document !== null) {
|
|
186
|
+
propsConfig.document = document;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (editorConfig !== null) {
|
|
190
|
+
propsConfig.editorConfig = editorConfig;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
let initConfig = Object.assign(propsConfig, cloneConfig || {});
|
|
194
|
+
|
|
195
|
+
const editor = window.DocsAPI.DocEditor(id, initConfig);
|
|
196
|
+
window.DocEditor.instances[id] = editor;
|
|
197
|
+
} catch (err: any) {
|
|
198
|
+
console.error(err);
|
|
199
|
+
this.onError(-1);
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
getDocument() {
|
|
203
|
+
var document: any = null;
|
|
204
|
+
|
|
205
|
+
if (this.document_fileType) {
|
|
206
|
+
document = document || {};
|
|
207
|
+
document.fileType = this.document_fileType;
|
|
208
|
+
}
|
|
209
|
+
if (this.document_title) {
|
|
210
|
+
document = document || {};
|
|
211
|
+
document.document_title = this.document_title;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return document;
|
|
215
|
+
},
|
|
216
|
+
getEditorConfig() {
|
|
217
|
+
var editorConfig: any = null;
|
|
218
|
+
|
|
219
|
+
if (this.editorConfig_lang) {
|
|
220
|
+
editorConfig = editorConfig || {};
|
|
221
|
+
editorConfig.lang = this.editorConfig_lang;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
return editorConfig;
|
|
225
|
+
},
|
|
226
|
+
onError(errorCode: Number) {
|
|
227
|
+
let message;
|
|
228
|
+
|
|
229
|
+
switch(errorCode) {
|
|
230
|
+
case -2:
|
|
231
|
+
message = "Error load DocsAPI from " + this.documentServerUrl;
|
|
232
|
+
break;
|
|
233
|
+
case -3:
|
|
234
|
+
message = "DocsAPI is not defined";
|
|
235
|
+
break;
|
|
236
|
+
default:
|
|
237
|
+
message = "Unknown error loading component";
|
|
238
|
+
errorCode = -1;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (typeof this.onLoadComponentError == "undefined") {
|
|
242
|
+
console.error(message);
|
|
243
|
+
} else {
|
|
244
|
+
this.onLoadComponentError(errorCode, message);
|
|
245
|
+
}
|
|
246
|
+
},
|
|
247
|
+
onAppReady() {
|
|
248
|
+
const id = this.id || "";
|
|
249
|
+
this.events_onAppReady!(window.DocEditor.instances[id]);
|
|
250
|
+
},
|
|
251
|
+
onChangeProps () {
|
|
252
|
+
const id = this.id || "";
|
|
253
|
+
|
|
254
|
+
if (window?.DocEditor?.instances[id]) {
|
|
255
|
+
window.DocEditor.instances[id].destroyEditor();
|
|
256
|
+
window.DocEditor.instances[id] = undefined;
|
|
257
|
+
|
|
258
|
+
console.log("Important props have been changed. Load new Editor.");
|
|
259
|
+
this.onLoad();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { shallowMount } from "@vue/test-utils";
|
|
18
|
+
import DocumentEditor from "./DocumentEditor.vue";
|
|
19
|
+
|
|
20
|
+
describe("DocumentEditor", () => {
|
|
21
|
+
it("renders the DocumentEditor component", () => {
|
|
22
|
+
const wrapper = shallowMount(DocumentEditor, {
|
|
23
|
+
props: {
|
|
24
|
+
id: "docxEditor",
|
|
25
|
+
documentServerUrl: "http://documentserver/",
|
|
26
|
+
config: {
|
|
27
|
+
"document": {
|
|
28
|
+
"fileType": "docx",
|
|
29
|
+
"key": "Khirz6zTPdfd7",
|
|
30
|
+
"title": "Example Document Title.docx",
|
|
31
|
+
"url": "https://example.com/url-to-example-document.docx"
|
|
32
|
+
},
|
|
33
|
+
"documentType": "word",
|
|
34
|
+
"editorConfig": {
|
|
35
|
+
"callbackUrl": "https://example.com/url-to-callback.ashx"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import SurDocumentEditor from "./components/DocumentEditor.vue";
|
|
18
|
+
|
|
19
|
+
export { SurDocumentEditor };
|
|
20
|
+
export * from "./model/config";
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface IConfig {
|
|
18
|
+
documentType?: string,
|
|
19
|
+
height?: string,
|
|
20
|
+
token?: string,
|
|
21
|
+
type?: string,
|
|
22
|
+
width?: string,
|
|
23
|
+
document?: {
|
|
24
|
+
fileType: string,
|
|
25
|
+
key: string,
|
|
26
|
+
referenceData?: {
|
|
27
|
+
fileKey: string,
|
|
28
|
+
instanceId: string,
|
|
29
|
+
key: string,
|
|
30
|
+
},
|
|
31
|
+
title: string,
|
|
32
|
+
url: string,
|
|
33
|
+
info?: {
|
|
34
|
+
owner?: string,
|
|
35
|
+
uploaded?: string,
|
|
36
|
+
favorite?: boolean,
|
|
37
|
+
folder?: string,
|
|
38
|
+
sharingSettings?: any[],
|
|
39
|
+
},
|
|
40
|
+
permissions?: {
|
|
41
|
+
/**
|
|
42
|
+
* @deprecated Deprecated since version 5.5, please add the onRequestRestore field instead.
|
|
43
|
+
*/
|
|
44
|
+
changeHistory?: boolean,
|
|
45
|
+
chat?: boolean,
|
|
46
|
+
comment?: boolean,
|
|
47
|
+
commentGroups?: any,
|
|
48
|
+
copy?: boolean,
|
|
49
|
+
deleteCommentAuthorOnly?: boolean,
|
|
50
|
+
download?: boolean,
|
|
51
|
+
edit?: boolean,
|
|
52
|
+
editCommentAuthorOnly?: boolean,
|
|
53
|
+
fillForms?: boolean,
|
|
54
|
+
modifyContentControl?: boolean,
|
|
55
|
+
modifyFilter?: boolean,
|
|
56
|
+
print?: boolean,
|
|
57
|
+
protect?: boolean,
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Deprecated since version 6.0, please add the onRequestRename field instead.
|
|
60
|
+
*/
|
|
61
|
+
rename?: boolean,
|
|
62
|
+
review?: boolean,
|
|
63
|
+
reviewGroups?: string[],
|
|
64
|
+
userInfoGroups?: string[],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
editorConfig?: {
|
|
68
|
+
actionLink?: any,
|
|
69
|
+
callbackUrl?: string,
|
|
70
|
+
coEditing?: {
|
|
71
|
+
mode: string,
|
|
72
|
+
change: boolean,
|
|
73
|
+
},
|
|
74
|
+
createUrl?: string,
|
|
75
|
+
lang?: string,
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Deprecated since version 8.2, please use the region parameter instead.
|
|
78
|
+
*/
|
|
79
|
+
location?: string,
|
|
80
|
+
mode?: string,
|
|
81
|
+
recent?: any[],
|
|
82
|
+
region?: string,
|
|
83
|
+
templates?: any[],
|
|
84
|
+
user?: {
|
|
85
|
+
/**
|
|
86
|
+
* @deprecated Deprecated since version 4.2, please use name instead.
|
|
87
|
+
*/
|
|
88
|
+
firstname?: string,
|
|
89
|
+
group?: string,
|
|
90
|
+
id?: string,
|
|
91
|
+
image?: string,
|
|
92
|
+
/**
|
|
93
|
+
* @deprecated Deprecated since version 4.2, please use name instead.
|
|
94
|
+
*/
|
|
95
|
+
lastname?: string,
|
|
96
|
+
name?: string,
|
|
97
|
+
},
|
|
98
|
+
customization?: {
|
|
99
|
+
anonymous?: {
|
|
100
|
+
request?: boolean,
|
|
101
|
+
label?: string,
|
|
102
|
+
},
|
|
103
|
+
autosave?: boolean,
|
|
104
|
+
/**
|
|
105
|
+
* @deprecated Deprecated since version 7.1, please use the document.permissions.chat parameter instead.
|
|
106
|
+
*/
|
|
107
|
+
chat?: boolean,
|
|
108
|
+
close?: {
|
|
109
|
+
visible: boolean,
|
|
110
|
+
text: string,
|
|
111
|
+
},
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated Deprecated since version 6.3, please use the document.permissions.editCommentAuthorOnly and document.permissions.deleteCommentAuthorOnly fields instead.
|
|
114
|
+
*/
|
|
115
|
+
commentAuthorOnly?: boolean,
|
|
116
|
+
comments?: boolean,
|
|
117
|
+
compactHeader?: boolean,
|
|
118
|
+
compactToolbar?: boolean,
|
|
119
|
+
compatibleFeatures?: boolean,
|
|
120
|
+
customer?: {
|
|
121
|
+
address?: string,
|
|
122
|
+
info?: string,
|
|
123
|
+
logo?: string,
|
|
124
|
+
logoDark?: string,
|
|
125
|
+
mail?: string,
|
|
126
|
+
name?: string,
|
|
127
|
+
phone?: string,
|
|
128
|
+
www?: string,
|
|
129
|
+
},
|
|
130
|
+
features?: any,
|
|
131
|
+
feedback?: any,
|
|
132
|
+
forcesave?: boolean,
|
|
133
|
+
forceWesternFontSize?: boolean,
|
|
134
|
+
goback?: any,
|
|
135
|
+
help?: boolean,
|
|
136
|
+
hideNotes?: boolean,
|
|
137
|
+
hideRightMenu?: boolean,
|
|
138
|
+
hideRulers?: boolean,
|
|
139
|
+
integrationMode?: string,
|
|
140
|
+
layout?: any,
|
|
141
|
+
logo?: {
|
|
142
|
+
image?: string,
|
|
143
|
+
imageDark?: string,
|
|
144
|
+
imageLight?: string,
|
|
145
|
+
imageEmbedded?: string,
|
|
146
|
+
url?: string,
|
|
147
|
+
visible?: boolean,
|
|
148
|
+
},
|
|
149
|
+
macros?: boolean,
|
|
150
|
+
macrosMode?: string,
|
|
151
|
+
mentionShare?: boolean,
|
|
152
|
+
mobile?: {
|
|
153
|
+
forceView?: boolean,
|
|
154
|
+
info?: boolean,
|
|
155
|
+
standardView?: boolean,
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* @deprecated Starting from version 8.2, please use the mobile parameter instead.
|
|
159
|
+
*/
|
|
160
|
+
mobileForceView?: boolean,
|
|
161
|
+
plugins?: boolean,
|
|
162
|
+
pointerMode?: 'select' | 'hand',
|
|
163
|
+
review?: {
|
|
164
|
+
hideReviewDisplay?: boolean,
|
|
165
|
+
hoverMode?: boolean,
|
|
166
|
+
reviewDisplay?: string,
|
|
167
|
+
showReviewChanges?: boolean,
|
|
168
|
+
trackChanges?: boolean,
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* @deprecated Deprecated since version 7.0. Please use the review.reviewDisplay parameter instead.
|
|
172
|
+
*/
|
|
173
|
+
reviewDisplay?: string,
|
|
174
|
+
showHorizontalScroll?: boolean,
|
|
175
|
+
/**
|
|
176
|
+
* @deprecated Deprecated since version 7.0. Please use the review.showReviewChanges parameter instead.
|
|
177
|
+
*/
|
|
178
|
+
showReviewChanges?: boolean,
|
|
179
|
+
showVerticalScroll?: boolean,
|
|
180
|
+
slidePlayerBackground?: string,
|
|
181
|
+
/**
|
|
182
|
+
* @deprecated Deprecated since version 7.1. Please use the features.spellcheck parameter instead.
|
|
183
|
+
*/
|
|
184
|
+
spellcheck?: boolean,
|
|
185
|
+
submitForm?: {
|
|
186
|
+
visible: boolean,
|
|
187
|
+
resultMessage: string,
|
|
188
|
+
} | boolean,
|
|
189
|
+
toolbarHideFileName?: boolean,
|
|
190
|
+
toolbarNoTabs?: boolean,
|
|
191
|
+
/**
|
|
192
|
+
* @deprecated Deprecated since version 7.0. Please use the review.trackChanges parameter instead.
|
|
193
|
+
*/
|
|
194
|
+
trackChanges?: boolean,
|
|
195
|
+
uiTheme?: string,
|
|
196
|
+
unit?: string,
|
|
197
|
+
wordHeadingsColor?: string,
|
|
198
|
+
zoom?: number,
|
|
199
|
+
},
|
|
200
|
+
embedded?: {
|
|
201
|
+
embedUrl?: string,
|
|
202
|
+
fullscreenUrl?: string,
|
|
203
|
+
saveUrl?: string,
|
|
204
|
+
shareUrl?: string,
|
|
205
|
+
toolbarDocked?: string,
|
|
206
|
+
},
|
|
207
|
+
plugins?: {
|
|
208
|
+
autostart?: string[],
|
|
209
|
+
options?: {
|
|
210
|
+
all?: Object,
|
|
211
|
+
pluginGuid: Object,
|
|
212
|
+
},
|
|
213
|
+
pluginsData?: string[],
|
|
214
|
+
/**
|
|
215
|
+
* @deprecated Deprecated since version 4.3, please use the absolute URLs in pluginsData field.
|
|
216
|
+
*/
|
|
217
|
+
url?: string,
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
events?: {
|
|
221
|
+
onAppReady?: (event: object) => void,
|
|
222
|
+
onCollaborativeChanges?: (event: object) => void,
|
|
223
|
+
onDocumentReady?: (event: object) => void,
|
|
224
|
+
onDocumentStateChange?: (event: object) => void,
|
|
225
|
+
onDownloadAs?: (event: object) => void,
|
|
226
|
+
onError?: (event: object) => void,
|
|
227
|
+
onInfo?: (event: object) => void,
|
|
228
|
+
onMetaChange?: (event: object) => void,
|
|
229
|
+
onMakeActionLink?: (event: object) => void,
|
|
230
|
+
onOutdatedVersion?: (event: object) => void,
|
|
231
|
+
onPluginsReady?: (event: object) => void,
|
|
232
|
+
onReady?: (event: object) => void,
|
|
233
|
+
onRequestClose?: (event: object) => void,
|
|
234
|
+
/**
|
|
235
|
+
* @deprecated Deprecated since version 7.5, please use onRequestSelectDocument instead.
|
|
236
|
+
*/
|
|
237
|
+
onRequestCompareFile?: (event: object) => void,
|
|
238
|
+
onRequestCreateNew?: (event: object) => void,
|
|
239
|
+
onRequestEditRights?: (event: object) => void,
|
|
240
|
+
onRequestFillingStatus?: (event: object) => void,
|
|
241
|
+
onRequestHistory?: (event: object) => void,
|
|
242
|
+
onRequestHistoryClose?: (event: object) => void,
|
|
243
|
+
onRequestHistoryData?: (event: object) => void,
|
|
244
|
+
onRequestInsertImage?: (event: object) => void,
|
|
245
|
+
/**
|
|
246
|
+
* @deprecated Deprecated since version 7.5, please use onRequestSelectSpreadsheet instead.
|
|
247
|
+
*/
|
|
248
|
+
onRequestMailMergeRecipients?: (event: object) => void,
|
|
249
|
+
onRequestOpen?: (event: object) => void,
|
|
250
|
+
onRequestReferenceData?: (event: object) => void,
|
|
251
|
+
onRequestReferenceSource?: (event: object) => void,
|
|
252
|
+
onRequestRefreshFile?: (event: object) => void,
|
|
253
|
+
onRequestRename?: (event: object) => void,
|
|
254
|
+
onRequestRestore?: (event: object) => void,
|
|
255
|
+
onRequestSaveAs?: (event: object) => void,
|
|
256
|
+
onRequestSelectDocument?: (event: object) => void,
|
|
257
|
+
onRequestSelectSpreadsheet?: (event: object) => void,
|
|
258
|
+
onRequestSendNotify?: (event: object) => void,
|
|
259
|
+
onRequestSharingSettings?: (event: object) => void,
|
|
260
|
+
onRequestStartFilling?: (event: object) => void,
|
|
261
|
+
onRequestUsers?: (event: object) => void,
|
|
262
|
+
onStartFilling?: (event: object) => void,
|
|
263
|
+
onSubmit?: (event: object) => void,
|
|
264
|
+
onUserActionRequired?: (event: object) => void,
|
|
265
|
+
onWarning?: (event: object) => void,
|
|
266
|
+
},
|
|
267
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/* eslint-disable */
|
|
18
|
+
declare module '*.vue' {
|
|
19
|
+
import type { DefineComponent } from 'vue'
|
|
20
|
+
const component: DefineComponent<{}, {}, any>
|
|
21
|
+
export default component
|
|
22
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* (c) Copyright Ascensio System SIA 2025
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const loadScript = async (url: string, id: string) => {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
try {
|
|
20
|
+
// If DocsAPI is defined return resolve.
|
|
21
|
+
//@ts-ignore
|
|
22
|
+
if (window.DocsAPI) return resolve(null);
|
|
23
|
+
|
|
24
|
+
const existedScript = document.getElementById(id);
|
|
25
|
+
|
|
26
|
+
if (existedScript) {
|
|
27
|
+
// If the script element is found, wait for it to load.
|
|
28
|
+
let intervalHandler = setInterval(() => {
|
|
29
|
+
const loading = existedScript.getAttribute("loading");
|
|
30
|
+
if (loading) {
|
|
31
|
+
// If the download is not completed, continue to wait.
|
|
32
|
+
return;
|
|
33
|
+
} else {
|
|
34
|
+
// If the download is completed, stop the wait.
|
|
35
|
+
clearInterval(intervalHandler);
|
|
36
|
+
|
|
37
|
+
// If DocsAPI is defined, after loading return resolve.
|
|
38
|
+
//@ts-ignore
|
|
39
|
+
if (window.DocsAPI) return resolve(null);
|
|
40
|
+
|
|
41
|
+
// If DocsAPI is not defined, delete the existing script and create a new one.
|
|
42
|
+
const script = _createScriptTag(id, url, resolve, reject);
|
|
43
|
+
existedScript.remove();
|
|
44
|
+
document.body.appendChild(script);
|
|
45
|
+
}
|
|
46
|
+
}, 500);
|
|
47
|
+
} else {
|
|
48
|
+
// If the script element is not found, create it.
|
|
49
|
+
const script = _createScriptTag(id, url, resolve, reject);
|
|
50
|
+
document.body.appendChild(script);
|
|
51
|
+
}
|
|
52
|
+
} catch (e) {
|
|
53
|
+
console.error(e);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const _createScriptTag = (id: string, url: string, resolve: (value: unknown) => void, reject: (reason?: any) => void) => {
|
|
59
|
+
const script = document.createElement("script");
|
|
60
|
+
|
|
61
|
+
script.id = id;
|
|
62
|
+
script.type = "text/javascript";
|
|
63
|
+
script.src = url;
|
|
64
|
+
script.async = true;
|
|
65
|
+
|
|
66
|
+
script.onload = () => {
|
|
67
|
+
// Remove attribute loading after loading is complete.
|
|
68
|
+
script.removeAttribute("loading");
|
|
69
|
+
resolve(null);
|
|
70
|
+
};
|
|
71
|
+
script.onerror = (error: any) => {
|
|
72
|
+
// Remove attribute loading after loading is complete.
|
|
73
|
+
script.removeAttribute("loading");
|
|
74
|
+
reject(error);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
script.setAttribute("loading", "");
|
|
78
|
+
|
|
79
|
+
return script;
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default loadScript;
|