Skip to content

Conversation

@danigirl329
Copy link
Member

@danigirl329 danigirl329 commented Dec 19, 2025

This pull request updates the AssetTagBuilder CKEditor 5 plugin to improve how custom r:asset:image tags are handled in both the editor's data model and its HTML output. The main focus is on normalizing the tag structure to ensure consistent handling of self-closing and paired tags, as well as updating the way these tags are rendered in the editor.

Asset Tag Normalization and Conversion Improvements:

  • Added a _defineDataNormalization method to ensure that all <r:asset:image> tags are normalized to paired tags when loading into the editor, and converted back to self-closing tags (with whitespace cleanup) when exporting data. This helps avoid inconsistencies between self-closing and paired tag formats. (F0951dbcL87, app/assets/builds/trusty_cms/ckeditor5.jsL103144-R103179)

  • Updated the upcast converter to use writer.createContainerElement('r:asset:image', attrs) instead of createEmptyElement, ensuring the tag is always treated as a container in the model. [1] [2]

  • Remove special characters from the menu bar

  • Add CSS to show a placeholder for asset tags on the front end of the editor.
    Plugin Initialization:

  • Registered the new normalization logic in the plugin's init method, so it's always applied when the plugin is loaded. [1] [2]

These changes make the handling of custom asset tags more robust and consistent, reducing the risk of malformed HTML or unexpected editor behavior. Reducing the risk of overwriting content in the editor view, which overwrites the content on saving.

@danigirl329
Copy link
Member Author

Screenshot 2025-12-22 at 10 18 32 AM Screenshot 2025-12-22 at 10 18 38 AM

@danigirl329 danigirl329 marked this pull request as ready for review December 22, 2025 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants