mirror of
https://framagit.org/les/gancio.git
synced 2025-02-01 00:52:01 +01:00
fix links and blur/focus strategy in Editor
This commit is contained in:
parent
a404f42ed7
commit
716f9ac5fd
1 changed files with 24 additions and 7 deletions
|
@ -55,8 +55,11 @@
|
||||||
v-icon mdi-format-list-bulleted
|
v-icon mdi-format-list-bulleted
|
||||||
|
|
||||||
v-btn(icon text tabindex='-1' :class='{ primary: isActive.link() }'
|
v-btn(icon text tabindex='-1' :class='{ primary: isActive.link() }'
|
||||||
@click='commands.link({href: ""}); $refs.link.focus(); linkActive=true')
|
@click='commands.link({href: getMarkAttrs("link") && getMarkAttrs("link").href ? "" : "https://"}); $refs.link.focus();')
|
||||||
v-icon mdi-link
|
v-icon mdi-link
|
||||||
|
v-text-field.pt-0.ml-1(v-show='isActive.link()' ref='link' @focus='focus' @blur='blur' hide-details
|
||||||
|
:value='isActive.link() && getMarkAttrs("link") && getMarkAttrs("link").href || ""'
|
||||||
|
@keypress.enter='commands.link({ href: $event.target.value}); editor.focus()')
|
||||||
|
|
||||||
editor-content.content(:editor='editor' spellcheck='false' :style="{ 'max-height': maxHeight }")
|
editor-content.content(:editor='editor' spellcheck='false' :style="{ 'max-height': maxHeight }")
|
||||||
</template>
|
</template>
|
||||||
|
@ -97,6 +100,7 @@ export default {
|
||||||
options: [],
|
options: [],
|
||||||
linkActive: false,
|
linkActive: false,
|
||||||
editor: null,
|
editor: null,
|
||||||
|
blurring: false,
|
||||||
update: false,
|
update: false,
|
||||||
focused: ''
|
focused: ''
|
||||||
}
|
}
|
||||||
|
@ -112,12 +116,8 @@ export default {
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
this.editor = new Editor({
|
this.editor = new Editor({
|
||||||
onFocus: () => {
|
onFocus: () => this.focus(),
|
||||||
this.focused = 'editor--focused'
|
onBlur: () => this.blur(),
|
||||||
},
|
|
||||||
onBlur: () => {
|
|
||||||
this.focused = ''
|
|
||||||
},
|
|
||||||
onUpdate: _.debounce(({ getHTML }) => {
|
onUpdate: _.debounce(({ getHTML }) => {
|
||||||
this.update = true
|
this.update = true
|
||||||
this.$emit('input', getHTML())
|
this.$emit('input', getHTML())
|
||||||
|
@ -150,6 +150,23 @@ export default {
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
if (this.editor) { this.editor.destroy() }
|
if (this.editor) { this.editor.destroy() }
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
blur () {
|
||||||
|
this.blurring = true
|
||||||
|
window.setTimeout(() => {
|
||||||
|
if (this.blurring) {
|
||||||
|
this.focused = ''
|
||||||
|
this.blurring = false
|
||||||
|
}
|
||||||
|
}, 200)
|
||||||
|
},
|
||||||
|
focus () {
|
||||||
|
this.focused = 'editor--focused'
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.blurring = false
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in a new issue