simditor 2.1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +23 -0
- data/README.md +19 -0
- data/lib/simditor.rb +5 -0
- data/lib/simditor/engine.rb +7 -0
- data/lib/simditor/version.rb +5 -0
- data/lib/simditor/version.rb~ +5 -0
- data/vendor/assets/images/upload-loading.png +0 -0
- data/vendor/assets/javascripts/simditor.js +4 -0
- data/vendor/assets/javascripts/simditor/hotkeys.js +246 -0
- data/vendor/assets/javascripts/simditor/module.js +174 -0
- data/vendor/assets/javascripts/simditor/simditor.js +5006 -0
- data/vendor/assets/javascripts/simditor/uploader.js +266 -0
- data/vendor/assets/stylesheets/simditor.scss +4 -0
- data/vendor/assets/stylesheets/simditor/editor.scss +681 -0
- data/vendor/assets/stylesheets/simditor/fonticon.scss +1 -0
- metadata +59 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 509551059b35c5be2fd35466e505a0abb60ff663
|
4
|
+
data.tar.gz: 782ee7fb9bc3f51343bd4dc92610eaf4d40c0e48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8dcfdedef8920f531b5e03c8b57fcc5f0d9d8c1e50f6c68a0f62e341bb24d125e331b0cfe8f910df4691779f2e1bff6a0fa3745220138e5aa37aaeca69ecadcf
|
7
|
+
data.tar.gz: df1cb856fecb9784e10ae2e9847b2244a939b72588066a98d7c783cef944f557d9b4eef60409f1a4fb65e9f8d0a1bb4d0ff99ada4ec0870375fb49135c0a7966
|
data/LICENSE
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
Simditor - A simple editor designed by mycolorway
|
2
|
+
Copyright (C) 2014 https://github.com/mycolorway/simditor
|
3
|
+
|
4
|
+
Rubygem - simditor - Rails assets wrapper for Simditor
|
5
|
+
Copyright (C) 2015 https://github.com/wentaoliu/simditor-rails
|
6
|
+
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
8
|
+
this software and associated documentation files (the "Software"), to deal in
|
9
|
+
the Software without restriction, including without limitation the rights to
|
10
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
11
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
12
|
+
so, subject to the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
15
|
+
copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# simditor gem
|
2
|
+
`simditor` gem is a Rails assets wrapper of [Simditor](https://github.com/mycolorway/simditor).
|
3
|
+
|
4
|
+
## Usage
|
5
|
+
|
6
|
+
in Gemfile
|
7
|
+
```ruby
|
8
|
+
gem 'simditor'
|
9
|
+
```
|
10
|
+
|
11
|
+
in application.js
|
12
|
+
```
|
13
|
+
//= require simditor
|
14
|
+
```
|
15
|
+
|
16
|
+
in application.css
|
17
|
+
```
|
18
|
+
*= require simditor
|
19
|
+
```
|
data/lib/simditor.rb
ADDED
Binary file
|
@@ -0,0 +1,246 @@
|
|
1
|
+
(function (root, factory) {
|
2
|
+
if (typeof define === 'function' && define.amd) {
|
3
|
+
// AMD. Register as an anonymous module.
|
4
|
+
define('simple-hotkeys', ["jquery",
|
5
|
+
"simple-module"], function ($, SimpleModule) {
|
6
|
+
return (root.returnExportsGlobal = factory($, SimpleModule));
|
7
|
+
});
|
8
|
+
} else if (typeof exports === 'object') {
|
9
|
+
// Node. Does not work with strict CommonJS, but
|
10
|
+
// only CommonJS-like enviroments that support module.exports,
|
11
|
+
// like Node.
|
12
|
+
module.exports = factory(require("jquery"),
|
13
|
+
require("simple-module"));
|
14
|
+
} else {
|
15
|
+
root.simple = root.simple || {};
|
16
|
+
root.simple['hotkeys'] = factory(jQuery,
|
17
|
+
SimpleModule);
|
18
|
+
}
|
19
|
+
}(this, function ($, SimpleModule) {
|
20
|
+
|
21
|
+
var Hotkeys, hotkeys,
|
22
|
+
__hasProp = {}.hasOwnProperty,
|
23
|
+
__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; };
|
24
|
+
|
25
|
+
Hotkeys = (function(_super) {
|
26
|
+
__extends(Hotkeys, _super);
|
27
|
+
|
28
|
+
function Hotkeys() {
|
29
|
+
return Hotkeys.__super__.constructor.apply(this, arguments);
|
30
|
+
}
|
31
|
+
|
32
|
+
Hotkeys.count = 0;
|
33
|
+
|
34
|
+
Hotkeys.keyNameMap = {
|
35
|
+
8: "Backspace",
|
36
|
+
9: "Tab",
|
37
|
+
13: "Enter",
|
38
|
+
16: "Shift",
|
39
|
+
17: "Control",
|
40
|
+
18: "Alt",
|
41
|
+
19: "Pause",
|
42
|
+
20: "CapsLock",
|
43
|
+
27: "Esc",
|
44
|
+
32: "Spacebar",
|
45
|
+
33: "PageUp",
|
46
|
+
34: "PageDown",
|
47
|
+
35: "End",
|
48
|
+
36: "Home",
|
49
|
+
37: "Left",
|
50
|
+
38: "Up",
|
51
|
+
39: "Right",
|
52
|
+
40: "Down",
|
53
|
+
45: "Insert",
|
54
|
+
46: "Del",
|
55
|
+
91: "Meta",
|
56
|
+
93: "Meta",
|
57
|
+
48: "0",
|
58
|
+
49: "1",
|
59
|
+
50: "2",
|
60
|
+
51: "3",
|
61
|
+
52: "4",
|
62
|
+
53: "5",
|
63
|
+
54: "6",
|
64
|
+
55: "7",
|
65
|
+
56: "8",
|
66
|
+
57: "9",
|
67
|
+
65: "A",
|
68
|
+
66: "B",
|
69
|
+
67: "C",
|
70
|
+
68: "D",
|
71
|
+
69: "E",
|
72
|
+
70: "F",
|
73
|
+
71: "G",
|
74
|
+
72: "H",
|
75
|
+
73: "I",
|
76
|
+
74: "J",
|
77
|
+
75: "K",
|
78
|
+
76: "L",
|
79
|
+
77: "M",
|
80
|
+
78: "N",
|
81
|
+
79: "O",
|
82
|
+
80: "P",
|
83
|
+
81: "Q",
|
84
|
+
82: "R",
|
85
|
+
83: "S",
|
86
|
+
84: "T",
|
87
|
+
85: "U",
|
88
|
+
86: "V",
|
89
|
+
87: "W",
|
90
|
+
88: "X",
|
91
|
+
89: "Y",
|
92
|
+
90: "Z",
|
93
|
+
96: "0",
|
94
|
+
97: "1",
|
95
|
+
98: "2",
|
96
|
+
99: "3",
|
97
|
+
100: "4",
|
98
|
+
101: "5",
|
99
|
+
102: "6",
|
100
|
+
103: "7",
|
101
|
+
104: "8",
|
102
|
+
105: "9",
|
103
|
+
106: "Multiply",
|
104
|
+
107: "Add",
|
105
|
+
109: "Subtract",
|
106
|
+
110: "Decimal",
|
107
|
+
111: "Divide",
|
108
|
+
112: "F1",
|
109
|
+
113: "F2",
|
110
|
+
114: "F3",
|
111
|
+
115: "F4",
|
112
|
+
116: "F5",
|
113
|
+
117: "F6",
|
114
|
+
118: "F7",
|
115
|
+
119: "F8",
|
116
|
+
120: "F9",
|
117
|
+
121: "F10",
|
118
|
+
122: "F11",
|
119
|
+
123: "F12",
|
120
|
+
124: "F13",
|
121
|
+
125: "F14",
|
122
|
+
126: "F15",
|
123
|
+
127: "F16",
|
124
|
+
128: "F17",
|
125
|
+
129: "F18",
|
126
|
+
130: "F19",
|
127
|
+
131: "F20",
|
128
|
+
132: "F21",
|
129
|
+
133: "F22",
|
130
|
+
134: "F23",
|
131
|
+
135: "F24",
|
132
|
+
59: ";",
|
133
|
+
61: "=",
|
134
|
+
186: ";",
|
135
|
+
187: "=",
|
136
|
+
188: ",",
|
137
|
+
190: ".",
|
138
|
+
191: "/",
|
139
|
+
192: "`",
|
140
|
+
219: "[",
|
141
|
+
220: "\\",
|
142
|
+
221: "]",
|
143
|
+
222: "'"
|
144
|
+
};
|
145
|
+
|
146
|
+
Hotkeys.aliases = {
|
147
|
+
"escape": "esc",
|
148
|
+
"delete": "del",
|
149
|
+
"return": "enter",
|
150
|
+
"ctrl": "control",
|
151
|
+
"space": "spacebar",
|
152
|
+
"ins": "insert",
|
153
|
+
"cmd": "meta",
|
154
|
+
"command": "meta",
|
155
|
+
"wins": "meta",
|
156
|
+
"windows": "meta"
|
157
|
+
};
|
158
|
+
|
159
|
+
Hotkeys.normalize = function(shortcut) {
|
160
|
+
var i, key, keyname, keys, _i, _len;
|
161
|
+
keys = shortcut.toLowerCase().replace(/\s+/gi, "").split("+");
|
162
|
+
for (i = _i = 0, _len = keys.length; _i < _len; i = ++_i) {
|
163
|
+
key = keys[i];
|
164
|
+
keys[i] = this.aliases[key] || key;
|
165
|
+
}
|
166
|
+
keyname = keys.pop();
|
167
|
+
keys.sort().push(keyname);
|
168
|
+
return keys.join("_");
|
169
|
+
};
|
170
|
+
|
171
|
+
Hotkeys.prototype.opts = {
|
172
|
+
el: document
|
173
|
+
};
|
174
|
+
|
175
|
+
Hotkeys.prototype._init = function() {
|
176
|
+
this.id = ++this.constructor.count;
|
177
|
+
this._map = {};
|
178
|
+
this._delegate = typeof this.opts.el === "string" ? document : this.opts.el;
|
179
|
+
return $(this._delegate).on("keydown.simple-hotkeys-" + this.id, this.opts.el, (function(_this) {
|
180
|
+
return function(e) {
|
181
|
+
var _ref;
|
182
|
+
return (_ref = _this._getHander(e)) != null ? _ref.call(_this, e) : void 0;
|
183
|
+
};
|
184
|
+
})(this));
|
185
|
+
};
|
186
|
+
|
187
|
+
Hotkeys.prototype._getHander = function(e) {
|
188
|
+
var keyname, shortcut;
|
189
|
+
if (!(keyname = this.constructor.keyNameMap[e.which])) {
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
shortcut = "";
|
193
|
+
if (e.altKey) {
|
194
|
+
shortcut += "alt_";
|
195
|
+
}
|
196
|
+
if (e.ctrlKey) {
|
197
|
+
shortcut += "control_";
|
198
|
+
}
|
199
|
+
if (e.metaKey) {
|
200
|
+
shortcut += "meta_";
|
201
|
+
}
|
202
|
+
if (e.shiftKey) {
|
203
|
+
shortcut += "shift_";
|
204
|
+
}
|
205
|
+
shortcut += keyname.toLowerCase();
|
206
|
+
return this._map[shortcut];
|
207
|
+
};
|
208
|
+
|
209
|
+
Hotkeys.prototype.respondTo = function(subject) {
|
210
|
+
if (typeof subject === 'string') {
|
211
|
+
return this._map[this.constructor.normalize(subject)] != null;
|
212
|
+
} else {
|
213
|
+
return this._getHander(subject) != null;
|
214
|
+
}
|
215
|
+
};
|
216
|
+
|
217
|
+
Hotkeys.prototype.add = function(shortcut, handler) {
|
218
|
+
this._map[this.constructor.normalize(shortcut)] = handler;
|
219
|
+
return this;
|
220
|
+
};
|
221
|
+
|
222
|
+
Hotkeys.prototype.remove = function(shortcut) {
|
223
|
+
delete this._map[this.constructor.normalize(shortcut)];
|
224
|
+
return this;
|
225
|
+
};
|
226
|
+
|
227
|
+
Hotkeys.prototype.destroy = function() {
|
228
|
+
$(this._delegate).off(".simple-hotkeys-" + this.id);
|
229
|
+
this._map = {};
|
230
|
+
return this;
|
231
|
+
};
|
232
|
+
|
233
|
+
return Hotkeys;
|
234
|
+
|
235
|
+
})(SimpleModule);
|
236
|
+
|
237
|
+
hotkeys = function(opts) {
|
238
|
+
return new Hotkeys(opts);
|
239
|
+
};
|
240
|
+
|
241
|
+
|
242
|
+
return hotkeys;
|
243
|
+
|
244
|
+
|
245
|
+
}));
|
246
|
+
|
@@ -0,0 +1,174 @@
|
|
1
|
+
(function (root, factory) {
|
2
|
+
if (typeof define === 'function' && define.amd) {
|
3
|
+
// AMD. Register as an anonymous module.
|
4
|
+
define('simple-module', ["jquery"], function ($) {
|
5
|
+
return (root.returnExportsGlobal = factory($));
|
6
|
+
});
|
7
|
+
} else if (typeof exports === 'object') {
|
8
|
+
// Node. Does not work with strict CommonJS, but
|
9
|
+
// only CommonJS-like enviroments that support module.exports,
|
10
|
+
// like Node.
|
11
|
+
module.exports = factory(require("jquery"));
|
12
|
+
} else {
|
13
|
+
root['SimpleModule'] = factory(jQuery);
|
14
|
+
}
|
15
|
+
}(this, function ($) {
|
16
|
+
|
17
|
+
var Module,
|
18
|
+
__slice = [].slice;
|
19
|
+
|
20
|
+
Module = (function() {
|
21
|
+
Module.extend = function(obj) {
|
22
|
+
var key, val, _ref;
|
23
|
+
if (!((obj != null) && typeof obj === 'object')) {
|
24
|
+
return;
|
25
|
+
}
|
26
|
+
for (key in obj) {
|
27
|
+
val = obj[key];
|
28
|
+
if (key !== 'included' && key !== 'extended') {
|
29
|
+
this[key] = val;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return (_ref = obj.extended) != null ? _ref.call(this) : void 0;
|
33
|
+
};
|
34
|
+
|
35
|
+
Module.include = function(obj) {
|
36
|
+
var key, val, _ref;
|
37
|
+
if (!((obj != null) && typeof obj === 'object')) {
|
38
|
+
return;
|
39
|
+
}
|
40
|
+
for (key in obj) {
|
41
|
+
val = obj[key];
|
42
|
+
if (key !== 'included' && key !== 'extended') {
|
43
|
+
this.prototype[key] = val;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
return (_ref = obj.included) != null ? _ref.call(this) : void 0;
|
47
|
+
};
|
48
|
+
|
49
|
+
Module.connect = function(cls) {
|
50
|
+
if (typeof cls !== 'function') {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
if (!cls.pluginName) {
|
54
|
+
throw new Error('Module.connect: cannot connect plugin without pluginName');
|
55
|
+
return;
|
56
|
+
}
|
57
|
+
cls.prototype._connected = true;
|
58
|
+
if (!this._connectedClasses) {
|
59
|
+
this._connectedClasses = [];
|
60
|
+
}
|
61
|
+
this._connectedClasses.push(cls);
|
62
|
+
if (cls.pluginName) {
|
63
|
+
return this[cls.pluginName] = cls;
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
Module.prototype.opts = {};
|
68
|
+
|
69
|
+
function Module(opts) {
|
70
|
+
var cls, instance, instances, name, _base, _i, _len;
|
71
|
+
this.opts = $.extend({}, this.opts, opts);
|
72
|
+
(_base = this.constructor)._connectedClasses || (_base._connectedClasses = []);
|
73
|
+
instances = (function() {
|
74
|
+
var _i, _len, _ref, _results;
|
75
|
+
_ref = this.constructor._connectedClasses;
|
76
|
+
_results = [];
|
77
|
+
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
78
|
+
cls = _ref[_i];
|
79
|
+
name = cls.pluginName.charAt(0).toLowerCase() + cls.pluginName.slice(1);
|
80
|
+
if (cls.prototype._connected) {
|
81
|
+
cls.prototype._module = this;
|
82
|
+
}
|
83
|
+
_results.push(this[name] = new cls());
|
84
|
+
}
|
85
|
+
return _results;
|
86
|
+
}).call(this);
|
87
|
+
if (this._connected) {
|
88
|
+
this.opts = $.extend({}, this.opts, this._module.opts);
|
89
|
+
} else {
|
90
|
+
this._init();
|
91
|
+
for (_i = 0, _len = instances.length; _i < _len; _i++) {
|
92
|
+
instance = instances[_i];
|
93
|
+
if (typeof instance._init === "function") {
|
94
|
+
instance._init();
|
95
|
+
}
|
96
|
+
}
|
97
|
+
}
|
98
|
+
this.trigger('initialized');
|
99
|
+
}
|
100
|
+
|
101
|
+
Module.prototype._init = function() {};
|
102
|
+
|
103
|
+
Module.prototype.on = function() {
|
104
|
+
var args, _ref;
|
105
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
106
|
+
(_ref = $(this)).on.apply(_ref, args);
|
107
|
+
return this;
|
108
|
+
};
|
109
|
+
|
110
|
+
Module.prototype.one = function() {
|
111
|
+
var args, _ref;
|
112
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
113
|
+
(_ref = $(this)).one.apply(_ref, args);
|
114
|
+
return this;
|
115
|
+
};
|
116
|
+
|
117
|
+
Module.prototype.off = function() {
|
118
|
+
var args, _ref;
|
119
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
120
|
+
(_ref = $(this)).off.apply(_ref, args);
|
121
|
+
return this;
|
122
|
+
};
|
123
|
+
|
124
|
+
Module.prototype.trigger = function() {
|
125
|
+
var args, _ref;
|
126
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
127
|
+
(_ref = $(this)).trigger.apply(_ref, args);
|
128
|
+
return this;
|
129
|
+
};
|
130
|
+
|
131
|
+
Module.prototype.triggerHandler = function() {
|
132
|
+
var args, _ref;
|
133
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
134
|
+
return (_ref = $(this)).triggerHandler.apply(_ref, args);
|
135
|
+
};
|
136
|
+
|
137
|
+
Module.prototype._t = function() {
|
138
|
+
var args, _ref;
|
139
|
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
140
|
+
return (_ref = this.constructor)._t.apply(_ref, args);
|
141
|
+
};
|
142
|
+
|
143
|
+
Module._t = function() {
|
144
|
+
var args, key, result, _ref;
|
145
|
+
key = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
146
|
+
result = ((_ref = this.i18n[this.locale]) != null ? _ref[key] : void 0) || '';
|
147
|
+
if (!(args.length > 0)) {
|
148
|
+
return result;
|
149
|
+
}
|
150
|
+
result = result.replace(/([^%]|^)%(?:(\d+)\$)?s/g, function(p0, p, position) {
|
151
|
+
if (position) {
|
152
|
+
return p + args[parseInt(position) - 1];
|
153
|
+
} else {
|
154
|
+
return p + args.shift();
|
155
|
+
}
|
156
|
+
});
|
157
|
+
return result.replace(/%%s/g, '%s');
|
158
|
+
};
|
159
|
+
|
160
|
+
Module.i18n = {
|
161
|
+
'zh-CN': {}
|
162
|
+
};
|
163
|
+
|
164
|
+
Module.locale = 'zh-CN';
|
165
|
+
|
166
|
+
return Module;
|
167
|
+
|
168
|
+
})();
|
169
|
+
|
170
|
+
|
171
|
+
return Module;
|
172
|
+
|
173
|
+
|
174
|
+
}));
|