bobbingwide / uk-tides

UK tides - heights and times
https://www.oik-plugins.com/oik-plugins/uk-tides-times-and-heights/
1 stars 2 forks source link

Update for WordPress 5.8 compatibility #9

Closed bobbingwide closed 3 years ago

bobbingwide commented 3 years ago

The UK-tides plugin was originally built using webpack. When used in WordPress 5.8 the Widget block editor produces a "doing it wrong" message due to the enqueueing of wp-editor. It seems the best solution is to rework the code to build it using wp-scripts which will enable use of

import ServerSideRender from '@wordpress/server-side-render';

See https://github.com/bobbingwide/bobbingwide/issues/30#issuecomment-885912962

bobbingwide commented 3 years ago

Problems I encountered attempting to change the build process.

I copied and cobbled the package.json file from sb-starting-block and reworked with settings for UK-tides. But I didn't know how to rebuild the node_modules. The following didn't work: npm install, npm ci. Eventually, I ran npm install @wordpress/scripts --save-dev and the build ran.

But since I'd only changed the import for ServerSideRender and the block was now being registered in the server using the block.json method the index.assets.php file didn't list all the dependencies. I needed to change each const to the equivalent import. eg Change from const { __ } = wp.i18n; to import { __ } = '@wordpress/i18n';

Once I'd got the block working I then came a problem not being able to select the block. With WordPress 5.7.2 and Gutenberg 10.7.4 ( in blocks.wp-a2z.org ) the block is easily selectable.

image

But with the new build it's not. It's possible to select the block using the List View, but you can't see the toolbar.

image

The toolbar is only shown when Top Toolbar is selected.

image

I have the same problem with the sb-post-edit-block.

bobbingwide commented 3 years ago

For the Post Edit block, I added the textAlign attribute. This made the block selectable. Let's see if adding this works for UK tides. And also see if the change affects the results noted in https://github.com/bobbingwide/sb-post-edit-block/issues/3

bobbingwide commented 3 years ago

Yes. Adding the textAlign toolbar icon group does make the block selectable. No. It doesn't affect the display of the gradient. That was a block.json / theme.json thing.

bobbingwide commented 3 years ago

Oh great, I've just rebuilt the JavaScript and now I can't choose the fontSize. What did I get wrong?

bobbingwide commented 3 years ago

UK-tides v3.0.0 is now released. Closing therefore