-
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.
Add Inline Images and Inline Blocks API (#6959)
* Add Inline Images and Inline Blocks API * Fix test * e2e: leave time for upload * e2e: fix multi selection test * e2e: wait for media modal * Address some feedback * Try search + click for block insert test * Rebase and address feedback * Try with data layer * Move registering tokens to store init * Rebase and test adjustments * Run tests in band * Generate a unique name for the upload image on each test run * Remove the deletion of previous images
- Loading branch information
Showing
27 changed files
with
476 additions
and
21 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
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 |
---|---|---|
|
@@ -38,6 +38,10 @@ | |
width: 100%; | ||
max-height: 100%; | ||
overflow: auto; | ||
|
||
img { | ||
display: inline; | ||
} | ||
} | ||
} | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { createSlotFill, PanelBody } from '@wordpress/components'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockTypesList from '../block-types-list'; | ||
import { searchItems } from './menu'; | ||
|
||
const { Fill, Slot } = createSlotFill( 'InserterResultsPortal' ); | ||
|
||
const InserterResultsPortal = ( { items, title, onSelect, onHover } ) => { | ||
return ( | ||
<Fill> | ||
{ ( { filterValue } ) => { | ||
const filteredItems = searchItems( items, filterValue ); | ||
|
||
if ( ! filteredItems.length ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<PanelBody | ||
title={ title } | ||
> | ||
<BlockTypesList items={ filteredItems } onSelect={ onSelect } onHover={ onHover } /> | ||
</PanelBody> | ||
); | ||
} } | ||
</Fill> | ||
); | ||
}; | ||
|
||
InserterResultsPortal.Slot = Slot; | ||
|
||
export default InserterResultsPortal; |
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,11 @@ | ||
.mce-content-body div.mce-resizehandle { | ||
border-radius: 50%; | ||
border: 2px solid $white; | ||
width: 15px !important; | ||
height: 15px !important; | ||
position: absolute; | ||
background: theme( primary ); | ||
padding: 0 3px 3px 0; | ||
box-sizing: border-box; | ||
cursor: se-resize; | ||
} |
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,48 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './editor.scss'; | ||
import MediaUpload from '../../../media-upload'; | ||
|
||
export const name = 'core/image'; | ||
|
||
export const settings = { | ||
id: 'image', | ||
|
||
title: __( 'Inline Image' ), | ||
|
||
type: 'image', | ||
|
||
icon: 'format-image', | ||
|
||
edit( { onSave } ) { | ||
return ( | ||
<MediaUpload | ||
type="image" | ||
onSelect={ ( media ) => onSave( media ) } | ||
onClose={ () => onSave( null ) } | ||
render={ ( { open } ) => { | ||
open(); | ||
return null; | ||
} } | ||
/> | ||
); | ||
}, | ||
|
||
save( { id, url, alt, width } ) { | ||
return ( | ||
<img | ||
className={ `wp-image-${ id }` } | ||
// set width in style attribute to prevent Block CSS from overriding it | ||
style={ { width: `${ Math.min( width, 150 ) }px` } } | ||
src={ url } | ||
alt={ alt } | ||
/> | ||
); | ||
}, | ||
}; |
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,6 @@ | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import * as image from './image'; | ||
|
||
export { image }; |
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
Oops, something went wrong.