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

HTML elements with <font> tag cannot be loaded into CKEditor #8621

Closed
LangQian opened this issue Dec 9, 2020 · 3 comments Β· Fixed by #8975
Closed

HTML elements with <font> tag cannot be loaded into CKEditor #8621

LangQian opened this issue Dec 9, 2020 · 3 comments Β· Fixed by #8975
Assignees
Labels
support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@LangQian
Copy link

LangQian commented Dec 9, 2020

πŸ“ Provide detailed reproduction steps (if any)

  1. Go to https://ckeditor.com/docs/ckeditor5/latest/examples/builds/classic-editor.html
  2. In console paste
    editor.setData('<font color="#ff9900">bbb</font>');
  3. Check the HTML parsed by CK Editor

βœ”οΈ Expected result

The element was kept the same.
OR
The tag was converted to something else, but the color information was kept.

❌ Actual result

Was converted to <p>bbb</p>. And the color was lost.


If you'd like to see this fixed sooner, add a πŸ‘ reaction to this post.

@LangQian LangQian added the type:bug This issue reports a buggy (incorrect) behavior. label Dec 9, 2020
@LangQian
Copy link
Author

LangQian commented Dec 9, 2020

Please note that our product was already released with CK Editor version 22.0.0, so this is an issue our customers are facing and we are trying to fix it urgently. If any fix or temporary workaround can be provided, we would really appreciate it. Thanks!

@mlewand mlewand added the support:2 An issue reported by a commercially licensed client. label Dec 14, 2020
@mlewand
Copy link
Contributor

mlewand commented Dec 14, 2020

Font color doesn't have the conversion for html4-style font color makrup (which is removed in html5). You can get around that with a simple converter:

editor.conversion.for( 'upcast' ).elementToAttribute( {
	view: {
		name: 'font',
		attributes: {
			'color': /.+/
		}
	},
	model: {
		key: 'fontColor',
		value: viewElement => viewElement.getAttribute( 'color' )
	}
} );

You can see how it works here: https://codepen.io/mlewand/pen/PoGWLor?editors=1010

@mlewand mlewand added this to the backlog milestone Dec 14, 2020
@LangQian
Copy link
Author

Hi @mlewand , thanks for your response and workaround. I later found that the issue also exists for 'face', 'size' and 'styles' attributes. How can I extend the above solution to apply on all of them? This is a sample input: <font color="#ff9900" face="arial black" style="font-style:italic;font-weight:bold" size="3">sample</font>.

@Mgsy Mgsy modified the milestones: backlog, iteration 40 Jan 21, 2021
niegowski added a commit that referenced this issue Feb 19, 2021
Feature (font): Add `<font>` styling compatibility. Closes #8621.
@AnnaTomanek AnnaTomanek changed the title HTML elements with <font> tag cannot be loaded into CK Editor HTML elements with <font> tag cannot be loaded into CKEditor Mar 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support:2 An issue reported by a commercially licensed client. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants