Skip to content

Commit 3fc66e1

Browse files
committed
Remaining styles
1 parent e22dfcc commit 3fc66e1

File tree

4 files changed

+25
-49
lines changed

4 files changed

+25
-49
lines changed

app/javascript/components/RichTextEditor.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export const useRichTextEditor = ({
281281
editable,
282282
editorProps: {
283283
attributes: {
284-
...(className ? { class: classNames("min-h-full rounded-t-none", className) } : {}),
284+
class: classNames("min-h-full whitespace-break-spaces rounded-t-none focus-within:outline-none", className),
285285
...(ariaLabel ? { "aria-label": ariaLabel } : {}),
286286
...(id ? { id } : {}),
287287
},

app/javascript/components/TiptapExtensions/Image.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as React from "react";
77
import { cast } from "ts-safe-cast";
88

99
import { assertDefined } from "$app/utils/assert";
10+
import { classNames } from "$app/utils/classNames";
1011
import FileUtils from "$app/utils/file";
1112

1213
import { LoadingSpinner } from "$app/components/LoadingSpinner";
@@ -102,6 +103,11 @@ const ImageNodeView = ({ node, editor, getPos }: NodeViewProps) => {
102103
const imageMarkup = (
103104
<img
104105
{...{ ...attrs, uploading: undefined }}
106+
className={classNames(
107+
"selection:bg-muted",
108+
editor.isEditable && "cursor-pointer",
109+
hasFocus && "outline-2 outline-accent",
110+
)}
105111
onLoad={() => setIsImageLoaded(true)}
106112
onClick={handleImageClick}
107113
data-drag-handle
@@ -111,11 +117,7 @@ const ImageNodeView = ({ node, editor, getPos }: NodeViewProps) => {
111117

112118
return (
113119
<NodeViewWrapper>
114-
<figure
115-
ref={nodeRef}
116-
data-has-focus={hasFocus || undefined}
117-
style={isUploading ? { position: "relative" } : undefined}
118-
>
120+
<figure ref={nodeRef} style={isUploading ? { position: "relative" } : undefined}>
119121
{attrs.link ? (
120122
<a href={cast(attrs.link)} target="_blank" rel="noopener noreferrer nofollow">
121123
{imageMarkup}

app/javascript/stylesheets/_rich_text.scss

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,6 @@
133133
}
134134
}
135135

136-
137-
.react-renderer[draggable] {
138-
cursor: unset;
139-
}
140-
141136
.embed {
142137
border: $border;
143138
border-radius: border-radius(1);
@@ -202,41 +197,3 @@
202197
}
203198
}
204199
}
205-
206-
.ProseMirror[contenteditable="true"] {
207-
white-space: break-spaces;
208-
209-
&:focus-within {
210-
outline: none;
211-
}
212-
213-
figure {
214-
& > img {
215-
cursor: pointer;
216-
}
217-
218-
// Chrome-specific workaround to prevent highlighting the br
219-
br::selection {
220-
background: none;
221-
}
222-
223-
img::selection {
224-
background: gray(3);
225-
}
226-
227-
&[data-has-focus] img {
228-
outline: $outline;
229-
}
230-
}
231-
}
232-
233-
234-
// Placeholder plugin
235-
.ProseMirror p.is-editor-empty:first-child::before,
236-
.ProseMirror .node-image.is-empty .figcaption::before {
237-
content: attr(data-placeholder);
238-
pointer-events: none;
239-
float: left;
240-
height: 0;
241-
@include text-muted;
242-
}

app/javascript/stylesheets/tailwind.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,20 @@
121121
transform: translateX(-50%);
122122
}
123123
}
124+
125+
/* Reset Tiptap's default grab cursor on draggable React node views */
126+
.ProseMirror .react-renderer[draggable] {
127+
@apply cursor-auto;
128+
}
129+
130+
/* Chrome-specific workaround to prevent highlighting the br ProseMirror creates in empty figure captions */
131+
.ProseMirror[contenteditable="true"] figure br::selection {
132+
@apply bg-transparent;
133+
}
134+
135+
/* Tiptap placeholder plugin */
136+
.ProseMirror p.is-editor-empty:first-child::before,
137+
.ProseMirror .node-image.is-empty .figcaption::before {
138+
content: attr(data-placeholder);
139+
@apply pointer-events-none float-left h-0 text-muted;
140+
}

0 commit comments

Comments
 (0)