ckeditor4 icon indicating copy to clipboard operation
ckeditor4 copied to clipboard

Support dragging block widgets into tables

Open engineering-this opened this issue 7 years ago • 6 comments

Are you reporting a feature request or a bug?

Feature

Check if the issue is already reported

Nothing found

Provide detailed reproduction steps (if any)

  1. Open editor that has widget and table plugins enabled. e.g. http://tests.ckeditor.dev:1030/tests/plugins/widget/manual/block
  2. Create empty table.
  3. Try to drag widget into any cell.

Expected result

Widget is dragged into table cell.

Actual result

Widget is not dragged into cell.

Additional info.

It is possible to drag widget into call that contains any block element p, div, etc.

Other details

  • Browser: any

engineering-this avatar Feb 12 '18 11:02 engineering-this

Two proposed solutions:

  1. Introduce configuration setting initTableWithBlock. That way people could decide whether they want to insert empty tables with empty td's or table with td's containing paragraphs. We actually could go one step further here and let users decide which block to use. So we could have:
  • config.initTableWithBlock = false; (default)
  • config.initTableWithBlock = 'p' ;
  • config.initTableWithBlock = 'div' ;
  • config.initTableWithBlock = 'perhaps others like h1-h6' ;
  1. Auto-create paragraphs or divs whenever widget gets inserted. Please note that it is possible to D&D inline widget inside the table but not the block one so I'm not sure we want to cover both cases or only one that doesn't work.

jswiderski avatar Jun 29 '18 09:06 jswiderski

There are someextra issues with widget and tables: #2189, #2190.

jswiderski avatar Jun 29 '18 10:06 jswiderski

Has there been any progress on this?

Being able to control how these tables are generated,

or at least having some events we could tie into would be amazing.

evt.onCellAdded

ect.

Your proposed configuration solutions would be amazing

config.initTableWithBlock = 'p'

ect.

SpencerGresoro avatar Sep 18 '18 15:09 SpencerGresoro

@SpencerGresoro So far we were unable to work on this issue.

As for the issue itself, it should be fixed in a way that it is possible to drop a widget directly to a table cell (even without block in it). This could be an often case that the cell has no block, and we need to handle it correctly.

mlewand avatar Oct 03 '18 09:10 mlewand

Thank you mlewand, I appreciate it.

SpencerGresoro avatar Oct 24 '18 22:10 SpencerGresoro

Actually this case is a bit more complicated.

Allowing dragging block widgets into table cell is simple, it can be achieved by adding

if ( el.getName() in { td: 1, th: 1 } ) {
	return CKEDITOR.LINEUTILS_INSIDE;
}

At the top of: https://github.com/ckeditor/ckeditor-dev/blob/460d751f8620ab780e60756c589adfb58673a9f3/plugins/widget/plugin.js#L2582-L2617

However after doing so new issue is visible: if table has more than one column you can drag only to cells in first column. It is also visible when each table cell has <p> inside. Mar-27-2019 14-05-54

That's because lineutils plugin which is used to find and create line which replaces caret in drag target is designed to work only with vertical values. Two table cells in same row has same y value, hence first one will be matched as closest. Extending lineutils to work in two dimensions is beyond the scope of regular bug fix, hence I'm changing type of issue to feature request.

engineering-this avatar Mar 27 '19 13:03 engineering-this