mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
Made ace actually use the new hooks system, and removed remnants of old system
This commit is contained in:
parent
81440cd856
commit
df531a7b2b
6 changed files with 22 additions and 55 deletions
|
@ -28,7 +28,7 @@ Ace2Editor.registry = {
|
||||||
nextId: 1
|
nextId: 1
|
||||||
};
|
};
|
||||||
|
|
||||||
var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
|
|
||||||
function Ace2Editor()
|
function Ace2Editor()
|
||||||
{
|
{
|
||||||
|
@ -300,7 +300,7 @@ function Ace2Editor()
|
||||||
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
||||||
iframeHTML[i] = JSON.stringify(iframeHTML[i]);
|
iframeHTML[i] = JSON.stringify(iframeHTML[i]);
|
||||||
}
|
}
|
||||||
plugins.callHook("aceInitInnerdocbodyHead", {
|
hooks.callAll("aceInitInnerdocbodyHead", {
|
||||||
iframeHTML: iframeHTML
|
iframeHTML: iframeHTML
|
||||||
});
|
});
|
||||||
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
var _MAX_LIST_LEVEL = 8;
|
var _MAX_LIST_LEVEL = 8;
|
||||||
|
|
||||||
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
||||||
var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
|
|
||||||
function sanitizeUnicode(s)
|
function sanitizeUnicode(s)
|
||||||
{
|
{
|
||||||
|
@ -37,8 +37,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
|
||||||
{
|
{
|
||||||
browser = browser || {};
|
browser = browser || {};
|
||||||
|
|
||||||
var plugins_ = plugins;
|
|
||||||
|
|
||||||
var dom = domInterface || {
|
var dom = domInterface || {
|
||||||
isNodeText: function(n)
|
isNodeText: function(n)
|
||||||
{
|
{
|
||||||
|
@ -448,7 +446,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
|
||||||
var oldAuthorOrNull = null;
|
var oldAuthorOrNull = null;
|
||||||
if (collectStyles)
|
if (collectStyles)
|
||||||
{
|
{
|
||||||
plugins_.callHook('collectContentPre', {
|
hooks.callAll('collectContentPre', {
|
||||||
cc: cc,
|
cc: cc,
|
||||||
state: state,
|
state: state,
|
||||||
tname: tname,
|
tname: tname,
|
||||||
|
@ -510,7 +508,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
|
||||||
|
|
||||||
if (collectStyles)
|
if (collectStyles)
|
||||||
{
|
{
|
||||||
plugins_.callHook('collectContentPost', {
|
hooks.callAll('collectContentPost', {
|
||||||
cc: cc,
|
cc: cc,
|
||||||
state: state,
|
state: state,
|
||||||
tname: tname,
|
tname: tname,
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
var Security = require('ep_etherpad-lite/static/js/security');
|
var Security = require('ep_etherpad-lite/static/js/security');
|
||||||
var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
|
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
|
||||||
|
|
||||||
var domline = {};
|
var domline = {};
|
||||||
|
@ -145,9 +145,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
|
||||||
var extraOpenTags = "";
|
var extraOpenTags = "";
|
||||||
var extraCloseTags = "";
|
var extraCloseTags = "";
|
||||||
|
|
||||||
var plugins_ = plugins;
|
map(hooks.callAll("aceCreateDomLine", {
|
||||||
|
|
||||||
map(plugins_.callHook("aceCreateDomLine", {
|
|
||||||
domline: domline,
|
domline: domline,
|
||||||
cls: cls
|
cls: cls
|
||||||
}), function(modifier)
|
}), function(modifier)
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
// requires: undefined
|
// requires: undefined
|
||||||
|
|
||||||
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
var Changeset = require('ep_etherpad-lite/static/js/Changeset');
|
||||||
var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
|
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
|
||||||
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
|
var map = require('ep_etherpad-lite/static/js/ace2_common').map;
|
||||||
|
|
||||||
var linestylefilter = {};
|
var linestylefilter = {};
|
||||||
|
@ -55,8 +55,6 @@ linestylefilter.getAuthorClassName = function(author)
|
||||||
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
|
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
|
||||||
{
|
{
|
||||||
|
|
||||||
var plugins_ = plugins;
|
|
||||||
|
|
||||||
if (lineLength == 0) return textAndClassFunc;
|
if (lineLength == 0) return textAndClassFunc;
|
||||||
|
|
||||||
var nextAfterAuthorColors = textAndClassFunc;
|
var nextAfterAuthorColors = textAndClassFunc;
|
||||||
|
@ -97,7 +95,7 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
classes += plugins_.callHookStr("aceAttribsToClasses", {
|
classes += hooks.callAllStr("aceAttribsToClasses", {
|
||||||
linestylefilter: linestylefilter,
|
linestylefilter: linestylefilter,
|
||||||
key: key,
|
key: key,
|
||||||
value: value
|
value: value
|
||||||
|
@ -300,9 +298,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
|
||||||
{
|
{
|
||||||
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
|
var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
|
||||||
|
|
||||||
var plugins_ = plugins;
|
var hookFilters = hooks.callAll("aceGetFilterStack", {
|
||||||
|
|
||||||
var hookFilters = plugins_.callHook("aceGetFilterStack", {
|
|
||||||
linestylefilter: linestylefilter,
|
linestylefilter: linestylefilter,
|
||||||
browser: browser
|
browser: browser
|
||||||
});
|
});
|
||||||
|
|
|
@ -61,3 +61,15 @@ exports.aCallFirst = function (hook_name, args, cb) {
|
||||||
if (plugins.hooks[hook_name][0] === undefined) cb([]);
|
if (plugins.hooks[hook_name][0] === undefined) cb([]);
|
||||||
hookCallWrapper(plugins.hooks[hook_name][0], hook_name, args, function (res) { cb(exports.flatten(res)); });
|
hookCallWrapper(plugins.hooks[hook_name][0], hook_name, args, function (res) { cb(exports.flatten(res)); });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
exports.callAllStr = function(hook_name, args, sep, pre, post) {
|
||||||
|
if (sep == undefined) sep = '';
|
||||||
|
if (pre == undefined) pre = '';
|
||||||
|
if (post == undefined) post = '';
|
||||||
|
var newCallhooks = [];
|
||||||
|
var callhooks = exports.callAll(hook_name, args);
|
||||||
|
for (var i = 0, ii = callhooks.length; i < ii; i++) {
|
||||||
|
newCallhooks[i] = pre + callhooks[i] + post;
|
||||||
|
}
|
||||||
|
return newCallhooks.join(sep || "");
|
||||||
|
}
|
||||||
|
|
|
@ -1,37 +0,0 @@
|
||||||
/**
|
|
||||||
* This code is mostly from the old Etherpad. Please help us to comment this code.
|
|
||||||
* This helps other people to understand this code better and helps them to improve it.
|
|
||||||
* TL;DR COMMENTS ON THIS FILE ARE HIGHLY APPRECIATED
|
|
||||||
*/
|
|
||||||
|
|
||||||
var plugins = {
|
|
||||||
callHook: function(hookName, args)
|
|
||||||
{
|
|
||||||
var global = (function () {return this}());
|
|
||||||
var hook = ((global.clientVars || {}).hooks || {})[hookName];
|
|
||||||
if (hook === undefined) return [];
|
|
||||||
var res = [];
|
|
||||||
for (var i = 0, N = hook.length; i < N; i++)
|
|
||||||
{
|
|
||||||
var plugin = hook[i];
|
|
||||||
var pluginRes = eval(plugin.plugin)[plugin.original || hookName](args);
|
|
||||||
if (pluginRes != undefined && pluginRes != null) res = res.concat(pluginRes);
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
},
|
|
||||||
|
|
||||||
callHookStr: function(hookName, args, sep, pre, post)
|
|
||||||
{
|
|
||||||
if (sep == undefined) sep = '';
|
|
||||||
if (pre == undefined) pre = '';
|
|
||||||
if (post == undefined) post = '';
|
|
||||||
var newCallhooks = [];
|
|
||||||
var callhooks = plugins.callHook(hookName, args);
|
|
||||||
for (var i = 0, ii = callhooks.length; i < ii; i++) {
|
|
||||||
newCallhooks[i] = pre + callhooks[i] + post;
|
|
||||||
}
|
|
||||||
return newCallhooks.join(sep || "");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.plugins = plugins;
|
|
Loading…
Reference in a new issue