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

Move the Classic block to the packages #10397

Merged
merged 4 commits into from Oct 9, 2018

Conversation

Projects
None yet
6 participants
@youknowriad
Contributor

youknowriad commented Oct 8, 2018

In order to merge Gutenberg into Core easily, all the Gutenberg JavaScript Core must be shared a reusable npm package. This PR moves the freeform block to the packages folder.

The idea is to test whether the wp.oldEditor global (provided by WP) is available or not before registering the block. An alternative proposed by @gziolo is to move this block to edit-post module. I think both alternatives are good options. We'll probably have to revisit at some point either way so I just went with the simplest one for noow.

This also means the block library is fully available as a package. (so a bunch of files removed etc...)

Testing instructions

Make sure you can use the classic block properly.

@youknowriad youknowriad added the Packages label Oct 8, 2018

@youknowriad youknowriad self-assigned this Oct 8, 2018

@youknowriad youknowriad requested review from gziolo and WordPress/gutenberg-core Oct 8, 2018

@iseulde

This comment has been minimized.

Show comment
Hide comment
@iseulde

iseulde Oct 8, 2018

Member

Should the folders be renamed to classic instead of freeform?

Member

iseulde commented Oct 8, 2018

Should the folders be renamed to classic instead of freeform?

@tofumatt

This comment has been minimized.

Show comment
Hide comment
@tofumatt

tofumatt Oct 8, 2018

Member

Yes; the "freeform" name is quite confusing! 😅

Member

tofumatt commented Oct 8, 2018

Yes; the "freeform" name is quite confusing! 😅

@youknowriad

This comment has been minimized.

Show comment
Hide comment
@youknowriad

youknowriad Oct 8, 2018

Contributor

@tofumatt @iseulde The reason it's kept as "classic" is because we can't change the name of the block at the moment. I can rename the folder to "classic" but it feels like we'd create an inconsistency between block names and folders which all other blocks follow.

Contributor

youknowriad commented Oct 8, 2018

@tofumatt @iseulde The reason it's kept as "classic" is because we can't change the name of the block at the moment. I can rename the folder to "classic" but it feels like we'd create an inconsistency between block names and folders which all other blocks follow.

@gziolo

This comment has been minimized.

Show comment
Hide comment
@gziolo

gziolo Oct 8, 2018

Member

The reason it's kept as "classic" is because we can't change the name of the block at the moment. I can rename the folder to "classic" but it feels like we'd create an inconsistency between block names and folders which all other blocks follow.

It's called Classic in the UI:

screen shot 2018-10-08 at 17 12 19

I don't like exceptions, but in this case, it is only an internal name. We refer to it as classic every time we chat. I would vote to rename the folder and the variable assigned with import and leave the rest as is.

Sidenote: when you search for freeform in the inserter it finds nothing.

Member

gziolo commented Oct 8, 2018

The reason it's kept as "classic" is because we can't change the name of the block at the moment. I can rename the folder to "classic" but it feels like we'd create an inconsistency between block names and folders which all other blocks follow.

It's called Classic in the UI:

screen shot 2018-10-08 at 17 12 19

I don't like exceptions, but in this case, it is only an internal name. We refer to it as classic every time we chat. I would vote to rename the folder and the variable assigned with import and leave the rest as is.

Sidenote: when you search for freeform in the inserter it finds nothing.

@gziolo

gziolo approved these changes Oct 8, 2018

This looks great. We could discuss whether it should land in edit-post but this makes all the things easier for the time being and removes a lot of dead code. I would still consider renaming the folder from freeform to classic.

