-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7550 from ckeditor/i/6755
Fix (widget): The resizing mechanism will not trigger other `view.Document#mousedown` events. Thanks to that while resizing an image inside a cell, the mouse will not trigger the table's actions. Closes #6755.
- Loading branch information
Showing
4 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/ckeditor5-widget/tests/widgetresize-integration.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. | ||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license | ||
*/ | ||
|
||
/* global document, Event */ | ||
|
||
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor'; | ||
|
||
import { setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model'; | ||
import testUtils from '@ckeditor/ckeditor5-core/tests/_utils/utils'; | ||
import Image from '@ckeditor/ckeditor5-image/src/image'; | ||
import ImageResize from '@ckeditor/ckeditor5-image/src/imageresize'; | ||
|
||
describe( 'WidgetResize - integration', () => { | ||
let editor, model, view, viewDocument, editorElement; | ||
|
||
testUtils.createSinonSandbox(); | ||
|
||
beforeEach( () => { | ||
editorElement = document.createElement( 'div' ); | ||
document.body.appendChild( editorElement ); | ||
|
||
return ClassicEditor.create( editorElement, { plugins: [ Image, ImageResize ] } ) | ||
.then( newEditor => { | ||
editor = newEditor; | ||
model = editor.model; | ||
view = editor.editing.view; | ||
viewDocument = view.document; | ||
} ); | ||
} ); | ||
|
||
afterEach( () => { | ||
editorElement.remove(); | ||
|
||
return editor.destroy(); | ||
} ); | ||
|
||
it( 'should not fire viewDocument#mousedown events after starting resizing', () => { | ||
const eventSpy = sinon.spy().named( 'ViewDocument#mousedown' ); | ||
|
||
setModelData( model, '[<image src="/assets/sample.png"></image>]' ); | ||
|
||
const resizeSquareUI = [ ...viewDocument.getRoot().getChild( 0 ).getChildren() ] | ||
.find( element => element.hasClass( 'ck-widget__resizer' ) ); | ||
|
||
const squareDomElement = view.domConverter.mapViewToDom( resizeSquareUI ).querySelector( '.ck-widget__resizer__handle-top-left' ); | ||
|
||
viewDocument.on( 'mousedown', eventSpy ); | ||
|
||
squareDomElement.dispatchEvent( new Event( 'mousedown' ) ); | ||
|
||
expect( eventSpy.called ).to.equal( false ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters