Skip to content

Commit

Permalink
fix(editorApi): Allow to pass in ReadonlyBar component
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas <jonas@freesources.org>
  • Loading branch information
mejo- authored and backportbot-nextcloud[bot] committed Oct 10, 2023
1 parent 68bf72f commit 31f6dce
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/components/Editor.vue
Expand Up @@ -42,13 +42,15 @@
<MainContainer v-if="hasEditor">
<!-- Readonly -->
<div v-if="readOnly" class="text-editor--readonly-bar">
<ReadonlyBar>
<Status :document="document"
:dirty="dirty"
:sessions="filteredSessions"
:sync-error="syncError"
:has-connection-issue="hasConnectionIssue" />
</ReadonlyBar>
<slot name="readonlyBar">
<ReadonlyBar>
<Status :document="document"
:dirty="dirty"
:sessions="filteredSessions"
:sync-error="syncError"
:has-connection-issue="hasConnectionIssue" />
</ReadonlyBar>
</slot>
</div>
<!-- Rich Menu -->
<template v-else>
Expand Down
4 changes: 3 additions & 1 deletion src/components/Editor/MarkdownContentEditor.vue
Expand Up @@ -25,7 +25,9 @@
@outline-toggled="outlineToggled">
<MainContainer>
<MenuBar v-if="!readOnly" :autohide="false" />
<ReadonlyBar v-else />
<slot v-else name="readonlyBar">
<ReadonlyBar />
</slot>
<ContentContainer />
</MainContainer>
</Wrapper>
Expand Down
16 changes: 16 additions & 0 deletions src/editor.js
Expand Up @@ -139,6 +139,10 @@ window.OCA.Text.createEditor = async function({

readOnly = false,
autofocus = true,
readonlyBar = {
component: null,
props: null,
},

onLoaded = () => {},
onUpdate = ({ markdown }) => {},
Expand Down Expand Up @@ -179,6 +183,16 @@ window.OCA.Text.createEditor = async function({
return data
},
render: h => {
const scopedSlots = readonlyBar?.component
? {
readonlyBar: () => {
return h(readonlyBar.component, {
props: readonlyBar.props,
})
},
}
: {}

return fileId
? h(Editor, {
props: {
Expand All @@ -190,13 +204,15 @@ window.OCA.Text.createEditor = async function({
autofocus,
showOutlineOutside: data.showOutlineOutside,
},
scopedSlots,
})
: h(MarkdownContentEditor, {
props: {
content: data.content,
readOnly: data.readOnly,
showOutlineOutside: data.showOutlineOutside,
},
scopedSlots,
})
},
store,
Expand Down

0 comments on commit 31f6dce

Please sign in to comment.