Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用 dangerouslyInsertHtml 方法,莫名其妙插入了空行和  字符 #6015

Open
dancci opened this issue Dec 18, 2024 · 2 comments

Comments

@dancci
Copy link

dancci commented Dec 18, 2024

bug 描述

使用 dangerouslyInsertHtml 方法,全选编辑器内容后粘贴,在首行莫名其妙插入了空行里面只有一个  字符

你预期的样子是?

未插入空行和  字符

系统和浏览器及版本号

  • windows11
  • google chrome Version 131.0.6778.140 (Official Build) (64-bit)

wangEditor 版本

"@wangeditor/editor": "^5.1.23",
"@wangeditor/editor-for-vue": "^5.1.10",

demo 能否复现该 bug ?

能/不能

在线 demo

请尽量提供在线 demo (推荐以下网站),帮助我们最低成本复现 bug

最小成本的复现步骤

(请告诉我们,如何最快的复现该 bug)

粘贴文本来源:飞书在线文档表格,单元格内的富文本

<Editor
  v-model="valueHtml"
  :defaultConfig="editorConfig"
  :editorId="editorId"
  :style="editorStyle"
  @custom-paste="handleCustomPaste"
/>

import { Editor, Toolbar } from '@wangeditor/editor-for-vue'

function handleCustomPaste(editor, event, callback) {
const html = event.clipboardData.getData('text/html') // 获取粘贴的 html
const text = event.clipboardData.getData('text/plain') // 获取粘贴的纯文本
const rtf = event.clipboardData.getData('text/rtf') // 获取 rtf 数据(如从 word wsp 复制粘贴)

editor.dangerouslyInsertHtml(html)

// 阻止默认的粘贴行为
event.preventDefault()
callback(false); // 返回 false ,阻止默认粘贴行为
return false
}

@zhangxinGithub
Copy link

解决了吗?

@dancci
Copy link
Author

dancci commented Jan 7, 2025

解决了吗?

没有,因为是自己用的后台,所以就手动删除空行了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants