mirror of
https://github.com/codex-team/editor.js
synced 2024-06-03 14:32:33 +02:00
2ab9eb13bc
* feat(block-events): delete keydown logic added * chore(ui-events): delete keydown will remove selected blocks * backspace tests added * delete keydown tests * tests for ui added * fix ci * separate block events tests for several files * Delete BlockEvents.cy.ts * rm unused change * add code-review fixes + corner cases handling * Update blockEvents.ts * allow merging only same type blocks
16 lines
454 B
TypeScript
16 lines
454 B
TypeScript
import type Block from '../block';
|
|
|
|
/**
|
|
* Check if two blocks could be merged.
|
|
*
|
|
* We can merge two blocks if:
|
|
* - they have the same type
|
|
* - they have a merge function (.mergeable = true)
|
|
*
|
|
* @param targetBlock - block to merge to
|
|
* @param blockToMerge - block to merge from
|
|
*/
|
|
export function areBlocksMergeable(targetBlock: Block, blockToMerge: Block): boolean {
|
|
return targetBlock.mergeable && targetBlock.name === blockToMerge.name;
|
|
}
|