|
|
@@ -9,6 +9,7 @@ import { setData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
|
|
|
import { defaultConversion, defaultSchema, modelTable } from './_utils/utils';
|
|
|
|
|
|
import TableSelection from '../src/tableselection';
|
|
|
+import { getData as getViewData } from '../../ckeditor5-engine/src/dev-utils/view';
|
|
|
|
|
|
describe( 'TableSelection', () => {
|
|
|
let editor, model, root, tableSelection;
|
|
|
@@ -63,7 +64,32 @@ describe( 'TableSelection', () => {
|
|
|
|
|
|
expect( Array.from( tableSelection.getSelection() ) ).to.deep.equal( [ nodeByPath ] );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should set view selection', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00[]', '01', '02' ],
|
|
|
+ [ '10', '11', '12' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ tableSelection.startSelection( root.getNodeByPath( [ 0, 0, 0 ] ) );
|
|
|
+
|
|
|
+ expect( getViewData( editor.editing.view ) ).to.equal(
|
|
|
+ '<figure class="table">' +
|
|
|
+ '<table>' +
|
|
|
+ '<tbody>' +
|
|
|
+ '<tr>' +
|
|
|
+ '[<td>00</td>]<td>01</td><td>02</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '<tr>' +
|
|
|
+ '<td>10</td><td>11</td><td>12</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '</tbody>' +
|
|
|
+ '</table>' +
|
|
|
+ '</figure>'
|
|
|
+ );
|
|
|
+ } );
|
|
|
} );
|
|
|
+
|
|
|
describe( 'stop()', () => {
|
|
|
it( 'should stop selection', () => {
|
|
|
setData( model, modelTable( [
|
|
|
@@ -136,6 +162,34 @@ describe( 'TableSelection', () => {
|
|
|
expect( tableSelection.isSelecting ).to.be.false;
|
|
|
expect( Array.from( tableSelection.getSelection() ) ).to.deep.equal( [ root.getNodeByPath( [ 0, 0, 0 ] ) ] );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should update view selection', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00[]', '01', '02' ],
|
|
|
+ [ '10', '11', '12' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ const startNode = root.getNodeByPath( [ 0, 0, 0 ] );
|
|
|
+ const firstEndNode = root.getNodeByPath( [ 0, 0, 1 ] );
|
|
|
+
|
|
|
+ tableSelection.startSelection( startNode );
|
|
|
+ tableSelection.stopSelection( firstEndNode );
|
|
|
+
|
|
|
+ expect( getViewData( editor.editing.view ) ).to.equal(
|
|
|
+ '<figure class="table">' +
|
|
|
+ '<table>' +
|
|
|
+ '<tbody>' +
|
|
|
+ '<tr>' +
|
|
|
+ '[<td>00</td>][<td>01</td>]<td>02</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '<tr>' +
|
|
|
+ '<td>10</td><td>11</td><td>12</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '</tbody>' +
|
|
|
+ '</table>' +
|
|
|
+ '</figure>'
|
|
|
+ );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'update()', () => {
|
|
|
@@ -199,6 +253,34 @@ describe( 'TableSelection', () => {
|
|
|
expect( tableSelection.isSelecting ).to.be.true;
|
|
|
expect( Array.from( tableSelection.getSelection() ) ).to.deep.equal( [ root.getNodeByPath( [ 0, 0, 0 ] ) ] );
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should update view selection', () => {
|
|
|
+ setData( model, modelTable( [
|
|
|
+ [ '00[]', '01', '02' ],
|
|
|
+ [ '10', '11', '12' ]
|
|
|
+ ] ) );
|
|
|
+
|
|
|
+ const startNode = root.getNodeByPath( [ 0, 0, 0 ] );
|
|
|
+ const firstEndNode = root.getNodeByPath( [ 0, 0, 1 ] );
|
|
|
+
|
|
|
+ tableSelection.startSelection( startNode );
|
|
|
+ tableSelection.updateSelection( firstEndNode );
|
|
|
+
|
|
|
+ expect( getViewData( editor.editing.view ) ).to.equal(
|
|
|
+ '<figure class="table">' +
|
|
|
+ '<table>' +
|
|
|
+ '<tbody>' +
|
|
|
+ '<tr>' +
|
|
|
+ '[<td>00</td>][<td>01</td>]<td>02</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '<tr>' +
|
|
|
+ '<td>10</td><td>11</td><td>12</td>' +
|
|
|
+ '</tr>' +
|
|
|
+ '</tbody>' +
|
|
|
+ '</table>' +
|
|
|
+ '</figure>'
|
|
|
+ );
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'getSelection()', () => {
|