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