如何让CKEditor在段落中插入列表?
How to make CKEditor insert list into paragraph?
我在 CKEditor 中有一些段落,我想在其中插入项目符号列表。
但这似乎是不可能的:单击列表图标将我的段落变成列表,但不会将列表插入现有段落。
所以我必须切换到源代码模式才能手动完成。
如何让CKEditor将新的列表插入到已有的段落中?
无法将列表插入每个段落 HTML specification:
A p element's end tag can be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element
此外,浏览器将 <p><ul></ul></p>
替换为 <p></p><ul></ul><p></p>
,因此确实无法做到这一点。所以CKEditor 4不允许。
规范中还有一个示例如何 link 带有列表的段落,在 "Note" 部分:
<p>For instance, this fantastic sentence has bullets relating to</p>
<ul>
<li>wizards,
<li>faster-than-light travel, and
<li>telepathy,
</ul>
<p>and is further discussed below.</p>
我在 CKEditor 中有一些段落,我想在其中插入项目符号列表。
但这似乎是不可能的:单击列表图标将我的段落变成列表,但不会将列表插入现有段落。 所以我必须切换到源代码模式才能手动完成。
如何让CKEditor将新的列表插入到已有的段落中?
无法将列表插入每个段落 HTML specification:
A p element's end tag can be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, section, table, or ul element
此外,浏览器将 <p><ul></ul></p>
替换为 <p></p><ul></ul><p></p>
,因此确实无法做到这一点。所以CKEditor 4不允许。
规范中还有一个示例如何 link 带有列表的段落,在 "Note" 部分:
<p>For instance, this fantastic sentence has bullets relating to</p>
<ul>
<li>wizards,
<li>faster-than-light travel, and
<li>telepathy,
</ul>
<p>and is further discussed below.</p>