Skip to content

Commit

Permalink
Merge pull request #5055 from nextcloud/backport/5020/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(ImageView): Fix detection of editable editor
  • Loading branch information
mejo- authored Nov 29, 2023
2 parents 92045eb + 8500cc9 commit c8efdf6
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 25 deletions.
4 changes: 2 additions & 2 deletions js/editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-editors.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-editors.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-files.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-public.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-text.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/text-viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text-viewer.js.map

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
-->

<template>
<NodeViewWrapper>
<NodeViewWrapper :contenteditable="isEditable">
<figure class="image image-view"
data-component="image-view"
:class="{'icon-loading': !loaded, 'image-view--failed': failed}"
Expand Down Expand Up @@ -74,7 +74,7 @@
v-show="loaded"
class="image__caption"
:title="alt">
<figcaption v-if="!editable">
<figcaption v-if="!isEditable">
{{ alt }}
</figcaption>
<div v-else class="image__caption__wrapper">
Expand Down Expand Up @@ -118,7 +118,7 @@
<input ref="altInput"
type="text"
:value="alt"
:disabled="!editable"
:disabled="!isEditable"
@blur="updateAlt"
@keyup.enter="updateAlt">
</div>
Expand Down Expand Up @@ -202,17 +202,15 @@ export default {
showImageModal: false,
embeddedImagesList: [],
imageIndex: null,
isEditable: false,
}
},
computed: {
isMediaAttachment() {
return this.attachmentType === this.$attachmentResolver.ATTACHMENT_TYPE_MEDIA
},
editable() {
return this.editor.isEditable
},
showDeleteIcon() {
return this.editable && this.showIcons
return this.isEditable && this.showIcons
},
showImageDeleteIcon() {
return this.showDeleteIcon && !this.isMediaAttachment
Expand Down Expand Up @@ -270,6 +268,10 @@ export default {
},
},
beforeMount() {
this.isEditable = this.editor.isEditable
this.editor.on('update', ({ editor }) => {
this.isEditable = editor.isEditable
})
if (!this.isSupportedImage) {
// TODO check if hasPreview and render a file preview if available
this.failed = true
Expand Down

0 comments on commit c8efdf6

Please sign in to comment.