mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-09 08:25:00 -04:00
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
var _ = require('ep_etherpad-lite/static/js/underscore')
|
|
, padeditor = require('ep_etherpad-lite/static/js/pad_editor').padeditor
|
|
, padeditbar = require('ep_etherpad-lite/static/js/pad_editbar').padeditbar
|
|
, simpleCommands = ["bold", "italic", "underline", "strikethrough"];
|
|
|
|
function registerCallWithAceCommand(commandName, callback) {
|
|
padeditbar.registerToolbarCommand(commandName, function () {
|
|
padeditor.ace.callWithAce(callback, commandName, true);
|
|
});
|
|
}
|
|
|
|
exports.postAceInit = function () {
|
|
_.each(simpleCommands, function (commandName) {
|
|
registerCallWithAceCommand(commandName, function (ace) {
|
|
ace.ace_toggleAttributeOnSelection(commandName)
|
|
});
|
|
});
|
|
|
|
_.each(["undo", "redo"], function (commandName) {
|
|
registerCallWithAceCommand(commandName, function (ace) {
|
|
ace.ace_doUndoRedo(commandName);
|
|
});
|
|
});
|
|
|
|
registerCallWithAceCommand('insertunorderedlist', function (ace) {
|
|
ace.ace_doInsertUnorderedList();
|
|
});
|
|
|
|
registerCallWithAceCommand("insertorderedlist", function (ace) {
|
|
ace.ace_doInsertOrderedList();
|
|
});
|
|
|
|
registerCallWithAceCommand("indent", function (ace) {
|
|
if (!ace.ace_doIndentOutdent(false)) {
|
|
ace.ace_doInsertUnorderedList();
|
|
}
|
|
});
|
|
|
|
registerCallWithAceCommand("outdent", function (ace) {
|
|
ace.ace_doIndentOutdent(true);
|
|
});
|
|
|
|
registerCallWithAceCommand("clearauthorship", function (ace) {
|
|
if ((!(ace.ace_getRep().selStart && ace.ace_getRep().selEnd)) || ace.ace_isCaret())
|
|
{
|
|
if (window.confirm("Clear authorship colors on entire document?"))
|
|
{
|
|
ace.ace_performDocumentApplyAttributesToCharRange(0, ace.ace_getRep().alltext.length, [
|
|
['author', '']
|
|
]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ace.ace_setAttributeOnSelection('author', '');
|
|
}
|
|
});
|
|
};
|