@x12i/editor 0.0.0-stage → 1.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 x12i
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
1
+ # @x12i/editor
2
+
3
+ Document schema for the Unified UI Kit block editor.
4
+
5
+ > **Status: foundation.** This package ships the versioned document JSON and the
6
+ > provider contracts for collaboration and AI assistance. The editor, the engine
7
+ > spike and the converters are not built yet.
8
+
9
+ The stored document is JSON that the kit owns, so the engine behind the editor
10
+ can change without migrating saved documents. It includes the kit blocks: a
11
+ chart block holds a [`ChartSpec`](../charts), a diagram block holds a
12
+ [`DiagramDocument`](../diagrams) and a data view block holds a
13
+ [`SavedView`](../data).
14
+
15
+ ```ts
16
+ import { createEmptyDocument, type EditorDocument } from "@x12i/editor";
17
+
18
+ const doc: EditorDocument = createEmptyDocument();
19
+ ```
20
+
21
+ ## Planned engine
22
+
23
+ Decided by a scored spike: Tiptap core on ProseMirror (MIT) is the default if
24
+ scores tie, with Plate and Lexical as alternatives. Collaboration will use Yjs
25
+ behind `CollaborationProvider`, with Hocuspocus (MIT) as the reference server.
26
+
27
+ Not allowed: BlockNote XL packages (GPL-3.0 or commercial) and Tiptap Pro
28
+ extensions or cloud features that need a subscription.
@@ -0,0 +1,184 @@
1
+ import { ChartSpec } from '@x12i/charts';
2
+ import { SavedView } from '@x12i/data';
3
+ import { DiagramDocument } from '@x12i/diagrams';
4
+
5
+ /**
6
+ * The stored document (spec section 11): versioned JSON owned by the kit, with
7
+ * converters to and from the engine's format planned. That keeps the editor
8
+ * engine (Tiptap by default) replaceable.
9
+ */
10
+
11
+ declare const DOCUMENT_VERSION = 1;
12
+ type Mark = {
13
+ type: "bold";
14
+ } | {
15
+ type: "italic";
16
+ } | {
17
+ type: "underline";
18
+ } | {
19
+ type: "strike";
20
+ } | {
21
+ type: "code";
22
+ } | {
23
+ type: "link";
24
+ href: string;
25
+ } | {
26
+ type: "color";
27
+ token: string;
28
+ } | {
29
+ type: "highlight";
30
+ token: string;
31
+ };
32
+ type InlineNode = {
33
+ type: "text";
34
+ text: string;
35
+ marks?: Mark[];
36
+ } | {
37
+ type: "mention";
38
+ kind: "person" | "page" | "date";
39
+ id: string;
40
+ label: string;
41
+ } | {
42
+ type: "emoji";
43
+ shortcode: string;
44
+ };
45
+ type Inline = InlineNode[];
46
+ interface BlockBase {
47
+ id: string;
48
+ }
49
+ type CalloutVariant = "info" | "success" | "warning" | "danger" | "neutral";
50
+ interface TaskItem {
51
+ id: string;
52
+ content: Inline;
53
+ checked: boolean;
54
+ children?: TaskItem[];
55
+ }
56
+ interface ListItem {
57
+ id: string;
58
+ content: Inline;
59
+ children?: ListItem[];
60
+ }
61
+ interface TableCell {
62
+ content: Inline;
63
+ colSpan?: number;
64
+ rowSpan?: number;
65
+ header?: boolean;
66
+ }
67
+ type Block = BlockBase & ({
68
+ type: "paragraph";
69
+ content: Inline;
70
+ } | {
71
+ type: "heading";
72
+ level: 1 | 2 | 3 | 4;
73
+ content: Inline;
74
+ } | {
75
+ type: "quote";
76
+ content: Inline;
77
+ } | {
78
+ type: "callout";
79
+ variant: CalloutVariant;
80
+ content: Inline;
81
+ } | {
82
+ type: "toggle";
83
+ summary: Inline;
84
+ children: Block[];
85
+ } | {
86
+ type: "divider";
87
+ } | {
88
+ type: "bulleted-list";
89
+ items: ListItem[];
90
+ } | {
91
+ type: "numbered-list";
92
+ items: ListItem[];
93
+ } | {
94
+ type: "task-list";
95
+ items: TaskItem[];
96
+ } | {
97
+ type: "code";
98
+ language?: string;
99
+ code: string;
100
+ } | {
101
+ type: "equation";
102
+ latex: string;
103
+ } | {
104
+ type: "table";
105
+ headerRow?: boolean;
106
+ headerColumn?: boolean;
107
+ rows: TableCell[][];
108
+ } | {
109
+ type: "image";
110
+ src: string;
111
+ alt: string;
112
+ caption?: Inline;
113
+ align?: "start" | "center" | "end";
114
+ width?: number;
115
+ } | {
116
+ type: "video" | "audio";
117
+ src: string;
118
+ caption?: Inline;
119
+ } | {
120
+ type: "file";
121
+ src: string;
122
+ name: string;
123
+ size?: number;
124
+ } | {
125
+ type: "bookmark";
126
+ url: string;
127
+ title?: string;
128
+ description?: string;
129
+ } | {
130
+ type: "columns";
131
+ columns: Block[][];
132
+ } | {
133
+ type: "page-break";
134
+ } | {
135
+ type: "table-of-contents";
136
+ } | {
137
+ type: "chart";
138
+ spec: ChartSpec;
139
+ } | {
140
+ type: "diagram";
141
+ engine: "mermaid" | "canvas" | "excalidraw";
142
+ diagram?: DiagramDocument;
143
+ source?: string;
144
+ } | {
145
+ type: "data-view";
146
+ dataset: string;
147
+ view: SavedView;
148
+ } | {
149
+ type: "ai";
150
+ prompt: string;
151
+ result?: Block[];
152
+ });
153
+ type BlockType = Block["type"];
154
+ interface EditorDocument {
155
+ version: typeof DOCUMENT_VERSION;
156
+ title?: string;
157
+ blocks: Block[];
158
+ }
159
+ /** An empty document with one empty paragraph. */
160
+ declare function createEmptyDocument(id?: string): EditorDocument;
161
+ /** Shared document model behind a provider interface (Yjs and Hocuspocus planned). */
162
+ interface CollaborationProvider {
163
+ connect(documentId: string): Promise<void>;
164
+ disconnect(): void;
165
+ onPresence(listener: (users: Array<{
166
+ id: string;
167
+ name: string;
168
+ color: string;
169
+ }>) => void): () => void;
170
+ }
171
+ type AiCommand = "continue" | "summarize" | "rewrite" | "fix-grammar";
172
+ /** Provider-agnostic hook. The kit calls no model by itself. */
173
+ interface AiProvider {
174
+ run(input: {
175
+ command: AiCommand;
176
+ selection: string;
177
+ /** For `rewrite`, for example "formal". */
178
+ tone?: string;
179
+ signal?: AbortSignal;
180
+ }): AsyncIterable<string>;
181
+ }
182
+
183
+ export { DOCUMENT_VERSION, createEmptyDocument };
184
+ export type { AiCommand, AiProvider, Block, BlockBase, BlockType, CalloutVariant, CollaborationProvider, EditorDocument, Inline, InlineNode, ListItem, Mark, TableCell, TaskItem };
package/dist/index.js ADDED
@@ -0,0 +1,12 @@
1
+ // src/index.ts
2
+ var DOCUMENT_VERSION = 1;
3
+ function createEmptyDocument(id = "root") {
4
+ return {
5
+ version: DOCUMENT_VERSION,
6
+ blocks: [{ id, type: "paragraph", content: [] }]
7
+ };
8
+ }
9
+
10
+ export { DOCUMENT_VERSION, createEmptyDocument };
11
+ //# sourceMappingURL=index.js.map
12
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";AASO,IAAM,gBAAA,GAAmB;AA0FzB,SAAS,mBAAA,CAAoB,KAAK,MAAA,EAAwB;AAC/D,EAAA,OAAO;AAAA,IACL,OAAA,EAAS,gBAAA;AAAA,IACT,MAAA,EAAQ,CAAC,EAAE,EAAA,EAAI,MAAM,WAAA,EAAa,OAAA,EAAS,EAAC,EAAG;AAAA,GACjD;AACF","file":"index.js","sourcesContent":["/**\r\n * The stored document (spec section 11): versioned JSON owned by the kit, with\r\n * converters to and from the engine's format planned. That keeps the editor\r\n * engine (Tiptap by default) replaceable.\r\n */\r\nimport type { ChartSpec } from \"@x12i/charts\";\r\nimport type { SavedView } from \"@x12i/data\";\r\nimport type { DiagramDocument } from \"@x12i/diagrams\";\r\n\r\nexport const DOCUMENT_VERSION = 1;\r\n\r\n// ---------------------------------------------------------------------------\r\n// Inline content\r\n// ---------------------------------------------------------------------------\r\n\r\nexport type Mark =\r\n | { type: \"bold\" }\r\n | { type: \"italic\" }\r\n | { type: \"underline\" }\r\n | { type: \"strike\" }\r\n | { type: \"code\" }\r\n | { type: \"link\"; href: string }\r\n | { type: \"color\"; token: string }\r\n | { type: \"highlight\"; token: string };\r\n\r\nexport type InlineNode =\r\n | { type: \"text\"; text: string; marks?: Mark[] }\r\n | { type: \"mention\"; kind: \"person\" | \"page\" | \"date\"; id: string; label: string }\r\n | { type: \"emoji\"; shortcode: string };\r\n\r\nexport type Inline = InlineNode[];\r\n\r\n// ---------------------------------------------------------------------------\r\n// Blocks\r\n// ---------------------------------------------------------------------------\r\n\r\nexport interface BlockBase {\r\n id: string;\r\n}\r\n\r\nexport type CalloutVariant = \"info\" | \"success\" | \"warning\" | \"danger\" | \"neutral\";\r\n\r\nexport interface TaskItem {\r\n id: string;\r\n content: Inline;\r\n checked: boolean;\r\n children?: TaskItem[];\r\n}\r\n\r\nexport interface ListItem {\r\n id: string;\r\n content: Inline;\r\n children?: ListItem[];\r\n}\r\n\r\nexport interface TableCell {\r\n content: Inline;\r\n colSpan?: number;\r\n rowSpan?: number;\r\n header?: boolean;\r\n}\r\n\r\nexport type Block = BlockBase &\r\n (\r\n | { type: \"paragraph\"; content: Inline }\r\n | { type: \"heading\"; level: 1 | 2 | 3 | 4; content: Inline }\r\n | { type: \"quote\"; content: Inline }\r\n | { type: \"callout\"; variant: CalloutVariant; content: Inline }\r\n | { type: \"toggle\"; summary: Inline; children: Block[] }\r\n | { type: \"divider\" }\r\n | { type: \"bulleted-list\"; items: ListItem[] }\r\n | { type: \"numbered-list\"; items: ListItem[] }\r\n | { type: \"task-list\"; items: TaskItem[] }\r\n | { type: \"code\"; language?: string; code: string }\r\n | { type: \"equation\"; latex: string }\r\n | { type: \"table\"; headerRow?: boolean; headerColumn?: boolean; rows: TableCell[][] }\r\n | { type: \"image\"; src: string; alt: string; caption?: Inline; align?: \"start\" | \"center\" | \"end\"; width?: number }\r\n | { type: \"video\" | \"audio\"; src: string; caption?: Inline }\r\n | { type: \"file\"; src: string; name: string; size?: number }\r\n | { type: \"bookmark\"; url: string; title?: string; description?: string }\r\n | { type: \"columns\"; columns: Block[][] }\r\n | { type: \"page-break\" }\r\n | { type: \"table-of-contents\" }\r\n // Kit blocks\r\n | { type: \"chart\"; spec: ChartSpec }\r\n | { type: \"diagram\"; engine: \"mermaid\" | \"canvas\" | \"excalidraw\"; diagram?: DiagramDocument; source?: string }\r\n | { type: \"data-view\"; dataset: string; view: SavedView }\r\n | { type: \"ai\"; prompt: string; result?: Block[] }\r\n );\r\n\r\nexport type BlockType = Block[\"type\"];\r\n\r\nexport interface EditorDocument {\r\n version: typeof DOCUMENT_VERSION;\r\n title?: string;\r\n blocks: Block[];\r\n}\r\n\r\n/** An empty document with one empty paragraph. */\r\nexport function createEmptyDocument(id = \"root\"): EditorDocument {\r\n return {\r\n version: DOCUMENT_VERSION,\r\n blocks: [{ id, type: \"paragraph\", content: [] }],\r\n };\r\n}\r\n\r\n// ---------------------------------------------------------------------------\r\n// Optional packages: collaboration and AI assistance\r\n// ---------------------------------------------------------------------------\r\n\r\n/** Shared document model behind a provider interface (Yjs and Hocuspocus planned). */\r\nexport interface CollaborationProvider {\r\n connect(documentId: string): Promise<void>;\r\n disconnect(): void;\r\n onPresence(listener: (users: Array<{ id: string; name: string; color: string }>) => void): () => void;\r\n}\r\n\r\nexport type AiCommand = \"continue\" | \"summarize\" | \"rewrite\" | \"fix-grammar\";\r\n\r\n/** Provider-agnostic hook. The kit calls no model by itself. */\r\nexport interface AiProvider {\r\n run(input: {\r\n command: AiCommand;\r\n selection: string;\r\n /** For `rewrite`, for example \"formal\". */\r\n tone?: string;\r\n signal?: AbortSignal;\r\n }): AsyncIterable<string>;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@x12i/editor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.0",
4
+ "description": "Document schema for the Unified UI Kit block editor: versioned JSON owned by the kit, so the engine stays replaceable. The editor itself is planned.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/x12i/unified-ui-kit.git",
9
+ "directory": "packages/editor"
10
+ },
11
+ "homepage": "https://github.com/x12i/unified-ui-kit/tree/main/packages/editor#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/x12i/unified-ui-kit/issues"
14
+ },
15
+ "type": "module",
16
+ "sideEffects": false,
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.js"
25
+ },
26
+ "./package.json": "./package.json"
27
+ },
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "dependencies": {
32
+ "@x12i/charts": "^1.0.0",
33
+ "@x12i/data": "^1.0.0",
34
+ "@x12i/diagrams": "^1.0.0"
35
+ },
36
+ "scripts": {
37
+ "build": "tsup",
38
+ "typecheck": "tsc --noEmit",
39
+ "lint": "eslint .",
40
+ "test": "vitest run --passWithNoTests"
41
+ }
6
42
  }