turnermm / ckgedit

CKEditor integrated into Dokuwiki
https://www.dokuwiki.org/plugin:ckgedit
GNU General Public License v2.0
60 stars 49 forks source link

Multiple rowspans in table row get mixed up #681

Closed SirDoctorK closed 2 years ago

SirDoctorK commented 2 years ago

DokuWiki's table syntax allows for rowspans - vertically connected cells - with ::: as the cell contents. If this is used on multiple columns, it confuses the CKG editor.

If the editor is used on a section that contains such a table, even if the edit is cancelled without saving, the second instance of the rowspan is swapped with the cell after it in the same row.

The editor gets even more confused if it is used to create such a table - it completely blanks and removes the edited section entirely, even content that existed before the editor was opened.

Verified on two different DokuWiki servers.

Example page:

image

DW source for example page:

====== Table test ======

==== Correct ====

This is how the table should look

^F1^F2^F3^F4^F5|
|1-1|2-1|3-1|4-1|5-1|
|1-2|2-2|3-2| ::: |5-2|
|1-3| ::: |3-3| ::: |5-3|
|1-4| ::: |3-4| ::: |5-4|
|1-5| ::: |3-5| ::: |5-5|

==== Incorrect ====

This is how it looks after being touched by the CKG editor. Note that once the rowspan ''| ::: |'' cell appears a second time in one row, the CKG editor swaps the second instance and the cell after it in that row.

^F1^F2^F3^F4^F5|
|1-1|2-1|3-1|4-1|5-1|
|1-2|2-2|3-2| ::: |5-2|
|1-3| ::: |3-3|5-3| ::: |
|1-4| ::: |3-4|5-4| ::: |
|1-5| ::: |3-5|5-5| ::: |
turnermm commented 2 years ago

The way to do this is to first create your table in the Ckgeditor and then embed it between the HTML BLOCK macros, as described in the ckgedit documentation. This will preserve the table as HTML and on reloading you can make whatever changes you need to the data and the table structure.

SirDoctorK commented 2 years ago

It seems that this workaround requires changing the table to HTML syntax instead of DokuWiki syntax manually. After enabling htmlok in DokuWiki settings, and adding the tags in the CKG editor as shown in the documentation, it just deleted the whole section.

Is a fix for this in progress? Requiring a workaround to avoid breaking standard DokuWiki syntax isn't a great experience...

turnermm commented 2 years ago

It seems that this workaround requires changing the table to HTML syntax instead of DokuWiki syntax manually.

No. Create your table using ckgedit's tools. Enclose it in the macros and save. Or create it in the Dokuwiki editor, enclose it in the macros and save. You do not code your own HTML.

The latter method was the way this was done: http://mturner.org/xen_server_igor/wiki/html_blocks

SirDoctorK commented 2 years ago

I see. Neither of those work on my system, despite having htmlok checked in the DW config. I've also verified that the example table you linked renders correctly if I copy it into the DW editor so it looks like the HTML block is working.

However, enclosing the DW-style table source in the HTML block just causes it to be shown in plain text. And adding the block to an existing or newly created table with CKG just deletes the whole section I was editing.

turnermm commented 2 years ago

Sorry. My previous post was not entirely correct. Or at the very least misleading. The blocks, as the name implies, are meant to mark off blocks of HTML, whichever editor is in use. But they are not designed to be used to mark off HTML code that you enter directly into the ckgedit editor. I’ve never tested it. But with htmlok set to true, you can enter HTML into the D-W editor. The plugin page gives an example of using it in the Dokuwiki editor. I am not sure what difference your system would make. I’ve used it on both Unix/Linux systems and Centos, with PHP versions starting with 5 and through 8.

SirDoctorK commented 2 years ago

Thanks for the clarification. Is the CKG editor intended to generate the HTML for tables created with it? And is a proper fix for complex tables in the CKG editor in the pipeline?

turnermm commented 2 years ago

The Ckeditor is a modern browser application. It's engine is JavaScript. When you save a page ckgedit saves it as Dokuwiki markup. And when you load a page from the server, ckgedit inserts into the editor the HTML output by Dokuwiki. That's the short story.

Complex tables are already supported. It would be great if someone with more patience and skill would refactor the code.

SirDoctorK commented 2 years ago

That makes sense. What doesn't make sense is why it's messing up the conversion from the editor to DokuWiki markup. Is the behavior I described consistent with what you see?

turnermm commented 2 years ago

That makes sense. What doesn't make sense is why it's messing up the conversion from the editor to DokuWiki

Complex tables are probably the most difficult feature for the parser to deal with. Which is why I suggested HTML blocks. Unfortunately they do not translate back to Dokuwiki markup. Or use an include