wysiwygido 0.3.0 → 0.4.0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  All notable changes to this project are documented here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses [Semantic Versioning](https://semver.org/). Until 1.0, minor versions may contain breaking changes; they are listed under "Changed" or "Removed".
4
4
 
5
+ ## 0.4.0
6
+
7
+ - Added: colour themes (`Themes` plugin): light, dark, sepia, ocean, forest, rose, solarized, midnight, nord and high-contrast, a View → Themes menu, `colorTheme` / `cycleColorTheme` / `clearColorTheme` commands, your own theme from a handful of colours, and `<wysiwyg-editor theme="sepia">`.
8
+ - Added: the editor emits a `theme` event when Dark Mode or Switch Background changes.
9
+
5
10
  ## 0.3.0
6
11
 
7
12
  - Added: change case (UPPER, lower, toggle, snake_case, camelCase, Title, Sentence, PascalCase, kebab-case) with shortcuts, a Home-tab menu and a right-click submenu; `Shift+F3` cycles.
package/README.md CHANGED
@@ -469,6 +469,30 @@ tOGGLE cASE (`Ctrl/⌘+Alt+G`), snake_case (`Ctrl/⌘+Alt+S`), camelCase (`Ctrl/
469
469
  in the right-click menu. Upper/lower/toggle/title/sentence keep every bold, link and colour in place; snake/camel/kebab join the words into one
470
470
  identifier that takes the formatting of its first letter. From code: `editor.execute('changeCase', 'snake')` or the pure `convertCase(text, 'camel')`.
471
471
 
472
+ ## Themes
473
+
474
+ Ten colour themes ship with the editor: `light`, `dark`, `sepia`, `ocean`, `forest`, `rose`, `solarized`, `midnight`, `nord` and `high-contrast`. A theme restyles the toolbar, ribbon, panels and the paper, and only inside the editor.
475
+
476
+ ```ts
477
+ import { createEditor, defaultPlugins, Themes } from 'wysiwygido';
478
+
479
+ createEditor({ element, plugins: [...defaultPlugins, Themes({ initial: 'sepia' })] });
480
+ editor.execute('colorTheme', 'midnight');
481
+ editor.execute('cycleColorTheme');
482
+ editor.execute('clearColorTheme'); // back to the stock look
483
+ ```
484
+
485
+ Pick one from **View → Themes** in the ribbon, or use `<wysiwyg-editor theme="nord">`. Dark Mode on its own returns to the stock look.
486
+
487
+ Your own theme is a handful of colours; hover, borders, selection and the rest are derived from them:
488
+
489
+ ```ts
490
+ Themes({ extra: [{ name: 'brand', label: 'Brand', palette: { mode: 'light', bg: '#fff8f0', surface: '#ffeede', fg: '#2a1a10',
491
+ muted: '#7a5a44', border: '#f0d6bf', accent: '#e8590c', workspace: '#f0d2b8', pageBg: '#fff', pageFg: '#2a1a10' } }] });
492
+ ```
493
+
494
+ `editor.extensions.themes` gives `list()`, `current()`, `register(theme)`, `apply(name)` and `clear()`. A theme can also set any `--wy-*` variable through `vars`.
495
+
472
496
  ## Cover page
473
497
 
474
498
  `Cover` (in `defaultPlugins`) adds a cover page: one picture that fills the whole first page, edge to edge, with the text starting on page 2. Use
package/dist/adapter.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createEditor } from "./src-CW6adV6q.js";
1
+ import { t as createEditor } from "./src-DmooWA6v.js";
2
2
  //#region src/adapter.ts
3
3
  /**
4
4
  * Framework-neutral binding for anything that needs a "value in, value out" control: Angular's `ControlValueAccessor`, Svelte, Solid,
package/dist/element.d.ts CHANGED
@@ -16,7 +16,7 @@ export interface WysiwygElement extends HTMLElement {
16
16
  *
17
17
  * <wysiwyg-editor value="<p>Hello</p>" ribbon paged theme="dark" name="body"></wysiwyg-editor>
18
18
  *
19
- * Attributes: `value`, `readonly`, `theme` (light | dark | auto), `placeholder`, `locale`, `ribbon`, `paged` (A4 pages with a ruler),
19
+ * Attributes: `value`, `readonly`, `theme` (light | dark | auto, or the name of a colour theme such as sepia), `placeholder`, `locale`, `ribbon`, `paged` (A4 pages with a ruler),
20
20
  * `outline`, `name` (the HTML is submitted with a surrounding form under this name). Properties: `value`, `readOnly`, `plugins`, `config`,
21
21
  * `editor`. Events: `editor-ready` and `editor-change` (`detail.html`). Load the stylesheet (`wysiwygido/style.css`) in the page:
22
22
  * the element renders in the light DOM so the document can be styled and printed like any other content.
@@ -92,3 +92,5 @@ export { Recording, isSafeClip } from './recording.js';
92
92
  export type { RecordingOptions } from './recording.js';
93
93
  export { PdfEpub } from './pdf-epub.js';
94
94
  export type { PdfEpubOptions } from './pdf-epub.js';
95
+ export { Themes, defaultThemes, themeVars } from './themes.js';
96
+ export type { Theme, ThemePalette, ThemesOptions, ThemeApi } from './themes.js';
@@ -0,0 +1,54 @@
1
+ import type { EditorPlugin } from '../types.js';
2
+ /** A colour theme in a few colours. The rest of the interface colours are derived from these. */
3
+ export interface ThemePalette {
4
+ /** Decides the browser's own controls (scrollbars, form fields) and the `light` / `dark` state of the editor. */
5
+ mode: 'light' | 'dark';
6
+ /** Toolbar, ribbon and panels. */
7
+ bg: string;
8
+ surface: string;
9
+ fg: string;
10
+ muted: string;
11
+ border: string;
12
+ /** Buttons, selections, focus. */
13
+ accent: string;
14
+ /** Area around the pages. */
15
+ workspace: string;
16
+ /** The paper and its text. */
17
+ pageBg: string;
18
+ pageFg: string;
19
+ /** Links in the document. Default: the accent. */
20
+ link?: string;
21
+ }
22
+ export interface Theme {
23
+ /** Id used by `editor.execute('colorTheme', id)`. */
24
+ name: string;
25
+ label: string;
26
+ palette: ThemePalette;
27
+ /** Any further `--wy-*` variables to set, with or without the leading dashes. */
28
+ vars?: Record<string, string>;
29
+ }
30
+ /** Expands a palette into the editor's CSS variables. */
31
+ export declare function themeVars(p: ThemePalette): Record<string, string>;
32
+ /** The themes that come with the editor. `light` and `dark` are the stock look. */
33
+ export declare const defaultThemes: Theme[];
34
+ export interface ThemesOptions {
35
+ /** Theme applied on start. Default: leave the editor's own `theme` option as it is. */
36
+ initial?: string;
37
+ /** Replace the built-in list. */
38
+ themes?: Theme[];
39
+ /** Add to the built-in list (same name replaces). */
40
+ extra?: Theme[];
41
+ }
42
+ /** The API stored on `editor.extensions.themes`. */
43
+ export interface ThemeApi {
44
+ list(): Theme[];
45
+ current(): string | null;
46
+ register(theme: Theme): void;
47
+ apply(name: string): boolean;
48
+ clear(): void;
49
+ }
50
+ /**
51
+ * Colour themes: `editor.execute('colorTheme', 'sepia')`, the View → Themes menu, or `editor.extensions.themes`.
52
+ * A theme sets the CSS variables on the editor element, so it never leaks outside it. Switching Dark Mode afterwards returns to the stock look.
53
+ */
54
+ export declare function Themes(options?: ThemesOptions): EditorPlugin;
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createEditor } from "./src-CW6adV6q.js";
1
+ import { t as createEditor } from "./src-DmooWA6v.js";
2
2
  import { createElement, forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
3
3
  //#region src/react.ts
4
4
  /** React wrapper (needs the optional `react` peer dependency). */