8
0

imageediting.js 20 KB

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