Skip to content

Commit a40b2ea

Browse files
feat: Argument to select moved block in moveBlocksUp/Down (BLO-907) (#2723)
* Added decoration to `TrailingNodeExtension` to hide trailing block when editor is read-only * Added optional argument to `moveBlocksUp/Down` to select block to move + tests * Updated docs * Revert "Added decoration to `TrailingNodeExtension` to hide trailing block when editor is read-only" This reverts commit 086beeb. * Added edge case handling + tests for columns * Updated tests
1 parent 447d9af commit a40b2ea

8 files changed

Lines changed: 4836 additions & 384 deletions

File tree

docs/content/docs/reference/editor/manipulating-content.mdx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,18 +252,26 @@ editor.replaceBlocks(
252252
#### Reordering Blocks
253253

254254
```typescript
255-
moveBlocksUp(): void
256-
moveBlocksDown(): void
255+
moveBlocksUp(blockIdentifier?: BlockIdentifier): void
256+
moveBlocksDown(blockIdentifier?: BlockIdentifier): void
257257
```
258258

259-
Moves the currently selected blocks up or down in the document.
259+
Moves the currently selected blocks up or down in the document. If a
260+
`blockIdentifier` is provided, that block is moved instead of the selection,
261+
and the selection is left unchanged.
260262

261263
```typescript
262264
// Move selected blocks up
263265
editor.moveBlocksUp();
264266

265267
// Move selected blocks down
266268
editor.moveBlocksDown();
269+
270+
// Move a specific block up, without changing the selection
271+
editor.moveBlocksUp("block-123");
272+
273+
// Move a specific block down, without changing the selection
274+
editor.moveBlocksDown("block-123");
267275
```
268276

269277
### Nesting Blocks

0 commit comments

Comments
 (0)