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

Allow basic d&d element/image in tables when tableselection is on #4951

Merged
merged 7 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ CKEditor 4 Changelog

## CKEditor 4.17.2 [IN DEVELOPMENT]

Fixed issues:

* [#547](https://github.com/ckeditor/ckeditor4/issues/547): Fixed: Element/Image drag to move within the table is no longer available.


## CKEditor 4.17.1

**Highlights:**
Expand Down
12 changes: 8 additions & 4 deletions plugins/tableselection/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,9 @@
function fakeSelectionDragHandler( evt ) {
var table = evt.data.getTarget().getAscendant( 'table', true );

// Prevent table selection during dragging. (#547)
fakeSelection.active = false;

// (#2945)
if ( table && table.hasAttribute( ignoredTableAttribute ) ) {
return;
Expand All @@ -391,10 +394,6 @@
if ( !cell || cell.hasClass( fakeSelectedClass ) ) {
return;
}

// We're not supporting dragging in our table selection for the time being.
evt.cancel();
evt.data.preventDefault();
}

function copyTable( editor, isCut ) {
Expand Down Expand Up @@ -789,6 +788,11 @@
return;
}

// #(547)
if ( evt.data.method === 'drop' ) {
return;
}
sculpt0r marked this conversation as resolved.
Show resolved Hide resolved

selectedTable = selectedCells[ 0 ].getAscendant( 'table' );
tableSel = new TableSelection( getSelectedCells( selection, selectedTable ) );

Expand Down
44 changes: 44 additions & 0 deletions tests/plugins/tableselection/manual/draganddropimage.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<textarea id="editor">
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td><img alt="" src="http://via.placeholder.com/100" />&nbsp;</td>
<td>test</td>
</tr>
<tr>
<td>
<p>&nbsp;</p>
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>

<p>&nbsp;</p>
</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
</textarea>

<script>
( function() {
if ( bender.tools.env.mobile ) {
return bender.ignore();
}

bender.tools.ignoreUnsupportedEnvironment( 'tableselection' );

CKEDITOR.replace( 'editor', {
height: 350
} );
} )();
</script>
18 changes: 18 additions & 0 deletions tests/plugins/tableselection/manual/draganddropimage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@bender-tags: dialog, 4.17.2, 547, bug
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, table, tableselection, image, undo, sourcearea, basicstyles, elementspath


1. Open browser's console.
3. Using drag&drop move image to other table cell.

**Expected**

* Image was moved properly.
* The content looking good and there is no error in the console.

**Unxpected**

* Image was not moved.
* There's error in the console.
* After the image was moved, the table was modified - an extra cell was added.
47 changes: 47 additions & 0 deletions tests/plugins/tableselection/manual/draganddropmixedcontent.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<textarea id="editor">
<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td>--&gt;&nbsp;<img alt="" src="http://via.placeholder.com/100" />&nbsp;<br />
Lorem ipsum dolor &lt;--<br />
sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.&nbsp;</td>
<td>test</td>
</tr>
<tr>
<td>
<p> </p>

<table border="1" cellpadding="1" cellspacing="1" style="width:500px">
<tbody>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>

<p> </p>
</td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</textarea>

<script>
( function() {
if ( bender.tools.env.mobile ) {
return bender.ignore();
}

bender.tools.ignoreUnsupportedEnvironment( 'tableselection' );

CKEDITOR.replace( 'editor', {
height: 350
} );
} )();
</script>
19 changes: 19 additions & 0 deletions tests/plugins/tableselection/manual/draganddropmixedcontent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@bender-tags: dialog, 4.17.2 547, bug
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, table, tableselection, undo, sourcearea, elementspath, image, basicstyles

**Note:** Before you start moving the selected mixed content text using D&D, hold down the left mouse button for a moment on selected text.

1. Open browser's console.
2. Select content between `--> <--`.
3. Using drag&drop move selected content to other table cell.

**Expected**

* Selected content was moved properly.
* The content looking good and there is no error in the console.

**Unxpected**

* Selected content was not moved.
* There's error in the console.
41 changes: 41 additions & 0 deletions tests/plugins/tableselection/manual/draganddroptext.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<textarea id="editor">
<table border="1" cellspacing="1" cellpadding="1" style="width:500px">
<tbody>
<tr>
<td>Move me.</td>
<td>test</td>
</tr>
<tr>
<td>
&nbsp;
<table border="1" cellspacing="1" cellpadding="1" style="width:500px">
<tbody>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
&nbsp;
</td>
<td> </td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
</tbody>
</table>
</textarea>

<script>
( function() {
if ( bender.tools.env.mobile ) {
return bender.ignore();
}

bender.tools.ignoreUnsupportedEnvironment( 'tableselection' );

CKEDITOR.replace( 'editor' );
} )();
</script>
19 changes: 19 additions & 0 deletions tests/plugins/tableselection/manual/draganddroptext.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@bender-tags: dialog, 4.17.2 547, bug
@bender-ui: collapsed
@bender-ckeditor-plugins: wysiwygarea, toolbar, table, tableselection, undo, sourcearea, elementspath

**Note:** Before you start moving the selected text using D&D, hold down the left mouse button for a moment on selected text.

1. Open browser's console.
2. Select only text `Move me.`.
3. Using drag&drop move selected text to other table cell.

**Expected**

* Selected text was moved properly.
* The content looking good and there is no error in the console.

**Unxpected**

* Selected text was not moved.
* There's error in the console.