Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

Fix loss of caret on image insertion in campaign from popup

Kailash Nadh2143def13657
diff --git a/frontend/src/components/Editor.vue b/frontend/src/components/Editor.vue
index efcda328..3b7d961f 100644
--- a/frontend/src/components/Editor.vue
+++ b/frontend/src/components/Editor.vue
@@ -95,6 +95,11 @@ export default {
radioFormat: this.contentType,
},
+ // Last position of the cursor in the editor before the media popup
+ // was opened. This is used to insert media on selection from the poup
+ // where the caret may be lost.
+ lastSel: null,
+
// Quill editor options.
options: {
placeholder: 'Content here',
@@ -189,15 +194,12 @@ export default {
},
toggleMedia() {
+ this.lastSel = this.$refs.quill.quill.getSelection();
this.isMediaVisible = !this.isMediaVisible;
},
onMediaSelect(m) {
- const sel = this.$refs.quill.quill.getSelection();
- if (!sel) {
- return;
- }
- this.$refs.quill.quill.insertEmbed(sel.index, 'image', m.url);
+ this.$refs.quill.quill.insertEmbed(this.lastSel.index || 0, 'image', m.url);
},
},