Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font feature should use lower priorities for their elements #2291

Closed
Reinmar opened this issue Apr 3, 2019 · 4 comments · Fixed by ckeditor/ckeditor5-font#44
Closed

Font feature should use lower priorities for their elements #2291

Reinmar opened this issue Apr 3, 2019 · 4 comments · Fixed by ckeditor/ckeditor5-font#44
Assignees
Labels
package:font status:discussion type:improvement This issue reports a possible enhancement of an existing feature.
Milestone

Comments

@Reinmar
Copy link
Member

Reinmar commented Apr 3, 2019

The common conflict is underline + font color. Underline must be used inside font color because otherwise, the underline will not match the font color:

image

Right now it works in the editor just fine:

image

<u> is rendered inside <span color>. But this is just a coincident because u is sorted alphabetically after span.

We should set font color's priority to a value between 6-9 (higher than link, lower than normal styles)... 7? :D

I'm not sure about background color. I think it should have the same priority so both spans are nicely merged (<span style=color:xxx; background-color: xxx>). The remaining question is – do we change the priority for font-size and font-family?

I guess we must do that because of this:

image

@Reinmar
Copy link
Member Author

Reinmar commented Apr 3, 2019

cc @oleq

@Reinmar
Copy link
Member Author

Reinmar commented Apr 3, 2019

Actually, FontSizeEditing and FontFamilyEditing use priority 5 already. Which, I think, is wrong, because it should not collide with links. Links should be always outside all other elements.

@oleq
Copy link
Member

oleq commented Apr 3, 2019

Checked and it looks like in the screenshot below.

<u> is rendered inside <span color>. But this is just a coincident because u is sorted alphabetically after span.

If that's true, let's have fixed priorities for both.

Actually, FontSizeEditing and FontFamilyEditing use priority 5 already. Which, I think, is wrong, because it should not collide with links. Links should be always outside all other elements.

It looks like it's OK now but maybe I'm missing something?

image

<div id="editor">
	<p>
		<u>
			<span style="color:white;background-color:red;">
				underline
			</span>
		</u>
		<a href="ckeditor.com">
			<span style="color:white;background-color:red;">
				a link
			</span>
		</a>
		<span style="color:white;background-color:red;font-family: 'Courier New', Courier, monospace;">
			font family
		</span>
		<span style="color:white;background-color:red;font-size: 32px;">
			font size
		</span>
		<span style="color:white;background-color:red;font-family: 'Courier New', Courier, monospace;font-size: 32px;">
			font family and size
		</span>
		<a href="ckeditor.com">
			<span style="color:white;background-color:red;font-family: 'Courier New', Courier, monospace;font-size: 32px;">
					font family, size in link
			</span>
		</a>
	</p>
</div>
/**
 * @license Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved.
 * For licensing, see LICENSE.md.
 */

/* globals console, window, document */

import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';
import ArticlePluginSet from '@ckeditor/ckeditor5-core/tests/_utils/articlepluginset';
import Underline from '@ckeditor/ckeditor5-basic-styles/src/underline';
import FontColor from '../../src/fontcolor';
import FontBackgroundColor from '../../src/fontbackgroundcolor';
import FontSize from '../../src/fontsize';
import FontFamily from '../../src/fontfamily';

ClassicEditor
	.create( document.querySelector( '#editor' ), {
		plugins: [
			ArticlePluginSet,
			Underline,
			FontColor,
			FontFamily,
			FontSize,
			FontBackgroundColor
		],
		toolbar: [
			'heading',
			'|',
			'fontColor',
			'fontBackgroundColor',
			'bold',
			'italic',
			'link',
			'bulletedList',
			'numberedList',
			'blockQuote',
			'undo',
			'redo'
		],
		fontSize: { options: [ 10, 12, 14, 'default', 18, 20, 22, 32 ] }
	} )
	.then( editor => {
		window.editor = editor;
	} )
	.catch( err => {
		console.error( err.stack );
	} );

@jodator
Copy link
Contributor

jodator commented Apr 4, 2019

We should have some manual / automatic test for all attributes elements priorities. There are handful of them and I'm worried that we might loose track of all of them.

Custom priorities are used by:

  • font color: 5
  • font family: 5
  • font size: 5
  • link: 5
  • bold, itellic, underline, etc default: 10
  • mention: 20

Reinmar referenced this issue in ckeditor/ckeditor5-font Jun 26, 2019
Other: Updated view attribute elements priorities to ensure proper order in which attribute elements are applied. Closes #35.
@mlewand mlewand transferred this issue from ckeditor/ckeditor5-font Oct 8, 2019
@mlewand mlewand added status:discussion type:improvement This issue reports a possible enhancement of an existing feature. package:font labels Oct 8, 2019
@mlewand mlewand added this to the iteration 25 milestone Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:font status:discussion type:improvement This issue reports a possible enhancement of an existing feature.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants