Skip to content

Commit

Permalink
fix(ViewerComponent): use MarkdownContentEditor for readonly views
Browse files Browse the repository at this point in the history
Also pass the `fileId` to the component. This adds support for
displaying images and attachments in the read-only view.

Fixes: #6267

Signed-off-by: Jonas <[email protected]>
  • Loading branch information
mejo- committed Aug 27, 2024
1 parent 5806197 commit a853705
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
19 changes: 13 additions & 6 deletions src/components/Editor/MarkdownContentEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
:show-outline-outside="showOutlineOutside"
@outline-toggled="outlineToggled">
<MainContainer>
<MenuBar v-if="!readOnly" :autohide="false" />
<slot v-else name="readonlyBar">
<ReadonlyBar />
</slot>
<template v-if="showMenuBar">
<MenuBar v-if="!readOnly" :autohide="false" />
<slot v-else name="readonlyBar">
<ReadonlyBar />
</slot>
</template>
<ContentContainer />
</MainContainer>
</Wrapper>
Expand Down Expand Up @@ -75,6 +77,10 @@ export default {
type: String,
default: null,
},
showMenuBar: {
type: Boolean,
default: true,
},
showOutlineOutside: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -175,6 +181,7 @@ export default {
}
</script>
<style scoped>
<style lang="scss">
@import './../../css/prosemirror';
@import './../../css/print';
</style>
8 changes: 4 additions & 4 deletions src/components/ViewerComponent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
id="editor-container"
data-text-el="editor-container"
class="text-editor source-viewer">
<Component :is="readerComponent" :content="content" />
<Component :is="readerComponent" :content="content" :fileId="fileid" :read-only="true" :show-menu-bar="false" />

Check warning on line 20 in src/components/ViewerComponent.vue

View workflow job for this annotation

GitHub Actions / NPM lint

Attribute ':fileId' must be hyphenated

Check failure on line 20 in src/components/ViewerComponent.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':read-only' should be on a new line

Check failure on line 20 in src/components/ViewerComponent.vue

View workflow job for this annotation

GitHub Actions / NPM lint

':show-menu-bar' should be on a new line
<NcButton v-if="isEmbedded" class="toggle-interactive" @click="toggleEdit">
{{ t('text', 'Edit') }}
<template #icon>
Expand All @@ -33,7 +33,7 @@ import axios from '@nextcloud/axios'
import PencilIcon from 'vue-material-design-icons/Pencil.vue'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
import PlainTextReader from './PlainTextReader.vue'
import RichTextReader from './RichTextReader.vue'
import MarkdownContentEditor from './Editor/MarkdownContentEditor.vue'
import { translate, translatePlural } from '@nextcloud/l10n'
import { getSharingToken } from '../helpers/token.js'
Expand All @@ -47,8 +47,8 @@ export default {
components: {
NcButton: Vue.extend(NcButton),
PencilIcon: Vue.extend(PencilIcon),
RichTextReader: Vue.extend(RichTextReader),
PlainTextReader: Vue.extend(PlainTextReader),
MarkdownContentEditor: Vue.extend(MarkdownContentEditor),
Editor: getEditorInstance,
},
provide() {
Expand Down Expand Up @@ -112,7 +112,7 @@ export default {
/** @return {boolean} */
readerComponent() {
return this.mime === 'text/markdown' ? RichTextReader : PlainTextReader
return this.mime === 'text/markdown' ? MarkdownContentEditor : PlainTextReader
},
},
Expand Down

0 comments on commit a853705

Please sign in to comment.