@shadow-garden/bapbong-ui 0.15.0 → 0.17.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.
@@ -0,0 +1,44 @@
1
+ import type { EqNode, VectorImageSpec } from '@shadow-garden/bapbong-contracts';
2
+ /** One entry of the built-in gallery: a name and the equation it inserts. */
3
+ export interface BuiltInEquation {
4
+ name: string;
5
+ ast: EqNode[];
6
+ }
7
+ /**
8
+ * The built-in equations Insert ▸ Equation offers, the way Word's gallery
9
+ * does. Chosen for the documents bapbong is actually used on — Vietnamese
10
+ * exam papers — so the list is the secondary-school canon, not Word's
11
+ * (Fourier series has no place in a year-12 paper). Each is a real AST: what
12
+ * lands in the document is editable, exports as m:oMath, and needs no
13
+ * conversion.
14
+ */
15
+ export declare const BUILT_IN_EQUATIONS: readonly BuiltInEquation[];
16
+ /**
17
+ * A typeset equation drawn as inline SVG — the SAME display list the canvas
18
+ * painter replays, so a preview is the drawing the page will show rather
19
+ * than an approximation of it. Pure geometry from contracts: this package
20
+ * still knows nothing about the layout engine (the caller typesets and
21
+ * hands the spec over).
22
+ */
23
+ export declare function equationPreviewSvg(spec: VectorImageSpec, opts?: {
24
+ maxWidth?: number;
25
+ }): SVGSVGElement;
26
+ export interface EquationGalleryOptions {
27
+ /** Entries to offer. Defaults to {@link BUILT_IN_EQUATIONS}. */
28
+ items?: readonly BuiltInEquation[];
29
+ /**
30
+ * Typesets one entry the way the document does — hosts pass the layout
31
+ * engine bound to the editor's own measurer, so a preview matches the
32
+ * page exactly. Without it the preview falls back to the equation's
33
+ * linear spelling.
34
+ */
35
+ layout?: (ast: EqNode[], sizePt: number) => VectorImageSpec | null;
36
+ /** A gallery entry was chosen — insert this equation. */
37
+ onPick: (ast: EqNode[]) => void;
38
+ /** The footer action: start an empty equation instead. */
39
+ onNew: () => void;
40
+ /** Shortcut hint shown beside the footer action (e.g. "⌥="). */
41
+ newShortcut?: string;
42
+ }
43
+ export declare function equationGallery(options: EquationGalleryOptions): HTMLElement;
44
+ //# sourceMappingURL=equation-gallery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equation-gallery.d.ts","sourceRoot":"","sources":["../../src/lib/equation-gallery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,eAAe,EAEhB,MAAM,kCAAkC,CAAC;AAI1C,6EAA6E;AAC7E,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,EAAE,CAAC;CACf;AAkBD;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAAS,eAAe,EAqExD,CAAC;AAIF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,eAAe,EACrB,IAAI,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,aAAa,CAYf;AAiDD,MAAM,WAAW,sBAAsB;IACrC,gEAAgE;IAChE,KAAK,CAAC,EAAE,SAAS,eAAe,EAAE,CAAC;IACnC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,eAAe,GAAG,IAAI,CAAC;IACnE,yDAAyD;IACzD,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IAChC,0DAA0D;IAC1D,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,gEAAgE;IAChE,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AA8BD,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,WAAW,CA6D5E"}
@@ -0,0 +1,30 @@
1
+ import type { EqNode, EqStructure, VectorImageSpec } from '@shadow-garden/bapbong-contracts';
2
+ export interface EquationPanelOptions {
3
+ /**
4
+ * Typesets one template the way the document would — the host passes the
5
+ * layout engine bound to the editor's measurer, so a preview is the
6
+ * drawing the page will show. Without it the structure grid falls back to
7
+ * plain labels.
8
+ */
9
+ layout?: (ast: EqNode[], sizePt: number) => VectorImageSpec | null;
10
+ /** A symbol was chosen — insert this character at the slot caret. */
11
+ onSymbol: (ch: string) => void;
12
+ /** A structure was chosen — insert this template at the slot caret. */
13
+ onStructure: (s: EqStructure) => void;
14
+ }
15
+ export interface EquationPanel {
16
+ /** The panel element. The caller positions it and shows/hides it. */
17
+ readonly el: HTMLElement;
18
+ destroy(): void;
19
+ }
20
+ /**
21
+ * The equation palette: Word's Symbols and Structures galleries as ONE
22
+ * floating surface with tabs inside it, rather than a bar that opens a
23
+ * separate flyout. Switching tabs then swaps the contents while the frame
24
+ * stays put — and inserting six symbols in a row costs no re-opening.
25
+ *
26
+ * Knows nothing about the editor: it reports a chosen symbol or template and
27
+ * the host hands that to the slot editor.
28
+ */
29
+ export declare function equationPanel(options: EquationPanelOptions): EquationPanel;
30
+ //# sourceMappingURL=equation-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"equation-panel.d.ts","sourceRoot":"","sources":["../../src/lib/equation-panel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,MAAM,EACN,WAAW,EACX,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAS1C,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,KAAK,eAAe,GAAG,IAAI,CAAC;IACnE,qEAAqE;IACrE,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/B,uEAAuE;IACvE,WAAW,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,aAAa;IAC5B,qEAAqE;IACrE,QAAQ,CAAC,EAAE,EAAE,WAAW,CAAC;IACzB,OAAO,IAAI,IAAI,CAAC;CACjB;AA+BD;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA8I1E"}
@@ -1 +1 @@
1
- {"version":3,"file":"font-dialog.d.ts","sourceRoot":"","sources":["../../src/lib/font-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AA+B5E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,4CAA4C;IAC5C,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChD;AAsGD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE,iBAAiB,GAAG,IAAI,CA2T1B"}
1
+ {"version":3,"file":"font-dialog.d.ts","sourceRoot":"","sources":["../../src/lib/font-dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AA+B5E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,2EAA2E;IAC3E,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5B,4CAA4C;IAC5C,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,OAAO,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAChD;AAkGD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,KAAK,EACL,OAAO,GACR,EAAE,iBAAiB,GAAG,IAAI,CA4T1B"}
@@ -32,6 +32,14 @@ export declare const IS_MAC: boolean;
32
32
  * a host passes its app registry after it for chords like ⌘F that live there.
33
33
  */
34
34
  export declare function shortcutLabel(command: string, registries: readonly (KeybindingRegistry | undefined)[]): string | undefined;
35
+ /**
36
+ * The segmented tab strip every bapbong-ui surface uses — the Font dialog's
37
+ * Font/Advanced, the equation palette's Symbols/Structures. One definition,
38
+ * so a widget added later cannot drift into its own look, and it reads the
39
+ * `--bb-ui-active-*` and `--bb-ui-control-*` variables the host already maps
40
+ * to its theme rather than inventing names nobody sets.
41
+ */
42
+ export declare const TABS_CSS = "\n.bb-tabs{display:inline-flex;align-self:flex-start;border:0.5px solid var(--bb-ui-control-border,var(--bb-ui-border,#d8d6cf));border-radius:6px;overflow:hidden}\n.bb-tab{height:30px;padding:0 18px;border:0;border-right:0.5px solid var(--bb-ui-border,#e3e3e0);background:transparent;color:inherit;opacity:.65;font:inherit;font-size:13px;cursor:pointer}\n.bb-tab:last-child{border-right:0}\n.bb-tab:hover{background:var(--bb-ui-hover,#f1efe8);opacity:.9}\n.bb-tab[aria-selected=\"true\"]{background:var(--bb-ui-active-bg,#e6f1fb);color:var(--bb-ui-active-fg,#0c447c);opacity:1}\n";
35
43
  /** Inject a stylesheet once, keyed by `id` (idempotent across mounts). */
36
44
  export declare function injectStyle(id: string, css: string): void;
37
45
  /** A rectangle to hang a floating panel from — a caret box, a button, or any
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/lib/internal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,kBAAkB,EACnB,MAAM,kCAAkC,CAAC;AAG1C;2DAC2D;AAC3D,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAE1D;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC;IACvC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,2BAA2B;IAC3B,QAAQ,EAAE,QAA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ACvC,CAwCA"}
@@ -1 +1 @@
1
- {"version":3,"file":"link-panel.d.ts","sourceRoot":"","sources":["../../src/lib/link-panel.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD;;;;;+CAK2C;IAC3C,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,IAAI,IAAI,CAAC;KACd,GAAG,IAAI,CAAC;IACT;qBACiB;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;+DAG2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd;0EACsE;IACtE,MAAM,IAAI,OAAO,CAAC;CACnB;AAyDD,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,eAAe,CA8MrE"}
1
+ {"version":3,"file":"link-panel.d.ts","sourceRoot":"","sources":["../../src/lib/link-panel.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;GAaG;AAEH,MAAM,WAAW,eAAe;IAC9B,uEAAuE;IACvE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACjD;;;;;+CAK2C;IAC3C,QAAQ,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,IAAI,IAAI,IAAI,CAAC;KACd,GAAG,IAAI,CAAC;IACT;qBACiB;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;+DAG2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,mEAAmE;IACnE,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,QAAQ,CAAC,IAAI,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,IAAI,IAAI,CAAC;IACd;0EACsE;IACtE,MAAM,IAAI,OAAO,CAAC;CACnB;AAyDD,wBAAgB,aAAa,CAAC,IAAI,EAAE,gBAAgB,GAAG,eAAe,CA+MrE"}
@@ -0,0 +1,45 @@
1
+ import { type ResolvedTableStyle, type TableLook } from '@shadow-garden/bapbong-contracts';
2
+ /**
3
+ * The Table style panel — Word's Table Design surface as one non-modal
4
+ * floating dialog: the six tblLook gates ("Table style options") and a
5
+ * gallery of styles whose thumbnails are drawn from the SAME resolved sheet
6
+ * and the SAME cellStyleLayer the renderer uses, so a preview can never
7
+ * disagree with the page.
8
+ *
9
+ * The host owns the data and the commands (applyTableStyle / setTableLook);
10
+ * the panel renders and reports. All three entry points — Format ▸ Table ▸
11
+ * Table style…, the contextual toolbar button, the table context menu — open
12
+ * this one instance.
13
+ */
14
+ export interface TableStyleGalleryItem {
15
+ id: string;
16
+ /** Human name for the tile tooltip + footer ("Light Grid · Accent 3"). */
17
+ name: string;
18
+ style: ResolvedTableStyle;
19
+ }
20
+ export interface TableStylePanelOptions {
21
+ /** Gallery content, re-read on every {@link TableStylePanelHandle.refresh}:
22
+ * typically the document's own sheet plus the host's built-in catalog. */
23
+ styles: () => TableStyleGalleryItem[];
24
+ /** The enclosing table's pair, or null when the caret left every table. */
25
+ current: () => {
26
+ styleId: string | null;
27
+ look: TableLook;
28
+ } | null;
29
+ /** A gallery pick (null = the "None" tile). */
30
+ onPick: (item: TableStyleGalleryItem | null) => void;
31
+ /** A gate checkbox flip. */
32
+ onLook: (patch: Partial<TableLook>) => void;
33
+ /** Where to float (see Dialog.anchor / panelAnchor). */
34
+ anchor?: () => DOMRect | null;
35
+ }
36
+ export interface TableStylePanelHandle {
37
+ open(): void;
38
+ close(): void;
39
+ /** Re-read styles()/current() and redraw. Cheap no-op when nothing moved. */
40
+ refresh(): void;
41
+ destroy(): void;
42
+ readonly isOpen: boolean;
43
+ }
44
+ export declare function createTableStylePanel(options: TableStylePanelOptions): TableStylePanelHandle;
45
+ //# sourceMappingURL=table-style-panel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table-style-panel.d.ts","sourceRoot":"","sources":["../../src/lib/table-style-panel.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,kBAAkB,EAEvB,KAAK,SAAS,EACf,MAAM,kCAAkC,CAAC;AAI1C;;;;;;;;;;;GAWG;AAEH,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,0EAA0E;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,kBAAkB,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC;+EAC2E;IAC3E,MAAM,EAAE,MAAM,qBAAqB,EAAE,CAAC;IACtC,2EAA2E;IAC3E,OAAO,EAAE,MAAM;QAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,GAAG,IAAI,CAAC;IAClE,+CAA+C;IAC/C,MAAM,EAAE,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,KAAK,IAAI,CAAC;IACrD,4BAA4B;IAC5B,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,KAAK,IAAI,CAAC;IAC5C,wDAAwD;IACxD,MAAM,CAAC,EAAE,MAAM,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,IAAI,IAAI,CAAC;IACb,KAAK,IAAI,IAAI,CAAC;IACd,6EAA6E;IAC7E,OAAO,IAAI,IAAI,CAAC;IAChB,OAAO,IAAI,IAAI,CAAC;IAChB,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;CAC1B;AAyED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,sBAAsB,GAC9B,qBAAqB,CAmHvB"}
@@ -79,16 +79,38 @@ export interface ToolbarButton {
79
79
  label?: string;
80
80
  /** Inline SVG markup (used instead of `label`). */
81
81
  svg?: string;
82
+ /** Text rendered BESIDE the svg — a labelled button ("Table style"). */
83
+ text?: string;
84
+ /** Render as an accent pill (the is-active palette, so every theme that
85
+ * restyles active buttons restyles this too) — for the one control in a
86
+ * contextual group that users should spot without hunting. */
87
+ accent?: boolean;
88
+ /** Append a small ▾ — the button opens a panel. */
89
+ caret?: boolean;
82
90
  /** Called with the button element (the anchor for what opens). */
83
91
  onClick: (anchor: HTMLElement) => void;
84
92
  }
85
93
  /** A toolbar group entry: a command name (button) or a control
86
94
  * (select/colour/split/button). */
87
95
  export type ToolbarEntry = string | ToolbarSelect | ToolbarColor | ToolbarSplit | ToolbarButton;
96
+ /** A toolbar cluster: a plain entry list, or one that only SHOWS in certain
97
+ * editor states (`visible`) — the contextual "Table style" group renders
98
+ * only while the caret sits in a table. Visibility is re-evaluated on every
99
+ * editor change, and a flip re-runs the overflow fold, so a group appearing
100
+ * never silently pushes the tail of the row out of sight. */
101
+ export type ToolbarGroup = ToolbarEntry[] | {
102
+ entries: ToolbarEntry[];
103
+ visible?: (state: EditorStateOf) => boolean;
104
+ /** Fold into the overflow popover only after every non-sticky group
105
+ * has folded (tail-first among sticky groups themselves) — for the
106
+ * contextual control that should stay in sight while anything else
107
+ * can still give way. */
108
+ sticky?: boolean;
109
+ };
88
110
  export interface ToolbarOptions {
89
111
  /** Groups rendered as separated clusters — command names (buttons) and/or
90
112
  * controls (selects). Defaults to marks then alignments, from the registry. */
91
- groups?: ToolbarEntry[][];
113
+ groups?: ToolbarGroup[];
92
114
  /** Presentation per command name, merged over the built-in defaults. */
93
115
  items?: Record<string, ToolbarItem>;
94
116
  }
@@ -106,5 +128,24 @@ export declare function defaultToolbarGroups(commands: Collection<Command>): str
106
128
  * DOM, styling and active-state tracking; a host framework only provides the
107
129
  * element and the editor handle, then calls `destroy()` on teardown.
108
130
  */
131
+ /** One toolbar group as the fold arithmetic sees it. */
132
+ export interface FoldCandidate {
133
+ /** Original toolbar position — identity for the returned set. */
134
+ idx: number;
135
+ /** Measured width in px (the caller caches the last non-zero measurement:
136
+ * a group inside the CLOSED popover is display:none and measures 0). */
137
+ width: number;
138
+ sticky: boolean;
139
+ /** Conditionally hidden right now — takes no space, never folds. */
140
+ hidden: boolean;
141
+ }
142
+ /**
143
+ * Which groups must fold into the ⋮ popover, as pure arithmetic: called with
144
+ * ONE batch of measurements, so the layout pass costs a single reflow
145
+ * instead of the old mutate-then-remeasure loop (O(N) forced reflows per
146
+ * resize tick). Fold order is non-sticky tail-first, then sticky tail-first
147
+ * — a sticky group leaves the row only when nothing else can give way.
148
+ */
149
+ export declare function foldPlan(candidates: readonly FoldCandidate[], avail: number, moreWidth: number, gap: number): Set<number>;
109
150
  export declare function mountToolbar(host: HTMLElement, editor: EditorHandle, options?: ToolbarOptions): ToolbarHandle;
110
151
  //# sourceMappingURL=toolbar.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"toolbar.d.ts","s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AI8D;AAC9D,MAAM,MAAM,YAAY,GACpB,YAAY,EAAE,GACd;IACE,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;IAC5C;;;8BAG0B;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEN,MAAM,WAAW,cAAc;IAC7B;oFACgF;IAChF,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,wEAAwE;IACxE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;CACrC;AAED,+CAA+C;AAC/C,MAAM,WAAW,aAAa;IAC5B,OAAO,IAAI,IAAI,CAAC;CACjB;AAqHD;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,UAAU,CAAC,OAAO,CAAC,GAC5B,MAAM,EAAE,EAAE,CAKZ;AAED;;;;GAIG;AACH,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,iEAAiE;IACjE,GAAG,EAAE,MAAM,CAAC;IACZ;6EACyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,oEAAoE;IACpE,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,SAAS,aAAa,EAAE,EACpC,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,GAAG,CAAC,MAAM,CAAC,CAyBb;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,WAAW,EACjB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAuZf"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadow-garden/bapbong-ui",
3
- "version": "0.15.0",
3
+ "version": "0.17.0",
4
4
  "description": "bapbong — framework-agnostic editor UI (toolbar/menubar) that mounts into a host element and binds to editor.commands",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -56,6 +56,6 @@
56
56
  }
57
57
  },
58
58
  "dependencies": {
59
- "@shadow-garden/bapbong-contracts": "^0.14.0"
59
+ "@shadow-garden/bapbong-contracts": "^0.16.0"
60
60
  }
61
61
  }