Update transforms.ts

This commit is contained in:
Nate Kelley 2025-08-07 23:34:53 -06:00
parent 51f896d19e
commit 4d3580bf3a
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
1 changed files with 5 additions and 1 deletions

View File

@ -74,7 +74,11 @@ export const insertBlock = (editor: PlateEditor, type: string) => {
select: true
});
}
if (getBlockType(block[0]) !== type) {
// Only remove the previous block when replacing an empty paragraph.
// This prevents non-paragraph blocks (e.g., metric elements) from being
// inadvertently removed when inserting a new block after them.
const previousType = getBlockType(block[0]);
if (previousType === KEYS.p && previousType !== type) {
// Check if SuggestionPlugin is available before using it
const suggestionApi = editor.getApi(SuggestionPlugin);
if (suggestionApi?.suggestion?.withoutSuggestions) {