Skip to content

Commit

Permalink
use css variable for preview background
Browse files Browse the repository at this point in the history
  • Loading branch information
illia-stv authored and arkflpc committed Oct 4, 2023
1 parent e450fea commit c462115
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ckeditor5-clipboard/src/dragdrop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ export default class DragDrop extends Plugin {
* Check: https://github.com/ckeditor/ckeditor5/issues/15085
*/
if ( env.isiOS ) {
preview.style.backgroundColor = 'white';
preview.style.backgroundColor = computedStyle.getPropertyValue( '--ck-color-base-background' );
}

preview.innerHTML = dataTransfer.getData( 'text/html' );
Expand Down
34 changes: 33 additions & 1 deletion packages/ckeditor5-clipboard/tests/dragdropblocktoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,39 @@ describe( 'Drag and Drop Block Toolbar', () => {

sinon.assert.calledWith( spy, sinon.match( {
style: {
backgroundColor: 'white'
backgroundColor: 'rgb(255, 255, 255)'
},
className: 'ck ck-content',
firstChild: sinon.match( {
tagName: 'P',
innerHTML: 'foobar'
} )
} ), 0, 0 );

env.isiOS = originalEnviOs;
} );

it( 'should show preview without white background if not iOS', () => {
const originalEnviOs = env.isiOS;

env.isiOS = false;

setModelData( model, '<paragraph>[foo]bar</paragraph>' );

const dataTransfer = new DataTransfer();
const spy = sinon.spy( dataTransfer, 'setDragImage' );

const dragStartEvent = new DragEvent( 'dragstart', {
dataTransfer
} );

blockToolbarButton.dispatchEvent( dragStartEvent );

sinon.assert.calledOnce( spy );

sinon.assert.calledWith( spy, sinon.match( {
style: {
backgroundColor: ''
},
className: 'ck ck-content',
firstChild: sinon.match( {
Expand Down

0 comments on commit c462115

Please sign in to comment.