Skip to content

Commit e430927

Browse files
authored
fix: 🐛 improve styles for crepe (#1306)
1 parent 4715a17 commit e430927

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

Diff for: packages/components/src/link-tooltip/preview/preview-configure.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function configureLinkPreviewTooltip(ctx: Ctx) {
2727
const result = shouldShowPreviewWhenHover(ctx, view, event)
2828
if (result) {
2929
const position = view.state.doc.resolve(result.pos)
30-
const markPosition = findMarkPosition(result.mark, view.state.doc, position.before(), position.after())
30+
const markPosition = findMarkPosition(result.mark, result.node, view.state.doc, position.before(), position.after())
3131
const from = markPosition.start
3232
const to = markPosition.end
3333
linkPreviewTooltipView.setRect(posToDOMRect(view, from, to))

Diff for: packages/components/src/link-tooltip/utils.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import type { EditorView } from '@milkdown/prose/view'
55
import { linkSchema } from '@milkdown/preset-commonmark'
66
import { linkPreviewTooltip } from './tooltips'
77

8-
export function findMarkPosition(mark: Mark, doc: Node, from: number, to: number) {
8+
export function findMarkPosition(mark: Mark, node: Node, doc: Node, from: number, to: number) {
99
let markPos = { start: -1, end: -1 }
10-
doc.nodesBetween(from, to, (node, pos) => {
10+
doc.nodesBetween(from, to, (n, pos) => {
1111
// stop recursive finding if result is found
1212
if (markPos.start > -1)
1313
return false
1414

15-
if (markPos.start === -1 && mark.isInSet(node.marks)) {
15+
if (markPos.start === -1 && mark.isInSet(n.marks) && node === n) {
1616
markPos = {
1717
start: pos,
18-
end: pos + Math.max(node.textContent.length, 1),
18+
end: pos + Math.max(n.textContent.length, 1),
1919
}
2020
}
2121

Diff for: packages/crepe/src/theme/classic-dark/style.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959

6060
.ProseMirror {
6161
padding: 60px 120px;
62+
letter-spacing: 0.5px;
6263

6364
& > * {
6465
margin: 20px 0 40px;
@@ -141,10 +142,13 @@
141142
background: color-mix(in srgb, var(--crepe-color-inline-area), transparent 40%);
142143
padding: 0 10px;
143144
border-radius: 4px;
145+
display: inline-block;
146+
line-height: 24px;
144147
}
145148

146149
a {
147150
color: var(--crepe-color-primary);
151+
text-decoration: underline;
148152
}
149153

150154
pre {
@@ -177,7 +181,7 @@
177181

178182
hr {
179183
border: none;
180-
border-bottom: 1px solid color-mix(in srgb, var(--crepe-color-outline), transparent 80%);
184+
border-bottom: 1px solid color-mix(in srgb, var(--crepe-color-outline), transparent 20%);
181185
height: 16px;
182186
position: relative;
183187

Diff for: packages/crepe/src/theme/classic/style.css

+5-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454

5555
.ProseMirror {
5656
padding: 60px 120px;
57+
letter-spacing: 0.5px;
5758

5859
& > * {
5960
margin: 20px 0 40px;
@@ -136,10 +137,13 @@
136137
background: color-mix(in srgb, var(--crepe-color-inline-area), transparent 40%);
137138
padding: 0 10px;
138139
border-radius: 4px;
140+
display: inline-block;
141+
line-height: 24px;
139142
}
140143

141144
a {
142145
color: var(--crepe-color-primary);
146+
text-decoration: underline;
143147
}
144148

145149
pre {
@@ -172,7 +176,7 @@
172176

173177
hr {
174178
border: none;
175-
border-bottom: 1px solid color-mix(in srgb, var(--crepe-color-outline), transparent 80%);
179+
border-bottom: 1px solid color-mix(in srgb, var(--crepe-color-outline), transparent 20%);
176180
height: 16px;
177181
position: relative;
178182

0 commit comments

Comments
 (0)