From b897b18b9cb727f277a41ba12349548fe854d724 Mon Sep 17 00:00:00 2001 From: Egil Moeller Date: Thu, 25 Mar 2010 17:53:24 +0100 Subject: Added support for plugins in the ACE linefilter --- infrastructure/ace/www/ace2_inner.js | 10 +--------- infrastructure/ace/www/linestylefilter.js | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'infrastructure/ace/www') diff --git a/infrastructure/ace/www/ace2_inner.js b/infrastructure/ace/www/ace2_inner.js index afd1e35..e817c95 100644 --- a/infrastructure/ace/www/ace2_inner.js +++ b/infrastructure/ace/www/ace2_inner.js @@ -1139,15 +1139,7 @@ function OUTER(gscope) { } else { var offsetIntoLine = 0; - var filteredFunc = textAndClassFunc; - filteredFunc = linestylefilter.getURLFilter(text, filteredFunc); - if (browser.msie) { - // IE7+ will take an e-mail address like and linkify it to foo@bar.com. - // We then normalize it back to text with no angle brackets. It's weird. So always - // break spans at an "at" sign. - filteredFunc = linestylefilter.getAtSignSplitterFilter( - text, filteredFunc); - } + var filteredFunc = linestylefilter.getFilterStack(text, textAndClassFunc, browser); var lineNum = rep.lines.indexOfEntry(lineEntry); var aline = rep.alines[lineNum]; filteredFunc = linestylefilter.getLineStyleFilter( diff --git a/infrastructure/ace/www/linestylefilter.js b/infrastructure/ace/www/linestylefilter.js index 0ac578b..c493911 100644 --- a/infrastructure/ace/www/linestylefilter.js +++ b/infrastructure/ace/www/linestylefilter.js @@ -1,5 +1,6 @@ // THIS FILE IS ALSO AN APPJET MODULE: etherpad.collab.ace.linestylefilter // %APPJET%: import("etherpad.collab.ace.easysync2.Changeset"); +// %APPJET%: import("etherpad.admin.plugins"); /** * Copyright 2009 Google Inc. @@ -18,6 +19,10 @@ */ // requires: easysync2.Changeset +// requires: top +// requires: plugins +// requires: plugins +// requires: undefined var linestylefilter = {}; @@ -226,6 +231,27 @@ linestylefilter.textAndClassFuncSplitter = function(func, splitPointsOpt) { return spanHandler; }; +linestylefilter.getFilterStack = function(lineText, textAndClassFunc, browser) { + var func = linestylefilter.getURLFilter(lineText, textAndClassFunc); + + /* Handle both client and server side situation */ + + var pluginModule = (top == undefined) ? plugins : top.plugins; + + var hookFilters = pluginModule.callHook("aceGetFilterStack", {linestylefilter:linestylefilter, browser:browser}); + for (var i = 0; i < hookFilters.length; i++) + func = hookFilters[i](lineText, func); + + if (browser !== undefined && browser.msie) { + // IE7+ will take an e-mail address like and linkify it to foo@bar.com. + // We then normalize it back to text with no angle brackets. It's weird. So always + // break spans at an "at" sign. + func = linestylefilter.getAtSignSplitterFilter( + lineText, func); + } + return func; +}; + // domLineObj is like that returned by domline.createDomLine linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj) { @@ -239,8 +265,7 @@ linestylefilter.populateDomLine = function(textLine, aline, apool, domLineObj.appendSpan(tokenText, tokenClass); } - var func = textAndClassFunc; - func = linestylefilter.getURLFilter(text, func); + var func = linestylefilter.getFilterStack(text, textAndClassFunc); func = linestylefilter.getLineStyleFilter(text.length, aline, func, apool); func(text, ''); -- cgit v1.2.3