Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore(web): bump @usememos/editor to 26.10.24

johnnyjoygh59afd178ff5b
diff --git a/web/package.json b/web/package.json
index 57fca7b6e..c5d620c12 100644
--- a/web/package.json
+++ b/web/package.json
@@ -25,7 +25,7 @@
"@tailwindcss/vite": "^4.2.4",
"@tanstack/react-query": "^5.100.9",
"@tanstack/react-query-devtools": "^5.100.9",
- "@usememos/editor": "26.10.22",
+ "@usememos/editor": "26.10.24",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"copy-to-clipboard": "^4.0.2",
diff --git a/web/pnpm-lock.yaml b/web/pnpm-lock.yaml
index c3fd4c212..1ba25b30b 100644
--- a/web/pnpm-lock.yaml
+++ b/web/pnpm-lock.yaml
@@ -36,8 +36,8 @@ importers:
specifier: ^5.100.9
'@usememos/editor':
- specifier: 26.10.22
+ specifier: 26.10.24
class-variance-authority:
specifier: ^0.7.1
version: 0.7.1
@@ -1006,8 +1006,8 @@ packages:
resolution: {integrity: sha512-WmoN8qaIAo7WTYWbAZuG8PYEhn5fkz7dZrqTBZ7dtt//lL2Gwms1IcnQ5yHqjDfX8Ft5j4YzDM23f87zBfDe9g==}
deprecated: Potential CWE-502 - Update to 1.3.1 or higher
- '@usememos/[email protected]':
- resolution: {integrity: sha512-Cd8BHuKDjyhwc4zJuWNmo0FjlvBVgBozb5fRn8oEJvPjr4whwJeOuwmR+DZT4wRaIe1Qc2J+UnxjMQQcm9GuvQ==}
+ '@usememos/[email protected]':
+ resolution: {integrity: sha512-hRikkcHkooXRMN5uRg2mqlEPzzpTj8NEP+uBwROAz2ruPLyaIAq0UhNPYCAnHNbJbLlQRRUW6+FhPq0O45SDCg==}
peerDependencies:
react: '>=18'
react-dom: '>=18'
@@ -2694,7 +2694,7 @@ snapshots:
'@ungap/[email protected]': {}
optionalDependencies:
react: 19.2.6
react-dom: 19.2.6([email protected])
diff --git a/web/src/lib/markdownStyles.ts b/web/src/lib/markdownStyles.ts
index b78b2072c..ad5fe7af8 100644
--- a/web/src/lib/markdownStyles.ts
+++ b/web/src/lib/markdownStyles.ts
@@ -1,18 +1,16 @@
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
/**
- * Per-level heading type (size / line height / weight / color). The composer and
- * the memo view are the same Markdown editor, so a heading looks the same while
- * editing and after saving. The scale stays close to the 16px body: headings
- * organize a note, they are not page titles.
+ * Per-level heading classes for the editor's `theme.classes.heading`. Size, line
+ * height and weight are the editor's own: it scales h1–h3 from its `fontSize` and
+ * `lineHeight` tokens (1.5×, 1.25× and 1.125×, each with the body's leading) and
+ * sets h4–h6 at the body size, in its own unlayered stylesheet, so a Tailwind size
+ * here would never apply and a changed token would not reach it. Only what the
+ * editor leaves to the app goes here. The composer and the memo view are the same
+ * Markdown editor, so a heading looks the same while editing and after saving.
*/
-const headingTypeClasses: Record<HeadingLevel, string> = {
- 1: "text-2xl/8 font-semibold",
- 2: "text-xl/7 font-semibold",
- 3: "text-lg/6.5 font-semibold",
- 4: "text-base/6 font-semibold",
- 5: "text-base/6 font-semibold",
- 6: "text-base/6 font-semibold text-muted-foreground",
+export const headingClasses: Readonly<Partial<Record<HeadingLevel, string>>> = {
+ 6: "text-muted-foreground",
};
/**
@@ -28,9 +26,6 @@ export const markdownStyles = {
image: "max-w-full my-2 rounded-lg",
} as const;
-/** Heading type for a level: size, line height, weight and color. */
-export const headingTypeClass = (level: HeadingLevel): string => headingTypeClasses[level];
-
/**
* Tag pill styling for the memo view. Split into two tokens so the view can swap
* `defaultColor` for a custom tag color (MemoEditor/view/MemoContentView.tsx). The composer
diff --git a/web/src/lib/memo-markdown.ts b/web/src/lib/memo-markdown.ts
index ecb8a405a..87600f1ee 100644
--- a/web/src/lib/memo-markdown.ts
+++ b/web/src/lib/memo-markdown.ts
@@ -23,7 +23,7 @@ import {
} from "@usememos/editor";
import { ensureHighlightTheme, highlightLoadedCode, loadHighlighter } from "@/lib/code-highlight";
import { colorToHex } from "@/lib/color";
-import { headingTypeClass, markdownStyles, mentionStyles, tagStyles } from "@/lib/markdownStyles";
+import { headingClasses, markdownStyles, mentionStyles, tagStyles } from "@/lib/markdownStyles";
import { findTagMetadata } from "@/lib/tag";
import { cn } from "@/lib/utils";
import type { Attachment } from "@/types/proto/api/attachment_service_pb";
@@ -250,8 +250,11 @@ export const memoResolveUrl =
/**
* The editor's look in memos' palette. Every color is one of the app's own CSS
- * variables, for both schemes, so the active memos theme decides; `inherit`
- * follows the `color-scheme` memos sets on the document.
+ * variables, set once for both schemes (`colors`), since the variables already
+ * follow the active memos theme; `inherit` follows the `color-scheme` memos sets
+ * on the document. No `highlight` token: memos' HTML sanitizer drops `<mark>`, and
+ * should it ever pass, the editor's yellow is what a highlighter means, where a
+ * tint of the primary color would read as a tag pill or a selection.
*/
export const MEMO_EDITOR_THEME: Theme = (() => {
const colors = {
@@ -270,8 +273,7 @@ export const MEMO_EDITOR_THEME: Theme = (() => {
return {
colorScheme: "inherit",
tokens: {
- light: colors,
- dark: colors,
+ colors,
font: "inherit",
mono: "var(--font-mono, ui-monospace, monospace)",
fontSize: 16,
@@ -280,14 +282,7 @@ export const MEMO_EDITOR_THEME: Theme = (() => {
blockGap: 8,
},
classes: {
- heading: {
- 1: headingTypeClass(1),
- 2: headingTypeClass(2),
- 3: headingTypeClass(3),
- 4: headingTypeClass(4),
- 5: headingTypeClass(5),
- 6: headingTypeClass(6),
- },
+ heading: headingClasses,
code: markdownStyles.inlineCode,
link: markdownStyles.link,
// The editor sizes and spaces its images; raw HTML images keep markdownStyles.image.
diff --git a/web/src/themes/COLOR_GUIDE.md b/web/src/themes/COLOR_GUIDE.md
index c1fe92234..76222e434 100644
--- a/web/src/themes/COLOR_GUIDE.md
+++ b/web/src/themes/COLOR_GUIDE.md
@@ -191,12 +191,7 @@ or add manual `dark:` overrides for feedback states.
## Theme Switching
-The color system automatically adapts between light and dark themes when the `.dark` class is applied to a parent element (typically `<html>` or `<body>`):
-
-```javascript
-// Toggle dark mode
-document.documentElement.classList.toggle("dark");
-```
+A theme is a stylesheet in this folder, selected by the `data-theme` attribute on `<html>`; `utils/theme.ts` sets the attribute and the document's `color-scheme`, and the memo editor follows that `color-scheme`. There is no `.dark` or `.light` class: do not add one to a container, since the editor would switch its own scheme on it.
## Accessibility