Merged
Conversation
jorgemanrubia
approved these changes
Jan 9, 2026
Member
jorgemanrubia
left a comment
There was a problem hiding this comment.
Superb work @samuelpecher. The suite is failing but good to go from my side 👏
c64d998 to
b300b4b
Compare
Collaborator
Author
I suspect this is a difference with GH action's environment. I'll see if I can make it work before mocking it out. |
* Allow configuration of highlighting * Filter for PASTE_TAG during node generation * StyleCanonicalizer object caches canonical style for speed
Requires lazy-loading the buttons on first toggle if the dropdown connects before the editor is connected
Now that the first interaction called on the editor, the selection is at the end.
b300b4b to
63fd7bd
Compare
samuelpecher
commented
Jan 12, 2026
Comment on lines
+76
to
+82
| def highlight_1_rgb | ||
| dark_mode? ? "rgb(240, 200, 22)" : "rgb(136, 118, 38)" | ||
| end | ||
|
|
||
| def dark_mode? | ||
| page.evaluate_script "window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches" | ||
| end |
Collaborator
Author
There was a problem hiding this comment.
@jorgemanrubia This was fun: the headless Chrome instance was picking-up the machine's dark mode setting. Local Omarchy is in dark mode, GH Actions is in light mode. Rather than depart from the pre-configured :selenium_chrome_headless I judo'd and made the test value dynamic.
Member
There was a problem hiding this comment.
OH LOL debugging that must have been fun!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements configuration for the highlighter for both the provided buttons as well as pasted style sanitization and canonicalization.
Highlighter's lexical functions have been packaged into a Lexical extension, registering the components according the the lifecycle phases according to the passed configuration.Highlighterremains to apply the configuration from the editor to the extensions and expose the light interface to the command dispatcher. Commands are routed to the editor via the newTOGGLE_HIGHLIGHT_COMMAND.This suggests a three part structure to layer functionality:
Highlighterhighlight_extensionThe extension structure allows collapsing the fake
HighlightNodeinto just ahtml.importconfiguration. Particularly, the changeTrixContentExtensionhighlights this transition from fake Lexical node to basic extension. Low-level Lexical operations are then moved intohighlight_extension.Since
htmlconfiguration is defined before non-global config is available, the sanitization step is deferred to a Node Transform through the use of Node State marking the node with ahasPastedStylesstate. This has the double advantage that any node subsequently marked by other code leveraging$applyHighlightwill benefit from the sanitization (such asTrixContentExtension).Styles are sanitizes and canonicalized through an extension-scoped persistant
StyleCanonicalizer. This optimization avoids repeating DOM element creation for calculating base RGB(A) values of the allowed styles, which is necessary as pastes have computed RGB(A) values. Lexical's CSS object cache is also leveraged for speed.The config shape (by button/preset) was chosen as it is most likely users will simply want to change the buttons or permit additional colors rather than change both settings for
colororbackground-color.