Skip to content

Commit fb9a9b3

Browse files
authored
Tiptap RTE: Include Tiptap's default styles (#19805)
* Disables Tiptap's `injectCSS` option This option would inject the default CSS styles into the `window.document`, which are never applied to the component's shadow DOM. * Add Tiptap's default styles to "rte-content.css" The `caret-color` rule (line 93) resolves issue #19791.
1 parent 66b2e3b commit fb9a9b3

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

src/Umbraco.Web.UI.Client/src/css/rte-content.css

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,82 @@
1919
padding: 10px;
2020
border-radius: 5px;
2121
}
22+
23+
/* Default Tiptap RTE styles.
24+
* Copied from: https://github.com/ueberdosis/tiptap/blob/v2.11.7/packages/core/src/style.ts
25+
* as we disable the `injectCSS` option in the Tiptap editor.
26+
*/
27+
28+
.ProseMirror {
29+
position: relative;
30+
}
31+
32+
.ProseMirror {
33+
word-wrap: break-word;
34+
white-space: pre-wrap;
35+
white-space: break-spaces;
36+
-webkit-font-variant-ligatures: none;
37+
font-variant-ligatures: none;
38+
font-feature-settings: 'liga' 0; /* the above doesn't seem to work in Edge */
39+
}
40+
41+
.ProseMirror [contenteditable='false'] {
42+
white-space: normal;
43+
}
44+
45+
.ProseMirror [contenteditable='false'] [contenteditable='true'] {
46+
white-space: pre-wrap;
47+
}
48+
49+
.ProseMirror pre {
50+
white-space: pre-wrap;
51+
}
52+
53+
img.ProseMirror-separator {
54+
display: inline !important;
55+
border: none !important;
56+
margin: 0 !important;
57+
width: 0 !important;
58+
height: 0 !important;
59+
}
60+
61+
.ProseMirror-gapcursor {
62+
display: none;
63+
pointer-events: none;
64+
position: absolute;
65+
margin: 0;
66+
}
67+
68+
.ProseMirror-gapcursor:after {
69+
content: '';
70+
display: block;
71+
position: absolute;
72+
top: -2px;
73+
width: 20px;
74+
border-top: 1px solid black;
75+
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
76+
}
77+
78+
@keyframes ProseMirror-cursor-blink {
79+
to {
80+
visibility: hidden;
81+
}
82+
}
83+
84+
.ProseMirror-hideselection *::selection {
85+
background: transparent;
86+
}
87+
88+
.ProseMirror-hideselection *::-moz-selection {
89+
background: transparent;
90+
}
91+
92+
.ProseMirror-hideselection * {
93+
caret-color: transparent;
94+
}
95+
96+
.ProseMirror-focused .ProseMirror-gapcursor {
97+
display: block;
98+
}
99+
100+
/* End of default Tiptap RTE styles */

src/Umbraco.Web.UI.Client/src/packages/tiptap/components/input-tiptap/input-tiptap.element.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ export class UmbInputTiptapElement extends UmbFormControlMixin<string, typeof Um
175175
editable: !this.readonly,
176176
extensions: tiptapExtensions,
177177
content: this.#value,
178+
injectCSS: false, // Prevents injecting CSS into `window.document`, as it never applies to the shadow DOM. [LK]
178179
//enableContentCheck: true,
179180
onBeforeCreate: ({ editor }) => {
180181
this._extensions.forEach((ext) => ext.setEditor(editor));

0 commit comments

Comments
 (0)