mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-10 00:45:01 -04:00
Moving the formatting buttons to a plugin.
This commit is contained in:
parent
e4ff4021ab
commit
103dc68e4d
7 changed files with 176 additions and 106 deletions
58
available_plugins/ep_formatting/static/js/toolbarButtons.js
Normal file
58
available_plugins/ep_formatting/static/js/toolbarButtons.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
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', '');
|
||||
}
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue