Skip to content

Commit

Permalink
fix: remove cleanStegaUnicode helper (#6564)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed May 3, 2024
1 parent 7dd2d84 commit 2e224d4
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions packages/@sanity/block-tools/src/HtmlDeserializer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export function preprocess(
parseHtml: HtmlParser,
options: HtmlPreprocessorOptions,
): Document {
const cleanHTML = cleanStegaUnicode(html)
const cleanHTML = vercelStegaClean(html)
const doc = parseHtml(normalizeHtmlBeforePreprocess(cleanHTML))
preprocessors.forEach((processor) => {
processor(cleanHTML, doc, options)
Expand Down Expand Up @@ -340,24 +340,6 @@ export function removeAllWhitespace(rootNode: Node) {
nodesToRemove.forEach((node) => node.parentElement?.removeChild(node))
}

/**
* This is a duplicate code from `@sanity/client/stega`
* Unfortunately, as it stands, the e2e process is pulling in the node version of `@sanity/client` and so we don't have access to the utility as it stands
* @todo remove once this utility is available in `@vercel/stega`
*
* Can take a `result` JSON from a `const {result} = client.fetch(query, params, {filterResponse: false})`
* and remove all stega-encoded data from it.
* @alpha
* @hidden
*/
export function cleanStegaUnicode(result: string): string {
try {
return vercelStegaClean(result)
} catch {
return result
}
}

function isWhitespaceBlock(elm: HTMLElement): boolean {
return ['p', 'br'].includes(tagName(elm) || '') && !elm.textContent?.trim()
}

0 comments on commit 2e224d4

Please sign in to comment.