-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
RichText: List: Fix indent/outdent #12667
Conversation
25c3046
to
794c90e
Compare
794c90e
to
2f4b56b
Compare
I'm still adding inline documentation for these changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally, it seems to work quite well.
The code could very much use some commenting, as it's difficult to follow.
|
||
let changed; | ||
|
||
for ( let index = startIndex + 1 || 0; index < length; index++ ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would || 0
ever take effect? The only situation I see is when the left-hand is 0
which... would produce the same result anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think startIndex
could be undefined. In any case needs commenting.
Very well aware :) That's why I commented earlier and it's still a WIP. |
b008ba8
to
360e6dc
Compare
Not sure if easy, but would love a fix for "Shift + Enter" but it could be good for a separate PR too. Aside the error that I can't reproduce anymore (fine to ignore if you don't know the potential cause), everything is good when using the list block. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far testing looks good. I've done a first pass as I familiarise myself with this. Will be back. :)
/** | ||
* Indents any selected list items if possible. | ||
* | ||
* @param {Object} value Value to change. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a type defined in JSDoc for rich text? If not, should we?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, not so far. Perhaps we can look into that separately.
tagName, | ||
value, | ||
onChange, | ||
} ) => ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slightly tangential to the PR, but I would've expected the relationship between RichText and the List block to be more like:
List#edit = ( … ) =>
<ListEdit>
<RichText />
</ListEdit>
rather than let RichText
conditionally render ListEdit
among its children based its own state and props (isSelected && this.multilineTag === 'li'
). It feels like a strange burden on RichText and adds some indirection that reminds me of React/Backbone mixins, since List#edit
has to remember to pass onTagNameChange
to RichText
. Also, I wonder why we need to generalise onTagNameChange
instead of letting ListEdit
implement specific logic for ul
and ol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to rethink, but I feel like it might be better to do separately because we leave most of this unchanged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed
lib/client-assets.php
Outdated
@@ -87,8 +87,6 @@ function register_tinymce_scripts() { | |||
gutenberg_override_script( 'wp-tinymce-root', includes_url( 'js/tinymce/' ) . "tinymce{$mce_suffix}.js", array(), $tinymce_version ); | |||
gutenberg_override_script( 'wp-tinymce', includes_url( 'js/tinymce/' ) . "plugins/compat3x/plugin{$suffix}.js", array( 'wp-tinymce-root' ), $tinymce_version ); | |||
} | |||
|
|||
gutenberg_override_script( 'wp-tinymce-lists', includes_url( 'js/tinymce/' ) . "plugins/lists/plugin{$suffix}.js", array( 'wp-tinymce' ), $tinymce_version ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: This line will separately become removed in #13466.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the process of removing core PHP related to Gutenberg PRs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the process of removing core PHP related to Gutenberg PRs?
I'm currently gutting most of the PHP, so that we'll get to a point where Gutenberg PHP is primarily just overrides to the default core scripts and block implementations.
See also:
ca99c91
to
e4dc45d
Compare
When is it behaving weirdly. Steps to reproduce? Does the same thing happen on master? Worth noting that the PR shouldn't affect enter/backspace behaviour as it doesn't touch that logic.
Same as above
Happens for master too. Let's look separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I confirm I have the same list block weirdness in master. Let's follow up on that separately. Using the list block is not very good in Firefox right now.
Thanks @youknowriad! I'll follow up with fixes for enter/backspace. |
* RichText: List: use value to indent/outdent * Add outdent * Support multi outdent * Hold one reference per format * Keep list formats when indenting to new index * Remove unneeded parameter * Rename * Add logic to change list type * Add tests * Add e2e tests * Add some basic docs. Clean up. * Remove duplicate wp-tinymce dependency * Clean up * Add more docs, fix getSelectedListNode * Put duplicate text values in constant
Description
Currently in some cases indenting and outdenting list items is broken.
This PR fixes some issues and uses the RichText value directly instead of using the editor commands.
How has this been tested?
Screenshots
Types of changes
Checklist: