Skip to content

Commit

Permalink
fix: remove redundant calls to normalizeBlock
Browse files Browse the repository at this point in the history
`htmlToBlocks` already calls `normalizeBlock` for each block it produces.
  • Loading branch information
christianhg committed Jan 15, 2025
1 parent 00672df commit 5f1e317
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions packages/editor/src/editor/plugins/createWithInsertData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {htmlToBlocks, normalizeBlock} from '@portabletext/block-tools'
import {htmlToBlocks} from '@portabletext/block-tools'
import type {PortableTextBlock, PortableTextChild} from '@sanity/types'
import {isEqual, uniq} from 'lodash'
import {Editor, Range, Transforms, type Descendant, type Node} from 'slate'
Expand Down Expand Up @@ -195,12 +195,7 @@ export function createWithInsertData(
portableText = htmlToBlocks(html, schemaTypes.portableText, {
unstable_whitespaceOnPasteMode: whitespaceOnPasteMode,
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
}).map((block) =>
normalizeBlock(block, {
blockTypeName,
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
}),
) as PortableTextBlock[]
}) as PortableTextBlock[]
fragment = toSlateValue(portableText, {schemaTypes})
insertedType = 'HTML'

Expand All @@ -220,12 +215,7 @@ export function createWithInsertData(
const textToHtml = `<html><body>${blocks}</body></html>`
portableText = htmlToBlocks(textToHtml, schemaTypes.portableText, {
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
}).map((block) =>
normalizeBlock(block, {
blockTypeName,
keyGenerator: editorActor.getSnapshot().context.keyGenerator,
}),
) as PortableTextBlock[]
}) as PortableTextBlock[]
fragment = toSlateValue(portableText, {
schemaTypes,
})
Expand Down

0 comments on commit 5f1e317

Please sign in to comment.