From b03f2fcf0e396f4229fa29685f968c8421caf290 Mon Sep 17 00:00:00 2001 From: Daniel Wildsmith Date: Mon, 21 Apr 2025 17:26:03 -0400 Subject: [PATCH] fix: quote > not displaying when selected --- components/editor/Decorations.ts | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/components/editor/Decorations.ts b/components/editor/Decorations.ts index d9a01c7..58a4beb 100644 --- a/components/editor/Decorations.ts +++ b/components/editor/Decorations.ts @@ -321,33 +321,36 @@ export class Decorations { decorations: { from: number; to: number; decoration: Decoration }[], view: EditorView ) { - const selectedLines = new Set() const doc = view.state.doc + const line = doc.lineAt(cursor.from) + + // Check if any part of the line is within any selection range + let lineIsSelected = false for (const range of view.state.selection.ranges) { - const line = doc.lineAt(range.from).number - selectedLines.add(line) + if ((range.from <= line.to) && (range.to >= line.from)) { + lineIsSelected = true + break + } } - // Process each `QuoteMark`. - const lineNumber = doc.lineAt(cursor.from).number - const cursorOnLine = selectedLines.has(lineNumber) - - // Hide `>` if cursor is not on this line, but show vertical bar. - if (!cursorOnLine) { + // Use the styled-quote-focused class if the line is selected + if (lineIsSelected) { decorations.push({ from: cursor.from, to: cursor.from + 1, - decoration: Decoration.mark({ class: 'cm-styled-quote' }), + decoration: Decoration.mark({ + class: 'cm-styled-quote-focused', + }), }) } else { decorations.push({ from: cursor.from, to: cursor.from + 1, - decoration: Decoration.mark({ - class: 'cm-styled-quote-focused', - }), + decoration: Decoration.mark({ class: 'cm-styled-quote' }), }) } + + // Always style the text after the quote mark decorations.push({ from: cursor.from + 1, to: doc.lineAt(cursor.to).to,