Support id and hreflang in WYSIWYG UI without requiring source editing

Created on 13 February 2025, about 2 months ago

Problem/Motivation

We don't want to give staff source editing capability. This would help ensure accessible content formatting, a consistent website look, and maintainability when HTML-savvy staff responsible for particular pages are succeeded by non-HTML-savvy staff. We also want staff to be able to easily add jump (anchor) links to a page. However, it appears certain features are only available with source editing.

Steps to reproduce

1. Go to Simplytest.me
2. Create a site in Drupal core 11.x-dev.
3. Go to /admin/config/content/formats/manage/basic_html
4. Note content of fields listing tags.

Result:

Source editing, Manually editable HTML tags contains:
<cite> <dl> <dt> <dd> <a hreflang> <blockquote cite> <ul type> <ol type> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>

Limit allowed HTML tags and correct faulty HTML, Allowed HTML tags contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>

5. Drag the Source (last) icon from Active Toolbar to Available Buttons.

Desired result:

Limit allowed HTML tags and correct faulty HTML, Allowed HTML tags contains:
<br> <p> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id> <cite> <dl> <dt> <dd> <a hreflang href> <blockquote cite> <ul type> <ol start type> <strong> <em> <code> <li> <img src alt data-entity-uuid data-entity-type height width data-caption data-align>

Additionally, there is some way to configure whether hreflang can be set to UN languages, website languages, or all Drupal languages.

Actual result:

Limit allowed HTML tags and correct faulty HTML, Allowed HTML tags contains:
<br> <p> <h2> <h3> <h4> <h5> <h6> <strong> <em> <code> <blockquote> <a href> <ul> <ol start> <li> <img src alt height width data-entity-uuid data-entity-type data-caption data-align>

6. Click Save configuration
7. Go to /node/add/page
8. If the text format is not set to Basic page, then set it to Basic page
9. In the body field, type: Heading 2
10. Select the text Heading 2

Desired result: There is some manner of pop-up consistent with the WYSIWYG which allows you to enter an ID for that heading.

Actual result: There is no way to enter an ID for the heading in order to provide anchors on the page.

11. In the body field, type: This is a link
12. Select the word link
13. Click the link icon in the WYSIWYG toolbar

Desired result: There is a Link URL field, followed by Link Target Language, a dropdown for hreflang.

Actual result: There is no way to enter an hreflang attribute.

Proposed resolution

Provide a facility to enter the ID attribute on headings and the hreflang attribute on links in the WYSIWYG without requiring direct source editing.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Active

Version

11.1 πŸ”₯

Component

ckeditor5.module

Created by

πŸ‡ΊπŸ‡ΈUnited States charles belov San Francisco, CA, US

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

Comments & Activities

Production build 0.71.5 2024