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 <[email protected]>
  • Loading branch information
mejo- committed Oct 10, 2023
1 parent 57e3281 commit 90f71d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
16 changes: 9 additions & 7 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,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
Original file line number Diff line number Diff line change
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
15 changes: 15 additions & 0 deletions src/editor.js
Original file line number Diff line number Diff line change
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,15 @@ window.OCA.Text.createEditor = async function({
return data
},
render: h => {
const scopedSlots = readonlyBar?.component
? {

Check failure on line 187 in src/editor.js

View workflow job for this annotation

GitHub Actions / eslint

Expected newline between consequent and alternate of ternary expression
readonlyBar: () => {
return h(readonlyBar.component, {
props: readonlyBar.props,
})
}

Check warning on line 192 in src/editor.js

View workflow job for this annotation

GitHub Actions / eslint

Missing trailing comma
} : {}

return fileId
? h(Editor, {
props: {
Expand All @@ -190,13 +203,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 90f71d5

Please sign in to comment.