-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement image copy paste on GB-RN mobile (#14802)
* Implement image corrector for native. * Add paste code to detect images being copy pasted. # Conflicts: # packages/block-editor/src/components/rich-text/index.native.js * Accepts multiples files on copy paste. * Implement media import. * Check if array has any images. * Add comment. * Remove duplicate listener activation.
- Loading branch information
1 parent
079c11b
commit 37bc735
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/blocks/src/api/raw-handling/image-corrector.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
/** | ||
* This method check for copy pasted img elements to see if they don't have suspicious attributes. | ||
* | ||
* @param {Node} node The node to check. | ||
* | ||
* @return {void} | ||
*/ | ||
export default function( node ) { | ||
if ( node.nodeName !== 'IMG' ) { | ||
return; | ||
} | ||
|
||
// Remove trackers and hardly visible images. | ||
if ( node.height === 1 || node.width === 1 ) { | ||
node.parentNode.removeChild( node ); | ||
} | ||
} |