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

[RNMobile] Column block #19013

Merged
merged 231 commits into from
Apr 8, 2020
Merged
Show file tree
Hide file tree
Changes from 217 commits
Commits
Show all changes
231 commits
Select commit Hold shift + click to select a range
6da1bf4
WIP: navigate down in the hierarchy of InnerBlocks
jbinda Sep 18, 2019
6387115
WIP: Navigation Dwon in Inner Block
jbinda Oct 8, 2019
e010328
merge master
jbinda Oct 8, 2019
09359f6
adjust style
jbinda Oct 8, 2019
a424c63
fix after merge
jbinda Oct 8, 2019
2e7204b
fix after merge
jbinda Oct 8, 2019
5dce162
playing with borders
jbinda Oct 8, 2019
76340c0
working full border
jbinda Oct 9, 2019
3295957
refactor v1
jbinda Oct 10, 2019
a28b17d
refactor v2
jbinda Oct 10, 2019
f00ad33
merge master
jbinda Oct 10, 2019
5326d44
fixed dashed border android
jbinda Oct 10, 2019
c70697c
refactor v3
jbinda Oct 10, 2019
eb7bed0
adjust button-block-appender margin
jbinda Oct 10, 2019
2fdedb7
refactor v4
jbinda Oct 10, 2019
d602fff
reefactor v5
jbinda Oct 10, 2019
497dcbc
refactor v6
jbinda Oct 10, 2019
ca22502
adjust for media text
jbinda Oct 11, 2019
dd06cba
adjust focus for media text
jbinda Oct 11, 2019
ec97815
refactor apply styles
jbinda Oct 11, 2019
3bf893b
merge master
jbinda Oct 11, 2019
8b02aae
adjust media text media container
jbinda Oct 11, 2019
4c1e1b9
pass isParentSelected prop to BlockEdit
jbinda Oct 11, 2019
e5976c0
adjust dim style
jbinda Oct 11, 2019
b54fa56
Move FloatingToolbar logic to get shippable temporary version
lukewalczak Oct 15, 2019
a6dcf70
fix after merge floating-toolbr
jbinda Oct 16, 2019
63b163f
style media-text and fix jumping behaviour
jbinda Oct 15, 2019
d7434b0
merge master
jbinda Oct 30, 2019
fb9faff
initial changes
jbinda Oct 31, 2019
ed9a435
add getPrefferedColorScheme for dashed border
jbinda Nov 4, 2019
aafa452
enable FloatingToolbar for MediaText
jbinda Nov 4, 2019
dffabf9
refactor rich text handler
jbinda Nov 4, 2019
4576c6a
change dark-mode block holder border to blue
jbinda Nov 4, 2019
90ae894
dark-mode for group appender and placeholder
jbinda Nov 5, 2019
d8d4e1d
adjust margin for group placeholder
jbinda Nov 5, 2019
677aade
adjust innerblock margin for media-text
jbinda Nov 5, 2019
168c3a2
adjust group placeholder border color
jbinda Nov 5, 2019
d8b05e2
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Nov 5, 2019
e8464a0
adjust appender button color
jbinda Nov 6, 2019
7a500e1
re-activate the stacking vertically on Media & Text
jbinda Nov 6, 2019
132fa7a
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Nov 6, 2019
4b25130
merge master
jbinda Nov 7, 2019
c8f7476
WIP: add key extractor and slider
jbinda Nov 7, 2019
f45596a
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Nov 7, 2019
f94c828
CR changes
jbinda Nov 8, 2019
845f920
CR changes for Android RichText focus
jbinda Nov 12, 2019
35d8c8b
CR changes for MediaText margins
jbinda Nov 13, 2019
7eba06d
CR changes for getTree selector
jbinda Nov 13, 2019
48a62f4
CR changes: fix selection loop
jbinda Nov 15, 2019
65b8400
clean passing props after seletion loop issue fix
jbinda Nov 15, 2019
bd2a9fc
merge master
jbinda Nov 15, 2019
608af4c
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Nov 15, 2019
c072555
replace block specific text
jbinda Nov 15, 2019
f06f6af
replace block specific style
jbinda Nov 15, 2019
f2be82d
fix getParent selectors
jbinda Nov 18, 2019
e47908d
adjust selection logic
jbinda Nov 18, 2019
e8ae8b2
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Nov 18, 2019
2674522
fix show appender in group block
jbinda Nov 18, 2019
84d8dad
fix hasInnerBlocks
jbinda Nov 18, 2019
014e3a0
refactor selectors
jbinda Nov 19, 2019
fdb2fae
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Nov 19, 2019
3b94490
refactor navigate-down logic
jbinda Nov 22, 2019
941baef
fix dimed style aplied
jbinda Nov 22, 2019
df0f5a4
add unit test for selector
jbinda Nov 25, 2019
8ab7ebe
use getBlockCount to check if block has children
jbinda Nov 25, 2019
3ebc50c
fix group margins, placeholder and appender
jbinda Nov 25, 2019
a035030
Merge branch 'rnmobile/try/navigate-down' into rnmobile/navigate-down
jbinda Nov 25, 2019
cd5b608
adjustments
jbinda Nov 25, 2019
bd5a1f8
add parameters to style
jbinda Nov 26, 2019
3219ad0
refactor for removing isGroupType
jbinda Nov 26, 2019
e3b540a
refactor group placeholder
jbinda Nov 26, 2019
f47e6dc
adjust media-text
jbinda Nov 27, 2019
ca7e08f
finalise group appender logic
jbinda Nov 27, 2019
8de07ef
selection and dim adjustments
jbinda Nov 27, 2019
93ae250
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Nov 28, 2019
662008e
handle semi-bordered
jbinda Nov 28, 2019
6414b89
refactor after tug review
jbinda Nov 29, 2019
722134d
add isOpen check to conditionally show/hide appender button under gro…
jbinda Nov 29, 2019
89bb54e
Merge remote-tracking branch 'origin/master' into fix-group-appender
jbinda Nov 29, 2019
524e0ca
Update packages/block-editor/src/store/selectors.js
jbinda Dec 3, 2019
7cf3950
Update packages/block-editor/src/store/selectors.js
jbinda Dec 3, 2019
5a456c9
Update packages/block-library/src/media-text/edit.native.js
jbinda Dec 3, 2019
061257a
export styles for media-text to stylesheet
jbinda Dec 3, 2019
7fb084a
fix order in test case
jbinda Dec 3, 2019
583650b
merge master
jbinda Dec 3, 2019
4574daf
refactor stylesheet in mediatext
jbinda Dec 3, 2019
b53816e
merge master
jbinda Dec 4, 2019
3b43568
merge fix
jbinda Dec 4, 2019
3041c44
fix block appender
jbinda Dec 4, 2019
2f09fac
styling column block
jbinda Dec 4, 2019
22d5904
group appender logic
jbinda Dec 4, 2019
7a38a0c
merge fix group appender button
jbinda Dec 4, 2019
84e31a3
Merge branch 'rnmobile/navigate-down' into column-draft
jbinda Dec 4, 2019
4af0b00
revert import
jbinda Dec 4, 2019
75482c5
@dratwas CR refactor
jbinda Dec 6, 2019
0814bb8
@dratwas CR refactor on descendant
jbinda Dec 6, 2019
7cb1ddb
Merge remote-tracking branch 'origin/master' into rnmobile/navigate-down
jbinda Dec 8, 2019
417809f
WIP: setup column block
jbinda Dec 9, 2019
2483015
Merge branch 'rnmobile/navigate-down' into column-draft
jbinda Dec 9, 2019
4cf89d0
Squash all commits related to Column block component
lukewalczak Dec 11, 2019
db475cf
Merge branch 'master' into rnmobile/column-block
lukewalczak Dec 11, 2019
4a780ea
styling fixes after navigation feature merge (#19455)
lukewalczak Jan 7, 2020
320f472
Check if icon exists before passing to cloneElement
lukewalczak Jan 7, 2020
e6eca79
merge master
jbinda Jan 7, 2020
006c7d6
sync remote
jbinda Jan 7, 2020
bab5cec
Merge remote-tracking branch 'origin/fix-group-crash' into rnmobile/c…
jbinda Jan 7, 2020
e43e010
fix breadcrumbs missing-key warning
jbinda Jan 7, 2020
42d6e2b
replace RangeControl with StepperControl to set columns number
jbinda Jan 13, 2020
7073832
add columns const and vieportWidth
jbinda Jan 14, 2020
5f6d0ab
distribute columns
jbinda Jan 15, 2020
fefc237
initial calculated version
jbinda Jan 16, 2020
8a75c23
handle size on selection
jbinda Jan 16, 2020
9e3b6c8
logic adjustment
jbinda Jan 17, 2020
d57c3ef
add logic for android
jbinda Jan 20, 2020
9d9f778
add vertical alingment
jbinda Jan 20, 2020
b2f9ce5
show appender when column is selected
jbinda Jan 20, 2020
4db7a6c
initial CodeRefactor
jbinda Jan 20, 2020
88b722f
merge master
jbinda Jan 20, 2020
cc26270
refactor logic
jbinda Jan 21, 2020
4341ae8
refactor style logic
jbinda Jan 21, 2020
616ad59
add verticalALignment separately for Column
jbinda Jan 23, 2020
eccbfe1
add Column icon on Toolbar when block is selected
jbinda Jan 23, 2020
3319144
fix appender to duplicate separator line
jbinda Jan 24, 2020
1043d31
distribute changes to android KeyboardAwareFlatList
jbinda Jan 24, 2020
933ced8
ColumnsEdit refactor
jbinda Jan 24, 2020
6909591
remove columnStyle prop
jbinda Jan 24, 2020
fb39bb3
merge master
jbinda Jan 27, 2020
0a17961
merge master
jbinda Jan 30, 2020
32d8bbb
fix merge issue
jbinda Jan 30, 2020
435dfa4
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Jan 31, 2020
8fa514b
refactor Column Block style and passing width
jbinda Feb 3, 2020
28b4a88
merge master
jbinda Feb 3, 2020
c4faefd
merge master
jbinda Feb 4, 2020
197a323
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Feb 4, 2020
c66d9e5
fix lint issue
jbinda Feb 4, 2020
9fc95cb
refactor
jbinda Feb 5, 2020
2976b5f
change placeholder dashed bordering in Column
jbinda Feb 3, 2020
81828ae
move container calculation to Columns, prevent to override settings
jbinda Feb 5, 2020
daed594
adjust logic
jbinda Feb 5, 2020
3569a0d
changes after Piotr code review
jbinda Feb 6, 2020
8804260
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Feb 6, 2020
562d674
fix crash after refactor
jbinda Feb 7, 2020
7828fa3
revert breadcrumb icon changes
jbinda Feb 7, 2020
46dd520
refactor to use existing API for icons
jbinda Feb 7, 2020
cd97df2
refactor to use existing API for icons
jbinda Feb 7, 2020
631621d
refactor getVerticalAlingnment function
jbinda Feb 7, 2020
3ee4e95
refactor verticalAlignment logic
jbinda Feb 7, 2020
d495d20
pass flatListProp to InnerBlock
jbinda Feb 7, 2020
7261e3c
pass render prop to get verticalAlignment
jbinda Feb 7, 2020
3fb166e
refactor on verticalAlignment logic
jbinda Feb 7, 2020
fb0b5bd
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Feb 9, 2020
055e1aa
simplify margin adjustment logic
jbinda Feb 10, 2020
546fca9
refactor Column Block after code review
jbinda Feb 14, 2020
f5926be
remove alternate placeholder style
jbinda Feb 14, 2020
c1b343c
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Feb 14, 2020
e782cd8
update mobile-toolbar margins
jbinda Feb 14, 2020
6fbd26b
fix layout with two placeholsers
jbinda Feb 17, 2020
bbb9ae9
fix layout with two placeholsers
jbinda Feb 17, 2020
6685a2d
remove Column and Columns toolbar icons
jbinda Feb 18, 2020
52e995c
handle remove columns in block
jbinda Feb 18, 2020
874f62b
minor fix
jbinda Feb 18, 2020
d113070
redirect selection after column remove
jbinda Feb 19, 2020
02d12ba
Merge remote-tracking branch 'origin/master' into HEAD
jbinda Feb 19, 2020
de328b0
Merge branch 'rnmobile/column-block' of github.com:WordPress/gutenber…
jbinda Feb 19, 2020
202e28a
fix Stepper according to APi change
jbinda Feb 20, 2020
a21bc78
fix verticalAlignment behaviour
jbinda Feb 20, 2020
a2a8f70
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Feb 20, 2020
0e87bfb
disable remove button for empty column blocks
jbinda Feb 20, 2020
e7dd896
disable inserter depending on setting
jbinda Feb 20, 2020
12f6501
allow to pass custonOnDelete to clear Column content
jbinda Feb 21, 2020
1f29bb3
add separator to Column placeholder
jbinda Feb 21, 2020
7721b61
Merge branch 'rnmobile/column-block' of github.com:WordPress/gutenber…
jbinda Feb 21, 2020
a58f815
pass columnsSetting with props
jbinda Feb 27, 2020
079ea70
set bordering logic to keep columns layaout splitted
jbinda Feb 27, 2020
b7fdc3c
Revert "allow to pass custonOnDelete to clear Column content"
jbinda Feb 27, 2020
52ee211
redirect disallowRemoveInnerBlock to hide trash button
jbinda Feb 27, 2020
457fabe
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 10, 2020
0507f5d
prevent Group block bounce inside Columns
jbinda Mar 10, 2020
2d25271
Implement mock block-wrapper for mobile version. (#20772)
SergioEstevao Mar 11, 2020
8f88d56
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 12, 2020
cc61080
Revert "Set flex-shrink to 0 on the cell container (#20768)"
jbinda Mar 12, 2020
0be334d
fix measureLayout warn/crash
jbinda Mar 12, 2020
1ae3647
fix accidentionally commented line
jbinda Mar 12, 2020
ad866bc
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 13, 2020
8118b95
[RNMobile] Add `useResizeObserver()` to Column Block (#20838)
jbinda Mar 16, 2020
246ba26
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 16, 2020
f57e6ac
apply disscussed changes with behaviour
jbinda Mar 12, 2020
50358cd
cleanup code
jbinda Mar 19, 2020
49fcb66
revert disable remove Column button changes
jbinda Mar 19, 2020
f20e9cb
remove separator line from Stepper
jbinda Mar 19, 2020
8551a54
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 19, 2020
bb89794
Revert "Revert "Set flex-shrink to 0 on the cell container (#20768)""
jbinda Mar 19, 2020
3f293e0
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 25, 2020
49d71b6
remove unused code
jbinda Mar 25, 2020
69f6eaf
read verticalAlignment from Columns and pass to new Column
jbinda Mar 25, 2020
87f24bf
initial refactor on passed prop name
jbinda Mar 25, 2020
0374821
refactor passed props
jbinda Mar 25, 2020
bda850f
Merge branch 'master' into rnmobile/column-block
jbinda Mar 25, 2020
3ec4b34
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 25, 2020
37bad85
[RNMobile] Adjust new borders implementations to columns PR (#21073)
dratwas Mar 26, 2020
12d6fb6
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Mar 26, 2020
4b2f1a5
bring back original toolbar margin
jbinda Mar 27, 2020
8b08fb4
extract BREAKPOINTS to const
jbinda Mar 27, 2020
05bd9ba
refactor customOnDelete to onDelete
jbinda Mar 31, 2020
09b58c1
change aplyBlockStyle name to applyColumnWidth
jbinda Mar 31, 2020
bc8230a
return horizontalDIrection prop from composed withSelect
jbinda Mar 31, 2020
5082a2b
remove isCollapsed from alignmentToolbar
jbinda Mar 31, 2020
066e771
refactor readable content view
jbinda Mar 31, 2020
8949595
refactor block-mover after code review
jbinda Mar 31, 2020
f6f80bf
refactor block-mover after code review
jbinda Mar 31, 2020
cacd282
change applyColumnWidth function name
jbinda Apr 2, 2020
9c326e2
apply translation on up/down left/right words
jbinda Apr 2, 2020
8c09ae0
unify name for onAddBlock and onDeleteBlock action
jbinda Apr 3, 2020
c314d6c
refactor on calculate Column width in Columns
jbinda Apr 3, 2020
1cfb209
split customBlockProps
jbinda Apr 3, 2020
54f389e
Revert "disable inserter depending on setting"
jbinda Mar 19, 2020
9d7027d
add overwritten support inserterin index.native.js
jbinda Apr 3, 2020
22e1a62
remove flatFistProp group
jbinda Apr 6, 2020
076c05e
avoid passing contentContainerStyle from Columns
jbinda Apr 6, 2020
e550920
adjust movers translation
jbinda Apr 6, 2020
86e43d5
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Apr 6, 2020
e610e5e
refactor movers translation
jbinda Apr 6, 2020
8bfde1e
refactor on passing styles from Columns
jbinda Apr 6, 2020
d0ffa5c
Merge remote-tracking branch 'origin/master' into rnmobile/column-block
jbinda Apr 6, 2020
4028950
refactor movers logic
jbinda Apr 7, 2020
4ca51b0
handle proper RTL arrow direction
jbinda Apr 8, 2020
a0d0423
fix a11y messages for movers
jbinda Apr 8, 2020
4d4d3eb
fix a11y VoiceOver for movers
jbinda Apr 8, 2020
d3c2601
extract common logic to switchButtonPropIfRTL function
jbinda Apr 8, 2020
938fa1f
remove extra space
jbinda Apr 8, 2020
2698250
remove devOnly flag from Columns/Column block
jbinda Apr 8, 2020
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
1 change: 0 additions & 1 deletion packages/base-styles/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ $block-selected-padding: 0;
$block-selected-child-margin: 5px;
$block-selected-to-content: $block-edge-to-content - $block-selected-margin - $block-selected-border-width;


/**
* Border radii.
*/
Expand Down
14 changes: 12 additions & 2 deletions packages/block-editor/src/components/block-list/block.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class BlockListBlock extends Component {
this.props.onCaretVerticalPositionChange
}
clientId={ this.props.clientId }
contentStyle={ this.props.contentStyle }
/>
);
}
Expand All @@ -91,6 +92,8 @@ class BlockListBlock extends Component {
parentId,
isDimmed,
isTouchable,
onDeleteBlock,
horizontalDirection,
hasParent,
isParentSelected,
onSelect,
Expand All @@ -112,7 +115,10 @@ class BlockListBlock extends Component {
accessible={ ! isSelected }
accessibilityRole={ 'button' }
>
<View accessibilityLabel={ accessibilityLabel }>
<View
style={ { flex: 1 } }
accessibilityLabel={ accessibilityLabel }
>
{ showFloatingToolbar && (
<FloatingToolbar>
{ hasParent && (
Expand Down Expand Up @@ -168,7 +174,11 @@ class BlockListBlock extends Component {
) }
<View style={ styles.neutralToolbar }>
{ isSelected && (
<BlockMobileToolbar clientId={ clientId } />
<BlockMobileToolbar
clientId={ clientId }
onDelete={ onDeleteBlock }
horizontalDirection={ horizontalDirection }
/>
) }
</View>
</View>
Expand Down
31 changes: 28 additions & 3 deletions packages/block-editor/src/components/block-list/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export class BlockList extends Component {
withFooter = true,
isReadOnly,
isRootList,
flatListProps,
shouldShowInsertionPointBefore,
shouldShowInsertionPointAfter,
marginVertical = styles.defaultBlock.marginTop,
Expand All @@ -122,6 +123,7 @@ export class BlockList extends Component {
onAccessibilityEscape={ clearSelectedBlock }
>
<KeyboardAwareFlatList
{ ...flatListProps }
{ ...( Platform.OS === 'android'
? { removeClippedSubviews: false }
: {} ) } // Disable clipping on Android to fix focus losing. See https://github.com/wordpress-mobile/gutenberg-mobile/pull/741#issuecomment-472746541
Expand All @@ -135,6 +137,7 @@ export class BlockList extends Component {
keyboardShouldPersistTaps="always"
scrollViewStyle={ {
flex: isRootList ? 1 : 0,
...( ! isRootList && { overflow: 'visible' } ),
} }
data={ blockClientIds }
keyExtractor={ identity }
Expand Down Expand Up @@ -179,11 +182,23 @@ export class BlockList extends Component {
shouldShowInsertionPointAfter,
marginVertical = styles.defaultBlock.marginTop,
marginHorizontal = styles.defaultBlock.marginLeft,
horizontalDirection,
contentResizeMode,
contentStyle,
onAddBlock,
onDeleteBlock,
} = this.props;

const readableContentViewStyle = contentResizeMode === 'stretch' && {
flex: 1,
};

return (
<ReadableContentView>
<View pointerEvents={ isReadOnly ? 'box-only' : 'auto' }>
<ReadableContentView style={ readableContentViewStyle }>
<View
style={ readableContentViewStyle }
pointerEvents={ isReadOnly ? 'box-only' : 'auto' }
>
{ shouldShowInsertionPointBefore( clientId ) && (
<BlockInsertionPoint />
) }
Expand All @@ -197,6 +212,10 @@ export class BlockList extends Component {
onCaretVerticalPositionChange={
this.onCaretVerticalPositionChange
}
horizontalDirection={ horizontalDirection }
contentStyle={ contentStyle }
onAddBlock={ onAddBlock }
onDeleteBlock={ onDeleteBlock }
/>
{ ! this.shouldShowInnerBlockAppender() &&
shouldShowInsertionPointAfter( clientId ) && (
Expand Down Expand Up @@ -225,7 +244,7 @@ export class BlockList extends Component {
}

export default compose( [
withSelect( ( select, { rootClientId } ) => {
withSelect( ( select, { rootClientId, __experimentalMoverDirection } ) => {
const {
getBlockCount,
getBlockOrder,
Expand All @@ -235,12 +254,16 @@ export default compose( [
getSettings,
} = select( 'core/block-editor' );

const horizontalDirection =
jbinda marked this conversation as resolved.
Show resolved Hide resolved
__experimentalMoverDirection === 'horizontal';

const selectedBlockClientId = getSelectedBlockClientId();
const blockClientIds = getBlockOrder( rootClientId );
const insertionPoint = getBlockInsertionPoint();
const blockInsertionPointIsVisible = isBlockInsertionPointVisible();
const shouldShowInsertionPointBefore = ( clientId ) => {
return (
! horizontalDirection &&
blockInsertionPointIsVisible &&
insertionPoint.rootClientId === rootClientId &&
// if list is empty, show the insertion point (via the default appender)
Expand All @@ -251,6 +274,7 @@ export default compose( [
};
const shouldShowInsertionPointAfter = ( clientId ) => {
return (
! horizontalDirection &&
blockInsertionPointIsVisible &&
insertionPoint.rootClientId === rootClientId &&
// if the insertion point is at the end of the list
Expand All @@ -271,6 +295,7 @@ export default compose( [
selectedBlockClientId,
isReadOnly,
isRootList: rootClientId === undefined,
horizontalDirection,
};
} ),
withDispatch( ( dispatch ) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,17 @@ import styles from './style.scss';
import BlockMover from '../block-mover';
import { BlockSettingsButton } from '../block-settings';

const BlockMobileToolbar = ( { clientId, onDelete, order } ) => (
const BlockMobileToolbar = ( {
clientId,
onDelete,
order,
horizontalDirection,
} ) => (
<View style={ styles.toolbar }>
<BlockMover clientIds={ [ clientId ] } />
<BlockMover
clientIds={ [ clientId ] }
horizontalDirection={ horizontalDirection }
/>

<View style={ styles.spacer } />

Expand All @@ -48,13 +56,15 @@ export default compose(
order: getBlockIndex( clientId ),
};
} ),
withDispatch( ( dispatch, { clientId, rootClientId } ) => {
withDispatch( ( dispatch, { clientId, rootClientId, onDelete } ) => {
const { removeBlock } = dispatch( 'core/block-editor' );
return {
onDelete: () => {
Keyboard.dismiss();
removeBlock( clientId, rootClientId );
},
onDelete:
onDelete ||
( () => {
Keyboard.dismiss();
removeBlock( clientId, rootClientId );
} ),
};
} )
)( BlockMobileToolbar );
65 changes: 54 additions & 11 deletions packages/block-editor/src/components/block-mover/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,31 @@ import { ToolbarButton } from '@wordpress/components';
import { __, sprintf } from '@wordpress/i18n';
import { withSelect, withDispatch } from '@wordpress/data';
import { withInstanceId, compose } from '@wordpress/compose';
import { arrowUp, arrowDown } from '@wordpress/icons';
import { arrowUp, arrowDown, arrowLeft, arrowRight } from '@wordpress/icons';

const horizontalMover = {
firstButtonIcon: arrowLeft,
secondButtonIcon: arrowRight,
firstButtonHint: __( 'Double tap to move the block to the left' ),
secondButtonHint: __( 'Double tap to move the block to the right' ),
firstBlockTitle: __( 'Move block left' ),
lastBlockTitle: __( 'Move block right' ),
firstButtonDirection: __( 'left' ),
secondButtonDirection: __( 'right' ),
location: 'position',
};

const verticalMover = {
firstButtonIcon: arrowUp,
secondButtonIcon: arrowDown,
firstButtonHint: __( 'Double tap to move the block up' ),
secondButtonHint: __( 'Double tap to move the block down' ),
firstBlockTitle: __( 'Move block up' ),
lastBlockTitle: __( 'Move block down' ),
firstButtonDirection: __( 'up' ),
secondButtonDirection: __( 'down' ),
location: 'row',
};

const BlockMover = ( {
isFirst,
Expand All @@ -20,7 +44,20 @@ const BlockMover = ( {
onMoveUp,
firstIndex,
rootClientId,
horizontalDirection,
} ) => {
const {
firstButtonIcon,
secondButtonIcon,
firstButtonHint,
secondButtonHint,
firstBlockTitle,
lastBlockTitle,
firstButtonDirection,
secondButtonDirection,
location,
} = horizontalDirection ? horizontalMover : verticalMover;

if ( isLocked || ( isFirst && isLast && ! rootClientId ) ) {
return null;
}
Expand All @@ -31,37 +68,43 @@ const BlockMover = ( {
title={
! isFirst
? sprintf(
/* translators: accessibility text. %1: current block position (number). %2: next block position (number) */
__( 'Move block up from row %1$s to row %2$s' ),
/* translators: accessibility text. %1: block moving direction (string). %2: location of block - row or order number (string). %3: current block position (number). %4: next block position (number) */
__(
'Move block %2$s from %1$s %3$s to %1$s %4$s'
pinarol marked this conversation as resolved.
Show resolved Hide resolved
),
location,
firstButtonDirection,
firstIndex + 1,
firstIndex
)
: __( 'Move block up' )
: firstBlockTitle
}
jbinda marked this conversation as resolved.
Show resolved Hide resolved
isDisabled={ isFirst }
onClick={ onMoveUp }
icon={ arrowUp }
extraProps={ { hint: __( 'Double tap to move the block up' ) } }
icon={ firstButtonIcon }
extraProps={ { hint: firstButtonHint } }
/>

<ToolbarButton
title={
! isLast
? sprintf(
/* translators: accessibility text. %1: current block position (number). %2: next block position (number) */
/* translators: accessibility text. %1: block moving direction (string). %2: location of block - row or order number (string). %3: current block position (number). %4: next block position (number) */
__(
'Move block down from row %1$s to row %2$s'
'Move block %2$s from %1$s %3$s to %1$s %4$s'
),
location,
secondButtonDirection,
firstIndex + 1,
firstIndex + 2
)
: __( 'Move block down' )
: lastBlockTitle
}
isDisabled={ isLast }
onClick={ onMoveDown }
icon={ arrowDown }
icon={ secondButtonIcon }
extraProps={ {
hint: __( 'Double tap to move the block down' ),
hint: secondButtonHint,
} }
/>
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function ButtonBlockAppender( {
rootClientId,
getStylesFromColorScheme,
showSeparator,
onAddBlock,
} ) {
const appenderStyle = {
...styles.appender,
Expand All @@ -39,7 +40,7 @@ function ButtonBlockAppender( {
rootClientId={ rootClientId }
renderToggle={ ( { onToggle, disabled, isOpen } ) => (
<Button
onClick={ onToggle }
onClick={ onAddBlock || onToggle }
aria-expanded={ isOpen }
disabled={ disabled }
fixedRatio={ false }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@
import BaseButtonBlockAppender from '../button-block-appender';
import withClientId from './with-client-id';

export const ButtonBlockAppender = ( { clientId, showSeparator } ) => {
export const ButtonBlockAppender = ( {
clientId,
showSeparator,
onAddBlock,
} ) => {
return (
<BaseButtonBlockAppender
rootClientId={ clientId }
showSeparator={ showSeparator }
onAddBlock={ onAddBlock }
/>
);
};
Expand Down
14 changes: 14 additions & 0 deletions packages/block-editor/src/components/inner-blocks/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class InnerBlocks extends Component {
const {
clientId,
renderAppender,
__experimentalMoverDirection,
flatListProps,
contentResizeMode,
contentStyle,
onAddBlock,
onDeleteBlock,
marginVertical,
marginHorizontal,
} = this.props;
Expand All @@ -126,6 +132,14 @@ class InnerBlocks extends Component {
rootClientId={ clientId }
renderAppender={ renderAppender }
withFooter={ false }
__experimentalMoverDirection={
__experimentalMoverDirection
}
flatListProps={ flatListProps }
contentResizeMode={ contentResizeMode }
contentStyle={ contentStyle }
onAddBlock={ onAddBlock }
onDeleteBlock={ onDeleteBlock }
/>
) }
</>
Expand Down
Loading