summaryrefslogtreecommitdiff
path: root/web/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/index.ts')
-rw-r--r--web/src/index.ts33
1 files changed, 28 insertions, 5 deletions
diff --git a/web/src/index.ts b/web/src/index.ts
index 6ab61c9..a6f0ac7 100644
--- a/web/src/index.ts
+++ b/web/src/index.ts
@@ -1,8 +1,10 @@
import Ratio from "./math/Ratio";
-import { Cell, CellRef, Doc, Grid } from "./types";
+import { Cell, CellRef, Doc, Grid, mapRowsInRange } from "./types";
import { ActiveCellSelection, Selection } from "./selection";
-import renderGrid, { RenderedGrid } from "./components/grid/renderGrid";
-import cellAtCoord from "./components/grid/cellAtCoord";
+import renderGrid, {
+ getRenderedCell,
+ RenderedGrid,
+} from "./components/grid/renderGrid";
function defaultDoc(): Doc {
const defaultCells: Cell[] = Array.from({ length: 16 }, () => ({
@@ -29,7 +31,12 @@ function defaultDoc(): Doc {
baseCellWidthRatio: new Ratio(1, 16),
parts: [
{
- rows: Array.from({ length: 4 }, () => ({
+ rows: Array.from({ length: 2 }, () => ({
+ cells: [...defaultCells],
+ })),
+ },
+ {
+ rows: Array.from({ length: 2 }, () => ({
cells: [...defaultCells],
})),
},
@@ -92,7 +99,23 @@ export default class Notive {
}
#dispatchSelectionChanged() {
- window.dispatchEvent(new CustomEvent("ntv:selection-changed"));
+ window.dispatchEvent(new CustomEvent("ntv:selectionchange"));
+ }
+
+ subdivideSelection(subdivisions: number) {
+ const selection = this.selection;
+
+ if (!selection) return;
+
+ const newDoc = mapRowsInRange(
+ this.doc,
+ selection.gridId,
+ selection.startCellRef(),
+ selection.endCellRef(),
+ (row, rowRef) => {
+ return row;
+ },
+ );
}
}