How to preserve a custom HTML tag

Created on 26 March 2024, 9 months ago

Problem/Motivation

I am trying to add support for a simple tag so it's preserved in CKEditor 5

I read #3335991-10: [upstream] [GHS] CKEditor 5 does not retain custom HTML tags that are not defined by CKEditor 5 plugins whenever /.*/ is not allowed (e.g. when filter_html is enabled) and ended up here copying the starterkit

Steps to reproduce

I've copied the starter template and modified:

MODULE.ckeditor5.yml

    elements:
      - <foo>

simpleboxediting.js

  _defineConverters() {
    // Converters are registered via the central editor object.
    const { conversion } = this.editor;

    conversion.for('upcast').elementToElement({
      model: 'foo',
      view: {
        name: 'foo',
      },
    });
  • Run webpack to reflect changes
  • Text format full html with ckeditor5 enabled, "SimpleBox Demo" and "Source" in Active Toolbar
  • /node/add/page - switch to Source
  • enter "test"
  • toggle "Source"
  • CKEditor is empty, markup contains:
<span data-ck-unsafe-element="foo"></span>

Remaining tasks

  • Explain what else needs to be changed for preserving a custom HTML tag when using the starterkit as a workaround (e.g. I need to preserve `drupal-entity`, `drupal-entity[data-align=left]`, `drupal-entity[data-align=right]`
💬 Support request
Status

Postponed

Version

1.0

Component

Documentation

Created by

miiimooo Europe

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

Comments & Activities

Production build 0.71.5 2024