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

Make it possible to undo prefix transforms #11497

Merged
merged 3 commits into from
Nov 19, 2018
Merged

Conversation

ellatrix
Copy link
Member

@ellatrix ellatrix commented Nov 5, 2018

Description

Fixes #11358.

This PR adjusts the prefix transforms so that they only execute when they match text right at the caret, so that they are undoable, and makes the check faster checking if the previous character is a space and not using any regular expressions otherwise on the whole text. Also adds e2e tests for all prefix and enter transforms, and adds some documentation.

How has this been tested?

Extra e2e tests have been added, but ensure e.g. list shortcuts like 1.  still work and it's possible to undo them and have it so that the prefix can be at the start without it being transformed.

Screenshots

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.

@ellatrix ellatrix added [Type] Bug An existing feature does not function as intended [Type] Performance Related to performance efforts labels Nov 5, 2018
@ellatrix ellatrix added this to the 4.3 milestone Nov 5, 2018
Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

Seems like a good enhancement but I'd appreciate a second opinion as I'm not very familiar with this code.

@youknowriad
Copy link
Contributor

Going to punt this for 4.4 as well. Tests are failing and this is just a way to divide work an ship.

@youknowriad youknowriad modified the milestones: 4.3, 4.4 Nov 9, 2018
@ellatrix
Copy link
Member Author

ellatrix commented Nov 9, 2018 via email

@youknowriad youknowriad modified the milestones: 4.4, 4.5 Nov 15, 2018
@ellatrix ellatrix added [Status] In Progress Tracking issues with work in progress and removed [Status] In Progress Tracking issues with work in progress labels Nov 16, 2018
@gziolo gziolo added the [Priority] High Used to indicate top priority items that need quick attention label Nov 19, 2018
@@ -27,8 +27,7 @@ export const settings = {
transforms: {
from: [
{
type: 'pattern',
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we schim the old API?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't know. It was never official/documented.

@youknowriad
Copy link
Contributor

have it so that the prefix can be at the start without it being transformed.

This is still very hard to do as if you add a space it's still transformed, I wonder if the undo should reset to the value with a space in it.

@@ -9,6 +9,7 @@ import {
convertBlock,
pressWithModifier,
insertBlock,
META_KEY,
Copy link
Member

@gziolo gziolo Nov 19, 2018

Choose a reason for hiding this comment

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

It needs to be rebased with the master branch.

With the latest refactoring, we are able to reuse logic from @wordpress/keycodes package and express this using primary modifier:

await pressWithModifier( 'primary', 'z' );

@gziolo gziolo force-pushed the fix/prefix-pattern branch from efb6a16 to c81e843 Compare November 19, 2018 12:14
@youknowriad
Copy link
Contributor

I'm not certain I understand what's different between this PR and master in terms of behavior.

Copy link
Contributor

@youknowriad youknowriad left a comment

Choose a reason for hiding this comment

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

I noticed that this fixes some issues with focus jumps.

@youknowriad youknowriad merged commit bad6c5a into master Nov 19, 2018
@ellatrix ellatrix deleted the fix/prefix-pattern branch November 19, 2018 23:16
@ellatrix
Copy link
Member Author

This is still very hard to do as if you add a space it's still transformed, I wonder if the undo should reset to the value with a space in it.

Haven't looked deeper, but probably some browsers, like Chrome, fail to visualise the trailing space. We might have to pad it with a non breaking space.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Priority] High Used to indicate top priority items that need quick attention [Type] Bug An existing feature does not function as intended [Type] Performance Related to performance efforts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Paragraph with starting 1. (e. g. for dates) not possible
4 participants