@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.
@@ -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
 
@@ -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}