Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions packages/ckeditor5-list/src/list/converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ export function listItemDowncastConverter(
return;
}

const options = {
...conversionApi.options,
dataPipeline
};

// Use positions mapping instead of mapper.toViewElement( listItem ) to find outermost view element.
// This is for cases when mapping is using inner view element like in the code blocks (pre > code).
const viewElement = findMappedViewElement( listItem, mapper, model )!;
Expand All @@ -360,10 +365,10 @@ export function listItemDowncastConverter(
unwrapListItemBlock( viewElement, writer );

// Insert custom item marker.
const viewRange = insertCustomMarkerElements( listItem, viewElement, strategies, writer, { dataPipeline } );
const viewRange = insertCustomMarkerElements( listItem, viewElement, strategies, writer, options );

// Then wrap them with the new list wrappers (UL, OL, LI).
wrapListItemBlock( listItem, viewRange, strategies, writer, conversionApi.options );
wrapListItemBlock( listItem, viewRange, strategies, writer, options );
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { Plugin } from 'ckeditor5/src/core.js';
import { env } from 'ckeditor5/src/utils.js';

import { ListEditing } from '../list/listediting.js';
import type { ListFormatting } from '../listformatting.js';
Expand Down Expand Up @@ -58,9 +59,14 @@ export class ListItemBoldIntegration extends Plugin {
scope: 'item',
attributeName: 'listItemBold',

setAttributeOnDowncast( writer, value, viewElement ) {
setAttributeOnDowncast( writer, value, viewElement, options ) {
if ( value ) {
writer.addClass( 'ck-list-marker-bold', viewElement );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
if ( env.isSafari && !( options && options.dataPipeline ) ) {
writer.setStyle( '--ck-content-list-marker-dummy-bold', '0', viewElement );
}
}
}
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { Plugin } from 'ckeditor5/src/core.js';
import type { ViewElement } from 'ckeditor5/src/engine.js';
import { env } from 'ckeditor5/src/utils.js';
import { _normalizeFontSizeOptions } from '@ckeditor/ckeditor5-font';

import { ListEditing } from '../list/listediting.js';
Expand Down Expand Up @@ -62,7 +63,7 @@ export class ListItemFontSizeIntegration extends Plugin {
scope: 'item',
attributeName: 'listItemFontSize',

setAttributeOnDowncast( writer, value: string, viewElement ) {
setAttributeOnDowncast( writer, value: string, viewElement, options ) {
if ( value ) {
const fontSizeOption = normalizedFontSizeOptions.find( option => option.model == value );

Expand All @@ -73,6 +74,11 @@ export class ListItemFontSizeIntegration extends Plugin {
}
else if ( fontSizeOption.view.classes ) {
writer.addClass( `ck-list-marker-font-size-${ value }`, viewElement );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
if ( env.isSafari && !( options && options.dataPipeline ) ) {
writer.setStyle( '--ck-content-list-marker-dummy-font-size', '0', viewElement );
}
}
} else {
writer.addClass( 'ck-list-marker-font-size', viewElement );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
*/

import { Plugin } from 'ckeditor5/src/core.js';
import { env } from 'ckeditor5/src/utils.js';

import { ListEditing } from '../list/listediting.js';
import type { ListFormatting } from '../listformatting.js';
Expand Down Expand Up @@ -58,9 +59,14 @@ export class ListItemItalicIntegration extends Plugin {
scope: 'item',
attributeName: 'listItemItalic',

setAttributeOnDowncast( writer, value, viewElement ) {
setAttributeOnDowncast( writer, value, viewElement, options ) {
if ( value ) {
writer.addClass( 'ck-list-marker-italic', viewElement );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
if ( env.isSafari && !( options && options.dataPipeline ) ) {
writer.setStyle( '--ck-content-list-marker-dummy-italic', '0', viewElement );
}
}
}
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard/src/clipboardpi
import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
import { _setModelData, _getModelData, _stringifyModel } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import { _getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view.js';
import { env } from 'ckeditor5/src/utils.js';

import { stubUid } from '../list/_utils/uid.js';
import { ListEditing } from '../../src/list/listediting.js';
Expand Down Expand Up @@ -336,6 +337,35 @@ describe( 'ListItemBoldIntegration', () => {
'</ul>'
);
} );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
it( 'should add dummy style for a Safari glitch (in editing pipeline only)', () => {
sinon.stub( env, 'isSafari' ).value( true );

_setModelData( model,
'<paragraph listIndent="0" listItemId="a" listItemBold="true" listType="bulleted">' +
'<$text bold="true">foo</$text>' +
'</paragraph>'
);

expect( _getViewData( view, { withoutSelection: true } ) ).to.equal(
'<ul>' +
'<li class="ck-list-marker-bold" style="--ck-content-list-marker-dummy-bold:0">' +
'<span class="ck-list-bogus-paragraph">' +
'<strong>foo</strong>' +
'</span>' +
'</li>' +
'</ul>'
);

expect( editor.getData( { skipListItemIds: true } ) ).to.equalMarkup(
'<ul>' +
'<li class="ck-list-marker-bold">' +
'<strong>foo</strong>' +
'</li>' +
'</ul>'
);
} );
} );

describe( 'upcast', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard';
import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
import { _setModelData, _getModelData, _stringifyModel } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import { _getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view.js';
import { env } from 'ckeditor5/src/utils.js';

import { stubUid } from '../list/_utils/uid.js';
import { ListEditing } from '../../src/list/listediting.js';
Expand Down Expand Up @@ -372,6 +373,35 @@ describe( 'ListItemFontSizeIntegration', () => {
'</ul>'
);
} );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
it( 'should add dummy style for a Safari glitch (in editing pipeline only)', () => {
sinon.stub( env, 'isSafari' ).value( true );

_setModelData( model,
'<paragraph listIndent="0" listItemId="a" listItemFontSize="tiny" listType="bulleted">' +
'<$text fontSize="tiny">foo</$text>' +
'</paragraph>'
);

expect( _getViewData( view, { withoutSelection: true } ) ).to.equal(
'<ul>' +
'<li class="ck-list-marker-font-size-tiny" style="--ck-content-list-marker-dummy-font-size:0">' +
'<span class="ck-list-bogus-paragraph">' +
'<span class="text-tiny">foo</span>' +
'</span>' +
'</li>' +
'</ul>'
);

expect( editor.getData( { skipListItemIds: true } ) ).to.equalMarkup(
'<ul>' +
'<li class="ck-list-marker-font-size-tiny">' +
'<span class="text-tiny">foo</span>' +
'</li>' +
'</ul>'
);
} );
} );

describe( 'upcast', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ClipboardPipeline } from '@ckeditor/ckeditor5-clipboard';
import { testUtils } from '@ckeditor/ckeditor5-core/tests/_utils/utils.js';
import { _setModelData, _getModelData, _stringifyModel } from '@ckeditor/ckeditor5-engine/src/dev-utils/model.js';
import { _getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view.js';
import { env } from 'ckeditor5/src/utils.js';

import { stubUid } from '../list/_utils/uid.js';
import { ListEditing } from '../../src/list/listediting.js';
Expand Down Expand Up @@ -336,6 +337,35 @@ describe( 'ListItemItalicIntegration', () => {
'</ul>'
);
} );

// See: https://github.com/ckeditor/ckeditor5/issues/18790.
it( 'should add dummy style for a Safari glitch (in editing pipeline only)', () => {
sinon.stub( env, 'isSafari' ).value( true );

_setModelData( model,
'<paragraph listIndent="0" listItemId="a" listItemItalic="true" listType="bulleted">' +
'<$text italic="true">foo</$text>' +
'</paragraph>'
);

expect( _getViewData( view, { withoutSelection: true } ) ).to.equal(
'<ul>' +
'<li class="ck-list-marker-italic" style="--ck-content-list-marker-dummy-italic:0">' +
'<span class="ck-list-bogus-paragraph">' +
'<i>foo</i>' +
'</span>' +
'</li>' +
'</ul>'
);

expect( editor.getData( { skipListItemIds: true } ) ).to.equalMarkup(
'<ul>' +
'<li class="ck-list-marker-italic">' +
'<i>foo</i>' +
'</li>' +
'</ul>'
);
} );
} );

describe( 'upcast', () => {
Expand Down