@kition/kit-editor 0.0.0-stage → 0.1.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.
Files changed (66) hide show
  1. package/README.md +103 -2
  2. package/dist/LICENSE +177 -0
  3. package/dist/assets/kitEngine.worker-9PIHJagj.js +13020 -0
  4. package/dist/chunks/workspaceTree-CpJ2i9hy.js +23 -0
  5. package/dist/index.js +6434 -0
  6. package/dist/styles.css +807 -0
  7. package/dist/types/src/CommandDialog.d.ts +22 -0
  8. package/dist/types/src/CommentsPanel.d.ts +45 -0
  9. package/dist/types/src/CustomizeDialog.d.ts +32 -0
  10. package/dist/types/src/HostButtons.d.ts +11 -0
  11. package/dist/types/src/RenderFailure.d.ts +7 -0
  12. package/dist/types/src/TextSink.d.ts +6 -0
  13. package/dist/types/src/brand.d.ts +2 -0
  14. package/dist/types/src/catalogMenus.d.ts +27 -0
  15. package/dist/types/src/chart.d.ts +138 -0
  16. package/dist/types/src/conflicts.d.ts +12 -0
  17. package/dist/types/src/drawing.d.ts +83 -0
  18. package/dist/types/src/editor.d.ts +544 -0
  19. package/dist/types/src/engine/KitCanvas.d.ts +70 -0
  20. package/dist/types/src/engine/createKitFile.d.ts +12 -0
  21. package/dist/types/src/engine/decorations.d.ts +14 -0
  22. package/dist/types/src/engine/engineOverlays.d.ts +197 -0
  23. package/dist/types/src/engine/engineTools.d.ts +116 -0
  24. package/dist/types/src/engine/kitDraft.d.ts +70 -0
  25. package/dist/types/src/engine/kitEngine.d.ts +370 -0
  26. package/dist/types/src/engine/kitEngine.worker.d.ts +30 -0
  27. package/dist/types/src/engine/kitHost.d.ts +41 -0
  28. package/dist/types/src/engine/kitModel.d.ts +32 -0
  29. package/dist/types/src/engine/kitModelRunner.d.ts +93 -0
  30. package/dist/types/src/engine/kitModule.d.ts +173 -0
  31. package/dist/types/src/engine/kitShortcuts.d.ts +32 -0
  32. package/dist/types/src/engine/kitTools.d.ts +79 -0
  33. package/dist/types/src/engine/lentFiles.d.ts +29 -0
  34. package/dist/types/src/engine/rasterViewport.d.ts +178 -0
  35. package/dist/types/src/engine/readOnly.d.ts +78 -0
  36. package/dist/types/src/engine/refusal.d.ts +39 -0
  37. package/dist/types/src/engine/replica.d.ts +23 -0
  38. package/dist/types/src/engine/useKitDocument.d.ts +154 -0
  39. package/dist/types/src/engine/workerRelay.d.ts +62 -0
  40. package/dist/types/src/files.d.ts +74 -0
  41. package/dist/types/src/frame/EditorFrame.d.ts +74 -0
  42. package/dist/types/src/frame/FocusBar.d.ts +10 -0
  43. package/dist/types/src/frame/MenuNodes.d.ts +20 -0
  44. package/dist/types/src/frame/MenuRibbon.d.ts +8 -0
  45. package/dist/types/src/frame/ModeButton.d.ts +7 -0
  46. package/dist/types/src/frame/menus.d.ts +64 -0
  47. package/dist/types/src/frame/modes.d.ts +51 -0
  48. package/dist/types/src/frame/useFrameLayout.d.ts +34 -0
  49. package/dist/types/src/host.d.ts +127 -0
  50. package/dist/types/src/index.d.ts +84 -0
  51. package/dist/types/src/ink.d.ts +26 -0
  52. package/dist/types/src/lease.d.ts +53 -0
  53. package/dist/types/src/oneInFlight.d.ts +7 -0
  54. package/dist/types/src/phrases.d.ts +25 -0
  55. package/dist/types/src/presence.d.ts +79 -0
  56. package/dist/types/src/strings.d.ts +6 -0
  57. package/dist/types/src/toolIcons.d.ts +32 -0
  58. package/dist/types/src/uiCatalog.d.ts +59 -0
  59. package/dist/types/src/uiConfig.d.ts +53 -0
  60. package/dist/types/src/uiContext.d.ts +65 -0
  61. package/dist/types/src/uiStore.d.ts +20 -0
  62. package/dist/types/src/useCommentAnchors.d.ts +29 -0
  63. package/dist/types/src/useKitSession.d.ts +115 -0
  64. package/dist/types/src/workspaceTree.d.ts +5 -0
  65. package/dist/workspaceTree.js +1 -0
  66. package/package.json +43 -3
