diff --git a/src/components/App.vue b/src/components/App.vue index e9e1b7aa..f8e72d42 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -21,6 +21,10 @@ import store from '../store'; Vue.directive('focus', { inserted(el) { el.focus(); + const value = el.value; + if (value && el.setSelectionRange) { + el.setSelectionRange(0, value.length); + } }, }); diff --git a/src/components/CodeEditor.vue b/src/components/CodeEditor.vue index 34658aa5..8111faf6 100644 --- a/src/components/CodeEditor.vue +++ b/src/components/CodeEditor.vue @@ -16,11 +16,11 @@ export default { } if (scrollElt) { const clEditor = cledit(preElt, scrollElt); + clEditor.on('contentChanged', value => this.$emit('changed', value)); clEditor.init({ content: this.value, sectionHighlighter: section => Prism.highlight(section.text, Prism.languages[this.lang]), }); - clEditor.on('contentChanged', value => this.$emit('changed', value)); clEditor.toggleEditable(!this.disabled); } }, diff --git a/src/components/Layout.vue b/src/components/Layout.vue index 749626ba..d64fbf64 100644 --- a/src/components/Layout.vue +++ b/src/components/Layout.vue @@ -1,5 +1,5 @@