Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exclude callback to bypass replacing emojis in certain HTML elements #587

Open
azaozz opened this issue Feb 1, 2023 · 1 comment
Open

Comments

@azaozz
Copy link

azaozz commented Feb 1, 2023

When replacing emojis with images in a whole HTML document, there may be areas/elements that need to be excluded from processing. For example: inline editors or elements with contentEditable. Ideally in such elements emoji characters would not be replaced. The replacement should happen when the edited content is displayed.

A nice way to control which HTML elements should be excluded from processing would probably be to have a callback function (that would return true/false) in the while loop in grabAllTextNodes().

I've considered using VS15 (U+FE0E) to force text presentation, however that is not suitable for use in inline editors/contentEditable. The requirement there is for emoji characters to be kept unchanged as the users have entered them.

@azaozz
Copy link
Author

azaozz commented Feb 1, 2023

There is a (pretty crude) example of how that can be implemented: WordPress/wordpress-develop#3800. Note that the patch there is a "hotfix" to implement the above feature in the built twemoji.js. Can make a proper PR if needed.

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

No branches or pull requests

1 participant