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

在编辑器使用引用中换行并为文字设置颜色会出现无法回显的 bug #539

Open
sksksksskskskssks opened this issue Feb 17, 2025 · 2 comments

Comments

@sksksksskskskssks
Copy link

sksksksskskskssks commented Feb 17, 2025

bug 描述

点击编辑器的引用然后输入任意两行内容(需要换行),再为文字添加上任意颜色,后面再次回显则会出现

Image

你预期的样子是?

正常显示

系统和浏览器及版本号

  • windows 11
  • chrome 133.0.6943.98

wangEditor-next 版本

"@wangeditor-next/editor": "^5.3.11",
"@wangeditor-next/editor-for-vue": "^5.1.14",

demo 能否复现该 bug ?

能/不能

  • demo 能复现成为 Error: Cannot resolve a DOM node from Slate node: {"text":"22222\n3333","color":"rgb(247, 89, 171)"}

Image

在线 demo

vue3 则是双向绑定,将 "<blockquote><span style=\"color: rgb(247, 89, 171);\">22222<br>3333</span>" 内容代码复制然后双向绑定回显则会出现该问题

最小成本的复现步骤

  • 初始化编辑器
  • cv <blockquote><span style="color: rgb(247, 89, 171);">22222<br>3333</span></blockquote> 代码
  • 即可复现

Image

@sksksksskskskssks
Copy link
Author

@cycleccc 我在其他的社区中看到说是设置一个变量记录当前实例,每次回显的时候重新创建一个实例就行了, 但是我测试了还是不行
这是帖子地址 https://blog.csdn.net/akkigg/article/details/130860204

@sksksksskskskssks
Copy link
Author

@cycleccc
这是我测试出来的, 以下是代码
`

<title>Document</title> <style> #editor—wrapper { border: 1px solid #ccc; z-index: 100; /* 按需定义 */ } #toolbar-container { border-bottom: 1px solid #ccc; } #editor-container { height: 500px; } </style>
<script src="https://unpkg.com/@wangeditor-next/editor@latest/dist/index.js"></script> <script>
  const { createEditor, createToolbar } = window.wangEditor

  const editorConfig = {
    // <blockquote><span style="color: rgb(247, 89, 171);">22222<br>3333</span></blockquote>
      placeholder: 'Type here...',
      onChange(editor) {
        const html = editor.getHtml()
        console.log('editor content', html)
        // 也可以同步到 <textarea>
      }
  }

  const editor = createEditor({
      selector: '#editor-container',
      html: '<blockquote><span style="color: rgb(247, 89, 171);">22222<br><br><br><br>3333</span></blockquote>',
      config: editorConfig,
      mode: 'default', // or 'simple'
  })

  const toolbarConfig = {}

  const toolbar = createToolbar({
      editor,
      selector: '#toolbar-container',
      config: toolbarConfig,
      mode: 'default', // or 'simple'
  });
</script> `

以上代码在初始化后会成为以下样式

Image

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

1 participant