|
|
@@ -12,10 +12,13 @@ import { assertEqualMarkup } from '@ckeditor/ckeditor5-utils/tests/_utils/utils'
|
|
|
import TableEditing from '../../src/tableediting';
|
|
|
import TableSelection from '../../src/tableselection';
|
|
|
import { assertSelectedCells, modelTable, viewTable } from '../_utils/utils';
|
|
|
+import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils';
|
|
|
|
|
|
describe( 'table selection', () => {
|
|
|
let editor, model, view, viewDoc;
|
|
|
|
|
|
+ testUtils.createSinonSandbox();
|
|
|
+
|
|
|
beforeEach( async () => {
|
|
|
editor = await VirtualTestEditor.create( {
|
|
|
plugins: [ TableEditing, TableSelection, Paragraph ]
|
|
|
@@ -418,6 +421,41 @@ describe( 'table selection', () => {
|
|
|
[ '10', '11' ]
|
|
|
], { asWidget: true } ) + '<p>{}foo</p>' );
|
|
|
} );
|
|
|
+
|
|
|
+ // https://github.com/ckeditor/ckeditor5/issues/6353
|
|
|
+ it( 'should do nothing on successive "mouseup" events beyond the table after the selection was fininished', () => {
|
|
|
+ const spy = testUtils.sinon.spy( editor.plugins.get( 'TableSelection' ), 'stopSelection' );
|
|
|
+
|
|
|
+ setModelData( model, modelTable( [
|
|
|
+ [ '[]00', '01' ],
|
|
|
+ [ '10', '11' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ pressMouseButtonOver( getTableCell( '00' ) );
|
|
|
+ movePressedMouseOver( getTableCell( '11' ) );
|
|
|
+ releaseMouseButtonOver( getTableCell( '11' ) );
|
|
|
+
|
|
|
+ sinon.assert.calledOnce( spy );
|
|
|
+
|
|
|
+ pressMouseButtonOver( viewDoc.getRoot() );
|
|
|
+ releaseMouseButtonOver( viewDoc.getRoot() );
|
|
|
+
|
|
|
+ sinon.assert.calledOnce( spy );
|
|
|
+ } );
|
|
|
+
|
|
|
+ // https://github.com/ckeditor/ckeditor5/issues/6114
|
|
|
+ it( 'should prevent default the "mousemove" event to prevent the native DOM selection from changing', () => {
|
|
|
+ setModelData( model, modelTable( [
|
|
|
+ [ '[]00', '01' ],
|
|
|
+ [ '10', '11' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ pressMouseButtonOver( getTableCell( '00' ) );
|
|
|
+ const domEvtData = movePressedMouseOver( getTableCell( '11' ) );
|
|
|
+ releaseMouseButtonOver( getTableCell( '11' ) );
|
|
|
+
|
|
|
+ sinon.assert.calledOnce( domEvtData.preventDefault );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
function getTableCell( data ) {
|
|
|
@@ -437,7 +475,7 @@ describe( 'table selection', () => {
|
|
|
}
|
|
|
|
|
|
function movePressedMouseOver( target ) {
|
|
|
- moveMouseOver( target, mouseButtonPressed );
|
|
|
+ return moveMouseOver( target, mouseButtonPressed );
|
|
|
}
|
|
|
|
|
|
function moveReleasedMouseOver( target ) {
|
|
|
@@ -445,7 +483,7 @@ describe( 'table selection', () => {
|
|
|
}
|
|
|
|
|
|
function moveMouseOver( target, ...decorators ) {
|
|
|
- fireEvent( view, 'mousemove', addTarget( target ), ...decorators );
|
|
|
+ return fireEvent( view, 'mousemove', addTarget( target ), ...decorators );
|
|
|
}
|
|
|
|
|
|
function releaseMouseButtonOver( target ) {
|
|
|
@@ -481,5 +519,7 @@ describe( 'table selection', () => {
|
|
|
}
|
|
|
|
|
|
viewDoc.fire( eventName, domEvtDataStub );
|
|
|
+
|
|
|
+ return domEvtDataStub;
|
|
|
}
|
|
|
} );
|