ant-design / pro-editor

🕹️ The Ultimate Editor UI Framework and Components
https://pro-editor.antdigital.dev
MIT License
189 stars 23 forks source link

[Bug] DOMPurify.sanitize在运行时报错(void 0) is not a function #177

Closed misakayao closed 3 months ago

misakayao commented 4 months ago

💻 系统环境 | Operating System

Windows

🌐 浏览器 | Browser

Chrome

🐛 问题描述 | Bug Description

1.1.1版本在使用vite打包时会有如下异常:

node_modules/@ant-design/pro-chat/node_modules/@ant-design/pro-editor/es/Highlight/hooks/useShiki.js (52:23): "sanitize" is not exported by "node_modules/dompurify/dist/purify.es.mjs", imported by "node_modules/@ant-design/pro-chat/node_modules/@ant-design/pro-editor/es/Highlight/hooks/useShiki.js".

代码运行时执行到 return DOMPurify.sanitize("<pre><code>".concat(content, "</code></pre>"));会直接抛异常

image

🚦 期望结果 | Expected Behavior

No response

📷 复现步骤 | Recurrence Steps

No response

📝 补充信息 | Additional Information

No response

life88 commented 4 months ago

也遇到同样的问题,网上看了一圈大概意思是 DOMPurify 需要使用import DOMPurify from 'dompurify' 的方式导入,使用 import * as DOMPurify from 'dompurify'的导入方式会出现这个问题。

目前我的解决方式是暂时先自定义了一个 chatItemRenderConfig.contentRender。我用的 pro-chat@1.12.2 的版本

ONLY-yours commented 3 months ago

sloved in 1.2.0