8
0

imageengine.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585
  1. /**
  2. * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. import VirtualTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/virtualtesteditor';
  6. import ImageEngine from '../../src/image/imageengine';
  7. import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
  8. import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
  9. import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
  10. import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter';
  11. import { isImageWidget } from '../../src/image/utils';
  12. import normalizeHtml from '@ckeditor/ckeditor5-utils/tests/_utils/normalizehtml';
  13. describe( 'ImageEngine', () => {
  14. let editor, model, document, viewDocument;
  15. beforeEach( () => {
  16. return VirtualTestEditor
  17. .create( {
  18. plugins: [ ImageEngine ]
  19. } )
  20. .then( newEditor => {
  21. editor = newEditor;
  22. model = editor.model;
  23. document = model.document;
  24. viewDocument = editor.editing.view;
  25. } );
  26. } );
  27. it( 'should be loaded', () => {
  28. expect( editor.plugins.get( ImageEngine ) ).to.be.instanceOf( ImageEngine );
  29. } );
  30. it( 'should set proper schema rules', () => {
  31. expect( model.schema.checkChild( [ '$root' ], 'image' ) ).to.be.true;
  32. expect( model.schema.checkAttribute( [ '$root', 'image' ], 'src' ) ).to.be.true;
  33. expect( model.schema.checkAttribute( [ '$root', 'image' ], 'alt' ) ).to.be.true;
  34. expect( model.schema.isObject( 'image' ) ).to.be.true;
  35. expect( model.schema.checkChild( [ '$root', 'image' ], 'image' ) ).to.be.false;
  36. expect( model.schema.checkChild( [ '$root', 'image' ], '$text' ) ).to.be.false;
  37. expect( model.schema.checkChild( [ '$root', '$block' ], 'image' ) ).to.be.false;
  38. } );
  39. describe( 'conversion in data pipeline', () => {
  40. describe( 'model to view', () => {
  41. it( 'should convert', () => {
  42. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  43. expect( editor.getData() ).to.equal( '<figure class="image"><img alt="alt text" src="foo.png"></figure>' );
  44. } );
  45. it( 'should convert without alt attribute', () => {
  46. setModelData( model, '<image src="foo.png"></image>' );
  47. expect( editor.getData() ).to.equal( '<figure class="image"><img src="foo.png"></figure>' );
  48. } );
  49. it( 'should convert srcset attribute to srcset and sizes attribute', () => {
  50. setModelData( model,
  51. '<image src="foo.png" alt="alt text" srcset=\'{ "data": "small.png 148w, big.png 1024w" }\'></image>'
  52. );
  53. expect( normalizeHtml( editor.getData() ) ).to.equal(
  54. '<figure class="image">' +
  55. '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small.png 148w, big.png 1024w"></img>' +
  56. '</figure>'
  57. );
  58. } );
  59. it( 'should convert srcset attribute to width, srcset and add sizes attribute', () => {
  60. setModelData( model,
  61. '<image ' +
  62. 'src="foo.png" ' +
  63. 'alt="alt text" ' +
  64. 'srcset=\'{ "data": "small.png 148w, big.png 1024w", "width": "1024" }\'>' +
  65. '</image>'
  66. );
  67. expect( normalizeHtml( editor.getData() ) ).to.equal(
  68. '<figure class="image">' +
  69. '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small.png 148w, big.png 1024w" width="1024"></img>' +
  70. '</figure>'
  71. );
  72. } );
  73. it( 'should not convert srcset attribute if is already consumed', () => {
  74. editor.data.modelToView.on( 'attribute:srcset:image', ( evt, data, consumable ) => {
  75. const parts = evt.name.split( ':' );
  76. const consumableType = parts[ 0 ] + ':' + parts[ 1 ];
  77. const modelImage = data.item;
  78. consumable.consume( modelImage, consumableType );
  79. }, { priority: 'high' } );
  80. setModelData( model,
  81. '<image ' +
  82. 'src="foo.png" ' +
  83. 'alt="alt text" ' +
  84. 'srcset=\'{ "data": "small.png 148w, big.png 1024w", "width": "1024" }\'>' +
  85. '</image>'
  86. );
  87. expect( editor.getData() ).to.equal(
  88. '<figure class="image">' +
  89. '<img alt="alt text" src="foo.png">' +
  90. '</figure>'
  91. );
  92. } );
  93. it( 'should not convert srcset attribute if has wrong data', () => {
  94. setModelData( model,
  95. '<image ' +
  96. 'src="foo.png" ' +
  97. 'alt="alt text" ' +
  98. 'srcset=\'{ "foo":"bar" }\'>' +
  99. '</image>' );
  100. const image = document.getRoot().getChild( 0 );
  101. model.change( writer => {
  102. writer.removeAttribute( 'srcset', image );
  103. } );
  104. expect( editor.getData() ).to.equal(
  105. '<figure class="image">' +
  106. '<img alt="alt text" src="foo.png">' +
  107. '</figure>'
  108. );
  109. } );
  110. } );
  111. describe( 'view to model', () => {
  112. it( 'should convert image figure', () => {
  113. editor.setData( '<figure class="image"><img src="foo.png" alt="alt text" /></figure>' );
  114. expect( getModelData( model, { withoutSelection: true } ) )
  115. .to.equal( '<image alt="alt text" src="foo.png"></image>' );
  116. } );
  117. it( 'should not convert if there is no image class', () => {
  118. editor.setData( '<figure class="quote">My quote</figure>' );
  119. expect( getModelData( model, { withoutSelection: true } ) )
  120. .to.equal( '' );
  121. } );
  122. it( 'should not convert if there is no img inside #1', () => {
  123. editor.setData( '<figure class="image"></figure>' );
  124. expect( getModelData( model, { withoutSelection: true } ) )
  125. .to.equal( '' );
  126. } );
  127. it( 'should not convert if there is no img inside #2', () => {
  128. editor.setData( '<figure class="image">test</figure>' );
  129. expect( getModelData( model, { withoutSelection: true } ) )
  130. .to.equal( '' );
  131. } );
  132. it( 'should convert without alt attribute', () => {
  133. editor.setData( '<figure class="image"><img src="foo.png" /></figure>' );
  134. expect( getModelData( model, { withoutSelection: true } ) )
  135. .to.equal( '<image src="foo.png"></image>' );
  136. } );
  137. it( 'should not convert without src attribute', () => {
  138. editor.setData( '<figure class="image"><img alt="alt text" /></figure>' );
  139. expect( getModelData( model, { withoutSelection: true } ) )
  140. .to.equal( '' );
  141. } );
  142. it( 'should not convert in wrong context', () => {
  143. const data = editor.data;
  144. const editing = editor.editing;
  145. model.schema.register( 'div', { inheritAllFrom: '$block' } );
  146. model.schema.on( 'checkChild', ( evt, args ) => {
  147. const def = model.schema.getDefinition( args[ 1 ] );
  148. if ( args[ 0 ].endsWith( '$root' ) && def.name == 'image' ) {
  149. evt.stop();
  150. evt.return = false;
  151. }
  152. }, { priority: 'high' } );
  153. buildModelConverter().for( data.modelToView, editing.modelToView ).fromElement( 'div' ).toElement( 'div' );
  154. buildViewConverter().for( data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
  155. editor.setData( '<div><figure class="image"><img src="foo.png" alt="alt text" /></figure></div>' );
  156. expect( getModelData( model, { withoutSelection: true } ) )
  157. .to.equal( '<div></div>' );
  158. } );
  159. it( 'should not convert if img is already consumed', () => {
  160. editor.data.viewToModel.on( 'element:figure', ( evt, data, consumable ) => {
  161. const img = data.input.getChild( 0 );
  162. consumable.consume( img, { name: true } );
  163. }, { priority: 'high' } );
  164. editor.setData( '<figure class="image"><img src="foo.png" alt="alt text" /></figure>' );
  165. expect( getModelData( model, { withoutSelection: true } ) )
  166. .to.equal( '' );
  167. } );
  168. it( 'should not convert if figure is already consumed', () => {
  169. editor.data.viewToModel.on( 'element:figure', ( evt, data, consumable ) => {
  170. const figure = data.input;
  171. consumable.consume( figure, { name: true, class: 'image' } );
  172. }, { priority: 'high' } );
  173. editor.setData( '<figure class="image"><img src="foo.png" alt="alt text" /></figure>' );
  174. expect( getModelData( model, { withoutSelection: true } ) )
  175. .to.equal( '' );
  176. } );
  177. it( 'should dispatch conversion for nested elements', () => {
  178. const conversionSpy = sinon.spy();
  179. editor.data.viewToModel.on( 'element:figcaption', conversionSpy );
  180. editor.setData( '<figure class="image"><img src="foo.png" alt="alt text" /><figcaption></figcaption></figure>' );
  181. sinon.assert.calledOnce( conversionSpy );
  182. } );
  183. it( 'should convert bare img element', () => {
  184. editor.setData( '<img src="foo.png" alt="alt text" />' );
  185. expect( getModelData( model, { withoutSelection: true } ) )
  186. .to.equal( '<image alt="alt text" src="foo.png"></image>' );
  187. } );
  188. it( 'should not convert alt attribute on non-img element', () => {
  189. const data = editor.data;
  190. const editing = editor.editing;
  191. model.schema.register( 'div', {
  192. inheritAllFrom: '$block',
  193. allowAttributes: 'alt'
  194. } );
  195. buildModelConverter().for( data.modelToView, editing.modelToView ).fromElement( 'div' ).toElement( 'div' );
  196. buildViewConverter().for( data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
  197. editor.setData( '<div alt="foo"></div>' );
  198. expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<div></div>' );
  199. } );
  200. it( 'should handle figure with two images', () => {
  201. model.schema.extend( '$text', { allowIn: 'image' } );
  202. editor.setData( '<figure class="image"><img src="foo.jpg" /><img src="bar.jpg" />abc</figure>' );
  203. // The foo.jpg image is properly converted using figure converter. The other image was tried to
  204. // be added as a child of foo.jpg and then was autohoisted.
  205. expect( getModelData( model, { withoutSelection: true } ) )
  206. .to.equal( '<image src="bar.jpg"></image><image src="foo.jpg">abc</image>' );
  207. } );
  208. it( 'should convert image with srcset attribute', () => {
  209. editor.setData(
  210. '<figure class="image">' +
  211. '<img src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w" />' +
  212. '</figure>'
  213. );
  214. expect( getModelData( model, { withoutSelection: true } ) )
  215. .to.equal( '<image alt="alt text" src="foo.png" srcset="{"data":"small.png 148w, big.png 1024w"}"></image>' );
  216. } );
  217. it( 'should convert image with srcset and width attributes', () => {
  218. editor.setData(
  219. '<figure class="image">' +
  220. '<img src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w" width="1024" />' +
  221. '</figure>'
  222. );
  223. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  224. '<image alt="alt text" src="foo.png" srcset="{"data":"small.png 148w, big.png 1024w","width":"1024"}"></image>' );
  225. } );
  226. it( 'should ignore sizes attribute', () => {
  227. editor.setData(
  228. '<figure class="image">' +
  229. '<img src="foo.png" alt="alt text" srcset="small.png 148w, big.png 1024w" sizes="50vw" />' +
  230. '</figure>'
  231. );
  232. expect( getModelData( model, { withoutSelection: true } ) )
  233. .to.equal( '<image alt="alt text" src="foo.png" srcset="{"data":"small.png 148w, big.png 1024w"}"></image>' );
  234. } );
  235. describe( 'should autohoist images', () => {
  236. beforeEach( () => {
  237. model.schema.register( 'div', { inheritAllFrom: '$block' } );
  238. buildModelConverter()
  239. .for( editor.data.modelToView, editor.editing.modelToView )
  240. .fromElement( 'div' )
  241. .toElement( 'div' );
  242. buildViewConverter()
  243. .for( editor.data.viewToModel )
  244. .fromElement( 'div' )
  245. .toElement( 'div' );
  246. } );
  247. it( 'image between non-hoisted elements', () => {
  248. editor.setData( '<div>foo<img src="foo.jpg" alt="foo" />bar</div>' );
  249. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  250. '<div>foo</div>' +
  251. '<image alt="foo" src="foo.jpg"></image>' +
  252. '<div>bar</div>'
  253. );
  254. } );
  255. it( 'multiple images', () => {
  256. editor.setData( '<div>foo<img src="foo.jpg" alt="foo" />ba<img src="foo.jpg" alt="foo" />r</div>' );
  257. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  258. '<div>foo</div>' +
  259. '<image alt="foo" src="foo.jpg"></image>' +
  260. '<div>ba</div>' +
  261. '<image alt="foo" src="foo.jpg"></image>' +
  262. '<div>r</div>'
  263. );
  264. } );
  265. it( 'images on borders of parent', () => {
  266. editor.setData( '<div><img src="foo.jpg" alt="foo" />foobar<img src="foo.jpg" alt="foo" /></div>' );
  267. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  268. '<image alt="foo" src="foo.jpg"></image>' +
  269. '<div>foobar</div>' +
  270. '<image alt="foo" src="foo.jpg"></image>'
  271. );
  272. } );
  273. it( 'images are only content of parent', () => {
  274. editor.setData( '<div><img src="foo.jpg" alt="foo" /><img src="foo.jpg" alt="foo" /></div>' );
  275. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  276. '<image alt="foo" src="foo.jpg"></image>' +
  277. '<image alt="foo" src="foo.jpg"></image>'
  278. );
  279. } );
  280. it( 'deep autohoisting #1', () => {
  281. model.schema.extend( 'div', { allowIn: 'div' } );
  282. editor.setData( '<div>foo<div>xx<img src="foo.jpg" alt="foo" /></div>bar</div>' );
  283. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  284. '<div>' +
  285. 'foo' +
  286. '<div>' +
  287. 'xx' +
  288. '</div>' +
  289. '</div>' +
  290. '<image alt="foo" src="foo.jpg"></image>' +
  291. '<div>bar</div>'
  292. );
  293. } );
  294. it( 'deep autohoisting #2', () => {
  295. model.schema.extend( 'div', { allowIn: 'div' } );
  296. editor.setData(
  297. '<div>x</div>' +
  298. '<div><div><div><img src="foo.jpg" alt="foo" /></div></div></div>' +
  299. '<div>y</div>'
  300. );
  301. expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
  302. '<div>x</div><image alt="foo" src="foo.jpg"></image><div>y</div>'
  303. );
  304. } );
  305. it( 'should not break a limiting element', () => {
  306. model.schema.register( 'limit', {
  307. inheritAllFrom: '$block',
  308. isLimit: true
  309. } );
  310. model.schema.extend( 'div', { allowIn: 'limit' } );
  311. buildModelConverter()
  312. .for( editor.data.modelToView, editor.editing.modelToView ).fromElement( 'limit' ).toElement( 'limit' );
  313. buildViewConverter().for( editor.data.viewToModel ).fromElement( 'limit' ).toElement( 'limit' );
  314. editor.setData( '<limit><div>foo<img src="foo.jpg" alt="foo" />bar</div></limit>' );
  315. // <limit> element does not have converters so it is not converted.
  316. expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<limit><div>foobar</div></limit>' );
  317. } );
  318. it( 'should not convert and autohoist image element without src attribute (which is not allowed by schema)', () => {
  319. editor.setData( '<div>foo<img alt="foo" />bar</div>' );
  320. expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<div>foobar</div>' );
  321. } );
  322. } );
  323. } );
  324. } );
  325. describe( 'conversion in editing pipeline', () => {
  326. describe( 'model to view', () => {
  327. it( 'should convert', () => {
  328. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  329. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  330. '<figure class="ck-widget image" contenteditable="false"><img alt="alt text" src="foo.png"></img></figure>'
  331. );
  332. } );
  333. it( 'converted element should be widgetized', () => {
  334. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  335. const figure = viewDocument.getRoot().getChild( 0 );
  336. expect( figure.name ).to.equal( 'figure' );
  337. expect( isImageWidget( figure ) ).to.be.true;
  338. } );
  339. it( 'should convert attribute change', () => {
  340. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  341. const image = document.getRoot().getChild( 0 );
  342. model.change( writer => {
  343. writer.setAttribute( 'alt', 'new text', image );
  344. } );
  345. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  346. '<figure class="ck-widget image" contenteditable="false"><img alt="new text" src="foo.png"></img></figure>'
  347. );
  348. } );
  349. it( 'should convert attribute removal', () => {
  350. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  351. const image = document.getRoot().getChild( 0 );
  352. model.change( writer => {
  353. writer.removeAttribute( 'alt', image );
  354. } );
  355. expect( getViewData( viewDocument, { withoutSelection: true } ) )
  356. .to.equal( '<figure class="ck-widget image" contenteditable="false"><img src="foo.png"></img></figure>' );
  357. } );
  358. it( 'should not convert change if is already consumed', () => {
  359. setModelData( model, '<image src="foo.png" alt="alt text"></image>' );
  360. const image = document.getRoot().getChild( 0 );
  361. editor.editing.modelToView.on( 'attribute:alt:image', ( evt, data, consumable ) => {
  362. consumable.consume( data.item, 'attribute:alt' );
  363. }, { priority: 'high' } );
  364. model.change( writer => {
  365. writer.removeAttribute( 'alt', image );
  366. } );
  367. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  368. '<figure class="ck-widget image" contenteditable="false"><img alt="alt text" src="foo.png"></img></figure>'
  369. );
  370. } );
  371. it( 'should convert srcset attribute to srcset and sizes', () => {
  372. setModelData( model,
  373. '<image ' +
  374. 'src="foo.png" ' +
  375. 'alt="alt text" ' +
  376. 'srcset=\'{ "data":"small.png 148w, big.png 1024w" }\'>' +
  377. '</image>' );
  378. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  379. '<figure class="ck-widget image" contenteditable="false">' +
  380. '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small.png 148w, big.png 1024w"></img>' +
  381. '</figure>'
  382. );
  383. } );
  384. it( 'should not convert srcset attribute if has wrong data', () => {
  385. setModelData( model,
  386. '<image ' +
  387. 'src="foo.png" ' +
  388. 'alt="alt text" ' +
  389. 'srcset=\'{ "foo":"bar" }\'>' +
  390. '</image>' );
  391. const image = document.getRoot().getChild( 0 );
  392. model.change( writer => {
  393. writer.removeAttribute( 'srcset', image );
  394. } );
  395. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  396. '<figure class="ck-widget image" contenteditable="false">' +
  397. '<img alt="alt text" src="foo.png"></img>' +
  398. '</figure>'
  399. );
  400. } );
  401. it( 'should convert srcset attribute to srcset, width and sizes', () => {
  402. setModelData( model,
  403. '<image ' +
  404. 'src="foo.png" ' +
  405. 'alt="alt text" ' +
  406. 'srcset=\'{ "data":"small.png 148w, big.png 1024w", "width":"1024" }\'>' +
  407. '</image>' );
  408. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  409. '<figure class="ck-widget image" contenteditable="false">' +
  410. '<img alt="alt text" sizes="100vw" src="foo.png" srcset="small.png 148w, big.png 1024w" width="1024"></img>' +
  411. '</figure>'
  412. );
  413. } );
  414. it( 'should remove sizes and srcsset attribute when srcset attribute is removed from model', () => {
  415. setModelData( model, '<image src="foo.png" srcset=\'{ "data": "small.png 148w, big.png 1024w" }\'></image>' );
  416. const image = document.getRoot().getChild( 0 );
  417. model.change( writer => {
  418. writer.removeAttribute( 'srcset', image );
  419. } );
  420. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  421. '<figure class="ck-widget image" contenteditable="false">' +
  422. '<img src="foo.png"></img>' +
  423. '</figure>'
  424. );
  425. } );
  426. it( 'should remove width, sizes and srcsset attribute when srcset attribute is removed from model', () => {
  427. setModelData( model,
  428. '<image ' +
  429. 'src="foo.png" ' +
  430. 'srcset=\'{ "data": "small.png 148w, big.png 1024w", "width": "1024" }\'>' +
  431. '</image>'
  432. );
  433. const image = document.getRoot().getChild( 0 );
  434. model.change( writer => {
  435. writer.removeAttribute( 'srcset', image );
  436. } );
  437. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  438. '<figure class="ck-widget image" contenteditable="false">' +
  439. '<img src="foo.png"></img>' +
  440. '</figure>'
  441. );
  442. } );
  443. it( 'should not convert srcset attribute if is already consumed', () => {
  444. editor.editing.modelToView.on( 'attribute:srcset:image', ( evt, data, consumable ) => {
  445. const parts = evt.name.split( ':' );
  446. const consumableType = parts[ 0 ] + ':' + parts[ 1 ];
  447. const modelImage = data.item;
  448. consumable.consume( modelImage, consumableType );
  449. }, { priority: 'high' } );
  450. setModelData( model,
  451. '<image ' +
  452. 'src="foo.png" ' +
  453. 'alt="alt text" ' +
  454. 'srcset=\'{ "data": "small.png 148w, big.png 1024w", "width": "1024" }\'>' +
  455. '</image>'
  456. );
  457. expect( getViewData( viewDocument, { withoutSelection: true } ) ).to.equal(
  458. '<figure class="ck-widget image" contenteditable="false">' +
  459. '<img alt="alt text" src="foo.png"></img>' +
  460. '</figure>'
  461. );
  462. } );
  463. } );
  464. } );
  465. } );