Skip to content

Instantly share code, notes, and snippets.

@yinheli
Last active August 29, 2015 14:05
Show Gist options
  • Save yinheli/2ea1c51710c452e9b81d to your computer and use it in GitHub Desktop.
Save yinheli/2ea1c51710c452e9b81d to your computer and use it in GitHub Desktop.
http://ziranzhi.com/ 写的 Simditor 插件, 解决回复 @ 的问题
class ReplayPlugin extends Plugin
constructor: (@widget) ->
super @widget
@editor = @widget
$('.bbp-admin-links a').on 'click', (e) =>
node = $(e.currentTarget).parent().parent().find('.bbp-author-name').clone()
node.text '@'+node.text()
@editor.trigger 'focus'
@editor.selection.insertNode node.append('  ')
@editor.trigger 'valuechanged'
@editor.trigger 'selectionchanged'
true
_init: ->
Simditor.connect ReplayPlugin
// Generated by CoffeeScript 1.7.1
(function() {
var ReplayPlugin, __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() {
this.constructor = child;
}
ctor.prototype = parent.prototype;
child.prototype = new ctor();
child.__super__ = parent.prototype;
return child;
};
ReplayPlugin = (function(_super) {
__extends(ReplayPlugin, _super);
function ReplayPlugin(widget) {
this.widget = widget;
ReplayPlugin.__super__.constructor.call(this, this.widget);
this.editor = this.widget;
$('.bbp-admin-links a').on('click', (function(_this) {
return function(e) {
var node;
node = $(e.currentTarget).parent().parent().find('.bbp-author-name').clone();
node.text('@' + node.text());
_this.editor.trigger('focus');
_this.editor.selection.insertNode(node.append('  '));
_this.editor.trigger('valuechanged');
_this.editor.trigger('selectionchanged');
return true;
};
})(this));
}
ReplayPlugin.prototype._init = function() {};
return ReplayPlugin;
})(Plugin);
Simditor.connect(ReplayPlugin);
}).call(this);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment