@voithos-labs/aragonite 0.10.1 → 0.10.2
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
|
@@ -22,11 +22,16 @@ npm install @voithos-labs/aragonite
|
|
|
22
22
|
import '@voithos-labs/aragonite/styles/editor-theme.css';
|
|
23
23
|
|
|
24
24
|
let editor;
|
|
25
|
+
const source = '# Hello\n';
|
|
25
26
|
</script>
|
|
26
27
|
|
|
27
|
-
<
|
|
28
|
+
<div class="aragonite-editor-theme" data-editor-theme="light">
|
|
29
|
+
<Editor bind:this={editor} {source} theme="light" />
|
|
30
|
+
</div>
|
|
28
31
|
```
|
|
29
32
|
|
|
33
|
+
(the wrapper switches on the built-in look, and it says `light` twice because the editor paints no background of its own: the wrapper and the editor both have to match the page they land on, and a fresh app's page is white. On a dark page write `dark` in both spots, or write nothing, dark being the default.)
|
|
34
|
+
|
|
30
35
|
To save the source, just do something like:
|
|
31
36
|
|
|
32
37
|
```svelte
|
|
@@ -1715,7 +1715,8 @@
|
|
|
1715
1715
|
declaration scales the whole surface. */
|
|
1716
1716
|
font-size: var(--editor-font-size, 1rem);
|
|
1717
1717
|
line-height: 1.6;
|
|
1718
|
-
|
|
1718
|
+
/* Inherit rather than assume a dark host: an unthemed page keeps its own text color. */
|
|
1719
|
+
color: var(--color-text-primary, currentColor);
|
|
1719
1720
|
min-height: 200px;
|
|
1720
1721
|
overflow-y: auto;
|
|
1721
1722
|
/* The editor corrects the scroll anchor by hand (list-windowing's
|
package/dist/editor-props.d.ts
CHANGED
|
@@ -49,7 +49,9 @@ export interface EditorProps {
|
|
|
49
49
|
scrollMode?: 'self' | 'host';
|
|
50
50
|
/** Theme name reflected to `data-editor-theme` on the editor root. Built-ins:
|
|
51
51
|
* `'dark'` (default) and `'light'`; any other value activates a consumer's
|
|
52
|
-
* own `.editor[data-editor-theme='<name>']` token block.
|
|
52
|
+
* own `.editor[data-editor-theme='<name>']` token block. The editor paints no
|
|
53
|
+
* background, so the name should match the page; an `aragonite-editor-theme`
|
|
54
|
+
* wrapper keys its own palette off the same attribute set on the wrapper. */
|
|
53
55
|
theme?: string;
|
|
54
56
|
/** How the document presents, read live like `theme`; `'source'` by default. The consumer
|
|
55
57
|
* guide's Presentation modes section describes what each rung shows and allows. */
|
|
@@ -50,9 +50,12 @@ The editor owns the caret, the tree, and the undo stack. You own load, save, and
|
|
|
50
50
|
import '@voithos-labs/aragonite/styles/editor-theme.css';
|
|
51
51
|
|
|
52
52
|
let editor;
|
|
53
|
+
const source = '# Hello\n';
|
|
53
54
|
</script>
|
|
54
55
|
|
|
55
|
-
<
|
|
56
|
+
<div class="aragonite-editor-theme" data-editor-theme="light">
|
|
57
|
+
<Editor bind:this={editor} {source} theme="light" />
|
|
58
|
+
</div>
|
|
56
59
|
<button onclick={() => save(editor.getSource())}>Save</button>
|
|
57
60
|
```
|
|
58
61
|
|
|
@@ -60,7 +63,7 @@ A few things in the above example snippet are decently important; you might want
|
|
|
60
63
|
|
|
61
64
|
1. **`source` seeds the document at mount**, and re-seeds it if the prop later changes. It's not a two way bound: the editor never writes back into it, so the document you read is always `getSource()`.
|
|
62
65
|
2. **`bind:this` is how you talk to a mounted editor.** For example, you might want to use important read functions like `getSource()` and `getSelection()`, or important write functions like `setSelection()` and `runCommand()`. [The instance surface](#the-instance-surface) covers all of it.
|
|
63
|
-
3. **
|
|
66
|
+
3. **The editor paints no background of its own.** It inherits your page, so its mode has to match the page it lands on, and it says `light` twice because there are two things to match: the wrapper carries the built-in look (font, colors) for everything inside it, and the `theme` prop keys the editor's own surfaces. A fresh app's page is white, hence `light`; on a dark page write `dark` in both spots, or write nothing, dark being the default. Skip the wrapper if your app already declares the tokens; [Theming](#theming) has the two tiers and how to customize yours.
|
|
64
67
|
|
|
65
68
|
Two more that aren't in the snippet but bite early: plugin registration is process-global and happens once at mount, but each editor activates exactly the plugins its own `plugins` prop lists ([Plugins](#plugins)); and `editor.__test.*` is internal and will move, so don't build on it.
|
|
66
69
|
|
|
@@ -645,7 +648,7 @@ A live change is supported, and virtual rendering re-estimates the document at t
|
|
|
645
648
|
|
|
646
649
|
Outside this contract sits the editor's own visual language: the syntax and code-token palettes, the marker colors, the selection, search, and reorder tints (derived from `--color-selection`, above), and the surfaces windowing paints where blocks aren't mounted yet. Those are dark-based or mode-independent; read `editor-theme.css` if you mean to retheme them.
|
|
647
650
|
|
|
648
|
-
**Plugin fallbacks.** A plugin reading a token keeps an inline fallback (`var(--color-text-muted, #aaaaaa)`) so it renders with no host, and every fallback matches the token's dark base value in `editor-theme.css`, never the light one. Which scopes a fallback fires in follows the tier: an editor-owned token defaults on `.editor`, so its fallback only fires outside the editor, while a host-chrome token defaults behind the opt-in class alone, so in a host that skips the class the fallback fires inside `.editor` too.
|
|
651
|
+
**Plugin fallbacks.** A plugin reading a token keeps an inline fallback (`var(--color-text-muted, #aaaaaa)`) so it renders with no host, and every fallback matches the token's dark base value in `editor-theme.css`, never the light one. The one exception is the text color: it falls back to `currentColor`, so an editor with no host tokens and no wrapper inherits the page's own text instead of painting white on whatever the page is. Which scopes a fallback fires in follows the tier: an editor-owned token defaults on `.editor`, so its fallback only fires outside the editor, while a host-chrome token defaults behind the opt-in class alone, so in a host that skips the class the fallback fires inside `.editor` too.
|
|
649
652
|
|
|
650
653
|
## Keyboard shortcuts
|
|
651
654
|
|
|
@@ -305,7 +305,7 @@ cNo.....................................oc
|
|
|
305
305
|
color: #3fd3d3;
|
|
306
306
|
}
|
|
307
307
|
85.714% {
|
|
308
|
-
color: var(--color-text-primary,
|
|
308
|
+
color: var(--color-text-primary, currentColor);
|
|
309
309
|
}
|
|
310
310
|
}
|
|
311
311
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -916,7 +916,9 @@ Pass the plugin to the editor's `plugins` prop. It installs before the seed pars
|
|
|
916
916
|
let editor = $state();
|
|
917
917
|
</script>
|
|
918
918
|
|
|
919
|
-
<
|
|
919
|
+
<div class="aragonite-editor-theme" data-editor-theme="light">
|
|
920
|
+
<Editor bind:this={editor} source={SEED} {plugins} theme="light" />
|
|
921
|
+
</div>
|
|
920
922
|
```
|
|
921
923
|
|
|
922
924
|
The chords are live (a **chord** is a key combination, written `Mod+7` where `Mod` is Ctrl, or Cmd on a Mac). Focus the box, press `Mod+8` to debunk the theory (the string comes down and the stamp lands) and `Mod+7` to allege it again, then read `editor.getSource()` back and watch the opener line flip between the two names:
|
|
@@ -931,7 +933,7 @@ editor.getSource();
|
|
|
931
933
|
|
|
932
934
|
The flip is one undoable edit, so undo un-debunks it, which is how conspiracies work anyway. And because the verdict lives in the bytes, a debunked conspiracy stays debunked across a reload.
|
|
933
935
|
|
|
934
|
-
|
|
936
|
+
The wrapper and the two `light`s are there because the editor paints no background of its own. A fresh app's page is white, so the built-in chrome (the wrapper's attribute) and the editor's own surfaces (the prop) both have to say so; on a dark page, both say `dark`, or nothing. [consumer-guide.md](consumer-guide.md)'s theming section explains the two tiers.
|
|
935
937
|
|
|
936
938
|
Want a collapse toggle? Give `reservedChrome` an `isCollapsed` probe over the node, and every focus walk, merge, and windowing decision (a collapsed body stays unmounted) reads that one declaration. Add `expandPatch` beside it, returning the metadata patch that opens the node, and a reveal into the collapsed body (a table-of-contents entry, a search match) opens the container first and commits it as one undoable edit. Without it, such a reveal has nowhere to land and reports that it didn't.
|
|
937
939
|
|