Skip to content

Commit

Permalink
feat: 修复当编辑区没内容时,上传一张图片,删除后鼠标位置的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Gavin-yh committed Aug 4, 2021
1 parent f683830 commit 2fec14e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/text/event-hooks/del-to-keep-p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ function deleteToKeepP(editor: Editor, deleteUpEvents: Function[], deleteDownEve
const html = editor.$textElem.html()
const text = editor.$textElem.text()
const txtHtml = html.trim()
/**
@description
如果编辑区清空的状态下,单单插入一张图片,删除图片后,会存在空的情况:'<p data-we-empty-p=""></p>'
需要包含这种边界情况
**/

const emptyTags: string[] = ['<p><br></p>', '<br>', '<p data-we-empty-p=""></p>', EMPTY_P]

const emptyTags: string[] = ['<p><br></p>', '<br>', EMPTY_P]
// 编辑器中的字符是""或空白,说明内容为空
if (/^\s*$/.test(text) && (!txtHtml || emptyTags.includes(txtHtml))) {
// 内容空了
Expand Down

0 comments on commit 2fec14e

Please sign in to comment.