diff --git a/packages/blocks/src/api/raw-handling/image-corrector.native.js b/packages/blocks/src/api/raw-handling/image-corrector.native.js index 10974e5dc10bd..c6a9288ede2d3 100644 --- a/packages/blocks/src/api/raw-handling/image-corrector.native.js +++ b/packages/blocks/src/api/raw-handling/image-corrector.native.js @@ -10,6 +10,10 @@ export default function imageCorrector( node ) { return; } + if ( node.src.indexOf( 'file:' ) === 0 ) { + node.setAttribute( 'src', '' ); + } + // Remove trackers and hardly visible images. if ( node.height === 1 || node.width === 1 ) { node.parentNode.removeChild( node ); diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index e9bd5e54a764d..4b8e321c72e1a 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -10,6 +10,7 @@ For each user feature we should also add a importance categorization label to i --> ## Unreleased +- [*] Fix a crash when pasting file images and special comment markup [#60476] ## 1.117.0 - [*] Add empty fallback option for the BottomSheetSelectControl component [#60333] diff --git a/packages/react-native-editor/src/jsdom-patches.js b/packages/react-native-editor/src/jsdom-patches.js index c86e4c82f3127..680bdcf1eb12e 100644 --- a/packages/react-native-editor/src/jsdom-patches.js +++ b/packages/react-native-editor/src/jsdom-patches.js @@ -257,6 +257,37 @@ Object.defineProperties( Node.prototype, { return sibling; }, }, + dataset: { + get() { + const node = this; + + // Helper function to convert property name to data-* attribute name + function toDataAttributeName( property ) { + return ( + 'data-' + + property.replace( + /[A-Z]/g, + ( match ) => '-' + match.toLowerCase() + ) + ); + } + return new Proxy( + {}, + { + set( _target, property, value ) { + const attributeName = toDataAttributeName( property ); + node.setAttribute( attributeName, value ); + return true; + }, + get( _target, property ) { + const attributeName = toDataAttributeName( property ); + return node.getAttribute( attributeName ); + }, + } + ); + }, + set() {}, + }, } ); class DOMParser { diff --git a/test/native/jest.config.js b/test/native/jest.config.js index 8bd77280dc550..71232758734fe 100644 --- a/test/native/jest.config.js +++ b/test/native/jest.config.js @@ -25,7 +25,6 @@ const RAW_HANDLING_UNSUPPORTED_UNIT_TESTS = [ 'html-formatting-remover', 'phrasing-content-reducer', 'figure-content-reducer', - 'special-comment-converter', 'normalise-blocks', 'image-corrector', ];