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

Conversation

Projects
None yet
4 participants
@iseulde
Member

iseulde 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.

@iseulde iseulde added this to the 4.3 milestone Nov 5, 2018

@youknowriad

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

@youknowriad

This comment has been minimized.

Contributor

youknowriad commented Nov 9, 2018

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

@iseulde

This comment has been minimized.

Member

iseulde commented Nov 9, 2018

@youknowriad youknowriad modified the milestones: 4.4, 4.5 Nov 15, 2018

@iseulde iseulde force-pushed the fix/prefix-pattern branch from a848c93 to 4d7ae53 Nov 15, 2018

@iseulde iseulde force-pushed the fix/prefix-pattern branch from e831ce3 to efb6a16 Nov 16, 2018

@@ -27,8 +27,7 @@ export const settings = {
transforms: {
from: [
{
type: 'pattern',

This comment has been minimized.

@youknowriad

youknowriad Nov 19, 2018

Contributor

Should we schim the old API?

This comment has been minimized.

@iseulde

iseulde Nov 19, 2018

Member

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

@youknowriad

This comment has been minimized.

Contributor

youknowriad commented Nov 19, 2018

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,

This comment has been minimized.

@gziolo

gziolo Nov 19, 2018

Member

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 Nov 19, 2018

@youknowriad

This comment has been minimized.

Contributor

youknowriad commented Nov 19, 2018

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

@youknowriad

I noticed that this fixes some issues with focus jumps.

@youknowriad youknowriad merged commit bad6c5a into master Nov 19, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@iseulde iseulde deleted the fix/prefix-pattern branch Nov 19, 2018

@iseulde

This comment has been minimized.

Member

iseulde commented Nov 19, 2018

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.

grey-rsi pushed a commit to OnTheGoSystems/gutenberg that referenced this pull request Nov 22, 2018

Make it possible to undo prefix transforms (WordPress#11497)
* Make it possible to undo prefix transforms

* Same for backticks

* Tests: Refactor tests to stop using META_KEY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment