|
@@ -4,7 +4,7 @@
|
|
|
:is="item.type"
|
|
:is="item.type"
|
|
|
:id="item.id"
|
|
:id="item.id"
|
|
|
@input="handleInput"
|
|
@input="handleInput"
|
|
|
- @keydown.stop="handleKeyDown"
|
|
|
|
|
|
|
+ @keydown="handleKeyDown"
|
|
|
contenteditable
|
|
contenteditable
|
|
|
v-html="item.content"
|
|
v-html="item.content"
|
|
|
>
|
|
>
|
|
@@ -14,12 +14,18 @@
|
|
|
<script>
|
|
<script>
|
|
|
import blockTypeRegs from '../../utils/block-type-regs'
|
|
import blockTypeRegs from '../../utils/block-type-regs'
|
|
|
import { MODIFY_ITEM, ADD_ITEM_AFTER } from '../../store/types/editor-types'
|
|
import { MODIFY_ITEM, ADD_ITEM_AFTER } from '../../store/types/editor-types'
|
|
|
|
|
+import { mapState } from 'vuex'
|
|
|
export default {
|
|
export default {
|
|
|
name: 'editable-item',
|
|
name: 'editable-item',
|
|
|
props: ['item', 'pageId'],
|
|
props: ['item', 'pageId'],
|
|
|
data: function() {
|
|
data: function() {
|
|
|
return {}
|
|
return {}
|
|
|
},
|
|
},
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ ...mapState({
|
|
|
|
|
+ range: state => state.editor.range
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
mounted() {},
|
|
mounted() {},
|
|
|
updated() {},
|
|
updated() {},
|
|
|
methods: {
|
|
methods: {
|
|
@@ -31,6 +37,11 @@ export default {
|
|
|
pageId: this.pageId,
|
|
pageId: this.pageId,
|
|
|
itemId: this.item.id
|
|
itemId: this.item.id
|
|
|
})
|
|
})
|
|
|
|
|
+ requestAnimationFrame(() => {
|
|
|
|
|
+ const focusNode = document.getElementById(this.item.id).nextSibling
|
|
|
|
|
+ focusNode.focus()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
break
|
|
break
|
|
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -53,6 +64,12 @@ export default {
|
|
|
itemId: this.item.id,
|
|
itemId: this.item.id,
|
|
|
diff
|
|
diff
|
|
|
})
|
|
})
|
|
|
|
|
+ requestAnimationFrame(() => {
|
|
|
|
|
+ const selection = window.getSelection()
|
|
|
|
|
+ selection.collapseToEnd()
|
|
|
|
|
+ selection.extend(selection.anchorNode, e.target.textContent.length)
|
|
|
|
|
+ selection.collapseToEnd()
|
|
|
|
|
+ })
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|