Skip to content

Tiptap RTE: Include Tiptap's default styles#19805

Merged
AndyButland merged 2 commits intomainfrom
v16/improvement/tiptap-disable-injectcss
Jul 29, 2025
Merged

Tiptap RTE: Include Tiptap's default styles#19805
AndyButland merged 2 commits intomainfrom
v16/improvement/tiptap-disable-injectcss

Conversation

@leekelleher
Copy link
Member

Description

By default the Tiptap editor would include its default CSS to the current document, e.g. window.document. However these would never be applied to the shadow DOM of the <input-tiptap> component, so never used.

By adding them to our "rte-content.css" file, we can include them in the RTE.

To note, one of the rules .ProseMirror-hideselection * { caret-color: transparent; } will resolve issue #19791.

How to test?

Try out the Tiptap RTE with and without this patch, are there any notable differences? (hopefully not)

To test out issue #19791, add a non-inline Block element to the RTE, then use keyboard navigation to select the Block. Before this patch, the cursor caret would be on the next line. After the patch, the caret is not visible when the Block is selected.

This option would inject the default CSS styles into
the `window.document`, which are never applied to
the component's shadow DOM.
The `caret-color` rule (line 93) resolves issue #19791.
Copilot AI review requested due to automatic review settings July 28, 2025 11:30
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue where Tiptap's default CSS styles were not being applied to the Tiptap RTE component due to shadow DOM isolation. The solution disables Tiptap's automatic CSS injection and manually includes the necessary styles.

  • Disables Tiptap's automatic CSS injection (injectCSS: false) since it doesn't work with shadow DOM
  • Manually includes Tiptap's default styles in the RTE content CSS file
  • Fixes issue #19791 where cursor caret visibility was problematic with block elements

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
input-tiptap.element.ts Disables automatic CSS injection from Tiptap editor
rte-content.css Adds manually copied default Tiptap styles with proper shadow DOM support

@leekelleher leekelleher linked an issue Jul 28, 2025 that may be closed by this pull request
Copy link
Contributor

@AndyButland AndyButland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks to work as expected @leekelleher. I've viewed before and after and can't see any differences, apart from the fix you note that I can verify.

I did note a couple of things but realised they are the same in main, so I'll note in passing just so you have them. They don't need to prevent merging this PR though, so I'll do so.

  1. There's a difference in the view of text around blocks depending on whether there is text preceding the block. See the following:
image image
  1. I found you can't Ctrl + Z to undo deleting a block.

@AndyButland AndyButland merged commit fb9a9b3 into main Jul 29, 2025
28 checks passed
@AndyButland AndyButland deleted the v16/improvement/tiptap-disable-injectcss branch July 29, 2025 05:58
@leekelleher
Copy link
Member Author

@AndyButland Thanks for the the review and feedback!

On your 2 notes...

  1. There's a difference in the view of text around blocks depending on whether there is text preceding the block.

I'll look into this. 👍

  1. I found you can't Ctrl + Z to undo deleting a block.

We have an issue to track this bug, #19637. I've been investigating potential fixes.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tiptap RTE: Caret navigation with Block elements

2 participants