-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
153 additions
and
212 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,10 @@ | ||
import TextFormatCommand from './text-format'; | ||
import { | ||
any | ||
} from '../utils/array-utils'; | ||
|
||
export default class BoldCommand extends TextFormatCommand { | ||
constructor(editor) { | ||
super({ | ||
super(editor, { | ||
tag: 'strong', | ||
name: 'bold', | ||
button: '<i class="ck-icon-bold"></i>' | ||
}); | ||
this.editor = editor; | ||
const { builder } = this.editor; | ||
this.markup = builder.createMarkup('strong'); | ||
} | ||
|
||
isActive() { | ||
return any(this.editor.activeMarkers, m => m.hasMarkup(this.markup)); | ||
} | ||
|
||
exec() { | ||
const range = this.editor.cursor.offsets; | ||
|
||
const markers = this.editor.run((postEditor) => { | ||
return postEditor.applyMarkupToMarkers(range, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
|
||
unexec() { | ||
const range = this.editor.cursor.offsets; | ||
const markers = this.editor.run((postEditor) => { | ||
return postEditor.removeMarkupFromMarkers(range, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
} |
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,36 +1,11 @@ | ||
import TextFormatCommand from './text-format'; | ||
import { | ||
any | ||
} from '../utils/array-utils'; | ||
|
||
export default class ItalicCommand extends TextFormatCommand { | ||
constructor(editor) { | ||
super({ | ||
super(editor, { | ||
tag: 'em', | ||
name: 'italic', | ||
button: '<i class="ck-icon-italic"></i>' | ||
}); | ||
this.editor = editor; | ||
const { builder } = this.editor; | ||
this.markup = builder.createMarkup('em'); | ||
} | ||
exec() { | ||
let markerRange = this.editor.cursor.offsets; | ||
if (!markerRange.headSection || !markerRange.tailSection) { | ||
return; | ||
} | ||
let markers = this.editor.run((postEditor) => { | ||
return postEditor.applyMarkupToMarkers(markerRange, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
unexec() { | ||
let markerRange = this.editor.cursor.offsets; | ||
let markers = this.editor.run((postEditor) => { | ||
return postEditor.removeMarkupFromMarkers(markerRange, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
isActive() { | ||
return any(this.editor.activeMarkers, m => m.hasMarkup(this.markup)); | ||
} | ||
} |
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
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,16 +1,37 @@ | ||
import Command from './base'; | ||
import { any } from '../utils/array-utils'; | ||
|
||
export default class TextFormatCommand extends Command { | ||
constructor(options={}) { | ||
constructor(editor, options={}) { | ||
super(options); | ||
this.editor = editor; | ||
this.tag = options.tag; | ||
} | ||
|
||
get markup() { | ||
if (this._markup) { return this._markup; } | ||
const { builder } = this.editor; | ||
this._markup = builder.createMarkup(this.tag); | ||
return this._markup; | ||
} | ||
|
||
isActive() { | ||
return any(this.editor.activeMarkers, m => m.hasMarkup(this.markup)); | ||
} | ||
|
||
exec() { | ||
throw new Error('Must implement exec in sub class'); | ||
const range = this.editor.cursor.offsets; | ||
const markers = this.editor.run((postEditor) => { | ||
return postEditor.applyMarkupToMarkers(range, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
|
||
unexec() { | ||
throw new Error('Must implement unexec in sub class'); | ||
const range = this.editor.cursor.offsets; | ||
const markers = this.editor.run((postEditor) => { | ||
return postEditor.removeMarkupFromMarkers(range, this.markup); | ||
}); | ||
this.editor.selectMarkers(markers); | ||
} | ||
} |
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
Oops, something went wrong.