-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow pasting iframes (squashed 7 commits)
- Loading branch information
Showing
9 changed files
with
141 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import { isEmbedded } from './utils'; | ||
|
||
/** | ||
* Browser dependencies | ||
*/ | ||
const { ELEMENT_NODE } = window.Node; | ||
|
||
/** | ||
* This filter takes embedded content out of paragraphs. | ||
* | ||
* @param {Node} node The node to filter. | ||
* | ||
* @return {void} | ||
*/ | ||
export default function( node ) { | ||
if ( node.nodeType !== ELEMENT_NODE ) { | ||
return; | ||
} | ||
|
||
if ( ! isEmbedded( node ) ) { | ||
return; | ||
} | ||
|
||
let wrapper = node; | ||
|
||
while ( wrapper && wrapper.nodeName !== 'P' ) { | ||
wrapper = wrapper.parentElement; | ||
} | ||
|
||
if ( wrapper ) { | ||
wrapper.parentNode.insertBefore( node, wrapper ); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { equal } from 'assert'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import embeddedContentReducer from '../embedded-content-reducer'; | ||
import { deepFilterHTML } from '../utils'; | ||
|
||
describe( 'embeddedContentReducer', () => { | ||
it( 'should move inline-block content from paragraph', () => { | ||
equal( | ||
deepFilterHTML( '<p><strong>test<img></strong></p>', [ embeddedContentReducer ] ), | ||
'<img><p><strong>test</strong></p>' | ||
); | ||
} ); | ||
} ); |
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
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
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