simditor 2.1.11.0 → 2.1.13.0
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 +169 -88
- data/vendor/assets/stylesheets/simditor/editor.scss +19 -10
- 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: 6a1eab9b36be1a087a73d9dfc94ff617e8c3f87e
|
4
|
+
data.tar.gz: 91deabc3ffb2d1562ad388904c2e10bb1523a7f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0d471b2eeb0efd1914186a03c23982ed7502d5901ffc2a79d75b33afa0300a75bcb7269efd4581772ecb83e9eca3f3e4e12f4434c0257b89df91f71c134c321
|
7
|
+
data.tar.gz: 9c6671b4e293d12498cf39ce105a305148705b0ceb69159ad5f35151a984983d2c876256ef1c5254dfe8b5f84a8ee612cac62d138e9146840daaca207bbe38c6
|
data/lib/simditor/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
/*!
|
2
|
-
* Simditor v2.1.
|
2
|
+
* Simditor v2.1.13
|
3
3
|
* http://simditor.tower.im/
|
4
|
-
* 2015-
|
4
|
+
* 2015-09-06
|
5
5
|
*/
|
6
6
|
(function (root, factory) {
|
7
7
|
if (typeof define === 'function' && define.amd) {
|
@@ -322,12 +322,13 @@ Formatter = (function(superClass) {
|
|
322
322
|
|
323
323
|
Formatter.prototype._init = function() {
|
324
324
|
this.editor = this._module;
|
325
|
-
this._allowedTags = this.opts.allowedTags || ['br', 'a', 'img', 'b', 'strong', 'i', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'h1', 'h2', 'h3', 'h4', 'hr'];
|
325
|
+
this._allowedTags = this.opts.allowedTags || ['br', 'a', 'img', 'b', 'strong', 'i', 'u', 'font', 'p', 'ul', 'ol', 'li', 'blockquote', 'pre', 'code', 'h1', 'h2', 'h3', 'h4', 'hr'];
|
326
326
|
this._allowedAttributes = this.opts.allowedAttributes || {
|
327
327
|
img: ['src', 'alt', 'width', 'height', 'data-image-src', 'data-image-size', 'data-image-name', 'data-non-image'],
|
328
328
|
a: ['href', 'target'],
|
329
329
|
font: ['color'],
|
330
|
-
pre: ['data-lang'
|
330
|
+
pre: ['data-lang'],
|
331
|
+
code: ['class'],
|
331
332
|
p: ['data-indent', 'data-align'],
|
332
333
|
h1: ['data-indent'],
|
333
334
|
h2: ['data-indent'],
|
@@ -680,7 +681,7 @@ InputManager = (function(superClass) {
|
|
680
681
|
return false;
|
681
682
|
};
|
682
683
|
})(this));
|
683
|
-
this.addShortcut('cmd+a', (function(_this) {
|
684
|
+
this.addShortcut((this.editor.util.os.mac ? 'cmd+a' : 'ctrl+a'), (function(_this) {
|
684
685
|
return function(e) {
|
685
686
|
var $children, firstBlock, lastBlock, range;
|
686
687
|
$children = _this.editor.body.children();
|
@@ -2066,7 +2067,7 @@ Indentation = (function(superClass) {
|
|
2066
2067
|
};
|
2067
2068
|
|
2068
2069
|
Indentation.prototype.indentBlock = function(blockEl) {
|
2069
|
-
var $blockEl, $childList, $nextTd, $parentLi, $pre, $td, indentLevel, range, tagName;
|
2070
|
+
var $blockEl, $childList, $nextTd, $nextTr, $parentLi, $pre, $td, $tr, indentLevel, range, tagName;
|
2070
2071
|
$blockEl = $(blockEl);
|
2071
2072
|
if (!$blockEl.length) {
|
2072
2073
|
return;
|
@@ -2098,10 +2099,15 @@ Indentation = (function(superClass) {
|
|
2098
2099
|
$blockEl.attr('data-indent', indentLevel);
|
2099
2100
|
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
|
2100
2101
|
range = this.editor.selection.getRange();
|
2101
|
-
$td = $(range.commonAncestorContainer).closest('td');
|
2102
|
-
$nextTd = $td.next('td');
|
2102
|
+
$td = $(range.commonAncestorContainer).closest('td, th');
|
2103
|
+
$nextTd = $td.next('td, th');
|
2103
2104
|
if (!($nextTd.length > 0)) {
|
2104
|
-
$
|
2105
|
+
$tr = $td.parent('tr');
|
2106
|
+
$nextTr = $tr.next('tr');
|
2107
|
+
if ($nextTr.length < 1 && $tr.parent().is('thead')) {
|
2108
|
+
$nextTr = $tr.parent('thead').next('tbody').find('tr:first');
|
2109
|
+
}
|
2110
|
+
$nextTd = $nextTr.find('td:first, th:first');
|
2105
2111
|
}
|
2106
2112
|
if (!($td.length > 0 && $nextTd.length > 0)) {
|
2107
2113
|
return false;
|
@@ -2126,7 +2132,7 @@ Indentation = (function(superClass) {
|
|
2126
2132
|
};
|
2127
2133
|
|
2128
2134
|
Indentation.prototype.outdentBlock = function(blockEl) {
|
2129
|
-
var $blockEl, $parent, $parentLi, $pre, $prevTd, $td, button, indentLevel, range, ref;
|
2135
|
+
var $blockEl, $parent, $parentLi, $pre, $prevTd, $prevTr, $td, $tr, button, indentLevel, range, ref;
|
2130
2136
|
$blockEl = $(blockEl);
|
2131
2137
|
if (!($blockEl && $blockEl.length > 0)) {
|
2132
2138
|
return;
|
@@ -2166,10 +2172,15 @@ Indentation = (function(superClass) {
|
|
2166
2172
|
$blockEl.attr('data-indent', indentLevel);
|
2167
2173
|
} else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
|
2168
2174
|
range = this.editor.selection.getRange();
|
2169
|
-
$td = $(range.commonAncestorContainer).closest('td');
|
2170
|
-
$prevTd = $td.prev('td');
|
2175
|
+
$td = $(range.commonAncestorContainer).closest('td, th');
|
2176
|
+
$prevTd = $td.prev('td, th');
|
2171
2177
|
if (!($prevTd.length > 0)) {
|
2172
|
-
$
|
2178
|
+
$tr = $td.parent('tr');
|
2179
|
+
$prevTr = $tr.prev('tr');
|
2180
|
+
if ($prevTr.length < 1 && $tr.parent().is('tbody')) {
|
2181
|
+
$prevTr = $tr.parent('tbody').prev('thead').find('tr:first');
|
2182
|
+
}
|
2183
|
+
$prevTd = $prevTr.find('td:last, th:last');
|
2173
2184
|
}
|
2174
2185
|
if (!($td.length > 0 && $prevTd.length > 0)) {
|
2175
2186
|
return;
|
@@ -2448,10 +2459,11 @@ Simditor.i18n = {
|
|
2448
2459
|
'title': '标题',
|
2449
2460
|
'normalText': '普通文本',
|
2450
2461
|
'underline': '下划线文字',
|
2451
|
-
'alignment': '
|
2462
|
+
'alignment': '水平对齐',
|
2452
2463
|
'alignCenter': '居中',
|
2453
2464
|
'alignLeft': '居左',
|
2454
|
-
'alignRight': '居右'
|
2465
|
+
'alignRight': '居右',
|
2466
|
+
'selectLanguage': '选择程序语言'
|
2455
2467
|
}
|
2456
2468
|
};
|
2457
2469
|
|
@@ -3498,21 +3510,25 @@ CodeButton = (function(superClass) {
|
|
3498
3510
|
};
|
3499
3511
|
|
3500
3512
|
CodeButton.prototype.decorate = function($pre) {
|
3501
|
-
var lang;
|
3502
|
-
|
3503
|
-
$
|
3504
|
-
|
3505
|
-
|
3513
|
+
var $code, lang, ref, ref1;
|
3514
|
+
$code = $pre.find('> code');
|
3515
|
+
if ($code.length > 0) {
|
3516
|
+
lang = (ref = $code.attr('class')) != null ? (ref1 = ref.match(/lang-(\S+)/)) != null ? ref1[1] : void 0 : void 0;
|
3517
|
+
$code.contents().unwrap();
|
3518
|
+
if (lang) {
|
3519
|
+
return $pre.attr('data-lang', lang);
|
3520
|
+
}
|
3506
3521
|
}
|
3507
3522
|
};
|
3508
3523
|
|
3509
3524
|
CodeButton.prototype.undecorate = function($pre) {
|
3510
|
-
var lang;
|
3525
|
+
var $code, lang;
|
3511
3526
|
lang = $pre.attr('data-lang');
|
3512
|
-
$
|
3527
|
+
$code = $('<code/>');
|
3513
3528
|
if (lang && lang !== -1) {
|
3514
|
-
|
3529
|
+
$code.addClass('lang-' + lang);
|
3515
3530
|
}
|
3531
|
+
return $pre.wrapInner($code).removeAttr('data-lang');
|
3516
3532
|
};
|
3517
3533
|
|
3518
3534
|
CodeButton.prototype.command = function() {
|
@@ -3581,9 +3597,8 @@ CodePopover = (function(superClass) {
|
|
3581
3597
|
return CodePopover.__super__.constructor.apply(this, arguments);
|
3582
3598
|
}
|
3583
3599
|
|
3584
|
-
CodePopover.prototype._tpl = "<div class=\"code-settings\">\n <div class=\"settings-field\">\n <select class=\"select-lang\">\n <option value=\"-1\">选择程序语言</option>\n <option value=\"bash\">Bash</option>\n <option value=\"c++\">C++</option>\n <option value=\"cs\">C#</option>\n <option value=\"css\">CSS</option>\n <option value=\"erlang\">Erlang</option>\n <option value=\"less\">Less</option>\n <option value=\"scss\">Sass</option>\n <option value=\"diff\">Diff</option>\n <option value=\"coffeeScript\">CoffeeScript</option>\n <option value=\"html\">Html,XML</option>\n <option value=\"json\">JSON</option>\n <option value=\"java\">Java</option>\n <option value=\"js\">JavaScript</option>\n <option value=\"markdown\">Markdown</option>\n <option value=\"oc\">Objective C</option>\n <option value=\"php\">PHP</option>\n <option value=\"perl\">Perl</option>\n <option value=\"python\">Python</option>\n <option value=\"ruby\">Ruby</option>\n <option value=\"sql\">SQL</option>\n </select>\n </div>\n</div>";
|
3585
|
-
|
3586
3600
|
CodePopover.prototype.render = function() {
|
3601
|
+
this._tpl = "<div class=\"code-settings\">\n <div class=\"settings-field\">\n <select class=\"select-lang\">\n <option value=\"-1\">" + (this._t('selectLanguage')) + "</option>\n <option value=\"bash\">Bash</option>\n <option value=\"c++\">C++</option>\n <option value=\"cs\">C#</option>\n <option value=\"css\">CSS</option>\n <option value=\"erlang\">Erlang</option>\n <option value=\"less\">Less</option>\n <option value=\"scss\">Sass</option>\n <option value=\"diff\">Diff</option>\n <option value=\"coffeeScript\">CoffeeScript</option>\n <option value=\"html\">Html,XML</option>\n <option value=\"json\">JSON</option>\n <option value=\"java\">Java</option>\n <option value=\"js\">JavaScript</option>\n <option value=\"markdown\">Markdown</option>\n <option value=\"oc\">Objective C</option>\n <option value=\"php\">PHP</option>\n <option value=\"perl\">Perl</option>\n <option value=\"python\">Python</option>\n <option value=\"ruby\">Ruby</option>\n <option value=\"sql\">SQL</option>\n </select>\n </div>\n</div>";
|
3587
3602
|
this.el.addClass('code-popover').append(this._tpl);
|
3588
3603
|
this.selectEl = this.el.find('.select-lang');
|
3589
3604
|
this.selectEl.on('change', (function(_this) {
|
@@ -3593,7 +3608,6 @@ CodePopover = (function(superClass) {
|
|
3593
3608
|
selected = _this.target.hasClass('selected');
|
3594
3609
|
_this.target.removeClass().removeAttr('data-lang');
|
3595
3610
|
if (_this.lang !== -1) {
|
3596
|
-
_this.target.addClass('lang-' + _this.lang);
|
3597
3611
|
_this.target.attr('data-lang', _this.lang);
|
3598
3612
|
}
|
3599
3613
|
if (selected) {
|
@@ -4581,7 +4595,7 @@ TableButton = (function(superClass) {
|
|
4581
4595
|
|
4582
4596
|
TableButton.prototype._init = function() {
|
4583
4597
|
TableButton.__super__._init.call(this);
|
4584
|
-
$.merge(this.editor.formatter._allowedTags, ['tbody', 'tr', 'td', 'colgroup', 'col']);
|
4598
|
+
$.merge(this.editor.formatter._allowedTags, ['thead', 'th', 'tbody', 'tr', 'td', 'colgroup', 'col']);
|
4585
4599
|
$.extend(this.editor.formatter._allowedAttributes, {
|
4586
4600
|
td: ['rowspan', 'colspan'],
|
4587
4601
|
col: ['width']
|
@@ -4604,7 +4618,7 @@ TableButton = (function(superClass) {
|
|
4604
4618
|
this.editor.on('selectionchanged.table', (function(_this) {
|
4605
4619
|
return function(e) {
|
4606
4620
|
var $container, range;
|
4607
|
-
_this.editor.body.find('.simditor-table td').removeClass('active');
|
4621
|
+
_this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active');
|
4608
4622
|
range = _this.editor.selection.getRange();
|
4609
4623
|
if (range == null) {
|
4610
4624
|
return;
|
@@ -4612,55 +4626,87 @@ TableButton = (function(superClass) {
|
|
4612
4626
|
$container = $(range.commonAncestorContainer);
|
4613
4627
|
if (range.collapsed && $container.is('.simditor-table')) {
|
4614
4628
|
if (_this.editor.selection.rangeAtStartOf($container)) {
|
4615
|
-
$container = $container.find('
|
4629
|
+
$container = $container.find('th:first');
|
4616
4630
|
} else {
|
4617
4631
|
$container = $container.find('td:last');
|
4618
4632
|
}
|
4619
4633
|
_this.editor.selection.setRangeAtEndOf($container);
|
4620
4634
|
}
|
4621
|
-
return $container.closest('td', _this.editor.body).addClass('active');
|
4635
|
+
return $container.closest('td, th', _this.editor.body).addClass('active');
|
4622
4636
|
};
|
4623
4637
|
})(this));
|
4624
4638
|
this.editor.on('blur.table', (function(_this) {
|
4625
4639
|
return function(e) {
|
4626
|
-
return _this.editor.body.find('.simditor-table td').removeClass('active');
|
4640
|
+
return _this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active');
|
4627
4641
|
};
|
4628
4642
|
})(this));
|
4629
4643
|
this.editor.inputManager.addKeystrokeHandler('38', 'td', (function(_this) {
|
4630
4644
|
return function(e, $node) {
|
4631
|
-
|
4632
|
-
$tr = $node.parent('tr');
|
4633
|
-
$prevTr = $tr.prev('tr');
|
4634
|
-
if (!($prevTr.length > 0)) {
|
4635
|
-
return true;
|
4636
|
-
}
|
4637
|
-
index = $tr.find('td').index($node);
|
4638
|
-
_this.editor.selection.setRangeAtEndOf($prevTr.find('td').eq(index));
|
4645
|
+
_this._tdNav($node, 'up');
|
4639
4646
|
return true;
|
4640
4647
|
};
|
4641
4648
|
})(this));
|
4642
|
-
|
4649
|
+
this.editor.inputManager.addKeystrokeHandler('38', 'th', (function(_this) {
|
4643
4650
|
return function(e, $node) {
|
4644
|
-
|
4645
|
-
|
4646
|
-
|
4647
|
-
|
4648
|
-
|
4649
|
-
|
4650
|
-
|
4651
|
-
|
4651
|
+
_this._tdNav($node, 'up');
|
4652
|
+
return true;
|
4653
|
+
};
|
4654
|
+
})(this));
|
4655
|
+
this.editor.inputManager.addKeystrokeHandler('40', 'td', (function(_this) {
|
4656
|
+
return function(e, $node) {
|
4657
|
+
_this._tdNav($node, 'down');
|
4658
|
+
return true;
|
4659
|
+
};
|
4660
|
+
})(this));
|
4661
|
+
return this.editor.inputManager.addKeystrokeHandler('40', 'th', (function(_this) {
|
4662
|
+
return function(e, $node) {
|
4663
|
+
_this._tdNav($node, 'down');
|
4652
4664
|
return true;
|
4653
4665
|
};
|
4654
4666
|
})(this));
|
4655
4667
|
};
|
4656
4668
|
|
4669
|
+
TableButton.prototype._tdNav = function($td, direction) {
|
4670
|
+
var $anotherTr, $tr, action, anotherTag, index, parentTag, ref;
|
4671
|
+
if (direction == null) {
|
4672
|
+
direction = 'up';
|
4673
|
+
}
|
4674
|
+
action = direction === 'up' ? 'prev' : 'next';
|
4675
|
+
ref = direction === 'up' ? ['tbody', 'thead'] : ['thead', 'tbody'], parentTag = ref[0], anotherTag = ref[1];
|
4676
|
+
$tr = $td.parent('tr');
|
4677
|
+
$anotherTr = this["_" + action + "Row"]($tr);
|
4678
|
+
if (!($anotherTr.length > 0)) {
|
4679
|
+
return true;
|
4680
|
+
}
|
4681
|
+
index = $tr.find('td, th').index($td);
|
4682
|
+
return this.editor.selection.setRangeAtEndOf($anotherTr.find('td, th').eq(index));
|
4683
|
+
};
|
4684
|
+
|
4685
|
+
TableButton.prototype._nextRow = function($tr) {
|
4686
|
+
var $nextTr;
|
4687
|
+
$nextTr = $tr.next('tr');
|
4688
|
+
if ($nextTr.length < 1 && $tr.parent('thead').length > 0) {
|
4689
|
+
$nextTr = $tr.parent('thead').next('tbody').find('tr:first');
|
4690
|
+
}
|
4691
|
+
return $nextTr;
|
4692
|
+
};
|
4693
|
+
|
4694
|
+
TableButton.prototype._prevRow = function($tr) {
|
4695
|
+
var $prevTr;
|
4696
|
+
$prevTr = $tr.prev('tr');
|
4697
|
+
if ($prevTr.length < 1 && $tr.parent('tbody').length > 0) {
|
4698
|
+
$prevTr = $tr.parent('tbody').prev('thead').find('tr');
|
4699
|
+
}
|
4700
|
+
return $prevTr;
|
4701
|
+
};
|
4702
|
+
|
4657
4703
|
TableButton.prototype.initResize = function($table) {
|
4658
4704
|
var $colgroup, $resizeHandle, $wrapper;
|
4659
4705
|
$wrapper = $table.parent('.simditor-table');
|
4660
4706
|
$colgroup = $table.find('colgroup');
|
4661
4707
|
if ($colgroup.length < 1) {
|
4662
4708
|
$colgroup = $('<colgroup/>').prependTo($table);
|
4663
|
-
$table.find('tr
|
4709
|
+
$table.find('thead tr th').each((function(_this) {
|
4664
4710
|
return function(i, td) {
|
4665
4711
|
var $col;
|
4666
4712
|
return $col = $('<col/>').appendTo($colgroup);
|
@@ -4669,7 +4715,7 @@ TableButton = (function(superClass) {
|
|
4669
4715
|
this.refreshTableWidth($table);
|
4670
4716
|
}
|
4671
4717
|
$resizeHandle = $('<div class="simditor-resize-handle" contenteditable="false"></div>').appendTo($wrapper);
|
4672
|
-
$wrapper.on('mousemove', 'td', (function(_this) {
|
4718
|
+
$wrapper.on('mousemove', 'td, th', (function(_this) {
|
4673
4719
|
return function(e) {
|
4674
4720
|
var $col, $td, index, ref, ref1, x;
|
4675
4721
|
if ($wrapper.hasClass('resizing')) {
|
@@ -4680,7 +4726,7 @@ TableButton = (function(superClass) {
|
|
4680
4726
|
if (x < 5 && $td.prev().length > 0) {
|
4681
4727
|
$td = $td.prev();
|
4682
4728
|
}
|
4683
|
-
if ($td.next('td').length < 1) {
|
4729
|
+
if ($td.next('td, th').length < 1) {
|
4684
4730
|
$resizeHandle.hide();
|
4685
4731
|
return;
|
4686
4732
|
}
|
@@ -4688,7 +4734,7 @@ TableButton = (function(superClass) {
|
|
4688
4734
|
$resizeHandle.show();
|
4689
4735
|
return;
|
4690
4736
|
}
|
4691
|
-
index = $td.parent().find('td').index($td);
|
4737
|
+
index = $td.parent().find('td, th').index($td);
|
4692
4738
|
$col = $colgroup.find('col').eq(index);
|
4693
4739
|
if ((ref1 = $resizeHandle.data('col')) != null ? ref1.is($col) : void 0) {
|
4694
4740
|
$resizeHandle.show();
|
@@ -4708,7 +4754,7 @@ TableButton = (function(superClass) {
|
|
4708
4754
|
$handle = $(e.currentTarget);
|
4709
4755
|
$leftTd = $handle.data('td');
|
4710
4756
|
$leftCol = $handle.data('col');
|
4711
|
-
$rightTd = $leftTd.next('td');
|
4757
|
+
$rightTd = $leftTd.next('td, th');
|
4712
4758
|
$rightCol = $leftCol.next('col');
|
4713
4759
|
startX = e.pageX;
|
4714
4760
|
startLeftWidth = $leftTd.outerWidth() * 1;
|
@@ -4788,28 +4834,33 @@ TableButton = (function(superClass) {
|
|
4788
4834
|
};
|
4789
4835
|
|
4790
4836
|
TableButton.prototype.renderMenu = function() {
|
4837
|
+
var $table;
|
4791
4838
|
$("<div class=\"menu-create-table\">\n</div>\n<div class=\"menu-edit-table\">\n <ul>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"deleteRow\"><span>" + (this._t('deleteRow')) + "</span></a></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"insertRowAbove\"><span>" + (this._t('insertRowAbove')) + " ( Ctrl + Alt + ↑ )</span></a></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"insertRowBelow\"><span>" + (this._t('insertRowBelow')) + " ( Ctrl + Alt + ↓ )</span></a></li>\n <li><span class=\"separator\"></span></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"deleteCol\"><span>" + (this._t('deleteColumn')) + "</span></a></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"insertColLeft\"><span>" + (this._t('insertColumnLeft')) + " ( Ctrl + Alt + ← )</span></a></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"insertColRight\"><span>" + (this._t('insertColumnRight')) + " ( Ctrl + Alt + → )</span></a></li>\n <li><span class=\"separator\"></span></li>\n <li><a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\" href=\"javascript:;\" data-param=\"deleteTable\"><span>" + (this._t('deleteTable')) + "</span></a></li>\n </ul>\n</div>").appendTo(this.menuWrapper);
|
4792
4839
|
this.createMenu = this.menuWrapper.find('.menu-create-table');
|
4793
4840
|
this.editMenu = this.menuWrapper.find('.menu-edit-table');
|
4794
|
-
this.createTable(6, 6).appendTo(this.createMenu);
|
4795
|
-
this.createMenu.on('mouseenter', 'td', (function(_this) {
|
4841
|
+
$table = this.createTable(6, 6).appendTo(this.createMenu);
|
4842
|
+
this.createMenu.on('mouseenter', 'td, th', (function(_this) {
|
4796
4843
|
return function(e) {
|
4797
|
-
var $td, $tr, num;
|
4798
|
-
_this.createMenu.find('td').removeClass('selected');
|
4844
|
+
var $td, $tr, $trs, num;
|
4845
|
+
_this.createMenu.find('td, th').removeClass('selected');
|
4799
4846
|
$td = $(e.currentTarget);
|
4800
4847
|
$tr = $td.parent();
|
4801
|
-
num = $tr.find('td').index($td) + 1;
|
4802
|
-
|
4848
|
+
num = $tr.find('td, th').index($td) + 1;
|
4849
|
+
$trs = $tr.prevAll('tr').addBack();
|
4850
|
+
if ($tr.parent().is('tbody')) {
|
4851
|
+
$trs = $trs.add($table.find('thead tr'));
|
4852
|
+
}
|
4853
|
+
return $trs.find("td:lt(" + num + "), th:lt(" + num + ")").addClass('selected');
|
4803
4854
|
};
|
4804
4855
|
})(this));
|
4805
4856
|
this.createMenu.on('mouseleave', (function(_this) {
|
4806
4857
|
return function(e) {
|
4807
|
-
return $(e.currentTarget).find('td').removeClass('selected');
|
4858
|
+
return $(e.currentTarget).find('td, th').removeClass('selected');
|
4808
4859
|
};
|
4809
4860
|
})(this));
|
4810
|
-
return this.createMenu.on('mousedown', 'td', (function(_this) {
|
4861
|
+
return this.createMenu.on('mousedown', 'td, th', (function(_this) {
|
4811
4862
|
return function(e) {
|
4812
|
-
var $closestBlock, $
|
4863
|
+
var $closestBlock, $td, $tr, colNum, rowNum;
|
4813
4864
|
_this.wrapper.removeClass('menu-on');
|
4814
4865
|
if (!_this.editor.inputManager.focused) {
|
4815
4866
|
return;
|
@@ -4818,6 +4869,9 @@ TableButton = (function(superClass) {
|
|
4818
4869
|
$tr = $td.parent();
|
4819
4870
|
colNum = $tr.find('td').index($td) + 1;
|
4820
4871
|
rowNum = $tr.prevAll('tr').length + 1;
|
4872
|
+
if ($tr.parent().is('tbody')) {
|
4873
|
+
rowNum += 1;
|
4874
|
+
}
|
4821
4875
|
$table = _this.createTable(rowNum, colNum, true);
|
4822
4876
|
$closestBlock = _this.editor.util.closestBlockEl();
|
4823
4877
|
if (_this.editor.util.isEmptyNode($closestBlock)) {
|
@@ -4826,7 +4880,7 @@ TableButton = (function(superClass) {
|
|
4826
4880
|
$closestBlock.after($table);
|
4827
4881
|
}
|
4828
4882
|
_this.decorate($table);
|
4829
|
-
_this.editor.selection.setRangeAtStartOf($table.find('
|
4883
|
+
_this.editor.selection.setRangeAtStartOf($table.find('th:first'));
|
4830
4884
|
_this.editor.trigger('valuechanged');
|
4831
4885
|
return false;
|
4832
4886
|
};
|
@@ -4834,13 +4888,15 @@ TableButton = (function(superClass) {
|
|
4834
4888
|
};
|
4835
4889
|
|
4836
4890
|
TableButton.prototype.createTable = function(row, col, phBr) {
|
4837
|
-
var $table, $tbody, $td, $tr, c, j, k, r, ref, ref1;
|
4891
|
+
var $table, $tbody, $td, $thead, $tr, c, j, k, r, ref, ref1;
|
4838
4892
|
$table = $('<table/>');
|
4893
|
+
$thead = $('<thead/>').appendTo($table);
|
4839
4894
|
$tbody = $('<tbody/>').appendTo($table);
|
4840
4895
|
for (r = j = 0, ref = row; 0 <= ref ? j < ref : j > ref; r = 0 <= ref ? ++j : --j) {
|
4841
|
-
$tr = $('<tr/>')
|
4896
|
+
$tr = $('<tr/>');
|
4897
|
+
$tr.appendTo(r === 0 ? $thead : $tbody);
|
4842
4898
|
for (c = k = 0, ref1 = col; 0 <= ref1 ? k < ref1 : k > ref1; c = 0 <= ref1 ? ++k : --k) {
|
4843
|
-
$td = $('<td/>').appendTo($tr);
|
4899
|
+
$td = $(r === 0 ? '<th/>' : '<td/>').appendTo($tr);
|
4844
4900
|
if (phBr) {
|
4845
4901
|
$td.append(this.editor.util.phBr);
|
4846
4902
|
}
|
@@ -4853,7 +4909,7 @@ TableButton = (function(superClass) {
|
|
4853
4909
|
var cols, tableWidth;
|
4854
4910
|
tableWidth = $table.width();
|
4855
4911
|
cols = $table.find('col');
|
4856
|
-
return $table.find('tr
|
4912
|
+
return $table.find('thead tr th').each((function(_this) {
|
4857
4913
|
return function(i, td) {
|
4858
4914
|
var $col;
|
4859
4915
|
$col = cols.eq(i);
|
@@ -4873,24 +4929,38 @@ TableButton = (function(superClass) {
|
|
4873
4929
|
}
|
4874
4930
|
};
|
4875
4931
|
|
4932
|
+
TableButton.prototype._changeCellTag = function($tr, tagName) {
|
4933
|
+
return $tr.find('td, th').each((function(_this) {
|
4934
|
+
return function(i, cell) {
|
4935
|
+
var $cell;
|
4936
|
+
$cell = $(cell);
|
4937
|
+
return $cell.replaceWith("<" + tagName + ">" + ($cell.html()) + "</" + tagName + ">");
|
4938
|
+
};
|
4939
|
+
})(this));
|
4940
|
+
};
|
4941
|
+
|
4876
4942
|
TableButton.prototype.deleteRow = function($td) {
|
4877
4943
|
var $newTr, $tr, index;
|
4878
4944
|
$tr = $td.parent('tr');
|
4879
|
-
if ($tr.
|
4945
|
+
if ($tr.closest('table').find('tr').length < 1) {
|
4880
4946
|
return this.deleteTable($td);
|
4881
4947
|
} else {
|
4882
|
-
$newTr =
|
4948
|
+
$newTr = this._nextRow($tr);
|
4883
4949
|
if (!($newTr.length > 0)) {
|
4884
|
-
$newTr =
|
4950
|
+
$newTr = this._prevRow($tr);
|
4951
|
+
}
|
4952
|
+
index = $tr.find('td, th').index($td);
|
4953
|
+
if ($tr.parent().is('thead')) {
|
4954
|
+
$newTr.appendTo($tr.parent());
|
4955
|
+
this._changeCellTag($newTr, 'th');
|
4885
4956
|
}
|
4886
|
-
index = $tr.find('td').index($td);
|
4887
4957
|
$tr.remove();
|
4888
|
-
return this.editor.selection.setRangeAtEndOf($newTr.find('td').eq(index));
|
4958
|
+
return this.editor.selection.setRangeAtEndOf($newTr.find('td, th').eq(index));
|
4889
4959
|
}
|
4890
4960
|
};
|
4891
4961
|
|
4892
4962
|
TableButton.prototype.insertRow = function($td, direction) {
|
4893
|
-
var $newTr, $table, $tr, colNum, i, index, j, ref;
|
4963
|
+
var $newTr, $table, $tr, cellTag, colNum, i, index, j, ref;
|
4894
4964
|
if (direction == null) {
|
4895
4965
|
direction = 'after';
|
4896
4966
|
}
|
@@ -4902,31 +4972,41 @@ TableButton = (function(superClass) {
|
|
4902
4972
|
return colNum = Math.max(colNum, $(tr).find('td').length);
|
4903
4973
|
};
|
4904
4974
|
})(this));
|
4975
|
+
index = $tr.find('td, th').index($td);
|
4905
4976
|
$newTr = $('<tr/>');
|
4977
|
+
cellTag = 'td';
|
4978
|
+
if (direction === 'after' && $tr.parent().is('thead')) {
|
4979
|
+
$tr.parent().next('tbody').prepend($newTr);
|
4980
|
+
} else if (direction === 'before' && $tr.parent().is('thead')) {
|
4981
|
+
$tr.before($newTr);
|
4982
|
+
$tr.parent().next('tbody').prepend($tr);
|
4983
|
+
this._changeCellTag($tr, 'td');
|
4984
|
+
cellTag = 'th';
|
4985
|
+
} else {
|
4986
|
+
$tr[direction]($newTr);
|
4987
|
+
}
|
4906
4988
|
for (i = j = 1, ref = colNum; 1 <= ref ? j <= ref : j >= ref; i = 1 <= ref ? ++j : --j) {
|
4907
|
-
$(
|
4989
|
+
$("<" + cellTag + "/>").append(this.editor.util.phBr).appendTo($newTr);
|
4908
4990
|
}
|
4909
|
-
|
4910
|
-
index = $tr.find('td').index($td);
|
4911
|
-
return this.editor.selection.setRangeAtStartOf($newTr.find('td').eq(index));
|
4991
|
+
return this.editor.selection.setRangeAtStartOf($newTr.find('td, th').eq(index));
|
4912
4992
|
};
|
4913
4993
|
|
4914
4994
|
TableButton.prototype.deleteCol = function($td) {
|
4915
4995
|
var $newTd, $table, $tr, index;
|
4916
4996
|
$tr = $td.parent('tr');
|
4917
|
-
if ($tr.
|
4997
|
+
if ($tr.closest('table').find('tr').length < 1 && $td.siblings('td, th').length < 1) {
|
4918
4998
|
return this.deleteTable($td);
|
4919
4999
|
} else {
|
4920
|
-
index = $tr.find('td').index($td);
|
4921
|
-
$newTd = $td.next('td');
|
5000
|
+
index = $tr.find('td, th').index($td);
|
5001
|
+
$newTd = $td.next('td, th');
|
4922
5002
|
if (!($newTd.length > 0)) {
|
4923
|
-
$newTd = $tr.prev('td');
|
5003
|
+
$newTd = $tr.prev('td, th');
|
4924
5004
|
}
|
4925
5005
|
$table = $tr.closest('table');
|
4926
5006
|
$table.find('col').eq(index).remove();
|
4927
5007
|
$table.find('tr').each((function(_this) {
|
4928
5008
|
return function(i, tr) {
|
4929
|
-
return $(tr).find('td').eq(index).remove();
|
5009
|
+
return $(tr).find('td, th').eq(index).remove();
|
4930
5010
|
};
|
4931
5011
|
})(this));
|
4932
5012
|
this.refreshTableWidth($table);
|
@@ -4940,14 +5020,15 @@ TableButton = (function(superClass) {
|
|
4940
5020
|
direction = 'after';
|
4941
5021
|
}
|
4942
5022
|
$tr = $td.parent('tr');
|
4943
|
-
index = $tr.find('td').index($td);
|
5023
|
+
index = $tr.find('td, th').index($td);
|
4944
5024
|
$table = $td.closest('table');
|
4945
5025
|
$col = $table.find('col').eq(index);
|
4946
5026
|
$table.find('tr').each((function(_this) {
|
4947
5027
|
return function(i, tr) {
|
4948
|
-
var $newTd;
|
4949
|
-
|
4950
|
-
|
5028
|
+
var $newTd, cellTag;
|
5029
|
+
cellTag = $(tr).parent().is('thead') ? 'th' : 'td';
|
5030
|
+
$newTd = $("<" + cellTag + "/>").append(_this.editor.util.phBr);
|
5031
|
+
return $(tr).find('td, th').eq(index)[direction]($newTd);
|
4951
5032
|
};
|
4952
5033
|
})(this));
|
4953
5034
|
$newCol = $('<col/>');
|
@@ -4957,7 +5038,7 @@ TableButton = (function(superClass) {
|
|
4957
5038
|
$col.attr('width', width + '%');
|
4958
5039
|
$newCol.attr('width', width + '%');
|
4959
5040
|
this.refreshTableWidth($table);
|
4960
|
-
$newTd = direction === 'after' ? $td.next('td') : $td.prev('td');
|
5041
|
+
$newTd = direction === 'after' ? $td.next('td, th') : $td.prev('td, th');
|
4961
5042
|
return this.editor.selection.setRangeAtStartOf($newTd);
|
4962
5043
|
};
|
4963
5044
|
|
@@ -4974,7 +5055,7 @@ TableButton = (function(superClass) {
|
|
4974
5055
|
TableButton.prototype.command = function(param) {
|
4975
5056
|
var $td, range;
|
4976
5057
|
range = this.editor.selection.getRange();
|
4977
|
-
$td = $(range.commonAncestorContainer).closest('td');
|
5058
|
+
$td = $(range.commonAncestorContainer).closest('td, th');
|
4978
5059
|
if (!($td.length > 0)) {
|
4979
5060
|
return;
|
4980
5061
|
}
|
@@ -609,6 +609,16 @@ $simditor-button-height: 40px;
|
|
609
609
|
}
|
610
610
|
}
|
611
611
|
|
612
|
+
code {
|
613
|
+
display: inline-block;
|
614
|
+
padding: 0 4px;
|
615
|
+
margin: 0 5px;
|
616
|
+
background: #eeeeee;
|
617
|
+
border-radius: 3px;
|
618
|
+
font-size: 13px;
|
619
|
+
font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
620
|
+
}
|
621
|
+
|
612
622
|
pre {
|
613
623
|
padding: 10px 5px 10px 10px;
|
614
624
|
margin: 15px 0;
|
@@ -621,16 +631,14 @@ $simditor-button-height: 40px;
|
|
621
631
|
white-space: pre;
|
622
632
|
word-wrap: normal;
|
623
633
|
overflow-x: auto;
|
624
|
-
}
|
625
634
|
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
635
|
+
code {
|
636
|
+
display: block;
|
637
|
+
padding: 0;
|
638
|
+
margin: 0;
|
639
|
+
background: none;
|
640
|
+
border-radius: 0;
|
641
|
+
}
|
634
642
|
}
|
635
643
|
|
636
644
|
hr {
|
@@ -653,12 +661,13 @@ $simditor-button-height: 40px;
|
|
653
661
|
background-color: #f9f9f9;
|
654
662
|
}
|
655
663
|
|
656
|
-
td {
|
664
|
+
td, th {
|
657
665
|
min-width: 40px;
|
658
666
|
height: 30px;
|
659
667
|
border: 1px solid #ccc;
|
660
668
|
vertical-align: top;
|
661
669
|
padding: 2px 4px;
|
670
|
+
text-align: left;
|
662
671
|
box-sizing: border-box;
|
663
672
|
|
664
673
|
&.active {
|
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.1.
|
4
|
+
version: 2.1.13.0
|
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-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rails assets wrapper for https://github.com/mycolorway/simditor
|
14
14
|
email:
|