Skip to content

Commit

Permalink
SHP Issue #24. Only apply alternate indent/outdent if available
Browse files Browse the repository at this point in the history
Also adjusted the state of the commands to accomodate being outside of a
header
  • Loading branch information
BDeveau committed Jan 26, 2017
1 parent 5aa7cc6 commit bdfc534
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions structuredheadings/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,12 +352,12 @@

//eslint-disable-next-line new-cap
var style = new CKEDITOR.style({ element: nextElement});
if(editor.config.numberedElements.indexOf(element.getName()) >= 0) {
editor.applyStyle(style);
} else {
editor.execCommand('indent');
if (editor.config.numberedElements.indexOf(element.getName()) >= 0) {
editor.applyStyle(style);
} else if (CKEDITOR.plugins.loaded.indent) {
editor.execCommand("indent");
}

if (isNumbered(editor, element)) {
setStyle(editor, editor.elementPath().block, editor.config.autonumberCurrentStyle);
}
Expand All @@ -374,7 +374,7 @@
editor.config.numberedElements[editor.config.numberedElements.indexOf(
previousHeader.getName()) + 1]
) {
//this.setState(CKEDITOR.TRISTATE_DISABLED);
this.setState(CKEDITOR.TRISTATE_DISABLED);
} else {
this.setState(CKEDITOR.TRISTATE_OFF);
}
Expand All @@ -398,10 +398,10 @@
element.getName()) - 1];
//eslint-disable-next-line new-cap
var style = new CKEDITOR.style({ element: prevElement});
if(editor.config.numberedElements.indexOf(element.getName()) >= 0) {
editor.applyStyle(style);
} else {
editor.execCommand('outdent');
if (editor.config.numberedElements.indexOf(element.getName()) >= 0) {
editor.applyStyle(style);
} else if (CKEDITOR.plugins.loaded.indent) {
editor.execCommand("outdent");
}
editor.applyStyle(style);
if (isNumbered(editor, element)) {
Expand All @@ -411,7 +411,7 @@
refresh: function (editor, path) {
if (path.block && editor.config.numberedElements.indexOf(path.block.getName()) >= 0) {
if (editor.config.numberedElements.indexOf(path.block.getName()) === 0) {
//this.setState(CKEDITOR.TRISTATE_DISABLED);
this.setState(CKEDITOR.TRISTATE_DISABLED);
} else {
this.setState(CKEDITOR.TRISTATE_OFF);
}
Expand Down

0 comments on commit bdfc534

Please sign in to comment.