simditor 2.2.2 → 2.2.3
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 +4 -4
- data/lib/simditor/version.rb +1 -1
- data/vendor/assets/javascripts/simditor/simditor.js +42 -33
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec61d0e7a6dd0c7dd0e645f8595398f1b030feb1
|
4
|
+
data.tar.gz: 2671a55ad34cc9a1887212d71cda892190516d0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2601e898469485b36a3e9d40aff91bb22d9c911f9e743ceafd9784086f767efa4c09ac244da12410face9d600af760b6a6819252531de81d55e8794ecf860b8
|
7
|
+
data.tar.gz: 997dc809b2c734a149870ac2dc64c21b9a6373f00652c913d133cf82287329c922c425e81f4bae3408dfcf6b3a4e49b643c97345ed5a50cc1c8f27dacda6f402
|
data/lib/simditor/version.rb
CHANGED
@@ -1,8 +1,3 @@
|
|
1
|
-
/*!
|
2
|
-
* Simditor v2.2.2
|
3
|
-
* http://simditor.tower.im/
|
4
|
-
* 2015-07-31
|
5
|
-
*/
|
6
1
|
(function (root, factory) {
|
7
2
|
if (typeof define === 'function' && define.amd) {
|
8
3
|
// AMD. Register as an anonymous module unless amdModuleId is set
|
@@ -1577,6 +1572,9 @@ UndoManager = (function(superClass) {
|
|
1577
1572
|
return;
|
1578
1573
|
}
|
1579
1574
|
html = this.editor.body.html();
|
1575
|
+
if (html !== currentState.html) {
|
1576
|
+
return;
|
1577
|
+
}
|
1580
1578
|
currentState.html = html;
|
1581
1579
|
return currentState.caret = this.caretPosition();
|
1582
1580
|
};
|
@@ -1669,11 +1667,7 @@ UndoManager = (function(superClass) {
|
|
1669
1667
|
} : {};
|
1670
1668
|
return caret;
|
1671
1669
|
} else {
|
1672
|
-
if (!this.editor.inputManager.focused) {
|
1673
|
-
this.editor.body.focus();
|
1674
|
-
}
|
1675
1670
|
if (!caret.start) {
|
1676
|
-
this.editor.body.blur();
|
1677
1671
|
return;
|
1678
1672
|
}
|
1679
1673
|
startContainer = this._getNodeByPosition(caret.start);
|
@@ -1985,7 +1979,7 @@ Toolbar = (function(superClass) {
|
|
1985
1979
|
};
|
1986
1980
|
|
1987
1981
|
Toolbar.prototype._init = function() {
|
1988
|
-
var toolbarHeight;
|
1982
|
+
var floatInitialized, initToolbarFloat, toolbarHeight;
|
1989
1983
|
this.editor = this._module;
|
1990
1984
|
if (!this.opts.toolbar) {
|
1991
1985
|
return;
|
@@ -2010,21 +2004,30 @@ Toolbar = (function(superClass) {
|
|
2010
2004
|
if (!this.opts.toolbarHidden && this.opts.toolbarFloat) {
|
2011
2005
|
this.wrapper.css('top', this.opts.toolbarFloatOffset);
|
2012
2006
|
toolbarHeight = 0;
|
2013
|
-
|
2014
|
-
return function(
|
2007
|
+
initToolbarFloat = (function(_this) {
|
2008
|
+
return function() {
|
2015
2009
|
_this.wrapper.css('position', 'static');
|
2016
2010
|
_this.wrapper.width('auto');
|
2017
2011
|
_this.editor.util.reflow(_this.wrapper);
|
2018
2012
|
_this.wrapper.width(_this.wrapper.outerWidth());
|
2019
|
-
_this.wrapper.css('left', _this.wrapper.offset().left);
|
2013
|
+
_this.wrapper.css('left', _this.editor.util.os.mobile ? _this.wrapper.position().left : _this.wrapper.offset().left);
|
2020
2014
|
_this.wrapper.css('position', '');
|
2021
2015
|
toolbarHeight = _this.wrapper.outerHeight();
|
2022
|
-
|
2016
|
+
_this.editor.placeholderEl.css('top', toolbarHeight);
|
2017
|
+
return true;
|
2023
2018
|
};
|
2024
|
-
})(this)
|
2019
|
+
})(this);
|
2020
|
+
$(window).on('resize.simditor-' + this.editor.id, function(e) {
|
2021
|
+
var floatInitialized;
|
2022
|
+
return floatInitialized = null;
|
2023
|
+
});
|
2024
|
+
floatInitialized = null;
|
2025
2025
|
$(window).on('scroll.simditor-' + this.editor.id, (function(_this) {
|
2026
2026
|
return function(e) {
|
2027
2027
|
var bottomEdge, scrollTop, topEdge;
|
2028
|
+
if (!_this.wrapper.is(':visible')) {
|
2029
|
+
return;
|
2030
|
+
}
|
2028
2031
|
topEdge = _this.editor.wrapper.offset().top;
|
2029
2032
|
bottomEdge = topEdge + _this.editor.wrapper.outerHeight() - 80;
|
2030
2033
|
scrollTop = $(document).scrollTop() + _this.opts.toolbarFloatOffset;
|
@@ -2034,6 +2037,7 @@ Toolbar = (function(superClass) {
|
|
2034
2037
|
return _this.wrapper.css('top', _this.opts.toolbarFloatOffset);
|
2035
2038
|
}
|
2036
2039
|
} else {
|
2040
|
+
floatInitialized || (floatInitialized = initToolbarFloat());
|
2037
2041
|
_this.editor.wrapper.addClass('toolbar-floating').css('padding-top', toolbarHeight);
|
2038
2042
|
if (_this.editor.util.os.mobile) {
|
2039
2043
|
return _this.wrapper.css('top', scrollTop - topEdge + _this.opts.toolbarFloatOffset);
|
@@ -2461,7 +2465,6 @@ Simditor = (function(superClass) {
|
|
2461
2465
|
};
|
2462
2466
|
|
2463
2467
|
Simditor.prototype.focus = function() {
|
2464
|
-
var $blockEl, range;
|
2465
2468
|
if (!(this.body.is(':visible') && this.body.is('[contenteditable]'))) {
|
2466
2469
|
this.el.find('textarea:visible').focus();
|
2467
2470
|
return;
|
@@ -2469,12 +2472,6 @@ Simditor = (function(superClass) {
|
|
2469
2472
|
if (this.inputManager.lastCaretPosition) {
|
2470
2473
|
return this.undoManager.caretPosition(this.inputManager.lastCaretPosition);
|
2471
2474
|
} else {
|
2472
|
-
$blockEl = this.body.find('p').last();
|
2473
|
-
if (!($blockEl.length > 0)) {
|
2474
|
-
$blockEl = $('<p/>').append(this.util.phBr).appendTo(this.body);
|
2475
|
-
}
|
2476
|
-
range = document.createRange();
|
2477
|
-
this.selection.setRangeAtEndOf($blockEl, range);
|
2478
2475
|
return this.body.focus();
|
2479
2476
|
}
|
2480
2477
|
};
|
@@ -2518,6 +2515,7 @@ Simditor.i18n = {
|
|
2518
2515
|
'bold': '加粗文字',
|
2519
2516
|
'code': '插入代码',
|
2520
2517
|
'color': '文字颜色',
|
2518
|
+
'coloredText': '彩色文字',
|
2521
2519
|
'hr': '分隔线',
|
2522
2520
|
'image': '插入图片',
|
2523
2521
|
'externalImage': '外链图片',
|
@@ -2562,6 +2560,7 @@ Simditor.i18n = {
|
|
2562
2560
|
'bold': 'Bold',
|
2563
2561
|
'code': 'Code',
|
2564
2562
|
'color': 'Text Color',
|
2563
|
+
'coloredText': 'Colored Text',
|
2565
2564
|
'hr': 'Horizontal Line',
|
2566
2565
|
'image': 'Insert Image',
|
2567
2566
|
'externalImage': 'External Image',
|
@@ -3222,7 +3221,7 @@ ColorButton = (function(superClass) {
|
|
3222
3221
|
});
|
3223
3222
|
return this.menuWrapper.on('click', '.font-color', (function(_this) {
|
3224
3223
|
return function(e) {
|
3225
|
-
var $link, $p, hex, rgb;
|
3224
|
+
var $link, $p, hex, range, rgb, textNode;
|
3226
3225
|
_this.wrapper.removeClass('menu-on');
|
3227
3226
|
$link = $(e.currentTarget);
|
3228
3227
|
if ($link.hasClass('font-color-default')) {
|
@@ -3239,6 +3238,13 @@ ColorButton = (function(superClass) {
|
|
3239
3238
|
if (!hex) {
|
3240
3239
|
return;
|
3241
3240
|
}
|
3241
|
+
range = _this.editor.selection.range();
|
3242
|
+
if (!$link.hasClass('font-color-default') && range.collapsed) {
|
3243
|
+
textNode = document.createTextNode(_this._t('coloredText'));
|
3244
|
+
range.insertNode(textNode);
|
3245
|
+
range.selectNodeContents(textNode);
|
3246
|
+
_this.editor.selection.range(range);
|
3247
|
+
}
|
3242
3248
|
document.execCommand('styleWithCSS', false, true);
|
3243
3249
|
document.execCommand('foreColor', false, hex);
|
3244
3250
|
document.execCommand('styleWithCSS', false, false);
|
@@ -4270,12 +4276,13 @@ ImagePopover = (function(superClass) {
|
|
4270
4276
|
this.altEl = this.el.find('#image-alt');
|
4271
4277
|
this.srcEl.on('keydown', (function(_this) {
|
4272
4278
|
return function(e) {
|
4279
|
+
var range;
|
4273
4280
|
if (!(e.which === 13 && !_this.target.hasClass('uploading'))) {
|
4274
4281
|
return;
|
4275
4282
|
}
|
4276
4283
|
e.preventDefault();
|
4277
|
-
|
4278
|
-
_this.button.editor.selection.setRangeAfter(_this.target);
|
4284
|
+
range = document.createRange();
|
4285
|
+
_this.button.editor.selection.setRangeAfter(_this.target, range);
|
4279
4286
|
return _this.hide();
|
4280
4287
|
};
|
4281
4288
|
})(this));
|
@@ -4301,7 +4308,7 @@ ImagePopover = (function(superClass) {
|
|
4301
4308
|
})(this));
|
4302
4309
|
this.el.find('.image-size').on('keydown', (function(_this) {
|
4303
4310
|
return function(e) {
|
4304
|
-
var inputEl;
|
4311
|
+
var $img, inputEl, range;
|
4305
4312
|
inputEl = $(e.currentTarget);
|
4306
4313
|
if (e.which === 13 || e.which === 27) {
|
4307
4314
|
e.preventDefault();
|
@@ -4310,9 +4317,10 @@ ImagePopover = (function(superClass) {
|
|
4310
4317
|
} else {
|
4311
4318
|
_this._restoreImg();
|
4312
4319
|
}
|
4313
|
-
_this.
|
4314
|
-
_this.
|
4315
|
-
|
4320
|
+
$img = _this.target;
|
4321
|
+
_this.hide();
|
4322
|
+
range = document.createRange();
|
4323
|
+
return _this.button.editor.selection.setRangeAfter($img, range);
|
4316
4324
|
} else if (e.which === 9) {
|
4317
4325
|
return _this.el.data('popover').refresh();
|
4318
4326
|
}
|
@@ -4320,10 +4328,11 @@ ImagePopover = (function(superClass) {
|
|
4320
4328
|
})(this));
|
4321
4329
|
this.altEl.on('keydown', (function(_this) {
|
4322
4330
|
return function(e) {
|
4331
|
+
var range;
|
4323
4332
|
if (e.which === 13) {
|
4324
4333
|
e.preventDefault();
|
4325
|
-
|
4326
|
-
_this.button.editor.selection.setRangeAfter(_this.target);
|
4334
|
+
range = document.createRange();
|
4335
|
+
_this.button.editor.selection.setRangeAfter(_this.target, range);
|
4327
4336
|
return _this.hide();
|
4328
4337
|
}
|
4329
4338
|
};
|
@@ -4393,7 +4402,7 @@ ImagePopover = (function(superClass) {
|
|
4393
4402
|
onlySetVal = false;
|
4394
4403
|
}
|
4395
4404
|
value = inputEl.val() * 1;
|
4396
|
-
if (!($.isNumeric(value) || value < 0)) {
|
4405
|
+
if (!(this.target && ($.isNumeric(value) || value < 0))) {
|
4397
4406
|
return;
|
4398
4407
|
}
|
4399
4408
|
if (inputEl.is(this.widthEl)) {
|
@@ -4410,8 +4419,8 @@ ImagePopover = (function(superClass) {
|
|
4410
4419
|
width: width,
|
4411
4420
|
height: height
|
4412
4421
|
});
|
4422
|
+
return this.editor.trigger('valuechanged');
|
4413
4423
|
}
|
4414
|
-
return this.editor.trigger('valuechanged');
|
4415
4424
|
};
|
4416
4425
|
|
4417
4426
|
ImagePopover.prototype._restoreImg = function() {
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simditor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wentao Liu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails assets wrapper for https://github.com/mycolorway/simditor
|
14
14
|
email:
|