diff options
author | Egil Moeller <egil.moller@freecode.no> | 2010-03-25 19:15:11 +0100 |
---|---|---|
committer | Egil Moeller <egil.moller@freecode.no> | 2010-03-25 19:15:11 +0100 |
commit | 8536c02d4f3029c70d052d4b5cabfd23dd06e200 (patch) | |
tree | c9e8b16f1c1b6be70de7f0e118218b736a2360ca | |
parent | 20014050bf91266757b2c1ba82ab333638fe570d (diff) | |
download | etherpad-8536c02d4f3029c70d052d4b5cabfd23dd06e200.tar.gz etherpad-8536c02d4f3029c70d052d4b5cabfd23dd06e200.tar.xz etherpad-8536c02d4f3029c70d052d4b5cabfd23dd06e200.zip |
Got the client side of twitter style tags to work
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/main.js | 5 | ||||
-rw-r--r-- | etherpad/src/plugins/twitterStyleTags/static/js/main.js | 26 |
2 files changed, 25 insertions, 6 deletions
diff --git a/etherpad/src/plugins/twitterStyleTags/main.js b/etherpad/src/plugins/twitterStyleTags/main.js index 686c863..f6dd3bf 100644 --- a/etherpad/src/plugins/twitterStyleTags/main.js +++ b/etherpad/src/plugins/twitterStyleTags/main.js @@ -3,11 +3,12 @@ import("plugins.twitterStyleTags.hooks"); import("plugins.twitterStyleTags.static.js.main"); function init() { - this.hooks = ['handlePath']; + this.hooks = ['handlePath', 'aceGetFilterStack', 'aceCreateDomLine']; this.client = new main.init(); this.description = 'Twitter-style tags'; this.handlePath = hooks.handlePath; - this.aceGetFilterStack = hooks.aceGetFilterStack; + this.aceGetFilterStack = main.aceGetFilterStack; + this.aceCreateDomLine = main.aceCreateDomLine; this.install = install; this.uninstall = uninstall; diff --git a/etherpad/src/plugins/twitterStyleTags/static/js/main.js b/etherpad/src/plugins/twitterStyleTags/static/js/main.js index 96be013..eae0c4f 100644 --- a/etherpad/src/plugins/twitterStyleTags/static/js/main.js +++ b/etherpad/src/plugins/twitterStyleTags/static/js/main.js @@ -1,10 +1,28 @@ function init() { - this.hooks = ['aceGetFilterStack']; - this.aceGetFilterStack = aceGetFilterStack; + this.hooks = ['aceGetFilterStack', 'aceCreateDomLine']; + this.aceGetFilterStack = aceGetFilterStack; + this.aceCreateDomLine = aceCreateDomLine; } -function aceGetFilterStack() { - console.log('aceGetFilterStack'); +function aceGetFilterStack(args) { + return [args.linestylefilter.getRegexpFilter( + new RegExp("#[^,#!\\s][^,#!\\s]*", "g"), 'padtag')]; +} + +function aceCreateDomLine(args) { + if (args.cls.indexOf('padtag') < 0) + return; + + var href; + cls = args.cls.replace(/(^| )padtag:(\S+)/g, function(x0, space, padtag) { + href = '/ep/tag/?query=' + padtag.substring(1); + return space + "padtag padtag_" + padtag.substring(1); + }); + + return [{ + cls: cls, + extraOpenTags: '<a href="' + href.replace(/\"/g, '"') + '">', + extraCloseTags: '</a>'}]; } /* used on the client side only */ |