1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
| /* eslint-disable no-undef */
| <!--onlyoffice 编辑器-->
| <template>
| <div id="editorDiv"></div>
| </template>
|
| <script>
| import { handleDocType } from '@/utils/onlyofficeUtil'
|
| export default {
| name: 'Editor',
| props: {
| option: {
| type: Object,
| default: () => {
| return {}
| }
| }
| },
| data() {
| return {
| doctype: ''
| }
| },
| mounted() {
| if (this.option.url) {
| this.setEditor(this.option)
| }
| },
| methods: {
| setEditor(option) {
| this.doctype = handleDocType(option.fileType)
| const config = {
| document: {
| fileType: option.fileType,
| key: option.key,
| title: option.title,
| permissions: {
| comment: true,
| download: true,
| modifyContentControl: true,
| modifyFilter: true,
| print: false,
| edit: option.isEdit,
| fillForms: true
| // review: false
| },
| url: option.url
|
| },
| type: option.type,
| documentType: this.doctype,
| editorConfig: {
| callbackUrl: option.callbackUrl,
| lang: 'zh',
| customization: {
| commentAuthorOnly: false,
| comments: true,
| compactHeader: false,
| compactToolbar: true,
| feedback: false,
| plugins: true
| },
| user: {
| id: option.user.id,
| name: option.user.name
| }
| // mode: option.mode
| },
| width: '100%',
| height: '100%',
| position: 'absolute',
| token: option.token
| }
| // eslint-disable-next-line no-unused-vars
| let docEditor = null
| // eslint-disable-next-line no-undef
| docEditor = new DocsAPI.DocEditor('editorDiv', config)
| }
| },
| watch: {
| option: {
| handler: function (n, o) {
| this.setEditor(n)
| this.doctype = handleDocType(n.fileType)
| },
| deep: true
| }
| }
| }
| </script>
|
| <style scoped>
|
| </style>
|
|