Skip to content

Commit 88dd7f6

Browse files
mejo-backportbot-nextcloud[bot]
authored andcommitted
fix(editorApi): Allow to pass in ReadonlyBar component
Signed-off-by: Jonas <[email protected]>
1 parent f7a2bb6 commit 88dd7f6

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

src/components/Editor.vue

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,15 @@
4343
<MainContainer v-if="hasEditor">
4444
<!-- Readonly -->
4545
<div v-if="readOnly" class="text-editor--readonly-bar">
46-
<ReadonlyBar>
47-
<Status :document="document"
48-
:dirty="dirty"
49-
:sessions="filteredSessions"
50-
:sync-error="syncError"
51-
:has-connection-issue="hasConnectionIssue" />
52-
</ReadonlyBar>
46+
<slot name="readonlyBar">
47+
<ReadonlyBar>
48+
<Status :document="document"
49+
:dirty="dirty"
50+
:sessions="filteredSessions"
51+
:sync-error="syncError"
52+
:has-connection-issue="hasConnectionIssue" />
53+
</ReadonlyBar>
54+
</slot>
5355
</div>
5456
<!-- Rich Menu -->
5557
<template v-else>

src/components/Editor/MarkdownContentEditor.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@
2525
@outline-toggled="outlineToggled">
2626
<MainContainer>
2727
<MenuBar v-if="!readOnly" :autohide="false" />
28-
<ReadonlyBar v-else />
28+
<slot v-else name="readonlyBar">
29+
<ReadonlyBar />
30+
</slot>
2931
<ContentContainer />
3032
</MainContainer>
3133
</Wrapper>

src/editor.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ window.OCA.Text.createEditor = async function({
139139

140140
readOnly = false,
141141
autofocus = true,
142+
readonlyBar = {
143+
component: null,
144+
props: null,
145+
},
142146

143147
onLoaded = () => {},
144148
onUpdate = ({ markdown }) => {},
@@ -179,6 +183,16 @@ window.OCA.Text.createEditor = async function({
179183
return data
180184
},
181185
render: h => {
186+
const scopedSlots = readonlyBar?.component
187+
? {
188+
readonlyBar: () => {
189+
return h(readonlyBar.component, {
190+
props: readonlyBar.props,
191+
})
192+
},
193+
}
194+
: {}
195+
182196
return fileId
183197
? h(Editor, {
184198
props: {
@@ -190,13 +204,15 @@ window.OCA.Text.createEditor = async function({
190204
autofocus,
191205
showOutlineOutside: data.showOutlineOutside,
192206
},
207+
scopedSlots,
193208
})
194209
: h(MarkdownContentEditor, {
195210
props: {
196211
content: data.content,
197212
readOnly: data.readOnly,
198213
showOutlineOutside: data.showOutlineOutside,
199214
},
215+
scopedSlots,
200216
})
201217
},
202218
store,

0 commit comments

Comments
 (0)