diff --git a/src/controller/insertcontent.js b/src/controller/insertcontent.js index 5a4faace9..69cd9f0f2 100644 --- a/src/controller/insertcontent.js +++ b/src/controller/insertcontent.js @@ -135,7 +135,7 @@ class Insertion { nodes = Array.from( nodes ); for ( let i = 0; i < nodes.length; i++ ) { - const node = nodes[ i ].clone(); + const node = nodes[ i ]; this._handleNode( node, { isFirst: i === 0 && parentContext.isFirst, diff --git a/tests/controller/insertcontent.js b/tests/controller/insertcontent.js index d86bca1d3..a29f925d1 100644 --- a/tests/controller/insertcontent.js +++ b/tests/controller/insertcontent.js @@ -9,6 +9,7 @@ import insertContent from '../../src/controller/insertcontent'; import DocumentFragment from '../../src/model/documentfragment'; import Text from '../../src/model/text'; +import Element from '../../src/model/element'; import { setData, getData, parse } from '../../src/dev-utils/model'; @@ -62,6 +63,25 @@ describe( 'DataController', () => { expect( getData( doc ) ).to.equal( 'xa[]x' ); } ); + it( 'should save the reference to the original object', () => { + const doc = new Document(); + const dataController = new DataController( doc ); + const batch = doc.batch(); + const content = new Element( 'image' ); + + doc.createRoot(); + + doc.schema.registerItem( 'paragraph', '$block' ); + doc.schema.registerItem( 'image', '$inline' ); + doc.schema.objects.add( 'image' ); + + setData( doc, 'foo[]' ); + + insertContent( dataController, content, doc.selection, batch ); + + expect( doc.getRoot().getChild( 0 ).getChild( 1 ) ).to.equal( content ); + } ); + describe( 'in simple scenarios', () => { beforeEach( () => { doc = new Document();