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 list block in React Native #14636

Merged
merged 31 commits into from
Apr 5, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bd83d8f
Make sure multiline property is filtered out of props on save.
SergioEstevao Mar 5, 2019
8ed9cc0
Send block edit parameters using the context.
SergioEstevao Mar 5, 2019
e0d7cf6
Add multiline variables to allow proper parsing and saving of propert…
SergioEstevao Mar 5, 2019
eb33f84
Add list edit toolbar options
SergioEstevao Mar 5, 2019
c64dd5a
Add multiline property.
SergioEstevao Mar 25, 2019
f0a1e21
Add list block to mobile gb.
SergioEstevao Mar 4, 2019
73aaa4f
Move list-edit.native.js to new location.
SergioEstevao Mar 20, 2019
b6938aa
Make block edit send down the onFocus property.
SergioEstevao Mar 26, 2019
74f77cf
Handle case where unstableSplit is passed has prop.
SergioEstevao Mar 26, 2019
79f408c
Pass multiline tags to serialiser.
SergioEstevao Mar 27, 2019
1f12a9f
Use the format-lib for handling "Enter" in lists
hypest Mar 28, 2019
cc8a4e8
Merge branch 'master' into rnmobile/lists2
SergioEstevao Mar 29, 2019
ca338c2
Force selection reset on split
hypest Mar 29, 2019
076936f
Add multiline wrapper tags to formatToValue.
SergioEstevao Mar 29, 2019
6ff97b8
Merge branch 'rnmobile/lists2' of https://github.com/WordPress/gutenb…
SergioEstevao Mar 29, 2019
73fbd38
Remove unnecessary code.
SergioEstevao Mar 29, 2019
e07498e
Force rich-text text update on list type change
hypest Mar 29, 2019
f40852c
Merge branch 'master' into rnmobile/lists2
SergioEstevao Apr 2, 2019
7fb36f6
Merge branch 'master' into rnmobile/lists2
SergioEstevao Apr 3, 2019
9145a6d
Merge branch 'master' into rnmobile/lists2
SergioEstevao Apr 4, 2019
58eae26
Disable indent and outdent.
SergioEstevao Apr 4, 2019
08318ca
Enable toggling list type of nested lists
hypest Apr 4, 2019
9dcd23b
Update list type toolbar button on native mobile
hypest Apr 4, 2019
fd62f01
Include diff missed by previous commit
hypest Apr 4, 2019
66e971d
Rename to denote that it's about lines
hypest Apr 5, 2019
da0e1a7
Split into separate functions and mark unstable
hypest Apr 5, 2019
eb009e8
Add missing JSDoc param
Tug Apr 5, 2019
cc5666e
Update snapshot for BlockControls
Tug Apr 5, 2019
91f790c
Merge branch 'master' into rnmobile/lists2
SergioEstevao Apr 5, 2019
4451cb3
Move isActiveListType, isListRootSelected to rich-text package
hypest Apr 5, 2019
97ac0fb
Remove excess empty line
hypest Apr 5, 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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Toolbar } from '@wordpress/components';
import { __ } from '@wordpress/i18n';
import {
changeListType,
getStartNestingLevel,
} from '@wordpress/rich-text';

/**
Expand All @@ -20,9 +21,8 @@ import BlockFormatControls from '../block-format-controls';
* @return {boolean} True if the root list or nothing is selected, false if an
* inner list is selected.
*/
function isListRootSelected() {
// Consider the root list selected if nothing is selected.
return true;
function isListRootSelected( value ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not replace getStartListFormat with both isListRootSelected and isActiveListType? This seems weird to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 @ellatrix , not sure I follow. Do you mean to completely remove getStartListFormat and implement its pieces inside isListRootSelected and isActiveListType?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, export isListRootSelected and isActiveListType from rich-text as unstable.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with 4451cb3.

return getStartNestingLevel( value ) < 1;
}

/**
Expand Down Expand Up @@ -54,7 +54,7 @@ export const ListEdit = ( {
onClick() {
onChange( changeListType( value, { type: 'ul' } ) );

if ( isListRootSelected() ) {
if ( isListRootSelected( value ) ) {
onTagNameChange( 'ul' );
}
},
Expand All @@ -66,7 +66,7 @@ export const ListEdit = ( {
onClick() {
onChange( changeListType( value, { type: 'ol' } ) );

if ( isListRootSelected() ) {
if ( isListRootSelected( value ) ) {
onTagNameChange( 'ol' );
}
},
Expand Down
19 changes: 19 additions & 0 deletions packages/rich-text/src/get-start-nesting-level.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Internal dependencies
*/

import { getLineIndex } from './get-line-index';

/**
* Returns the nesting level of the list at the selection start position.
*
* @param {Object} value The rich-text value
*
* @return {number} The nesting level, starting from 0.
*/
export function getStartNestingLevel( value ) {
hypest marked this conversation as resolved.
Show resolved Hide resolved
const { text, replacements, start, end } = value;
const startingLineIndex = getLineIndex( value, start );
const startLineFormats = replacements[ startingLineIndex ] || [];
return startLineFormats.length;
}
1 change: 1 addition & 0 deletions packages/rich-text/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export { getActiveObject } from './get-active-object';
export { getSelectionEnd } from './get-selection-end';
export { getSelectionStart } from './get-selection-start';
export { getTextContent } from './get-text-content';
export { getStartNestingLevel } from './get-start-nesting-level';
export { isCollapsed } from './is-collapsed';
export { isEmpty, isEmptyLine } from './is-empty';
export { join } from './join';
Expand Down