@@ -0,0 +1,22 @@
1
+ import type { KitCommand } from './engine/kitModule.js';
2
+ /** Whether running `command` needs values a person has to give (a required parameter). */
3
+ export declare function needsParams(command: KitCommand): boolean;
4
+ /**
5
+ * A command's parameters as a form, from its schema (standard A5): a menu for an enum, a number
6
+ * field, a check box, or a text field (JSON for arrays and objects). Runs it with the values.
7
+ */
8
+ export declare function CommandDialog({ command, onRun, onClose, labels, values: given, title, }: {
9
+ command: KitCommand;
10
+ onRun: (params: Record<string, unknown>) => void;
11
+ onClose: () => void;
12
+ labels: {
13
+ run: string;
14
+ cancel: string;
15
+ required: string;
16
+ more?: string;
17
+ };
18
+ /** Values to start with (the current page), over the schema's defaults. */
19
+ values?: Record<string, unknown>;
20
+ /** The dialog's title, translated (the command's title by default). */
21
+ title?: string;
22
+ }): import("react").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import type { CommentAnchor, CommentThread } from '@kition/kdm';
2
+ export type CommentsPanelLabels = {
3
+ title: string;
4
+ empty: string;
5
+ newComment: string;
6
+ placeholder: string;
7
+ replyPlaceholder: string;
8
+ comment: string;
9
+ reply: string;
10
+ cancel: string;
11
+ resolve: string;
12
+ reopen: string;
13
+ delete: string;
14
+ resolved: string;
15
+ readOnlyHistory: string;
16
+ you: string;
17
+ };
18
+ export declare const COMMENTS_PANEL_LABELS: CommentsPanelLabels;
19
+ export type CommentsPanelProps = {
20
+ threads: CommentThread[];
21
+ /** This person's principal id (the `author` of what they write); `null` when unknown. */
22
+ me: string | null;
23
+ /** Whether this person may write comments at all. */
24
+ canComment: boolean;
25
+ /** Threads others opened are read-only history (no co-editing session). */
26
+ othersReadOnly?: boolean;
27
+ /** Where a new thread would go; set, the panel shows its composer first. */
28
+ pendingAnchor?: CommentAnchor | null;
29
+ /** The thread the kit highlights (its anchor was clicked); the panel scrolls to it. */
30
+ activeThread?: string | null;
31
+ onActivate?: (thread: string) => void;
32
+ onAdd: (anchor: CommentAnchor, body: string) => void;
33
+ onCancelNew?: () => void;
34
+ onReply: (thread: string, body: string) => void;
35
+ onResolve: (thread: string, resolved: boolean) => void;
36
+ onDelete: (thread: string, comment: string) => void;
37
+ /** What the thread's anchor points at, to show above it ("Slide 2", a quote). */
38
+ anchorLabel?: (anchor: CommentAnchor) => string | null;
39
+ /** When a comment was written, for people; ISO text by default. */
40
+ formatTime?: (created: string) => string;
41
+ labels?: Partial<CommentsPanelLabels>;
42
+ testId?: string;
43
+ };
44
+ /** The comments side panel: the threads, newest activity last, and a composer for new ones. */
45
+ export declare function CommentsPanel(props: CommentsPanelProps): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import type { KitUiElement } from '@kition/kit-ui-protocol';
2
+ export type CustomizeNode = {
3
+ element: KitUiElement;
4
+ children: CustomizeNode[];
5
+ };
6
+ /**
7
+ * The tree the dialog shows: elements without host hides (`catalog` is built without the
8
+ * person's hides, so `hidden` means hidden by the host) or a host-hidden element above them,
9
+ * without commands outside menus, without More (the way back here), and, with a `query`, only
10
+ * matches and the elements above them.
11
+ *
12
+ * A kit's declared `parent` ids can be wrong and form a cycle (an element that is, directly or
13
+ * through a loop, its own ancestor). Children are indexed once (`O(n)`), and a node's subtree is
14
+ * built while tracking the ids on its current path; a child already on that path is cut (and
15
+ * warned about once) instead of recursed into, so a bad declaration cannot hang the dialog.
16
+ */
17
+ export declare function customizeTree(catalog: readonly KitUiElement[], query: string): CustomizeNode[];
18
+ type Labels = {
19
+ title: string;
20
+ search: string;
21
+ restore: string;
22
+ cancel: string;
23
+ save: string;
24
+ };
25
+ export declare function CustomizeDialog({ catalog, personal, labels, onSave, onClose }: {
26
+ catalog: readonly KitUiElement[];
27
+ personal: readonly string[];
28
+ labels: Labels;
29
+ onSave: (hide: string[]) => void;
30
+ onClose: () => void;
31
+ }): import("react").JSX.Element;
32
+ export {};
@@ -0,0 +1,11 @@
1
+ /** The host's buttons (protocol section 9) where a shared container draws them. */
2
+ import { type IconComponent } from '@kition/tessera-icons/react';
3
+ /** The icon names a host may give its buttons; an unknown name shows a plain square. */
4
+ export declare const HOST_ICONS: Record<string, IconComponent>;
5
+ /** A host icon as an icon component: a name from `HOST_ICONS`, or a `data:image/…` URL drawn as an image (it runs no script). `Object.hasOwn` keeps a name such as `constructor` or `__proto__` from resolving to an inherited property instead of a plain square. */
6
+ export declare function hostIcon(icon: string | undefined): IconComponent | undefined;
7
+ /** The host buttons at `place`, as menu items, ribbon buttons, or document action buttons. */
8
+ export declare function HostButtons({ place, as }: {
9
+ place: string;
10
+ as: 'menu' | 'ribbon' | 'action';
11
+ }): import("react").JSX.Element;
@@ -0,0 +1,7 @@
1
+ /** A render failure stays visible while the live canvas remains available for navigation. */
2
+ export declare function RenderFailure({ message, title, retryLabel, onRetry }: {
3
+ message: string;
4
+ title: string;
5
+ retryLabel: string;
6
+ onRetry: () => void;
7
+ }): import("react").JSX.Element;
@@ -0,0 +1,6 @@
1
+ import { type KeyboardEvent } from 'react';
2
+ export declare function TextSink({ active, onText, onKey }: {
3
+ active: boolean;
4
+ onText: (text: string) => void;
5
+ onKey: (event: KeyboardEvent<HTMLTextAreaElement>) => boolean;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ /** A kit's brand color (`ui.brand`, standard U5b) and its contrast rules, now in Kition Tessera. */
2
+ export { brandTokens, contrast, luminance, textOn, validBrand, type KitBrand } from '@kition/tessera-ui';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * An upstream-style menu catalog as menus: rows in catalog order, submenus to any depth where
3
+ * their first row is, separators collapsed where hidden rows leave them. Pure.
4
+ */
5
+ import type { MenuRow } from './uiCatalog.js';
6
+ /** A menu's contents: rows, separators, and submenus (`path` is the submenu's `menu:` path). */
7
+ export type CatalogNode = {
8
+ kind: 'row';
9
+ row: MenuRow;
10
+ } | {
11
+ kind: 'separator';
12
+ } | {
13
+ kind: 'submenu';
14
+ label: string;
15
+ path: string;
16
+ children: CatalogNode[];
17
+ };
18
+ export type CatalogMenu = {
19
+ label: string;
20
+ children: CatalogNode[];
21
+ };
22
+ /**
23
+ * A catalog as menus, in catalog order, with only `visible` rows. Separators collapse where hidden
24
+ * rows leave them leading, trailing, or doubled; a menu or submenu left empty is dropped unless
25
+ * `keepEmpty(path)`.
26
+ */
27
+ export declare function catalogMenuTree(catalog: readonly MenuRow[], visible: (row: MenuRow) => boolean, keepEmpty?: (path: string) => boolean): CatalogMenu[];
@@ -0,0 +1,138 @@
1
+ import { type IconComponent } from "@kition/tessera-icons/react";
2
+ /**
3
+ * Ribbon controls for charts, shared by every kit that implements `KitDrawing 1.1`'s charts
4
+ * (`drawing.insert` of kind `chart`, `drawing.chart`, `drawing.describe`'s `chart` member). Like
5
+ * the shape controls they hold no model: they read the chart's description and run commands, so
6
+ * the person's edit and an agent's are the same change.
7
+ */
8
+ /** An axis's scale and labels (`AxisSpec`); members left out are automatic. */
9
+ export type ChartAxis = {
10
+ min?: number;
11
+ max?: number;
12
+ major?: number;
13
+ numberFormat?: string;
14
+ hidden?: boolean;
15
+ };
16
+ /** A chart's description (`ChartSpec`, `KitDrawing 1.1` DR15). */
17
+ export type ChartSpec = {
18
+ kind: string | {
19
+ other: string;
20
+ };
21
+ title?: string;
22
+ categories: string[];
23
+ series: Array<{
24
+ name: string;
25
+ values: Array<number | null>;
26
+ color?: unknown;
27
+ kind?: string | {
28
+ other: string;
29
+ };
30
+ lineWidth?: number;
31
+ marker?: string;
32
+ smooth?: boolean;
33
+ trendline?: {
34
+ kind: string;
35
+ order?: number;
36
+ period?: number;
37
+ forward?: number;
38
+ backward?: number;
39
+ };
40
+ errorBars?: {
41
+ kind: string;
42
+ value?: number;
43
+ };
44
+ secondary?: boolean;
45
+ }>;
46
+ legend?: string;
47
+ dataLabels: boolean;
48
+ gridlines: boolean;
49
+ xTitle?: string;
50
+ yTitle?: string;
51
+ xAxis?: ChartAxis;
52
+ yAxis?: ChartAxis;
53
+ dataLabelPosition?: string;
54
+ };
55
+ /** The formatting a kit's charts take through `drawing.chart` (Chart Design › Format). */
56
+ export type ChartFormat = "axes" | "labelPosition" | "lineWidth" | "marker" | "smooth" | "trends" | "combo";
57
+ export declare const CHART_FORMATS: readonly ChartFormat[];
58
+ /** The types a series of a combination takes (Format Series › Chart Type). */
59
+ export declare const COMBO_KINDS: readonly ["column", "stackedColumn", "line", "lineMarkers", "area"];
60
+ /** Chart Elements › Trendline: Office's quick choices (DrawingML `ST_TrendlineType`). */
61
+ export declare const CHART_TRENDLINES: ReadonlyArray<{
62
+ id: string;
63
+ label: string;
64
+ trendline: {
65
+ kind: string;
66
+ forward?: number;
67
+ period?: number;
68
+ };
69
+ }>;
70
+ /** Chart Elements › Error Bars: Office's quick choices (DrawingML `ST_ErrValType`). */
71
+ export declare const CHART_ERROR_BARS: ReadonlyArray<{
72
+ id: string;
73
+ label: string;
74
+ errorBars: {
75
+ kind: string;
76
+ value?: number;
77
+ };
78
+ }>;
79
+ /** Series markers (DrawingML `ST_MarkerStyle`). */
80
+ export declare const CHART_MARKERS: readonly ["none", "auto", "circle", "dash", "diamond", "dot", "plus", "square", "star", "triangle", "x"];
81
+ /** Where a type's data labels may sit, as Office offers them. */
82
+ export declare function labelPositions(kind: ChartSpec["kind"] | undefined): string[];
83
+ /** Whether a type draws its series as lines, which take markers and smoothing. */
84
+ export declare function linesOf(kind: ChartSpec["kind"] | undefined): boolean;
85
+ /** The chart types the controls offer, by `KitDrawing` name. */
86
+ export declare const CHART_KINDS: ReadonlyArray<{
87
+ kind: string;
88
+ icon: IconComponent;
89
+ label: string;
90
+ }>;
91
+ /** Insert › Chart: a new chart of a type at the kit's default place, selected. */
92
+ export declare function ChartInsertMenu({ testId, size, primary, }: {
93
+ testId?: string;
94
+ size?: "large" | "small";
95
+ primary?: boolean;
96
+ }): import("react").JSX.Element;
97
+ /** The description of chart `id`, read again after every change to the document. */
98
+ export declare function useChartSpec(id: string | null): ChartSpec | null;
99
+ /**
100
+ * Chart Design for chart `id`: its type, its elements (title, legend, data labels, gridlines,
101
+ * axis titles), its formatting (axes, label position, series looks) and its data.
102
+ * `dataEditable` false (a spreadsheet, whose charts show its cells) leaves the data to the kit;
103
+ * `formats` names the formatting the kit's charts take (all by default).
104
+ */
105
+ export declare function ChartDesignGroups({ id, testId, dataEditable, formats, }: {
106
+ id: string;
107
+ testId?: string;
108
+ dataEditable?: boolean;
109
+ formats?: readonly ChartFormat[];
110
+ }): import("react").JSX.Element;
111
+ /** Format Axis: an axis's bounds, major unit, number format and whether it shows. */
112
+ export declare function ChartAxisDialog({ spec, onApply, onClose, testId, }: {
113
+ spec: ChartSpec;
114
+ onApply: (change: Record<string, unknown>) => void;
115
+ onClose: () => void;
116
+ testId?: string;
117
+ }): import("react").JSX.Element;
118
+ /** Format Series: a series' line width, marker and smoothing, as the kit takes them. */
119
+ export declare function ChartSeriesDialog({ spec, formats, onApply, onClose, testId, }: {
120
+ spec: ChartSpec;
121
+ formats?: readonly ChartFormat[];
122
+ onApply: (change: Record<string, unknown>) => void;
123
+ onClose: () => void;
124
+ testId?: string;
125
+ }): import("react").JSX.Element;
126
+ /** The chart's data as a grid: categories down, series across. */
127
+ export declare function ChartDataDialog({ spec, onApply, onClose, testId, }: {
128
+ spec: ChartSpec;
129
+ onApply: (data: {
130
+ categories: string[];
131
+ series: Array<{
132
+ name: string;
133
+ values: Array<number | null>;
134
+ }>;
135
+ }) => void;
136
+ onClose: () => void;
137
+ testId?: string;
138
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { KitConflict } from '@kition/kit-ui-protocol';
2
+ import type { HostConnection } from './host.js';
3
+ export type { KitConflict };
4
+ /** Parses an engine's conflict list (JSON or a value): the well-formed entries, ordered by id. */
5
+ export declare function parseConflicts(value: unknown): KitConflict[];
6
+ /** Tells the host the document's unresolved conflicts (`document/conflicts`) when they changed since last told. */
7
+ export declare function reportConflicts(host: HostConnection, conflicts: KitConflict[]): void;
8
+ /**
9
+ * Reads the document's conflicts with `read` after every change (`revision`) and reports them
10
+ * when they changed. `read` failing (an engine without conflicts) reports nothing.
11
+ */
12
+ export declare function useConflictReport(host: HostConnection, read: (() => Promise<unknown>) | null, revision: number): void;
@@ -0,0 +1,83 @@
1
+ import { type IconComponent } from '@kition/tessera-icons/react';
2
+ /**
3
+ * Ribbon controls for drawing objects, shared by every kit that implements the Kit Harness
4
+ * Protocol's `KitDrawing 1.0` (`drawing.insert`, `drawing.format`, `drawing.transform`,
5
+ * `drawing.delete`). They hold no model of their own: every control runs an engine command, so
6
+ * the person's edit and an agent's are the same change.
7
+ */
8
+ /** The shapes the menu offers, by DrawingML preset name. */
9
+ export declare const DRAWING_SHAPES: ReadonlyArray<{
10
+ preset: string;
11
+ icon: IconComponent;
12
+ label: string;
13
+ }>;
14
+ /** Outline weights in points. */
15
+ export declare const DRAWING_WEIGHTS: number[];
16
+ /**
17
+ * Insert › Shapes and Text Box: a new object at the kit's default place, selected. `label` names
18
+ * the group (default Illustrations), for a kit whose own Illustrations group sits beside it.
19
+ * `merge` takes the engine's group at that path (`"Insert/Illustrations"`) into this one, less
20
+ * the engine's own Shapes and Text Box; leave that group out of the kit's `CommandTab` (`omit`).
21
+ * `primary` lists the merged engine commands Single line's row shows; Shapes and Text Box always
22
+ * show there.
23
+ */
24
+ export declare function DrawingInsertGroup({ testId, label, merge, exclude, primary }: {
25
+ testId?: string;
26
+ label?: string;
27
+ merge?: string;
28
+ exclude?: readonly string[];
29
+ primary?: readonly string[];
30
+ }): import("react").JSX.Element;
31
+ /** Shape Format › Fill › Gradient: from the colour to its light tint, as Office's variations go. */
32
+ export declare const DRAWING_GRADIENTS: ReadonlyArray<{
33
+ id: string;
34
+ label: string;
35
+ angle: number;
36
+ path?: string;
37
+ }>;
38
+ /** A gradient fill of `kind` from `color` (`#RRGGBB`) to its light tint. */
39
+ export declare function gradientFill(color: string, kind: (typeof DRAWING_GRADIENTS)[number]): {
40
+ gradient: {
41
+ path?: string | undefined;
42
+ stops: {
43
+ pos: number;
44
+ color: string;
45
+ }[];
46
+ angle: number;
47
+ };
48
+ };
49
+ /** Shape Format › Effects: shadows and a glow, as Office's presets go. */
50
+ export declare const DRAWING_SHADOWS: ReadonlyArray<{
51
+ id: string;
52
+ label: string;
53
+ shadow: {
54
+ blur: number;
55
+ distance: number;
56
+ angle: number;
57
+ };
58
+ }>;
59
+ /** Shape Format › Transform: WordArt's preset text warps (`KitDrawing 1.3`, DR26). */
60
+ export declare const DRAWING_WARPS: ReadonlyArray<{
61
+ preset: string;
62
+ label: string;
63
+ }>;
64
+ /**
65
+ * Shape Format › Transform's menu: `onPick` gets a preset of [`DRAWING_WARPS`], or `null` for
66
+ * no transform. `DrawingFormatGroup` runs `drawing.text`; a kit with its own command for the
67
+ * selection runs that.
68
+ */
69
+ export declare function DrawingWarpMenu({ disabled, testId, onPick }: {
70
+ disabled?: boolean;
71
+ testId?: string;
72
+ onPick: (preset: string | null) => void;
73
+ }): import("react").JSX.Element;
74
+ /**
75
+ * Shape Format for the selected objects `ids`: fill, outline colour and weight, effects, a text
76
+ * warp (each object's own `drawing.text`), the shape's outline, where they sit in the stack (`drawing.arrange`), grouping, a quarter turn, and
77
+ * deleting. Shown by the kit while it has drawing objects selected.
78
+ */
79
+ export declare function DrawingFormatGroup({ ids, testId, effects }: {
80
+ ids: readonly string[];
81
+ testId?: string;
82
+ effects?: boolean;
83
+ }): import("react").JSX.Element;