Skip to content

Commit

Permalink
🐛 修复刚打开编辑器不选中编辑框点击改变背景色会报错的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-lcs committed Nov 11, 2019
1 parent e7f731f commit 9837a68
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/AEditor/src/components/foreColor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
</template>

<script>
// import placeCaretAtEnd from '../../utils/placeCaretAtEnd'
import { Chrome as colorPicker } from 'vue-color'
import setPreviousRange from '../../utils/setPreviousRange'
export default {
Expand All @@ -36,8 +35,10 @@ export default {
this.preSelection = window.getSelection()
this.containsEditor = this.preSelection.containsNode(this.cureditor, true)
const range = document.createRange()
range.setStart(this.preSelection.getRangeAt(0).startContainer, this.preSelection.getRangeAt(0).startOffset)
range.setEnd(this.preSelection.getRangeAt(0).endContainer, this.preSelection.getRangeAt(0).endOffset)
if (window.getSelection().rangeCount >= 1) {
range.setStart(this.preSelection.getRangeAt(0).startContainer, this.preSelection.getRangeAt(0).startOffset)
range.setEnd(this.preSelection.getRangeAt(0).endContainer, this.preSelection.getRangeAt(0).endOffset)
}
this.range = range
this.$refs['fore-color-block'].style.display = this.$refs['fore-color-block'].style.display === 'block' ? 'none' : 'block'
},
Expand Down

0 comments on commit 9837a68

Please sign in to comment.