bobbingwide / oik-blocks

WordPress 5.0 blocks for oik shortcodes
https://oik-plugins.com/oik-plugins/oik-blocks
GNU General Public License v3.0
1 stars 0 forks source link

Create a dynamic block to replace the [bw_csv] shortcode #2

Closed bobbingwide closed 2 years ago

bobbingwide commented 6 years ago

The [bw_csv] shortcode, delivered in oik-bob-bing-wide, provides a variety of formatting options for content entered as Comma Separated Values. Since Gutenberg doesn’t yet support an ASIS block, which could be used as one solution to the problem, we should develop a dynamic block that supports the functionality implemented for the bw_csv shortcode

Requirements

Proposed solution

Initial solution

Future

bobbingwide commented 6 years ago

At @WordCampLondon last weekend, I considered the best way of implementing the uo=table|u|ul|o|ol|d|dl parameter to the shortcode, which is used to switch the display of the content.

I realised this could be achieved using the toolbar icons.

uo value Icon For
default, table editor-table Generate HTML table
u, ul editor-ul Unordered list
o, ol editor-ol Ordered list
d, dl ? Description list.

The Advanced settings area could be used for the other attributes

th="y| n - Format table headings"
y="| Y| N - Convert y to a dash icon tick or cross"
n="| N| Y - Convert n to a dash icon cross or tick"
del,sep=",| | - Delimeter between columns

It will also show the textual representation of the uo= attribute.

bobbingwide commented 5 years ago

The oik-csv block does not work with Gutenberg 4.0.0 Uncaught TypeError: withInstanceId is not a function

bobbingwide commented 5 years ago

For some reason, as yet unidentified, the [bw_code] shortcode is being expanded incorrectly within the CSV block. It's OK when used in another block in the content. Find out why; for example see s.b/oikcom/oik_pluginversion/oik-bob-bing-wide-v1-31-1/

... The [bw_code bw_archive] shortcode is being expanded correctly to what's not normally treated as a shortcode since the LSB ( [ ) gets changed to [, which is supposed to prevent further expansion.

But it gets expanded anyway, later on. This is due to the unescape_invalid_shortcodes() function which replaces [ with [ again. This logic was introduced in WordPress 4.3.2

How come I've not seen / debugged this problem before?

Solution is to wrap the LSB in a span tag... in the oik base code. But in how many places?

bobbingwide commented 5 years ago

I want to be able to preview the block using server side rendering.

I was getting the following response.

{"code":"rest_invalid_param","message":"Invalid parameter(s): attributes",
"data":{"status":400,"params":{"attributes":"content is not a valid property of Object."}}}

The problem was that I'd copied the ServerSideRender tag but forgotten to change the block= parameter from oik-block/css to oik-block/csv.

bobbingwide commented 5 years ago

To support Description list format I needed to add a tool icon built from an SVG file. I made some progress, leaving a bit of a mess behind that I'll tidy up later. One day I'll learn how to create the svg path= parameter with a lot less fuss.

bobbingwide commented 5 years ago

Following changes for https://github.com/bobbingwide/oik/issues/120 we need to add logic to support shortcode expansion when the CSV block is rendered by the editor in the pseudo preview mode.

bobbingwide commented 5 years ago

Now we need to remove the unnecessary text field and replace it with a Format table headings toggle - attribute name th. This will be active when the format ( uo ) is Table. The default is true.

bobbingwide commented 4 years ago

Having found out how to implement transform to: for shortcodes I now want to add it the oik-blocks/csv block to transform the [bw_csv] shortcode.

bobbingwide commented 4 years ago

This block will be migrated from oik-blocks to oik-bob-bing-wide. Its new prefix will be oik-bbw. The new block may support a total attribute that will contain codes for how to create column totals. This will be developed as a new parameter to the [bw_csv] shortcode.

bobbingwide commented 2 years ago

Delivered as part of the oik-bob-bing-wide plugin. Closing therefore.