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

Fix for remaining fake selection in advance tab of table properties #599

Merged
merged 7 commits into from
Jul 25, 2017
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ New Features:

Fixed Issues:

* [#579](https://github.com/ckeditor/ckeditor-dev/issues/579): Fixed: Internal `cke_table-faked-selection-table` class visible in Stylesheet Classes field in [Table Properties](http://ckeditor.com/addon/table) dialog.
* [#545](https://github.com/ckeditor/ckeditor-dev/issues/545): [Edge] Fixed: Error thrown when pressing the Select All button in a [Source Mode](http://ckeditor.com/addon/sourcearea).
* [#582](https://github.com/ckeditor/ckeditor-dev/issues/582): Fixed: Double slash in path to stylesheet needed by [Table Selection](http://ckeditor.com/addon/tableselection) plugin. Thanks to [Marius Dumitru Florea](https://github.com/mflorea)!
* [#491](https://github.com/ckeditor/ckeditor-dev/issues/491): Fixed: Unnecessary dependency on [Editor Toolbar](http://ckeditor.com/addon/toolbar) plugin inside [Notification](http://ckeditor.com/addon/notification) plugin.
Expand Down
6 changes: 3 additions & 3 deletions plugins/tableselection/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
'use strict';

var fakeSelectedClass = 'cke_table-faked-selection',
fakeSelectedTableClass = fakeSelectedClass + '-table',
fakeSelectedEditorClass = fakeSelectedClass + '-editor',
fakeSelectedTableDataAttribute = 'cke-table-faked-selection-table',
fakeSelection = { active: false },
tabletools,
getSelectedCells,
Expand Down Expand Up @@ -122,7 +122,7 @@
}

if ( selectedCells.count() > 0 ) {
selectedCells.getItem( 0 ).getAscendant( 'table' ).removeClass( fakeSelectedTableClass );
selectedCells.getItem( 0 ).getAscendant( 'table' ).data( fakeSelectedTableDataAttribute, false );
}

editor.fire( 'unlockSnapshot' );
Expand Down Expand Up @@ -251,7 +251,7 @@

if ( cells.length > 0 ) {
editor.editable().addClass( fakeSelectedEditorClass );
cells[ 0 ].getAscendant( 'table' ).addClass( fakeSelectedTableClass );
cells[ 0 ].getAscendant( 'table' ).data( fakeSelectedTableDataAttribute, '' );
}

editor.fire( 'unlockSnapshot' );
Expand Down
2 changes: 1 addition & 1 deletion plugins/tableselection/styles/tableselection.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.cke_table-faked-selection-editor *::selection, table.cke_table-faked-selection-table *::selection {
.cke_table-faked-selection-editor *::selection, table[data-cke-table-faked-selection-table] *::selection {
background: transparent;
}

Expand Down
27 changes: 27 additions & 0 deletions tests/plugins/table/fakeselectionadvancetab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* bender-tags: editor,unit */
/* bender-ckeditor-plugins: dialogadvtab,table,tableselection */

( function() {
'use strict';

bender.editor = true;

bender.test( {

// #579
'test advance table dialog for ignorig selection class': function() {
if ( !CKEDITOR.plugins.tableselection.isSupportedEnvironment ) {
assert.ignore();
}

var bot = this.editorBot;

// Add table with fake selection.
bot.setHtmlWithSelection( '<table border="1">[<tr><td>Cell1</td><td>Cell2</td></tr>]</table>' );

bot.dialog( 'tableProperties', function( dialog ) {
assert.areSame( '', dialog.getValueOf( 'advanced', 'advCSSClasses' ) );
} );
}
} );
} )();
34 changes: 34 additions & 0 deletions tests/plugins/table/manual/fakeselectionadvancetab.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<textarea id="editor1">
&lt;table border="1" bordercolor="#ccc" cellpadding="5" cellspacing="0" style="border-collapse:collapse"&gt;
&lt;caption&gt;&lt;strong&gt;Mission crew&lt;/strong&gt;&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th scope="col" style="background-color: rgb(221, 221, 221);"&gt;Position&lt;/th&gt;
&lt;th scope="col" style="background-color: rgb(221, 221, 221);"&gt;Astronaut&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Commander&lt;/td&gt;
&lt;td style="text-align:center"&gt;Neil A. Armstrong&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Command Module Pilot&lt;/td&gt;
&lt;td style="text-align:center"&gt;Michael Collins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lunar Module Pilot&lt;/td&gt;
&lt;td style="text-align:center"&gt;Edwin &amp;quot;Buzz&amp;quot; E. Aldrin, Jr.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
</textarea>

<script>
CKEDITOR.replace( 'editor1' );
CKEDITOR.on( 'instanceLoaded', function() {
if ( !CKEDITOR.plugins.tableselection.isSupportedEnvironment ) {
bender.ignore();
}
});
</script>
13 changes: 13 additions & 0 deletions tests/plugins/table/manual/fakeselectionadvancetab.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
@bender-tags: 4.7.2, bug, 579
@bender-ui: collapsed
@bender-ckeditor-plugins: dialogadvtab,table,tableselection,wysiwygarea

1. Select at least 2 cells in table.
1. Right click and select `Table Properties`.
1. Make sure that selection is now fake (selection colour changed to grey).
1. Go to `Avanced` tab.
1. Check `Stylesheet Classes`.

**Expected:** `Stylesheet Classes` field is empty.

**Unexpected:** `Stylesheet Classes` contains internal cke class with fakeselection.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</table>
</p>
=>
<table class="cke_table-faked-selection-table">
<table data-cke-table-faked-selection-table="">
<tbody>
<tr>
<td class="cke_table-faked-selection">11@</td>
Expand All @@ -36,7 +36,7 @@
</table>
</p>
=>
<table class="cke_table-faked-selection-table">
<table data-cke-table-faked-selection-table="">
<tbody>
<tr>
<td class="cke_table-faked-selection">11@</td>
Expand All @@ -62,7 +62,7 @@
</tr>
</table>
=>
<table class="cke_table-faked-selection-table">
<table data-cke-table-faked-selection-table="">
<tbody>
<tr>
<td class="cke_table-faked-selection" colspan="2">11@</td>
Expand All @@ -76,4 +76,4 @@
</tr>
</tbody>
</table>
</textarea>
</textarea>