Skip to content

Commit

Permalink
fix: 修复从浏览器点击复制后图片粘贴到编辑器图片出现2个bug
Browse files Browse the repository at this point in the history
  • Loading branch information
q378532364 committed Apr 10, 2021
1 parent 45db80b commit 899748b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/text/event-hooks/paste-text-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,13 @@ function pasteTextHtml(editor: Editor, pasteEvents: Function[]) {
// if (!lastEl?.length) return
// editor.selection.moveCursor(lastEl.elems[0])
} else {
editor.cmd.do('insertHTML', html) // html
// 如果用户从百度等网站点击复制得到的图片是一串img标签且待src的http地址
// 见 https://github.com/wangeditor-team/wangEditor/issues/3119
// 如果是走用户定义的图片上传逻辑
const isHasOnlyImgEleReg = /^<img [^>]*src=['"]([^'"]+)[^>]*>$/g
if (!isHasOnlyImgEleReg.test(html)) {
editor.cmd.do('insertHTML', html)
}
}
}
} catch (ex) {
Expand Down

0 comments on commit 899748b

Please sign in to comment.