Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement lists for ReactNative #14249

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f5852b9
Bump plugin version to 5.1.0-rc.1
noisysocks Feb 18, 2019
a953826
Merge branch 'master' into rnmobile/lists
SergioEstevao Feb 18, 2019
a2f9c36
Merge branch 'master' into rnmobile/lists
SergioEstevao Feb 18, 2019
81e13d6
RichText: only ignore input types that insert HTML (#13914)
ellatrix Feb 20, 2019
bfe46d6
Bump plugin version to 5.1.0
noisysocks Feb 20, 2019
bb39e9a
Merge branch 'master' into rnmobile/release-v1.0
hypest Feb 20, 2019
2240dcf
Deprecate RichTextInputEvent on mobile too (#13975)
hypest Feb 20, 2019
ece3caf
The undelying RichText component implementation has changed the param…
daniloercoli Feb 20, 2019
d2e2a18
Fixes wrong state comparison (#13987)
marecar3 Feb 20, 2019
811fbe0
Re-add rootTagsToEliminate prop (#14006)
pinarol Feb 21, 2019
762f769
[Mobile]Update PostTitle to apply borders when it is focused (#13970)
pinarol Feb 21, 2019
7c32d3a
Mobile: Rename ref to innerRef on PostTitle (#14024)
etoledom Feb 21, 2019
258a10b
Fixes a red screen in mobile. (#14011)
diegoreymendez Feb 22, 2019
36b7447
Change background color on image placeholder block (#14033)
marecar3 Feb 22, 2019
1171ec5
Fix post title native syntax (#14041)
Tug Feb 22, 2019
d5de5f5
Mobile: Links UI using BottomSheet component (#13972)
etoledom Feb 22, 2019
85550bb
Fixes pasting links. (#14038)
diegoreymendez Feb 22, 2019
e485688
Update post title vertical paddings (#14040)
pinarol Feb 22, 2019
331b68d
Add try/catch fallback to plain text for pasteHandler (#14044)
mkevins Feb 22, 2019
0cbf01c
Fix link interface. (#14052)
SergioEstevao Feb 22, 2019
db68e6c
[Mobile]Fix title padding on Android (#14057)
pinarol Feb 22, 2019
0718f7e
Revert wrong format image color (#14058)
marecar3 Feb 22, 2019
987a5a4
Stop building the mobile release branch on Travis (#14060)
hypest Feb 22, 2019
926ed3f
[Native mobile] Bring release v1.0.1 back to "mobile develop" (#14075)
hypest Feb 24, 2019
9090888
Merge branch 'rnmobile/develop' into rnmobile/lists
SergioEstevao Mar 4, 2019
4f166f4
Rnmobile/refactor rich text sizing code (#14164)
SergioEstevao Mar 4, 2019
4a54597
Merge branch 'rnmobile/develop' into rnmobile/lists
SergioEstevao Mar 4, 2019
2ca5f3a
Add list block to mobile gb.
SergioEstevao Mar 4, 2019
a8ef4a8
Make sure multiline property is filtered out of props on save.
SergioEstevao Mar 5, 2019
65ba640
Send block edit parameters using the context.
SergioEstevao Mar 5, 2019
410ba47
Add multiline variables to allow proper parsing and saving of propert…
SergioEstevao Mar 5, 2019
3f702dd
Mobile: Fix pasting in header (#14118)
diegoreymendez Mar 5, 2019
2a41903
Mobile: Fix links ui on landscape iOS v2 (#14240)
etoledom Mar 5, 2019
d0ee47b
Add list edit toolbar options
SergioEstevao Mar 5, 2019
ae4954b
Merge branch 'rnmobile/develop' into rnmobile/lists
SergioEstevao Mar 5, 2019
eb59a11
Mobile: Avoid adding empty link to text. (#14270)
etoledom Mar 7, 2019
60fbafb
Avoid to reset html to empty string if block is heading and platform …
marecar3 Mar 8, 2019
8f82fd3
Set minHeight based on fontSize or style. (#14344)
SergioEstevao Mar 8, 2019
940a858
Merge branch 'rnmobile/develop' into rnmobile/lists
SergioEstevao Mar 11, 2019
ea8d9d7
Remove unused styles classes. (#14338)
SergioEstevao Mar 12, 2019
38377fe
[Mobile]Fix placeholder position of block appender (#14386)
pinarol Mar 12, 2019
de77ad8
[Mobile]Update caret position on insert link (#14317)
pinarol Mar 13, 2019
a981491
Get the last master changes into the mobile develop branch (#14375)
Tug Mar 14, 2019
3f234fa
[RNmobile] Bring Placeholder text back working on Heading blocks (#14…
daniloercoli Mar 14, 2019
3581b0e
Add disableEditingMenu prop to manage showing editing menu on iOS (#1…
pinarol Mar 15, 2019
ac02ed9
[React Native] request cancel image upload (#14391)
mzorz Mar 19, 2019
71a4f39
Merge branch 'rnmobile/develop' into rnmobile/lists
SergioEstevao Mar 20, 2019
c569abf
Move list-edit.native.js to new location.
SergioEstevao Mar 20, 2019
5516432
Add multiline property.
SergioEstevao Mar 25, 2019
850b8d9
Merge branch 'master' into rnmobile/lists
SergioEstevao Mar 26, 2019
8d052c5
Make sure multiline property is filtered out of props on save.
SergioEstevao Mar 5, 2019
717ff8c
Send block edit parameters using the context.
SergioEstevao Mar 5, 2019
8c0066e
Add multiline variables to allow proper parsing and saving of propert…
SergioEstevao Mar 5, 2019
5553920
Add list edit toolbar options
SergioEstevao Mar 5, 2019
d3972e3
Add multiline property.
SergioEstevao Mar 25, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/block-editor/src/components/block-compare/block-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ import { Button } from '@wordpress/components';
const BlockView = ( { title, rawContent, renderedContent, action, actionText, className } ) => {
return (
<div className={ className }>
<div className="editor-block-compare__content block-editor-block-compare__content">
<h2 className="editor-block-compare__heading block-editor-block-compare__heading">{ title }</h2>
<div className="editor-block-compare__content">
<h2 className="editor-block-compare__heading">{ title }</h2>

<div className="editor-block-compare__html block-editor-block-compare__html">
<div className="editor-block-compare__html">
{ rawContent }
</div>

<div className="editor-block-compare__preview block-editor-block-compare__preview edit-post-visual-editor">
<div className="editor-block-compare__preview edit-post-visual-editor">
{ renderedContent }
</div>
</div>

<div className="editor-block-compare__action block-editor-block-compare__action">
<div className="editor-block-compare__action">
<Button isLarge tabIndex="0" onClick={ action }>{ actionText }</Button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,26 @@ exports[`BlockView should match snapshot 1`] = `
className="class"
>
<div
className="editor-block-compare__content block-editor-block-compare__content"
className="editor-block-compare__content"
>
<h2
className="editor-block-compare__heading block-editor-block-compare__heading"
className="editor-block-compare__heading"
>
title
</h2>
<div
className="editor-block-compare__html block-editor-block-compare__html"
className="editor-block-compare__html"
>
raw
</div>
<div
className="editor-block-compare__preview block-editor-block-compare__preview edit-post-visual-editor"
className="editor-block-compare__preview edit-post-visual-editor"
>
render
</div>
</div>
<div
className="editor-block-compare__action block-editor-block-compare__action"
className="editor-block-compare__action"
>
<ForwardRef(Button)
isLarge={true}
Expand Down
3 changes: 2 additions & 1 deletion packages/block-editor/src/components/block-edit/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ class BlockEdit extends Component {
}

static getDerivedStateFromProps( props ) {
const { clientId, name, isSelected } = props;
const { clientId, name, isSelected, onFocus } = props;

return {
name,
isSelected,
clientId,
onFocus,
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import { createSlotFill } from '@wordpress/components';

const { Fill: __experimentalBlockSettingsMenuFirstItem, Slot } = createSlotFill( '__experimentalBlockSettingsMenuFirstItem' );
const { Fill: _BlockSettingsMenuFirstItem, Slot } = createSlotFill( '_BlockSettingsMenuFirstItem' );

__experimentalBlockSettingsMenuFirstItem.Slot = Slot;
_BlockSettingsMenuFirstItem.Slot = Slot;

export default __experimentalBlockSettingsMenuFirstItem;
export default _BlockSettingsMenuFirstItem;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
import { createSlotFill } from '@wordpress/components';

const { Fill: __experimentalBlockSettingsMenuPluginsExtension, Slot } = createSlotFill( '__experimentalBlockSettingsMenuPluginsExtension' );
const { Fill: _BlockSettingsMenuPluginsExtension, Slot } = createSlotFill( '_BlockSettingsMenuPluginsExtension' );

__experimentalBlockSettingsMenuPluginsExtension.Slot = Slot;
_BlockSettingsMenuPluginsExtension.Slot = Slot;

export default __experimentalBlockSettingsMenuPluginsExtension;
export default _BlockSettingsMenuPluginsExtension;
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/**
* External dependencies
*/
import { noop, every } from 'lodash';

/**
* WordPress dependencies
*/
import { Fragment } from '@wordpress/element';
import { MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { hasBlockSupport, isReusableBlock } from '@wordpress/blocks';
import { withSelect, withDispatch } from '@wordpress/data';
import { compose } from '@wordpress/compose';

export function ReusableBlockConvertButton( {
isVisible,
isReusable,
onConvertToStatic,
onConvertToReusable,
} ) {
if ( ! isVisible ) {
return null;
}

return (
<Fragment>
{ ! isReusable && (
<MenuItem
className="editor-block-settings-menu__control block-editor-block-settings-menu__control"
icon="controls-repeat"
onClick={ onConvertToReusable }
>
{ __( 'Add to Reusable Blocks' ) }
</MenuItem>
) }
{ isReusable && (
<MenuItem
className="editor-block-settings-menu__control block-editor-block-settings-menu__control"
icon="controls-repeat"
onClick={ onConvertToStatic }
>
{ __( 'Convert to Regular Block' ) }
</MenuItem>
) }
</Fragment>
);
}

export default compose( [
withSelect( ( select, { clientIds } ) => {
const {
getBlocksByClientId,
canInsertBlockType,
} = select( 'core/block-editor' );
const {
__experimentalGetReusableBlock: getReusableBlock,
} = select( 'core/editor' );
const { canUser } = select( 'core' );

const blocks = getBlocksByClientId( clientIds );

const isReusable = (
blocks.length === 1 &&
blocks[ 0 ] &&
isReusableBlock( blocks[ 0 ] ) &&
!! getReusableBlock( blocks[ 0 ].attributes.ref )
);

// Show 'Convert to Regular Block' when selected block is a reusable block
const isVisible = isReusable || (
// Hide 'Add to Reusable Blocks' when reusable blocks are disabled
canInsertBlockType( 'core/block' ) &&

every( blocks, ( block ) => (
// Guard against the case where a regular block has *just* been converted
!! block &&

// Hide 'Add to Reusable Blocks' on invalid blocks
block.isValid &&

// Hide 'Add to Reusable Blocks' when block doesn't support being made reusable
hasBlockSupport( block.name, 'reusable', true )
) ) &&

// Hide 'Add to Reusable Blocks' when current doesn't have permission to do that
!! canUser( 'create', 'blocks' )
);

return {
isReusable,
isVisible,
};
} ),
withDispatch( ( dispatch, { clientIds, onToggle = noop } ) => {
const {
__experimentalConvertBlockToReusable: convertBlockToReusable,
__experimentalConvertBlockToStatic: convertBlockToStatic,
} = dispatch( 'core/editor' );

return {
onConvertToStatic() {
if ( clientIds.length !== 1 ) {
return;
}
convertBlockToStatic( clientIds[ 0 ] );
onToggle();
},
onConvertToReusable() {
convertBlockToReusable( clientIds );
onToggle();
},
};
} ),
] )( ReusableBlockConvertButton );
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* External dependencies
*/
import { noop } from 'lodash';

/**
* WordPress dependencies
*/
import { compose } from '@wordpress/compose';
import { MenuItem } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import { isReusableBlock } from '@wordpress/blocks';
import { withSelect, withDispatch } from '@wordpress/data';

export function ReusableBlockDeleteButton( { isVisible, isDisabled, onDelete } ) {
if ( ! isVisible ) {
return null;
}

return (
<MenuItem
className="editor-block-settings-menu__control block-editor-block-settings-menu__control"
icon="no"
disabled={ isDisabled }
onClick={ () => onDelete() }
>
{ __( 'Remove from Reusable Blocks' ) }
</MenuItem>
);
}

export default compose( [
withSelect( ( select, { clientId } ) => {
const { getBlock } = select( 'core/block-editor' );
const { canUser } = select( 'core' );
const { __experimentalGetReusableBlock: getReusableBlock } = select( 'core/editor' );
const block = getBlock( clientId );

const reusableBlock = block && isReusableBlock( block ) ?
getReusableBlock( block.attributes.ref ) :
null;

return {
isVisible: !! reusableBlock && !! canUser( 'delete', 'blocks', reusableBlock.id ),
isDisabled: reusableBlock && reusableBlock.isTemporary,
};
} ),
withDispatch( ( dispatch, { clientId, onToggle = noop }, { select } ) => {
const {
__experimentalDeleteReusableBlock: deleteReusableBlock,
} = dispatch( 'core/editor' );
const { getBlock } = select( 'core/block-editor' );

return {
onDelete() {
// TODO: Make this a <Confirm /> component or similar
// eslint-disable-next-line no-alert
const hasConfirmed = window.confirm( __(
'Are you sure you want to delete this Reusable Block?\n\n' +
'It will be permanently removed from all posts and pages that use it.'
) );

if ( hasConfirmed ) {
const block = getBlock( clientId );
deleteReusableBlock( block.attributes.ref );
onToggle();
}
},
};
} ),
] )( ReusableBlockDeleteButton );
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`ReusableBlockDeleteButton matches the snapshot 1`] = `
<MenuItem
className="editor-block-settings-menu__control block-editor-block-settings-menu__control"
disabled={false}
icon="no"
onClick={[Function]}
>
Remove from Reusable Blocks
</MenuItem>
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* External dependencies
*/
import ShallowRenderer from 'react-test-renderer/shallow';

/**
* Internal dependencies
*/
import { ReusableBlockConvertButton } from '../reusable-block-convert-button';

describe( 'ReusableBlockConvertButton', () => {
function getShallowRenderOutput( element ) {
const renderer = new ShallowRenderer();
renderer.render( element );
return renderer.getRenderOutput();
}

it( 'should not render when isVisible false', () => {
const wrapper = getShallowRenderOutput(
<ReusableBlockConvertButton isVisible={ false } />
);
expect( wrapper ).toBe( null );
} );

it( 'should allow converting a static block to a reusable block', () => {
const onConvert = jest.fn();
const wrapper = getShallowRenderOutput(
<ReusableBlockConvertButton
isVisible
isReusable={ false }
onConvertToReusable={ onConvert }
/>
);
expect( wrapper.props.children[ 1 ] ).toBeFalsy();
const button = wrapper.props.children[ 0 ];
expect( button.props.children ).toBe( 'Add to Reusable Blocks' );
button.props.onClick();
expect( onConvert ).toHaveBeenCalled();
} );

it( 'should allow converting a reusable block to static', () => {
const onConvert = jest.fn();
const wrapper = getShallowRenderOutput(
<ReusableBlockConvertButton
isVisible
isReusable
onConvertToStatic={ onConvert }
/>
);
expect( wrapper.props.children[ 0 ] ).toBeFalsy();
const button = wrapper.props.children[ 1 ];
expect( button.props.children ).toBe( 'Convert to Regular Block' );
button.props.onClick();
expect( onConvert ).toHaveBeenCalled();
} );
} );
Loading