forked from Redactor2/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlimiter.js
More file actions
executable file
·45 lines (38 loc) · 824 Bytes
/
Copy pathlimiter.js
File metadata and controls
executable file
·45 lines (38 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
(function($)
{
$.Redactor.prototype.limiter = function()
{
return {
init: function()
{
if (!this.opts.limiter)
{
return;
}
this.core.editor().on('keydown.redactor-plugin-limiter', $.proxy(function(e)
{
var key = e.which;
var ctrl = e.ctrlKey || e.metaKey;
if (key === this.keyCode.BACKSPACE
|| key === this.keyCode.DELETE
|| key === this.keyCode.ESC
|| key === this.keyCode.SHIFT
|| (ctrl && key === 65)
|| (ctrl && key === 82)
|| (ctrl && key === 116)
)
{
return;
}
var text = this.core.editor().text();
text = text.replace(/\u200B/g, '');
var count = text.length;
if (count >= this.opts.limiter)
{
return false;
}
}, this));
}
};
};
})(jQuery);