尝试支持 Shift+Enter 换行而不是从新段落开始,我使用的是 quill issues/252中的代码示例。我能够在编辑器中实现这一点,但是在使用 quill-delta-to-html 转换器时,段落换行符不会持续存在。只有 quill 能够解析增量并正确识别换行符对象。
样本增量:
{
"ops": [
{
"insert": "TOKYO: Japanese shares closed lower on Thursday, weighed down by worries that a resurgence of Covid-19 infections would lead to an extension of restrictions and slow the economic recovery.\nThe Nikkei share average fell 0.29 "
},
{
"attributes": {
"strike": true
},
"insert": "percent"
},
{
"insert": " to 28,707.04, \nwhile the broader "
},
{
"attributes": {
"strike": true
},
"insert": "Topix"
},
{
"insert": " slipped 0.22 percent to 1,939.21."
},
{
"attributes": {
"linebreak": "true"
},
"insert": "\n"
},
{
"insert": "Japan is likely to extend by two weeks or more coronavirus containment measures in the greater Tokyo area as infection numbers creep up less than a month before the Summer Ol.\nThe sea transport sector fell 3.84 per cent and was the biggest loser among the 33 sector sub-indexes on the Tokyo bourse, with Kawasaki Kisen declining 4.63 per cent, Mitsui OSK Lines losing 3.93 per cent and Nippon Yusen shedding 3.73 per cent.\nFurniture and home improvement goods store operator Nitori rose 2.14 per cent after posting a record quarterly net profit.\nShin-Etsu Chemical advanced 1.32 per cent and was the top gainer among the top 30 core Topix names, followed b ..\nTo provide a consistent editing experience, you need both consistent data and predictable behaviors. The DOM unfortunately lacks both of these. The solution for modern editors is to maintain their own document model to represent their contents. "
},
{
"attributes": {
"link": "https://github.com/quilljs/parchment/"
},
"insert": "Parchment"
},
{
"insert": " is that solution for Quill. It is organized in its own codebase with its own API layer. Through Parchment you can customize the content and formats Quill recognizes, or add entirely new ones.\n\nIn this guide, we will use the building blocks provided by Parchment and Quill to replicate the editor on Medium. We will start with the bare bones of Quill, without any themes, extraneous modules, or formats. At this basic level, Quill only understands plain text. But by the end of this guide, links, videos, and even tweets will be understood.\nRead more at:\n"
},
{
"attributes": {
"link": "https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst"
},
"insert": "https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst"
},
{
"insert": ""
}
]
}
预期的 HTML:
p.linebreak-true {
margin-top: -16px !important;
}
<p>TOKYO: Japanese shares closed lower on Thursday, weighed down by worries that a resurgence of Covid-19 infections would lead to an extension of restrictions and slow the economic recovery.</p>
<p>The Nikkei share average fell 0.29 <s>percent</s> to 28,707.04, </p>
<p class="linebreak-true">while the broader <s>Topix</s> slipped 0.22 percent to 1,939.21.</p>
<p>Japan is likely to extend by two weeks or more coronavirus containment measures in the greater Tokyo area as infection numbers creep up less than a month before the Summer Ol.</p>
<p>The sea transport sector fell 3.84 per cent and was the biggest loser among the 33 sector sub-indexes on the Tokyo bourse, with Kawasaki Kisen declining 4.63 per cent, Mitsui OSK Lines losing 3.93 per cent and Nippon Yusen shedding 3.73 per cent.</p>
<p>Furniture and home improvement goods store operator Nitori rose 2.14 per cent after posting a record quarterly net profit.</p>
<p>Shin-Etsu Chemical advanced 1.32 per cent and was the top gainer among the top 30 core Topix names, followed b ..</p>
<p>To provide a consistent editing experience, you need both consistent data and predictable behaviors. The DOM unfortunately lacks both of these. The solution for modern editors is to maintain their own document model to represent their contents.
<a
href="https://github.com/quilljs/parchment/" rel="noopener noreferrer" target="_blank">Parchment</a> is that solution for Quill. It is organized in its own codebase with its own API layer. Through Parchment you can customize the content and formats Quill recognizes, or add entirely new ones.</p>
<p><br></p>
<p>In this guide, we will use the building blocks provided by Parchment and Quill to replicate the editor on Medium. We will start with the bare bones of Quill, without any themes, extraneous modules, or formats. At this basic level, Quill only understands
plain text. But by the end of this guide, links, videos, and even tweets will be understood.</p>
<p>Read more at:</p>
<p><a href="https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst" rel="noopener noreferrer"
target="_blank">https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst</a></p>
<p><br></p>
实际 HTML:
p.linebreak-true {
margin-top: -16px !important;
}
<p>TOKYO: Japanese shares closed lower on Thursday, weighed down by worries that a resurgence of Covid-19 infections would lead to an extension of restrictions and slow the economic recovery.</p>
<p>The Nikkei share average fell 0.29 <s>percent</s> to 28,707.04, </p>
<p>while the broader <s>Topix</s> slipped 0.22 percent to 1,939.21.</p>
<p>Japan is likely to extend by two weeks or more coronavirus containment measures in the greater Tokyo area as infection numbers creep up less than a month before the Summer Ol.</p>
<p>The sea transport sector fell 3.84 per cent and was the biggest loser among the 33 sector sub-indexes on the Tokyo bourse, with Kawasaki Kisen declining 4.63 per cent, Mitsui OSK Lines losing 3.93 per cent and Nippon Yusen shedding 3.73 per cent.</p>
<p>Furniture and home improvement goods store operator Nitori rose 2.14 per cent after posting a record quarterly net profit.</p>
<p>Shin-Etsu Chemical advanced 1.32 per cent and was the top gainer among the top 30 core Topix names, followed b ..</p>
<p>To provide a consistent editing experience, you need both consistent data and predictable behaviors. The DOM unfortunately lacks both of these. The solution for modern editors is to maintain their own document model to represent their contents.
<a
href="https://github.com/quilljs/parchment/" rel="noopener noreferrer" target="_blank">Parchment</a> is that solution for Quill. It is organized in its own codebase with its own API layer. Through Parchment you can customize the content and formats Quill recognizes, or add entirely new ones.</p>
<p><br></p>
<p>In this guide, we will use the building blocks provided by Parchment and Quill to replicate the editor on Medium. We will start with the bare bones of Quill, without any themes, extraneous modules, or formats. At this basic level, Quill only understands
plain text. But by the end of this guide, links, videos, and even tweets will be understood.</p>
<p>Read more at:</p>
<p><a href="https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst" rel="noopener noreferrer"
target="_blank">https://economictimes.indiatimes.com/markets/stocks/news/nikkei-ends-lower-japanese-shares-slip-as-virus-resurgence-spurs-slowdown-worries/articleshow/84014134.cms?utm_source=contentofinterest&utm_medium=text&utm_campaign=cppst</a></p>
<p><br></p>
由于中间样式节点和使用 npm 包捕获自定义属性不起作用,因此操作 delta 很困难。