Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Feature: basicStyles.useEmTag option to use em instead of i tag #78

Closed
wants to merge 2 commits into from
Closed

Conversation

tuomassalo
Copy link

This PR adds the option to make the Italic command produce <em> tags instead of <i> tags.

I apologize for not having the time to write tests. I presume it to be quite straightforward.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.7%) to 99.275% when pulling 53dbaf6 on AvoineOy:master into e4b8417 on ckeditor:master.

@Reinmar Reinmar self-requested a review September 28, 2018 11:15
@Reinmar
Copy link
Member

Reinmar commented Sep 28, 2018

Hi! Thanks for the PR, but there's no need for a new option here. You can change how italic is rendered by adding a higher priority converter:

import {
	downcastAttributeToElement
} from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';

// ...

editor.conversion.for( 'downcast' ).add( downcastAttributeToElement( {
	model: 'italic',
	view: 'em',
	converterPriority: 'high'
} ) );

A configuration option would be, of course, easier to use, but we avoid adding those because it's a neverending story of adding just one more and hence bloating and complicating the code (happened in CKEditor 4).

Thanks once again for the PR.

@Reinmar Reinmar closed this Sep 28, 2018
@tuomassalo
Copy link
Author

I'm writing this down just in case someone finds this page. Downcasting must be done early enough, e.g. in a plugin init. Here's a plugin that does the trick.

import { downcastAttributeToElement } from '@ckeditor/ckeditor5-engine/src/conversion/downcast-converters';
import Plugin from '@ckeditor/ckeditor5-core/src/plugin';

class EmTagItalicPlugin extends Plugin {
  init() {
    // emit `em` tags instead of `i` tags
    this.editor.conversion.for( 'downcast' ).add( downcastAttributeToElement( {
      model: 'italic',
      view: 'em',
      converterPriority: 'high'
    } ) );
  }
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants