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

Replace TinyMCE decode entities #10283

Merged
merged 1 commit into from Oct 3, 2018

Conversation

Projects
None yet
3 participants
@iseulde
Member

iseulde commented Oct 1, 2018

Description

Replace TinyMCE function to decode entities with existing Gutenberg package.

How has this been tested?

Copy paste for example http://example.com/path/to/page?name=gutenberg&color=black on top of a selection. A link should be created and the "&" character should be decoded.

I was looking at adding an e2e test but didn't find anything useful right away to do pasting.

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 requested a review from WordPress/gutenberg-core Oct 2, 2018

@tofumatt

Makes sense to me! I think I can add a test for copy/pasting if there's no huge rush on merging this (like an hour or so!)

@iseulde

This comment has been minimized.

Show comment
Hide comment
@iseulde

iseulde Oct 2, 2018

Member
Member

iseulde commented Oct 2, 2018

@tofumatt

This comment has been minimized.

Show comment
Hide comment
@tofumatt

tofumatt Oct 2, 2018

Member

Clipboard tests in Puppeteer are super weird and not straightforward.

I tried:

it( 'should create a link from a pasted URL ', async () => {
		const url = 'http://example.com/path/to/page?name=gutenberg&color=black';
		// Create some text, including the URL we want to copy/paste.
		await clickBlockAppender();
		await page.keyboard.type( `First paragraph ${ url }` );

		// Select the URL in this paragraph.
		for ( let i = 0; i < url.length; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowLeft' );
		}

		// Copy the URL.
		await pressWithModifier( META_KEY, 'C' );

		// Move the cursor back to the end and create a new paragraph.
		for ( let i = 0; i < url.length; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowRight' );
		}
		await page.keyboard.press( 'Enter' );
		await page.keyboard.type( 'Second paragraph where we can replace the last word.' );

		// Select the last word and paste the URL.
		await page.keyboard.press( 'ArrowLeft' );
		for ( let i = 1; i <= 4; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowLeft' );
		}
		await pressWithModifier( META_KEY, 'P' );

		expect( await getEditedPostContent() ).toMatchSnapshot();
	} );

but it never copy/pasted. I say just merge this and I will work on the tests for a later PR.

Member

tofumatt commented Oct 2, 2018

Clipboard tests in Puppeteer are super weird and not straightforward.

I tried:

it( 'should create a link from a pasted URL ', async () => {
		const url = 'http://example.com/path/to/page?name=gutenberg&color=black';
		// Create some text, including the URL we want to copy/paste.
		await clickBlockAppender();
		await page.keyboard.type( `First paragraph ${ url }` );

		// Select the URL in this paragraph.
		for ( let i = 0; i < url.length; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowLeft' );
		}

		// Copy the URL.
		await pressWithModifier( META_KEY, 'C' );

		// Move the cursor back to the end and create a new paragraph.
		for ( let i = 0; i < url.length; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowRight' );
		}
		await page.keyboard.press( 'Enter' );
		await page.keyboard.type( 'Second paragraph where we can replace the last word.' );

		// Select the last word and paste the URL.
		await page.keyboard.press( 'ArrowLeft' );
		for ( let i = 1; i <= 4; i++ ) {
			await pressWithModifier( 'Shift', 'ArrowLeft' );
		}
		await pressWithModifier( META_KEY, 'P' );

		expect( await getEditedPostContent() ).toMatchSnapshot();
	} );

but it never copy/pasted. I say just merge this and I will work on the tests for a later PR.

@iseulde iseulde merged commit 2cd853f into master Oct 3, 2018

2 checks passed

codecov/project 49.3% remains the same compared to 78d1254
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@iseulde iseulde deleted the try/replace-mce-decode-entities branch Oct 3, 2018

@mtias mtias added this to the 4.0 milestone Oct 9, 2018

@mtias mtias added the Code Quality label Oct 9, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment