-
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.
Split into separate functions and mark unstable
- Loading branch information
Showing
4 changed files
with
29 additions
and
8 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 |
---|---|---|
|
@@ -6,7 +6,8 @@ import { Toolbar } from '@wordpress/components'; | |
import { __ } from '@wordpress/i18n'; | ||
import { | ||
changeListType, | ||
getLineListFormat, | ||
__unstableGetLineNestingLevel, | ||
__unstableGetLineListFormat, | ||
} from '@wordpress/rich-text'; | ||
|
||
/** | ||
|
@@ -22,7 +23,7 @@ import BlockFormatControls from '../block-format-controls'; | |
* inner list is selected. | ||
*/ | ||
function isListRootSelected( value ) { | ||
return getLineListFormat( value ).nestingLevel < 1; | ||
return __unstableGetLineNestingLevel( value ) < 1; | ||
} | ||
|
||
/** | ||
|
@@ -35,7 +36,7 @@ function isListRootSelected( value ) { | |
* @return {boolean} [description] | ||
*/ | ||
function isActiveListType( tagName, rootTagName, value ) { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
hypest
Author
Contributor
|
||
const listFormat = getLineListFormat( value ); | ||
const listFormat = __unstableGetLineListFormat( value ); | ||
|
||
if ( ! listFormat || ! listFormat.type ) { | ||
return tagName === rootTagName; | ||
|
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 @@ | ||
/** | ||
* 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 list nesting level, starting from 0. | ||
*/ | ||
export function getLineNestingLevel( value ) { | ||
const { replacements, start } = value; | ||
const startingLineIndex = getLineIndex( value, start ); | ||
const startLineFormats = replacements[ startingLineIndex ] || []; | ||
return startLineFormats.length; | ||
} |
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
Hm, I'm still not sure why not move
isActiveListType
andisListRootSelected
torich-text
?