How do you get the cursor below the template?

Created on 7 June 2024, 6 months ago
Updated 19 July 2024, 4 months ago

If I install the module and add it to my text format, then create a node and only place the "Simple table" in the text area, I can't get the cursor out of the template, below or above it without switching to the source view and adding something above or below there.

Does everyone have this problem?

I also tried ckeditor_template module dev version with the patch for ckeditor5 and I run into the same issue when my template consists of nested divs. See https://www.drupal.org/project/ckeditor_templates/issues/3273358 CKEditor 5 support for Content Templates Needs review

I also realize this is a ckeditor5 issue https://github.com/ckeditor/ckeditor5/issues/10220

There is also a core issue about this https://www.drupal.org/project/drupal/issues/3344462 🐛 [GHS] Allow the cursor to leave s and other HTML elements at document start or end Postponed: needs info

I don't want to duplicate all the other issues, but just wondering if anybody here has found a way around this without switching to the source view?

As of right now I'd say upgrading to ckeditor5 is blocked by this for anybody using ckeditor templates and hiding the source button, no? Which I feel like the point of ckeditor templates is to be able to provide users without Source view or knowledge with some custom HTML behind the scenes that they don't need to understand.

💬 Support request
Status

Closed: works as designed

Version

1.0

Component

User interface

Created by

🇨🇦Canada porchlight

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @porchlight
  • 🇩🇪Germany dbielke1986

    Hi porchlight,

    Can you please check the linked items? I already mentioned the following answer in issue 3402691 💬 Inserted HTML template goes wrong Closed: works as designed .

    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>&nbsp;</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><p>&nbsp;</p>"
        },
        {
            "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><p>&nbsp;</p>"
        } 
    ] 
  • 🇨🇦Canada porchlight

    @dbielke1986 Nice! Thanks for the suggestion! That kinda solves it, but I think it creates other issues?

    1. it prints an empty <p> tag in the textarea on the front-end page.
    2. if you move your cursor to that <p> tag and then hit backspace, you erase that <p> tag and then you can get stuck in the template again
    3. doesn't take into account textareas that already exist using these templates. If a textarea ends in one of these templates currently without the <p> then you still cannot get below the template.

    Not trying to take it out on you! I know it's a ckeditor issue and I appreciate the suggestion; I just don't think that's going to be enough to appease my end-users.

  • Status changed to Closed: works as designed 5 months ago
  • 🇩🇪Germany dbielke1986

    @porchlight

    You are absolutely right. All the points mentioned are correct and must be taken into account.
    And you are also right to say that this is a CKEditor issue that we cannot solve on the module side.

    The

    is a WorkAround that at least helps to get out of the

    .

    I would close the issue as we cannot make any code changes and it is not a bug in the module.
    Would that be ok for you? If not, please just open it again.

  • 🇨🇦Canada porchlight

    @dbielke1986 that's totally fair. I figured it wasn't something we could solve in this module but was hoping maybe somebody had some trick to get around it. Anyways, all good. I'll monitor the other issues for a fix. I also noticed the ckeditor plugin pack https://www.drupal.org/project/ckeditor5_plugin_pack has templates that may work, but not available until Drupal 10.3, so worse comes to worst I can wait for that. You can play with the templates on the ckeditor demo page https://ckeditor.com/docs/ckeditor5/latest/features/template.html - it looks like they incorporate widget functionality somehow.

  • 🇨🇦Canada porchlight

    Tested the templates provided by https://www.drupal.org/project/ckeditor5_plugin_pack and they have the same issue...

Production build 0.71.5 2024