mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-09 08:25:00 -04:00
Merge d939fd1ef4
into 4195e11a41
This commit is contained in:
commit
1c3bd6ae60
7 changed files with 178 additions and 106 deletions
13
available_plugins/ep_formatting/ep.json
Normal file
13
available_plugins/ep_formatting/ep.json
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"parts": [
|
||||
{
|
||||
"name": "basic-formatting",
|
||||
"client_hooks": {
|
||||
"postAceInit": "ep_formatting/static/js/toolbarButtons:postAceInit"
|
||||
},
|
||||
"hooks": {
|
||||
"eejsBlock_editbarMenuLeft": "ep_formatting/plugin:eejsBlock_editbarMenuLeft"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
10
available_plugins/ep_formatting/package.json
Normal file
10
available_plugins/ep_formatting/package.json
Normal file
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"author": "cohitre <smiles@cohitre.com> (http://cohitre.com)",
|
||||
"name": "ep_formatting",
|
||||
"description": "Show basic formatting options in the etherpad-lite toolbar.",
|
||||
"version": "0.0.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Pita/etherpad-lite"
|
||||
}
|
||||
}
|
6
available_plugins/ep_formatting/plugin.js
Normal file
6
available_plugins/ep_formatting/plugin.js
Normal file
|
@ -0,0 +1,6 @@
|
|||
var eejs = require('ep_etherpad-lite/node/eejs/');
|
||||
|
||||
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
|
||||
args.content = args.content + eejs.require("ep_formatting/templates/buttons.ejs");
|
||||
return cb();
|
||||
}
|
60
available_plugins/ep_formatting/static/js/toolbarButtons.js
Normal file
60
available_plugins/ep_formatting/static/js/toolbarButtons.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
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;
|
||||
|
||||
function registerCallWithAceCommand(commandName, callback) {
|
||||
padeditbar.registerToolbarCommand(commandName, function () {
|
||||
padeditor.ace.callWithAce(callback, commandName, true);
|
||||
});
|
||||
}
|
||||
|
||||
exports.postAceInit = function () {
|
||||
var simpleCommands = ["bold", "italic", "underline", "strikethrough"]
|
||||
, undoRedoCommands = ["undo", "redo"];
|
||||
|
||||
_.each(simpleCommands, function (commandName) {
|
||||
registerCallWithAceCommand(commandName, function (ace) {
|
||||
ace.ace_toggleAttributeOnSelection(commandName)
|
||||
});
|
||||
});
|
||||
|
||||
_.each(undoRedoCommands, 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', '');
|
||||
}
|
||||
});
|
||||
};
|
58
available_plugins/ep_formatting/templates/buttons.ejs
Normal file
58
available_plugins/ep_formatting/templates/buttons.ejs
Normal file
|
@ -0,0 +1,58 @@
|
|||
<li id="bold" data-key="bold">
|
||||
<a class="grouped-left" title="Bold (ctrl-B)">
|
||||
<span class="buttonicon buttonicon-bold"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="italic" data-key="italic">
|
||||
<a class="grouped-middle" title="Italics (ctrl-I)">
|
||||
<span class="buttonicon buttonicon-italic"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="underline" data-key="underline">
|
||||
<a class="grouped-middle" title="Underline (ctrl-U)">
|
||||
<span class="buttonicon buttonicon-underline"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="strikethrough" data-key="strikethrough">
|
||||
<a class="grouped-right" title="Strikethrough">
|
||||
<span class="buttonicon buttonicon-strikethrough"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="oderedlist" data-key="insertorderedlist">
|
||||
<a class="grouped-left" title="Toggle Ordered List">
|
||||
<span class="buttonicon buttonicon-insertorderedlist"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="unoderedlist" data-key="insertunorderedlist">
|
||||
<a class="grouped-middle" title="Toggle Bullet List">
|
||||
<span class="buttonicon buttonicon-insertunorderedlist"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="indent" data-key="indent">
|
||||
<a class="grouped-middle" title="Indent">
|
||||
<span class="buttonicon buttonicon-indent"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="outdent" data-key="outdent">
|
||||
<a class="grouped-right" title="Unindent">
|
||||
<span class="buttonicon buttonicon-outdent"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="undo" data-key="undo">
|
||||
<a class="grouped-left" title="Undo (ctrl-Z)">
|
||||
<span class="buttonicon buttonicon-undo"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="redo" data-key="redo">
|
||||
<a class="grouped-right" title="Redo (ctrl-Y)">
|
||||
<span class="buttonicon buttonicon-redo"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="clearAuthorship" data-key="clearauthorship">
|
||||
<a title="Clear Authorship Colors">
|
||||
<span class="buttonicon buttonicon-clearauthorship"></span>
|
||||
</a>
|
||||
</li>
|
|
@ -116,6 +116,23 @@ var padeditbar = (function()
|
|||
{
|
||||
$("#editbar").addClass('disabledtoolbar').removeClass("enabledtoolbar");
|
||||
},
|
||||
hasToolbarCommand: function (commandName) {
|
||||
return this.toolbarCommands && this.toolbarCommands[commandName] !== undefined;
|
||||
},
|
||||
registerToolbarCommand: function (commandName, method) {
|
||||
this.toolbarCommands = this.toolbarCommands || {};
|
||||
this.toolbarCommands[commandName] = method;
|
||||
return this;
|
||||
},
|
||||
executeToolbarCommand: function (commandName) {
|
||||
var args = Array.prototype.slice.call(arguments, 1);
|
||||
|
||||
if (this.hasToolbarCommand(commandName)) {
|
||||
this.toolbarCommands[commandName].apply(this, args);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
toolbarClick: function(cmd)
|
||||
{
|
||||
if (self.isEnabled())
|
||||
|
@ -136,48 +153,14 @@ var padeditbar = (function()
|
|||
}
|
||||
else if (cmd == 'import_export')
|
||||
{
|
||||
self.toogleDropDown("importexport");
|
||||
self.toogleDropDown("importexport");
|
||||
}
|
||||
else if (cmd == 'savedRevision')
|
||||
{
|
||||
padsavedrevs.saveNow();
|
||||
}
|
||||
else
|
||||
{
|
||||
padeditor.ace.callWithAce(function(ace)
|
||||
{
|
||||
if (cmd == 'bold' || cmd == 'italic' || cmd == 'underline' || cmd == 'strikethrough') ace.ace_toggleAttributeOnSelection(cmd);
|
||||
else if (cmd == 'undo' || cmd == 'redo') ace.ace_doUndoRedo(cmd);
|
||||
else if (cmd == 'insertunorderedlist') ace.ace_doInsertUnorderedList();
|
||||
else if (cmd == 'insertorderedlist') ace.ace_doInsertOrderedList();
|
||||
else if (cmd == 'indent')
|
||||
{
|
||||
if (!ace.ace_doIndentOutdent(false))
|
||||
{
|
||||
ace.ace_doInsertUnorderedList();
|
||||
}
|
||||
}
|
||||
else if (cmd == 'outdent')
|
||||
{
|
||||
ace.ace_doIndentOutdent(true);
|
||||
}
|
||||
else if (cmd == 'clearauthorship')
|
||||
{
|
||||
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', '');
|
||||
}
|
||||
}
|
||||
}, cmd, true);
|
||||
else if (self.hasToolbarCommand(cmd)) {
|
||||
self.executeToolbarCommand(cmd);
|
||||
}
|
||||
}
|
||||
if(padeditor.ace) padeditor.ace.focus();
|
||||
|
|
|
@ -24,64 +24,6 @@
|
|||
<div id="editbar" class="toolbar">
|
||||
<ul class="menu_left">
|
||||
<% e.begin_block("editbarMenuLeft"); %>
|
||||
<li id="bold" data-key="bold">
|
||||
<a class="grouped-left" title="Bold (ctrl-B)">
|
||||
<span class="buttonicon buttonicon-bold"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="italic" data-key="italic">
|
||||
<a class="grouped-middle" title="Italics (ctrl-I)">
|
||||
<span class="buttonicon buttonicon-italic"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="underline" data-key="underline">
|
||||
<a class="grouped-middle" title="Underline (ctrl-U)">
|
||||
<span class="buttonicon buttonicon-underline"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="strikethrough" data-key="strikethrough">
|
||||
<a class="grouped-right" title="Strikethrough">
|
||||
<span class="buttonicon buttonicon-strikethrough"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="oderedlist" data-key="insertorderedlist">
|
||||
<a class="grouped-left" title="Toggle Ordered List">
|
||||
<span class="buttonicon buttonicon-insertorderedlist"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="unoderedlist" data-key="insertunorderedlist">
|
||||
<a class="grouped-middle" title="Toggle Bullet List">
|
||||
<span class="buttonicon buttonicon-insertunorderedlist"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="indent" data-key="indent">
|
||||
<a class="grouped-middle" title="Indent">
|
||||
<span class="buttonicon buttonicon-indent"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="outdent" data-key="outdent">
|
||||
<a class="grouped-right" title="Unindent">
|
||||
<span class="buttonicon buttonicon-outdent"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="undo" data-key="undo">
|
||||
<a class="grouped-left" title="Undo (ctrl-Z)">
|
||||
<span class="buttonicon buttonicon-undo"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li id="redo" data-key="redo">
|
||||
<a class="grouped-right" title="Redo (ctrl-Y)">
|
||||
<span class="buttonicon buttonicon-redo"></span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="separator"></li>
|
||||
<li id="clearAuthorship" data-key="clearauthorship">
|
||||
<a title="Clear Authorship Colors">
|
||||
<span class="buttonicon buttonicon-clearauthorship"></span>
|
||||
</a>
|
||||
</li>
|
||||
<% e.end_block(); %>
|
||||
</ul>
|
||||
<ul class="menu_right">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue