Skip to content

Fix support for SVG in rich text#24582

Closed
stokesman wants to merge 2 commits intoWordPress:trunkfrom
stokesman:update/support-svg-in-rich-text
Closed

Fix support for SVG in rich text#24582
stokesman wants to merge 2 commits intoWordPress:trunkfrom
stokesman:update/support-svg-in-rich-text

Conversation

@stokesman
Copy link
Copy Markdown
Contributor

Description

Fixes support for SVG in RichText by adding simple logic to element/attribute creation for the use of createElementNS and setAttributeNS where appropriate. Adds a couple of test cases to cover expected behavior. Changes were made intending to do the simplest thing that could work for most use cases and not to fully support all SVG markup.

Why

To enable SVG icons in rich text. Presently, adding SVG markup is possible and it will display properly on the frontend, but in the block editor, it does not display due to the elements being created without namespacing.

Demonstration

I've made a gist of a plugin that allows easy reproduction of the issue (also works to just run the JS in the console while on an editor screen). It adds a button to the rich text toolbar for inserting sample SVG markup.

How has this been tested?

Ran unit tests. Ran e2e tests with WordPress 5.4.2. Rich text related tests all passed.

Types of changes

Bugfix and added tests

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR.

@stokesman stokesman force-pushed the update/support-svg-in-rich-text branch from 50f8a86 to 0ca1aea Compare September 17, 2020 16:48
@skorasaurus skorasaurus added the [Package] Rich text /packages/rich-text label Dec 6, 2020
@etoledom etoledom removed their request for review December 8, 2020 16:38
Base automatically changed from master to trunk March 1, 2021 15:43
@guarani guarani removed their request for review February 7, 2022 18:52
@stokesman
Copy link
Copy Markdown
Contributor Author

This is now #40496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Rich text /packages/rich-text

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants