-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change Italic command to operate semantically, Bold command uses "str…
…ong" tag
- Loading branch information
Showing
4 changed files
with
55 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,25 @@ | ||
import TextFormatCommand from './text-format'; | ||
import { inherit } from 'content-kit-utils'; | ||
import Markup from '../models/markup'; | ||
import { | ||
any | ||
} from '../utils/array-utils'; | ||
|
||
function ItalicCommand() { | ||
TextFormatCommand.call(this, { | ||
name: 'italic', | ||
tag: 'em', | ||
mappedTags: ['i'], | ||
button: '<i class="ck-icon-italic"></i>' | ||
}); | ||
export default class ItalicCommand extends TextFormatCommand { | ||
constructor(editor) { | ||
super({ | ||
name: 'italic', | ||
button: '<i class="ck-icon-italic"></i>' | ||
}); | ||
this.editor = editor; | ||
this.markup = Markup.create('em'); | ||
} | ||
exec() { | ||
this.editor.applyMarkupToSelection(this.markup); | ||
} | ||
unexec() { | ||
this.editor.removeMarkupFromSelection(this.markup); | ||
} | ||
isActive() { | ||
return any(this.editor.activeMarkers, m => m.hasMarkup(this.markup)); | ||
} | ||
} | ||
inherit(ItalicCommand, TextFormatCommand); | ||
|
||
export default ItalicCommand; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters