@openstage/glyph-core 0.2.0 → 0.2.1

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.
Files changed (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +14 -2
package/README.md ADDED
@@ -0,0 +1,77 @@
1
+ # @openstage/glyph-core
2
+
3
+ Engine-agnostic core for [Glyph](https://codeberg.org/open-stage/glyph): the
4
+ serializable document model, smart constructors, validation, migration, branded
5
+ value types, and the shared config/command types. **No DOM and no editor-engine
6
+ dependency** — safe to use on a server or in any framework.
7
+
8
+ ```bash
9
+ npm i @openstage/glyph-core
10
+ ```
11
+
12
+ ## Building documents
13
+
14
+ Documents are a serializable tree. Build them with the smart constructors
15
+ rather than object literals:
16
+
17
+ ```ts
18
+ import {
19
+ document,
20
+ heading,
21
+ paragraph,
22
+ plain,
23
+ text,
24
+ bold,
25
+ link,
26
+ bulletList,
27
+ listItem,
28
+ codeBlock,
29
+ } from '@openstage/glyph-core';
30
+
31
+ const doc = document(
32
+ heading(1)(plain('Welcome')),
33
+ paragraph(plain('Hello '), text(bold)('world'), plain('.')),
34
+ paragraph(text(link('https://example.com'))('a link')),
35
+ bulletList(listItem(paragraph(plain('item one')))),
36
+ codeBlock('typescript')('const x = 1;'),
37
+ );
38
+ ```
39
+
40
+ The result is plain JSON — safe to `JSON.stringify` and store verbatim.
41
+
42
+ ## Validation & migration
43
+
44
+ For untrusted input (backend, `localStorage`):
45
+
46
+ ```ts
47
+ import { isEditorDocument, migrate } from '@openstage/glyph-core';
48
+
49
+ const raw: unknown = JSON.parse(localStorage.getItem('doc') ?? 'null');
50
+ if (isEditorDocument(raw)) {
51
+ const doc = migrate(raw); // upgrades older schema versions
52
+ }
53
+ ```
54
+
55
+ `assertEditorDocument` throws a `TypeError` with a path on invalid input.
56
+
57
+ ## What's inside
58
+
59
+ - Document model & schema (`EditorDocument`, `SCHEMA_VERSION`)
60
+ - Curried smart constructors (`document`, `heading`, `paragraph`, `text`,
61
+ `link`, `codeBlock`, list/quote helpers, …)
62
+ - Branded value types (`Href`, `Language`, `CommandId`) with `.of()` validators
63
+ - Structural validation (`isEditorDocument` / `assertEditorDocument`)
64
+ - Forward migration (`migrate`) and the supported-language list
65
+ - Shared types (`EditorConfig`, `EditorApi`, `SlashCommand`, `EditorTheme`,
66
+ `ToolbarItemId`, `ToolbarIcon`) and `DEFAULT_TOOLBAR`
67
+
68
+ The public API exposes no third-party types.
69
+
70
+ ## Documentation
71
+
72
+ Full guide, configuration reference, and backend-integration notes:
73
+ <https://codeberg.org/open-stage/glyph#readme>
74
+
75
+ ## License
76
+
77
+ MIT © Gabriel Bornea
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openstage/glyph-core",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "license": "MIT",
5
5
  "author": "Gabriel Bornea",
6
6
  "repository": {
@@ -33,5 +33,17 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "monadyssey": "^2.0.1"
36
- }
36
+ },
37
+ "description": "Engine-agnostic document model, smart constructors, validation and migration for the Glyph editor.",
38
+ "keywords": [
39
+ "editor",
40
+ "rich-text",
41
+ "prosemirror",
42
+ "tiptap",
43
+ "document-model",
44
+ "json",
45
+ "schema",
46
+ "wysiwyg",
47
+ "glyph"
48
+ ]
37
49
  }