@jackuait/blok 0.6.0-beta.6 → 0.6.0-beta.8
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/dist/blok.mjs +2 -2
- package/dist/chunks/{blok-BOtlKwVO.mjs → blok-bzxy6Olq.mjs} +187 -173
- package/dist/chunks/{i18next-loader-CJNShSyT.mjs → i18next-loader-CzL6YHyQ.mjs} +1 -1
- package/dist/chunks/{index-BUAPAChM.mjs → index-DSSrx_Co.mjs} +1 -1
- package/dist/chunks/{inline-tool-convert-UoYdJJic.mjs → inline-tool-convert-D4SXxjDd.mjs} +1 -1
- package/dist/full.mjs +2 -2
- package/dist/tools.mjs +39 -39
- package/package.json +1 -1
- package/src/components/modules/api/blocks.ts +18 -0
- package/src/components/modules/rectangleSelection.ts +6 -3
- package/src/components/modules/saver.ts +3 -2
- package/src/components/modules/toolbar/index.ts +52 -16
- package/src/components/modules/toolbar/plus-button.ts +22 -1
- package/src/tools/table/table-add-controls.ts +1 -1
- package/src/tools/table/table-cell-blocks.ts +6 -0
- package/types/api/blocks.d.ts +8 -0
|
@@ -45,6 +45,7 @@ interface TableCellBlocksOptions {
|
|
|
45
45
|
export class TableCellBlocks {
|
|
46
46
|
private api: API;
|
|
47
47
|
private gridElement: HTMLElement;
|
|
48
|
+
private tableBlockId: string;
|
|
48
49
|
private _activeCellWithBlocks: CellPosition | null = null;
|
|
49
50
|
private onNavigateToCell?: CellNavigationCallback;
|
|
50
51
|
|
|
@@ -68,6 +69,7 @@ export class TableCellBlocks {
|
|
|
68
69
|
constructor(options: TableCellBlocksOptions) {
|
|
69
70
|
this.api = options.api;
|
|
70
71
|
this.gridElement = options.gridElement;
|
|
72
|
+
this.tableBlockId = options.tableBlockId;
|
|
71
73
|
this.onNavigateToCell = options.onNavigateToCell;
|
|
72
74
|
|
|
73
75
|
this.api.events.on('block changed', this.handleBlockMutation);
|
|
@@ -269,6 +271,7 @@ export class TableCellBlocks {
|
|
|
269
271
|
const block = this.api.blocks.insert('paragraph', { text }, {}, this.api.blocks.getBlocksCount(), false);
|
|
270
272
|
|
|
271
273
|
container.appendChild(block.holder);
|
|
274
|
+
this.api.blocks.setBlockParent(block.id, this.tableBlockId);
|
|
272
275
|
normalizedRow.push({ blocks: [block.id] });
|
|
273
276
|
}
|
|
274
277
|
|
|
@@ -315,6 +318,7 @@ export class TableCellBlocks {
|
|
|
315
318
|
}
|
|
316
319
|
|
|
317
320
|
container.appendChild(block.holder);
|
|
321
|
+
this.api.blocks.setBlockParent(blockId, this.tableBlockId);
|
|
318
322
|
mountedIds.push(blockId);
|
|
319
323
|
}
|
|
320
324
|
|
|
@@ -344,6 +348,7 @@ export class TableCellBlocks {
|
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
container.appendChild(block.holder);
|
|
351
|
+
this.api.blocks.setBlockParent(blockId, this.tableBlockId);
|
|
347
352
|
this.stripPlaceholders(container);
|
|
348
353
|
}
|
|
349
354
|
|
|
@@ -402,6 +407,7 @@ export class TableCellBlocks {
|
|
|
402
407
|
const block = this.api.blocks.insert('paragraph', { text: '' }, {}, this.api.blocks.getBlocksCount(), true);
|
|
403
408
|
|
|
404
409
|
container.appendChild(block.holder);
|
|
410
|
+
this.api.blocks.setBlockParent(block.id, this.tableBlockId);
|
|
405
411
|
this.stripPlaceholders(container);
|
|
406
412
|
}
|
|
407
413
|
|
package/types/api/blocks.d.ts
CHANGED
|
@@ -78,6 +78,14 @@ export interface Blocks {
|
|
|
78
78
|
*/
|
|
79
79
|
getChildren(parentId: string): BlockAPI[];
|
|
80
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Sets the parent of a block, updating both the block's parentId and the parent's contentIds.
|
|
83
|
+
*
|
|
84
|
+
* @param blockId - id of the block to reparent
|
|
85
|
+
* @param parentId - id of the new parent block, or null for root level
|
|
86
|
+
*/
|
|
87
|
+
setBlockParent(blockId: string, parentId: string | null): void;
|
|
88
|
+
|
|
81
89
|
/**
|
|
82
90
|
* Returns Blocks count
|
|
83
91
|
* @return {number}
|