mirror of
				https://github.com/ether/etherpad-lite.git
				synced 2025-11-04 02:01:30 +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
					
				@ -28,7 +28,7 @@ Ace2Editor.registry = {
 | 
			
		||||
  nextId: 1
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
var plugins = require('ep_etherpad-lite/static/js/plugins').plugins;
 | 
			
		||||
var hooks = require('ep_etherpad-lite/static/js/pluginfw/hooks');
 | 
			
		||||
 | 
			
		||||
function Ace2Editor()
 | 
			
		||||
{
 | 
			
		||||
@ -300,7 +300,7 @@ function Ace2Editor()
 | 
			
		||||
      for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
 | 
			
		||||
        iframeHTML[i] = JSON.stringify(iframeHTML[i]);
 | 
			
		||||
      }
 | 
			
		||||
      plugins.callHook("aceInitInnerdocbodyHead", {
 | 
			
		||||
      hooks.callAll("aceInitInnerdocbodyHead", {
 | 
			
		||||
        iframeHTML: iframeHTML
 | 
			
		||||
      });
 | 
			
		||||
      for (var i = 0, ii = iframeHTML.length; i < ii; i++) {
 | 
			
		||||
 | 
			
		||||
@ -26,7 +26,7 @@
 | 
			
		||||
var _MAX_LIST_LEVEL = 8;
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
{
 | 
			
		||||
@ -37,8 +37,6 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
 | 
			
		||||
{
 | 
			
		||||
  browser = browser || {};
 | 
			
		||||
 | 
			
		||||
  var plugins_ = plugins;
 | 
			
		||||
 | 
			
		||||
  var dom = domInterface || {
 | 
			
		||||
    isNodeText: function(n)
 | 
			
		||||
    {
 | 
			
		||||
@ -448,7 +446,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
 | 
			
		||||
        var oldAuthorOrNull = null;
 | 
			
		||||
        if (collectStyles)
 | 
			
		||||
        {
 | 
			
		||||
          plugins_.callHook('collectContentPre', {
 | 
			
		||||
          hooks.callAll('collectContentPre', {
 | 
			
		||||
            cc: cc,
 | 
			
		||||
            state: state,
 | 
			
		||||
            tname: tname,
 | 
			
		||||
@ -510,7 +508,7 @@ function makeContentCollector(collectStyles, browser, apool, domInterface, class
 | 
			
		||||
 | 
			
		||||
        if (collectStyles)
 | 
			
		||||
        {
 | 
			
		||||
          plugins_.callHook('collectContentPost', {
 | 
			
		||||
          hooks.callAll('collectContentPost', {
 | 
			
		||||
            cc: cc,
 | 
			
		||||
            state: state,
 | 
			
		||||
            tname: tname,
 | 
			
		||||
 | 
			
		||||
@ -27,7 +27,7 @@
 | 
			
		||||
// requires: undefined
 | 
			
		||||
 | 
			
		||||
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 domline = {};
 | 
			
		||||
@ -145,9 +145,7 @@ domline.createDomLine = function(nonEmpty, doesWrap, optBrowser, optDocument)
 | 
			
		||||
    var extraOpenTags = "";
 | 
			
		||||
    var extraCloseTags = "";
 | 
			
		||||
 | 
			
		||||
    var plugins_ = plugins;
 | 
			
		||||
 | 
			
		||||
    map(plugins_.callHook("aceCreateDomLine", {
 | 
			
		||||
    map(hooks.callAll("aceCreateDomLine", {
 | 
			
		||||
      domline: domline,
 | 
			
		||||
      cls: cls
 | 
			
		||||
    }), function(modifier)
 | 
			
		||||
 | 
			
		||||
@ -29,7 +29,7 @@
 | 
			
		||||
// requires: undefined
 | 
			
		||||
 | 
			
		||||
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 linestylefilter = {};
 | 
			
		||||
@ -55,8 +55,6 @@ linestylefilter.getAuthorClassName = function(author)
 | 
			
		||||
linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFunc, apool)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
  var plugins_ = plugins;
 | 
			
		||||
 | 
			
		||||
  if (lineLength == 0) return textAndClassFunc;
 | 
			
		||||
 | 
			
		||||
  var nextAfterAuthorColors = textAndClassFunc;
 | 
			
		||||
@ -97,7 +95,7 @@ linestylefilter.getLineStyleFilter = function(lineLength, aline, textAndClassFun
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
              classes += plugins_.callHookStr("aceAttribsToClasses", {
 | 
			
		||||
              classes += hooks.callAllStr("aceAttribsToClasses", {
 | 
			
		||||
                linestylefilter: linestylefilter,
 | 
			
		||||
                key: key,
 | 
			
		||||
                value: value
 | 
			
		||||
@ -300,9 +298,7 @@ linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser)
 | 
			
		||||
{
 | 
			
		||||
  var func = linestylefilter.getURLFilter(lineText, textAndClassFunc);
 | 
			
		||||
 | 
			
		||||
  var plugins_ = plugins;
 | 
			
		||||
 | 
			
		||||
  var hookFilters = plugins_.callHook("aceGetFilterStack", {
 | 
			
		||||
  var hookFilters = hooks.callAll("aceGetFilterStack", {
 | 
			
		||||
    linestylefilter: linestylefilter,
 | 
			
		||||
    browser: browser
 | 
			
		||||
  });
 | 
			
		||||
 | 
			
		||||
@ -61,3 +61,15 @@ exports.aCallFirst = function (hook_name, args, cb) {
 | 
			
		||||
  if (plugins.hooks[hook_name][0] === undefined) cb([]);
 | 
			
		||||
  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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user