-
Notifications
You must be signed in to change notification settings - Fork 124
Expand file tree
/
Copy pathWrapper.vue
More file actions
140 lines (122 loc) Β· 2.54 KB
/
Copy pathWrapper.vue
File metadata and controls
140 lines (122 loc) Β· 2.54 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!--
- SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
- SPDX-License-Identifier: AGPL-3.0-or-later
-->
<template>
<div class="text-editor__wrapper"
:class="{
'has-conflicts': isResolvingConflict,
'is-rich-workspace': $isRichWorkspace,
'is-rich-editor': $isRichEditor,
}">
<slot />
</div>
</template>
<script>
import { subscribe, unsubscribe } from '@nextcloud/event-bus'
import { useIsRichEditorMixin, useIsRichWorkspaceMixin } from './../Editor.provider.js'
import { OUTLINE_STATE, OUTLINE_ACTIONS, READ_ONLY_ACTIONS } from './Wrapper.provider.js'
import useStore from '../../mixins/store.js'
import { mapState } from 'vuex'
export default {
name: 'Wrapper',
mixins: [useStore, useIsRichEditorMixin, useIsRichWorkspaceMixin],
provide() {
const val = {}
Object.defineProperties(val, {
[OUTLINE_STATE]: {
get: () => this.outline,
},
[OUTLINE_ACTIONS]: {
get: () => ({
toggle: this.outlineToggle,
}),
},
[READ_ONLY_ACTIONS]: {
get: () => ({
toggle: this.readOnlyToggle,
}),
},
})
return val
},
props: {
isResolvingConflict: {
type: Boolean,
default: false,
},
hasConnectionIssue: {
type: Boolean,
default: false,
},
contentLoaded: {
type: Boolean,
default: true,
},
showOutlineOutside: {
type: Boolean,
default: false,
},
},
data: () => ({
outline: {
visible: false,
enable: false,
},
}),
computed: {
...mapState({
viewWidth: (state) => state.text.viewWidth,
}),
showOutline() {
return this.isAbleToShowOutline
? this.outline.visible
: false
},
isAbleToShowOutline() {
if (this.$isRichWorkspace) {
return false
}
return true
},
},
watch: {
'showOutlineOutside'() {
this.outline.visible = this.showOutlineOutside
},
},
mounted() {
subscribe('text:keyboard:outline', this.outlineToggle)
this.outline.enable = this.isAbleToShowOutline
this.$watch(
() => this.isAbleToShowOutline,
(enable) => {
// make outline state reactive through the provider
Object.assign(this.outline, { enable })
},
)
},
beforeDestroy() {
unsubscribe('text:keyboard:outline', this.outlineToggle)
},
methods: {
outlineToggle() {
this.outline.visible = !this.outline.visible
this.$emit('outline-toggled', this.outline.visible)
},
readOnlyToggle() {
this.$emit('read-only-toggled')
},
},
}
</script>
<style scoped lang="scss">
.text-editor__wrapper {
display: flex;
flex-grow: 1;
width: 100%;
.ProseMirror {
margin-top: 0 !important;
}
}
</style>