fix text color and highlight

This commit is contained in:
Philipinho
2026-08-14 01:27:04 +01:00
parent 06d7e24676
commit 8ba4792e25
8 changed files with 83 additions and 6 deletions
@@ -2,8 +2,7 @@ import { EditorContent, ReactNodeViewRenderer, useEditor } from "@tiptap/react";
import { Placeholder } from "@tiptap/extension-placeholder";
import { StarterKit } from "@tiptap/starter-kit";
import { TextStyle } from "@tiptap/extension-text-style";
import { Color } from "@tiptap/extension-color";
import { Mention, LinkExtension } from "@docmost/editor-ext";
import { Mention, LinkExtension, Color } from "@docmost/editor-ext";
import classes from "./comment.module.css";
import { useFocusWithin } from "@mantine/hooks";
import clsx from "clsx";
@@ -10,7 +10,6 @@ import { Superscript } from "@tiptap/extension-superscript";
import SubScript from "@tiptap/extension-subscript";
import { Typography } from "@tiptap/extension-typography";
import { TextStyle } from "@tiptap/extension-text-style";
import { Color } from "@tiptap/extension-color";
import { Youtube } from "@tiptap/extension-youtube";
import SlashCommand, {
SlashCommandExtension as Command,
@@ -54,6 +53,7 @@ import {
Subpages,
Heading,
Highlight,
Color,
Indent,
UniqueID,
SharedStorage,
@@ -1,6 +1,46 @@
/* Highlight colors with dark mode support */
.ProseMirror {
@mixin dark {
/* Arbitrary (imported) colors have no hand-tuned dark variant, so derive
one: cap lightness and chroma so the fill sits on the dark surface.
Our own palette opts out and keeps the values below. */
mark[data-color]:not(
[data-color="#98d8f2" i],
[data-color="#7edb6c" i],
[data-color="#e0d6ed" i],
[data-color="#ffc6c2" i],
[data-color="#faf594" i],
[data-color="#f5c8a9" i],
[data-color="#f5cfe0" i],
[data-color="#dfdfd7" i],
[data-color="#d7c4b7" i]
) {
background-color: oklch(
from var(--mark-bg, #fff) min(l, clamp(0.28, calc(1.22 - l), 0.45))
min(calc(c * 1.8), 0.09) h
) !important;
}
/* Imported text colors are picked for a light page and go unreadable on
the dark surface, so lift their lightness. */
span[data-text-color]:not(
[data-text-color="#2563EB" i],
[data-text-color="#008A00" i],
[data-text-color="#9333EA" i],
[data-text-color="#E00000" i],
[data-text-color="#EAB308" i],
[data-text-color="#FFA500" i],
[data-text-color="#BA4081" i],
[data-text-color="#A8A29E" i],
[data-text-color="#92400E" i]
) {
color: oklch(
from var(--text-color, currentcolor) max(l, 0.72) min(c, 0.16) h
) !important;
}
}
/* Blue */
mark[data-color="#98d8f2"] {
background-color: light-dark(