Skip to content

使用HTMLDeserializer对codeblock进行反序列时,<br/>未正确转换为\n,导致代码未换行 #181

@paul-xiao

Description

@paul-xiao

Description
使用HTMLDeserializer对codeblock进行反序列时,<br/>未正确转换为\n,导致代码未换行,@big-camel 请确认一下呢。

Recording
示例代码如下:

  let domString = `<pre data-line-wrapping="false" data-syntax="plain" data-tab-size="2" data-theme="light" style="font-family:" source="" code="" pro",="" ui-monospace,="" sfmono-regular,="" menlo,="" monaco,="" consolas,="" "liberation="" mono",="" "courier="" new",="" monospace;font-size:14px;line-height:1.5;background-color:#fafafa;color:#232930;border-radius:4px;border:1px="" solid="" rgb(229="" 231="" 235="" 1);padding:4px="" 8px;"="">const count = 0<br><br>count++<br><br>console.log(count)</pre>`
  const document = new DOMParser().parseFromString(domString, 'text/html')
  const html = HTMLDeserializer.transformWithEditor(editor, document.body)
   console.log(html)

Actual Output
image

image

Expected Output
image

[
      {
        lineWrapping: false,
        theme: 'light',
        tabSize: 2,
        language: 'plain',
        code: 'const count = 0\ncount++\nconsole.log(count)',
        id: '1ovmmypwdbhc',
        type: 'codeblock',
        children: [
          {
            text: ''
          }
        ]
      }
    ]

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions