@shadow-garden/bapbong-commands 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.
- package/LICENSE +21 -0
- package/README.md +46 -0
- package/dist/index.cjs +818 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +752 -0
- package/dist/lib/edit.d.ts +4 -0
- package/dist/lib/edit.d.ts.map +1 -0
- package/dist/lib/history.d.ts +6 -0
- package/dist/lib/history.d.ts.map +1 -0
- package/dist/lib/insert.d.ts +11 -0
- package/dist/lib/insert.d.ts.map +1 -0
- package/dist/lib/list.d.ts +14 -0
- package/dist/lib/list.d.ts.map +1 -0
- package/dist/lib/marks.d.ts +53 -0
- package/dist/lib/marks.d.ts.map +1 -0
- package/dist/lib/paragraph.d.ts +25 -0
- package/dist/lib/paragraph.d.ts.map +1 -0
- package/dist/lib/registry.d.ts +15 -0
- package/dist/lib/registry.d.ts.map +1 -0
- package/dist/lib/sections.d.ts +32 -0
- package/dist/lib/sections.d.ts.map +1 -0
- package/dist/lib/table-structure.d.ts +31 -0
- package/dist/lib/table-structure.d.ts.map +1 -0
- package/dist/lib/table.d.ts +36 -0
- package/dist/lib/table.d.ts.map +1 -0
- package/package.json +65 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/lib/edit.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,wEAAwE;AACxE,wBAAgB,sBAAsB,IAAI,OAAO,CAMhD"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
/** Undo the last change (requires the prosemirror-history plugin in state). */
|
|
3
|
+
export declare function undoCommand(): Command;
|
|
4
|
+
/** Redo the last undone change. */
|
|
5
|
+
export declare function redoCommand(): Command;
|
|
6
|
+
//# sourceMappingURL=history.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"history.d.ts","sourceRoot":"","sources":["../../src/lib/history.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAYhE,+EAA+E;AAC/E,wBAAgB,WAAW,IAAI,OAAO,CAMrC;AAED,mCAAmC;AACnC,wBAAgB,WAAW,IAAI,OAAO,CAMrC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
/** Toggle "start on a new page" (`w:pageBreakBefore`) on the paragraph(s) the
|
|
3
|
+
* selection touches; the first such paragraph decides the new on/off state. */
|
|
4
|
+
export declare function pageBreakCommand(): Command;
|
|
5
|
+
/** Insert a `rows`×`cols` table of empty cells, replacing the selection. */
|
|
6
|
+
export declare function insertTable(rows?: number, cols?: number): Command;
|
|
7
|
+
/** Insert an inline image at the selection. */
|
|
8
|
+
export declare function insertImage(src: string, alt?: string): Command;
|
|
9
|
+
/** Apply (or clear, with `null`) a hyperlink over the selected range. */
|
|
10
|
+
export declare function setLink(href: string | null): Command;
|
|
11
|
+
//# sourceMappingURL=insert.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/lib/insert.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAGhE;gFACgF;AAChF,wBAAgB,gBAAgB,IAAI,OAAO,CAwB1C;AAED,4EAA4E;AAC5E,wBAAgB,WAAW,CAAC,IAAI,SAAI,EAAE,IAAI,SAAI,GAAG,OAAO,CAavD;AAED,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,SAAK,GAAG,OAAO,CAU1D;AAED,yEAAyE;AACzE,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAiBpD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
export type ListKind = 'bullet' | 'ordered';
|
|
3
|
+
/**
|
|
4
|
+
* Toggle a bullet / numbered list on the selected paragraphs. If every target
|
|
5
|
+
* is already this kind, it's removed; otherwise they're set to it. Lists are a
|
|
6
|
+
* paragraph attr (`{ numId, level }`) recomputed live by the numbering counter,
|
|
7
|
+
* so markers renumber as you edit. The ordered definition is injected into
|
|
8
|
+
* `doc.attrs.numbering` on first use; the bullet renders from a static marker.
|
|
9
|
+
*
|
|
10
|
+
* (Export writes `w:numPr` for the numId; round-tripping editor-authored lists
|
|
11
|
+
* to a Word-openable marker needs numbering.xml regen on export — a follow-up.)
|
|
12
|
+
*/
|
|
13
|
+
export declare function toggleList(kind: ListKind): Command;
|
|
14
|
+
//# sourceMappingURL=list.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/lib/list.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,MAAM,MAAM,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;AA0C5C;;;;;;;;;GASG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,QAAQ,GAAG,OAAO,CAiClD"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
3
|
+
/**
|
|
4
|
+
* Whether `markName` (optionally with specific `attrs`) covers the selection,
|
|
5
|
+
* or sits in the stored marks when the selection is empty. Schema-agnostic: an
|
|
6
|
+
* unknown mark is simply inactive. With `attrs` (e.g. `{ value: 'super' }` for
|
|
7
|
+
* a superscript) it matches only marks carrying those attribute values.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isMarkActive(state: EditorState, markName: string, attrs?: Record<string, unknown>): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Toggle a mark over the selection. `name` is the command id (what menus
|
|
12
|
+
* reference, e.g. `bold`); `markName` is the schema mark it toggles (defaults to
|
|
13
|
+
* `name`). Pass `attrs` for attribute-bearing marks (e.g. superscript =
|
|
14
|
+
* `vertAlign` with `{ value: 'super' }`); same-type marks exclude each other,
|
|
15
|
+
* so super/sub stay mutually exclusive.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toggleMarkCommand(name: string, markName?: string, attrs?: Record<string, unknown>): Command;
|
|
18
|
+
/**
|
|
19
|
+
* Set a value-bearing mark (`fontSize`/`textColor`/`highlight`/`fontFamily`) to
|
|
20
|
+
* specific `attrs` over the selection — replacing any existing value — or
|
|
21
|
+
* remove it when `attrs` is null. Empty selection updates the stored marks so
|
|
22
|
+
* the next typed text carries the value. The value-bearing analogue of
|
|
23
|
+
* {@link toggleMarkCommand} (which only flips a mark on/off).
|
|
24
|
+
*/
|
|
25
|
+
export declare function setMarkAttr(markName: string, attrs: Record<string, unknown> | null): Command;
|
|
26
|
+
/**
|
|
27
|
+
* The value of `markName`'s `attrKey` over the selection: the stored/cursor
|
|
28
|
+
* mark when empty, the shared value if uniform across a range, else null (mixed
|
|
29
|
+
* or unset). Used to show the current font size / colour in a toolbar control.
|
|
30
|
+
*/
|
|
31
|
+
export declare function activeMarkValue(state: EditorState, markName: string, attrKey: string): unknown;
|
|
32
|
+
/** Set the font size (points) over the selection; null clears it. */
|
|
33
|
+
export declare function setFontSize(pt: number | null): Command;
|
|
34
|
+
/** The font size (pt) at the selection, or null when mixed/unset. */
|
|
35
|
+
export declare function activeFontSize(state: EditorState): number | null;
|
|
36
|
+
/** Set the font family over the selection; null clears it. */
|
|
37
|
+
export declare function setFontFamily(family: string | null): Command;
|
|
38
|
+
/** The font family at the selection, or null when mixed/unset. */
|
|
39
|
+
export declare function activeFontFamily(state: EditorState): string | null;
|
|
40
|
+
/** Set the text colour over the selection; null clears it. */
|
|
41
|
+
export declare function setTextColor(color: string | null): Command;
|
|
42
|
+
/** The text colour at the selection, or null when mixed/unset. */
|
|
43
|
+
export declare function activeTextColor(state: EditorState): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Remove all inline marks from the selection (Clear formatting). On an empty
|
|
46
|
+
* selection it clears the stored marks so the next typed text is unformatted.
|
|
47
|
+
*/
|
|
48
|
+
export declare function clearMarks(): Command;
|
|
49
|
+
/** Set the highlight (text background) colour over the selection; null clears it. */
|
|
50
|
+
export declare function setHighlight(color: string | null): Command;
|
|
51
|
+
/** The highlight colour at the selection, or null when mixed/unset. */
|
|
52
|
+
export declare function activeHighlight(state: EditorState): string | null;
|
|
53
|
+
//# sourceMappingURL=marks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"marks.d.ts","sourceRoot":"","sources":["../../src/lib/marks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAKhE;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAgBT;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAa,EACvB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAUT;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAsB5F;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAsB9F;AAED,qEAAqE;AACrE,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAEtD;AAED,qEAAqE;AACrE,wBAAgB,cAAc,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAGhE;AAED,8DAA8D;AAC9D,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE5D;AAED,kEAAkE;AAClE,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAGlE;AAED,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE1D;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAGjE;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,OAAO,CAcpC;AAED,qFAAqF;AACrF,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAE1D;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAGjE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
3
|
+
/** Paragraph alignment values (mirrors the `paragraph.align` schema attr / w:jc). */
|
|
4
|
+
export declare const ALIGNMENTS: readonly ["left", "center", "right", "justify"];
|
|
5
|
+
export type Align = (typeof ALIGNMENTS)[number];
|
|
6
|
+
/**
|
|
7
|
+
* The alignment shared by every paragraph touched by the selection, or null
|
|
8
|
+
* when they differ or use the default. Drives the toolbar's active alignment.
|
|
9
|
+
*/
|
|
10
|
+
export declare function activeAlign(state: EditorState): Align | null;
|
|
11
|
+
/**
|
|
12
|
+
* Set (or clear, with `null`) paragraph alignment across the selection. The
|
|
13
|
+
* command id is `align-<value>` (or `align-clear`) so each alignment is its own
|
|
14
|
+
* toolbar button.
|
|
15
|
+
*/
|
|
16
|
+
export declare function setAlign(align: Align | null): Command;
|
|
17
|
+
/**
|
|
18
|
+
* Toggle a heading level (1–6) on the selected paragraphs (`heading-<level>`).
|
|
19
|
+
* If every target is already this level it reverts to a body paragraph;
|
|
20
|
+
* otherwise they all become this level. The layout sizes a heading from its
|
|
21
|
+
* level and the model serialises it as `<h1>`–`<h6>` (semantic for the a11y
|
|
22
|
+
* mirror) / a Word "Heading N" style on export.
|
|
23
|
+
*/
|
|
24
|
+
export declare function toggleHeading(level: number): Command;
|
|
25
|
+
//# sourceMappingURL=paragraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paragraph.d.ts","sourceRoot":"","sources":["../../src/lib/paragraph.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,qFAAqF;AACrF,eAAO,MAAM,UAAU,iDAAkD,CAAC;AAC1E,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,GAAG,KAAK,GAAG,IAAI,CAS5D;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,OAAO,CAiBrD;AAYD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAqBpD"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Collection } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
3
|
+
/**
|
|
4
|
+
* The built-in static commands a toolbar/menubar references by name — mark
|
|
5
|
+
* toggles, paragraph alignment, super/subscript, history and page break. The
|
|
6
|
+
* UI picks which to surface (the catalog can grow without bloating any one
|
|
7
|
+
* toolbar). Parameterized ops that need a runtime value (cell background,
|
|
8
|
+
* column width, a colour, a table size, an image src, a link href) are called
|
|
9
|
+
* via their factory functions directly, not from this registry.
|
|
10
|
+
*
|
|
11
|
+
* Returns a fresh {@link Collection} each call so a host can extend it (e.g. add
|
|
12
|
+
* plugin-contributed commands) without mutating a shared instance.
|
|
13
|
+
*/
|
|
14
|
+
export declare function defaultCommands(): Collection<Command>;
|
|
15
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/lib/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAQhE;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,IAAI,UAAU,CAAC,OAAO,CAAC,CAiCrD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
/**
|
|
3
|
+
* Insert a section break after the block at the caret: the section the caret
|
|
4
|
+
* sits in is split in two at that boundary. **Columns are unchanged** — the new
|
|
5
|
+
* section inherits the current column layout — so this only sets where the
|
|
6
|
+
* following content begins (`newPage` → a fresh page, else continuous). Change
|
|
7
|
+
* the column count separately with {@link setColumns} (the Word model: columns
|
|
8
|
+
* are a per-section property, set via Format → Columns).
|
|
9
|
+
*
|
|
10
|
+
* Sections are stored positionally (`doc.attrs.sections`, by `blockCount`), so
|
|
11
|
+
* like imported sections they can drift if blocks are later added/removed
|
|
12
|
+
* elsewhere — a known model limitation, not introduced here.
|
|
13
|
+
*/
|
|
14
|
+
export declare function insertSectionBreak(opts: {
|
|
15
|
+
newPage: boolean;
|
|
16
|
+
}): Command;
|
|
17
|
+
/**
|
|
18
|
+
* Remove the section break at `boundaryIndex` (0-based; there are
|
|
19
|
+
* `sections.length - 1` breaks, break `b` sits between section `b` and `b+1`).
|
|
20
|
+
* The two sections merge into one. Word semantics: the upper content adopts the
|
|
21
|
+
* **following** section's column layout (`columns` taken from section `b+1`),
|
|
22
|
+
* while the merged section keeps section `b`'s page-start.
|
|
23
|
+
*/
|
|
24
|
+
export declare function removeSectionBreak(boundaryIndex: number): Command;
|
|
25
|
+
/**
|
|
26
|
+
* Set the column count of the section the caret sits in (Format → Columns). A
|
|
27
|
+
* count > 1 needs a section to flow into, so a single-section doc becomes
|
|
28
|
+
* multi-column as a whole; scope columns to a region by inserting section
|
|
29
|
+
* breaks around it first ({@link insertSectionBreak}).
|
|
30
|
+
*/
|
|
31
|
+
export declare function setColumns(count: number): Command;
|
|
32
|
+
//# sourceMappingURL=sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sections.d.ts","sourceRoot":"","sources":["../../src/lib/sections.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAiB,MAAM,kCAAkC,CAAC;AA8B/E;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAyBtE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAqBjE;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAmBjD"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
2
|
+
/** Insert a blank row above/below the current row, mirroring its column widths. */
|
|
3
|
+
export declare function insertRow(below: boolean): Command;
|
|
4
|
+
/** Insert a blank column left/right of the current one (in every row), copying
|
|
5
|
+
* the current column's width. */
|
|
6
|
+
export declare function insertColumn(right: boolean): Command;
|
|
7
|
+
/** Delete the current row. Removing the last row deletes the whole table.
|
|
8
|
+
* (Spanning cells are best-effort, like {@link insertRow}.) */
|
|
9
|
+
export declare function deleteRow(): Command;
|
|
10
|
+
/** Delete the current column (the cell at this index in every row). Removing
|
|
11
|
+
* the last column deletes the whole table. (Spanning cells are best-effort.) */
|
|
12
|
+
export declare function deleteColumn(): Command;
|
|
13
|
+
/** A selected cell within a block grid (matches the editor's `SelectedCell` —
|
|
14
|
+
* passed structurally so this stays in the isomorphic command layer). */
|
|
15
|
+
export interface MergeCell {
|
|
16
|
+
pos: number;
|
|
17
|
+
row: number;
|
|
18
|
+
col: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Merge a rectangular block of cells into the top-left one: it gains
|
|
22
|
+
* `colspan = cols` / `rowspan = rows`, the rest are removed, and their
|
|
23
|
+
* non-empty content is appended (so nothing is lost). The spanned-over cells
|
|
24
|
+
* disappear from their rows — exactly the shape the layout's occupancy grid
|
|
25
|
+
* expects for an imported merged cell. Best-effort if the block already
|
|
26
|
+
* contains spanning cells.
|
|
27
|
+
*/
|
|
28
|
+
export declare function mergeCells(cells: MergeCell[], rows: number, cols: number): Command;
|
|
29
|
+
/** Delete the entire table the selection sits in. */
|
|
30
|
+
export declare function deleteTable(): Command;
|
|
31
|
+
//# sourceMappingURL=table-structure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table-structure.d.ts","sourceRoot":"","sources":["../../src/lib/table-structure.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAwChE,mFAAmF;AACnF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAmBjD;AAED;kCACkC;AAClC,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkCpD;AAED;gEACgE;AAChE,wBAAgB,SAAS,IAAI,OAAO,CAiBnC;AAED;iFACiF;AACjF,wBAAgB,YAAY,IAAI,OAAO,CAiCtC;AAED;0EAC0E;AAC1E,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA4ClF;AAED,qDAAqD;AACrD,wBAAgB,WAAW,IAAI,OAAO,CAWrC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { EditorState } from 'prosemirror-state';
|
|
2
|
+
import type { Node as ProseMirrorNode } from 'prosemirror-model';
|
|
3
|
+
import type { Command } from '@shadow-garden/bapbong-contracts';
|
|
4
|
+
/** A located table cell: its node + the doc position just before it. */
|
|
5
|
+
export interface CellInfo {
|
|
6
|
+
pos: number;
|
|
7
|
+
node: ProseMirrorNode;
|
|
8
|
+
}
|
|
9
|
+
/** Cell attributes a caller may set (mirrors the `table_cell` schema attrs). */
|
|
10
|
+
export interface CellAttrs {
|
|
11
|
+
background: string | null;
|
|
12
|
+
vAlign: 'center' | 'bottom' | null;
|
|
13
|
+
colwidth: number[] | null;
|
|
14
|
+
borders: unknown;
|
|
15
|
+
}
|
|
16
|
+
/** The `table_cell` containing the selection head, or null when outside a table.
|
|
17
|
+
* The cell-properties dialog and context menu use this to know their target. */
|
|
18
|
+
export declare function cellAt(state: EditorState): CellInfo | null;
|
|
19
|
+
/**
|
|
20
|
+
* Merge `attrs` onto the `table_cell` at `pos` — the generic primitive the cell
|
|
21
|
+
* properties dialog dispatches. No-op (returns false) if `pos` isn't a cell.
|
|
22
|
+
*/
|
|
23
|
+
export declare function setCellAttrs(pos: number, attrs: Partial<CellAttrs>): Command;
|
|
24
|
+
/** Set the same attrs on several cells (by doc position) in one transaction —
|
|
25
|
+
* the cell-properties dialog applied across a selected block. */
|
|
26
|
+
export declare function setCellsAttrs(positions: number[], attrs: Partial<CellAttrs>): Command;
|
|
27
|
+
/** Set the current cell's background fill (`null` clears it). */
|
|
28
|
+
export declare function setCellBackground(color: string | null): Command;
|
|
29
|
+
/**
|
|
30
|
+
* Set one cell's column width in px. The L2 column-resize plugin owns the
|
|
31
|
+
* geometry (which cells share a column) and composes this across each of them;
|
|
32
|
+
* on its own it sets a single cell. (colspan>1 cells carry a width-per-spanned-
|
|
33
|
+
* column array — here we set a single width.)
|
|
34
|
+
*/
|
|
35
|
+
export declare function setColumnWidth(cellPos: number, width: number): Command;
|
|
36
|
+
//# sourceMappingURL=table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/lib/table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAEhE,wEAAwE;AACxE,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,gFAAgF;AAChF,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IACnC,QAAQ,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;iFACiF;AACjF,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,QAAQ,GAAG,IAAI,CAO1D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAc5E;AAED;kEACkE;AAClE,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,OAAO,CAgBrF;AAED,iEAAiE;AACjE,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAS/D;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAKtE"}
|
package/package.json
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@shadow-garden/bapbong-commands",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "bapbong — headless editor commands + queries + registry (isomorphic; backend and UI share the same ops)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/shadowgarden-app/bapbong.git",
|
|
9
|
+
"directory": "packages/commands"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.cjs",
|
|
13
|
+
"module": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
"./package.json": "./package.json",
|
|
17
|
+
".": {
|
|
18
|
+
"@shadow-garden/source": "./src/index.ts",
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!**/*.tsbuildinfo"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"nx": {
|
|
33
|
+
"tags": [
|
|
34
|
+
"scope:pure"
|
|
35
|
+
],
|
|
36
|
+
"targets": {
|
|
37
|
+
"build": {
|
|
38
|
+
"executor": "@nx/esbuild:esbuild",
|
|
39
|
+
"outputs": [
|
|
40
|
+
"{options.outputPath}"
|
|
41
|
+
],
|
|
42
|
+
"options": {
|
|
43
|
+
"outputPath": "packages/commands/dist",
|
|
44
|
+
"main": "packages/commands/src/index.ts",
|
|
45
|
+
"tsConfig": "packages/commands/tsconfig.lib.json",
|
|
46
|
+
"format": [
|
|
47
|
+
"esm",
|
|
48
|
+
"cjs"
|
|
49
|
+
],
|
|
50
|
+
"declarationRootDir": "packages/commands/src",
|
|
51
|
+
"external": [
|
|
52
|
+
"@shadow-garden/bapbong-contracts"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"prosemirror-commands": "^1.7.1",
|
|
60
|
+
"prosemirror-history": "^1.4.1",
|
|
61
|
+
"prosemirror-model": "^1.25.7",
|
|
62
|
+
"prosemirror-state": "^1.4.4",
|
|
63
|
+
"@shadow-garden/bapbong-contracts": "^0.1.0"
|
|
64
|
+
}
|
|
65
|
+
}
|