8
0
Просмотр исходного кода

Merge t/ckeditor5-engine/1208

Other: Aligned code to the changes in the engine.
Piotrek Koszuliński 8 лет назад
Родитель
Сommit
b8f20783be

+ 5 - 4
packages/ckeditor5-clipboard/src/clipboard.js

@@ -88,7 +88,7 @@ import HtmlDataProcessor from '@ckeditor/ckeditor5-engine/src/dataprocessor/html
  *
  * The default action is to:
  *
- * 1. {@link module:engine/controller/datacontroller~DataController#getSelectedContent get selected content} from the editor,
+ * 1. {@link module:engine/model/model~Model#getSelectedContent get selected content} from the editor,
  * 2. prevent the default action of the native `copy` or `cut` event,
  * 3. fire {@link module:engine/view/document~Document#event:clipboardOutput} with a clone of the selected content
  * converted to a {@link module:engine/view/documentfragment~DocumentFragment view document fragment}.
@@ -159,6 +159,7 @@ export default class Clipboard extends Plugin {
 		this.listenTo( this, 'inputTransformation', ( evt, data ) => {
 			if ( !data.content.isEmpty ) {
 				const dataController = this.editor.data;
+				const model = this.editor.model;
 
 				// Convert the pasted content to a model document fragment.
 				// Conversion is contextual, but in this case we need an "all allowed" context and for that
@@ -169,7 +170,7 @@ export default class Clipboard extends Plugin {
 					return;
 				}
 
-				dataController.insertContent( modelFragment, doc.selection );
+				model.insertContent( modelFragment, doc.selection );
 			}
 		}, { priority: 'low' } );
 
@@ -180,7 +181,7 @@ export default class Clipboard extends Plugin {
 
 			data.preventDefault();
 
-			const content = editor.data.toView( editor.data.getSelectedContent( doc.selection ) );
+			const content = editor.data.toView( editor.model.getSelectedContent( doc.selection ) );
 
 			editingView.fire( 'clipboardOutput', { dataTransfer, content, method: evt.name } );
 		}
@@ -203,7 +204,7 @@ export default class Clipboard extends Plugin {
 			}
 
 			if ( data.method == 'cut' ) {
-				editor.data.deleteContent( doc.selection );
+				editor.model.deleteContent( doc.selection );
 			}
 		}, { priority: 'low' } );
 	}

+ 6 - 6
packages/ckeditor5-clipboard/tests/clipboard.js

@@ -168,7 +168,7 @@ describe( 'Clipboard feature', () => {
 
 		it( 'inserts content to the editor', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editingView.fire( 'paste', {
 				dataTransfer: dataTransferMock,
@@ -181,7 +181,7 @@ describe( 'Clipboard feature', () => {
 
 		it( 'does not insert content when editor is read-only', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': '<p>x</p>', 'text/plain': 'y' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editor.isReadOnly = true;
 
@@ -197,7 +197,7 @@ describe( 'Clipboard feature', () => {
 			// Whole content is invalid. Even though there is "view" content, the "model" content would be empty.
 			// Do not insert content in this case.
 			const dataTransferMock = createDataTransfer( { 'text/html': '<unknownTag></unknownTag>', 'text/plain': '' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editingView.fire( 'paste', {
 				dataTransfer: dataTransferMock,
@@ -211,7 +211,7 @@ describe( 'Clipboard feature', () => {
 			// It's enough if we check this here with a text node and paragraph because if the conversion was made
 			// in a normal root, then text or paragraph wouldn't be allowed here.
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x<p>y</p>', 'text/plain': 'z' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editingView.fire( 'paste', {
 				dataTransfer: dataTransferMock,
@@ -224,7 +224,7 @@ describe( 'Clipboard feature', () => {
 
 		it( 'does nothing when pasted content is empty', () => {
 			const dataTransferMock = createDataTransfer( { 'text/plain': '' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editingView.fire( 'clipboardInput', {
 				dataTransfer: dataTransferMock,
@@ -251,7 +251,7 @@ describe( 'Clipboard feature', () => {
 
 		it( 'uses low priority observer for the clipboardInput event', () => {
 			const dataTransferMock = createDataTransfer( { 'text/html': 'x' } );
-			const spy = sinon.stub( editor.data, 'insertContent' );
+			const spy = sinon.stub( editor.model, 'insertContent' );
 
 			editingView.on( 'clipboardInput', evt => {
 				evt.stop();

+ 1 - 1
packages/ckeditor5-clipboard/tests/manual/dropping.js

@@ -35,7 +35,7 @@ ClassicEditor
 
 			editor.model.change( () => {
 				const insertAtSelection = new Selection( [ editor.editing.mapper.toModelRange( data.dropRange ) ] );
-				editor.data.insertContent( new Text( '@' ), insertAtSelection );
+				editor.model.insertContent( new Text( '@' ), insertAtSelection );
 				editor.model.document.selection.setTo( insertAtSelection );
 			} );
 		} );