mce 0.19.2 → 0.21.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.
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  painting: string;
9
9
  selecting: string;
10
10
  cropping: string;
11
+ tableEditing: string;
11
12
  selectObject: string;
12
13
  commitChanges: string;
13
14
  extend: string;
@@ -8,6 +8,7 @@ declare const _default: {
8
8
  painting: string;
9
9
  selecting: string;
10
10
  cropping: string;
11
+ tableEditing: string;
11
12
  selectObject: string;
12
13
  commitChanges: string;
13
14
  extend: string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Drag-to-reorder for children of a flex/auto-layout container.
3
+ *
4
+ * `transform.ts` skips the absolute move for such a child; here we make it
5
+ * follow the cursor (a temporary left/top offset over its flow slot), swap
6
+ * order with its siblings as its centre crosses theirs, and on release drop
7
+ * the offset so it snaps back into its (new) slot.
8
+ *
9
+ * The sibling layout is derived analytically from sizes/gap captured once at
10
+ * drag start + the current children order (the order array updates
11
+ * synchronously on `moveChild`, but the rendered transforms only catch up on
12
+ * the next tick — so reading them back with `getObb` mid-drag is stale and
13
+ * makes the swap oscillate at the boundary). Structural changes run on the raw
14
+ * (non-reactive) nodes, else the canvas hands a Proxy to yoga's embind which
15
+ * throws a Proxy-invariant error and drops the child.
16
+ */
17
+ declare const _default: import("..").Plugin;
18
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: import("../plugin").Plugin;
2
+ export default _default;
@@ -44,6 +44,7 @@ declare global {
44
44
  | 'moving'
45
45
  | 'transforming'
46
46
  | 'typing'
47
+ | 'tableEditing'
47
48
  | 'cropping'
48
49
  | 'pathEditing'
49
50
  | 'imageReplacing'
@@ -29,6 +29,7 @@ import './plugins/autoNest'
29
29
  import './plugins/clipboard'
30
30
  import './plugins/doc'
31
31
  import './plugins/edit'
32
+ import './plugins/flexLayout'
32
33
  import './plugins/formatPaint'
33
34
  import './plugins/frame'
34
35
  import './plugins/history'
@@ -53,6 +54,7 @@ import './plugins/smartGuides'
53
54
  import './plugins/smartSelection'
54
55
  import './plugins/state'
55
56
  import './plugins/statusbar'
57
+ import './plugins/table'
56
58
  import './plugins/test'
57
59
  import './plugins/timeline'
58
60
  import './plugins/tool'
@@ -8,3 +8,4 @@ export * from './helper';
8
8
  export * from './image';
9
9
  export * from './propsFactory';
10
10
  export * from './saveAs';
11
+ export * from './table';
@@ -0,0 +1,93 @@
1
+ import type { NormalizedTable, Table } from 'modern-idoc';
2
+ /**
3
+ * A mutable, editor-side mirror of an idoc table. It intentionally keeps the
4
+ * same shape as {@link NormalizedTable} (flat `cells[]` keyed by `row`/`col`
5
+ * with optional `rowSpan`/`colSpan`) so it can be written straight back via
6
+ * `Element2DTable.setProperties()`.
7
+ */
8
+ export interface TableModelCell {
9
+ row: number;
10
+ col: number;
11
+ rowSpan?: number;
12
+ colSpan?: number;
13
+ children?: any[];
14
+ background?: any;
15
+ style?: any;
16
+ }
17
+ export interface TableModel {
18
+ columns: {
19
+ width: number;
20
+ }[];
21
+ rows: {
22
+ height: number;
23
+ }[];
24
+ cells: TableModelCell[];
25
+ }
26
+ export interface CellPos {
27
+ row: number;
28
+ col: number;
29
+ }
30
+ export interface CellRange {
31
+ minRow: number;
32
+ minCol: number;
33
+ maxRow: number;
34
+ maxCol: number;
35
+ }
36
+ export interface CellRect {
37
+ left: number;
38
+ top: number;
39
+ width: number;
40
+ height: number;
41
+ }
42
+ /** White cell fill so the canvas renders a solid table (not a transparent grid). */
43
+ export declare const CELL_BACKGROUND = "#ffffff";
44
+ /** 1px gridline drawn by the canvas on each cell. */
45
+ export declare const CELL_BORDER_STYLE: {
46
+ readonly borderColor: "#e5e7eb";
47
+ readonly borderWidth: 1;
48
+ readonly borderStyle: "solid";
49
+ readonly boxSizing: "border-box";
50
+ };
51
+ export declare function defaultTextStyle(header?: boolean): any;
52
+ /**
53
+ * Build a fresh cell child. The text element is given a `width`/`height` to fill
54
+ * its cell at render time (see {@link modelToTable}) so `verticalAlign` centers
55
+ * the text — the canvas has no flex/percent path that does this otherwise.
56
+ */
57
+ export declare function createCellChild(text?: string, refStyle?: any): any;
58
+ /** Deep-clone a live (normalized) table into an editable model. */
59
+ export declare function cloneTableModel(table: Pick<NormalizedTable, 'columns' | 'rows' | 'cells'>): TableModel;
60
+ /**
61
+ * Serialise the model into the shape `Element2DTable.setProperties` accepts,
62
+ * sizing each cell's text child to its (possibly merged) cell rect so the
63
+ * canvas vertically/horizontally centers the text.
64
+ */
65
+ export declare function modelToTable(model: TableModel): Table;
66
+ export declare function gridWidth(model: TableModel): number;
67
+ export declare function gridHeight(model: TableModel): number;
68
+ export declare function colLeft(model: TableModel, col: number): number;
69
+ export declare function rowTop(model: TableModel, row: number): number;
70
+ export declare function cellRowSpan(cell: TableModelCell): number;
71
+ export declare function cellColSpan(cell: TableModelCell): number;
72
+ /** Pixel rect (relative to the table's top-left) for an anchor cell. */
73
+ export declare function getCellRect(model: TableModel, cell: TableModelCell): CellRect;
74
+ export declare function cellRange(cell: TableModelCell): CellRange;
75
+ /** Map every covered grid position `"row:col"` to its anchor cell. */
76
+ export declare function buildCoverage(model: TableModel): Map<string, TableModelCell>;
77
+ export declare function getCellAt(model: TableModel, row: number, col: number): TableModelCell | undefined;
78
+ export declare function getCellText(cell: TableModelCell | undefined): string;
79
+ export declare function setCellText(cell: TableModelCell, text: string): void;
80
+ /**
81
+ * Expand a raw selection so it never cuts through a merged cell — any cell
82
+ * whose span overlaps the range pulls the range out to cover it fully.
83
+ */
84
+ export declare function normalizeRange(model: TableModel, range: CellRange): CellRange;
85
+ export declare function insertRow(model: TableModel, index: number): void;
86
+ export declare function insertColumn(model: TableModel, index: number): void;
87
+ export declare function removeRow(model: TableModel, index: number): void;
88
+ export declare function removeColumn(model: TableModel, index: number): void;
89
+ /** Merge a (normalized) range into its top-left cell, dropping the rest. */
90
+ export declare function mergeRange(model: TableModel, range: CellRange): TableModelCell | undefined;
91
+ /** Reset a merged cell back to 1×1, re-filling the freed positions. */
92
+ export declare function splitCell(model: TableModel, cell: TableModelCell): void;
93
+ export declare function isMergedCell(cell: TableModelCell): boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mce",
3
3
  "type": "module",
4
- "version": "0.19.2",
4
+ "version": "0.21.0",
5
5
  "description": "A headless infinite canvas editor framework built on WebGL rendering, supports exporting to image, video, and PPT. Only the ESM.",
6
6
  "author": "wxm",
7
7
  "license": "MIT",