Add option to keep existing IDs

Created on 6 February 2024, 11 months ago
Updated 26 June 2024, 6 months ago

Problem/Motivation

This filter works well to set IDs on headings, but when a heading in content already has an ID on it, the existing ID is replaced with a new automatically generated one, which is not always desirable.

EG, we'd like to be able to let users set their own IDs, or migrate in content that already uses IDs, and keep the existing ID values in place.

Steps to reproduce

Set up a filter format that uses the filter provided by this module. Add a heading with an ID in content, with an ID that doesn't match the heading text. The existing ID will be changed to match the heading text.

Proposed resolution

Add an option to preserve existing IDs to the filter.

Remaining tasks

None

User interface changes

New settings form in the filter.

API changes

None

Data model changes

None

Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom rupertj Bristol, UK

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

Merge Requests

Comments & Activities

  • Issue created by @rupertj
  • Status changed to Needs review 11 months ago
  • 🇬🇧United Kingdom rupertj Bristol, UK

    Uploading a patch that implements a setting to keep existing IDs when filtering.

  • 🇦🇺Australia pingers

    Can you please add a test case for this?

  • 🇬🇧United Kingdom rupertj Bristol, UK

    Good call. Here's a updated patch with a unit test for the new option.

  • Status changed to RTBC 8 months ago
  • 🇧🇪Belgium dieterholvoet Brussels

    I was looking for the same thing in order to make this module work with the CKEditor ID Attributes module . The latest patch does the job, after enabling the new option in the text format.

  • 🇦🇺Australia pingers

    Thanks! I'd like to verify in our build, then I'll happily merge.

  • 🇨🇦Canada ryanrobinson_wlu

    This works for me. I've just started testing the module with this patch, and everything is good so far.

  • 🇨🇦Canada ryanrobinson_wlu

    After updating to Drupal 10.3, with this patch installed and its functionality in use on two existing text formats, I'm getting this error when I try to save a new text format:

    'keep_existing_ids' is not a supported key.
    

    It does not matter if the new format has the "Automatically apply identifiers (anchors) to headings in content" filter is enabled or not. The error occurs either way.

    Removing the patch does fix it, which makes sense since that key identified is pretty clearly tied to this patch.

    I'm not sure what the fix is - is there something else that needs to be done to declare that key as supported?

  • Merge request !3Resolve #3419508 "Add option to" → (Open) created by dieterholvoet
  • Status changed to Needs review 6 months ago
  • 🇧🇪Belgium dieterholvoet Brussels

    I added the necessary config schema. Should be fixed in the MR.

  • 🇨🇦Canada ryanrobinson_wlu

    Thank you. I think that's good again. I tested with the patch option (not overriding existing) still on, removing the patch option, and removing having the filter entirely. No errors from any of them.

  • Status changed to RTBC 6 months ago
Production build 0.71.5 2024