Show outdated Hide outdated packages/block-library/src/index.js Outdated
registerBlockType( name, settings );
} );
setDefaultBlockName( paragraph.name );
if ( window.wp && window.wp.oldEditor ) {

This comment has been minimized.

@gziolo

gziolo Oct 8, 2018

Member

We could register Classic block in here to avoid conditional in other parts.

if ( window.wp && window.wp.oldEditor ) {
    registerBlockType( freeform.name, freeform.settings );
    setUnknownTypeHandlerName( freeform.name );
}
@gziolo

gziolo Oct 8, 2018

Member

We could register Classic block in here to avoid conditional in other parts.

if ( window.wp && window.wp.oldEditor ) {
    registerBlockType( freeform.name, freeform.settings );
    setUnknownTypeHandlerName( freeform.name );
}

This comment has been minimized.

@youknowriad

youknowriad Oct 8, 2018

Contributor

I wasn't sure about the implication of the order of the block's registration, I know it has some importance in the transforms priority.

@youknowriad

youknowriad Oct 8, 2018

Contributor

I wasn't sure about the implication of the order of the block's registration, I know it has some importance in the transforms priority.

This comment has been minimized.

@gziolo

gziolo Oct 8, 2018

Member

I don't think it is important in this case, but I'm fine with leaving it as it is.

@gziolo

gziolo Oct 8, 2018

Member

I don't think it is important in this case, but I'm fine with leaving it as it is.

@gziolo gziolo added this to the 4.0 milestone Oct 8, 2018

@gziolo

This comment has been minimized.

Show comment
Hide comment
@gziolo

gziolo Oct 8, 2018

Member

We probably still need to add a changelog entry because technically speaking, you still can enable Classic block by defining window.wp.oldEditor global variable. It would mean version bump is minor because it adds new feature.

Member

gziolo commented Oct 8, 2018

We probably still need to add a changelog entry because technically speaking, you still can enable Classic block by defining window.wp.oldEditor global variable. It would mean version bump is minor because it adds new feature.

@youknowriad

This comment has been minimized.

Show comment
Hide comment
@youknowriad

youknowriad Oct 8, 2018

Contributor

I'll wait for a review of #10396 to merge this one as it's targetting that branch.

Contributor

youknowriad commented Oct 8, 2018

I'll wait for a review of #10396 to merge this one as it's targetting that branch.

@youknowriad youknowriad merged commit c303621 into update/move-html-blokc-to-packages Oct 9, 2018

@youknowriad youknowriad deleted the update/move-freeform-block-to-packages branch Oct 9, 2018

youknowriad added a commit that referenced this pull request Oct 9, 2018

Move the HTML block into the blocks library package (#10396)(#10397)
* Move the HTML block into the blocks library package

* Move the Classic block to the packages

* Move the Classic block to the packages
@talldan

This comment has been minimized.

Show comment
Hide comment
@talldan

talldan Oct 10, 2018

Contributor

Hey @youknowriad - I’m seeing a warning in latest master:

Warning: filemtime(): stat failed for /var/www/html/wp-content/plugins/gutenberg/build/block-library/edit-blocks.css in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php on line 741

It's still there after I cleaned the repo using git clean -dfx. I noticed some references to edit-blocks.css in this file, so I imagine there's a good chance it's related.

Contributor

talldan commented Oct 10, 2018

Hey @youknowriad - I’m seeing a warning in latest master:

Warning: filemtime(): stat failed for /var/www/html/wp-content/plugins/gutenberg/build/block-library/edit-blocks.css in /var/www/html/wp-content/plugins/gutenberg/lib/client-assets.php on line 741

It's still there after I cleaned the repo using git clean -dfx. I noticed some references to edit-blocks.css in this file, so I imagine there's a good chance it's related.

@gziolo

This comment has been minimized.

Show comment
Hide comment
@gziolo

gziolo Oct 10, 2018

Member

@talldan, looking into it.

Member

gziolo commented Oct 10, 2018

@talldan, looking into it.

@gziolo

This comment has been minimized.

Show comment
Hide comment
@gziolo

gziolo Oct 10, 2018

Member

I can't reproduce:

screen shot 2018-10-10 at 10 43 31

All 3 styles for block-library load properly. Also PHP code doesn't reference the file you shared:

wp_register_style(
		'wp-edit-blocks',
		gutenberg_url( 'build/block-library/editor.css' ),
		array(
			'wp-components',
			'wp-editor',
			// Always include visual styles so the editor never appears broken.
			'wp-block-library-theme',
		),
		filemtime( gutenberg_dir_path() . 'build/block-library/editor.css' )
	);
Member

gziolo commented Oct 10, 2018

I can't reproduce:

screen shot 2018-10-10 at 10 43 31

All 3 styles for block-library load properly. Also PHP code doesn't reference the file you shared:

wp_register_style(
		'wp-edit-blocks',
		gutenberg_url( 'build/block-library/editor.css' ),
		array(
			'wp-components',
			'wp-editor',
			// Always include visual styles so the editor never appears broken.
			'wp-block-library-theme',
		),
		filemtime( gutenberg_dir_path() . 'build/block-library/editor.css' )
	);
@talldan

This comment has been minimized.

Show comment
Hide comment
@talldan

talldan Oct 10, 2018

Contributor

Hmm, unusual. Restarted my docker env and it's fine now. Thanks for looking into it.

Contributor

talldan commented Oct 10, 2018

Hmm, unusual. Restarted my docker env and it's fine now. Thanks for looking into it.

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