# \`white-space\` CSS 属性在富文本编辑器中粘贴时未被尊重

**URL:** <https://meta.discourse.org/t/white-space-css-property-of-clipboard-data-not-respected-when-pasting-in-rich-text-editor/379035>\
**Category:** Bug\
**Tags:** composer\
**Created:** [2025年八月18日 12:07 UTC](https://meta.discourse.org/t/white-space-css-property-of-clipboard-data-not-respected-when-pasting-in-rich-text-editor/379035 "2025-08-18T12:07:08Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![renato](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/renato/32/383632_2.png) [@renato](https://meta.discourse.org/u/renato)\
**Post date:** [2025年十月21日 13:56 UTC](https://meta.discourse.org/t/white-space-css-property-of-clipboard-data-not-respected-when-pasting-in-rich-text-editor/379035/11 "2025-10-21T13:56:09Z")

</div>

此问题应通过 [FIX: [rich editor] convert newlines to hard breaks when parsed from HTML by renato · Pull Request #35518 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/35518) 修复（尚未合并，仍在等待代码审查）。

我的[第一次尝试](https://github.com/discourse/discourse/pull/35426)是将其转换为代码块，但我认为这过于激进，会导致一些误报。相反，我们只需在粘贴 HTML 的上下文中保留换行符，将它们转换为硬换行符。（感谢 Marijn 对 `prosemirror-model` 的改进：[https://github.com/ProseMirror/prosemirror-model/commit/79e9f2b9497ec3aac70d180aa846267dafa48d9a）](https://github.com/ProseMirror/prosemirror-model/commit/79e9f2b9497ec3aac70d180aa846267dafa48d9a%EF%BC%89)

随着代码工具栏按钮的最新改进，用户应该能够选择带有硬换行的粘贴部分并将其转换为代码块，并且换行符应该会被保留。

---

_[View the full topic](https://meta.discourse.org/t/white-space-css-property-of-clipboard-data-not-respected-when-pasting-in-rich-text-editor/379035)._
