Skip to content

Commit

Permalink
docs: 完善注释
Browse files Browse the repository at this point in the history
  • Loading branch information
donaldshen committed May 16, 2019
1 parent 0282413 commit 9b56c9d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/v-editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,17 @@ export default {
editor.customConfig.onchangeTimeout =
this.editorOptions.onchangeTimeout || defaultEditorOptions.onchangeTimeout // 单位 ms
// NOTE: 输入内容为空时,返回空字符串。空的quote和table都算内容为空
editor.customConfig.onchange = html => {
// NOTE: 输入内容为空时,返回空字符串。空的quote和table都算内容为空
// WARNING: editor.txt.text()返回的是去掉标签的html内容
// 这意味着空table的时候返回一堆'&nbsp...'
// WARNING: 斜体和加粗会往内容中插入'zero width space',会干扰空值判断
// NOTE: 不要使用editor.txt.text()
// editor.txt.text()返回的是去掉标签的html内容
// 这意味着空格变成&nbsp,无法被trim
const noText = !editor.$textElem[0].textContent
.trim()
// NOTE: 斜体和加粗会往内容中插入'zero width space',会干扰空值判断
.replace(/\u200b/g, '')
// WARNING: 注意只有图片的情况
// NOTE: 注意只有图片的情况
const noImg = !html.includes('img')
this.$emit('input', noText && noImg ? '' : html)
}
Expand Down

0 comments on commit 9b56c9d

Please sign in to comment.