spire.officejs-angular-ve 1.0.2
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,320 @@
|
|
|
1
|
+
# spire.officejs-angular
|
|
2
|
+
|
|
3
|
+
An Angular component library for integrating Spire.OfficeJS editors into your Angular applications.
|
|
4
|
+
|
|
5
|
+
# Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install spire.officejs-angular
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
# Usage
|
|
12
|
+
|
|
13
|
+
## Using with Template Reference
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { Component, AfterViewInit, OnInit, ViewChild, isDevMode } from '@angular/core';
|
|
17
|
+
import { SpireOfficejsEditorComponent } from 'spire.officejs-angular';
|
|
18
|
+
|
|
19
|
+
@Component({
|
|
20
|
+
selector: 'app-root',
|
|
21
|
+
standalone: true,
|
|
22
|
+
imports: [SpireOfficejsEditorComponent],
|
|
23
|
+
template: `
|
|
24
|
+
<div>
|
|
25
|
+
<button (click)="openEditor()">Open Editor</button>
|
|
26
|
+
<spire-officejs-editor
|
|
27
|
+
#editorRef
|
|
28
|
+
[config]="config"
|
|
29
|
+
[serverUrl]="serverUrl"
|
|
30
|
+
></spire-officejs-editor>
|
|
31
|
+
</div>
|
|
32
|
+
`
|
|
33
|
+
})
|
|
34
|
+
export class OfficeJS implements AfterViewInit, OnInit {
|
|
35
|
+
constructor (private router: Router) {}
|
|
36
|
+
|
|
37
|
+
file = new File() // The actual File Data of the document
|
|
38
|
+
fileUint8Data = new Uint8Array() // The actual Uint8Array data of the document
|
|
39
|
+
serverUrl = window.location.origin
|
|
40
|
+
Editor: any
|
|
41
|
+
config: any = {}
|
|
42
|
+
Api: any
|
|
43
|
+
|
|
44
|
+
editorTypes = {
|
|
45
|
+
document: 'document',
|
|
46
|
+
pdf: 'pdf',
|
|
47
|
+
spreadsheet: 'spreadsheet',
|
|
48
|
+
presentation: 'presentation'
|
|
49
|
+
}
|
|
50
|
+
exts_document = ['docx', 'docm', 'doc', 'dotx', 'dotm', 'dot', 'odt', 'fodt', 'ott', 'txt', 'wps', 'wpt']
|
|
51
|
+
exts_spreadsheet = ['xlsx', 'csv', 'xlsm', 'xls', 'xltx', 'xltm', 'xlt', 'et', 'ett']
|
|
52
|
+
exts_presentation = ['pptx', 'pptm', 'ppt', 'ppsx', 'ppsm', 'pps', 'potx', 'potm', 'dps', 'dpt']
|
|
53
|
+
exts_pdf= ['pdf', 'xps']
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
@ViewChild('editorRef') editorRef?: SpireOfficejsEditorComponent
|
|
57
|
+
|
|
58
|
+
ngOnInit () {
|
|
59
|
+
this.init()
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
ngAfterViewInit () {
|
|
63
|
+
this.openEditor()
|
|
64
|
+
}
|
|
65
|
+
init () {
|
|
66
|
+
if (!this.file) {
|
|
67
|
+
this.router.navigate([''])
|
|
68
|
+
return
|
|
69
|
+
}
|
|
70
|
+
this.initConfig()
|
|
71
|
+
}
|
|
72
|
+
initConfig () {
|
|
73
|
+
var url = new URL(import.meta.url)
|
|
74
|
+
var editorType = ''
|
|
75
|
+
var ext = this.getFileExtension()
|
|
76
|
+
if (isDevMode()) {
|
|
77
|
+
this.serverUrl = `http://127.0.0.1:7000`
|
|
78
|
+
} else {
|
|
79
|
+
this.serverUrl = `${url.origin}/spire.officejs`
|
|
80
|
+
this.serverUrl = `${url.origin}/spire.officejs`
|
|
81
|
+
}
|
|
82
|
+
if (this.exts_document.includes(ext)) editorType = this.editorTypes.document
|
|
83
|
+
else if (this.exts_spreadsheet.includes(ext))
|
|
84
|
+
editorType = this.editorTypes.spreadsheet
|
|
85
|
+
else if (this.exts_presentation.includes(ext))
|
|
86
|
+
editorType = this.editorTypes.presentation
|
|
87
|
+
else if (this.exts_pdf.includes(ext)) editorType = this.editorTypes.pdf
|
|
88
|
+
|
|
89
|
+
this.config = {
|
|
90
|
+
fileAttrs: {
|
|
91
|
+
fileInfo: {
|
|
92
|
+
name: this.file.name,
|
|
93
|
+
ext: ext,
|
|
94
|
+
primary: String(new Date().getTime()), //this is key
|
|
95
|
+
creator: 'Jonn',
|
|
96
|
+
createTime: '2022-04-18 11:30:43'
|
|
97
|
+
},
|
|
98
|
+
sourceUrl: this.serverUrl + '/files/__ffff_192.168.2.134/' + this.file.name,
|
|
99
|
+
createUrl: this.serverUrl + '/open',
|
|
100
|
+
mergeFolderUrl: '',
|
|
101
|
+
fileChoiceUrl: '',
|
|
102
|
+
templates: {}
|
|
103
|
+
},
|
|
104
|
+
user: {
|
|
105
|
+
id: 'uid-1',
|
|
106
|
+
name: 'Jonn',
|
|
107
|
+
canSave: true
|
|
108
|
+
},
|
|
109
|
+
editorAttrs: {
|
|
110
|
+
editorMode: this.file.name.endsWith('.pdf') ? 'view' : 'edit',
|
|
111
|
+
editorWidth: '100%',
|
|
112
|
+
editorHeight: '100%',
|
|
113
|
+
editorType: editorType,
|
|
114
|
+
platform: 'desktop', //desktop£¬ mobile£¬ embedded
|
|
115
|
+
viewLanguage: 'zh', //en/zh
|
|
116
|
+
isReadOnly: false,
|
|
117
|
+
canChat: true,
|
|
118
|
+
canComment: true,
|
|
119
|
+
canReview: true,
|
|
120
|
+
canDownload: true,
|
|
121
|
+
canEdit: this.file.name.endsWith('.pdf') ? false : true,
|
|
122
|
+
canForcesave: true,
|
|
123
|
+
embedded: {
|
|
124
|
+
saveUrl: '',
|
|
125
|
+
embedUrl: '',
|
|
126
|
+
shareUrl: '',
|
|
127
|
+
toolbarDocked: 'top'
|
|
128
|
+
},
|
|
129
|
+
useWebAssemblyDoc: true,
|
|
130
|
+
useWebAssemblyExcel: true,
|
|
131
|
+
useWebAssemblyPpt: true,
|
|
132
|
+
useWebAssemblyPdf: true,
|
|
133
|
+
spireDocJsLicense: '',
|
|
134
|
+
spireXlsJsLicense: '',
|
|
135
|
+
spirePresentationJsLicense: '',
|
|
136
|
+
spirePdfJsLicense: '',
|
|
137
|
+
serverless: {
|
|
138
|
+
useServerless: true,
|
|
139
|
+
baseUrl: this.serverUrl,
|
|
140
|
+
fileData: this.fileUint8Data
|
|
141
|
+
},
|
|
142
|
+
events: {
|
|
143
|
+
onSave: this.onFileSave
|
|
144
|
+
},
|
|
145
|
+
plugins: {
|
|
146
|
+
pluginsData: []
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
OnWindowReSize () {
|
|
152
|
+
let wrapEl = document.getElementsByClassName('form') as any
|
|
153
|
+
if (wrapEl.length) {
|
|
154
|
+
wrapEl[0].style.height = screen.availHeight + 'px'
|
|
155
|
+
window.scrollTo(0, -1)
|
|
156
|
+
wrapEl[0].style.height = window.innerHeight + 'px'
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
getFileExtension () {
|
|
160
|
+
const filename = this.file.name.split(/[\\/]/).pop() as string
|
|
161
|
+
return filename.substring(filename.lastIndexOf('.') + 1).toLowerCase() || ''
|
|
162
|
+
}
|
|
163
|
+
onFileSave (data: any) {
|
|
164
|
+
console.log('save data', data)
|
|
165
|
+
}
|
|
166
|
+
openEditor () {
|
|
167
|
+
if(this.editorRef?.open)
|
|
168
|
+
this.editorRef.open()
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Using in NgModule-based Applications
|
|
174
|
+
|
|
175
|
+
If you're using NgModule-based Angular applications:
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
import { NgModule } from '@angular/core';
|
|
179
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
180
|
+
import { SpireOfficejsEditorModule } from 'spire.officejs-angular';
|
|
181
|
+
|
|
182
|
+
@NgModule({
|
|
183
|
+
declarations: [AppComponent],
|
|
184
|
+
imports: [
|
|
185
|
+
BrowserModule,
|
|
186
|
+
SpireOfficejsEditorModule
|
|
187
|
+
],
|
|
188
|
+
bootstrap: [AppComponent]
|
|
189
|
+
})
|
|
190
|
+
export class AppModule { }
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
# Parameters
|
|
194
|
+
|
|
195
|
+
## Input Properties
|
|
196
|
+
|
|
197
|
+
| Property | Description | Type | Default |
|
|
198
|
+
|----------|-------------|------|---------|
|
|
199
|
+
| id | Editor container ID | `string` | `'SpireofficejsEditor'` |
|
|
200
|
+
| config | Editor configuration object | `object` | **Required** |
|
|
201
|
+
| serverUrl | Server URL for Spire.OfficeJS | `string` | **Required** |
|
|
202
|
+
|
|
203
|
+
## Methods
|
|
204
|
+
|
|
205
|
+
| Method | Description |
|
|
206
|
+
|--------|-------------|
|
|
207
|
+
| open() | Manually initialize and open the editor |
|
|
208
|
+
|
|
209
|
+
## Config Structure
|
|
210
|
+
|
|
211
|
+
The `config` object should contain:
|
|
212
|
+
|
|
213
|
+
```typescript
|
|
214
|
+
{
|
|
215
|
+
fileAttrs: {
|
|
216
|
+
fileInfo: {
|
|
217
|
+
name: string,
|
|
218
|
+
ext: string,
|
|
219
|
+
primary: string,
|
|
220
|
+
creator: string,
|
|
221
|
+
createTime: string
|
|
222
|
+
},
|
|
223
|
+
sourceUrl: string,
|
|
224
|
+
createUrl?: string,
|
|
225
|
+
mergeFolderUrl?: string,
|
|
226
|
+
fileChoiceUrl?: string,
|
|
227
|
+
templates?: object
|
|
228
|
+
},
|
|
229
|
+
user: {
|
|
230
|
+
id: string,
|
|
231
|
+
name: string,
|
|
232
|
+
canSave: boolean
|
|
233
|
+
},
|
|
234
|
+
editorAttrs: {
|
|
235
|
+
editorMode: 'edit' | 'view',
|
|
236
|
+
editorWidth: string,
|
|
237
|
+
editorHeight: string,
|
|
238
|
+
editorType: 'document' | 'spreadsheet' | 'presentation' | 'pdf',
|
|
239
|
+
platform: 'desktop' | 'mobile',
|
|
240
|
+
viewLanguage: string,
|
|
241
|
+
isReadOnly: boolean,
|
|
242
|
+
canChat: boolean,
|
|
243
|
+
canComment: boolean,
|
|
244
|
+
canReview: boolean,
|
|
245
|
+
canDownload: boolean,
|
|
246
|
+
canEdit: boolean,
|
|
247
|
+
canForcesave: boolean,
|
|
248
|
+
embedded?: {
|
|
249
|
+
saveUrl: string,
|
|
250
|
+
embedUrl: string,
|
|
251
|
+
shareUrl: string,
|
|
252
|
+
toolbarDocked: string
|
|
253
|
+
},
|
|
254
|
+
useWebAssemblyDoc: boolean,
|
|
255
|
+
useWebAssemblyExcel: boolean,
|
|
256
|
+
useWebAssemblyPpt: boolean,
|
|
257
|
+
useWebAssemblyPdf: boolean,
|
|
258
|
+
spireDocJsLicense: string,
|
|
259
|
+
spireXlsJsLicense: string,
|
|
260
|
+
spirePresentationJsLicense: string,
|
|
261
|
+
spirePdfJsLicense: string,
|
|
262
|
+
serverless?: {
|
|
263
|
+
useServerless: boolean,
|
|
264
|
+
baseUrl: string,
|
|
265
|
+
fileData: Uint8Array
|
|
266
|
+
},
|
|
267
|
+
events: {
|
|
268
|
+
onSave: (data: any) => void
|
|
269
|
+
},
|
|
270
|
+
plugins: {
|
|
271
|
+
pluginsData: any[]
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
# Important Notes
|
|
278
|
+
|
|
279
|
+
1. Using this component requires the `vite` plugin to build a standalone server. You can refer to [Using the Official Migration Schematic](#using-the-official-migration-schematic) or configure it yourself.
|
|
280
|
+
2. Make sure your server is running and accessible from the client application.
|
|
281
|
+
3. The component will automatically load the necessary editor scripts from the provided `serverUrl`.
|
|
282
|
+
4. For production use, ensure proper error handling and loading states.
|
|
283
|
+
5. This component is built as a standalone Angular component and supports both standalone and NgModule-based applications.
|
|
284
|
+
|
|
285
|
+
# Supported File Formats
|
|
286
|
+
|
|
287
|
+
## Document
|
|
288
|
+
.docx, .docm, .doc, .dotx, .dotm, .dot, .odt, .fodt, .ott, .txt, .wps, .wpt
|
|
289
|
+
|
|
290
|
+
## Spreadsheet
|
|
291
|
+
.xlsx, .csv, .xlsm, .xls, .xltx, .xltm, .xlt, .et, .ett
|
|
292
|
+
|
|
293
|
+
## Presentation
|
|
294
|
+
.pptx, .pptm, .ppt, .ppsx, .ppsm, .pps, .potx, .potm, .dps, .dpt
|
|
295
|
+
|
|
296
|
+
## PDF
|
|
297
|
+
.pdf, .xps
|
|
298
|
+
|
|
299
|
+
# Build Tool Plugins
|
|
300
|
+
|
|
301
|
+
| Build Tool | Plugin Name | NPM Package |
|
|
302
|
+
|------------|-------------|-------------|
|
|
303
|
+
| Vite | vite-plugin-spire.officejs | [vite-plugin-spire.officejs](https://www.npmjs.com/package/vite-plugin-spire.officejs) |
|
|
304
|
+
|
|
305
|
+
# Using the Official Migration Schematic
|
|
306
|
+
|
|
307
|
+
1. In your Angular project root directory, run the following command:
|
|
308
|
+
```bash
|
|
309
|
+
npm i @analogjs/platform @nx/devkit
|
|
310
|
+
|
|
311
|
+
npx ng generate @analogjs/platform:migrate --project [your-project-name]
|
|
312
|
+
```
|
|
313
|
+
If you're unsure about the project name, you can check the `projects` field in the `angular.json` file.
|
|
314
|
+
|
|
315
|
+
2. Execute the automatic migration
|
|
316
|
+
This Schematic will automatically complete the following tasks:
|
|
317
|
+
- Install the necessary dependency packages.
|
|
318
|
+
- Create the `vite.config.ts` configuration file in the project root directory.
|
|
319
|
+
- Update `angular.json`, replacing the original `build` and `serve` builders with the Vite builders provided by Analog.
|
|
320
|
+
- Modify entry files such as `src/main.ts` to adapt to Vite's workflow.
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Input, Component, NgModule } from '@angular/core';
|
|
3
|
+
import SpireofficeEditor from 'spire.officejs-web-editors';
|
|
4
|
+
|
|
5
|
+
class SpireOfficejsEditorComponent {
|
|
6
|
+
id = 'SpireofficejsEditor';
|
|
7
|
+
config;
|
|
8
|
+
serverUrl;
|
|
9
|
+
SpireEditor;
|
|
10
|
+
baseUrl;
|
|
11
|
+
isEditorInitialized = false;
|
|
12
|
+
ngOnInit() {
|
|
13
|
+
this.validateProps();
|
|
14
|
+
}
|
|
15
|
+
ngAfterViewInit() {
|
|
16
|
+
this.init();
|
|
17
|
+
}
|
|
18
|
+
validateProps() {
|
|
19
|
+
if (!this.config) {
|
|
20
|
+
throw new Error('Missing parameter "config"');
|
|
21
|
+
}
|
|
22
|
+
if (this.serverUrl == null || this.serverUrl == undefined) {
|
|
23
|
+
throw new Error('Missing parameter "serverUrl"');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
init() {
|
|
27
|
+
this.initServerUrl();
|
|
28
|
+
this.loadScript();
|
|
29
|
+
}
|
|
30
|
+
initServerUrl() {
|
|
31
|
+
if (this.serverUrl) {
|
|
32
|
+
if (this.serverUrl.endsWith('/')) {
|
|
33
|
+
this.baseUrl = this.serverUrl.substring(0, this.serverUrl.length - 1);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.baseUrl = this.serverUrl;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.baseUrl = window.location.origin;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
initEditor() {
|
|
44
|
+
if (SpireofficeEditor && SpireofficeEditor.OpenApi) {
|
|
45
|
+
const OpenApi = SpireofficeEditor.OpenApi;
|
|
46
|
+
this.SpireEditor = new OpenApi(this.id, this.config);
|
|
47
|
+
window.Api = this.SpireEditor.GetOpenApi();
|
|
48
|
+
this.onWindowResize();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
loadScript() {
|
|
52
|
+
const scriptTag = document.createElement('script');
|
|
53
|
+
const url = `${this.baseUrl}/web/editors/spireapi/SpireCloudEditor.js`;
|
|
54
|
+
scriptTag.setAttribute('src', url);
|
|
55
|
+
scriptTag.onerror = () => {
|
|
56
|
+
console.error(`Failed to load script: ${url}`);
|
|
57
|
+
};
|
|
58
|
+
document.body.appendChild(scriptTag);
|
|
59
|
+
}
|
|
60
|
+
onWindowResize() {
|
|
61
|
+
const wrapEl = document.getElementsByClassName('spire-officejs-editors-wrapper');
|
|
62
|
+
if (wrapEl.length) {
|
|
63
|
+
if (wrapEl[0]) {
|
|
64
|
+
wrapEl[0].style.height = screen.availHeight + 'px';
|
|
65
|
+
}
|
|
66
|
+
window.scrollTo(0, -1);
|
|
67
|
+
if (wrapEl[0]) {
|
|
68
|
+
wrapEl[0].style.height = window.innerHeight + 'px';
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
open() {
|
|
73
|
+
this.initEditor();
|
|
74
|
+
}
|
|
75
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
76
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.2.18", type: SpireOfficejsEditorComponent, isStandalone: true, selector: "spire-officejs-editor", inputs: { id: "id", config: "config", serverUrl: "serverUrl" }, ngImport: i0, template: `<div [id]="id" class="spire-officejs-editors-wrapper">Loading editor...</div>`, isInline: true, styles: [".spire-officejs-editors-wrapper{width:100%;height:100%}\n"] });
|
|
77
|
+
}
|
|
78
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorComponent, decorators: [{
|
|
79
|
+
type: Component,
|
|
80
|
+
args: [{ selector: 'spire-officejs-editor', template: `<div [id]="id" class="spire-officejs-editors-wrapper">Loading editor...</div>`, standalone: true, styles: [".spire-officejs-editors-wrapper{width:100%;height:100%}\n"] }]
|
|
81
|
+
}], propDecorators: { id: [{
|
|
82
|
+
type: Input
|
|
83
|
+
}], config: [{
|
|
84
|
+
type: Input
|
|
85
|
+
}], serverUrl: [{
|
|
86
|
+
type: Input
|
|
87
|
+
}] } });
|
|
88
|
+
|
|
89
|
+
class SpireOfficejsEditorModule {
|
|
90
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
91
|
+
static ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorModule, imports: [SpireOfficejsEditorComponent], exports: [SpireOfficejsEditorComponent] });
|
|
92
|
+
static ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorModule });
|
|
93
|
+
}
|
|
94
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.18", ngImport: i0, type: SpireOfficejsEditorModule, decorators: [{
|
|
95
|
+
type: NgModule,
|
|
96
|
+
args: [{
|
|
97
|
+
imports: [SpireOfficejsEditorComponent],
|
|
98
|
+
exports: [SpireOfficejsEditorComponent]
|
|
99
|
+
}]
|
|
100
|
+
}] });
|
|
101
|
+
|
|
102
|
+
/*
|
|
103
|
+
* Public API Surface of src
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Generated bundle index. Do not edit.
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
export { SpireOfficejsEditorComponent, SpireOfficejsEditorModule };
|
|
111
|
+
//# sourceMappingURL=spire.officejs-angular.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spire.officejs-angular.mjs","sources":["../../components/projects/src/officejsEditor/officejsEditor.component.ts","../../components/projects/src/officejsEditor/officejsEditor.module.ts","../../components/projects/src/public-api.ts","../../components/projects/src/spire.officejs-angular.ts"],"sourcesContent":["import { Component, OnInit, AfterViewInit, Input, Output, EventEmitter } from '@angular/core'\r\nimport type { OfficejsEditorProps, OfficejsEditorMethods } from './officejsEditor.types'\r\nimport SpireofficeEditor from 'spire.officejs-web-editors'\r\n\r\n\r\n@Component({\r\n selector: 'spire-officejs-editor',\r\n template: `<div [id]=\"id\" class=\"spire-officejs-editors-wrapper\">Loading editor...</div>`,\r\n styles: [\r\n `\r\n .spire-officejs-editors-wrapper {\r\n width: 100%;\r\n height: 100%;\r\n }\r\n `\r\n ],\r\n standalone: true\r\n})\r\nexport class SpireOfficejsEditorComponent\r\n implements OnInit, AfterViewInit, OfficejsEditorProps, OfficejsEditorMethods\r\n{\r\n @Input() id: string = 'SpireofficejsEditor'\r\n @Input() config!: object\r\n @Input() serverUrl!: string\r\n\r\n private SpireEditor: any\r\n private baseUrl!: string\r\n private isEditorInitialized = false\r\n\r\n ngOnInit (): void {\r\n this.validateProps()\r\n }\r\n\r\n ngAfterViewInit (): void {\r\n this.init()\r\n }\r\n\r\n protected validateProps (): void {\r\n if (!this.config) {\r\n throw new Error('Missing parameter \"config\"')\r\n }\r\n if (this.serverUrl == null || this.serverUrl == undefined) {\r\n throw new Error('Missing parameter \"serverUrl\"')\r\n }\r\n }\r\n\r\n protected init (): void {\r\n this.initServerUrl()\r\n this.loadScript()\r\n }\r\n\r\n protected initServerUrl (): void {\r\n if (this.serverUrl) {\r\n if (this.serverUrl.endsWith('/')) {\r\n this.baseUrl = this.serverUrl.substring(0, this.serverUrl.length - 1)\r\n } else {\r\n this.baseUrl = this.serverUrl\r\n }\r\n } else {\r\n this.baseUrl = window.location.origin\r\n }\r\n }\r\n\r\n protected initEditor (): void {\r\n if (SpireofficeEditor && SpireofficeEditor.OpenApi) {\r\n const OpenApi: any = SpireofficeEditor.OpenApi\r\n this.SpireEditor = new OpenApi(this.id, this.config)\r\n window.Api = this.SpireEditor.GetOpenApi()\r\n this.onWindowResize()\r\n }\r\n }\r\n\r\n protected loadScript (): void {\r\n const scriptTag = document.createElement('script')\r\n const url = `${this.baseUrl}/web/editors/spireapi/SpireCloudEditor.js`\r\n\r\n scriptTag.setAttribute('src', url)\r\n scriptTag.onerror = () => {\r\n console.error(`Failed to load script: ${url}`)\r\n }\r\n document.body.appendChild(scriptTag)\r\n }\r\n\r\n protected onWindowResize (): void {\r\n const wrapEl = document.getElementsByClassName(\r\n 'spire-officejs-editors-wrapper'\r\n ) as HTMLCollectionOf<HTMLElement>\r\n if (wrapEl.length) {\r\n if (wrapEl[0]) {\r\n wrapEl[0].style.height = screen.availHeight + 'px'\r\n }\r\n window.scrollTo(0, -1)\r\n if (wrapEl[0]) {\r\n wrapEl[0].style.height = window.innerHeight + 'px'\r\n }\r\n }\r\n }\r\n\r\n public open (): void {\r\n this.initEditor()\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { SpireOfficejsEditorComponent } from './officejsEditor.component';\r\n\r\n@NgModule({\r\n imports: [SpireOfficejsEditorComponent],\r\n exports: [SpireOfficejsEditorComponent]\r\n})\r\nexport class SpireOfficejsEditorModule { }","/*\r\n * Public API Surface of src\r\n */\r\n\r\nexport * from './officejsEditor/public-api';\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;MAkBa,4BAA4B,CAAA;IAG9B,EAAE,GAAW,qBAAqB;AAClC,IAAA,MAAM;AACN,IAAA,SAAS;AAEV,IAAA,WAAW;AACX,IAAA,OAAO;IACP,mBAAmB,GAAG,KAAK;IAEnC,QAAQ,GAAA;QACN,IAAI,CAAC,aAAa,EAAE;IACtB;IAEA,eAAe,GAAA;QACb,IAAI,CAAC,IAAI,EAAE;IACb;IAEU,aAAa,GAAA;AACrB,QAAA,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;AAChB,YAAA,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC;QAC/C;AACA,QAAA,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,IAAI,IAAI,CAAC,SAAS,IAAI,SAAS,EAAE;AACzD,YAAA,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC;QAClD;IACF;IAEU,IAAI,GAAA;QACZ,IAAI,CAAC,aAAa,EAAE;QACpB,IAAI,CAAC,UAAU,EAAE;IACn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,CAAA,EAAA,CAAA;yGAE3B,yBAAyB,EAAA,CAAA;;4FAAzB,yBAAyB,EAAA,UAAA,EAAA,CAAA;kBAJrC,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;oBACR,OAAO,EAAE,CAAC,4BAA4B,CAAC;oBACvC,OAAO,EAAE,CAAC,4BAA4B;AACvC,iBAAA;;;ACND;;AAEG;;ACFH;;AAEG;;;;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "spire.officejs-angular-ve",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"sideEffects": false,
|
|
5
|
+
"module": "fesm2022/spire.officejs-angular.mjs",
|
|
6
|
+
"typings": "types/spire.officejs-angular.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./package.json": {
|
|
9
|
+
"default": "./package.json"
|
|
10
|
+
},
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./types/spire.officejs-angular.d.ts",
|
|
13
|
+
"default": "./fesm2022/spire.officejs-angular.mjs"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"tslib": "^2.3.0",
|
|
18
|
+
"vite-plugin-spire.officejs": "^10.0.0",
|
|
19
|
+
"spire.officejs-ve": "1.0.2"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"spire.officejs",
|
|
23
|
+
"Angular",
|
|
24
|
+
"TypeScript",
|
|
25
|
+
"Vite"
|
|
26
|
+
],
|
|
27
|
+
"author": "icebluezhang",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"description": ""
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { OnInit, AfterViewInit } from '@angular/core';
|
|
3
|
+
|
|
4
|
+
declare global {
|
|
5
|
+
interface Window {
|
|
6
|
+
Api: any;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
interface OfficejsEditorProps {
|
|
10
|
+
id?: string;
|
|
11
|
+
config: object;
|
|
12
|
+
serverUrl: string;
|
|
13
|
+
}
|
|
14
|
+
interface OfficejsEditorMethods {
|
|
15
|
+
open(): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare class SpireOfficejsEditorComponent implements OnInit, AfterViewInit, OfficejsEditorProps, OfficejsEditorMethods {
|
|
19
|
+
id: string;
|
|
20
|
+
config: object;
|
|
21
|
+
serverUrl: string;
|
|
22
|
+
private SpireEditor;
|
|
23
|
+
private baseUrl;
|
|
24
|
+
private isEditorInitialized;
|
|
25
|
+
ngOnInit(): void;
|
|
26
|
+
ngAfterViewInit(): void;
|
|
27
|
+
protected validateProps(): void;
|
|
28
|
+
protected init(): void;
|
|
29
|
+
protected initServerUrl(): void;
|
|
30
|
+
protected initEditor(): void;
|
|
31
|
+
protected loadScript(): void;
|
|
32
|
+
protected onWindowResize(): void;
|
|
33
|
+
open(): void;
|
|
34
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SpireOfficejsEditorComponent, never>;
|
|
35
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<SpireOfficejsEditorComponent, "spire-officejs-editor", never, { "id": { "alias": "id"; "required": false; }; "config": { "alias": "config"; "required": false; }; "serverUrl": { "alias": "serverUrl"; "required": false; }; }, {}, never, never, true, never>;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare class SpireOfficejsEditorModule {
|
|
39
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<SpireOfficejsEditorModule, never>;
|
|
40
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<SpireOfficejsEditorModule, never, [typeof SpireOfficejsEditorComponent], [typeof SpireOfficejsEditorComponent]>;
|
|
41
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<SpireOfficejsEditorModule>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { SpireOfficejsEditorComponent, SpireOfficejsEditorModule };
|