mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-19 14:13:34 +01:00
pad_editbar: Convert registerDefaultCommands()
into a method
This commit is contained in:
parent
0d4f147349
commit
4b4eef5f4a
1 changed files with 104 additions and 107 deletions
|
@ -125,7 +125,7 @@ const padeditbar = (() => {
|
|||
};
|
||||
const syncAnimation = syncAnimationFn();
|
||||
|
||||
const self = {
|
||||
return {
|
||||
_editbarPosition: 0,
|
||||
|
||||
init() {
|
||||
|
@ -150,7 +150,7 @@ const padeditbar = (() => {
|
|||
this.checkAllIconsAreDisplayedInToolbar();
|
||||
$(window).resize(_.debounce(() => this.checkAllIconsAreDisplayedInToolbar(), 100));
|
||||
|
||||
registerDefaultCommands(this);
|
||||
this._registerDefaultCommands();
|
||||
|
||||
hooks.callAll('postToolbarInit', {
|
||||
toolbar: this,
|
||||
|
@ -356,27 +356,22 @@ const padeditbar = (() => {
|
|||
}
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const aceAttributeCommand = (cmd, ace) => {
|
||||
ace.ace_toggleAttributeOnSelection(cmd);
|
||||
};
|
||||
_registerDefaultCommands() {
|
||||
this.registerDropdownCommand('showusers', 'users');
|
||||
this.registerDropdownCommand('settings');
|
||||
this.registerDropdownCommand('connectivity');
|
||||
this.registerDropdownCommand('import_export');
|
||||
this.registerDropdownCommand('embed');
|
||||
|
||||
const registerDefaultCommands = (toolbar) => {
|
||||
toolbar.registerDropdownCommand('showusers', 'users');
|
||||
toolbar.registerDropdownCommand('settings');
|
||||
toolbar.registerDropdownCommand('connectivity');
|
||||
toolbar.registerDropdownCommand('import_export');
|
||||
toolbar.registerDropdownCommand('embed');
|
||||
|
||||
toolbar.registerCommand('settings', () => {
|
||||
toolbar.toggleDropDown('settings', () => {
|
||||
this.registerCommand('settings', () => {
|
||||
this.toggleDropDown('settings', () => {
|
||||
$('#options-stickychat').focus();
|
||||
});
|
||||
});
|
||||
|
||||
toolbar.registerCommand('import_export', () => {
|
||||
toolbar.toggleDropDown('import_export', () => {
|
||||
this.registerCommand('import_export', () => {
|
||||
this.toggleDropDown('import_export', () => {
|
||||
// If Import file input exists then focus on it..
|
||||
if ($('#importfileinput').length !== 0) {
|
||||
setTimeout(() => {
|
||||
|
@ -388,59 +383,62 @@ const padeditbar = (() => {
|
|||
});
|
||||
});
|
||||
|
||||
toolbar.registerCommand('showusers', () => {
|
||||
toolbar.toggleDropDown('users', () => {
|
||||
this.registerCommand('showusers', () => {
|
||||
this.toggleDropDown('users', () => {
|
||||
$('#myusernameedit').focus();
|
||||
});
|
||||
});
|
||||
|
||||
toolbar.registerCommand('embed', () => {
|
||||
toolbar.setEmbedLinks();
|
||||
toolbar.toggleDropDown('embed', () => {
|
||||
this.registerCommand('embed', () => {
|
||||
this.setEmbedLinks();
|
||||
this.toggleDropDown('embed', () => {
|
||||
$('#linkinput').focus().select();
|
||||
});
|
||||
});
|
||||
|
||||
toolbar.registerCommand('savedRevision', () => {
|
||||
this.registerCommand('savedRevision', () => {
|
||||
padsavedrevs.saveNow();
|
||||
});
|
||||
|
||||
toolbar.registerCommand('showTimeSlider', () => {
|
||||
this.registerCommand('showTimeSlider', () => {
|
||||
document.location = `${document.location.pathname}/timeslider`;
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('bold', aceAttributeCommand);
|
||||
toolbar.registerAceCommand('italic', aceAttributeCommand);
|
||||
toolbar.registerAceCommand('underline', aceAttributeCommand);
|
||||
toolbar.registerAceCommand('strikethrough', aceAttributeCommand);
|
||||
const aceAttributeCommand = (cmd, ace) => {
|
||||
ace.ace_toggleAttributeOnSelection(cmd);
|
||||
};
|
||||
this.registerAceCommand('bold', aceAttributeCommand);
|
||||
this.registerAceCommand('italic', aceAttributeCommand);
|
||||
this.registerAceCommand('underline', aceAttributeCommand);
|
||||
this.registerAceCommand('strikethrough', aceAttributeCommand);
|
||||
|
||||
toolbar.registerAceCommand('undo', (cmd, ace) => {
|
||||
this.registerAceCommand('undo', (cmd, ace) => {
|
||||
ace.ace_doUndoRedo(cmd);
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('redo', (cmd, ace) => {
|
||||
this.registerAceCommand('redo', (cmd, ace) => {
|
||||
ace.ace_doUndoRedo(cmd);
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('insertunorderedlist', (cmd, ace) => {
|
||||
this.registerAceCommand('insertunorderedlist', (cmd, ace) => {
|
||||
ace.ace_doInsertUnorderedList();
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('insertorderedlist', (cmd, ace) => {
|
||||
this.registerAceCommand('insertorderedlist', (cmd, ace) => {
|
||||
ace.ace_doInsertOrderedList();
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('indent', (cmd, ace) => {
|
||||
this.registerAceCommand('indent', (cmd, ace) => {
|
||||
if (!ace.ace_doIndentOutdent(false)) {
|
||||
ace.ace_doInsertUnorderedList();
|
||||
}
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('outdent', (cmd, ace) => {
|
||||
this.registerAceCommand('outdent', (cmd, ace) => {
|
||||
ace.ace_doIndentOutdent(true);
|
||||
});
|
||||
|
||||
toolbar.registerAceCommand('clearauthorship', (cmd, ace) => {
|
||||
this.registerAceCommand('clearauthorship', (cmd, ace) => {
|
||||
// If we have the whole document selected IE control A has been hit
|
||||
const rep = ace.ace_getRep();
|
||||
let doPrompt = false;
|
||||
|
@ -473,7 +471,7 @@ const padeditbar = (() => {
|
|||
}
|
||||
});
|
||||
|
||||
toolbar.registerCommand('timeslider_returnToPad', (cmd) => {
|
||||
this.registerCommand('timeslider_returnToPad', (cmd) => {
|
||||
if (document.referrer.length > 0 &&
|
||||
document.referrer.substring(document.referrer.lastIndexOf('/') - 1,
|
||||
document.referrer.lastIndexOf('/')) === 'p') {
|
||||
|
@ -483,9 +481,8 @@ const padeditbar = (() => {
|
|||
.substring(0, document.location.href.lastIndexOf('/'));
|
||||
}
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
return self;
|
||||
})();
|
||||
|
||||
exports.padeditbar = padeditbar;
|
||||
|
|
Loading…
Reference in a new issue