- Issue created by @kentaono
- 🇯🇵Japan kentaono
Hello all,
I have tried pasting the above two HTML codes in CKEditor5 source mode and had no problems pasting them manually. - 🇩🇪Germany dbielke1986
Can confirm this behavior - we will take a look at it.
Thanks for reporting! - Status changed to Closed: works as designed
about 1 year ago 8:20am 20 November 2023 - 🇩🇪Germany dbielke1986
The reason for this is a standard behavior of the CKEditor. If you insert the heading, you remain in the current DIV.
You can reproduce this by simply switching to a new line after inserting the first heading and continuing to write there. Here you remain in the current DIV. The following template is therefore also inserted within the first DIV.
You can solve this by adapting your templates as follows (add the "
<p> </p>
" after the template-div):[ { "title": "Heading2", "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1. 1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z\"/></svg>", "description": "Insert heading2 tags for this site.", "html": "<div class=\"o-title__border\"><h2 class=\"o-title__xl\">Heading2</h2></div><strong><p> </p></strong>" }, { "title": "Heading3", "icon": "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"24\" height=\"24\" viewBox=\"0 0 24 24\"><path d=\"M8 16h8v2H8zm0-4h8v2H8zm6-10H6c-1. 1 0-2 .9-2 2v16c0 1.1.89 2 1.99 2H18c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z\"/></svg>", "description": "Insert heading3 tags for this site.", "html": "<div class=\"o-title__border2\"><h3 class=\"o-title__l\">Headingr3</h3></div><strong><p> </p></strong>" } ]
- 🇯🇵Japan kentaono
Hello Daniel,
Thanks for the reply.
I followed your advice and wrote the template and was able to insert the tags as intended. - 🇩🇪Germany dbielke1986
This "trapped cursor" thing is an issue with CKEditor 5 in general, as reported here in core: [GHS] Allow the cursor to leave divs and other HTML elements at document start or end (3344462) 🐛 [GHS] Allow the cursor to leave s and other HTML elements at document start or end Postponed: needs info and upstream on CKEditor's github: [GHS] It is not possible to leave DIV element #10220 back in 2021 with sadly little movement. It happens whenever you try and use a
<div>
(or simmilar) in CKEditor 5.