Skip to content

Commit

Permalink
Blocks pkg: remove 'browser' dependencies (#56433)
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 28, 2023
1 parent 4494a79 commit 6d9740f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
7 changes: 1 addition & 6 deletions packages/blocks/src/api/raw-handling/image-corrector.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@
*/
import { createBlobURL } from '@wordpress/blob';

/**
* Browser dependencies
*/
const { atob, File } = window;

export default function imageCorrector( node ) {
if ( node.nodeName !== 'IMG' ) {
return;
Expand Down Expand Up @@ -44,7 +39,7 @@ export default function imageCorrector( node ) {
}

const name = type.replace( '/', '.' );
const file = new File( [ uint8Array ], name, { type } );
const file = new window.File( [ uint8Array ], name, { type } );

node.src = createBlobURL( file );
}
Expand Down
5 changes: 0 additions & 5 deletions packages/blocks/src/api/raw-handling/ms-list-converter.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Browser dependencies
*/
const { parseInt } = window;

/**
* Internal dependencies
*/
Expand Down
9 changes: 3 additions & 6 deletions packages/blocks/src/api/raw-handling/paste-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ import { deepFilterHTML, isPlain, getBlockContentSchema } from './utils';
import emptyParagraphRemover from './empty-paragraph-remover';
import slackParagraphCorrector from './slack-paragraph-corrector';

/**
* Browser dependencies
*/
const { console } = window;
const log = ( ...args ) => window?.console?.log?.( ...args );

/**
* Filters HTML to only contain phrasing content.
Expand All @@ -60,7 +57,7 @@ function filterInlineHTML( HTML ) {
HTML = deepFilterHTML( HTML, [ htmlFormattingRemover, brRemover ] );

// Allows us to ask for this information when we get a report.
console.log( 'Processed inline HTML:\n\n', HTML );
log( 'Processed inline HTML:\n\n', HTML );

return HTML;
}
Expand Down Expand Up @@ -214,7 +211,7 @@ export function pasteHandler( {
);

// Allows us to ask for this information when we get a report.
console.log( 'Processed HTML piece:\n\n', piece );
log( 'Processed HTML piece:\n\n', piece );

return htmlToBlocks( piece, pasteHandler );
} )
Expand Down
3 changes: 2 additions & 1 deletion packages/blocks/src/store/process-block-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import { BLOCK_ICON_DEFAULT, DEPRECATED_ENTRY_KEYS } from '../api/constants';

/** @typedef {import('../api/registration').WPBlockType} WPBlockType */

const { error, warn } = window.console;
const error = ( ...args ) => window?.console?.error?.( ...args );
const warn = ( ...args ) => window?.console?.warn?.( ...args );

/**
* Mapping of legacy category slugs to their latest normal values, used to
Expand Down

0 comments on commit 6d9740f

Please sign in to comment.