Skip to content
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

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

Closed
bobbingwide opened this issue Apr 6, 2018 · 10 comments
Closed

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

bobbingwide opened this issue Apr 6, 2018 · 10 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

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

  • Develop a new CSV block which enables the user to enter Comma Separated Data
  • Support the existing options to define the output format
  • Support the existing options to load the CSV content from an attachment
  • Support the existing option to convert selected characters to dashicon ticks and crosses
  • Support inline shortcodes

Proposed solution

Initial solution

  • Develop a dynamic block called oik-block/csv in blocks/oik-csv
  • Support attributes as if the block were the [bw_csv] shortcode
  • Store the data for $content in an attribute called content

Future

  • Add support for displaying an uploaded CSV file
@bobbingwide
Copy link
Owner Author

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
Copy link
Owner Author

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

@bobbingwide
Copy link
Owner Author

bobbingwide commented Dec 10, 2018

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
Copy link
Owner Author

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
Copy link
Owner Author

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 added a commit that referenced this issue Feb 21, 2019
…select list. Add support for Description list, including a hand crafted icon.
bobbingwide added a commit that referenced this issue Feb 21, 2019
@bobbingwide
Copy link
Owner Author

bobbingwide commented Feb 22, 2019

Following changes for bobbingwide/oik#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 added a commit that referenced this issue Feb 25, 2019
@bobbingwide
Copy link
Owner Author

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
Copy link
Owner Author

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 bobbingwide added the enhancement New feature or request label Jan 19, 2020
@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 19, 2020

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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant