@usememos/editor 26.10.23 → 26.10.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -309,13 +309,28 @@ Colors are `text`, `muted`, `background`, `accent`, `link`, `codeBackground`, `b
309
309
 
310
310
  `fontSize` and `lineHeight` size the whole document, not only its paragraphs: headings are 1.5, 1.25 and 1.125 times `fontSize` (h4 to h6 the body size), code blocks, raw blocks and tables 0.875 times it, and the code block's language label 0.75. Each keeps the body's leading, the room `lineHeight` leaves around `fontSize`, so `fontSize: 14` with `lineHeight: 20` gives a 21px h1 on 27px lines, and code at 12.25px on 18.25px lines.
311
311
 
312
- For an app styled with [shadcn/ui](https://ui.shadcn.com), `shadcnTheme` maps the tokens to shadcn's variables (`--foreground`, `--primary`, `--muted`, `--border`, `--popover`, `--radius`, …), so the editor follows the app's theme, light and dark included:
312
+ An app that keeps its palette in CSS variables passes them as the values, and the editor follows the app's theme, light and dark included, since the variables change with it. With the names most Tailwind-based component kits use:
313
313
 
314
314
  ```ts
315
- import { Editor, shadcnTheme } from '@usememos/editor';
316
-
317
- new Editor({ element, theme: shadcnTheme });
318
- // or, with a change: { tokens: { ...shadcnTheme.tokens, radius: 4 } }
315
+ new Editor({
316
+ element,
317
+ theme: {
318
+ tokens: {
319
+ colors: {
320
+ text: 'var(--foreground)',
321
+ muted: 'var(--muted-foreground)',
322
+ accent: 'var(--primary)',
323
+ codeBackground: 'var(--muted)',
324
+ border: 'var(--border)',
325
+ popupBackground: 'var(--popover)',
326
+ hover: 'var(--accent)',
327
+ danger: 'var(--destructive)',
328
+ },
329
+ font: 'inherit',
330
+ radius: 'calc(var(--radius) - 2px)',
331
+ },
332
+ },
333
+ });
319
334
  ```
320
335
 
321
336
  The same tokens can be set in CSS, with no JavaScript, as `--mbe-<name>-light` and `--mbe-<name>-dark` (`--mbe-accent-light`, `--mbe-code-bg-dark`; the names are in `theme.css`). They inherit, so set them on `:root` for every editor on the page, or on a container for the editors in it. `theme.css` reads them with the default palette as fallback; a value you leave out keeps the default:
@@ -328,7 +343,7 @@ The same tokens can be set in CSS, with no JavaScript, as `--mbe-<name>-light` a
328
343
  }
329
344
  ```
330
345
 
331
- `colorScheme` picks light or dark: `auto` (the default) follows `prefers-color-scheme`, or `data-theme="light"` or `data-theme="dark"`, or a `light` or `dark` class (as Tailwind and shadcn/ui toggle it), on the editor or an ancestor; `light` and `dark` force one; `inherit` follows the page's `color-scheme`, for apps that switch it themselves. Switching tokens or the scheme with `setOptions({ theme })` re-renders nothing.
346
+ `colorScheme` picks light or dark: `auto` (the default) follows `prefers-color-scheme`, or `data-theme="light"` or `data-theme="dark"`, or a `light` or `dark` class (as Tailwind-style theming toggles it), on the editor or an ancestor; `light` and `dark` force one; `inherit` follows the page's `color-scheme`, for apps that switch it themselves. Switching tokens or the scheme with `setOptions({ theme })` re-renders nothing.
332
347
 
333
348
  The `theme` option's `classes` add your own classes to rendered elements, next to the editor's `mbe-*` classes, so the editor can share classes with the rest of your app:
334
349
 
package/dist/index.js CHANGED
@@ -8719,23 +8719,6 @@ function delta(start, end, viewStart, viewEnd) {
8719
8719
  }
8720
8720
 
8721
8721
  // src/theme.ts
8722
- var shadcnTheme = {
8723
- tokens: {
8724
- colors: {
8725
- text: "var(--foreground)",
8726
- muted: "var(--muted-foreground)",
8727
- accent: "var(--primary)",
8728
- codeBackground: "var(--muted)",
8729
- border: "var(--border)",
8730
- popupBackground: "var(--popover)",
8731
- hover: "var(--accent)",
8732
- danger: "var(--destructive)"
8733
- },
8734
- font: "inherit",
8735
- mono: "var(--font-mono, ui-monospace, monospace)",
8736
- radius: "calc(var(--radius) - 2px)"
8737
- }
8738
- };
8739
8722
  function mergeClasses(maps) {
8740
8723
  const out = {};
8741
8724
  for (const map of maps) {
@@ -12544,7 +12527,6 @@ export {
12544
12527
  setLinkInRange,
12545
12528
  setMarkInRange,
12546
12529
  setTokenInRange,
12547
- shadcnTheme,
12548
12530
  sliceInline,
12549
12531
  sortMarks,
12550
12532
  startOf,