Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/files-modal.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.

17 changes: 14 additions & 3 deletions src/components/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import { mapActions, mapState } from 'vuex'
import escapeHtml from 'escape-html'
import { getCurrentUser } from '@nextcloud/auth'
import { loadState } from '@nextcloud/initial-state'
import { emit } from '@nextcloud/event-bus'
import { emit, subscribe, unsubscribe } from '@nextcloud/event-bus'
import { Collaboration } from '@tiptap/extension-collaboration'
import { CollaborationCursor } from '@tiptap/extension-collaboration-cursor'
import { Doc } from 'yjs'
Expand Down Expand Up @@ -318,6 +318,8 @@ export default {
window.addEventListener('beforeprint', this.preparePrinting)
window.addEventListener('afterprint', this.preparePrinting)
}
subscribe('text:image-node:add', this.onAddImageNode)
subscribe('text:image-node:delete', this.onDeleteImageNode)
this.$parent?.$emit('update:loaded', true)
},
created() {
Expand All @@ -332,6 +334,8 @@ export default {
window.removeEventListener('beforeprint', this.preparePrinting)
window.removeEventListener('afterprint', this.preparePrinting)
}
unsubscribe('text:image-node:add', this.onAddImageNode)
unsubscribe('text:image-node:delete', this.onDeleteImageNode)
this.$providers.forEach(p => p.destroy())
},
methods: {
Expand Down Expand Up @@ -581,7 +585,6 @@ export default {
},

onError({ type, data }) {

this.$nextTick(() => {
this.$editor?.setEditable(false)
this.$emit('sync-service:error')
Expand Down Expand Up @@ -658,15 +661,23 @@ export default {
this.$emit('sync-service:save')
})
},

onFocus() {
this.$emit('focus')
},
onBlur() {
this.$emit('blur')
},

async close() {
onAddImageNode() {
this.$parent.$emit('add-image-node')
},

onDeleteImageNode(imageUrl) {
this.$parent.$emit('delete-image-node', imageUrl)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not blocking but maybe we can annotate those through emits though I'm not sure if that necessary the right place since we emit on the parent

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably the wrong place, as it's actually the parent that emits the event, no? Maybe something to look into for all emits at once before migrating to Vue 3.

},

async close() {
if (this.currentSession && this.$syncService) {
try {
await this.$syncService.close()
Expand Down
3 changes: 3 additions & 0 deletions src/components/Editor/MediaHandler.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<script>
import { getCurrentUser } from '@nextcloud/auth'
import { showError } from '@nextcloud/dialogs'
import { emit } from '@nextcloud/event-bus'
import { logger } from '../../helpers/logger.js'

import {
Expand Down Expand Up @@ -212,6 +213,8 @@ export default {

// Scroll image into view
this.$editor.commands.scrollIntoView()

emit('text:image-node:add', null)
},
},
}
Expand Down
13 changes: 9 additions & 4 deletions src/nodes/ImageView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
class="buttons">
<NcButton :aria-label="t('text', 'Delete this attachment')"
:title="t('text', 'Delete this attachment')"
@click="deleteNode">
@click="onDelete">
<template #icon>
<DeleteIcon />
</template>
Expand Down Expand Up @@ -86,7 +86,7 @@
class="image__caption__delete">
<NcButton :aria-label="t('text', 'Delete this image')"
:title="t('text', 'Delete this image')"
@click="deleteNode">
@click="onDelete">
<template #icon>
<DeleteIcon />
</template>
Expand Down Expand Up @@ -133,9 +133,10 @@ import axios from '@nextcloud/axios'
import ClickOutside from 'vue-click-outside'
import { NcButton } from '@nextcloud/vue'
import ShowImageModal from '../components/ImageView/ShowImageModal.vue'
import store from './../mixins/store.js'
import { useAttachmentResolver } from './../components/Editor.provider.js'
import store from '../mixins/store.js'
import { useAttachmentResolver } from '../components/Editor.provider.js'
import { mimetypesImages as IMAGE_MIMES } from '../helpers/mime.js'
import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import { NodeViewWrapper } from '@tiptap/vue-2'
import { logger } from '../helpers/logger.js'
Expand Down Expand Up @@ -359,6 +360,10 @@ export default {
this.imageIndex = this.embeddedImagesList.findIndex(image => image.relativePath === src)
this.showImageModal = true
},
onDelete() {
emit('text:image-node:delete', this.imageUrl)
this.deleteNode()
},
},
}
</script>
Expand Down