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

Open
bobbingwide opened this Issue Apr 6, 2018 · 7 comments

Comments

Projects
None yet
1 participant
@bobbingwide
Copy link
Owner

bobbingwide commented Apr 6, 2018

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

This comment has been minimized.

Copy link
Owner Author

bobbingwide commented Apr 16, 2018

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

This comment has been minimized.

Copy link
Owner Author

bobbingwide commented Oct 22, 2018

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

@bobbingwide

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner Author

bobbingwide commented Feb 17, 2019

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

This comment has been minimized.

Copy link
Owner Author

bobbingwide commented Feb 19, 2019

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

Issue #2 - Improve logic for selecting format using tool icons and a …
…select list. Add support for Description list, including a hand crafted icon.

bobbingwide added a commit that referenced this issue Feb 21, 2019

@bobbingwide

This comment has been minimized.

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

This comment has been minimized.

Copy link
Owner Author

bobbingwide commented Feb 26, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.