+ var os;
|
|
1611
|
+ os = {};
|
|
1612
|
+ if (/Mac/.test(navigator.appVersion)) {
|
|
1613
|
+ os.mac = true;
|
|
1614
|
+ } else if (/Linux/.test(navigator.appVersion)) {
|
|
1615
|
+ os.linux = true;
|
|
1616
|
+ } else if (/Win/.test(navigator.appVersion)) {
|
|
1617
|
+ os.win = true;
|
|
1618
|
+ } else if (/X11/.test(navigator.appVersion)) {
|
|
1619
|
+ os.unix = true;
|
|
1620
|
+ }
|
|
1621
|
+ if (/Mobi/.test(navigator.appVersion)) {
|
|
1622
|
+ os.mobile = true;
|
|
1623
|
+ }
|
|
1624
|
+ return os;
|
|
1625
|
+ })();
|
|
1626
|
+
|
|
1627
|
+ Util.prototype.browser = (function() {
|
|
1628
|
+ var chrome, edge, firefox, ie, ref, ref1, ref2, ref3, ref4, safari, ua;
|
|
1629
|
+ ua = navigator.userAgent;
|
|
1630
|
+ ie = /(msie|trident)/i.test(ua);
|
|
1631
|
+ chrome = /chrome|crios/i.test(ua);
|
|
1632
|
+ safari = /safari/i.test(ua) && !chrome;
|
|
1633
|
+ firefox = /firefox/i.test(ua);
|
|
1634
|
+ edge = /edge/i.test(ua);
|
|
1635
|
+ if (ie) {
|
|
1636
|
+ return {
|
|
1637
|
+ msie: true,
|
|
1638
|
+ version: ((ref = ua.match(/(msie |rv:)(\d+(\.\d+)?)/i)) != null ? ref[2] : void 0) * 1
|
|
1639
|
+ };
|
|
1640
|
+ } else if (edge) {
|
|
1641
|
+ return {
|
|
1642
|
+ edge: true,
|
|
1643
|
+ webkit: true,
|
|
1644
|
+ version: ((ref1 = ua.match(/edge\/(\d+(\.\d+)?)/i)) != null ? ref1[1] : void 0) * 1
|
|
1645
|
+ };
|
|
1646
|
+ } else if (chrome) {
|
|
1647
|
+ return {
|
|
1648
|
+ webkit: true,
|
|
1649
|
+ chrome: true,
|
|
1650
|
+ version: ((ref2 = ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i)) != null ? ref2[1] : void 0) * 1
|
|
1651
|
+ };
|
|
1652
|
+ } else if (safari) {
|
|
1653
|
+ return {
|
|
1654
|
+ webkit: true,
|
|
1655
|
+ safari: true,
|
|
1656
|
+ version: ((ref3 = ua.match(/version\/(\d+(\.\d+)?)/i)) != null ? ref3[1] : void 0) * 1
|
|
1657
|
+ };
|
|
1658
|
+ } else if (firefox) {
|
|
1659
|
+ return {
|
|
1660
|
+ mozilla: true,
|
|
1661
|
+ firefox: true,
|
|
1662
|
+ version: ((ref4 = ua.match(/firefox\/(\d+(\.\d+)?)/i)) != null ? ref4[1] : void 0) * 1
|
|
1663
|
+ };
|
|
1664
|
+ } else {
|
|
1665
|
+ return {};
|
|
1666
|
+ }
|
|
1667
|
+ })();
|
|
1668
|
+
|
|
1669
|
+ Util.prototype.support = (function() {
|
|
1670
|
+ return {
|
|
1671
|
+ onselectionchange: (function() {
|
|
1672
|
+ var e, onselectionchange;
|
|
1673
|
+ onselectionchange = document.onselectionchange;
|
|
1674
|
+ if (onselectionchange !== void 0) {
|
|
1675
|
+ try {
|
|
1676
|
+ document.onselectionchange = 0;
|
|
1677
|
+ return document.onselectionchange === null;
|
|
1678
|
+ } catch (_error) {
|
|
1679
|
+ e = _error;
|
|
1680
|
+ } finally {
|
|
1681
|
+ document.onselectionchange = onselectionchange;
|
|
1682
|
+ }
|
|
1683
|
+ }
|
|
1684
|
+ return false;
|
|
1685
|
+ })(),
|
|
1686
|
+ oninput: (function() {
|
|
1687
|
+ return !/(msie|trident)/i.test(navigator.userAgent);
|
|
1688
|
+ })()
|
|
1689
|
+ };
|
|
1690
|
+ })();
|
|
1691
|
+
|
|
1692
|
+ Util.prototype.reflow = function(el) {
|
|
1693
|
+ if (el == null) {
|
|
1694
|
+ el = document;
|
|
1695
|
+ }
|
|
1696
|
+ return $(el)[0].offsetHeight;
|
|
1697
|
+ };
|
|
1698
|
+
|
|
1699
|
+ Util.prototype.metaKey = function(e) {
|
|
1700
|
+ var isMac;
|
|
1701
|
+ isMac = /Mac/.test(navigator.userAgent);
|
|
1702
|
+ if (isMac) {
|
|
1703
|
+ return e.metaKey;
|
|
1704
|
+ } else {
|
|
1705
|
+ return e.ctrlKey;
|
|
1706
|
+ }
|
|
1707
|
+ };
|
|
1708
|
+
|
|
1709
|
+ Util.prototype.isEmptyNode = function(node) {
|
|
1710
|
+ var $node;
|
|
1711
|
+ $node = $(node);
|
|
1712
|
+ return $node.is(':empty') || (!$node.text() && !$node.find(':not(br, span, div)').length);
|
|
1713
|
+ };
|
|
1714
|
+
|
|
1715
|
+ Util.prototype.isDecoratedNode = function(node) {
|
|
1716
|
+ return $(node).is('[class^="simditor-"]');
|
|
1717
|
+ };
|
|
1718
|
+
|
|
1719
|
+ Util.prototype.blockNodes = ["div", "p", "ul", "ol", "li", "blockquote", "hr", "pre", "h1", "h2", "h3", "h4", "h5", "table"];
|
|
1720
|
+
|
|
1721
|
+ Util.prototype.isBlockNode = function(node) {
|
|
1722
|
+ node = $(node)[0];
|
|
1723
|
+ if (!node || node.nodeType === 3) {
|
|
1724
|
+ return false;
|
|
1725
|
+ }
|
|
1726
|
+ return new RegExp("^(" + (this.blockNodes.join('|')) + ")$").test(node.nodeName.toLowerCase());
|
|
1727
|
+ };
|
|
1728
|
+
|
|
1729
|
+ Util.prototype.getNodeLength = function(node) {
|
|
1730
|
+ node = $(node)[0];
|
|
1731
|
+ switch (node.nodeType) {
|
|
1732
|
+ case 7:
|
|
1733
|
+ case 10:
|
|
1734
|
+ return 0;
|
|
1735
|
+ case 3:
|
|
1736
|
+ case 8:
|
|
1737
|
+ return node.length;
|
|
1738
|
+ default:
|
|
1739
|
+ return node.childNodes.length;
|
|
1740
|
+ }
|
|
1741
|
+ };
|
|
1742
|
+
|
|
1743
|
+ Util.prototype.dataURLtoBlob = function(dataURL) {
|
|
1744
|
+ var BlobBuilder, arrayBuffer, bb, blobArray, byteString, hasArrayBufferViewSupport, hasBlobConstructor, i, intArray, k, mimeString, ref, supportBlob;
|
|
1745
|
+ hasBlobConstructor = window.Blob && (function() {
|
|
1746
|
+ var e;
|
|
1747
|
+ try {
|
|
1748
|
+ return Boolean(new Blob());
|
|
1749
|
+ } catch (_error) {
|
|
1750
|
+ e = _error;
|
|
1751
|
+ return false;
|
|
1752
|
+ }
|
|
1753
|
+ })();
|
|
1754
|
+ hasArrayBufferViewSupport = hasBlobConstructor && window.Uint8Array && (function() {
|
|
1755
|
+ var e;
|
|
1756
|
+ try {
|
|
1757
|
+ return new Blob([new Uint8Array(100)]).size === 100;
|
|
1758
|
+ } catch (_error) {
|
|
1759
|
+ e = _error;
|
|
1760
|
+ return false;
|
|
1761
|
+ }
|
|
1762
|
+ })();
|
|
1763
|
+ BlobBuilder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
|
1764
|
+ supportBlob = hasBlobConstructor || BlobBuilder;
|
|
1765
|
+ if (!(supportBlob && window.atob && window.ArrayBuffer && window.Uint8Array)) {
|
|
1766
|
+ return false;
|
|
1767
|
+ }
|
|
1768
|
+ if (dataURL.split(',')[0].indexOf('base64') >= 0) {
|
|
1769
|
+ byteString = atob(dataURL.split(',')[1]);
|
|
1770
|
+ } else {
|
|
1771
|
+ byteString = decodeURIComponent(dataURL.split(',')[1]);
|
|
1772
|
+ }
|
|
1773
|
+ arrayBuffer = new ArrayBuffer(byteString.length);
|
|
1774
|
+ intArray = new Uint8Array(arrayBuffer);
|
|
1775
|
+ for (i = k = 0, ref = byteString.length; 0 <= ref ? k <= ref : k >= ref; i = 0 <= ref ? ++k : --k) {
|
|
1776
|
+ intArray[i] = byteString.charCodeAt(i);
|
|
1777
|
+ }
|
|
1778
|
+ mimeString = dataURL.split(',')[0].split(':')[1].split(';')[0];
|
|
1779
|
+ if (hasBlobConstructor) {
|
|
1780
|
+ blobArray = hasArrayBufferViewSupport ? intArray : arrayBuffer;
|
|
1781
|
+ return new Blob([blobArray], {
|
|
1782
|
+ type: mimeString
|
|
1783
|
+ });
|
|
1784
|
+ }
|
|
1785
|
+ bb = new BlobBuilder();
|
|
1786
|
+ bb.append(arrayBuffer);
|
|
1787
|
+ return bb.getBlob(mimeString);
|
|
1788
|
+ };
|
|
1789
|
+
|
|
1790
|
+ Util.prototype.throttle = function(func, wait) {
|
|
1791
|
+ var args, call, ctx, last, rtn, throttled, timeoutID;
|
|
1792
|
+ last = 0;
|
|
1793
|
+ timeoutID = 0;
|
|
1794
|
+ ctx = args = rtn = null;
|
|
1795
|
+ call = function() {
|
|
1796
|
+ timeoutID = 0;
|
|
1797
|
+ last = +new Date();
|
|
1798
|
+ rtn = func.apply(ctx, args);
|
|
1799
|
+ ctx = null;
|
|
1800
|
+ return args = null;
|
|
1801
|
+ };
|
|
1802
|
+ throttled = function() {
|
|
1803
|
+ var delta;
|
|
1804
|
+ ctx = this;
|
|
1805
|
+ args = arguments;
|
|
1806
|
+ delta = new Date() - last;
|
|
1807
|
+ if (!timeoutID) {
|
|
1808
|
+ if (delta >= wait) {
|
|
1809
|
+ call();
|
|
1810
|
+ } else {
|
|
1811
|
+ timeoutID = setTimeout(call, wait - delta);
|
|
1812
|
+ }
|
|
1813
|
+ }
|
|
1814
|
+ return rtn;
|
|
1815
|
+ };
|
|
1816
|
+ throttled.clear = function() {
|
|
1817
|
+ if (!timeoutID) {
|
|
1818
|
+ return;
|
|
1819
|
+ }
|
|
1820
|
+ clearTimeout(timeoutID);
|
|
1821
|
+ return call();
|
|
1822
|
+ };
|
|
1823
|
+ return throttled;
|
|
1824
|
+ };
|
|
1825
|
+
|
|
1826
|
+ Util.prototype.formatHTML = function(html) {
|
|
1827
|
+ var cursor, indentString, lastMatch, level, match, re, repeatString, result, str;
|
|
1828
|
+ re = /<(\/?)(.+?)(\/?)>/g;
|
|
1829
|
+ result = '';
|
|
1830
|
+ level = 0;
|
|
1831
|
+ lastMatch = null;
|
|
1832
|
+ indentString = ' ';
|
|
1833
|
+ repeatString = function(str, n) {
|
|
1834
|
+ return new Array(n + 1).join(str);
|
|
1835
|
+ };
|
|
1836
|
+ while ((match = re.exec(html)) !== null) {
|
|
1837
|
+ match.isBlockNode = $.inArray(match[2], this.blockNodes) > -1;
|
|
1838
|
+ match.isStartTag = match[1] !== '/' && match[3] !== '/';
|
|
1839
|
+ match.isEndTag = match[1] === '/' || match[3] === '/';
|
|
1840
|
+ cursor = lastMatch ? lastMatch.index + lastMatch[0].length : 0;
|
|
1841
|
+ if ((str = html.substring(cursor, match.index)).length > 0 && $.trim(str)) {
|
|
1842
|
+ result += str;
|
|
1843
|
+ }
|
|
1844
|
+ if (match.isBlockNode && match.isEndTag && !match.isStartTag) {
|
|
1845
|
+ level -= 1;
|
|
1846
|
+ }
|
|
1847
|
+ if (match.isBlockNode && match.isStartTag) {
|
|
1848
|
+ if (!(lastMatch && lastMatch.isBlockNode && lastMatch.isEndTag)) {
|
|
1849
|
+ result += '\n';
|
|
1850
|
+ }
|
|
1851
|
+ result += repeatString(indentString, level);
|
|
1852
|
+ }
|
|
1853
|
+ result += match[0];
|
|
1854
|
+ if (match.isBlockNode && match.isEndTag) {
|
|
1855
|
+ result += '\n';
|
|
1856
|
+ }
|
|
1857
|
+ if (match.isBlockNode && match.isStartTag) {
|
|
1858
|
+ level += 1;
|
|
1859
|
+ }
|
|
1860
|
+ lastMatch = match;
|
|
1861
|
+ }
|
|
1862
|
+ return $.trim(result);
|
|
1863
|
+ };
|
|
1864
|
+
|
|
1865
|
+ return Util;
|
|
1866
|
+
|
|
1867
|
+})(SimpleModule);
|
|
1868
|
+
|
|
1869
|
+Toolbar = (function(superClass) {
|
|
1870
|
+ extend(Toolbar, superClass);
|
|
1871
|
+
|
|
1872
|
+ function Toolbar() {
|
|
1873
|
+ return Toolbar.__super__.constructor.apply(this, arguments);
|
|
1874
|
+ }
|
|
1875
|
+
|
|
1876
|
+ Toolbar.pluginName = 'Toolbar';
|
|
1877
|
+
|
|
1878
|
+ Toolbar.prototype.opts = {
|
|
1879
|
+ toolbar: true,
|
|
1880
|
+ toolbarFloat: true,
|
|
1881
|
+ toolbarHidden: false,
|
|
1882
|
+ toolbarFloatOffset: 0
|
|
1883
|
+ };
|
|
1884
|
+
|
|
1885
|
+ Toolbar.prototype._tpl = {
|
|
1886
|
+ wrapper: '<div class="simditor-toolbar"><ul></ul></div>',
|
|
1887
|
+ separator: '<li><span class="separator"></span></li>'
|
|
1888
|
+ };
|
|
1889
|
+
|
|
1890
|
+ Toolbar.prototype._init = function() {
|
|
1891
|
+ var floatInitialized, initToolbarFloat, toolbarHeight;
|
|
1892
|
+ this.editor = this._module;
|
|
1893
|
+ if (!this.opts.toolbar) {
|
|
1894
|
+ return;
|
|
1895
|
+ }
|
|
1896
|
+ if (!$.isArray(this.opts.toolbar)) {
|
|
1897
|
+ this.opts.toolbar = ['bold', 'italic', 'underline', 'strikethrough', '|', 'ol', 'ul', 'blockquote', 'code', '|', 'link', 'image', '|', 'indent', 'outdent'];
|
|
1898
|
+ }
|
|
1899
|
+ this._render();
|
|
1900
|
+ this.list.on('click', function(e) {
|
|
1901
|
+ return false;
|
|
1902
|
+ });
|
|
1903
|
+ this.wrapper.on('mousedown', (function(_this) {
|
|
1904
|
+ return function(e) {
|
|
1905
|
+ return _this.list.find('.menu-on').removeClass('.menu-on');
|
|
1906
|
+ };
|
|
1907
|
+ })(this));
|
|
1908
|
+ $(document).on('mousedown.simditor' + this.editor.id, (function(_this) {
|
|
1909
|
+ return function(e) {
|
|
1910
|
+ return _this.list.find('.menu-on').removeClass('.menu-on');
|
|
1911
|
+ };
|
|
1912
|
+ })(this));
|
|
1913
|
+ if (!this.opts.toolbarHidden && this.opts.toolbarFloat) {
|
|
1914
|
+ this.wrapper.css('top', this.opts.toolbarFloatOffset);
|
|
1915
|
+ toolbarHeight = 0;
|
|
1916
|
+ initToolbarFloat = (function(_this) {
|
|
1917
|
+ return function() {
|
|
1918
|
+ _this.wrapper.css('position', 'static');
|
|
1919
|
+ _this.wrapper.width('auto');
|
|
1920
|
+ _this.editor.util.reflow(_this.wrapper);
|
|
1921
|
+ _this.wrapper.width(_this.wrapper.outerWidth());
|
|
1922
|
+ _this.wrapper.css('left', _this.editor.util.os.mobile ? _this.wrapper.position().left : _this.wrapper.offset().left);
|
|
1923
|
+ _this.wrapper.css('position', '');
|
|
1924
|
+
|
|
1925
|
+ _this.editor.wrapper.width(_this.wrapper.outerWidth());
|
|
1926
|
+
|
|
1927
|
+ toolbarHeight = _this.wrapper.outerHeight();
|
|
1928
|
+ _this.editor.placeholderEl.css('top', toolbarHeight);
|
|
1929
|
+ return true;
|
|
1930
|
+ };
|
|
1931
|
+ })(this);
|
|
1932
|
+ floatInitialized = null;
|
|
1933
|
+ $(window).on('resize.simditor-' + this.editor.id, function(e) {
|
|
1934
|
+ return floatInitialized = initToolbarFloat();
|
|
1935
|
+ });
|
|
1936
|
+ $(window).on('scroll.simditor-' + this.editor.id, (function(_this) {
|
|
1937
|
+ return function(e) {
|
|
1938
|
+ var bottomEdge, scrollTop, topEdge;
|
|
1939
|
+ if (!_this.wrapper.is(':visible')) {
|
|
1940
|
+ return;
|
|
1941
|
+ }
|
|
1942
|
+ topEdge = _this.editor.wrapper.offset().top;
|
|
1943
|
+ bottomEdge = topEdge + _this.editor.wrapper.outerHeight() - 80;
|
|
1944
|
+ scrollTop = $(document).scrollTop() + _this.opts.toolbarFloatOffset;
|
|
1945
|
+ if (scrollTop <= topEdge || scrollTop >= bottomEdge) {
|
|
1946
|
+ _this.editor.wrapper.removeClass('toolbar-floating').css('padding-top', '');
|
|
1947
|
+ if (_this.editor.util.os.mobile) {
|
|
1948
|
+ return _this.wrapper.css('top', _this.opts.toolbarFloatOffset);
|
|
1949
|
+ }
|
|
1950
|
+ } else {
|
|
1951
|
+ floatInitialized || (floatInitialized = initToolbarFloat());
|
|
1952
|
+ _this.editor.wrapper.addClass('toolbar-floating').css('padding-top', toolbarHeight);
|
|
1953
|
+ if (_this.editor.util.os.mobile) {
|
|
1954
|
+ return _this.wrapper.css('top', scrollTop - topEdge + _this.opts.toolbarFloatOffset);
|
|
1955
|
+ }
|
|
1956
|
+ }
|
|
1957
|
+ };
|
|
1958
|
+ })(this));
|
|
1959
|
+ }
|
|
1960
|
+ this.editor.on('destroy', (function(_this) {
|
|
1961
|
+ return function() {
|
|
1962
|
+ return _this.buttons.length = 0;
|
|
1963
|
+ };
|
|
1964
|
+ })(this));
|
|
1965
|
+ return $(document).on("mousedown.simditor-" + this.editor.id, (function(_this) {
|
|
1966
|
+ return function(e) {
|
|
1967
|
+ return _this.list.find('li.menu-on').removeClass('menu-on');
|
|
1968
|
+ };
|
|
1969
|
+ })(this));
|
|
1970
|
+ };
|
|
1971
|
+
|
|
1972
|
+ Toolbar.prototype._render = function() {
|
|
1973
|
+ var k, len, name, ref;
|
|
1974
|
+ this.buttons = [];
|
|
1975
|
+ this.wrapper = $(this._tpl.wrapper).prependTo(this.editor.wrapper);
|
|
1976
|
+ this.list = this.wrapper.find('ul');
|
|
1977
|
+ ref = this.opts.toolbar;
|
|
1978
|
+ for (k = 0, len = ref.length; k < len; k++) {
|
|
1979
|
+ name = ref[k];
|
|
1980
|
+ if (name === '|') {
|
|
1981
|
+ $(this._tpl.separator).appendTo(this.list);
|
|
1982
|
+ continue;
|
|
1983
|
+ }
|
|
1984
|
+ if (!this.constructor.buttons[name]) {
|
|
1985
|
+ throw new Error("simditor: invalid toolbar button " + name);
|
|
1986
|
+ continue;
|
|
1987
|
+ }
|
|
1988
|
+ this.buttons.push(new this.constructor.buttons[name]({
|
|
1989
|
+ editor: this.editor
|
|
1990
|
+ }));
|
|
1991
|
+ }
|
|
1992
|
+ if (this.opts.toolbarHidden) {
|
|
1993
|
+ return this.wrapper.hide();
|
|
1994
|
+ }
|
|
1995
|
+ };
|
|
1996
|
+
|
|
1997
|
+ Toolbar.prototype.findButton = function(name) {
|
|
1998
|
+ var button;
|
|
1999
|
+ button = this.list.find('.toolbar-item-' + name).data('button');
|
|
2000
|
+ return button != null ? button : null;
|
|
2001
|
+ };
|
|
2002
|
+
|
|
2003
|
+ Toolbar.addButton = function(btn) {
|
|
2004
|
+ return this.buttons[btn.prototype.name] = btn;
|
|
2005
|
+ };
|
|
2006
|
+
|
|
2007
|
+ Toolbar.buttons = {};
|
|
2008
|
+
|
|
2009
|
+ return Toolbar;
|
|
2010
|
+
|
|
2011
|
+})(SimpleModule);
|
|
2012
|
+
|
|
2013
|
+Indentation = (function(superClass) {
|
|
2014
|
+ extend(Indentation, superClass);
|
|
2015
|
+
|
|
2016
|
+ function Indentation() {
|
|
2017
|
+ return Indentation.__super__.constructor.apply(this, arguments);
|
|
2018
|
+ }
|
|
2019
|
+
|
|
2020
|
+ Indentation.pluginName = 'Indentation';
|
|
2021
|
+
|
|
2022
|
+ Indentation.prototype.opts = {
|
|
2023
|
+ tabIndent: true
|
|
2024
|
+ };
|
|
2025
|
+
|
|
2026
|
+ Indentation.prototype._init = function() {
|
|
2027
|
+ this.editor = this._module;
|
|
2028
|
+ return this.editor.keystroke.add('tab', '*', (function(_this) {
|
|
2029
|
+ return function(e) {
|
|
2030
|
+ var codeButton;
|
|
2031
|
+ codeButton = _this.editor.toolbar.findButton('code');
|
|
2032
|
+ if (!(_this.opts.tabIndent || (codeButton && codeButton.active))) {
|
|
2033
|
+ return;
|
|
2034
|
+ }
|
|
2035
|
+ return _this.indent(e.shiftKey);
|
|
2036
|
+ };
|
|
2037
|
+ })(this));
|
|
2038
|
+ };
|
|
2039
|
+
|
|
2040
|
+ Indentation.prototype.indent = function(isBackward) {
|
|
2041
|
+ var $blockNodes, $endNodes, $startNodes, nodes, result;
|
|
2042
|
+ $startNodes = this.editor.selection.startNodes();
|
|
2043
|
+ $endNodes = this.editor.selection.endNodes();
|
|
2044
|
+ $blockNodes = this.editor.selection.blockNodes();
|
|
2045
|
+ nodes = [];
|
|
2046
|
+ $blockNodes = $blockNodes.each(function(i, node) {
|
|
2047
|
+ var include, j, k, len, n;
|
|
2048
|
+ include = true;
|
|
2049
|
+ for (j = k = 0, len = nodes.length; k < len; j = ++k) {
|
|
2050
|
+ n = nodes[j];
|
|
2051
|
+ if ($.contains(node, n)) {
|
|
2052
|
+ include = false;
|
|
2053
|
+ break;
|
|
2054
|
+ } else if ($.contains(n, node)) {
|
|
2055
|
+ nodes.splice(j, 1, node);
|
|
2056
|
+ include = false;
|
|
2057
|
+ break;
|
|
2058
|
+ }
|
|
2059
|
+ }
|
|
2060
|
+ if (include) {
|
|
2061
|
+ return nodes.push(node);
|
|
2062
|
+ }
|
|
2063
|
+ });
|
|
2064
|
+ $blockNodes = $(nodes);
|
|
2065
|
+ result = false;
|
|
2066
|
+ $blockNodes.each((function(_this) {
|
|
2067
|
+ return function(i, blockEl) {
|
|
2068
|
+ var r;
|
|
2069
|
+ r = isBackward ? _this.outdentBlock(blockEl) : _this.indentBlock(blockEl);
|
|
2070
|
+ if (r) {
|
|
2071
|
+ return result = r;
|
|
2072
|
+ }
|
|
2073
|
+ };
|
|
2074
|
+ })(this));
|
|
2075
|
+ return result;
|
|
2076
|
+ };
|
|
2077
|
+
|
|
2078
|
+ Indentation.prototype.indentBlock = function(blockEl) {
|
|
2079
|
+ var $blockEl, $childList, $nextTd, $nextTr, $parentLi, $pre, $td, $tr, marginLeft, tagName;
|
|
2080
|
+ $blockEl = $(blockEl);
|
|
2081
|
+ if (!$blockEl.length) {
|
|
2082
|
+ return;
|
|
2083
|
+ }
|
|
2084
|
+ if ($blockEl.is('pre')) {
|
|
2085
|
+ $pre = this.editor.selection.containerNode();
|
|
2086
|
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
|
|
2087
|
+ return;
|
|
2088
|
+ }
|
|
2089
|
+ this.indentText(this.editor.selection.range());
|
|
2090
|
+ } else if ($blockEl.is('li')) {
|
|
2091
|
+ $parentLi = $blockEl.prev('li');
|
|
2092
|
+ if ($parentLi.length < 1) {
|
|
2093
|
+ return;
|
|
2094
|
+ }
|
|
2095
|
+ this.editor.selection.save();
|
|
2096
|
+ tagName = $blockEl.parent()[0].tagName;
|
|
2097
|
+ $childList = $parentLi.children('ul, ol');
|
|
2098
|
+ if ($childList.length > 0) {
|
|
2099
|
+ $childList.append($blockEl);
|
|
2100
|
+ } else {
|
|
2101
|
+ $('<' + tagName + '/>').append($blockEl).appendTo($parentLi);
|
|
2102
|
+ }
|
|
2103
|
+ this.editor.selection.restore();
|
|
2104
|
+ } else if ($blockEl.is('p, h1, h2, h3, h4')) {
|
|
2105
|
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0;
|
|
2106
|
+ marginLeft = (Math.round(marginLeft / this.opts.indentWidth) + 1) * this.opts.indentWidth;
|
|
2107
|
+ $blockEl.css('margin-left', marginLeft);
|
|
2108
|
+ } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
|
|
2109
|
+ $td = this.editor.selection.containerNode().closest('td, th');
|
|
2110
|
+ $nextTd = $td.next('td, th');
|
|
2111
|
+ if (!($nextTd.length > 0)) {
|
|
2112
|
+ $tr = $td.parent('tr');
|
|
2113
|
+ $nextTr = $tr.next('tr');
|
|
2114
|
+ if ($nextTr.length < 1 && $tr.parent().is('thead')) {
|
|
2115
|
+ $nextTr = $tr.parent('thead').next('tbody').find('tr:first');
|
|
2116
|
+ }
|
|
2117
|
+ $nextTd = $nextTr.find('td:first, th:first');
|
|
2118
|
+ }
|
|
2119
|
+ if (!($td.length > 0 && $nextTd.length > 0)) {
|
|
2120
|
+ return;
|
|
2121
|
+ }
|
|
2122
|
+ this.editor.selection.setRangeAtEndOf($nextTd);
|
|
2123
|
+ } else {
|
|
2124
|
+ return false;
|
|
2125
|
+ }
|
|
2126
|
+ return true;
|
|
2127
|
+ };
|
|
2128
|
+
|
|
2129
|
+ Indentation.prototype.indentText = function(range) {
|
|
2130
|
+ var text, textNode;
|
|
2131
|
+ text = range.toString().replace(/^(?=.+)/mg, '\u00A0\u00A0');
|
|
2132
|
+ textNode = document.createTextNode(text || '\u00A0\u00A0');
|
|
2133
|
+ range.deleteContents();
|
|
2134
|
+ range.insertNode(textNode);
|
|
2135
|
+ if (text) {
|
|
2136
|
+ range.selectNode(textNode);
|
|
2137
|
+ return this.editor.selection.range(range);
|
|
2138
|
+ } else {
|
|
2139
|
+ return this.editor.selection.setRangeAfter(textNode);
|
|
2140
|
+ }
|
|
2141
|
+ };
|
|
2142
|
+
|
|
2143
|
+ Indentation.prototype.outdentBlock = function(blockEl) {
|
|
2144
|
+ var $blockEl, $parent, $parentLi, $pre, $prevTd, $prevTr, $td, $tr, marginLeft, range;
|
|
2145
|
+ $blockEl = $(blockEl);
|
|
2146
|
+ if (!($blockEl && $blockEl.length > 0)) {
|
|
2147
|
+ return;
|
|
2148
|
+ }
|
|
2149
|
+ if ($blockEl.is('pre')) {
|
|
2150
|
+ $pre = this.editor.selection.containerNode();
|
|
2151
|
+ if (!($pre.is($blockEl) || $pre.closest('pre').is($blockEl))) {
|
|
2152
|
+ return;
|
|
2153
|
+ }
|
|
2154
|
+ this.outdentText(range);
|
|
2155
|
+ } else if ($blockEl.is('li')) {
|
|
2156
|
+ $parent = $blockEl.parent();
|
|
2157
|
+ $parentLi = $parent.parent('li');
|
|
2158
|
+ this.editor.selection.save();
|
|
2159
|
+ if ($parentLi.length < 1) {
|
|
2160
|
+ range = document.createRange();
|
|
2161
|
+ range.setStartBefore($parent[0]);
|
|
2162
|
+ range.setEndBefore($blockEl[0]);
|
|
2163
|
+ $parent.before(range.extractContents());
|
|
2164
|
+ $('<p/>').insertBefore($parent).after($blockEl.children('ul, ol')).append($blockEl.contents());
|
|
2165
|
+ $blockEl.remove();
|
|
2166
|
+ } else {
|
|
2167
|
+ if ($blockEl.next('li').length > 0) {
|
|
2168
|
+ $('<' + $parent[0].tagName + '/>').append($blockEl.nextAll('li')).appendTo($blockEl);
|
|
2169
|
+ }
|
|
2170
|
+ $blockEl.insertAfter($parentLi);
|
|
2171
|
+ if ($parent.children('li').length < 1) {
|
|
2172
|
+ $parent.remove();
|
|
2173
|
+ }
|
|
2174
|
+ }
|
|
2175
|
+ this.editor.selection.restore();
|
|
2176
|
+ } else if ($blockEl.is('p, h1, h2, h3, h4')) {
|
|
2177
|
+ marginLeft = parseInt($blockEl.css('margin-left')) || 0;
|
|
2178
|
+ marginLeft = Math.max(Math.round(marginLeft / this.opts.indentWidth) - 1, 0) * this.opts.indentWidth;
|
|
2179
|
+ $blockEl.css('margin-left', marginLeft === 0 ? '' : marginLeft);
|
|
2180
|
+ } else if ($blockEl.is('table') || $blockEl.is('.simditor-table')) {
|
|
2181
|
+ $td = this.editor.selection.containerNode().closest('td, th');
|
|
2182
|
+ $prevTd = $td.prev('td, th');
|
|
2183
|
+ if (!($prevTd.length > 0)) {
|
|
2184
|
+ $tr = $td.parent('tr');
|
|
2185
|
+ $prevTr = $tr.prev('tr');
|
|
2186
|
+ if ($prevTr.length < 1 && $tr.parent().is('tbody')) {
|
|
2187
|
+ $prevTr = $tr.parent('tbody').prev('thead').find('tr:first');
|
|
2188
|
+ }
|
|
2189
|
+ $prevTd = $prevTr.find('td:last, th:last');
|
|
2190
|
+ }
|
|
2191
|
+ if (!($td.length > 0 && $prevTd.length > 0)) {
|
|
2192
|
+ return;
|
|
2193
|
+ }
|
|
2194
|
+ this.editor.selection.setRangeAtEndOf($prevTd);
|
|
2195
|
+ } else {
|
|
2196
|
+ return false;
|
|
2197
|
+ }
|
|
2198
|
+ return true;
|
|
2199
|
+ };
|
|
2200
|
+
|
|
2201
|
+ Indentation.prototype.outdentText = function(range) {};
|
|
2202
|
+
|
|
2203
|
+ return Indentation;
|
|
2204
|
+
|
|
2205
|
+})(SimpleModule);
|
|
2206
|
+
|
|
2207
|
+Clipboard = (function(superClass) {
|
|
2208
|
+ extend(Clipboard, superClass);
|
|
2209
|
+
|
|
2210
|
+ function Clipboard() {
|
|
2211
|
+ return Clipboard.__super__.constructor.apply(this, arguments);
|
|
2212
|
+ }
|
|
2213
|
+
|
|
2214
|
+ Clipboard.pluginName = 'Clipboard';
|
|
2215
|
+
|
|
2216
|
+ Clipboard.prototype.opts = {
|
|
2217
|
+ pasteImage: false,
|
|
2218
|
+ cleanPaste: false
|
|
2219
|
+ };
|
|
2220
|
+
|
|
2221
|
+ Clipboard.prototype._init = function() {
|
|
2222
|
+ this.editor = this._module;
|
|
2223
|
+ if (this.opts.pasteImage && typeof this.opts.pasteImage !== 'string') {
|
|
2224
|
+ this.opts.pasteImage = 'inline';
|
|
2225
|
+ }
|
|
2226
|
+ return this.editor.body.on('paste', (function(_this) {
|
|
2227
|
+ return function(e) {
|
|
2228
|
+ var range;
|
|
2229
|
+ if (_this.pasting || _this._pasteBin) {
|
|
2230
|
+ return;
|
|
2231
|
+ }
|
|
2232
|
+ if (_this.editor.triggerHandler(e) === false) {
|
|
2233
|
+ return false;
|
|
2234
|
+ }
|
|
2235
|
+ range = _this.editor.selection.deleteRangeContents();
|
|
2236
|
+ if (_this.editor.body.html()) {
|
|
2237
|
+ if (!range.collapsed) {
|
|
2238
|
+ range.collapse(true);
|
|
2239
|
+ }
|
|
2240
|
+ } else {
|
|
2241
|
+ _this.editor.formatter.format();
|
|
2242
|
+ _this.editor.selection.setRangeAtStartOf(_this.editor.body.find('p:first'));
|
|
2243
|
+ }
|
|
2244
|
+ if (_this._processPasteByClipboardApi(e)) {
|
|
2245
|
+ return false;
|
|
2246
|
+ }
|
|
2247
|
+ _this.editor.inputManager.throttledValueChanged.clear();
|
|
2248
|
+ _this.editor.inputManager.throttledSelectionChanged.clear();
|
|
2249
|
+ _this.editor.undoManager.throttledPushState.clear();
|
|
2250
|
+ _this.editor.selection.reset();
|
|
2251
|
+ _this.editor.undoManager.resetCaretPosition();
|
|
2252
|
+ _this.pasting = true;
|
|
2253
|
+ return _this._getPasteContent(function(pasteContent) {
|
|
2254
|
+ _this._processPasteContent(pasteContent);
|
|
2255
|
+ _this._pasteInBlockEl = null;
|
|
2256
|
+ _this._pastePlainText = null;
|
|
2257
|
+ return _this.pasting = false;
|
|
2258
|
+ });
|
|
2259
|
+ };
|
|
2260
|
+ })(this));
|
|
2261
|
+ };
|
|
2262
|
+
|
|
2263
|
+ Clipboard.prototype._processPasteByClipboardApi = function(e) {
|
|
2264
|
+ var imageFile, pasteItem, ref, uploadOpt;
|
|
2265
|
+ if (this.editor.util.browser.edge) {
|
|
2266
|
+ return;
|
|
2267
|
+ }
|
|
2268
|
+ if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.items && e.originalEvent.clipboardData.items.length > 0) {
|
|
2269
|
+ pasteItem = e.originalEvent.clipboardData.items[0];
|
|
2270
|
+ if (/^image\//.test(pasteItem.type)) {
|
|
2271
|
+ imageFile = pasteItem.getAsFile();
|
|
2272
|
+ if (!((imageFile != null) && this.opts.pasteImage)) {
|
|
2273
|
+ return;
|
|
2274
|
+ }
|
|
2275
|
+ if (!imageFile.name) {
|
|
2276
|
+ imageFile.name = "Clipboard Image.png";
|
|
2277
|
+ }
|
|
2278
|
+ if (this.editor.triggerHandler('pasting', [imageFile]) === false) {
|
|
2279
|
+ return;
|
|
2280
|
+ }
|
|
2281
|
+ uploadOpt = {};
|
|
2282
|
+ uploadOpt[this.opts.pasteImage] = true;
|
|
2283
|
+ if ((ref = this.editor.uploader) != null) {
|
|
2284
|
+ ref.upload(imageFile, uploadOpt);
|
|
2285
|
+ }
|
|
2286
|
+ return true;
|
|
2287
|
+ }
|
|
2288
|
+ }
|
|
2289
|
+ };
|
|
2290
|
+
|
|
2291
|
+ Clipboard.prototype._getPasteContent = function(callback) {
|
|
2292
|
+ var state;
|
|
2293
|
+ this._pasteBin = $('<div contenteditable="true" />').addClass('simditor-paste-bin').attr('tabIndex', '-1').appendTo(this.editor.el);
|
|
2294
|
+ state = {
|
|
2295
|
+ html: this.editor.body.html(),
|
|
2296
|
+ caret: this.editor.undoManager.caretPosition()
|
|
2297
|
+ };
|
|
2298
|
+ this._pasteBin.focus();
|
|
2299
|
+ return setTimeout((function(_this) {
|
|
2300
|
+ return function() {
|
|
2301
|
+ var pasteContent;
|
|
2302
|
+ _this.editor.hidePopover();
|
|
2303
|
+ _this.editor.body.get(0).innerHTML = state.html;
|
|
2304
|
+ _this.editor.undoManager.caretPosition(state.caret);
|
|
2305
|
+ _this.editor.body.focus();
|
|
2306
|
+ _this.editor.selection.reset();
|
|
2307
|
+ _this.editor.selection.range();
|
|
2308
|
+ _this._pasteInBlockEl = _this.editor.selection.blockNodes().last();
|
|
2309
|
+ _this._pastePlainText = _this.opts.cleanPaste || _this._pasteInBlockEl.is('pre, table');
|
|
2310
|
+ if (_this._pastePlainText) {
|
|
2311
|
+ pasteContent = _this.editor.formatter.clearHtml(_this._pasteBin.html(), true);
|
|
2312
|
+ } else {
|
|
2313
|
+ pasteContent = $('<div/>').append(_this._pasteBin.contents());
|
|
2314
|
+ pasteContent.find('table colgroup').remove();
|
|
2315
|
+ _this.editor.formatter.format(pasteContent);
|
|
2316
|
+ _this.editor.formatter.decorate(pasteContent);
|
|
2317
|
+ _this.editor.formatter.beautify(pasteContent.children());
|
|
2318
|
+ pasteContent = pasteContent.contents();
|
|
2319
|
+ }
|
|
2320
|
+ _this._pasteBin.remove();
|
|
2321
|
+ _this._pasteBin = null;
|
|
2322
|
+ return callback(pasteContent);
|
|
2323
|
+ };
|
|
2324
|
+ })(this), 0);
|
|
2325
|
+ };
|
|
2326
|
+
|
|
2327
|
+ Clipboard.prototype._processPasteContent = function(pasteContent) {
|
|
2328
|
+ var $blockEl, $img, blob, children, insertPosition, k, l, lastLine, len, len1, len2, len3, len4, line, lines, m, node, o, q, ref, ref1, ref2, uploadOpt;
|
|
2329
|
+ if (this.editor.triggerHandler('pasting', [pasteContent]) === false) {
|
|
2330
|
+ return;
|
|
2331
|
+ }
|
|
2332
|
+ $blockEl = this._pasteInBlockEl;
|
|
2333
|
+ if (!pasteContent) {
|
|
2334
|
+ return;
|
|
2335
|
+ } else if (this._pastePlainText) {
|
|
2336
|
+ if ($blockEl.is('table')) {
|
|
2337
|
+ lines = pasteContent.split('\n');
|
|
2338
|
+ lastLine = lines.pop();
|
|
2339
|
+ for (k = 0, len = lines.length; k < len; k++) {
|
|
2340
|
+ line = lines[k];
|
|
2341
|
+ this.editor.selection.insertNode(document.createTextNode(line));
|
|
2342
|
+ this.editor.selection.insertNode($('<br/>'));
|
|
2343
|
+ }
|
|
2344
|
+ this.editor.selection.insertNode(document.createTextNode(lastLine));
|
|
2345
|
+ } else {
|
|
2346
|
+ pasteContent = $('<div/>').text(pasteContent);
|
|
2347
|
+ ref = pasteContent.contents();
|
|
2348
|
+ for (l = 0, len1 = ref.length; l < len1; l++) {
|
|
2349
|
+ node = ref[l];
|
|
2350
|
+ this.editor.selection.insertNode($(node)[0]);
|
|
2351
|
+ }
|
|
2352
|
+ }
|
|
2353
|
+ } else if ($blockEl.is(this.editor.body)) {
|
|
2354
|
+ for (m = 0, len2 = pasteContent.length; m < len2; m++) {
|
|
2355
|
+ node = pasteContent[m];
|
|
2356
|
+ this.editor.selection.insertNode(node);
|
|
2357
|
+ }
|
|
2358
|
+ } else if (pasteContent.length < 1) {
|
|
2359
|
+ return;
|
|
2360
|
+ } else if (pasteContent.length === 1) {
|
|
2361
|
+ if (pasteContent.is('p')) {
|
|
2362
|
+ children = pasteContent.contents();
|
|
2363
|
+ if (children.length === 1 && children.is('img')) {
|
|
2364
|
+ $img = children;
|
|
2365
|
+ if (/^data:image/.test($img.attr('src'))) {
|
|
2366
|
+ if (!this.opts.pasteImage) {
|
|
2367
|
+ return;
|
|
2368
|
+ }
|
|
2369
|
+ blob = this.editor.util.dataURLtoBlob($img.attr("src"));
|
|
2370
|
+ blob.name = "Clipboard Image.png";
|
|
2371
|
+ uploadOpt = {};
|
|
2372
|
+ uploadOpt[this.opts.pasteImage] = true;
|
|
2373
|
+ if ((ref1 = this.editor.uploader) != null) {
|
|
2374
|
+ ref1.upload(blob, uploadOpt);
|
|
2375
|
+ }
|
|
2376
|
+ return;
|
|
2377
|
+ } else if ($img.is('img[src^="webkit-fake-url://"]')) {
|
|
2378
|
+ return;
|
|
2379
|
+ }
|
|
2380
|
+ }
|
|
2381
|
+ for (o = 0, len3 = children.length; o < len3; o++) {
|
|
2382
|
+ node = children[o];
|
|
2383
|
+ this.editor.selection.insertNode(node);
|
|
2384
|
+ }
|
|
2385
|
+ } else if ($blockEl.is('p') && this.editor.util.isEmptyNode($blockEl)) {
|
|
2386
|
+ $blockEl.replaceWith(pasteContent);
|
|
2387
|
+ this.editor.selection.setRangeAtEndOf(pasteContent);
|
|
2388
|
+ } else if (pasteContent.is('ul, ol')) {
|
|
2389
|
+ if (pasteContent.find('li').length === 1) {
|
|
2390
|
+ pasteContent = $('<div/>').text(pasteContent.text());
|
|
2391
|
+ ref2 = pasteContent.contents();
|
|
2392
|
+ for (q = 0, len4 = ref2.length; q < len4; q++) {
|
|
2393
|
+ node = ref2[q];
|
|
2394
|
+ this.editor.selection.insertNode($(node)[0]);
|
|
2395
|
+ }
|
|
2396
|
+ } else if ($blockEl.is('li')) {
|
|
2397
|
+ $blockEl.parent().after(pasteContent);
|
|
2398
|
+ this.editor.selection.setRangeAtEndOf(pasteContent);
|
|
2399
|
+ } else {
|
|
2400
|
+ $blockEl.after(pasteContent);
|
|
2401
|
+ this.editor.selection.setRangeAtEndOf(pasteContent);
|
|
2402
|
+ }
|
|
2403
|
+ } else {
|
|
2404
|
+ $blockEl.after(pasteContent);
|
|
2405
|
+ this.editor.selection.setRangeAtEndOf(pasteContent);
|
|
2406
|
+ }
|
|
2407
|
+ } else {
|
|
2408
|
+ if ($blockEl.is('li')) {
|
|
2409
|
+ $blockEl = $blockEl.parent();
|
|
2410
|
+ }
|
|
2411
|
+ if (this.editor.selection.rangeAtStartOf($blockEl)) {
|
|
2412
|
+ insertPosition = 'before';
|
|
2413
|
+ } else if (this.editor.selection.rangeAtEndOf($blockEl)) {
|
|
2414
|
+ insertPosition = 'after';
|
|
2415
|
+ } else {
|
|
2416
|
+ this.editor.selection.breakBlockEl($blockEl);
|
|
2417
|
+ insertPosition = 'before';
|
|
2418
|
+ }
|
|
2419
|
+ $blockEl[insertPosition](pasteContent);
|
|
2420
|
+ this.editor.selection.setRangeAtEndOf(pasteContent.last());
|
|
2421
|
+ }
|
|
2422
|
+ return this.editor.inputManager.throttledValueChanged();
|
|
2423
|
+ };
|
|
2424
|
+
|
|
2425
|
+ return Clipboard;
|
|
2426
|
+
|
|
2427
|
+})(SimpleModule);
|
|
2428
|
+
|
|
2429
|
+Simditor = (function(superClass) {
|
|
2430
|
+ extend(Simditor, superClass);
|
|
2431
|
+
|
|
2432
|
+ function Simditor() {
|
|
2433
|
+ return Simditor.__super__.constructor.apply(this, arguments);
|
|
2434
|
+ }
|
|
2435
|
+
|
|
2436
|
+ Simditor.connect(Util);
|
|
2437
|
+
|
|
2438
|
+ Simditor.connect(InputManager);
|
|
2439
|
+
|
|
2440
|
+ Simditor.connect(Selection);
|
|
2441
|
+
|
|
2442
|
+ Simditor.connect(UndoManager);
|
|
2443
|
+
|
|
2444
|
+ Simditor.connect(Keystroke);
|
|
2445
|
+
|
|
2446
|
+ Simditor.connect(Formatter);
|
|
2447
|
+
|
|
2448
|
+ Simditor.connect(Toolbar);
|
|
2449
|
+
|
|
2450
|
+ Simditor.connect(Indentation);
|
|
2451
|
+
|
|
2452
|
+ Simditor.connect(Clipboard);
|
|
2453
|
+
|
|
2454
|
+ Simditor.count = 0;
|
|
2455
|
+
|
|
2456
|
+ Simditor.prototype.opts = {
|
|
2457
|
+ textarea: null,
|
|
2458
|
+ placeholder: '',
|
|
2459
|
+ defaultImage: 'images/image.png',
|
|
2460
|
+ params: {},
|
|
2461
|
+ upload: false,
|
|
2462
|
+ indentWidth: 40
|
|
2463
|
+ };
|
|
2464
|
+
|
|
2465
|
+ Simditor.prototype._init = function() {
|
|
2466
|
+ var e, editor, form, uploadOpts;
|
|
2467
|
+ this.textarea = $(this.opts.textarea);
|
|
2468
|
+ this.opts.placeholder = this.opts.placeholder || this.textarea.attr('placeholder');
|
|
2469
|
+ if (!this.textarea.length) {
|
|
2470
|
+ throw new Error('simditor: param textarea is required.');
|
|
2471
|
+ return;
|
|
2472
|
+ }
|
|
2473
|
+ editor = this.textarea.data('simditor');
|
|
2474
|
+ if (editor != null) {
|
|
2475
|
+ editor.destroy();
|
|
2476
|
+ }
|
|
2477
|
+ this.id = ++Simditor.count;
|
|
2478
|
+ this._render();
|
|
2479
|
+ if (simpleHotkeys) {
|
|
2480
|
+ this.hotkeys = simpleHotkeys({
|
|
2481
|
+ el: this.body
|
|
2482
|
+ });
|
|
2483
|
+ } else {
|
|
2484
|
+ throw new Error('simditor: simple-hotkeys is required.');
|
|
2485
|
+ return;
|
|
2486
|
+ }
|
|
2487
|
+ if (this.opts.upload && simpleUploader) {
|
|
2488
|
+ uploadOpts = typeof this.opts.upload === 'object' ? this.opts.upload : {};
|
|
2489
|
+ this.uploader = simpleUploader(uploadOpts);
|
|
2490
|
+ }
|
|
2491
|
+ form = this.textarea.closest('form');
|
|
2492
|
+ if (form.length) {
|
|
2493
|
+ form.on('submit.simditor-' + this.id, (function(_this) {
|
|
2494
|
+ return function() {
|
|
2495
|
+ return _this.sync();
|
|
2496
|
+ };
|
|
2497
|
+ })(this));
|
|
2498
|
+ form.on('reset.simditor-' + this.id, (function(_this) {
|
|
2499
|
+ return function() {
|
|
2500
|
+ return _this.setValue('');
|
|
2501
|
+ };
|
|
2502
|
+ })(this));
|
|
2503
|
+ }
|
|
2504
|
+ this.on('initialized', (function(_this) {
|
|
2505
|
+ return function() {
|
|
2506
|
+ if (_this.opts.placeholder) {
|
|
2507
|
+ _this.on('valuechanged', function() {
|
|
2508
|
+ return _this._placeholder();
|
|
2509
|
+ });
|
|
2510
|
+ }
|
|
2511
|
+ _this.setValue(_this.textarea.val().trim() || '');
|
|
2512
|
+ if (_this.textarea.attr('autofocus')) {
|
|
2513
|
+ return _this.focus();
|
|
2514
|
+ }
|
|
2515
|
+ };
|
|
2516
|
+ })(this));
|
|
2517
|
+ if (this.util.browser.mozilla) {
|
|
2518
|
+ this.util.reflow();
|
|
2519
|
+ try {
|
|
2520
|
+ document.execCommand('enableObjectResizing', false, false);
|
|
2521
|
+ return document.execCommand('enableInlineTableEditing', false, false);
|
|
2522
|
+ } catch (_error) {
|
|
2523
|
+ e = _error;
|
|
2524
|
+ }
|
|
2525
|
+ }
|
|
2526
|
+ };
|
|
2527
|
+
|
|
2528
|
+ Simditor.prototype._tpl = "<div class=\"simditor\">\n <div class=\"simditor-wrapper\">\n <div class=\"simditor-placeholder\"></div>\n <div class=\"simditor-body\" contenteditable=\"true\">\n </div>\n </div>\n</div>";
|
|
2529
|
+
|
|
2530
|
+ Simditor.prototype._render = function() {
|
|
2531
|
+ var key, ref, results, val;
|
|
2532
|
+ this.el = $(this._tpl).insertBefore(this.textarea);
|
|
2533
|
+ this.wrapper = this.el.find('.simditor-wrapper');
|
|
2534
|
+ this.body = this.wrapper.find('.simditor-body');
|
|
2535
|
+ this.placeholderEl = this.wrapper.find('.simditor-placeholder').append(this.opts.placeholder);
|
|
2536
|
+ this.el.data('simditor', this);
|
|
2537
|
+ this.wrapper.append(this.textarea);
|
|
2538
|
+ this.textarea.data('simditor', this).blur();
|
|
2539
|
+ this.body.attr('tabindex', this.textarea.attr('tabindex'));
|
|
2540
|
+ if (this.util.os.mac) {
|
|
2541
|
+ this.el.addClass('simditor-mac');
|
|
2542
|
+ } else if (this.util.os.linux) {
|
|
2543
|
+ this.el.addClass('simditor-linux');
|
|
2544
|
+ }
|
|
2545
|
+ if (this.util.os.mobile) {
|
|
2546
|
+ this.el.addClass('simditor-mobile');
|
|
2547
|
+ }
|
|
2548
|
+ if (this.opts.params) {
|
|
2549
|
+ ref = this.opts.params;
|
|
2550
|
+ results = [];
|
|
2551
|
+ for (key in ref) {
|
|
2552
|
+ val = ref[key];
|
|
2553
|
+ results.push($('<input/>', {
|
|
2554
|
+ type: 'hidden',
|
|
2555
|
+ name: key,
|
|
2556
|
+ value: val
|
|
2557
|
+ }).insertAfter(this.textarea));
|
|
2558
|
+ }
|
|
2559
|
+ return results;
|
|
2560
|
+ }
|
|
2561
|
+ };
|
|
2562
|
+
|
|
2563
|
+ Simditor.prototype._placeholder = function() {
|
|
2564
|
+ var children;
|
|
2565
|
+ children = this.body.children();
|
|
2566
|
+ if (children.length === 0 || (children.length === 1 && this.util.isEmptyNode(children) && parseInt(children.css('margin-left') || 0) < this.opts.indentWidth)) {
|
|
2567
|
+ return this.placeholderEl.show();
|
|
2568
|
+ } else {
|
|
2569
|
+ return this.placeholderEl.hide();
|
|
2570
|
+ }
|
|
2571
|
+ };
|
|
2572
|
+
|
|
2573
|
+ Simditor.prototype.setValue = function(val) {
|
|
2574
|
+ this.hidePopover();
|
|
2575
|
+ this.textarea.val(val);
|
|
2576
|
+ this.body.get(0).innerHTML = val;
|
|
2577
|
+ this.formatter.format();
|
|
2578
|
+ this.formatter.decorate();
|
|
2579
|
+ this.util.reflow(this.body);
|
|
2580
|
+ this.inputManager.lastCaretPosition = null;
|
|
2581
|
+ return this.trigger('valuechanged');
|
|
2582
|
+ };
|
|
2583
|
+
|
|
2584
|
+ Simditor.prototype.getValue = function() {
|
|
2585
|
+ return this.sync();
|
|
2586
|
+ };
|
|
2587
|
+
|
|
2588
|
+ Simditor.prototype.sync = function() {
|
|
2589
|
+ var children, cloneBody, emptyP, firstP, lastP, val;
|
|
2590
|
+ cloneBody = this.body.clone();
|
|
2591
|
+ this.formatter.undecorate(cloneBody);
|
|
2592
|
+ this.formatter.format(cloneBody);
|
|
2593
|
+ this.formatter.autolink(cloneBody);
|
|
2594
|
+ children = cloneBody.children();
|
|
2595
|
+ lastP = children.last('p');
|
|
2596
|
+ firstP = children.first('p');
|
|
2597
|
+ while (lastP.is('p') && this.util.isEmptyNode(lastP)) {
|
|
2598
|
+ emptyP = lastP;
|
|
2599
|
+ lastP = lastP.prev('p');
|
|
2600
|
+ emptyP.remove();
|
|
2601
|
+ }
|
|
2602
|
+ while (firstP.is('p') && this.util.isEmptyNode(firstP)) {
|
|
2603
|
+ emptyP = firstP;
|
|
2604
|
+ firstP = lastP.next('p');
|
|
2605
|
+ emptyP.remove();
|
|
2606
|
+ }
|
|
2607
|
+ cloneBody.find('img.uploading').remove();
|
|
2608
|
+ val = $.trim(cloneBody.html());
|
|
2609
|
+ this.textarea.val(val);
|
|
2610
|
+ return val;
|
|
2611
|
+ };
|
|
2612
|
+
|
|
2613
|
+ Simditor.prototype.focus = function() {
|
|
2614
|
+ var $blockEl, range;
|
|
2615
|
+ if (!(this.body.is(':visible') && this.body.is('[contenteditable]'))) {
|
|
2616
|
+ this.el.find('textarea:visible').focus();
|
|
2617
|
+ return;
|
|
2618
|
+ }
|
|
2619
|
+ if (this.inputManager.lastCaretPosition) {
|
|
2620
|
+ this.undoManager.caretPosition(this.inputManager.lastCaretPosition);
|
|
2621
|
+ return this.inputManager.lastCaretPosition = null;
|
|
2622
|
+ } else {
|
|
2623
|
+ $blockEl = this.body.children().last();
|
|
2624
|
+ if (!$blockEl.is('p')) {
|
|
2625
|
+ $blockEl = $('<p/>').append(this.util.phBr).appendTo(this.body);
|
|
2626
|
+ }
|
|
2627
|
+ range = document.createRange();
|
|
2628
|
+ return this.selection.setRangeAtEndOf($blockEl, range);
|
|
2629
|
+ }
|
|
2630
|
+ };
|
|
2631
|
+
|
|
2632
|
+ Simditor.prototype.blur = function() {
|
|
2633
|
+ if (this.body.is(':visible') && this.body.is('[contenteditable]')) {
|
|
2634
|
+ return this.body.blur();
|
|
2635
|
+ } else {
|
|
2636
|
+ return this.body.find('textarea:visible').blur();
|
|
2637
|
+ }
|
|
2638
|
+ };
|
|
2639
|
+
|
|
2640
|
+ Simditor.prototype.hidePopover = function() {
|
|
2641
|
+ return this.el.find('.simditor-popover').each(function(i, popover) {
|
|
2642
|
+ popover = $(popover).data('popover');
|
|
2643
|
+ if (popover.active) {
|
|
2644
|
+ return popover.hide();
|
|
2645
|
+ }
|
|
2646
|
+ });
|
|
2647
|
+ };
|
|
2648
|
+
|
|
2649
|
+ Simditor.prototype.destroy = function() {
|
|
2650
|
+ this.triggerHandler('destroy');
|
|
2651
|
+ this.textarea.closest('form').off('.simditor .simditor-' + this.id);
|
|
2652
|
+ this.selection.clear();
|
|
2653
|
+ this.inputManager.focused = false;
|
|
2654
|
+ this.textarea.insertBefore(this.el).hide().val('').removeData('simditor');
|
|
2655
|
+ this.el.remove();
|
|
2656
|
+ $(document).off('.simditor-' + this.id);
|
|
2657
|
+ $(window).off('.simditor-' + this.id);
|
|
2658
|
+ return this.off();
|
|
2659
|
+ };
|
|
2660
|
+
|
|
2661
|
+ return Simditor;
|
|
2662
|
+
|
|
2663
|
+})(SimpleModule);
|
|
2664
|
+
|
|
2665
|
+Simditor.i18n = {
|
|
2666
|
+ 'zh-CN': {
|
|
2667
|
+ 'blockquote': '引用',
|
|
2668
|
+ 'bold': '加粗文字',
|
|
2669
|
+ 'code': '插入代码',
|
|
2670
|
+ 'color': '文字颜色',
|
|
2671
|
+ 'coloredText': '彩色文字',
|
|
2672
|
+ 'hr': '分隔线',
|
|
2673
|
+ 'image': '插入图片',
|
|
2674
|
+ 'externalImage': '外链图片',
|
|
2675
|
+ 'uploadImage': '上传图片',
|
|
2676
|
+ 'uploadFailed': '上传失败了',
|
|
2677
|
+ 'uploadError': '上传出错了',
|
|
2678
|
+ 'imageUrl': '图片地址',
|
|
2679
|
+ 'imageSize': '图片尺寸',
|
|
2680
|
+ 'imageAlt': '图片描述',
|
|
2681
|
+ 'restoreImageSize': '还原图片尺寸',
|
|
2682
|
+ 'uploading': '正在上传',
|
|
2683
|
+ 'indent': '向右缩进',
|
|
2684
|
+ 'outdent': '向左缩进',
|
|
2685
|
+ 'italic': '斜体文字',
|
|
2686
|
+ 'link': '插入链接',
|
|
2687
|
+ 'linkText': '链接文字',
|
|
2688
|
+ 'linkUrl': '链接地址',
|
|
2689
|
+ 'linkTarget': '打开方式',
|
|
2690
|
+ 'openLinkInCurrentWindow': '在新窗口中打开',
|
|
2691
|
+ 'openLinkInNewWindow': '在当前窗口中打开',
|
|
2692
|
+ 'removeLink': '移除链接',
|
|
2693
|
+ 'ol': '有序列表',
|
|
2694
|
+ 'ul': '无序列表',
|
|
2695
|
+ 'strikethrough': '删除线文字',
|
|
2696
|
+ 'table': '表格',
|
|
2697
|
+ 'deleteRow': '删除行',
|
|
2698
|
+ 'insertRowAbove': '在上面插入行',
|
|
2699
|
+ 'insertRowBelow': '在下面插入行',
|
|
2700
|
+ 'deleteColumn': '删除列',
|
|
2701
|
+ 'insertColumnLeft': '在左边插入列',
|
|
2702
|
+ 'insertColumnRight': '在右边插入列',
|
|
2703
|
+ 'deleteTable': '删除表格',
|
|
2704
|
+ 'title': '标题',
|
|
2705
|
+ 'normalText': '普通文本',
|
|
2706
|
+ 'underline': '下划线文字',
|
|
2707
|
+ 'alignment': '水平对齐',
|
|
2708
|
+ 'alignCenter': '居中',
|
|
2709
|
+ 'alignLeft': '居左',
|
|
2710
|
+ 'alignRight': '居右',
|
|
2711
|
+ 'selectLanguage': '选择程序语言',
|
|
2712
|
+ 'fontScale': '字体大小',
|
|
2713
|
+ 'fontScaleXLarge': '超大字体',
|
|
2714
|
+ 'fontScaleLarge': '大号字体',
|
|
2715
|
+ 'fontScaleNormal': '正常大小',
|
|
2716
|
+ 'fontScaleSmall': '小号字体',
|
|
2717
|
+ 'fontScaleXSmall': '超小字体'
|
|
2718
|
+ },
|
|
2719
|
+ 'en-US': {
|
|
2720
|
+ 'blockquote': 'Block Quote',
|
|
2721
|
+ 'bold': 'Bold',
|
|
2722
|
+ 'code': 'Code',
|
|
2723
|
+ 'color': 'Text Color',
|
|
2724
|
+ 'coloredText': 'Colored Text',
|
|
2725
|
+ 'hr': 'Horizontal Line',
|
|
2726
|
+ 'image': 'Insert Image',
|
|
2727
|
+ 'externalImage': 'External Image',
|
|
2728
|
+ 'uploadImage': 'Upload Image',
|
|
2729
|
+ 'uploadFailed': 'Upload failed',
|
|
2730
|
+ 'uploadError': 'Error occurs during upload',
|
|
2731
|
+ 'imageUrl': 'Url',
|
|
2732
|
+ 'imageSize': 'Size',
|
|
2733
|
+ 'imageAlt': 'Alt',
|
|
2734
|
+ 'restoreImageSize': 'Restore Origin Size',
|
|
2735
|
+ 'uploading': 'Uploading',
|
|
2736
|
+ 'indent': 'Indent',
|
|
2737
|
+ 'outdent': 'Outdent',
|
|
2738
|
+ 'italic': 'Italic',
|
|
2739
|
+ 'link': 'Insert Link',
|
|
2740
|
+ 'linkText': 'Text',
|
|
2741
|
+ 'linkUrl': 'Url',
|
|
2742
|
+ 'linkTarget': 'Target',
|
|
2743
|
+ 'openLinkInCurrentWindow': 'Open link in current window',
|
|
2744
|
+ 'openLinkInNewWindow': 'Open link in new window',
|
|
2745
|
+ 'removeLink': 'Remove Link',
|
|
2746
|
+ 'ol': 'Ordered List',
|
|
2747
|
+ 'ul': 'Unordered List',
|
|
2748
|
+ 'strikethrough': 'Strikethrough',
|
|
2749
|
+ 'table': 'Table',
|
|
2750
|
+ 'deleteRow': 'Delete Row',
|
|
2751
|
+ 'insertRowAbove': 'Insert Row Above',
|
|
2752
|
+ 'insertRowBelow': 'Insert Row Below',
|
|
2753
|
+ 'deleteColumn': 'Delete Column',
|
|
2754
|
+ 'insertColumnLeft': 'Insert Column Left',
|
|
2755
|
+ 'insertColumnRight': 'Insert Column Right',
|
|
2756
|
+ 'deleteTable': 'Delete Table',
|
|
2757
|
+ 'title': 'Title',
|
|
2758
|
+ 'normalText': 'Text',
|
|
2759
|
+ 'underline': 'Underline',
|
|
2760
|
+ 'alignment': 'Alignment',
|
|
2761
|
+ 'alignCenter': 'Align Center',
|
|
2762
|
+ 'alignLeft': 'Align Left',
|
|
2763
|
+ 'alignRight': 'Align Right',
|
|
2764
|
+ 'selectLanguage': 'Select Language',
|
|
2765
|
+ 'fontScale': 'Font Size',
|
|
2766
|
+ 'fontScaleXLarge': 'X Large Size',
|
|
2767
|
+ 'fontScaleLarge': 'Large Size',
|
|
2768
|
+ 'fontScaleNormal': 'Normal Size',
|
|
2769
|
+ 'fontScaleSmall': 'Small Size',
|
|
2770
|
+ 'fontScaleXSmall': 'X Small Size'
|
|
2771
|
+ }
|
|
2772
|
+};
|
|
2773
|
+
|
|
2774
|
+Button = (function(superClass) {
|
|
2775
|
+ extend(Button, superClass);
|
|
2776
|
+
|
|
2777
|
+ Button.prototype._tpl = {
|
|
2778
|
+ item: '<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',
|
|
2779
|
+ menuWrapper: '<div class="toolbar-menu"></div>',
|
|
2780
|
+ menuItem: '<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',
|
|
2781
|
+ separator: '<li><span class="separator"></span></li>'
|
|
2782
|
+ };
|
|
2783
|
+
|
|
2784
|
+ Button.prototype.name = '';
|
|
2785
|
+
|
|
2786
|
+ Button.prototype.icon = '';
|
|
2787
|
+
|
|
2788
|
+ Button.prototype.title = '';
|
|
2789
|
+
|
|
2790
|
+ Button.prototype.text = '';
|
|
2791
|
+
|
|
2792
|
+ Button.prototype.htmlTag = '';
|
|
2793
|
+
|
|
2794
|
+ Button.prototype.disableTag = '';
|
|
2795
|
+
|
|
2796
|
+ Button.prototype.menu = false;
|
|
2797
|
+
|
|
2798
|
+ Button.prototype.active = false;
|
|
2799
|
+
|
|
2800
|
+ Button.prototype.disabled = false;
|
|
2801
|
+
|
|
2802
|
+ Button.prototype.needFocus = true;
|
|
2803
|
+
|
|
2804
|
+ Button.prototype.shortcut = null;
|
|
2805
|
+
|
|
2806
|
+ function Button(opts) {
|
|
2807
|
+ this.editor = opts.editor;
|
|
2808
|
+ this.title = this._t(this.name);
|
|
2809
|
+ Button.__super__.constructor.call(this, opts);
|
|
2810
|
+ }
|
|
2811
|
+
|
|
2812
|
+ Button.prototype._init = function() {
|
|
2813
|
+ var k, len, ref, tag;
|
|
2814
|
+ this.render();
|
|
2815
|
+ this.el.on('mousedown', (function(_this) {
|
|
2816
|
+ return function(e) {
|
|
2817
|
+ var exceed, noFocus, param;
|
|
2818
|
+ e.preventDefault();
|
|
2819
|
+ noFocus = _this.needFocus && !_this.editor.inputManager.focused;
|
|
2820
|
+ if (_this.el.hasClass('disabled') || noFocus) {
|
|
2821
|
+ return false;
|
|
2822
|
+ }
|
|
2823
|
+ if (_this.menu) {
|
|
2824
|
+ _this.wrapper.toggleClass('menu-on').siblings('li').removeClass('menu-on');
|
|
2825
|
+ if (_this.wrapper.is('.menu-on')) {
|
|
2826
|
+ exceed = _this.menuWrapper.offset().left + _this.menuWrapper.outerWidth() + 5 - _this.editor.wrapper.offset().left - _this.editor.wrapper.outerWidth();
|
|
2827
|
+ if (exceed > 0) {
|
|
2828
|
+ _this.menuWrapper.css({
|
|
2829
|
+ 'left': 'auto',
|
|
2830
|
+ 'right': 0
|
|
2831
|
+ });
|
|
2832
|
+ }
|
|
2833
|
+ _this.trigger('menuexpand');
|
|
2834
|
+ }
|
|
2835
|
+ return false;
|
|
2836
|
+ }
|
|
2837
|
+ param = _this.el.data('param');
|
|
2838
|
+ _this.command(param);
|
|
2839
|
+ return false;
|
|
2840
|
+ };
|
|
2841
|
+ })(this));
|
|
2842
|
+ this.wrapper.on('click', 'a.menu-item', (function(_this) {
|
|
2843
|
+ return function(e) {
|
|
2844
|
+ var btn, noFocus, param;
|
|
2845
|
+ e.preventDefault();
|
|
2846
|
+ btn = $(e.currentTarget);
|
|
2847
|
+ _this.wrapper.removeClass('menu-on');
|
|
2848
|
+ noFocus = _this.needFocus && !_this.editor.inputManager.focused;
|
|
2849
|
+ if (btn.hasClass('disabled') || noFocus) {
|
|
2850
|
+ return false;
|
|
2851
|
+ }
|
|
2852
|
+ _this.editor.toolbar.wrapper.removeClass('menu-on');
|
|
2853
|
+ param = btn.data('param');
|
|
2854
|
+ _this.command(param);
|
|
2855
|
+ return false;
|
|
2856
|
+ };
|
|
2857
|
+ })(this));
|
|
2858
|
+ this.wrapper.on('mousedown', 'a.menu-item', function(e) {
|
|
2859
|
+ return false;
|
|
2860
|
+ });
|
|
2861
|
+ this.editor.on('blur', (function(_this) {
|
|
2862
|
+ return function() {
|
|
2863
|
+ var editorActive;
|
|
2864
|
+ editorActive = _this.editor.body.is(':visible') && _this.editor.body.is('[contenteditable]');
|
|
2865
|
+ if (!(editorActive && !_this.editor.clipboard.pasting)) {
|
|
2866
|
+ return;
|
|
2867
|
+ }
|
|
2868
|
+ _this.setActive(false);
|
|
2869
|
+ return _this.setDisabled(false);
|
|
2870
|
+ };
|
|
2871
|
+ })(this));
|
|
2872
|
+ if (this.shortcut != null) {
|
|
2873
|
+ this.editor.hotkeys.add(this.shortcut, (function(_this) {
|
|
2874
|
+ return function(e) {
|
|
2875
|
+ _this.el.mousedown();
|
|
2876
|
+ return false;
|
|
2877
|
+ };
|
|
2878
|
+ })(this));
|
|
2879
|
+ }
|
|
2880
|
+ ref = this.htmlTag.split(',');
|
|
2881
|
+ for (k = 0, len = ref.length; k < len; k++) {
|
|
2882
|
+ tag = ref[k];
|
|
2883
|
+ tag = $.trim(tag);
|
|
2884
|
+ if (tag && $.inArray(tag, this.editor.formatter._allowedTags) < 0) {
|
|
2885
|
+ this.editor.formatter._allowedTags.push(tag);
|
|
2886
|
+ }
|
|
2887
|
+ }
|
|
2888
|
+ return this.editor.on('selectionchanged', (function(_this) {
|
|
2889
|
+ return function(e) {
|
|
2890
|
+ if (_this.editor.inputManager.focused) {
|
|
2891
|
+ return _this._status();
|
|
2892
|
+ }
|
|
2893
|
+ };
|
|
2894
|
+ })(this));
|
|
2895
|
+ };
|
|
2896
|
+
|
|
2897
|
+ Button.prototype.iconClassOf = function(icon) {
|
|
2898
|
+ if (icon) {
|
|
2899
|
+ return "simditor-icon simditor-icon-" + icon;
|
|
2900
|
+ } else {
|
|
2901
|
+ return '';
|
|
2902
|
+ }
|
|
2903
|
+ };
|
|
2904
|
+
|
|
2905
|
+ Button.prototype.setIcon = function(icon) {
|
|
2906
|
+ return this.el.find('span').removeClass().addClass(this.iconClassOf(icon)).text(this.text);
|
|
2907
|
+ };
|
|
2908
|
+
|
|
2909
|
+ Button.prototype.render = function() {
|
|
2910
|
+ this.wrapper = $(this._tpl.item).appendTo(this.editor.toolbar.list);
|
|
2911
|
+ this.el = this.wrapper.find('a.toolbar-item');
|
|
2912
|
+ this.el.attr('title', this.title).addClass("toolbar-item-" + this.name).data('button', this);
|
|
2913
|
+ this.setIcon(this.icon);
|
|
2914
|
+ if (!this.menu) {
|
|
2915
|
+ return;
|
|
2916
|
+ }
|
|
2917
|
+ this.menuWrapper = $(this._tpl.menuWrapper).appendTo(this.wrapper);
|
|
2918
|
+ this.menuWrapper.addClass("toolbar-menu-" + this.name);
|
|
2919
|
+ return this.renderMenu();
|
|
2920
|
+ };
|
|
2921
|
+
|
|
2922
|
+ Button.prototype.renderMenu = function() {
|
|
2923
|
+ var $menuBtnEl, $menuItemEl, k, len, menuItem, ref, ref1, results;
|
|
2924
|
+ if (!$.isArray(this.menu)) {
|
|
2925
|
+ return;
|
|
2926
|
+ }
|
|
2927
|
+ this.menuEl = $('<ul/>').appendTo(this.menuWrapper);
|
|
2928
|
+ ref = this.menu;
|
|
2929
|
+ results = [];
|
|
2930
|
+ for (k = 0, len = ref.length; k < len; k++) {
|
|
2931
|
+ menuItem = ref[k];
|
|
2932
|
+ if (menuItem === '|') {
|
|
2933
|
+ $(this._tpl.separator).appendTo(this.menuEl);
|
|
2934
|
+ continue;
|
|
2935
|
+ }
|
|
2936
|
+ $menuItemEl = $(this._tpl.menuItem).appendTo(this.menuEl);
|
|
2937
|
+ $menuBtnEl = $menuItemEl.find('a.menu-item').attr({
|
|
2938
|
+ 'title': (ref1 = menuItem.title) != null ? ref1 : menuItem.text,
|
|
2939
|
+ 'data-param': menuItem.param
|
|
2940
|
+ }).addClass('menu-item-' + menuItem.name);
|
|
2941
|
+ if (menuItem.icon) {
|
|
2942
|
+ results.push($menuBtnEl.find('span').addClass(this.iconClassOf(menuItem.icon)));
|
|
2943
|
+ } else {
|
|
2944
|
+ results.push($menuBtnEl.find('span').text(menuItem.text));
|
|
2945
|
+ }
|
|
2946
|
+ }
|
|
2947
|
+ return results;
|
|
2948
|
+ };
|
|
2949
|
+
|
|
2950
|
+ Button.prototype.setActive = function(active) {
|
|
2951
|
+ if (active === this.active) {
|
|
2952
|
+ return;
|
|
2953
|
+ }
|
|
2954
|
+ this.active = active;
|
|
2955
|
+ return this.el.toggleClass('active', this.active);
|
|
2956
|
+ };
|
|
2957
|
+
|
|
2958
|
+ Button.prototype.setDisabled = function(disabled) {
|
|
2959
|
+ if (disabled === this.disabled) {
|
|
2960
|
+ return;
|
|
2961
|
+ }
|
|
2962
|
+ this.disabled = disabled;
|
|
2963
|
+ return this.el.toggleClass('disabled', this.disabled);
|
|
2964
|
+ };
|
|
2965
|
+
|
|
2966
|
+ Button.prototype._disableStatus = function() {
|
|
2967
|
+ var disabled, endNodes, startNodes;
|
|
2968
|
+ startNodes = this.editor.selection.startNodes();
|
|
2969
|
+ endNodes = this.editor.selection.endNodes();
|
|
2970
|
+ disabled = startNodes.filter(this.disableTag).length > 0 || endNodes.filter(this.disableTag).length > 0;
|
|
2971
|
+ this.setDisabled(disabled);
|
|
2972
|
+ if (this.disabled) {
|
|
2973
|
+ this.setActive(false);
|
|
2974
|
+ }
|
|
2975
|
+ return this.disabled;
|
|
2976
|
+ };
|
|
2977
|
+
|
|
2978
|
+ Button.prototype._activeStatus = function() {
|
|
2979
|
+ var active, endNode, endNodes, startNode, startNodes;
|
|
2980
|
+ startNodes = this.editor.selection.startNodes();
|
|
2981
|
+ endNodes = this.editor.selection.endNodes();
|
|
2982
|
+ startNode = startNodes.filter(this.htmlTag);
|
|
2983
|
+ endNode = endNodes.filter(this.htmlTag);
|
|
2984
|
+ active = startNode.length > 0 && endNode.length > 0 && startNode.is(endNode);
|
|
2985
|
+ this.node = active ? startNode : null;
|
|
2986
|
+ this.setActive(active);
|
|
2987
|
+ return this.active;
|
|
2988
|
+ };
|
|
2989
|
+
|
|
2990
|
+ Button.prototype._status = function() {
|
|
2991
|
+ this._disableStatus();
|
|
2992
|
+ if (this.disabled) {
|
|
2993
|
+ return;
|
|
2994
|
+ }
|
|
2995
|
+ return this._activeStatus();
|
|
2996
|
+ };
|
|
2997
|
+
|
|
2998
|
+ Button.prototype.command = function(param) {};
|
|
2999
|
+
|
|
3000
|
+ Button.prototype._t = function() {
|
|
3001
|
+ var args, ref, result;
|
|
3002
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
3003
|
+ result = Button.__super__._t.apply(this, args);
|
|
3004
|
+ if (!result) {
|
|
3005
|
+ result = (ref = this.editor)._t.apply(ref, args);
|
|
3006
|
+ }
|
|
3007
|
+ return result;
|
|
3008
|
+ };
|
|
3009
|
+
|
|
3010
|
+ return Button;
|
|
3011
|
+
|
|
3012
|
+})(SimpleModule);
|
|
3013
|
+
|
|
3014
|
+Simditor.Button = Button;
|
|
3015
|
+
|
|
3016
|
+Popover = (function(superClass) {
|
|
3017
|
+ extend(Popover, superClass);
|
|
3018
|
+
|
|
3019
|
+ Popover.prototype.offset = {
|
|
3020
|
+ top: 4,
|
|
3021
|
+ left: 0
|
|
3022
|
+ };
|
|
3023
|
+
|
|
3024
|
+ Popover.prototype.target = null;
|
|
3025
|
+
|
|
3026
|
+ Popover.prototype.active = false;
|
|
3027
|
+
|
|
3028
|
+ function Popover(opts) {
|
|
3029
|
+ this.button = opts.button;
|
|
3030
|
+ this.editor = opts.button.editor;
|
|
3031
|
+ Popover.__super__.constructor.call(this, opts);
|
|
3032
|
+ }
|
|
3033
|
+
|
|
3034
|
+ Popover.prototype._init = function() {
|
|
3035
|
+ this.el = $('<div class="simditor-popover"></div>').appendTo(this.editor.el).data('popover', this);
|
|
3036
|
+ this.render();
|
|
3037
|
+ this.el.on('mouseenter', (function(_this) {
|
|
3038
|
+ return function(e) {
|
|
3039
|
+ return _this.el.addClass('hover');
|
|
3040
|
+ };
|
|
3041
|
+ })(this));
|
|
3042
|
+ return this.el.on('mouseleave', (function(_this) {
|
|
3043
|
+ return function(e) {
|
|
3044
|
+ return _this.el.removeClass('hover');
|
|
3045
|
+ };
|
|
3046
|
+ })(this));
|
|
3047
|
+ };
|
|
3048
|
+
|
|
3049
|
+ Popover.prototype.render = function() {};
|
|
3050
|
+
|
|
3051
|
+ Popover.prototype._initLabelWidth = function() {
|
|
3052
|
+ var $fields;
|
|
3053
|
+ $fields = this.el.find('.settings-field');
|
|
3054
|
+ if (!($fields.length > 0)) {
|
|
3055
|
+ return;
|
|
3056
|
+ }
|
|
3057
|
+ this._labelWidth = 0;
|
|
3058
|
+ $fields.each((function(_this) {
|
|
3059
|
+ return function(i, field) {
|
|
3060
|
+ var $field, $label;
|
|
3061
|
+ $field = $(field);
|
|
3062
|
+ $label = $field.find('label');
|
|
3063
|
+ if (!($label.length > 0)) {
|
|
3064
|
+ return;
|
|
3065
|
+ }
|
|
3066
|
+ return _this._labelWidth = Math.max(_this._labelWidth, $label.width());
|
|
3067
|
+ };
|
|
3068
|
+ })(this));
|
|
3069
|
+ return $fields.find('label').width(this._labelWidth);
|
|
3070
|
+ };
|
|
3071
|
+
|
|
3072
|
+ Popover.prototype.show = function($target, position) {
|
|
3073
|
+ if (position == null) {
|
|
3074
|
+ position = 'bottom';
|
|
3075
|
+ }
|
|
3076
|
+ if ($target == null) {
|
|
3077
|
+ return;
|
|
3078
|
+ }
|
|
3079
|
+ this.el.siblings('.simditor-popover').each(function(i, popover) {
|
|
3080
|
+ popover = $(popover).data('popover');
|
|
3081
|
+ if (popover.active) {
|
|
3082
|
+ return popover.hide();
|
|
3083
|
+ }
|
|
3084
|
+ });
|
|
3085
|
+ if (this.active && this.target) {
|
|
3086
|
+ this.target.removeClass('selected');
|
|
3087
|
+ }
|
|
3088
|
+ this.target = $target.addClass('selected');
|
|
3089
|
+ if (this.active) {
|
|
3090
|
+ this.refresh(position);
|
|
3091
|
+ return this.trigger('popovershow');
|
|
3092
|
+ } else {
|
|
3093
|
+ this.active = true;
|
|
3094
|
+ this.el.css({
|
|
3095
|
+ left: -9999
|
|
3096
|
+ }).show();
|
|
3097
|
+ if (!this._labelWidth) {
|
|
3098
|
+ this._initLabelWidth();
|
|
3099
|
+ }
|
|
3100
|
+ this.editor.util.reflow();
|
|
3101
|
+ this.refresh(position);
|
|
3102
|
+ return this.trigger('popovershow');
|
|
3103
|
+ }
|
|
3104
|
+ };
|
|
3105
|
+
|
|
3106
|
+ Popover.prototype.hide = function() {
|
|
3107
|
+ if (!this.active) {
|
|
3108
|
+ return;
|
|
3109
|
+ }
|
|
3110
|
+ if (this.target) {
|
|
3111
|
+ this.target.removeClass('selected');
|
|
3112
|
+ }
|
|
3113
|
+ this.target = null;
|
|
3114
|
+ this.active = false;
|
|
3115
|
+ this.el.hide();
|
|
3116
|
+ return this.trigger('popoverhide');
|
|
3117
|
+ };
|
|
3118
|
+
|
|
3119
|
+ Popover.prototype.refresh = function(position) {
|
|
3120
|
+ var editorOffset, left, maxLeft, targetH, targetOffset, top;
|
|
3121
|
+ if (position == null) {
|
|
3122
|
+ position = 'bottom';
|
|
3123
|
+ }
|
|
3124
|
+ if (!this.active) {
|
|
3125
|
+ return;
|
|
3126
|
+ }
|
|
3127
|
+ editorOffset = this.editor.el.offset();
|
|
3128
|
+ targetOffset = this.target.offset();
|
|
3129
|
+ targetH = this.target.outerHeight();
|
|
3130
|
+ if (position === 'bottom') {
|
|
3131
|
+ top = targetOffset.top - editorOffset.top + targetH;
|
|
3132
|
+ } else if (position === 'top') {
|
|
3133
|
+ top = targetOffset.top - editorOffset.top - this.el.height();
|
|
3134
|
+ }
|
|
3135
|
+ maxLeft = this.editor.wrapper.width() - this.el.outerWidth() - 10;
|
|
3136
|
+ left = Math.min(targetOffset.left - editorOffset.left, maxLeft);
|
|
3137
|
+ return this.el.css({
|
|
3138
|
+ top: top + this.offset.top,
|
|
3139
|
+ left: left + this.offset.left
|
|
3140
|
+ });
|
|
3141
|
+ };
|
|
3142
|
+
|
|
3143
|
+ Popover.prototype.destroy = function() {
|
|
3144
|
+ this.target = null;
|
|
3145
|
+ this.active = false;
|
|
3146
|
+ this.editor.off('.linkpopover');
|
|
3147
|
+ return this.el.remove();
|
|
3148
|
+ };
|
|
3149
|
+
|
|
3150
|
+ Popover.prototype._t = function() {
|
|
3151
|
+ var args, ref, result;
|
|
3152
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
3153
|
+ result = Popover.__super__._t.apply(this, args);
|
|
3154
|
+ if (!result) {
|
|
3155
|
+ result = (ref = this.button)._t.apply(ref, args);
|
|
3156
|
+ }
|
|
3157
|
+ return result;
|
|
3158
|
+ };
|
|
3159
|
+
|
|
3160
|
+ return Popover;
|
|
3161
|
+
|
|
3162
|
+})(SimpleModule);
|
|
3163
|
+
|
|
3164
|
+Simditor.Popover = Popover;
|
|
3165
|
+
|
|
3166
|
+TitleButton = (function(superClass) {
|
|
3167
|
+ extend(TitleButton, superClass);
|
|
3168
|
+
|
|
3169
|
+ function TitleButton() {
|
|
3170
|
+ return TitleButton.__super__.constructor.apply(this, arguments);
|
|
3171
|
+ }
|
|
3172
|
+
|
|
3173
|
+ TitleButton.prototype.name = 'title';
|
|
3174
|
+
|
|
3175
|
+ TitleButton.prototype.htmlTag = 'h1, h2, h3, h4, h5';
|
|
3176
|
+
|
|
3177
|
+ TitleButton.prototype.disableTag = 'pre, table';
|
|
3178
|
+
|
|
3179
|
+ TitleButton.prototype._init = function() {
|
|
3180
|
+ this.menu = [
|
|
3181
|
+ {
|
|
3182
|
+ name: 'normal',
|
|
3183
|
+ text: this._t('normalText'),
|
|
3184
|
+ param: 'p'
|
|
3185
|
+ }, '|', {
|
|
3186
|
+ name: 'h1',
|
|
3187
|
+ text: this._t('title') + ' 1',
|
|
3188
|
+ param: 'h1'
|
|
3189
|
+ }, {
|
|
3190
|
+ name: 'h2',
|
|
3191
|
+ text: this._t('title') + ' 2',
|
|
3192
|
+ param: 'h2'
|
|
3193
|
+ }, {
|
|
3194
|
+ name: 'h3',
|
|
3195
|
+ text: this._t('title') + ' 3',
|
|
3196
|
+ param: 'h3'
|
|
3197
|
+ }, {
|
|
3198
|
+ name: 'h4',
|
|
3199
|
+ text: this._t('title') + ' 4',
|
|
3200
|
+ param: 'h4'
|
|
3201
|
+ }, {
|
|
3202
|
+ name: 'h5',
|
|
3203
|
+ text: this._t('title') + ' 5',
|
|
3204
|
+ param: 'h5'
|
|
3205
|
+ }
|
|
3206
|
+ ];
|
|
3207
|
+ return TitleButton.__super__._init.call(this);
|
|
3208
|
+ };
|
|
3209
|
+
|
|
3210
|
+ TitleButton.prototype.setActive = function(active, param) {
|
|
3211
|
+ TitleButton.__super__.setActive.call(this, active);
|
|
3212
|
+ if (active) {
|
|
3213
|
+ param || (param = this.node[0].tagName.toLowerCase());
|
|
3214
|
+ }
|
|
3215
|
+ this.el.removeClass('active-p active-h1 active-h2 active-h3 active-h4 active-h5');
|
|
3216
|
+ if (active) {
|
|
3217
|
+ return this.el.addClass('active active-' + param);
|
|
3218
|
+ }
|
|
3219
|
+ };
|
|
3220
|
+
|
|
3221
|
+ TitleButton.prototype.command = function(param) {
|
|
3222
|
+ var $rootNodes;
|
|
3223
|
+ $rootNodes = this.editor.selection.rootNodes();
|
|
3224
|
+ this.editor.selection.save();
|
|
3225
|
+ $rootNodes.each((function(_this) {
|
|
3226
|
+ return function(i, node) {
|
|
3227
|
+ var $node;
|
|
3228
|
+ $node = $(node);
|
|
3229
|
+ if ($node.is('blockquote') || $node.is(param) || $node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node)) {
|
|
3230
|
+ return;
|
|
3231
|
+ }
|
|
3232
|
+ return $('<' + param + '/>').append($node.contents()).replaceAll($node);
|
|
3233
|
+ };
|
|
3234
|
+ })(this));
|
|
3235
|
+ this.editor.selection.restore();
|
|
3236
|
+ return this.editor.trigger('valuechanged');
|
|
3237
|
+ };
|
|
3238
|
+
|
|
3239
|
+ return TitleButton;
|
|
3240
|
+
|
|
3241
|
+})(Button);
|
|
3242
|
+
|
|
3243
|
+Simditor.Toolbar.addButton(TitleButton);
|
|
3244
|
+
|
|
3245
|
+FontScaleButton = (function(superClass) {
|
|
3246
|
+ extend(FontScaleButton, superClass);
|
|
3247
|
+
|
|
3248
|
+ function FontScaleButton() {
|
|
3249
|
+ return FontScaleButton.__super__.constructor.apply(this, arguments);
|
|
3250
|
+ }
|
|
3251
|
+
|
|
3252
|
+ FontScaleButton.prototype.name = 'fontScale';
|
|
3253
|
+
|
|
3254
|
+ FontScaleButton.prototype.icon = 'font';
|
|
3255
|
+
|
|
3256
|
+ FontScaleButton.prototype.disableTag = 'pre';
|
|
3257
|
+
|
|
3258
|
+ FontScaleButton.prototype.htmlTag = 'span';
|
|
3259
|
+
|
|
3260
|
+ FontScaleButton.prototype.sizeMap = {
|
|
3261
|
+ 'x-large': '1.5em',
|
|
3262
|
+ 'large': '1.25em',
|
|
3263
|
+ 'small': '.75em',
|
|
3264
|
+ 'x-small': '.5em'
|
|
3265
|
+ };
|
|
3266
|
+
|
|
3267
|
+ FontScaleButton.prototype._init = function() {
|
|
3268
|
+ this.menu = [
|
|
3269
|
+ {
|
|
3270
|
+ name: '150%',
|
|
3271
|
+ text: this._t('fontScaleXLarge'),
|
|
3272
|
+ param: '5'
|
|
3273
|
+ }, {
|
|
3274
|
+ name: '125%',
|
|
3275
|
+ text: this._t('fontScaleLarge'),
|
|
3276
|
+ param: '4'
|
|
3277
|
+ }, {
|
|
3278
|
+ name: '100%',
|
|
3279
|
+ text: this._t('fontScaleNormal'),
|
|
3280
|
+ param: '3'
|
|
3281
|
+ }, {
|
|
3282
|
+ name: '75%',
|
|
3283
|
+ text: this._t('fontScaleSmall'),
|
|
3284
|
+ param: '2'
|
|
3285
|
+ }, {
|
|
3286
|
+ name: '50%',
|
|
3287
|
+ text: this._t('fontScaleXSmall'),
|
|
3288
|
+ param: '1'
|
|
3289
|
+ }
|
|
3290
|
+ ];
|
|
3291
|
+ return FontScaleButton.__super__._init.call(this);
|
|
3292
|
+ };
|
|
3293
|
+
|
|
3294
|
+ FontScaleButton.prototype._activeStatus = function() {
|
|
3295
|
+ var active, endNode, endNodes, range, startNode, startNodes;
|
|
3296
|
+ range = this.editor.selection.range();
|
|
3297
|
+ startNodes = this.editor.selection.startNodes();
|
|
3298
|
+ endNodes = this.editor.selection.endNodes();
|
|
3299
|
+ startNode = startNodes.filter('span[style*="font-size"]');
|
|
3300
|
+ endNode = endNodes.filter('span[style*="font-size"]');
|
|
3301
|
+ active = startNodes.length > 0 && endNodes.length > 0 && startNode.is(endNode);
|
|
3302
|
+ this.setActive(active);
|
|
3303
|
+ return this.active;
|
|
3304
|
+ };
|
|
3305
|
+
|
|
3306
|
+ FontScaleButton.prototype.command = function(param) {
|
|
3307
|
+ var $scales, containerNode, range;
|
|
3308
|
+ range = this.editor.selection.range();
|
|
3309
|
+ if (range.collapsed) {
|
|
3310
|
+ return;
|
|
3311
|
+ }
|
|
3312
|
+ document.execCommand('styleWithCSS', false, true);
|
|
3313
|
+ document.execCommand('fontSize', false, param);
|
|
3314
|
+ document.execCommand('styleWithCSS', false, false);
|
|
3315
|
+ this.editor.selection.reset();
|
|
3316
|
+ this.editor.selection.range();
|
|
3317
|
+ containerNode = this.editor.selection.containerNode();
|
|
3318
|
+ if (containerNode[0].nodeType === Node.TEXT_NODE) {
|
|
3319
|
+ $scales = containerNode.closest('span[style*="font-size"]');
|
|
3320
|
+ } else {
|
|
3321
|
+ $scales = containerNode.find('span[style*="font-size"]');
|
|
3322
|
+ }
|
|
3323
|
+ $scales.each((function(_this) {
|
|
3324
|
+ return function(i, n) {
|
|
3325
|
+ var $span, size;
|
|
3326
|
+ $span = $(n);
|
|
3327
|
+ size = n.style.fontSize;
|
|
3328
|
+ if (/large|x-large|small|x-small/.test(size)) {
|
|
3329
|
+ return $span.css('fontSize', _this.sizeMap[size]);
|
|
3330
|
+ } else if (size === 'medium') {
|
|
3331
|
+ return $span.replaceWith($span.contents());
|
|
3332
|
+ }
|
|
3333
|
+ };
|
|
3334
|
+ })(this));
|
|
3335
|
+ return this.editor.trigger('valuechanged');
|
|
3336
|
+ };
|
|
3337
|
+
|
|
3338
|
+ return FontScaleButton;
|
|
3339
|
+
|
|
3340
|
+})(Button);
|
|
3341
|
+
|
|
3342
|
+Simditor.Toolbar.addButton(FontScaleButton);
|
|
3343
|
+
|
|
3344
|
+BoldButton = (function(superClass) {
|
|
3345
|
+ extend(BoldButton, superClass);
|
|
3346
|
+
|
|
3347
|
+ function BoldButton() {
|
|
3348
|
+ return BoldButton.__super__.constructor.apply(this, arguments);
|
|
3349
|
+ }
|
|
3350
|
+
|
|
3351
|
+ BoldButton.prototype.name = 'bold';
|
|
3352
|
+
|
|
3353
|
+ BoldButton.prototype.icon = 'bold';
|
|
3354
|
+
|
|
3355
|
+ BoldButton.prototype.htmlTag = 'b, strong';
|
|
3356
|
+
|
|
3357
|
+ BoldButton.prototype.disableTag = 'pre';
|
|
3358
|
+
|
|
3359
|
+ BoldButton.prototype.shortcut = 'cmd+b';
|
|
3360
|
+
|
|
3361
|
+ BoldButton.prototype._init = function() {
|
|
3362
|
+ if (this.editor.util.os.mac) {
|
|
3363
|
+ this.title = this.title + ' ( Cmd + b )';
|
|
3364
|
+ } else {
|
|
3365
|
+ this.title = this.title + ' ( Ctrl + b )';
|
|
3366
|
+ this.shortcut = 'ctrl+b';
|
|
3367
|
+ }
|
|
3368
|
+ return BoldButton.__super__._init.call(this);
|
|
3369
|
+ };
|
|
3370
|
+
|
|
3371
|
+ BoldButton.prototype._activeStatus = function() {
|
|
3372
|
+ var active;
|
|
3373
|
+ active = document.queryCommandState('bold') === true;
|
|
3374
|
+ this.setActive(active);
|
|
3375
|
+ return this.active;
|
|
3376
|
+ };
|
|
3377
|
+
|
|
3378
|
+ BoldButton.prototype.command = function() {
|
|
3379
|
+ document.execCommand('bold');
|
|
3380
|
+ if (!this.editor.util.support.oninput) {
|
|
3381
|
+ this.editor.trigger('valuechanged');
|
|
3382
|
+ }
|
|
3383
|
+ return $(document).trigger('selectionchange');
|
|
3384
|
+ };
|
|
3385
|
+
|
|
3386
|
+ return BoldButton;
|
|
3387
|
+
|
|
3388
|
+})(Button);
|
|
3389
|
+
|
|
3390
|
+Simditor.Toolbar.addButton(BoldButton);
|
|
3391
|
+
|
|
3392
|
+ItalicButton = (function(superClass) {
|
|
3393
|
+ extend(ItalicButton, superClass);
|
|
3394
|
+
|
|
3395
|
+ function ItalicButton() {
|
|
3396
|
+ return ItalicButton.__super__.constructor.apply(this, arguments);
|
|
3397
|
+ }
|
|
3398
|
+
|
|
3399
|
+ ItalicButton.prototype.name = 'italic';
|
|
3400
|
+
|
|
3401
|
+ ItalicButton.prototype.icon = 'italic';
|
|
3402
|
+
|
|
3403
|
+ ItalicButton.prototype.htmlTag = 'i';
|
|
3404
|
+
|
|
3405
|
+ ItalicButton.prototype.disableTag = 'pre';
|
|
3406
|
+
|
|
3407
|
+ ItalicButton.prototype.shortcut = 'cmd+i';
|
|
3408
|
+
|
|
3409
|
+ ItalicButton.prototype._init = function() {
|
|
3410
|
+ if (this.editor.util.os.mac) {
|
|
3411
|
+ this.title = this.title + " ( Cmd + i )";
|
|
3412
|
+ } else {
|
|
3413
|
+ this.title = this.title + " ( Ctrl + i )";
|
|
3414
|
+ this.shortcut = 'ctrl+i';
|
|
3415
|
+ }
|
|
3416
|
+ return ItalicButton.__super__._init.call(this);
|
|
3417
|
+ };
|
|
3418
|
+
|
|
3419
|
+ ItalicButton.prototype._activeStatus = function() {
|
|
3420
|
+ var active;
|
|
3421
|
+ active = document.queryCommandState('italic') === true;
|
|
3422
|
+ this.setActive(active);
|
|
3423
|
+ return this.active;
|
|
3424
|
+ };
|
|
3425
|
+
|
|
3426
|
+ ItalicButton.prototype.command = function() {
|
|
3427
|
+ document.execCommand('italic');
|
|
3428
|
+ if (!this.editor.util.support.oninput) {
|
|
3429
|
+ this.editor.trigger('valuechanged');
|
|
3430
|
+ }
|
|
3431
|
+ return $(document).trigger('selectionchange');
|
|
3432
|
+ };
|
|
3433
|
+
|
|
3434
|
+ return ItalicButton;
|
|
3435
|
+
|
|
3436
|
+})(Button);
|
|
3437
|
+
|
|
3438
|
+Simditor.Toolbar.addButton(ItalicButton);
|
|
3439
|
+
|
|
3440
|
+UnderlineButton = (function(superClass) {
|
|
3441
|
+ extend(UnderlineButton, superClass);
|
|
3442
|
+
|
|
3443
|
+ function UnderlineButton() {
|
|
3444
|
+ return UnderlineButton.__super__.constructor.apply(this, arguments);
|
|
3445
|
+ }
|
|
3446
|
+
|
|
3447
|
+ UnderlineButton.prototype.name = 'underline';
|
|
3448
|
+
|
|
3449
|
+ UnderlineButton.prototype.icon = 'underline';
|
|
3450
|
+
|
|
3451
|
+ UnderlineButton.prototype.htmlTag = 'u';
|
|
3452
|
+
|
|
3453
|
+ UnderlineButton.prototype.disableTag = 'pre';
|
|
3454
|
+
|
|
3455
|
+ UnderlineButton.prototype.shortcut = 'cmd+u';
|
|
3456
|
+
|
|
3457
|
+ UnderlineButton.prototype.render = function() {
|
|
3458
|
+ if (this.editor.util.os.mac) {
|
|
3459
|
+ this.title = this.title + ' ( Cmd + u )';
|
|
3460
|
+ } else {
|
|
3461
|
+ this.title = this.title + ' ( Ctrl + u )';
|
|
3462
|
+ this.shortcut = 'ctrl+u';
|
|
3463
|
+ }
|
|
3464
|
+ return UnderlineButton.__super__.render.call(this);
|
|
3465
|
+ };
|
|
3466
|
+
|
|
3467
|
+ UnderlineButton.prototype._activeStatus = function() {
|
|
3468
|
+ var active;
|
|
3469
|
+ active = document.queryCommandState('underline') === true;
|
|
3470
|
+ this.setActive(active);
|
|
3471
|
+ return this.active;
|
|
3472
|
+ };
|
|
3473
|
+
|
|
3474
|
+ UnderlineButton.prototype.command = function() {
|
|
3475
|
+ document.execCommand('underline');
|
|
3476
|
+ if (!this.editor.util.support.oninput) {
|
|
3477
|
+ this.editor.trigger('valuechanged');
|
|
3478
|
+ }
|
|
3479
|
+ return $(document).trigger('selectionchange');
|
|
3480
|
+ };
|
|
3481
|
+
|
|
3482
|
+ return UnderlineButton;
|
|
3483
|
+
|
|
3484
|
+})(Button);
|
|
3485
|
+
|
|
3486
|
+Simditor.Toolbar.addButton(UnderlineButton);
|
|
3487
|
+
|
|
3488
|
+ColorButton = (function(superClass) {
|
|
3489
|
+ extend(ColorButton, superClass);
|
|
3490
|
+
|
|
3491
|
+ function ColorButton() {
|
|
3492
|
+ return ColorButton.__super__.constructor.apply(this, arguments);
|
|
3493
|
+ }
|
|
3494
|
+
|
|
3495
|
+ ColorButton.prototype.name = 'color';
|
|
3496
|
+
|
|
3497
|
+ ColorButton.prototype.icon = 'tint';
|
|
3498
|
+
|
|
3499
|
+ ColorButton.prototype.disableTag = 'pre';
|
|
3500
|
+
|
|
3501
|
+ ColorButton.prototype.menu = true;
|
|
3502
|
+
|
|
3503
|
+ ColorButton.prototype.render = function() {
|
|
3504
|
+ var args;
|
|
3505
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
3506
|
+ return ColorButton.__super__.render.apply(this, args);
|
|
3507
|
+ };
|
|
3508
|
+
|
|
3509
|
+ ColorButton.prototype.renderMenu = function() {
|
|
3510
|
+ $('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper);
|
|
3511
|
+ this.menuWrapper.on('mousedown', '.color-list', function(e) {
|
|
3512
|
+ return false;
|
|
3513
|
+ });
|
|
3514
|
+ return this.menuWrapper.on('click', '.font-color', (function(_this) {
|
|
3515
|
+ return function(e) {
|
|
3516
|
+ var $link, $p, hex, range, rgb, textNode;
|
|
3517
|
+ _this.wrapper.removeClass('menu-on');
|
|
3518
|
+ $link = $(e.currentTarget);
|
|
3519
|
+ if ($link.hasClass('font-color-default')) {
|
|
3520
|
+ $p = _this.editor.body.find('p, li');
|
|
3521
|
+ if (!($p.length > 0)) {
|
|
3522
|
+ return;
|
|
3523
|
+ }
|
|
3524
|
+ rgb = window.getComputedStyle($p[0], null).getPropertyValue('color');
|
|
3525
|
+ hex = _this._convertRgbToHex(rgb);
|
|
3526
|
+ } else {
|
|
3527
|
+ rgb = window.getComputedStyle($link[0], null).getPropertyValue('background-color');
|
|
3528
|
+ hex = _this._convertRgbToHex(rgb);
|
|
3529
|
+ }
|
|
3530
|
+ if (!hex) {
|
|
3531
|
+ return;
|
|
3532
|
+ }
|
|
3533
|
+ range = _this.editor.selection.range();
|
|
3534
|
+ if (!$link.hasClass('font-color-default') && range.collapsed) {
|
|
3535
|
+ textNode = document.createTextNode(_this._t('coloredText'));
|
|
3536
|
+ range.insertNode(textNode);
|
|
3537
|
+ range.selectNodeContents(textNode);
|
|
3538
|
+ _this.editor.selection.range(range);
|
|
3539
|
+ }
|
|
3540
|
+ document.execCommand('styleWithCSS', false, true);
|
|
3541
|
+ document.execCommand('foreColor', false, hex);
|
|
3542
|
+ document.execCommand('styleWithCSS', false, false);
|
|
3543
|
+ if (!_this.editor.util.support.oninput) {
|
|
3544
|
+ return _this.editor.trigger('valuechanged');
|
|
3545
|
+ }
|
|
3546
|
+ };
|
|
3547
|
+ })(this));
|
|
3548
|
+ };
|
|
3549
|
+
|
|
3550
|
+ ColorButton.prototype._convertRgbToHex = function(rgb) {
|
|
3551
|
+ var match, re, rgbToHex;
|
|
3552
|
+ re = /rgb\((\d+),\s?(\d+),\s?(\d+)\)/g;
|
|
3553
|
+ match = re.exec(rgb);
|
|
3554
|
+ if (!match) {
|
|
3555
|
+ return '';
|
|
3556
|
+ }
|
|
3557
|
+ rgbToHex = function(r, g, b) {
|
|
3558
|
+ var componentToHex;
|
|
3559
|
+ componentToHex = function(c) {
|
|
3560
|
+ var hex;
|
|
3561
|
+ hex = c.toString(16);
|
|
3562
|
+ if (hex.length === 1) {
|
|
3563
|
+ return '0' + hex;
|
|
3564
|
+ } else {
|
|
3565
|
+ return hex;
|
|
3566
|
+ }
|
|
3567
|
+ };
|
|
3568
|
+ return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
|
|
3569
|
+ };
|
|
3570
|
+ return rgbToHex(match[1] * 1, match[2] * 1, match[3] * 1);
|
|
3571
|
+ };
|
|
3572
|
+
|
|
3573
|
+ return ColorButton;
|
|
3574
|
+
|
|
3575
|
+})(Button);
|
|
3576
|
+
|
|
3577
|
+Simditor.Toolbar.addButton(ColorButton);
|
|
3578
|
+
|
|
3579
|
+ListButton = (function(superClass) {
|
|
3580
|
+ extend(ListButton, superClass);
|
|
3581
|
+
|
|
3582
|
+ function ListButton() {
|
|
3583
|
+ return ListButton.__super__.constructor.apply(this, arguments);
|
|
3584
|
+ }
|
|
3585
|
+
|
|
3586
|
+ ListButton.prototype.type = '';
|
|
3587
|
+
|
|
3588
|
+ ListButton.prototype.disableTag = 'pre, table';
|
|
3589
|
+
|
|
3590
|
+ ListButton.prototype.command = function(param) {
|
|
3591
|
+ var $list, $rootNodes, anotherType;
|
|
3592
|
+ $rootNodes = this.editor.selection.blockNodes();
|
|
3593
|
+ anotherType = this.type === 'ul' ? 'ol' : 'ul';
|
|
3594
|
+ this.editor.selection.save();
|
|
3595
|
+ $list = null;
|
|
3596
|
+ $rootNodes.each((function(_this) {
|
|
3597
|
+ return function(i, node) {
|
|
3598
|
+ var $node;
|
|
3599
|
+ $node = $(node);
|
|
3600
|
+ if ($node.is('blockquote, li') || $node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node) || !$.contains(document, node)) {
|
|
3601
|
+ return;
|
|
3602
|
+ }
|
|
3603
|
+ if ($node.is(_this.type)) {
|
|
3604
|
+ $node.children('li').each(function(i, li) {
|
|
3605
|
+ var $childList, $li;
|
|
3606
|
+ $li = $(li);
|
|
3607
|
+ $childList = $li.children('ul, ol').insertAfter($node);
|
|
3608
|
+ return $('<p/>').append($(li).html() || _this.editor.util.phBr).insertBefore($node);
|
|
3609
|
+ });
|
|
3610
|
+ return $node.remove();
|
|
3611
|
+ } else if ($node.is(anotherType)) {
|
|
3612
|
+ return $('<' + _this.type + '/>').append($node.contents()).replaceAll($node);
|
|
3613
|
+ } else if ($list && $node.prev().is($list)) {
|
|
3614
|
+ $('<li/>').append($node.html() || _this.editor.util.phBr).appendTo($list);
|
|
3615
|
+ return $node.remove();
|
|
3616
|
+ } else {
|
|
3617
|
+ $list = $("<" + _this.type + "><li></li></" + _this.type + ">");
|
|
3618
|
+ $list.find('li').append($node.html() || _this.editor.util.phBr);
|
|
3619
|
+ return $list.replaceAll($node);
|
|
3620
|
+ }
|
|
3621
|
+ };
|
|
3622
|
+ })(this));
|
|
3623
|
+ this.editor.selection.restore();
|
|
3624
|
+ return this.editor.trigger('valuechanged');
|
|
3625
|
+ };
|
|
3626
|
+
|
|
3627
|
+ return ListButton;
|
|
3628
|
+
|
|
3629
|
+})(Button);
|
|
3630
|
+
|
|
3631
|
+OrderListButton = (function(superClass) {
|
|
3632
|
+ extend(OrderListButton, superClass);
|
|
3633
|
+
|
|
3634
|
+ function OrderListButton() {
|
|
3635
|
+ return OrderListButton.__super__.constructor.apply(this, arguments);
|
|
3636
|
+ }
|
|
3637
|
+
|
|
3638
|
+ OrderListButton.prototype.type = 'ol';
|
|
3639
|
+
|
|
3640
|
+ OrderListButton.prototype.name = 'ol';
|
|
3641
|
+
|
|
3642
|
+ OrderListButton.prototype.icon = 'list-ol';
|
|
3643
|
+
|
|
3644
|
+ OrderListButton.prototype.htmlTag = 'ol';
|
|
3645
|
+
|
|
3646
|
+ OrderListButton.prototype.shortcut = 'cmd+/';
|
|
3647
|
+
|
|
3648
|
+ OrderListButton.prototype._init = function() {
|
|
3649
|
+ if (this.editor.util.os.mac) {
|
|
3650
|
+ this.title = this.title + ' ( Cmd + / )';
|
|
3651
|
+ } else {
|
|
3652
|
+ this.title = this.title + ' ( ctrl + / )';
|
|
3653
|
+ this.shortcut = 'ctrl+/';
|
|
3654
|
+ }
|
|
3655
|
+ return OrderListButton.__super__._init.call(this);
|
|
3656
|
+ };
|
|
3657
|
+
|
|
3658
|
+ return OrderListButton;
|
|
3659
|
+
|
|
3660
|
+})(ListButton);
|
|
3661
|
+
|
|
3662
|
+UnorderListButton = (function(superClass) {
|
|
3663
|
+ extend(UnorderListButton, superClass);
|
|
3664
|
+
|
|
3665
|
+ function UnorderListButton() {
|
|
3666
|
+ return UnorderListButton.__super__.constructor.apply(this, arguments);
|
|
3667
|
+ }
|
|
3668
|
+
|
|
3669
|
+ UnorderListButton.prototype.type = 'ul';
|
|
3670
|
+
|
|
3671
|
+ UnorderListButton.prototype.name = 'ul';
|
|
3672
|
+
|
|
3673
|
+ UnorderListButton.prototype.icon = 'list-ul';
|
|
3674
|
+
|
|
3675
|
+ UnorderListButton.prototype.htmlTag = 'ul';
|
|
3676
|
+
|
|
3677
|
+ UnorderListButton.prototype.shortcut = 'cmd+.';
|
|
3678
|
+
|
|
3679
|
+ UnorderListButton.prototype._init = function() {
|
|
3680
|
+ if (this.editor.util.os.mac) {
|
|
3681
|
+ this.title = this.title + ' ( Cmd + . )';
|
|
3682
|
+ } else {
|
|
3683
|
+ this.title = this.title + ' ( Ctrl + . )';
|
|
3684
|
+ this.shortcut = 'ctrl+.';
|
|
3685
|
+ }
|
|
3686
|
+ return UnorderListButton.__super__._init.call(this);
|
|
3687
|
+ };
|
|
3688
|
+
|
|
3689
|
+ return UnorderListButton;
|
|
3690
|
+
|
|
3691
|
+})(ListButton);
|
|
3692
|
+
|
|
3693
|
+Simditor.Toolbar.addButton(OrderListButton);
|
|
3694
|
+
|
|
3695
|
+Simditor.Toolbar.addButton(UnorderListButton);
|
|
3696
|
+
|
|
3697
|
+BlockquoteButton = (function(superClass) {
|
|
3698
|
+ extend(BlockquoteButton, superClass);
|
|
3699
|
+
|
|
3700
|
+ function BlockquoteButton() {
|
|
3701
|
+ return BlockquoteButton.__super__.constructor.apply(this, arguments);
|
|
3702
|
+ }
|
|
3703
|
+
|
|
3704
|
+ BlockquoteButton.prototype.name = 'blockquote';
|
|
3705
|
+
|
|
3706
|
+ BlockquoteButton.prototype.icon = 'quote-left';
|
|
3707
|
+
|
|
3708
|
+ BlockquoteButton.prototype.htmlTag = 'blockquote';
|
|
3709
|
+
|
|
3710
|
+ BlockquoteButton.prototype.disableTag = 'pre, table';
|
|
3711
|
+
|
|
3712
|
+ BlockquoteButton.prototype.command = function() {
|
|
3713
|
+ var $rootNodes, clearCache, nodeCache;
|
|
3714
|
+ $rootNodes = this.editor.selection.rootNodes();
|
|
3715
|
+ $rootNodes = $rootNodes.filter(function(i, node) {
|
|
3716
|
+ return !$(node).parent().is('blockquote');
|
|
3717
|
+ });
|
|
3718
|
+ this.editor.selection.save();
|
|
3719
|
+ nodeCache = [];
|
|
3720
|
+ clearCache = (function(_this) {
|
|
3721
|
+ return function() {
|
|
3722
|
+ if (nodeCache.length > 0) {
|
|
3723
|
+ $("<" + _this.htmlTag + "/>").insertBefore(nodeCache[0]).append(nodeCache);
|
|
3724
|
+ return nodeCache.length = 0;
|
|
3725
|
+ }
|
|
3726
|
+ };
|
|
3727
|
+ })(this);
|
|
3728
|
+ $rootNodes.each((function(_this) {
|
|
3729
|
+ return function(i, node) {
|
|
3730
|
+ var $node;
|
|
3731
|
+ $node = $(node);
|
|
3732
|
+ if (!$node.parent().is(_this.editor.body)) {
|
|
3733
|
+ return;
|
|
3734
|
+ }
|
|
3735
|
+ if ($node.is(_this.htmlTag)) {
|
|
3736
|
+ clearCache();
|
|
3737
|
+ return $node.children().unwrap();
|
|
3738
|
+ } else if ($node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node)) {
|
|
3739
|
+ return clearCache();
|
|
3740
|
+ } else {
|
|
3741
|
+ return nodeCache.push(node);
|
|
3742
|
+ }
|
|
3743
|
+ };
|
|
3744
|
+ })(this));
|
|
3745
|
+ clearCache();
|
|
3746
|
+ this.editor.selection.restore();
|
|
3747
|
+ return this.editor.trigger('valuechanged');
|
|
3748
|
+ };
|
|
3749
|
+
|
|
3750
|
+ return BlockquoteButton;
|
|
3751
|
+
|
|
3752
|
+})(Button);
|
|
3753
|
+
|
|
3754
|
+Simditor.Toolbar.addButton(BlockquoteButton);
|
|
3755
|
+
|
|
3756
|
+CodeButton = (function(superClass) {
|
|
3757
|
+ extend(CodeButton, superClass);
|
|
3758
|
+
|
|
3759
|
+ function CodeButton() {
|
|
3760
|
+ return CodeButton.__super__.constructor.apply(this, arguments);
|
|
3761
|
+ }
|
|
3762
|
+
|
|
3763
|
+ CodeButton.prototype.name = 'code';
|
|
3764
|
+
|
|
3765
|
+ CodeButton.prototype.icon = 'code';
|
|
3766
|
+
|
|
3767
|
+ CodeButton.prototype.htmlTag = 'pre';
|
|
3768
|
+
|
|
3769
|
+ CodeButton.prototype.disableTag = 'ul, ol, table';
|
|
3770
|
+
|
|
3771
|
+ CodeButton.prototype._init = function() {
|
|
3772
|
+ CodeButton.__super__._init.call(this);
|
|
3773
|
+ this.editor.on('decorate', (function(_this) {
|
|
3774
|
+ return function(e, $el) {
|
|
3775
|
+ return $el.find('pre').each(function(i, pre) {
|
|
3776
|
+ return _this.decorate($(pre));
|
|
3777
|
+ });
|
|
3778
|
+ };
|
|
3779
|
+ })(this));
|
|
3780
|
+ return this.editor.on('undecorate', (function(_this) {
|
|
3781
|
+ return function(e, $el) {
|
|
3782
|
+ return $el.find('pre').each(function(i, pre) {
|
|
3783
|
+ return _this.undecorate($(pre));
|
|
3784
|
+ });
|
|
3785
|
+ };
|
|
3786
|
+ })(this));
|
|
3787
|
+ };
|
|
3788
|
+
|
|
3789
|
+ CodeButton.prototype.render = function() {
|
|
3790
|
+ var args;
|
|
3791
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
3792
|
+ CodeButton.__super__.render.apply(this, args);
|
|
3793
|
+ return this.popover = new CodePopover({
|
|
3794
|
+ button: this
|
|
3795
|
+ });
|
|
3796
|
+ };
|
|
3797
|
+
|
|
3798
|
+ CodeButton.prototype._checkMode = function() {
|
|
3799
|
+ var $blockNodes, range;
|
|
3800
|
+ range = this.editor.selection.range();
|
|
3801
|
+ if (($blockNodes = $(range.cloneContents()).find(this.editor.util.blockNodes.join(','))) > 0 || (range.collapsed && this.editor.selection.startNodes().filter('code').length === 0)) {
|
|
3802
|
+ this.inlineMode = false;
|
|
3803
|
+ return this.htmlTag = 'pre';
|
|
3804
|
+ } else {
|
|
3805
|
+ this.inlineMode = true;
|
|
3806
|
+ return this.htmlTag = 'code';
|
|
3807
|
+ }
|
|
3808
|
+ };
|
|
3809
|
+
|
|
3810
|
+ CodeButton.prototype._status = function() {
|
|
3811
|
+ this._checkMode();
|
|
3812
|
+ CodeButton.__super__._status.call(this);
|
|
3813
|
+ if (this.inlineMode) {
|
|
3814
|
+ return;
|
|
3815
|
+ }
|
|
3816
|
+ if (this.active) {
|
|
3817
|
+ return this.popover.show(this.node);
|
|
3818
|
+ } else {
|
|
3819
|
+ return this.popover.hide();
|
|
3820
|
+ }
|
|
3821
|
+ };
|
|
3822
|
+
|
|
3823
|
+ CodeButton.prototype.decorate = function($pre) {
|
|
3824
|
+ var $code, lang, ref, ref1;
|
|
3825
|
+ $code = $pre.find('> code');
|
|
3826
|
+ if ($code.length > 0) {
|
|
3827
|
+ lang = (ref = $code.attr('class')) != null ? (ref1 = ref.match(/lang-(\S+)/)) != null ? ref1[1] : void 0 : void 0;
|
|
3828
|
+ $code.contents().unwrap();
|
|
3829
|
+ if (lang) {
|
|
3830
|
+ return $pre.attr('data-lang', lang);
|
|
3831
|
+ }
|
|
3832
|
+ }
|
|
3833
|
+ };
|
|
3834
|
+
|
|
3835
|
+ CodeButton.prototype.undecorate = function($pre) {
|
|
3836
|
+ var $code, lang;
|
|
3837
|
+ lang = $pre.attr('data-lang');
|
|
3838
|
+ $code = $('<code/>');
|
|
3839
|
+ if (lang && lang !== -1) {
|
|
3840
|
+ $code.addClass('lang-' + lang);
|
|
3841
|
+ }
|
|
3842
|
+ return $pre.wrapInner($code).removeAttr('data-lang');
|
|
3843
|
+ };
|
|
3844
|
+
|
|
3845
|
+ CodeButton.prototype.command = function() {
|
|
3846
|
+ if (this.inlineMode) {
|
|
3847
|
+ return this._inlineCommand();
|
|
3848
|
+ } else {
|
|
3849
|
+ return this._blockCommand();
|
|
3850
|
+ }
|
|
3851
|
+ };
|
|
3852
|
+
|
|
3853
|
+ CodeButton.prototype._blockCommand = function() {
|
|
3854
|
+ var $rootNodes, clearCache, nodeCache, resultNodes;
|
|
3855
|
+ $rootNodes = this.editor.selection.rootNodes();
|
|
3856
|
+ nodeCache = [];
|
|
3857
|
+ resultNodes = [];
|
|
3858
|
+ clearCache = (function(_this) {
|
|
3859
|
+ return function() {
|
|
3860
|
+ var $pre;
|
|
3861
|
+ if (!(nodeCache.length > 0)) {
|
|
3862
|
+ return;
|
|
3863
|
+ }
|
|
3864
|
+ $pre = $("<" + _this.htmlTag + "/>").insertBefore(nodeCache[0]).text(_this.editor.formatter.clearHtml(nodeCache));
|
|
3865
|
+ resultNodes.push($pre[0]);
|
|
3866
|
+ return nodeCache.length = 0;
|
|
3867
|
+ };
|
|
3868
|
+ })(this);
|
|
3869
|
+ $rootNodes.each((function(_this) {
|
|
3870
|
+ return function(i, node) {
|
|
3871
|
+ var $node, $p;
|
|
3872
|
+ $node = $(node);
|
|
3873
|
+ if ($node.is(_this.htmlTag)) {
|
|
3874
|
+ clearCache();
|
|
3875
|
+ $p = $('<p/>').append($node.html().replace('\n', '<br/>')).replaceAll($node);
|
|
3876
|
+ return resultNodes.push($p[0]);
|
|
3877
|
+ } else if ($node.is(_this.disableTag) || _this.editor.util.isDecoratedNode($node) || $node.is('blockquote')) {
|
|
3878
|
+ return clearCache();
|
|
3879
|
+ } else {
|
|
3880
|
+ return nodeCache.push(node);
|
|
3881
|
+ }
|
|
3882
|
+ };
|
|
3883
|
+ })(this));
|
|
3884
|
+ clearCache();
|
|
3885
|
+ this.editor.selection.setRangeAtEndOf($(resultNodes).last());
|
|
3886
|
+ return this.editor.trigger('valuechanged');
|
|
3887
|
+ };
|
|
3888
|
+
|
|
3889
|
+ CodeButton.prototype._inlineCommand = function() {
|
|
3890
|
+ var $code, $contents, range;
|
|
3891
|
+ range = this.editor.selection.range();
|
|
3892
|
+ if (this.active) {
|
|
3893
|
+ range.selectNodeContents(this.node[0]);
|
|
3894
|
+ this.editor.selection.save(range);
|
|
3895
|
+ this.node.contents().unwrap();
|
|
3896
|
+ this.editor.selection.restore();
|
|
3897
|
+ } else {
|
|
3898
|
+ $contents = $(range.extractContents());
|
|
3899
|
+ $code = $("<" + this.htmlTag + "/>").append($contents.contents());
|
|
3900
|
+ range.insertNode($code[0]);
|
|
3901
|
+ range.selectNodeContents($code[0]);
|
|
3902
|
+ this.editor.selection.range(range);
|
|
3903
|
+ }
|
|
3904
|
+ return this.editor.trigger('valuechanged');
|
|
3905
|
+ };
|
|
3906
|
+
|
|
3907
|
+ return CodeButton;
|
|
3908
|
+
|
|
3909
|
+})(Button);
|
|
3910
|
+
|
|
3911
|
+CodePopover = (function(superClass) {
|
|
3912
|
+ extend(CodePopover, superClass);
|
|
3913
|
+
|
|
3914
|
+ function CodePopover() {
|
|
3915
|
+ return CodePopover.__super__.constructor.apply(this, arguments);
|
|
3916
|
+ }
|
|
3917
|
+
|
|
3918
|
+ CodePopover.prototype.render = function() {
|
|
3919
|
+ var $option, k, lang, len, ref;
|
|
3920
|
+ 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 </select>\n </div>\n</div>";
|
|
3921
|
+ this.langs = this.editor.opts.codeLanguages || [
|
|
3922
|
+ {
|
|
3923
|
+ name: 'Bash',
|
|
3924
|
+ value: 'bash'
|
|
3925
|
+ }, {
|
|
3926
|
+ name: 'C++',
|
|
3927
|
+ value: 'c++'
|
|
3928
|
+ }, {
|
|
3929
|
+ name: 'C#',
|
|
3930
|
+ value: 'cs'
|
|
3931
|
+ }, {
|
|
3932
|
+ name: 'CSS',
|
|
3933
|
+ value: 'css'
|
|
3934
|
+ }, {
|
|
3935
|
+ name: 'Erlang',
|
|
3936
|
+ value: 'erlang'
|
|
3937
|
+ }, {
|
|
3938
|
+ name: 'Less',
|
|
3939
|
+ value: 'less'
|
|
3940
|
+ }, {
|
|
3941
|
+ name: 'Sass',
|
|
3942
|
+ value: 'sass'
|
|
3943
|
+ }, {
|
|
3944
|
+ name: 'Diff',
|
|
3945
|
+ value: 'diff'
|
|
3946
|
+ }, {
|
|
3947
|
+ name: 'CoffeeScript',
|
|
3948
|
+ value: 'coffeescript'
|
|
3949
|
+ }, {
|
|
3950
|
+ name: 'HTML,XML',
|
|
3951
|
+ value: 'html'
|
|
3952
|
+ }, {
|
|
3953
|
+ name: 'JSON',
|
|
3954
|
+ value: 'json'
|
|
3955
|
+ }, {
|
|
3956
|
+ name: 'Java',
|
|
3957
|
+ value: 'java'
|
|
3958
|
+ }, {
|
|
3959
|
+ name: 'JavaScript',
|
|
3960
|
+ value: 'js'
|
|
3961
|
+ }, {
|
|
3962
|
+ name: 'Markdown',
|
|
3963
|
+ value: 'markdown'
|
|
3964
|
+ }, {
|
|
3965
|
+ name: 'Objective C',
|
|
3966
|
+ value: 'oc'
|
|
3967
|
+ }, {
|
|
3968
|
+ name: 'PHP',
|
|
3969
|
+ value: 'php'
|
|
3970
|
+ }, {
|
|
3971
|
+ name: 'Perl',
|
|
3972
|
+ value: 'parl'
|
|
3973
|
+ }, {
|
|
3974
|
+ name: 'Python',
|
|
3975
|
+ value: 'python'
|
|
3976
|
+ }, {
|
|
3977
|
+ name: 'Ruby',
|
|
3978
|
+ value: 'ruby'
|
|
3979
|
+ }, {
|
|
3980
|
+ name: 'SQL',
|
|
3981
|
+ value: 'sql'
|
|
3982
|
+ }
|
|
3983
|
+ ];
|
|
3984
|
+ this.el.addClass('code-popover').append(this._tpl);
|
|
3985
|
+ this.selectEl = this.el.find('.select-lang');
|
|
3986
|
+ ref = this.langs;
|
|
3987
|
+ for (k = 0, len = ref.length; k < len; k++) {
|
|
3988
|
+ lang = ref[k];
|
|
3989
|
+ $option = $('<option/>', {
|
|
3990
|
+ text: lang.name,
|
|
3991
|
+ value: lang.value
|
|
3992
|
+ }).appendTo(this.selectEl);
|
|
3993
|
+ }
|
|
3994
|
+ this.selectEl.on('change', (function(_this) {
|
|
3995
|
+ return function(e) {
|
|
3996
|
+ var selected;
|
|
3997
|
+ _this.lang = _this.selectEl.val();
|
|
3998
|
+ selected = _this.target.hasClass('selected');
|
|
3999
|
+ _this.target.removeClass().removeAttr('data-lang');
|
|
4000
|
+ if (_this.lang !== -1) {
|
|
4001
|
+ _this.target.attr('data-lang', _this.lang);
|
|
4002
|
+ }
|
|
4003
|
+ if (selected) {
|
|
4004
|
+ _this.target.addClass('selected');
|
|
4005
|
+ }
|
|
4006
|
+ return _this.editor.trigger('valuechanged');
|
|
4007
|
+ };
|
|
4008
|
+ })(this));
|
|
4009
|
+ return this.editor.on('valuechanged', (function(_this) {
|
|
4010
|
+ return function(e) {
|
|
4011
|
+ if (_this.active) {
|
|
4012
|
+ return _this.refresh();
|
|
4013
|
+ }
|
|
4014
|
+ };
|
|
4015
|
+ })(this));
|
|
4016
|
+ };
|
|
4017
|
+
|
|
4018
|
+ CodePopover.prototype.show = function() {
|
|
4019
|
+ var args;
|
|
4020
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
4021
|
+ CodePopover.__super__.show.apply(this, args);
|
|
4022
|
+ this.lang = this.target.attr('data-lang');
|
|
4023
|
+ if (this.lang != null) {
|
|
4024
|
+ return this.selectEl.val(this.lang);
|
|
4025
|
+ } else {
|
|
4026
|
+ return this.selectEl.val(-1);
|
|
4027
|
+ }
|
|
4028
|
+ };
|
|
4029
|
+
|
|
4030
|
+ return CodePopover;
|
|
4031
|
+
|
|
4032
|
+})(Popover);
|
|
4033
|
+
|
|
4034
|
+Simditor.Toolbar.addButton(CodeButton);
|
|
4035
|
+
|
|
4036
|
+LinkButton = (function(superClass) {
|
|
4037
|
+ extend(LinkButton, superClass);
|
|
4038
|
+
|
|
4039
|
+ function LinkButton() {
|
|
4040
|
+ return LinkButton.__super__.constructor.apply(this, arguments);
|
|
4041
|
+ }
|
|
4042
|
+
|
|
4043
|
+ LinkButton.prototype.name = 'link';
|
|
4044
|
+
|
|
4045
|
+ LinkButton.prototype.icon = 'link';
|
|
4046
|
+
|
|
4047
|
+ LinkButton.prototype.htmlTag = 'a';
|
|
4048
|
+
|
|
4049
|
+ LinkButton.prototype.disableTag = 'pre';
|
|
4050
|
+
|
|
4051
|
+ LinkButton.prototype.render = function() {
|
|
4052
|
+ var args;
|
|
4053
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
4054
|
+ LinkButton.__super__.render.apply(this, args);
|
|
4055
|
+ return this.popover = new LinkPopover({
|
|
4056
|
+ button: this
|
|
4057
|
+ });
|
|
4058
|
+ };
|
|
4059
|
+
|
|
4060
|
+ LinkButton.prototype._status = function() {
|
|
4061
|
+ LinkButton.__super__._status.call(this);
|
|
4062
|
+ if (this.active && !this.editor.selection.rangeAtEndOf(this.node)) {
|
|
4063
|
+ return this.popover.show(this.node);
|
|
4064
|
+ } else {
|
|
4065
|
+ return this.popover.hide();
|
|
4066
|
+ }
|
|
4067
|
+ };
|
|
4068
|
+
|
|
4069
|
+ LinkButton.prototype.command = function() {
|
|
4070
|
+ var $contents, $link, $newBlock, linkText, range, txtNode;
|
|
4071
|
+ range = this.editor.selection.range();
|
|
4072
|
+ if (this.active) {
|
|
4073
|
+ txtNode = document.createTextNode(this.node.text());
|
|
4074
|
+ this.node.replaceWith(txtNode);
|
|
4075
|
+ range.selectNode(txtNode);
|
|
4076
|
+ } else {
|
|
4077
|
+ $contents = $(range.extractContents());
|
|
4078
|
+ linkText = this.editor.formatter.clearHtml($contents.contents(), false);
|
|
4079
|
+ $link = $('<a/>', {
|
|
4080
|
+ href: 'http://www.example.com',
|
|
4081
|
+ target: '_blank',
|
|
4082
|
+ text: linkText || this._t('linkText')
|
|
4083
|
+ });
|
|
4084
|
+ if (this.editor.selection.blockNodes().length > 0) {
|
|
4085
|
+ range.insertNode($link[0]);
|
|
4086
|
+ } else {
|
|
4087
|
+ $newBlock = $('<p/>').append($link);
|
|
4088
|
+ range.insertNode($newBlock[0]);
|
|
4089
|
+ }
|
|
4090
|
+ range.selectNodeContents($link[0]);
|
|
4091
|
+ this.popover.one('popovershow', (function(_this) {
|
|
4092
|
+ return function() {
|
|
4093
|
+ if (linkText) {
|
|
4094
|
+ _this.popover.urlEl.focus();
|
|
4095
|
+ return _this.popover.urlEl[0].select();
|
|
4096
|
+ } else {
|
|
4097
|
+ _this.popover.textEl.focus();
|
|
4098
|
+ return _this.popover.textEl[0].select();
|
|
4099
|
+ }
|
|
4100
|
+ };
|
|
4101
|
+ })(this));
|
|
4102
|
+ }
|
|
4103
|
+ this.editor.selection.range(range);
|
|
4104
|
+ return this.editor.trigger('valuechanged');
|
|
4105
|
+ };
|
|
4106
|
+
|
|
4107
|
+ return LinkButton;
|
|
4108
|
+
|
|
4109
|
+})(Button);
|
|
4110
|
+
|
|
4111
|
+LinkPopover = (function(superClass) {
|
|
4112
|
+ extend(LinkPopover, superClass);
|
|
4113
|
+
|
|
4114
|
+ function LinkPopover() {
|
|
4115
|
+ return LinkPopover.__super__.constructor.apply(this, arguments);
|
|
4116
|
+ }
|
|
4117
|
+
|
|
4118
|
+ LinkPopover.prototype.render = function() {
|
|
4119
|
+ var tpl;
|
|
4120
|
+ tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('linkText')) + "</label>\n <input class=\"link-text\" type=\"text\"/>\n <a class=\"btn-unlink\" href=\"javascript:;\" title=\"" + (this._t('removeLink')) + "\"\n tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-unlink\"></span>\n </a>\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('linkUrl')) + "</label>\n <input class=\"link-url\" type=\"text\"/>\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('linkTarget')) + "</label>\n <select class=\"link-target\">\n <option value=\"_blank\">" + (this._t('openLinkInNewWindow')) + " (_blank)</option>\n <option value=\"_self\">" + (this._t('openLinkInCurrentWindow')) + " (_self)</option>\n </select>\n </div>\n</div>";
|
|
4121
|
+ this.el.addClass('link-popover').append(tpl);
|
|
4122
|
+ this.textEl = this.el.find('.link-text');
|
|
4123
|
+ this.urlEl = this.el.find('.link-url');
|
|
4124
|
+ this.unlinkEl = this.el.find('.btn-unlink');
|
|
4125
|
+ this.selectTarget = this.el.find('.link-target');
|
|
4126
|
+ this.textEl.on('keyup', (function(_this) {
|
|
4127
|
+ return function(e) {
|
|
4128
|
+ if (e.which === 13) {
|
|
4129
|
+ return;
|
|
4130
|
+ }
|
|
4131
|
+ _this.target.text(_this.textEl.val());
|
|
4132
|
+ return _this.editor.inputManager.throttledValueChanged();
|
|
4133
|
+ };
|
|
4134
|
+ })(this));
|
|
4135
|
+ this.urlEl.on('keyup', (function(_this) {
|
|
4136
|
+ return function(e) {
|
|
4137
|
+ var val;
|
|
4138
|
+ if (e.which === 13) {
|
|
4139
|
+ return;
|
|
4140
|
+ }
|
|
4141
|
+ val = _this.urlEl.val();
|
|
4142
|
+ if (!(/https?:\/\/|^\//ig.test(val) || !val)) {
|
|
4143
|
+ val = 'http://' + val;
|
|
4144
|
+ }
|
|
4145
|
+ _this.target.attr('href', val);
|
|
4146
|
+ return _this.editor.inputManager.throttledValueChanged();
|
|
4147
|
+ };
|
|
4148
|
+ })(this));
|
|
4149
|
+ $([this.urlEl[0], this.textEl[0]]).on('keydown', (function(_this) {
|
|
4150
|
+ return function(e) {
|
|
4151
|
+ var range;
|
|
4152
|
+ if (e.which === 13 || e.which === 27 || (!e.shiftKey && e.which === 9 && $(e.target).hasClass('link-url'))) {
|
|
4153
|
+ e.preventDefault();
|
|
4154
|
+ range = document.createRange();
|
|
4155
|
+ _this.editor.selection.setRangeAfter(_this.target, range);
|
|
4156
|
+ _this.hide();
|
|
4157
|
+ return _this.editor.inputManager.throttledValueChanged();
|
|
4158
|
+ }
|
|
4159
|
+ };
|
|
4160
|
+ })(this));
|
|
4161
|
+ this.unlinkEl.on('click', (function(_this) {
|
|
4162
|
+ return function(e) {
|
|
4163
|
+ var range, txtNode;
|
|
4164
|
+ txtNode = document.createTextNode(_this.target.text());
|
|
4165
|
+ _this.target.replaceWith(txtNode);
|
|
4166
|
+ _this.hide();
|
|
4167
|
+ range = document.createRange();
|
|
4168
|
+ _this.editor.selection.setRangeAfter(txtNode, range);
|
|
4169
|
+ return _this.editor.inputManager.throttledValueChanged();
|
|
4170
|
+ };
|
|
4171
|
+ })(this));
|
|
4172
|
+ return this.selectTarget.on('change', (function(_this) {
|
|
4173
|
+ return function(e) {
|
|
4174
|
+ _this.target.attr('target', _this.selectTarget.val());
|
|
4175
|
+ return _this.editor.inputManager.throttledValueChanged();
|
|
4176
|
+ };
|
|
4177
|
+ })(this));
|
|
4178
|
+ };
|
|
4179
|
+
|
|
4180
|
+ LinkPopover.prototype.show = function() {
|
|
4181
|
+ var args;
|
|
4182
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
4183
|
+ LinkPopover.__super__.show.apply(this, args);
|
|
4184
|
+ this.textEl.val(this.target.text());
|
|
4185
|
+ return this.urlEl.val(this.target.attr('href'));
|
|
4186
|
+ };
|
|
4187
|
+
|
|
4188
|
+ return LinkPopover;
|
|
4189
|
+
|
|
4190
|
+})(Popover);
|
|
4191
|
+
|
|
4192
|
+Simditor.Toolbar.addButton(LinkButton);
|
|
4193
|
+
|
|
4194
|
+ImageButton = (function(superClass) {
|
|
4195
|
+ extend(ImageButton, superClass);
|
|
4196
|
+
|
|
4197
|
+ function ImageButton() {
|
|
4198
|
+ return ImageButton.__super__.constructor.apply(this, arguments);
|
|
4199
|
+ }
|
|
4200
|
+
|
|
4201
|
+ ImageButton.prototype.name = 'image';
|
|
4202
|
+
|
|
4203
|
+ ImageButton.prototype.icon = 'picture-o';
|
|
4204
|
+
|
|
4205
|
+ ImageButton.prototype.htmlTag = 'img';
|
|
4206
|
+
|
|
4207
|
+ ImageButton.prototype.disableTag = 'pre, table';
|
|
4208
|
+
|
|
4209
|
+ ImageButton.prototype.defaultImage = '';
|
|
4210
|
+
|
|
4211
|
+ ImageButton.prototype.needFocus = false;
|
|
4212
|
+
|
|
4213
|
+ ImageButton.prototype._init = function() {
|
|
4214
|
+ var item, k, len, ref;
|
|
4215
|
+ if (this.editor.opts.imageButton) {
|
|
4216
|
+ if (Array.isArray(this.editor.opts.imageButton)) {
|
|
4217
|
+ this.menu = [];
|
|
4218
|
+ ref = this.editor.opts.imageButton;
|
|
4219
|
+ for (k = 0, len = ref.length; k < len; k++) {
|
|
4220
|
+ item = ref[k];
|
|
4221
|
+ this.menu.push({
|
|
4222
|
+ name: item + '-image',
|
|
4223
|
+ text: this._t(item + 'Image')
|
|
4224
|
+ });
|
|
4225
|
+ }
|
|
4226
|
+ } else {
|
|
4227
|
+ this.menu = false;
|
|
4228
|
+ }
|
|
4229
|
+ } else {
|
|
4230
|
+ if (this.editor.uploader != null) {
|
|
4231
|
+ this.menu = [
|
|
4232
|
+ {
|
|
4233
|
+ name: 'upload-image',
|
|
4234
|
+ text: this._t('uploadImage')
|
|
4235
|
+ }, {
|
|
4236
|
+ name: 'external-image',
|
|
4237
|
+ text: this._t('externalImage')
|
|
4238
|
+ }
|
|
4239
|
+ ];
|
|
4240
|
+ } else {
|
|
4241
|
+ this.menu = false;
|
|
4242
|
+ }
|
|
4243
|
+ }
|
|
4244
|
+ this.defaultImage = this.editor.opts.defaultImage;
|
|
4245
|
+ this.editor.body.on('click', 'img:not([data-non-image])', (function(_this) {
|
|
4246
|
+ return function(e) {
|
|
4247
|
+ var $img, range;
|
|
4248
|
+ $img = $(e.currentTarget);
|
|
4249
|
+ range = document.createRange();
|
|
4250
|
+ range.selectNode($img[0]);
|
|
4251
|
+ _this.editor.selection.range(range);
|
|
4252
|
+ if (!_this.editor.util.support.onselectionchange) {
|
|
4253
|
+ _this.editor.trigger('selectionchanged');
|
|
4254
|
+ }
|
|
4255
|
+ return false;
|
|
4256
|
+ };
|
|
4257
|
+ })(this));
|
|
4258
|
+ this.editor.body.on('mouseup', 'img:not([data-non-image])', function(e) {
|
|
4259
|
+ return false;
|
|
4260
|
+ });
|
|
4261
|
+ this.editor.on('selectionchanged.image', (function(_this) {
|
|
4262
|
+ return function() {
|
|
4263
|
+ var $contents, $img, range;
|
|
4264
|
+ range = _this.editor.selection.range();
|
|
4265
|
+ if (range == null) {
|
|
4266
|
+ return;
|
|
4267
|
+ }
|
|
4268
|
+ $contents = $(range.cloneContents()).contents();
|
|
4269
|
+ if ($contents.length === 1 && $contents.is('img:not([data-non-image])')) {
|
|
4270
|
+ $img = $(range.startContainer).contents().eq(range.startOffset);
|
|
4271
|
+ return _this.popover.show($img);
|
|
4272
|
+ } else {
|
|
4273
|
+ return _this.popover.hide();
|
|
4274
|
+ }
|
|
4275
|
+ };
|
|
4276
|
+ })(this));
|
|
4277
|
+ this.editor.on('valuechanged.image', (function(_this) {
|
|
4278
|
+ return function() {
|
|
4279
|
+ var $masks;
|
|
4280
|
+ $masks = _this.editor.wrapper.find('.simditor-image-loading');
|
|
4281
|
+ if (!($masks.length > 0)) {
|
|
4282
|
+ return;
|
|
4283
|
+ }
|
|
4284
|
+ return $masks.each(function(i, mask) {
|
|
4285
|
+ var $img, $mask, file;
|
|
4286
|
+ $mask = $(mask);
|
|
4287
|
+ $img = $mask.data('img');
|
|
4288
|
+ if (!($img && $img.parent().length > 0)) {
|
|
4289
|
+ $mask.remove();
|
|
4290
|
+ if ($img) {
|
|
4291
|
+ file = $img.data('file');
|
|
4292
|
+ if (file) {
|
|
4293
|
+ _this.editor.uploader.cancel(file);
|
|
4294
|
+ if (_this.editor.body.find('img.uploading').length < 1) {
|
|
4295
|
+ return _this.editor.uploader.trigger('uploadready', [file]);
|
|
4296
|
+ }
|
|
4297
|
+ }
|
|
4298
|
+ }
|
|
4299
|
+ }
|
|
4300
|
+ });
|
|
4301
|
+ };
|
|
4302
|
+ })(this));
|
|
4303
|
+ return ImageButton.__super__._init.call(this);
|
|
4304
|
+ };
|
|
4305
|
+
|
|
4306
|
+ ImageButton.prototype.render = function() {
|
|
4307
|
+ var args;
|
|
4308
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
4309
|
+ ImageButton.__super__.render.apply(this, args);
|
|
4310
|
+ this.popover = new ImagePopover({
|
|
4311
|
+ button: this
|
|
4312
|
+ });
|
|
4313
|
+ if (this.editor.opts.imageButton === 'upload') {
|
|
4314
|
+ return this._initUploader(this.el);
|
|
4315
|
+ }
|
|
4316
|
+ };
|
|
4317
|
+
|
|
4318
|
+ ImageButton.prototype.renderMenu = function() {
|
|
4319
|
+ ImageButton.__super__.renderMenu.call(this);
|
|
4320
|
+ return this._initUploader();
|
|
4321
|
+ };
|
|
4322
|
+
|
|
4323
|
+ ImageButton.prototype._initUploader = function($uploadItem) {
|
|
4324
|
+ var $input, createInput, uploadProgress;
|
|
4325
|
+ if ($uploadItem == null) {
|
|
4326
|
+ $uploadItem = this.menuEl.find('.menu-item-upload-image');
|
|
4327
|
+ }
|
|
4328
|
+ if (this.editor.uploader == null) {
|
|
4329
|
+ this.el.find('.btn-upload').remove();
|
|
4330
|
+ return;
|
|
4331
|
+ }
|
|
4332
|
+ $input = null;
|
|
4333
|
+ createInput = (function(_this) {
|
|
4334
|
+ return function() {
|
|
4335
|
+ if ($input) {
|
|
4336
|
+ $input.remove();
|
|
4337
|
+ }
|
|
4338
|
+ return $input = $('<input/>', {
|
|
4339
|
+ type: 'file',
|
|
4340
|
+ title: _this._t('uploadImage'),
|
|
4341
|
+ multiple: true,
|
|
4342
|
+ accept: 'image/*'
|
|
4343
|
+ }).appendTo($uploadItem);
|
|
4344
|
+ };
|
|
4345
|
+ })(this);
|
|
4346
|
+ createInput();
|
|
4347
|
+ $uploadItem.on('click mousedown', 'input[type=file]', function(e) {
|
|
4348
|
+ return e.stopPropagation();
|
|
4349
|
+ });
|
|
4350
|
+ $uploadItem.on('change', 'input[type=file]', (function(_this) {
|
|
4351
|
+ return function(e) {
|
|
4352
|
+ if (_this.editor.inputManager.focused) {
|
|
4353
|
+ _this.editor.uploader.upload($input, {
|
|
4354
|
+ inline: true
|
|
4355
|
+ });
|
|
4356
|
+ createInput();
|
|
4357
|
+ } else {
|
|
4358
|
+ _this.editor.one('focus', function(e) {
|
|
4359
|
+ _this.editor.uploader.upload($input, {
|
|
4360
|
+ inline: true
|
|
4361
|
+ });
|
|
4362
|
+ return createInput();
|
|
4363
|
+ });
|
|
4364
|
+ _this.editor.focus();
|
|
4365
|
+ }
|
|
4366
|
+ return _this.wrapper.removeClass('menu-on');
|
|
4367
|
+ };
|
|
4368
|
+ })(this));
|
|
4369
|
+ this.editor.uploader.on('beforeupload', (function(_this) {
|
|
4370
|
+ return function(e, file) {
|
|
4371
|
+ var $img;
|
|
4372
|
+ if (!file.inline) {
|
|
4373
|
+ return;
|
|
4374
|
+ }
|
|
4375
|
+ if (file.img) {
|
|
4376
|
+ $img = $(file.img);
|
|
4377
|
+ } else {
|
|
4378
|
+ $img = _this.createImage(file.name);
|
|
4379
|
+ file.img = $img;
|
|
4380
|
+ }
|
|
4381
|
+ $img.addClass('uploading');
|
|
4382
|
+ $img.data('file', file);
|
|
4383
|
+ return _this.editor.uploader.readImageFile(file.obj, function(img) {
|
|
4384
|
+ var src;
|
|
4385
|
+ if (!$img.hasClass('uploading')) {
|
|
4386
|
+ return;
|
|
4387
|
+ }
|
|
4388
|
+ src = img ? img.src : _this.defaultImage;
|
|
4389
|
+ return _this.loadImage($img, src, function() {
|
|
4390
|
+ if (_this.popover.active) {
|
|
4391
|
+ _this.popover.refresh();
|
|
4392
|
+ return _this.popover.srcEl.val(_this._t('uploading')).prop('disabled', true);
|
|
4393
|
+ }
|
|
4394
|
+ });
|
|
4395
|
+ });
|
|
4396
|
+ };
|
|
4397
|
+ })(this));
|
|
4398
|
+ uploadProgress = $.proxy(this.editor.util.throttle(function(e, file, loaded, total) {
|
|
4399
|
+ var $img, $mask, percent;
|
|
4400
|
+ if (!file.inline) {
|
|
4401
|
+ return;
|
|
4402
|
+ }
|
|
4403
|
+ $mask = file.img.data('mask');
|
|
4404
|
+ if (!$mask) {
|
|
4405
|
+ return;
|
|
4406
|
+ }
|
|
4407
|
+ $img = $mask.data('img');
|
|
4408
|
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) {
|
|
4409
|
+ $mask.remove();
|
|
4410
|
+ return;
|
|
4411
|
+ }
|
|
4412
|
+ percent = loaded / total;
|
|
4413
|
+ percent = (percent * 100).toFixed(0);
|
|
4414
|
+ if (percent > 99) {
|
|
4415
|
+ percent = 99;
|
|
4416
|
+ }
|
|
4417
|
+ return $mask.find('.progress').height((100 - percent) + "%");
|
|
4418
|
+ }, 500), this);
|
|
4419
|
+ this.editor.uploader.on('uploadprogress', uploadProgress);
|
|
4420
|
+ this.editor.uploader.on('uploadsuccess', (function(_this) {
|
|
4421
|
+ return function(e, file, result) {
|
|
4422
|
+ var $img, img_path, msg;
|
|
4423
|
+ if (!file.inline) {
|
|
4424
|
+ return;
|
|
4425
|
+ }
|
|
4426
|
+ $img = file.img;
|
|
4427
|
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) {
|
|
4428
|
+ return;
|
|
4429
|
+ }
|
|
4430
|
+ if (typeof result !== 'object') {
|
|
4431
|
+ try {
|
|
4432
|
+ result = $.parseJSON(result);
|
|
4433
|
+ } catch (_error) {
|
|
4434
|
+ e = _error;
|
|
4435
|
+ result = {
|
|
4436
|
+ success: false
|
|
4437
|
+ };
|
|
4438
|
+ }
|
|
4439
|
+ }
|
|
4440
|
+ if (result.success === false) {
|
|
4441
|
+ msg = result.msg || _this._t('uploadFailed');
|
|
4442
|
+ alert(msg);
|
|
4443
|
+ img_path = _this.defaultImage;
|
|
4444
|
+ } else {
|
|
4445
|
+ img_path = result.file_path;
|
|
4446
|
+ }
|
|
4447
|
+ _this.loadImage($img, img_path, function() {
|
|
4448
|
+ var $mask;
|
|
4449
|
+ $img.removeData('file');
|
|
4450
|
+ $img.removeClass('uploading').removeClass('loading');
|
|
4451
|
+ $mask = $img.data('mask');
|
|
4452
|
+ if ($mask) {
|
|
4453
|
+ $mask.remove();
|
|
4454
|
+ }
|
|
4455
|
+ $img.removeData('mask');
|
|
4456
|
+ _this.editor.trigger('valuechanged');
|
|
4457
|
+ if (_this.editor.body.find('img.uploading').length < 1) {
|
|
4458
|
+ return _this.editor.uploader.trigger('uploadready', [file, result]);
|
|
4459
|
+ }
|
|
4460
|
+ });
|
|
4461
|
+ if (_this.popover.active) {
|
|
4462
|
+ _this.popover.srcEl.prop('disabled', false);
|
|
4463
|
+ return _this.popover.srcEl.val(result.file_path);
|
|
4464
|
+ }
|
|
4465
|
+ };
|
|
4466
|
+ })(this));
|
|
4467
|
+ return this.editor.uploader.on('uploaderror', (function(_this) {
|
|
4468
|
+ return function(e, file, xhr) {
|
|
4469
|
+ var $img, msg, result;
|
|
4470
|
+ if (!file.inline) {
|
|
4471
|
+ return;
|
|
4472
|
+ }
|
|
4473
|
+ if (xhr.statusText === 'abort') {
|
|
4474
|
+ return;
|
|
4475
|
+ }
|
|
4476
|
+ if (xhr.responseText) {
|
|
4477
|
+ try {
|
|
4478
|
+ result = $.parseJSON(xhr.responseText);
|
|
4479
|
+ msg = result.msg;
|
|
4480
|
+ } catch (_error) {
|
|
4481
|
+ e = _error;
|
|
4482
|
+ msg = _this._t('uploadError');
|
|
4483
|
+ }
|
|
4484
|
+ alert(msg);
|
|
4485
|
+ }
|
|
4486
|
+ $img = file.img;
|
|
4487
|
+ if (!($img.hasClass('uploading') && $img.parent().length > 0)) {
|
|
4488
|
+ return;
|
|
4489
|
+ }
|
|
4490
|
+ _this.loadImage($img, _this.defaultImage, function() {
|
|
4491
|
+ var $mask;
|
|
4492
|
+ $img.removeData('file');
|
|
4493
|
+ $img.removeClass('uploading').removeClass('loading');
|
|
4494
|
+ $mask = $img.data('mask');
|
|
4495
|
+ if ($mask) {
|
|
4496
|
+ $mask.remove();
|
|
4497
|
+ }
|
|
4498
|
+ return $img.removeData('mask');
|
|
4499
|
+ });
|
|
4500
|
+ if (_this.popover.active) {
|
|
4501
|
+ _this.popover.srcEl.prop('disabled', false);
|
|
4502
|
+ _this.popover.srcEl.val(_this.defaultImage);
|
|
4503
|
+ }
|
|
4504
|
+ _this.editor.trigger('valuechanged');
|
|
4505
|
+ if (_this.editor.body.find('img.uploading').length < 1) {
|
|
4506
|
+ return _this.editor.uploader.trigger('uploadready', [file, result]);
|
|
4507
|
+ }
|
|
4508
|
+ };
|
|
4509
|
+ })(this));
|
|
4510
|
+ };
|
|
4511
|
+
|
|
4512
|
+ ImageButton.prototype._status = function() {
|
|
4513
|
+ return this._disableStatus();
|
|
4514
|
+ };
|
|
4515
|
+
|
|
4516
|
+ ImageButton.prototype.loadImage = function($img, src, callback) {
|
|
4517
|
+ var $mask, img, positionMask;
|
|
4518
|
+ positionMask = (function(_this) {
|
|
4519
|
+ return function() {
|
|
4520
|
+ var imgOffset, wrapperOffset;
|
|
4521
|
+ imgOffset = $img.offset();
|
|
4522
|
+ wrapperOffset = _this.editor.wrapper.offset();
|
|
4523
|
+ return $mask.css({
|
|
4524
|
+ top: imgOffset.top - wrapperOffset.top,
|
|
4525
|
+ left: imgOffset.left - wrapperOffset.left,
|
|
4526
|
+ width: $img.width(),
|
|
4527
|
+ height: $img.height()
|
|
4528
|
+ }).show();
|
|
4529
|
+ };
|
|
4530
|
+ })(this);
|
|
4531
|
+ $img.addClass('loading');
|
|
4532
|
+ $mask = $img.data('mask');
|
|
4533
|
+ if (!$mask) {
|
|
4534
|
+ $mask = $('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper);
|
|
4535
|
+ positionMask();
|
|
4536
|
+ $img.data('mask', $mask);
|
|
4537
|
+ $mask.data('img', $img);
|
|
4538
|
+ }
|
|
4539
|
+ img = new Image();
|
|
4540
|
+ img.onload = (function(_this) {
|
|
4541
|
+ return function() {
|
|
4542
|
+ var height, width;
|
|
4543
|
+ if (!$img.hasClass('loading') && !$img.hasClass('uploading')) {
|
|
4544
|
+ return;
|
|
4545
|
+ }
|
|
4546
|
+ width = img.width;
|
|
4547
|
+ height = img.height;
|
|
4548
|
+ $img.attr({
|
|
4549
|
+ src: src,
|
|
4550
|
+ width: width,
|
|
4551
|
+ height: height,
|
|
4552
|
+ 'data-image-size': width + ',' + height
|
|
4553
|
+ }).removeClass('loading');
|
|
4554
|
+ if ($img.hasClass('uploading')) {
|
|
4555
|
+ _this.editor.util.reflow(_this.editor.body);
|
|
4556
|
+ positionMask();
|
|
4557
|
+ } else {
|
|
4558
|
+ $mask.remove();
|
|
4559
|
+ $img.removeData('mask');
|
|
4560
|
+ }
|
|
4561
|
+ if ($.isFunction(callback)) {
|
|
4562
|
+ return callback(img);
|
|
4563
|
+ }
|
|
4564
|
+ };
|
|
4565
|
+ })(this);
|
|
4566
|
+ img.onerror = function() {
|
|
4567
|
+ if ($.isFunction(callback)) {
|
|
4568
|
+ callback(false);
|
|
4569
|
+ }
|
|
4570
|
+ $mask.remove();
|
|
4571
|
+ return $img.removeData('mask').removeClass('loading');
|
|
4572
|
+ };
|
|
4573
|
+ return img.src = src;
|
|
4574
|
+ };
|
|
4575
|
+
|
|
4576
|
+ ImageButton.prototype.createImage = function(name) {
|
|
4577
|
+ var $img, range;
|
|
4578
|
+ if (name == null) {
|
|
4579
|
+ name = 'Image';
|
|
4580
|
+ }
|
|
4581
|
+ if (!this.editor.inputManager.focused) {
|
|
4582
|
+ this.editor.focus();
|
|
4583
|
+ }
|
|
4584
|
+ range = this.editor.selection.range();
|
|
4585
|
+ range.deleteContents();
|
|
4586
|
+ this.editor.selection.range(range);
|
|
4587
|
+ $img = $('<img/>').attr('alt', name);
|
|
4588
|
+ range.insertNode($img[0]);
|
|
4589
|
+ this.editor.selection.setRangeAfter($img, range);
|
|
4590
|
+ this.editor.trigger('valuechanged');
|
|
4591
|
+ return $img;
|
|
4592
|
+ };
|
|
4593
|
+
|
|
4594
|
+ ImageButton.prototype.command = function(src) {
|
|
4595
|
+ var $img;
|
|
4596
|
+ $img = this.createImage();
|
|
4597
|
+ return this.loadImage($img, src || this.defaultImage, (function(_this) {
|
|
4598
|
+ return function() {
|
|
4599
|
+ _this.editor.trigger('valuechanged');
|
|
4600
|
+ _this.editor.util.reflow($img);
|
|
4601
|
+ $img.click();
|
|
4602
|
+ return _this.popover.one('popovershow', function() {
|
|
4603
|
+ _this.popover.srcEl.focus();
|
|
4604
|
+ return _this.popover.srcEl[0].select();
|
|
4605
|
+ });
|
|
4606
|
+ };
|
|
4607
|
+ })(this));
|
|
4608
|
+ };
|
|
4609
|
+
|
|
4610
|
+ return ImageButton;
|
|
4611
|
+
|
|
4612
|
+})(Button);
|
|
4613
|
+
|
|
4614
|
+ImagePopover = (function(superClass) {
|
|
4615
|
+ extend(ImagePopover, superClass);
|
|
4616
|
+
|
|
4617
|
+ function ImagePopover() {
|
|
4618
|
+ return ImagePopover.__super__.constructor.apply(this, arguments);
|
|
4619
|
+ }
|
|
4620
|
+
|
|
4621
|
+ ImagePopover.prototype.offset = {
|
|
4622
|
+ top: 6,
|
|
4623
|
+ left: -4
|
|
4624
|
+ };
|
|
4625
|
+
|
|
4626
|
+ ImagePopover.prototype.render = function() {
|
|
4627
|
+ var tpl;
|
|
4628
|
+ tpl = "<div class=\"link-settings\">\n <div class=\"settings-field\">\n <label>" + (this._t('imageUrl')) + "</label>\n <input class=\"image-src\" type=\"text\" tabindex=\"1\" />\n <a class=\"btn-upload\" href=\"javascript:;\"\n title=\"" + (this._t('uploadImage')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-upload\"></span>\n </a>\n </div>\n <div class='settings-field'>\n <label>" + (this._t('imageAlt')) + "</label>\n <input class=\"image-alt\" id=\"image-alt\" type=\"text\" tabindex=\"1\" />\n </div>\n <div class=\"settings-field\">\n <label>" + (this._t('imageSize')) + "</label>\n <input class=\"image-size\" id=\"image-width\" type=\"text\" tabindex=\"2\" />\n <span class=\"times\">×</span>\n <input class=\"image-size\" id=\"image-height\" type=\"text\" tabindex=\"3\" />\n <a class=\"btn-restore\" href=\"javascript:;\"\n title=\"" + (this._t('restoreImageSize')) + "\" tabindex=\"-1\">\n <span class=\"simditor-icon simditor-icon-undo\"></span>\n </a>\n </div>\n</div>";
|
|
4629
|
+ this.el.addClass('image-popover').append(tpl);
|
|
4630
|
+ this.srcEl = this.el.find('.image-src');
|
|
4631
|
+ this.widthEl = this.el.find('#image-width');
|
|
4632
|
+ this.heightEl = this.el.find('#image-height');
|
|
4633
|
+ this.altEl = this.el.find('#image-alt');
|
|
4634
|
+ this.srcEl.on('keydown', (function(_this) {
|
|
4635
|
+ return function(e) {
|
|
4636
|
+ var range;
|
|
4637
|
+ if (!(e.which === 13 && !_this.target.hasClass('uploading'))) {
|
|
4638
|
+ return;
|
|
4639
|
+ }
|
|
4640
|
+ e.preventDefault();
|
|
4641
|
+ range = document.createRange();
|
|
4642
|
+ _this.button.editor.selection.setRangeAfter(_this.target, range);
|
|
4643
|
+ return _this.hide();
|
|
4644
|
+ };
|
|
4645
|
+ })(this));
|
|
4646
|
+ this.srcEl.on('blur', (function(_this) {
|
|
4647
|
+ return function(e) {
|
|
4648
|
+ return _this._loadImage(_this.srcEl.val());
|
|
4649
|
+ };
|
|
4650
|
+ })(this));
|
|
4651
|
+ this.el.find('.image-size').on('blur', (function(_this) {
|
|
4652
|
+ return function(e) {
|
|
4653
|
+ _this._resizeImg($(e.currentTarget));
|
|
4654
|
+ return _this.el.data('popover').refresh();
|
|
4655
|
+ };
|
|
4656
|
+ })(this));
|
|
4657
|
+ this.el.find('.image-size').on('keyup', (function(_this) {
|
|
4658
|
+ return function(e) {
|
|
4659
|
+ var inputEl;
|
|
4660
|
+ inputEl = $(e.currentTarget);
|
|
4661
|
+ if (!(e.which === 13 || e.which === 27 || e.which === 9)) {
|
|
4662
|
+ return _this._resizeImg(inputEl, true);
|
|
4663
|
+ }
|
|
4664
|
+ };
|
|
4665
|
+ })(this));
|
|
4666
|
+ this.el.find('.image-size').on('keydown', (function(_this) {
|
|
4667
|
+ return function(e) {
|
|
4668
|
+ var $img, inputEl, range;
|
|
4669
|
+ inputEl = $(e.currentTarget);
|
|
4670
|
+ if (e.which === 13 || e.which === 27) {
|
|
4671
|
+ e.preventDefault();
|
|
4672
|
+ if (e.which === 13) {
|
|
4673
|
+ _this._resizeImg(inputEl);
|
|
4674
|
+ } else {
|
|
4675
|
+ _this._restoreImg();
|
|
4676
|
+ }
|
|
4677
|
+ $img = _this.target;
|
|
4678
|
+ _this.hide();
|
|
4679
|
+ range = document.createRange();
|
|
4680
|
+ return _this.button.editor.selection.setRangeAfter($img, range);
|
|
4681
|
+ } else if (e.which === 9) {
|
|
4682
|
+ return _this.el.data('popover').refresh();
|
|
4683
|
+ }
|
|
4684
|
+ };
|
|
4685
|
+ })(this));
|
|
4686
|
+ this.altEl.on('keydown', (function(_this) {
|
|
4687
|
+ return function(e) {
|
|
4688
|
+ var range;
|
|
4689
|
+ if (e.which === 13) {
|
|
4690
|
+ e.preventDefault();
|
|
4691
|
+ range = document.createRange();
|
|
4692
|
+ _this.button.editor.selection.setRangeAfter(_this.target, range);
|
|
4693
|
+ return _this.hide();
|
|
4694
|
+ }
|
|
4695
|
+ };
|
|
4696
|
+ })(this));
|
|
4697
|
+ this.altEl.on('keyup', (function(_this) {
|
|
4698
|
+ return function(e) {
|
|
4699
|
+ if (e.which === 13 || e.which === 27 || e.which === 9) {
|
|
4700
|
+ return;
|
|
4701
|
+ }
|
|
4702
|
+ _this.alt = _this.altEl.val();
|
|
4703
|
+ return _this.target.attr('alt', _this.alt);
|
|
4704
|
+ };
|
|
4705
|
+ })(this));
|
|
4706
|
+ this.el.find('.btn-restore').on('click', (function(_this) {
|
|
4707
|
+ return function(e) {
|
|
4708
|
+ _this._restoreImg();
|
|
4709
|
+ return _this.el.data('popover').refresh();
|
|
4710
|
+ };
|
|
4711
|
+ })(this));
|
|
4712
|
+ this.editor.on('valuechanged', (function(_this) {
|
|
4713
|
+ return function(e) {
|
|
4714
|
+ if (_this.active) {
|
|
4715
|
+ return _this.refresh();
|
|
4716
|
+ }
|
|
4717
|
+ };
|
|
4718
|
+ })(this));
|
|
4719
|
+ return this._initUploader();
|
|
4720
|
+ };
|
|
4721
|
+
|
|
4722
|
+ ImagePopover.prototype._initUploader = function() {
|
|
4723
|
+ var $uploadBtn, createInput;
|
|
4724
|
+ $uploadBtn = this.el.find('.btn-upload');
|
|
4725
|
+ if (this.editor.uploader == null) {
|
|
4726
|
+ $uploadBtn.remove();
|
|
4727
|
+ return;
|
|
4728
|
+ }
|
|
4729
|
+ createInput = (function(_this) {
|
|
4730
|
+ return function() {
|
|
4731
|
+ if (_this.input) {
|
|
4732
|
+ _this.input.remove();
|
|
4733
|
+ }
|
|
4734
|
+ return _this.input = $('<input/>', {
|
|
4735
|
+ type: 'file',
|
|
4736
|
+ title: _this._t('uploadImage'),
|
|
4737
|
+ multiple: true,
|
|
4738
|
+ accept: 'image/*'
|
|
4739
|
+ }).appendTo($uploadBtn);
|
|
4740
|
+ };
|
|
4741
|
+ })(this);
|
|
4742
|
+ createInput();
|
|
4743
|
+ this.el.on('click mousedown', 'input[type=file]', function(e) {
|
|
4744
|
+ return e.stopPropagation();
|
|
4745
|
+ });
|
|
4746
|
+ return this.el.on('change', 'input[type=file]', (function(_this) {
|
|
4747
|
+ return function(e) {
|
|
4748
|
+ _this.editor.uploader.upload(_this.input, {
|
|
4749
|
+ inline: true,
|
|
4750
|
+ img: _this.target
|
|
4751
|
+ });
|
|
4752
|
+ return createInput();
|
|
4753
|
+ };
|
|
4754
|
+ })(this));
|
|
4755
|
+ };
|
|
4756
|
+
|
|
4757
|
+ ImagePopover.prototype._resizeImg = function(inputEl, onlySetVal) {
|
|
4758
|
+ var height, value, width;
|
|
4759
|
+ if (onlySetVal == null) {
|
|
4760
|
+ onlySetVal = false;
|
|
4761
|
+ }
|
|
4762
|
+ value = inputEl.val() * 1;
|
|
4763
|
+ if (!(this.target && ($.isNumeric(value) || value < 0))) {
|
|
4764
|
+ return;
|
|
4765
|
+ }
|
|
4766
|
+ if (inputEl.is(this.widthEl)) {
|
|
4767
|
+ width = value;
|
|
4768
|
+ height = this.height * value / this.width;
|
|
4769
|
+ this.heightEl.val(height);
|
|
4770
|
+ } else {
|
|
4771
|
+ height = value;
|
|
4772
|
+ width = this.width * value / this.height;
|
|
4773
|
+ this.widthEl.val(width);
|
|
4774
|
+ }
|
|
4775
|
+ if (!onlySetVal) {
|
|
4776
|
+ this.target.attr({
|
|
4777
|
+ width: width,
|
|
4778
|
+ height: height
|
|
4779
|
+ });
|
|
4780
|
+ return this.editor.trigger('valuechanged');
|
|
4781
|
+ }
|
|
4782
|
+ };
|
|
4783
|
+
|
|
4784
|
+ ImagePopover.prototype._restoreImg = function() {
|
|
4785
|
+ var ref, size;
|
|
4786
|
+ size = ((ref = this.target.data('image-size')) != null ? ref.split(",") : void 0) || [this.width, this.height];
|
|
4787
|
+ this.target.attr({
|
|
4788
|
+ width: size[0] * 1,
|
|
4789
|
+ height: size[1] * 1
|
|
4790
|
+ });
|
|
4791
|
+ this.widthEl.val(size[0]);
|
|
4792
|
+ this.heightEl.val(size[1]);
|
|
4793
|
+ return this.editor.trigger('valuechanged');
|
|
4794
|
+ };
|
|
4795
|
+
|
|
4796
|
+ ImagePopover.prototype._loadImage = function(src, callback) {
|
|
4797
|
+ if (/^data:image/.test(src) && !this.editor.uploader) {
|
|
4798
|
+ if (callback) {
|
|
4799
|
+ callback(false);
|
|
4800
|
+ }
|
|
4801
|
+ return;
|
|
4802
|
+ }
|
|
4803
|
+ if (this.target.attr('src') === src) {
|
|
4804
|
+ return;
|
|
4805
|
+ }
|
|
4806
|
+ return this.button.loadImage(this.target, src, (function(_this) {
|
|
4807
|
+ return function(img) {
|
|
4808
|
+ var blob;
|
|
4809
|
+ if (!img) {
|
|
4810
|
+ return;
|
|
4811
|
+ }
|
|
4812
|
+ if (_this.active) {
|
|
4813
|
+ _this.width = img.width;
|
|
4814
|
+ _this.height = img.height;
|
|
4815
|
+ _this.widthEl.val(_this.width);
|
|
4816
|
+ _this.heightEl.val(_this.height);
|
|
4817
|
+ }
|
|
4818
|
+ if (/^data:image/.test(src)) {
|
|
4819
|
+ blob = _this.editor.util.dataURLtoBlob(src);
|
|
4820
|
+ blob.name = "Base64 Image.png";
|
|
4821
|
+ _this.editor.uploader.upload(blob, {
|
|
4822
|
+ inline: true,
|
|
4823
|
+ img: _this.target
|
|
4824
|
+ });
|
|
4825
|
+ } else {
|
|
4826
|
+ _this.editor.trigger('valuechanged');
|
|
4827
|
+ }
|
|
4828
|
+ if (callback) {
|
|
4829
|
+ return callback(img);
|
|
4830
|
+ }
|
|
4831
|
+ };
|
|
4832
|
+ })(this));
|
|
4833
|
+ };
|
|
4834
|
+
|
|
4835
|
+ ImagePopover.prototype.show = function() {
|
|
4836
|
+ var $img, args;
|
|
4837
|
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
|
4838
|
+ ImagePopover.__super__.show.apply(this, args);
|
|
4839
|
+ $img = this.target;
|
|
4840
|
+ this.width = $img.width();
|
|
4841
|
+ this.height = $img.height();
|
|
4842
|
+ this.alt = $img.attr('alt');
|
|
4843
|
+ if ($img.hasClass('uploading')) {
|
|
4844
|
+ return this.srcEl.val(this._t('uploading')).prop('disabled', true);
|
|
4845
|
+ } else {
|
|
4846
|
+ this.srcEl.val($img.attr('src')).prop('disabled', false);
|
|
4847
|
+ this.widthEl.val(this.width);
|
|
4848
|
+ this.heightEl.val(this.height);
|
|
4849
|
+ return this.altEl.val(this.alt);
|
|
4850
|
+ }
|
|
4851
|
+ };
|
|
4852
|
+
|
|
4853
|
+ return ImagePopover;
|
|
4854
|
+
|
|
4855
|
+})(Popover);
|
|
4856
|
+
|
|
4857
|
+Simditor.Toolbar.addButton(ImageButton);
|
|
4858
|
+
|
|
4859
|
+IndentButton = (function(superClass) {
|
|
4860
|
+ extend(IndentButton, superClass);
|
|
4861
|
+
|
|
4862
|
+ function IndentButton() {
|
|
4863
|
+ return IndentButton.__super__.constructor.apply(this, arguments);
|
|
4864
|
+ }
|
|
4865
|
+
|
|
4866
|
+ IndentButton.prototype.name = 'indent';
|
|
4867
|
+
|
|
4868
|
+ IndentButton.prototype.icon = 'indent';
|
|
4869
|
+
|
|
4870
|
+ IndentButton.prototype._init = function() {
|
|
4871
|
+ this.title = this._t(this.name) + ' (Tab)';
|
|
4872
|
+ return IndentButton.__super__._init.call(this);
|
|
4873
|
+ };
|
|
4874
|
+
|
|
4875
|
+ IndentButton.prototype._status = function() {};
|
|
4876
|
+
|
|
4877
|
+ IndentButton.prototype.command = function() {
|
|
4878
|
+ return this.editor.indentation.indent();
|
|
4879
|
+ };
|
|
4880
|
+
|
|
4881
|
+ return IndentButton;
|
|
4882
|
+
|
|
4883
|
+})(Button);
|
|
4884
|
+
|
|
4885
|
+Simditor.Toolbar.addButton(IndentButton);
|
|
4886
|
+
|
|
4887
|
+OutdentButton = (function(superClass) {
|
|
4888
|
+ extend(OutdentButton, superClass);
|
|
4889
|
+
|
|
4890
|
+ function OutdentButton() {
|
|
4891
|
+ return OutdentButton.__super__.constructor.apply(this, arguments);
|
|
4892
|
+ }
|
|
4893
|
+
|
|
4894
|
+ OutdentButton.prototype.name = 'outdent';
|
|
4895
|
+
|
|
4896
|
+ OutdentButton.prototype.icon = 'outdent';
|
|
4897
|
+
|
|
4898
|
+ OutdentButton.prototype._init = function() {
|
|
4899
|
+ this.title = this._t(this.name) + ' (Shift + Tab)';
|
|
4900
|
+ return OutdentButton.__super__._init.call(this);
|
|
4901
|
+ };
|
|
4902
|
+
|
|
4903
|
+ OutdentButton.prototype._status = function() {};
|
|
4904
|
+
|
|
4905
|
+ OutdentButton.prototype.command = function() {
|
|
4906
|
+ return this.editor.indentation.indent(true);
|
|
4907
|
+ };
|
|
4908
|
+
|
|
4909
|
+ return OutdentButton;
|
|
4910
|
+
|
|
4911
|
+})(Button);
|
|
4912
|
+
|
|
4913
|
+Simditor.Toolbar.addButton(OutdentButton);
|
|
4914
|
+
|
|
4915
|
+HrButton = (function(superClass) {
|
|
4916
|
+ extend(HrButton, superClass);
|
|
4917
|
+
|
|
4918
|
+ function HrButton() {
|
|
4919
|
+ return HrButton.__super__.constructor.apply(this, arguments);
|
|
4920
|
+ }
|
|
4921
|
+
|
|
4922
|
+ HrButton.prototype.name = 'hr';
|
|
4923
|
+
|
|
4924
|
+ HrButton.prototype.icon = 'minus';
|
|
4925
|
+
|
|
4926
|
+ HrButton.prototype.htmlTag = 'hr';
|
|
4927
|
+
|
|
4928
|
+ HrButton.prototype._status = function() {};
|
|
4929
|
+
|
|
4930
|
+ HrButton.prototype.command = function() {
|
|
4931
|
+ var $hr, $newBlock, $nextBlock, $rootBlock;
|
|
4932
|
+ $rootBlock = this.editor.selection.rootNodes().first();
|
|
4933
|
+ $nextBlock = $rootBlock.next();
|
|
4934
|
+ if ($nextBlock.length > 0) {
|
|
4935
|
+ this.editor.selection.save();
|
|
4936
|
+ } else {
|
|
4937
|
+ $newBlock = $('<p/>').append(this.editor.util.phBr);
|
|
4938
|
+ }
|
|
4939
|
+ $hr = $('<hr/>').insertAfter($rootBlock);
|
|
4940
|
+ if ($newBlock) {
|
|
4941
|
+ $newBlock.insertAfter($hr);
|
|
4942
|
+ this.editor.selection.setRangeAtStartOf($newBlock);
|
|
4943
|
+ } else {
|
|
4944
|
+ this.editor.selection.restore();
|
|
4945
|
+ }
|
|
4946
|
+ return this.editor.trigger('valuechanged');
|
|
4947
|
+ };
|
|
4948
|
+
|
|
4949
|
+ return HrButton;
|
|
4950
|
+
|
|
4951
|
+})(Button);
|
|
4952
|
+
|
|
4953
|
+Simditor.Toolbar.addButton(HrButton);
|
|
4954
|
+
|
|
4955
|
+TableButton = (function(superClass) {
|
|
4956
|
+ extend(TableButton, superClass);
|
|
4957
|
+
|
|
4958
|
+ function TableButton() {
|
|
4959
|
+ return TableButton.__super__.constructor.apply(this, arguments);
|
|
4960
|
+ }
|
|
4961
|
+
|
|
4962
|
+ TableButton.prototype.name = 'table';
|
|
4963
|
+
|
|
4964
|
+ TableButton.prototype.icon = 'table';
|
|
4965
|
+
|
|
4966
|
+ TableButton.prototype.htmlTag = 'table';
|
|
4967
|
+
|
|
4968
|
+ TableButton.prototype.disableTag = 'pre, li, blockquote';
|
|
4969
|
+
|
|
4970
|
+ TableButton.prototype.menu = true;
|
|
4971
|
+
|
|
4972
|
+ TableButton.prototype._init = function() {
|
|
4973
|
+ TableButton.__super__._init.call(this);
|
|
4974
|
+ $.merge(this.editor.formatter._allowedTags, ['thead', 'th', 'tbody', 'tr', 'td', 'colgroup', 'col']);
|
|
4975
|
+ $.extend(this.editor.formatter._allowedAttributes, {
|
|
4976
|
+ td: ['rowspan', 'colspan'],
|
|
4977
|
+ col: ['width']
|
|
4978
|
+ });
|
|
4979
|
+ $.extend(this.editor.formatter._allowedStyles, {
|
|
4980
|
+ td: ['text-align'],
|
|
4981
|
+ th: ['text-align']
|
|
4982
|
+ });
|
|
4983
|
+ this._initShortcuts();
|
|
4984
|
+ this.editor.on('decorate', (function(_this) {
|
|
4985
|
+ return function(e, $el) {
|
|
4986
|
+ return $el.find('table').each(function(i, table) {
|
|
4987
|
+ return _this.decorate($(table));
|
|
4988
|
+ });
|
|
4989
|
+ };
|
|
4990
|
+ })(this));
|
|
4991
|
+ this.editor.on('undecorate', (function(_this) {
|
|
4992
|
+ return function(e, $el) {
|
|
4993
|
+ return $el.find('table').each(function(i, table) {
|
|
4994
|
+ return _this.undecorate($(table));
|
|
4995
|
+ });
|
|
4996
|
+ };
|
|
4997
|
+ })(this));
|
|
4998
|
+ this.editor.on('selectionchanged.table', (function(_this) {
|
|
4999
|
+ return function(e) {
|
|
5000
|
+ var $container, range;
|
|
5001
|
+ _this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active');
|
|
5002
|
+ range = _this.editor.selection.range();
|
|
5003
|
+ if (!range) {
|
|
5004
|
+ return;
|
|
5005
|
+ }
|
|
5006
|
+ $container = _this.editor.selection.containerNode();
|
|
5007
|
+ if (range.collapsed && $container.is('.simditor-table')) {
|
|
5008
|
+ if (_this.editor.selection.rangeAtStartOf($container)) {
|
|
5009
|
+ $container = $container.find('th:first');
|
|
5010
|
+ } else {
|
|
5011
|
+ $container = $container.find('td:last');
|
|
5012
|
+ }
|
|
5013
|
+ _this.editor.selection.setRangeAtEndOf($container);
|
|
5014
|
+ }
|
|
5015
|
+ return $container.closest('td, th', _this.editor.body).addClass('active');
|
|
5016
|
+ };
|
|
5017
|
+ })(this));
|
|
5018
|
+ this.editor.on('blur.table', (function(_this) {
|
|
5019
|
+ return function(e) {
|
|
5020
|
+ return _this.editor.body.find('.simditor-table td, .simditor-table th').removeClass('active');
|
|
5021
|
+ };
|
|
5022
|
+ })(this));
|
|
5023
|
+ this.editor.keystroke.add('up', 'td', (function(_this) {
|
|
5024
|
+ return function(e, $node) {
|
|
5025
|
+ _this._tdNav($node, 'up');
|
|
5026
|
+ return true;
|
|
5027
|
+ };
|
|
5028
|
+ })(this));
|
|
5029
|
+ this.editor.keystroke.add('up', 'th', (function(_this) {
|
|
5030
|
+ return function(e, $node) {
|
|
5031
|
+ _this._tdNav($node, 'up');
|
|
5032
|
+ return true;
|
|
5033
|
+ };
|
|
5034
|
+ })(this));
|
|
5035
|
+ this.editor.keystroke.add('down', 'td', (function(_this) {
|
|
5036
|
+ return function(e, $node) {
|
|
5037
|
+ _this._tdNav($node, 'down');
|
|
5038
|
+ return true;
|
|
5039
|
+ };
|
|
5040
|
+ })(this));
|
|
5041
|
+ return this.editor.keystroke.add('down', 'th', (function(_this) {
|
|
5042
|
+ return function(e, $node) {
|
|
5043
|
+ _this._tdNav($node, 'down');
|
|
5044
|
+ return true;
|
|
5045
|
+ };
|
|
5046
|
+ })(this));
|
|
5047
|
+ };
|
|
5048
|
+
|
|
5049
|
+ TableButton.prototype._tdNav = function($td, direction) {
|
|
5050
|
+ var $anotherTr, $tr, action, anotherTag, index, parentTag, ref;
|
|
5051
|
+ if (direction == null) {
|
|
5052
|
+ direction = 'up';
|
|
5053
|
+ }
|
|
5054
|
+ action = direction === 'up' ? 'prev' : 'next';
|
|
5055
|
+ ref = direction === 'up' ? ['tbody', 'thead'] : ['thead', 'tbody'], parentTag = ref[0], anotherTag = ref[1];
|
|
5056
|
+ $tr = $td.parent('tr');
|
|
5057
|
+ $anotherTr = this["_" + action + "Row"]($tr);
|
|
5058
|
+ if (!($anotherTr.length > 0)) {
|
|
5059
|
+ return true;
|
|
5060
|
+ }
|
|
5061
|
+ index = $tr.find('td, th').index($td);
|
|
5062
|
+ return this.editor.selection.setRangeAtEndOf($anotherTr.find('td, th').eq(index));
|
|
5063
|
+ };
|
|
5064
|
+
|
|
5065
|
+ TableButton.prototype._nextRow = function($tr) {
|
|
5066
|
+ var $nextTr;
|
|
5067
|
+ $nextTr = $tr.next('tr');
|
|
5068
|
+ if ($nextTr.length < 1 && $tr.parent('thead').length > 0) {
|
|
5069
|
+ $nextTr = $tr.parent('thead').next('tbody').find('tr:first');
|
|
5070
|
+ }
|
|
5071
|
+ return $nextTr;
|
|
5072
|
+ };
|
|
5073
|
+
|
|
5074
|
+ TableButton.prototype._prevRow = function($tr) {
|
|
5075
|
+ var $prevTr;
|
|
5076
|
+ $prevTr = $tr.prev('tr');
|
|
5077
|
+ if ($prevTr.length < 1 && $tr.parent('tbody').length > 0) {
|
|
5078
|
+ $prevTr = $tr.parent('tbody').prev('thead').find('tr');
|
|
5079
|
+ }
|
|
5080
|
+ return $prevTr;
|
|
5081
|
+ };
|
|
5082
|
+
|
|
5083
|
+ TableButton.prototype.initResize = function($table) {
|
|
5084
|
+ var $colgroup, $resizeHandle, $wrapper;
|
|
5085
|
+ $wrapper = $table.parent('.simditor-table');
|
|
5086
|
+ $colgroup = $table.find('colgroup');
|
|
5087
|
+ if ($colgroup.length < 1) {
|
|
5088
|
+ $colgroup = $('<colgroup/>').prependTo($table);
|
|
5089
|
+ $table.find('thead tr th').each(function(i, td) {
|
|
5090
|
+ var $col;
|
|
5091
|
+ return $col = $('<col/>').appendTo($colgroup);
|
|
5092
|
+ });
|
|
5093
|
+ this.refreshTableWidth($table);
|
|
5094
|
+ }
|
|
5095
|
+ $resizeHandle = $('<div />', {
|
|
5096
|
+ "class": 'simditor-resize-handle',
|
|
5097
|
+ contenteditable: 'false'
|
|
5098
|
+ }).appendTo($wrapper);
|
|
5099
|
+ $wrapper.on('mousemove', 'td, th', function(e) {
|
|
5100
|
+ var $col, $td, index, ref, ref1, x;
|
|
5101
|
+ if ($wrapper.hasClass('resizing')) {
|
|
5102
|
+ return;
|
|
5103
|
+ }
|
|
5104
|
+ $td = $(e.currentTarget);
|
|
5105
|
+ x = e.pageX - $(e.currentTarget).offset().left;
|
|
5106
|
+ if (x < 5 && $td.prev().length > 0) {
|
|
5107
|
+ $td = $td.prev();
|
|
5108
|
+ }
|
|
5109
|
+ if ($td.next('td, th').length < 1) {
|
|
5110
|
+ $resizeHandle.hide();
|
|
5111
|
+ return;
|
|
5112
|
+ }
|
|
5113
|
+ if ((ref = $resizeHandle.data('td')) != null ? ref.is($td) : void 0) {
|
|
5114
|
+ $resizeHandle.show();
|
|
5115
|
+ return;
|
|
5116
|
+ }
|
|
5117
|
+ index = $td.parent().find('td, th').index($td);
|
|
5118
|
+ $col = $colgroup.find('col').eq(index);
|
|
5119
|
+ if ((ref1 = $resizeHandle.data('col')) != null ? ref1.is($col) : void 0) {
|
|
5120
|
+ $resizeHandle.show();
|
|
5121
|
+ return;
|
|
5122
|
+ }
|
|
5123
|
+ return $resizeHandle.css('left', $td.position().left + $td.outerWidth() - 5).data('td', $td).data('col', $col).show();
|
|
5124
|
+ });
|
|
5125
|
+ $wrapper.on('mouseleave', function(e) {
|
|
5126
|
+ return $resizeHandle.hide();
|
|
5127
|
+ });
|
|
5128
|
+ return $wrapper.on('mousedown', '.simditor-resize-handle', function(e) {
|
|
5129
|
+ var $handle, $leftCol, $leftTd, $rightCol, $rightTd, minWidth, startHandleLeft, startLeftWidth, startRightWidth, startX, tableWidth;
|
|
5130
|
+ $handle = $(e.currentTarget);
|
|
5131
|
+ $leftTd = $handle.data('td');
|
|
5132
|
+ $leftCol = $handle.data('col');
|
|
5133
|
+ $rightTd = $leftTd.next('td, th');
|
|
5134
|
+ $rightCol = $leftCol.next('col');
|
|
5135
|
+ startX = e.pageX;
|
|
5136
|
+ startLeftWidth = $leftTd.outerWidth() * 1;
|
|
5137
|
+ startRightWidth = $rightTd.outerWidth() * 1;
|
|
5138
|
+ startHandleLeft = parseFloat($handle.css('left'));
|
|
5139
|
+ tableWidth = $leftTd.closest('table').width();
|
|
5140
|
+ minWidth = 50;
|
|
5141
|
+ $(document).on('mousemove.simditor-resize-table', function(e) {
|
|
5142
|
+ var deltaX, leftWidth, rightWidth;
|
|
5143
|
+ deltaX = e.pageX - startX;
|
|
5144
|
+ leftWidth = startLeftWidth + deltaX;
|
|
5145
|
+ rightWidth = startRightWidth - deltaX;
|
|
5146
|
+ if (leftWidth < minWidth) {
|
|
5147
|
+ leftWidth = minWidth;
|
|
5148
|
+ deltaX = minWidth - startLeftWidth;
|
|
5149
|
+ rightWidth = startRightWidth - deltaX;
|
|
5150
|
+ } else if (rightWidth < minWidth) {
|
|
5151
|
+ rightWidth = minWidth;
|
|
5152
|
+ deltaX = startRightWidth - minWidth;
|
|
5153
|
+ leftWidth = startLeftWidth + deltaX;
|
|
5154
|
+ }
|
|
5155
|
+ $leftCol.attr('width', (leftWidth / tableWidth * 100) + '%');
|
|
5156
|
+ $rightCol.attr('width', (rightWidth / tableWidth * 100) + '%');
|
|
5157
|
+ return $handle.css('left', startHandleLeft + deltaX);
|
|
5158
|
+ });
|
|
5159
|
+ $(document).one('mouseup.simditor-resize-table', function(e) {
|
|
5160
|
+ $(document).off('.simditor-resize-table');
|
|
5161
|
+ return $wrapper.removeClass('resizing');
|
|
5162
|
+ });
|
|
5163
|
+ $wrapper.addClass('resizing');
|
|
5164
|
+ return false;
|
|
5165
|
+ });
|
|
5166
|
+ };
|
|
5167
|
+
|
|
5168
|
+ TableButton.prototype._initShortcuts = function() {
|
|
5169
|
+ this.editor.hotkeys.add('ctrl+alt+up', (function(_this) {
|
|
5170
|
+ return function(e) {
|
|
5171
|
+ _this.editMenu.find('.menu-item[data-param=insertRowAbove]').click();
|
|
5172
|
+ return false;
|
|
5173
|
+ };
|
|
5174
|
+ })(this));
|
|
5175
|
+ this.editor.hotkeys.add('ctrl+alt+down', (function(_this) {
|
|
5176
|
+ return function(e) {
|
|
5177
|
+ _this.editMenu.find('.menu-item[data-param=insertRowBelow]').click();
|
|
5178
|
+ return false;
|
|
5179
|
+ };
|
|
5180
|
+ })(this));
|
|
5181
|
+ this.editor.hotkeys.add('ctrl+alt+left', (function(_this) {
|
|
5182
|
+ return function(e) {
|
|
5183
|
+ _this.editMenu.find('.menu-item[data-param=insertColLeft]').click();
|
|
5184
|
+ return false;
|
|
5185
|
+ };
|
|
5186
|
+ })(this));
|
|
5187
|
+ return this.editor.hotkeys.add('ctrl+alt+right', (function(_this) {
|
|
5188
|
+ return function(e) {
|
|
5189
|
+ _this.editMenu.find('.menu-item[data-param=insertColRight]').click();
|
|
5190
|
+ return false;
|
|
5191
|
+ };
|
|
5192
|
+ })(this));
|
|
5193
|
+ };
|
|
5194
|
+
|
|
5195
|
+ TableButton.prototype.decorate = function($table) {
|
|
5196
|
+ var $headRow, $tbody, $thead;
|
|
5197
|
+ if ($table.parent('.simditor-table').length > 0) {
|
|
5198
|
+ this.undecorate($table);
|
|
5199
|
+ }
|
|
5200
|
+ $table.wrap('<div class="simditor-table"></div>');
|
|
5201
|
+ if ($table.find('thead').length < 1) {
|
|
5202
|
+ $thead = $('<thead />');
|
|
5203
|
+ $headRow = $table.find('tr').first();
|
|
5204
|
+ $thead.append($headRow);
|
|
5205
|
+ this._changeCellTag($headRow, 'th');
|
|
5206
|
+ $tbody = $table.find('tbody');
|
|
5207
|
+ if ($tbody.length > 0) {
|
|
5208
|
+ $tbody.before($thead);
|
|
5209
|
+ } else {
|
|
5210
|
+ $table.prepend($thead);
|
|
5211
|
+ }
|
|
5212
|
+ }
|
|
5213
|
+ this.initResize($table);
|
|
5214
|
+ return $table.parent();
|
|
5215
|
+ };
|
|
5216
|
+
|
|
5217
|
+ TableButton.prototype.undecorate = function($table) {
|
|
5218
|
+ if (!($table.parent('.simditor-table').length > 0)) {
|
|
5219
|
+ return;
|
|
5220
|
+ }
|
|
5221
|
+ return $table.parent().replaceWith($table);
|
|
5222
|
+ };
|
|
5223
|
+
|
|
5224
|
+ TableButton.prototype.renderMenu = function() {
|
|
5225
|
+ var $table;
|
|
5226
|
+ $("<div class=\"menu-create-table\">\n</div>\n<div class=\"menu-edit-table\">\n <ul>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteRow\">\n <span>" + (this._t('deleteRow')) + "</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertRowAbove\">\n <span>" + (this._t('insertRowAbove')) + " ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertRowBelow\">\n <span>" + (this._t('insertRowBelow')) + " ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class=\"separator\"></span></li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteCol\">\n <span>" + (this._t('deleteColumn')) + "</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertColLeft\">\n <span>" + (this._t('insertColumnLeft')) + " ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"insertColRight\">\n <span>" + (this._t('insertColumnRight')) + " ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class=\"separator\"></span></li>\n <li>\n <a tabindex=\"-1\" unselectable=\"on\" class=\"menu-item\"\n href=\"javascript:;\" data-param=\"deleteTable\">\n <span>" + (this._t('deleteTable')) + "</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper);
|
|
5227
|
+ this.createMenu = this.menuWrapper.find('.menu-create-table');
|
|
5228
|
+ this.editMenu = this.menuWrapper.find('.menu-edit-table');
|
|
5229
|
+ $table = this.createTable(6, 6).appendTo(this.createMenu);
|
|
5230
|
+ this.createMenu.on('mouseenter', 'td, th', (function(_this) {
|
|
5231
|
+ return function(e) {
|
|
5232
|
+ var $td, $tr, $trs, num;
|
|
5233
|
+ _this.createMenu.find('td, th').removeClass('selected');
|
|
5234
|
+ $td = $(e.currentTarget);
|
|
5235
|
+ $tr = $td.parent();
|
|
5236
|
+ num = $tr.find('td, th').index($td) + 1;
|
|
5237
|
+ $trs = $tr.prevAll('tr').addBack();
|
|
5238
|
+ if ($tr.parent().is('tbody')) {
|
|
5239
|
+ $trs = $trs.add($table.find('thead tr'));
|
|
5240
|
+ }
|
|
5241
|
+ return $trs.find("td:lt(" + num + "), th:lt(" + num + ")").addClass('selected');
|
|
5242
|
+ };
|
|
5243
|
+ })(this));
|
|
5244
|
+ this.createMenu.on('mouseleave', function(e) {
|
|
5245
|
+ return $(e.currentTarget).find('td, th').removeClass('selected');
|
|
5246
|
+ });
|
|
5247
|
+ return this.createMenu.on('mousedown', 'td, th', (function(_this) {
|
|
5248
|
+ return function(e) {
|
|
5249
|
+ var $closestBlock, $td, $tr, colNum, rowNum;
|
|
5250
|
+ _this.wrapper.removeClass('menu-on');
|
|
5251
|
+ if (!_this.editor.inputManager.focused) {
|
|
5252
|
+ return;
|
|
5253
|
+ }
|
|
5254
|
+ $td = $(e.currentTarget);
|
|
5255
|
+ $tr = $td.parent();
|
|
5256
|
+ colNum = $tr.find('td').index($td) + 1;
|
|
5257
|
+ rowNum = $tr.prevAll('tr').length + 1;
|
|
5258
|
+ if ($tr.parent().is('tbody')) {
|
|
5259
|
+ rowNum += 1;
|
|
5260
|
+ }
|
|
5261
|
+ $table = _this.createTable(rowNum, colNum, true);
|
|
5262
|
+ $closestBlock = _this.editor.selection.blockNodes().last();
|
|
5263
|
+ if (_this.editor.util.isEmptyNode($closestBlock)) {
|
|
5264
|
+ $closestBlock.replaceWith($table);
|
|
5265
|
+ } else {
|
|
5266
|
+ $closestBlock.after($table);
|
|
5267
|
+ }
|
|
5268
|
+ _this.decorate($table);
|
|
5269
|
+ _this.editor.selection.setRangeAtStartOf($table.find('th:first'));
|
|
5270
|
+ _this.editor.trigger('valuechanged');
|
|
5271
|
+ return false;
|
|
5272
|
+ };
|
|
5273
|
+ })(this));
|
|
5274
|
+ };
|
|
5275
|
+
|
|
5276
|
+ TableButton.prototype.createTable = function(row, col, phBr) {
|
|
5277
|
+ var $table, $tbody, $td, $thead, $tr, c, k, l, r, ref, ref1;
|
|
5278
|
+ $table = $('<table/>');
|
|
5279
|
+ $thead = $('<thead/>').appendTo($table);
|
|
5280
|
+ $tbody = $('<tbody/>').appendTo($table);
|
|
5281
|
+ for (r = k = 0, ref = row; 0 <= ref ? k < ref : k > ref; r = 0 <= ref ? ++k : --k) {
|
|
5282
|
+ $tr = $('<tr/>');
|
|
5283
|
+ $tr.appendTo(r === 0 ? $thead : $tbody);
|
|
5284
|
+ for (c = l = 0, ref1 = col; 0 <= ref1 ? l < ref1 : l > ref1; c = 0 <= ref1 ? ++l : --l) {
|
|
5285
|
+ $td = $(r === 0 ? '<th/>' : '<td/>').appendTo($tr);
|
|
5286
|
+ if (phBr) {
|
|
5287
|
+ $td.append(this.editor.util.phBr);
|
|
5288
|
+ }
|
|
5289
|
+ }
|
|
5290
|
+ }
|
|
5291
|
+ return $table;
|
|
5292
|
+ };
|
|
5293
|
+
|
|
5294
|
+ TableButton.prototype.refreshTableWidth = function($table) {
|
|
5295
|
+ var cols, tableWidth;
|
|
5296
|
+ tableWidth = $table.width();
|
|
5297
|
+ cols = $table.find('col');
|
|
5298
|
+ return $table.find('thead tr th').each(function(i, td) {
|
|
5299
|
+ var $col;
|
|
5300
|
+ $col = cols.eq(i);
|
|
5301
|
+ return $col.attr('width', ($(td).outerWidth() / tableWidth * 100) + '%');
|
|
5302
|
+ });
|
|
5303
|
+ };
|
|
5304
|
+
|
|
5305
|
+ TableButton.prototype.setActive = function(active) {
|
|
5306
|
+ TableButton.__super__.setActive.call(this, active);
|
|
5307
|
+ if (active) {
|
|
5308
|
+ this.createMenu.hide();
|
|
5309
|
+ return this.editMenu.show();
|
|
5310
|
+ } else {
|
|
5311
|
+ this.createMenu.show();
|
|
5312
|
+ return this.editMenu.hide();
|
|
5313
|
+ }
|
|
5314
|
+ };
|
|
5315
|
+
|
|
5316
|
+ TableButton.prototype._changeCellTag = function($tr, tagName) {
|
|
5317
|
+ return $tr.find('td, th').each(function(i, cell) {
|
|
5318
|
+ var $cell;
|
|
5319
|
+ $cell = $(cell);
|
|
5320
|
+ return $cell.replaceWith("<" + tagName + ">" + ($cell.html()) + "</" + tagName + ">");
|
|
5321
|
+ });
|
|
5322
|
+ };
|
|
5323
|
+
|
|
5324
|
+ TableButton.prototype.deleteRow = function($td) {
|
|
5325
|
+ var $newTr, $tr, index;
|
|
5326
|
+ $tr = $td.parent('tr');
|
|
5327
|
+ if ($tr.closest('table').find('tr').length < 1) {
|
|
5328
|
+ return this.deleteTable($td);
|
|
5329
|
+ } else {
|
|
5330
|
+ $newTr = this._nextRow($tr);
|
|
5331
|
+ if (!($newTr.length > 0)) {
|
|
5332
|
+ $newTr = this._prevRow($tr);
|
|
5333
|
+ }
|
|
5334
|
+ index = $tr.find('td, th').index($td);
|
|
5335
|
+ if ($tr.parent().is('thead')) {
|
|
5336
|
+ $newTr.appendTo($tr.parent());
|
|
5337
|
+ this._changeCellTag($newTr, 'th');
|
|
5338
|
+ }
|
|
5339
|
+ $tr.remove();
|
|
5340
|
+ return this.editor.selection.setRangeAtEndOf($newTr.find('td, th').eq(index));
|
|
5341
|
+ }
|
|
5342
|
+ };
|
|
5343
|
+
|
|
5344
|
+ TableButton.prototype.insertRow = function($td, direction) {
|
|
5345
|
+ var $newTr, $table, $tr, cellTag, colNum, i, index, k, ref;
|
|
5346
|
+ if (direction == null) {
|
|
5347
|
+ direction = 'after';
|
|
5348
|
+ }
|
|
5349
|
+ $tr = $td.parent('tr');
|
|
5350
|
+ $table = $tr.closest('table');
|
|
5351
|
+ colNum = 0;
|
|
5352
|
+ $table.find('tr').each(function(i, tr) {
|
|
5353
|
+ return colNum = Math.max(colNum, $(tr).find('td').length);
|
|
5354
|
+ });
|
|
5355
|
+ index = $tr.find('td, th').index($td);
|
|
5356
|
+ $newTr = $('<tr/>');
|
|
5357
|
+ cellTag = 'td';
|
|
5358
|
+ if (direction === 'after' && $tr.parent().is('thead')) {
|
|
5359
|
+ $tr.parent().next('tbody').prepend($newTr);
|
|
5360
|
+ } else if (direction === 'before' && $tr.parent().is('thead')) {
|
|
5361
|
+ $tr.before($newTr);
|
|
5362
|
+ $tr.parent().next('tbody').prepend($tr);
|
|
5363
|
+ this._changeCellTag($tr, 'td');
|
|
5364
|
+ cellTag = 'th';
|
|
5365
|
+ } else {
|
|
5366
|
+ $tr[direction]($newTr);
|
|
5367
|
+ }
|
|
5368
|
+ for (i = k = 1, ref = colNum; 1 <= ref ? k <= ref : k >= ref; i = 1 <= ref ? ++k : --k) {
|
|
5369
|
+ $("<" + cellTag + "/>").append(this.editor.util.phBr).appendTo($newTr);
|
|
5370
|
+ }
|
|
5371
|
+ return this.editor.selection.setRangeAtStartOf($newTr.find('td, th').eq(index));
|
|
5372
|
+ };
|
|
5373
|
+
|
|
5374
|
+ TableButton.prototype.deleteCol = function($td) {
|
|
5375
|
+ var $newTd, $table, $tr, index, noOtherCol, noOtherRow;
|
|
5376
|
+ $tr = $td.parent('tr');
|
|
5377
|
+ noOtherRow = $tr.closest('table').find('tr').length < 2;
|
|
5378
|
+ noOtherCol = $td.siblings('td, th').length < 1;
|
|
5379
|
+ if (noOtherRow && noOtherCol) {
|
|
5380
|
+ return this.deleteTable($td);
|
|
5381
|
+ } else {
|
|
5382
|
+ index = $tr.find('td, th').index($td);
|
|
5383
|
+ $newTd = $td.next('td, th');
|
|
5384
|
+ if (!($newTd.length > 0)) {
|
|
5385
|
+ $newTd = $tr.prev('td, th');
|
|
5386
|
+ }
|
|
5387
|
+ $table = $tr.closest('table');
|
|
5388
|
+ $table.find('col').eq(index).remove();
|
|
5389
|
+ $table.find('tr').each(function(i, tr) {
|
|
5390
|
+ return $(tr).find('td, th').eq(index).remove();
|
|
5391
|
+ });
|
|
5392
|
+ this.refreshTableWidth($table);
|
|
5393
|
+ return this.editor.selection.setRangeAtEndOf($newTd);
|
|
5394
|
+ }
|
|
5395
|
+ };
|
|
5396
|
+
|
|
5397
|
+ TableButton.prototype.insertCol = function($td, direction) {
|
|
5398
|
+ var $col, $newCol, $newTd, $table, $tr, index, tableWidth, width;
|
|
5399
|
+ if (direction == null) {
|
|
5400
|
+ direction = 'after';
|
|
5401
|
+ }
|
|
5402
|
+ $tr = $td.parent('tr');
|
|
5403
|
+ index = $tr.find('td, th').index($td);
|
|
5404
|
+ $table = $td.closest('table');
|
|
5405
|
+ $col = $table.find('col').eq(index);
|
|
5406
|
+ $table.find('tr').each((function(_this) {
|
|
5407
|
+ return function(i, tr) {
|
|
5408
|
+ var $newTd, cellTag;
|
|
5409
|
+ cellTag = $(tr).parent().is('thead') ? 'th' : 'td';
|
|
5410
|
+ $newTd = $("<" + cellTag + "/>").append(_this.editor.util.phBr);
|
|
5411
|
+ return $(tr).find('td, th').eq(index)[direction]($newTd);
|
|
5412
|
+ };
|
|
5413
|
+ })(this));
|
|
5414
|
+ $newCol = $('<col/>');
|
|
5415
|
+ $col[direction]($newCol);
|
|
5416
|
+ tableWidth = $table.width();
|
|
5417
|
+ width = Math.max(parseFloat($col.attr('width')) / 2, 50 / tableWidth * 100);
|
|
5418
|
+ $col.attr('width', width + '%');
|
|
5419
|
+ $newCol.attr('width', width + '%');
|
|
5420
|
+ this.refreshTableWidth($table);
|
|
5421
|
+ $newTd = direction === 'after' ? $td.next('td, th') : $td.prev('td, th');
|
|
5422
|
+ return this.editor.selection.setRangeAtStartOf($newTd);
|
|
5423
|
+ };
|
|
5424
|
+
|
|
5425
|
+ TableButton.prototype.deleteTable = function($td) {
|
|
5426
|
+ var $block, $table;
|
|
5427
|
+ $table = $td.closest('.simditor-table');
|
|
5428
|
+ $block = $table.next('p');
|
|
5429
|
+ $table.remove();
|
|
5430
|
+ if ($block.length > 0) {
|
|
5431
|
+ return this.editor.selection.setRangeAtStartOf($block);
|
|
5432
|
+ }
|
|
5433
|
+ };
|
|
5434
|
+
|
|
5435
|
+ TableButton.prototype.command = function(param) {
|
|
5436
|
+ var $td;
|
|
5437
|
+ $td = this.editor.selection.containerNode().closest('td, th');
|
|
5438
|
+ if (!($td.length > 0)) {
|
|
5439
|
+ return;
|
|
5440
|
+ }
|
|
5441
|
+ if (param === 'deleteRow') {
|
|
5442
|
+ this.deleteRow($td);
|
|
5443
|
+ } else if (param === 'insertRowAbove') {
|
|
5444
|
+ this.insertRow($td, 'before');
|
|
5445
|
+ } else if (param === 'insertRowBelow') {
|
|
5446
|
+ this.insertRow($td);
|
|
5447
|
+ } else if (param === 'deleteCol') {
|
|
5448
|
+ this.deleteCol($td);
|
|
5449
|
+ } else if (param === 'insertColLeft') {
|
|
5450
|
+ this.insertCol($td, 'before');
|
|
5451
|
+ } else if (param === 'insertColRight') {
|
|
5452
|
+ this.insertCol($td);
|
|
5453
|
+ } else if (param === 'deleteTable') {
|
|
5454
|
+ this.deleteTable($td);
|
|
5455
|
+ } else {
|
|
5456
|
+ return;
|
|
5457
|
+ }
|
|
5458
|
+ return this.editor.trigger('valuechanged');
|
|
5459
|
+ };
|
|
5460
|
+
|
|
5461
|
+ return TableButton;
|
|
5462
|
+
|
|
5463
|
+})(Button);
|
|
5464
|
+
|
|
5465
|
+Simditor.Toolbar.addButton(TableButton);
|
|
5466
|
+
|
|
5467
|
+StrikethroughButton = (function(superClass) {
|
|
5468
|
+ extend(StrikethroughButton, superClass);
|
|
5469
|
+
|
|
5470
|
+ function StrikethroughButton() {
|
|
5471
|
+ return StrikethroughButton.__super__.constructor.apply(this, arguments);
|
|
5472
|
+ }
|
|
5473
|
+
|
|
5474
|
+ StrikethroughButton.prototype.name = 'strikethrough';
|
|
5475
|
+
|
|
5476
|
+ StrikethroughButton.prototype.icon = 'strikethrough';
|
|
5477
|
+
|
|
5478
|
+ StrikethroughButton.prototype.htmlTag = 'strike';
|
|
5479
|
+
|
|
5480
|
+ StrikethroughButton.prototype.disableTag = 'pre';
|
|
5481
|
+
|
|
5482
|
+ StrikethroughButton.prototype._activeStatus = function() {
|
|
5483
|
+ var active;
|
|
5484
|
+ active = document.queryCommandState('strikethrough') === true;
|
|
5485
|
+ this.setActive(active);
|
|
5486
|
+ return this.active;
|
|
5487
|
+ };
|
|
5488
|
+
|
|
5489
|
+ StrikethroughButton.prototype.command = function() {
|
|
5490
|
+ document.execCommand('strikethrough');
|
|
5491
|
+ if (!this.editor.util.support.oninput) {
|
|
5492
|
+ this.editor.trigger('valuechanged');
|
|
5493
|
+ }
|
|
5494
|
+ return $(document).trigger('selectionchange');
|
|
5495
|
+ };
|
|
5496
|
+
|
|
5497
|
+ return StrikethroughButton;
|
|
5498
|
+
|
|
5499
|
+})(Button);
|
|
5500
|
+
|
|
5501
|
+Simditor.Toolbar.addButton(StrikethroughButton);
|
|
5502
|
+
|
|
5503
|
+AlignmentButton = (function(superClass) {
|
|
5504
|
+ extend(AlignmentButton, superClass);
|
|
5505
|
+
|
|
5506
|
+ function AlignmentButton() {
|
|
5507
|
+ return AlignmentButton.__super__.constructor.apply(this, arguments);
|
|
5508
|
+ }
|
|
5509
|
+
|
|
5510
|
+ AlignmentButton.prototype.name = "alignment";
|
|
5511
|
+
|
|
5512
|
+ AlignmentButton.prototype.icon = 'align-left';
|
|
5513
|
+
|
|
5514
|
+ AlignmentButton.prototype.htmlTag = 'p, h1, h2, h3, h4, td, th';
|
|
5515
|
+
|
|
5516
|
+ AlignmentButton.prototype._init = function() {
|
|
5517
|
+ this.menu = [
|
|
5518
|
+ {
|
|
5519
|
+ name: 'left',
|
|
5520
|
+ text: this._t('alignLeft'),
|
|
5521
|
+ icon: 'align-left',
|
|
5522
|
+ param: 'left'
|
|
5523
|
+ }, {
|
|
5524
|
+ name: 'center',
|
|
5525
|
+ text: this._t('alignCenter'),
|
|
5526
|
+ icon: 'align-center',
|
|
5527
|
+ param: 'center'
|
|
5528
|
+ }, {
|
|
5529
|
+ name: 'right',
|
|
5530
|
+ text: this._t('alignRight'),
|
|
5531
|
+ icon: 'align-right',
|
|
5532
|
+ param: 'right'
|
|
5533
|
+ }
|
|
5534
|
+ ];
|
|
5535
|
+ return AlignmentButton.__super__._init.call(this);
|
|
5536
|
+ };
|
|
5537
|
+
|
|
5538
|
+ AlignmentButton.prototype.setActive = function(active, align) {
|
|
5539
|
+ if (align == null) {
|
|
5540
|
+ align = 'left';
|
|
5541
|
+ }
|
|
5542
|
+ if (align !== 'left' && align !== 'center' && align !== 'right') {
|
|
5543
|
+ align = 'left';
|
|
5544
|
+ }
|
|
5545
|
+ if (align === 'left') {
|
|
5546
|
+ AlignmentButton.__super__.setActive.call(this, false);
|
|
5547
|
+ } else {
|
|
5548
|
+ AlignmentButton.__super__.setActive.call(this, active);
|
|
5549
|
+ }
|
|
5550
|
+ this.el.removeClass('align-left align-center align-right');
|
|
5551
|
+ if (active) {
|
|
5552
|
+ this.el.addClass('align-' + align);
|
|
5553
|
+ }
|
|
5554
|
+ this.setIcon('align-' + align);
|
|
5555
|
+ return this.menuEl.find('.menu-item').show().end().find('.menu-item-' + align).hide();
|
|
5556
|
+ };
|
|
5557
|
+
|
|
5558
|
+ AlignmentButton.prototype._status = function() {
|
|
5559
|
+ this.nodes = this.editor.selection.nodes().filter(this.htmlTag);
|
|
5560
|
+ if (this.nodes.length < 1) {
|
|
5561
|
+ this.setDisabled(true);
|
|
5562
|
+ return this.setActive(false);
|
|
5563
|
+ } else {
|
|
5564
|
+ this.setDisabled(false);
|
|
5565
|
+ return this.setActive(true, this.nodes.first().css('text-align'));
|
|
5566
|
+ }
|
|
5567
|
+ };
|
|
5568
|
+
|
|
5569
|
+ AlignmentButton.prototype.command = function(align) {
|
|
5570
|
+ if (align !== 'left' && align !== 'center' && align !== 'right') {
|
|
5571
|
+ throw new Error("simditor alignment button: invalid align " + align);
|
|
5572
|
+ }
|
|
5573
|
+ this.nodes.css({
|
|
5574
|
+ 'text-align': align === 'left' ? '' : align
|
|
5575
|
+ });
|
|
5576
|
+ this.editor.trigger('valuechanged');
|
|
5577
|
+ return this.editor.inputManager.throttledSelectionChanged();
|
|
5578
|
+ };
|
|
5579
|
+
|
|
5580
|
+ return AlignmentButton;
|
|
5581
|
+
|
|
5582
|
+})(Button);
|
|
5583
|
+
|
|
5584
|
+Simditor.Toolbar.addButton(AlignmentButton);
|
|
5585
|
+
|
|
5586
|
+return Simditor;
|
|
5587
|
+
|
|
5588
|
+}));
|
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+!function(a,b){"function"==typeof define&&define.amd?
|
|
2
|
+// AMD. Register as an anonymous module unless amdModuleId is set
|
|
3
|
+define("simple-module",["jquery"],function(c){return a.Module=b(c)}):"object"==typeof exports?module.exports=b(require("jquery")):a.SimpleModule=b(jQuery)}(this,function(a){var b,c=[].slice;return b=function(){function b(b){var c,d,e,f,g,h,i;if(this.opts=a.extend({},this.opts,b),(c=this.constructor)._connectedClasses||(c._connectedClasses=[]),g=function(){var a,b,c,e;for(c=this.constructor._connectedClasses,e=[],a=0,b=c.length;b>a;a++)d=c[a],i=d.pluginName.charAt(0).toLowerCase()+d.pluginName.slice(1),d.prototype._connected&&(d.prototype._module=this),e.push(this[i]=new d);return e}.call(this),this._connected)this.opts=a.extend({},this.opts,this._module.opts);else for(this._init(),e=0,h=g.length;h>e;e++)f=g[e],"function"==typeof f._init&&f._init();this.trigger("initialized")}return b.extend=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this[b]=d);return null!=(c=a.extended)?c.call(this):void 0}},b.include=function(a){var b,c,d;if(null!=a&&"object"==typeof a){for(b in a)d=a[b],"included"!==b&&"extended"!==b&&(this.prototype[b]=d);return null!=(c=a.included)?c.call(this):void 0}},b.connect=function(a){if("function"==typeof a){if(!a.pluginName)throw new Error("Module.connect: cannot connect plugin without pluginName");return a.prototype._connected=!0,this._connectedClasses||(this._connectedClasses=[]),this._connectedClasses.push(a),a.pluginName?this[a.pluginName]=a:void 0}},b.prototype.opts={},b.prototype._init=function(){},b.prototype.on=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).on.apply(d,b),this},b.prototype.one=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).one.apply(d,b),this},b.prototype.off=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).off.apply(d,b),this},b.prototype.trigger=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).trigger.apply(d,b),this},b.prototype.triggerHandler=function(){var b,d;return b=1<=arguments.length?c.call(arguments,0):[],(d=a(this)).triggerHandler.apply(d,b)},b.prototype._t=function(){var a,b;return a=1<=arguments.length?c.call(arguments,0):[],(b=this.constructor)._t.apply(b,a)},b._t=function(){var a,b,d,e;return b=arguments[0],a=2<=arguments.length?c.call(arguments,1):[],e=(null!=(d=this.i18n[this.locale])?d[b]:void 0)||"",a.length>0?(e=e.replace(/([^%]|^)%(?:(\d+)\$)?s/g,function(b,c,d){return d?c+a[parseInt(d)-1]:c+a.shift()}),e.replace(/%%s/g,"%s")):e},b.i18n={"zh-CN":{}},b.locale="zh-CN",b}()});!function(a,b){"function"==typeof define&&define.amd?
|
|
4
|
+// AMD. Register as an anonymous module unless amdModuleId is set
|
|
5
|
+define("simple-hotkeys",["jquery","simple-module"],function(c,d){return a.hotkeys=b(c,d)}):"object"==typeof exports?
|
|
6
|
+// Node. Does not work with strict CommonJS, but
|
|
7
|
+// only CommonJS-like environments that support module.exports,
|
|
8
|
+// like Node.
|
|
9
|
+module.exports=b(require("jquery"),require("simple-module")):(a.simple=a.simple||{},a.simple.hotkeys=b(jQuery,SimpleModule))}(this,function(a,b){var c,d,e=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(c,b),c.count=0,c.keyNameMap={8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Spacebar",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",45:"Insert",46:"Del",91:"Meta",93:"Meta",48:"0",49:"1",50:"2",51:"3",52:"4",53:"5",54:"6",55:"7",56:"8",57:"9",65:"A",66:"B",67:"C",68:"D",69:"E",70:"F",71:"G",72:"H",73:"I",74:"J",75:"K",76:"L",77:"M",78:"N",79:"O",80:"P",81:"Q",82:"R",83:"S",84:"T",85:"U",86:"V",87:"W",88:"X",89:"Y",90:"Z",96:"0",97:"1",98:"2",99:"3",100:"4",101:"5",102:"6",103:"7",104:"8",105:"9",106:"Multiply",107:"Add",109:"Subtract",110:"Decimal",111:"Divide",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",124:"F13",125:"F14",126:"F15",127:"F16",128:"F17",129:"F18",130:"F19",131:"F20",132:"F21",133:"F22",134:"F23",135:"F24",59:";",61:"=",186:";",187:"=",188:",",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},c.aliases={escape:"esc","delete":"del","return":"enter",ctrl:"control",space:"spacebar",ins:"insert",cmd:"meta",command:"meta",wins:"meta",windows:"meta"},c.normalize=function(a){var b,c,d,e,f,g;for(f=a.toLowerCase().replace(/\s+/gi,"").split("+"),b=c=0,g=f.length;g>c;b=++c)d=f[b],f[b]=this.aliases[d]||d;return e=f.pop(),f.sort().push(e),f.join("_")},c.prototype.opts={el:document},c.prototype._init=function(){return this.id=++this.constructor.count,this._map={},this._delegate="string"==typeof this.opts.el?document:this.opts.el,a(this._delegate).on("keydown.simple-hotkeys-"+this.id,this.opts.el,function(a){return function(b){var c;return null!=(c=a._getHander(b))?c.call(a,b):void 0}}(this))},c.prototype._getHander=function(a){var b,c;if(b=this.constructor.keyNameMap[a.which])return c="",a.altKey&&(c+="alt_"),a.ctrlKey&&(c+="control_"),a.metaKey&&(c+="meta_"),a.shiftKey&&(c+="shift_"),c+=b.toLowerCase(),this._map[c]},c.prototype.respondTo=function(a){return"string"==typeof a?null!=this._map[this.constructor.normalize(a)]:null!=this._getHander(a)},c.prototype.add=function(a,b){return this._map[this.constructor.normalize(a)]=b,this},c.prototype.remove=function(a){return delete this._map[this.constructor.normalize(a)],this},c.prototype.destroy=function(){return a(this._delegate).off(".simple-hotkeys-"+this.id),this._map={},this},c}(b),d=function(a){return new c(a)}});!function(a,b){"function"==typeof define&&define.amd?
|
|
10
|
+// AMD. Register as an anonymous module unless amdModuleId is set
|
|
11
|
+define("simple-uploader",["jquery","simple-module"],function(c,d){return a.uploader=b(c,d)}):"object"==typeof exports?
|
|
12
|
+// Node. Does not work with strict CommonJS, but
|
|
13
|
+// only CommonJS-like environments that support module.exports,
|
|
14
|
+// like Node.
|
|
15
|
+module.exports=b(require("jquery"),require("simple-module")):(a.simple=a.simple||{},a.simple.uploader=b(jQuery,SimpleModule))}(this,function(a,b){var c,d,e=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(c,b),c.count=0,c.prototype.opts={url:"",params:null,fileKey:"upload_file",connectionCount:3},c.prototype._init=function(){return this.files=[],this.queue=[],this.id=++c.count,this.on("uploadcomplete",function(b){return function(c,d){return b.files.splice(a.inArray(d,b.files),1),b.queue.length>0&&b.files.length<b.opts.connectionCount?b.upload(b.queue.shift()):b.uploading=!1}}(this)),a(window).on("beforeunload.uploader-"+this.id,function(a){return function(b){return a.uploading?(b.originalEvent.returnValue=a._t("leaveConfirm"),a._t("leaveConfirm")):void 0}}(this))},c.prototype.generateId=function(){var a;return a=0,function(){return a+=1}}(),c.prototype.upload=function(b,c){var d,e,f,g;if(null==c&&(c={}),null!=b){if(a.isArray(b)||b instanceof FileList)for(e=0,g=b.length;g>e;e++)d=b[e],this.upload(d,c);else a(b).is("input:file")?(f=a(b).attr("name"),f&&(c.fileKey=f),this.upload(a.makeArray(a(b)[0].files),c)):b.id&&b.obj||(b=this.getFile(b));if(b&&b.obj){if(a.extend(b,c),this.files.length>=this.opts.connectionCount)return void this.queue.push(b);if(this.triggerHandler("beforeupload",[b])!==!1)return this.files.push(b),this._xhrUpload(b),this.uploading=!0}}},c.prototype.getFile=function(a){var b,c,d;return a instanceof window.File||a instanceof window.Blob?(b=null!=(c=a.fileName)?c:a.name,{id:this.generateId(),url:this.opts.url,params:this.opts.params,fileKey:this.opts.fileKey,name:b,size:null!=(d=a.fileSize)?d:a.size,ext:b?b.split(".").pop().toLowerCase():"",obj:a}):null},c.prototype._xhrUpload=function(b){var c,d,e,f;if(c=new FormData,c.append(b.fileKey,b.obj),c.append("original_filename",b.name),b.params){e=b.params;for(d in e)f=e[d],c.append(d,f)}return b.xhr=a.ajax({url:b.url,data:c,processData:!1,contentType:!1,type:"POST",headers:{"X-File-Name":encodeURIComponent(b.name)},xhr:function(){var b;return b=a.ajaxSettings.xhr(),b&&(b.upload.onprogress=function(a){return function(b){return a.progress(b)}}(this)),b},progress:function(a){return function(c){return c.lengthComputable?a.trigger("uploadprogress",[b,c.loaded,c.total]):void 0}}(this),error:function(a){return function(c,d,e){return a.trigger("uploaderror",[b,c,d])}}(this),success:function(c){return function(d){return c.trigger("uploadprogress",[b,b.size,b.size]),c.trigger("uploadsuccess",[b,d]),a(document).trigger("uploadsuccess",[b,d,c])}}(this),complete:function(a){return function(c,d){return a.trigger("uploadcomplete",[b,c.responseText])}}(this)})},c.prototype.cancel=function(a){var b,c,d,e;if(!a.id)for(e=this.files,c=0,d=e.length;d>c;c++)if(b=e[c],b.id===1*a){a=b;break}return this.trigger("uploadcancel",[a]),a.xhr&&a.xhr.abort(),a.xhr=null},c.prototype.readImageFile=function(b,c){var d,e;if(a.isFunction(c))return e=new Image,e.onload=function(){return c(e)},e.onerror=function(){return c()},window.FileReader&&FileReader.prototype.readAsDataURL&&/^image/.test(b.type)?(d=new FileReader,d.onload=function(a){return e.src=a.target.result},d.readAsDataURL(b)):c()},c.prototype.destroy=function(){var b,c,d,e;for(this.queue.length=0,e=this.files,c=0,d=e.length;d>c;c++)b=e[c],this.cancel(b);return a(window).off(".uploader-"+this.id),a(document).off(".uploader-"+this.id)},c.i18n={"zh-CN":{leaveConfirm:"正在上传文件,如果离开上传会自动取消"}},c.locale="zh-CN",c}(b),d=function(a){return new c(a)}});/*!
|
|
16
|
+* Simditor v2.3.6
|
|
17
|
+* http://simditor.tower.im/
|
|
18
|
+* 2015-12-21
|
|
19
|
+*/
|
|
20
|
+!function(a,b){"function"==typeof define&&define.amd?
|
|
21
|
+// AMD. Register as an anonymous module unless amdModuleId is set
|
|
22
|
+define("simditor",["jquery","simple-module","simple-hotkeys","simple-uploader"],function(c,d,e,f){return a.Simditor=b(c,d,e,f)}):"object"==typeof exports?module.exports=b(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader")):a.Simditor=b(jQuery,SimpleModule,simple.hotkeys,simple.uploader)}(this,function(a,b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M=function(a,b){function c(){this.constructor=a}for(var d in b)N.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},N={}.hasOwnProperty,O=[].indexOf||function(a){for(var b=0,c=this.length;c>b;b++)if(b in this&&this[b]===a)return b;return-1},P=[].slice;return C=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Selection",c.prototype._range=null,c.prototype._startNodes=null,c.prototype._endNodes=null,c.prototype._containerNode=null,c.prototype._nodes=null,c.prototype._blockNodes=null,c.prototype._rootNodes=null,c.prototype._init=function(){return this.editor=this._module,this._selection=document.getSelection(),this.editor.on("selectionchanged",function(a){return function(b){return a.reset(),a._range=a._selection.getRangeAt(0)}}(this)),this.editor.on("blur",function(a){return function(b){return a.reset()}}(this))},c.prototype.reset=function(){return this._range=null,this._startNodes=null,this._endNodes=null,this._containerNode=null,this._nodes=null,this._blockNodes=null,this._rootNodes=null},c.prototype.clear=function(){var a;try{this._selection.removeAllRanges()}catch(b){a=b}return this.reset()},c.prototype.range=function(a){var b;return a?(this.clear(),this._selection.addRange(a),this._range=a,b=this.editor.util.browser.firefox||this.editor.util.browser.msie,!this.editor.inputManager.focused&&b&&this.editor.body.focus()):!this._range&&this.editor.inputManager.focused&&this._selection.rangeCount&&(this._range=this._selection.getRangeAt(0)),this._range},c.prototype.startNodes=function(){return this._range&&(this._startNodes||(this._startNodes=function(b){return function(){var c;return c=a(b._range.startContainer).parentsUntil(b.editor.body).get(),c.unshift(b._range.startContainer),a(c)}}(this)())),this._startNodes},c.prototype.endNodes=function(){var b;return this._range&&(this._endNodes||(this._endNodes=this._range.collapsed?this.startNodes():(b=a(this._range.endContainer).parentsUntil(this.editor.body).get(),b.unshift(this._range.endContainer),a(b)))),this._endNodes},c.prototype.containerNode=function(){return this._range&&(this._containerNode||(this._containerNode=a(this._range.commonAncestorContainer))),this._containerNode},c.prototype.nodes=function(){return this._range&&(this._nodes||(this._nodes=function(b){return function(){var c;return c=[],b.startNodes().first().is(b.endNodes().first())?c=b.startNodes().get():(b.startNodes().each(function(d,e){var f,g,h,i,j,k,l;return g=a(e),b.endNodes().index(g)>-1?c.push(e):g.parent().is(b.editor.body)||(k=b.endNodes().index(g.parent()))>-1?(f=k&&k>-1?b.endNodes().eq(k-1):b.endNodes().last(),h=g.parent().contents(),l=h.index(g),i=h.index(f),a.merge(c,h.slice(l,i).get())):(h=g.parent().contents(),j=h.index(g),a.merge(c,h.slice(j).get()))}),b.endNodes().each(function(d,e){var f,g,h;return f=a(e),f.parent().is(b.editor.body)||b.startNodes().index(f.parent())>-1?(c.push(e),!1):(g=f.parent().contents(),h=g.index(f),a.merge(c,g.slice(0,h+1)))})),a(a.unique(c))}}(this)())),this._nodes},c.prototype.blockNodes=function(){return this._range?(this._blockNodes||(this._blockNodes=function(a){return function(){return a.nodes().filter(function(b,c){return a.editor.util.isBlockNode(c)})}}(this)()),this._blockNodes):void 0},c.prototype.rootNodes=function(){return this._range?(this._rootNodes||(this._rootNodes=function(b){return function(){return b.nodes().filter(function(c,d){var e;return e=a(d).parent(),e.is(b.editor.body)||e.is("blockquote")})}}(this)()),this._rootNodes):void 0},c.prototype.rangeAtEndOf=function(b,c){var d,e,f,g,h,i;return null==c&&(c=this.range()),c&&c.collapsed?(b=a(b)[0],f=c.endContainer,g=this.editor.util.getNodeLength(f),e=c.endOffset===g-1,h=a(f).contents().last().is("br"),d=c.endOffset===g,e&&h||d?b===f?!0:a.contains(b,f)?(i=!0,a(f).parentsUntil(b).addBack().each(function(b,c){var d,e,f,g;return g=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),d=g.last(),f=d.get(0)===c,e=d.is("br")&&d.prev().get(0)===c,f||e?void 0:(i=!1,!1)}),i):!1:!1):void 0},c.prototype.rangeAtStartOf=function(b,c){var d,e;return null==c&&(c=this.range()),c&&c.collapsed?(b=a(b)[0],e=c.startContainer,0!==c.startOffset?!1:b===e?!0:a.contains(b,e)?(d=!0,a(e).parentsUntil(b).addBack().each(function(b,c){var e;return e=a(c).parent().contents().filter(function(){return!(this!==c&&3===this.nodeType&&!this.nodeValue)}),e.first().get(0)!==c?d=!1:void 0}),d):!1):void 0},c.prototype.insertNode=function(b,c){return null==c&&(c=this.range()),c?(b=a(b)[0],c.insertNode(b),this.setRangeAfter(b,c)):void 0},c.prototype.setRangeAfter=function(b,c){return null==c&&(c=this.range()),null!=c?(b=a(b)[0],c.setEndAfter(b),c.collapse(!1),this.range(c)):void 0},c.prototype.setRangeBefore=function(b,c){return null==c&&(c=this.range()),null!=c?(b=a(b)[0],c.setEndBefore(b),c.collapse(!1),this.range(c)):void 0},c.prototype.setRangeAtStartOf=function(b,c){return null==c&&(c=this.range()),b=a(b).get(0),c.setEnd(b,0),c.collapse(!1),this.range(c)},c.prototype.setRangeAtEndOf=function(b,c){var d,e,f,g,h,i,j;return null==c&&(c=this.range()),e=a(b),b=e[0],e.is("pre")?(f=e.contents(),f.length>0?(g=f.last(),i=g.text(),h=this.editor.util.getNodeLength(g[0]),"\n"===i.charAt(i.length-1)?c.setEnd(g[0],h-1):c.setEnd(g[0],h)):c.setEnd(b,0)):(j=this.editor.util.getNodeLength(b),3!==b.nodeType&&j>0&&(d=a(b).contents().last(),d.is("br")?j-=1:3!==d[0].nodeType&&this.editor.util.isEmptyNode(d)&&(d.append(this.editor.util.phBr),b=d[0],j=0)),c.setEnd(b,j)),c.collapse(!1),this.range(c)},c.prototype.deleteRangeContents=function(a){var b,c,d,e;return null==a&&(a=this.range()),e=a.cloneRange(),d=a.cloneRange(),e.collapse(!0),d.collapse(!1),c=this.rangeAtStartOf(this.editor.body,e),b=this.rangeAtEndOf(this.editor.body,d),!a.collapsed&&c&&b?(this.editor.body.empty(),a.setStart(this.editor.body[0],0),a.collapse(!0),this.range(a)):a.deleteContents(),a},c.prototype.breakBlockEl=function(b,c){var d;return null==c&&(c=this.range()),d=a(b),c.collapsed?(c.setStartBefore(d.get(0)),c.collapsed?d:d.before(c.extractContents())):d},c.prototype.save=function(b){var c,d,e;return null==b&&(b=this.range()),this._selectionSaved?void 0:(d=b.cloneRange(),d.collapse(!1),e=a("<span/>").addClass("simditor-caret-start"),c=a("<span/>").addClass("simditor-caret-end"),d.insertNode(c[0]),b.insertNode(e[0]),this.clear(),this._selectionSaved=!0)},c.prototype.restore=function(){var a,b,c,d,e,f,g;return this._selectionSaved?(e=this.editor.body.find(".simditor-caret-start"),a=this.editor.body.find(".simditor-caret-end"),e.length&&a.length?(f=e.parent(),g=f.contents().index(e),b=a.parent(),c=b.contents().index(a),f[0]===b[0]&&(c-=1),d=document.createRange(),d.setStart(f.get(0),g),d.setEnd(b.get(0),c),e.remove(),a.remove(),this.range(d)):(e.remove(),a.remove()),this._selectionSaved=!1,d):!1},c}(b),n=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Formatter",c.prototype.opts={allowedTags:[],allowedAttributes:{},allowedStyles:{}},c.prototype._init=function(){return this.editor=this._module,this._allowedTags=a.merge(["br","span","a","img","b","strong","i","strike","u","font","p","ul","ol","li","blockquote","pre","code","h1","h2","h3","h4","hr"],this.opts.allowedTags),this._allowedAttributes=a.extend({img:["src","alt","width","height","data-non-image"],a:["href","target"],font:["color"],code:["class"]},this.opts.allowedAttributes),this._allowedStyles=a.extend({span:["color","font-size"],b:["color"],i:["color"],strong:["color"],strike:["color"],u:["color"],p:["margin-left","text-align"],h1:["margin-left","text-align"],h2:["margin-left","text-align"],h3:["margin-left","text-align"],h4:["margin-left","text-align"]},this.opts.allowedStyles),this.editor.body.on("click","a",function(a){return!1})},c.prototype.decorate=function(a){return null==a&&(a=this.editor.body),this.editor.trigger("decorate",[a]),a},c.prototype.undecorate=function(a){return null==a&&(a=this.editor.body.clone()),this.editor.trigger("undecorate",[a]),a},c.prototype.autolink=function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o;for(null==b&&(b=this.editor.body),i=[],e=function(c){return c.contents().each(function(c,d){var f,g;return f=a(d),f.is("a")||f.closest("a, pre",b).length?void 0:!f.is("iframe")&&f.contents().length?e(f):(g=f.text())&&/https?:\/\/|www\./gi.test(g)?i.push(f):void 0})},e(b),k=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/gi,f=0,h=i.length;h>f;f++){for(d=i[f],n=d.text(),l=[],j=null,g=0;null!==(j=k.exec(n));)m=n.substring(g,j.index),l.push(document.createTextNode(m)),g=k.lastIndex,o=/^(http(s)?:\/\/|\/)/.test(j[0])?j[0]:"http://"+j[0],c=a('<a href="'+o+'" rel="nofollow"></a>').text(j[0]),l.push(c[0]);l.push(document.createTextNode(n.substring(g))),d.replaceWith(a(l))}return b},c.prototype.format=function(b){var c,d,e,f,g,h,i,j,k,l;if(null==b&&(b=this.editor.body),b.is(":empty"))return b.append("<p>"+this.editor.util.phBr+"</p>"),b;for(k=b.contents(),e=0,g=k.length;g>e;e++)i=k[e],this.cleanNode(i,!0);for(l=b.contents(),f=0,h=l.length;h>f;f++)j=l[f],c=a(j),c.is("br")?("undefined"!=typeof d&&null!==d&&(d=null),c.remove()):this.editor.util.isBlockNode(j)?c.is("li")?d&&d.is("ul, ol")?d.append(j):(d=a("<ul/>").insertBefore(j),d.append(j)):d=null:((!d||d.is("ul, ol"))&&(d=a("<p/>").insertBefore(j)),d.append(j),this.editor.util.isEmptyNode(d)&&d.append(this.editor.util.phBr));return b},c.prototype.cleanNode=function(b,c){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u;if(f=a(b),f.length>0){if(3===f[0].nodeType)return t=f.text().replace(/(\r\n|\n|\r)/gm,""),void(t?(u=document.createTextNode(t),f.replaceWith(u)):f.remove());if(k=f.is("iframe")?null:f.contents(),l=this.editor.util.isDecoratedNode(f),f.is(this._allowedTags.join(","))||l){if(f.is("a")&&(e=f.find("img")).length>0&&(f.replaceWith(e),f=e,k=null),f.is("td")&&(d=f.find(this.editor.util.blockNodes.join(","))).length>0&&(d.each(function(b){return function(b,c){return a(c).contents().unwrap()}}(this)),k=f.contents()),f.is("img")&&f.hasClass("uploading")&&f.remove(),!l){for(i=this._allowedAttributes[f[0].tagName.toLowerCase()],r=a.makeArray(f[0].attributes),m=0,o=r.length;o>m;m++)j=r[m],"style"!==j.name&&(null!=i&&(s=j.name,O.call(i,s)>=0)||f.removeAttr(j.name));this._cleanNodeStyles(f),f.is("span")&&0===f[0].attributes.length&&f.contents().first().unwrap()}}else 1!==f[0].nodeType||f.is(":empty")?(f.remove(),k=null):f.is("div, article, dl, header, footer, tr")?(f.append("<br/>"),k.first().unwrap()):f.is("table")?(g=a("<p/>"),f.find("tr").each(function(b,c){return g.append(a(c).text()+"<br/>")}),f.replaceWith(g),k=null):f.is("thead, tfoot")?(f.remove(),k=null):f.is("th")?(h=a("<td/>").append(f.contents()),f.replaceWith(h)):k.first().unwrap();if(c&&null!=k&&!f.is("pre"))for(n=0,p=k.length;p>n;n++)q=k[n],this.cleanNode(q,!0);return null}},c.prototype._cleanNodeStyles=function(b){var c,d,e,f,g,h,i,j,k;if(j=b.attr("style")){if(b.removeAttr("style"),c=this._allowedStyles[b[0].tagName.toLowerCase()],!(c&&c.length>0))return b;for(k={},g=j.split(";"),d=0,e=g.length;e>d;d++)i=g[d],i=a.trim(i),f=i.split(":"),(f.length=2)&&(h=f[0],O.call(c,h)>=0&&(k[a.trim(f[0])]=a.trim(f[1])));return Object.keys(k).length>0&&b.css(k),b}},c.prototype.clearHtml=function(b,c){var d,e,f;return null==c&&(c=!0),d=a("<div/>").append(b),e=d.contents(),f="",e.each(function(b){return function(d,g){var h,i;return 3===g.nodeType?f+=g.nodeValue:1===g.nodeType&&(h=a(g),i=h.is("iframe")?null:h.contents(),i&&i.length>0&&(f+=b.clearHtml(i)),c&&d<e.length-1&&h.is("br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header"))?f+="\n":void 0}}(this)),f},c.prototype.beautify=function(b){var c;return c=function(a){return!!(a.is("p")&&!a.text()&&a.children(":not(br)").length<1)},b.each(function(b,d){var e,f;return e=a(d),f=e.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty'),(f||c(e))&&e.remove(),e.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove()})},c}(b),t=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="InputManager",c.prototype._modifierKeys=[16,17,18,91,93,224],c.prototype._arrowKeys=[37,38,39,40],c.prototype._init=function(){var b,c;return this.editor=this._module,this.throttledValueChanged=this.editor.util.throttle(function(a){return function(b){return setTimeout(function(){return a.editor.trigger("valuechanged",b)},10)}}(this),300),this.throttledSelectionChanged=this.editor.util.throttle(function(a){return function(){return a.editor.trigger("selectionchanged")}}(this),50),a(document).on("selectionchange.simditor"+this.editor.id,function(a){return function(b){var c;if(a.focused&&!a.editor.clipboard.pasting)return(c=function(){return a._selectionTimer&&(clearTimeout(a._selectionTimer),a._selectionTimer=null),a.editor.selection._selection.rangeCount>0?a.throttledSelectionChanged():a._selectionTimer=setTimeout(function(){return a._selectionTimer=null,a.focused?c():void 0},10)})()}}(this)),this.editor.on("valuechanged",function(b){return function(){var c;return b.lastCaretPosition=null,c=b.editor.body.children().filter(function(a,c){return b.editor.util.isBlockNode(c)}),b.focused&&0===c.length&&(b.editor.selection.save(),b.editor.formatter.format(),b.editor.selection.restore()),b.editor.body.find("hr, pre, .simditor-table").each(function(c,d){var e,f;return e=a(d),(e.parent().is("blockquote")||e.parent()[0]===b.editor.body[0])&&(f=!1,0===e.next().length&&(a("<p/>").append(b.editor.util.phBr).insertAfter(e),f=!0),0===e.prev().length&&(a("<p/>").append(b.editor.util.phBr).insertBefore(e),f=!0),f)?b.throttledValueChanged():void 0}),b.editor.body.find("pre:empty").append(b.editor.util.phBr),!b.editor.util.support.onselectionchange&&b.focused?b.throttledSelectionChanged():void 0}}(this)),this.editor.body.on("keydown",a.proxy(this._onKeyDown,this)).on("keypress",a.proxy(this._onKeyPress,this)).on("keyup",a.proxy(this._onKeyUp,this)).on("mouseup",a.proxy(this._onMouseUp,this)).on("focus",a.proxy(this._onFocus,this)).on("blur",a.proxy(this._onBlur,this)).on("drop",a.proxy(this._onDrop,this)).on("input",a.proxy(this._onInput,this)),this.editor.util.browser.firefox&&(this.editor.hotkeys.add("cmd+left",function(a){return function(b){return b.preventDefault(),a.editor.selection._selection.modify("move","backward","lineboundary"),!1}}(this)),this.editor.hotkeys.add("cmd+right",function(a){return function(b){return b.preventDefault(),a.editor.selection._selection.modify("move","forward","lineboundary"),!1}}(this)),b=this.editor.util.os.mac?"cmd+a":"ctrl+a",this.editor.hotkeys.add(b,function(a){return function(b){var c,d,e,f;return c=a.editor.body.children(),c.length>0?(d=c.first().get(0),e=c.last().get(0),f=document.createRange(),f.setStart(d,0),f.setEnd(e,a.editor.util.getNodeLength(e)),a.editor.selection.range(f),!1):void 0}}(this))),c=this.editor.util.os.mac?"cmd+enter":"ctrl+enter",this.editor.hotkeys.add(c,function(a){return function(b){return a.editor.el.closest("form").find("button:submit").click(),!1}}(this))},c.prototype._onFocus=function(a){return this.editor.clipboard.pasting?void 0:(this.editor.el.addClass("focus").removeClass("error"),this.focused=!0,setTimeout(function(a){return function(){var b,c;return c=a.editor.selection._selection.getRangeAt(0),c.startContainer===a.editor.body[0]&&(a.lastCaretPosition?a.editor.undoManager.caretPosition(a.lastCaretPosition):(b=a.editor.body.children().first(),c=document.createRange(),a.editor.selection.setRangeAtStartOf(b,c))),a.lastCaretPosition=null,a.editor.triggerHandler("focus"),a.editor.util.support.onselectionchange?void 0:a.throttledSelectionChanged()}}(this),0))},c.prototype._onBlur=function(a){var b;if(!this.editor.clipboard.pasting)return this.editor.el.removeClass("focus"),this.editor.sync(),this.focused=!1,this.lastCaretPosition=null!=(b=this.editor.undoManager.currentState())?b.caret:void 0,this.editor.triggerHandler("blur")},c.prototype._onMouseUp=function(a){return this.editor.util.support.onselectionchange?void 0:this.throttledSelectionChanged()},c.prototype._onKeyDown=function(a){var b,c;if(this.editor.triggerHandler(a)===!1)return!1;if(!this.editor.hotkeys.respondTo(a)){if(this.editor.keystroke.respondTo(a))return this.throttledValueChanged(),!1;if(b=a.which,!(O.call(this._modifierKeys,b)>=0||(c=a.which,O.call(this._arrowKeys,c)>=0)||this.editor.util.metaKey(a)&&86===a.which))return this.editor.util.support.oninput||this.throttledValueChanged(["typing"]),null}},c.prototype._onKeyPress=function(a){return this.editor.triggerHandler(a)===!1?!1:void 0},c.prototype._onKeyUp=function(b){var c,d;return this.editor.triggerHandler(b)===!1?!1:!this.editor.util.support.onselectionchange&&(d=b.which,O.call(this._arrowKeys,d)>=0)?void this.throttledValueChanged():void(8!==b.which&&46!==b.which||!this.editor.util.isEmptyNode(this.editor.body)||(this.editor.body.empty(),c=a("<p/>").append(this.editor.util.phBr).appendTo(this.editor.body),this.editor.selection.setRangeAtStartOf(c)))},c.prototype._onDrop=function(a){return this.editor.triggerHandler(a)===!1?!1:this.throttledValueChanged()},c.prototype._onInput=function(a){return this.throttledValueChanged(["oninput"])},c}(b),v=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Keystroke",c.prototype._init=function(){return this.editor=this._module,this._keystrokeHandlers={},this._initKeystrokeHandlers()},c.prototype.add=function(a,b,c){return a=a.toLowerCase(),a=this.editor.hotkeys.constructor.aliases[a]||a,this._keystrokeHandlers[a]||(this._keystrokeHandlers[a]={}),this._keystrokeHandlers[a][b]=c},c.prototype.respondTo=function(b){var c,d,e,f;return(d=null!=(e=this.editor.hotkeys.constructor.keyNameMap[b.which])?e.toLowerCase():void 0)&&d in this._keystrokeHandlers&&(f="function"==typeof(c=this._keystrokeHandlers[d])["*"]?c["*"](b):void 0,f||this.editor.selection.startNodes().each(function(c){return function(e,g){var h,i;if(g.nodeType===Node.ELEMENT_NODE)return h=null!=(i=c._keystrokeHandlers[d])?i[g.tagName.toLowerCase()]:void 0,f="function"==typeof h?h(b,a(g)):void 0,f===!0||f===!1?!1:void 0}}(this)),f)?!0:void 0},c.prototype._initKeystrokeHandlers=function(){var b;return this.editor.util.browser.safari&&this.add("enter","*",function(b){return function(c){var d,e;if(c.shiftKey&&(d=b.editor.selection.blockNodes().last(),!d.is("pre")))return e=a("<br/>"),b.editor.selection.rangeAtEndOf(d)?(b.editor.selection.insertNode(e),b.editor.selection.insertNode(a("<br/>")),b.editor.selection.setRangeBefore(e)):b.editor.selection.insertNode(e),!0}}(this)),(this.editor.util.browser.webkit||this.editor.util.browser.msie)&&(b=function(b){return function(c,d){var e;if(b.editor.selection.rangeAtEndOf(d))return e=a("<p/>").append(b.editor.util.phBr).insertAfter(d),b.editor.selection.setRangeAtStartOf(e),!0}}(this),this.add("enter","h1",b),this.add("enter","h2",b),this.add("enter","h3",b),this.add("enter","h4",b),this.add("enter","h5",b),this.add("enter","h6",b)),this.add("backspace","*",function(a){return function(b){var c,d,e,f;return e=a.editor.selection.rootNodes().first(),d=e.prev(),d.is("hr")&&a.editor.selection.rangeAtStartOf(e)?(a.editor.selection.save(),d.remove(),a.editor.selection.restore(),!0):(c=a.editor.selection.blockNodes().last(),f=a.editor.util.browser.webkit,f&&a.editor.selection.rangeAtStartOf(c)?(a.editor.selection.save(),a.editor.formatter.cleanNode(c,!0),a.editor.selection.restore(),null):void 0)}}(this)),this.add("enter","li",function(b){return function(c,d){var e,f,g,h;if(e=d.clone(),e.find("ul, ol").remove(),b.editor.util.isEmptyNode(e)&&d.is(b.editor.selection.blockNodes().last())){if(f=d.parent(),d.next("li").length>0){if(!b.editor.util.isEmptyNode(d))return;f.parent("li").length>0?(g=a("<li/>").append(b.editor.util.phBr).insertAfter(f.parent("li")),h=a("<"+f[0].tagName+"/>").append(d.nextAll("li")),g.append(h)):(g=a("<p/>").append(b.editor.util.phBr).insertAfter(f),h=a("<"+f[0].tagName+"/>").append(d.nextAll("li")),g.after(h))}else f.parent("li").length>0?(g=a("<li/>").insertAfter(f.parent("li")),d.contents().length>0?g.append(d.contents()):g.append(b.editor.util.phBr)):(g=a("<p/>").append(b.editor.util.phBr).insertAfter(f),d.children("ul, ol").length>0&&g.after(d.children("ul, ol")));return d.prev("li").length?d.remove():f.remove(),b.editor.selection.setRangeAtStartOf(g),!0}}}(this)),this.add("enter","pre",function(b){return function(c,d){var e,f,g;return c.preventDefault(),c.shiftKey?(e=a("<p/>").append(b.editor.util.phBr).insertAfter(d),b.editor.selection.setRangeAtStartOf(e),!0):(g=b.editor.selection.range(),f=null,g.deleteContents(),!b.editor.util.browser.msie&&b.editor.selection.rangeAtEndOf(d)?(f=document.createTextNode("\n\n"),g.insertNode(f),g.setEnd(f,1)):(f=document.createTextNode("\n"),g.insertNode(f),g.setStartAfter(f)),g.collapse(!1),b.editor.selection.range(g),!0)}}(this)),this.add("enter","blockquote",function(a){return function(b,c){var d,e;return d=a.editor.selection.blockNodes().last(),d.is("p")&&!d.next().length&&a.editor.util.isEmptyNode(d)?(c.after(d),e=document.createRange(),a.editor.selection.setRangeAtStartOf(d,e),!0):void 0}}(this)),this.add("backspace","li",function(b){return function(c,d){var e,f,g,h,i,j,k,l,m;return f=d.children("ul, ol"),i=d.prev("li"),f.length>0&&i.length>0?(m="",j=null,d.contents().each(function(b,c){if(1===c.nodeType&&/UL|OL/.test(c.nodeName))return!1;if(1!==c.nodeType||!/BR/.test(c.nodeName))return 3===c.nodeType&&c.nodeValue?m+=c.nodeValue:1===c.nodeType&&(m+=a(c).text()),j=a(c)}),k=b.editor.util.browser.firefox&&!j.next("br").length,j&&1===m.length&&k?(e=a(b.editor.util.phBr).insertAfter(j),j.remove(),b.editor.selection.setRangeBefore(e),!0):m.length>0?!1:(l=document.createRange(),h=i.children("ul, ol"),h.length>0?(g=a("<li/>").append(b.editor.util.phBr).appendTo(h),h.append(f.children("li")),d.remove(),b.editor.selection.setRangeAtEndOf(g,l)):(b.editor.selection.setRangeAtEndOf(i,l),i.append(f),d.remove(),b.editor.selection.range(l)),!0)):!1}}(this)),this.add("backspace","pre",function(b){return function(c,d){var e,f,g;if(b.editor.selection.rangeAtStartOf(d))return f=d.html().replace("\n","<br/>")||b.editor.util.phBr,e=a("<p/>").append(f).insertAfter(d),d.remove(),g=document.createRange(),b.editor.selection.setRangeAtStartOf(e,g),!0}}(this)),this.add("backspace","blockquote",function(a){return function(b,c){var d,e;if(a.editor.selection.rangeAtStartOf(c))return d=c.children().first().unwrap(),e=document.createRange(),a.editor.selection.setRangeAtStartOf(d,e),!0}}(this))},c}(b),J=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="UndoManager",c.prototype._index=-1,c.prototype._capacity=20,c.prototype._startPosition=null,c.prototype._endPosition=null,c.prototype._init=function(){var a,b;return this.editor=this._module,this._stack=[],this.editor.util.os.mac?(b="cmd+z",a="shift+cmd+z"):this.editor.util.os.win?(b="ctrl+z",a="ctrl+y"):(b="ctrl+z",a="shift+ctrl+z"),this.editor.hotkeys.add(b,function(a){return function(b){return b.preventDefault(),a.undo(),!1}}(this)),this.editor.hotkeys.add(a,function(a){return function(b){return b.preventDefault(),a.redo(),!1}}(this)),this.throttledPushState=this.editor.util.throttle(function(a){return function(){return a._pushUndoState()}}(this),2e3),this.editor.on("valuechanged",function(a){return function(b,c){return"undo"!==c&&"redo"!==c?a.throttledPushState():void 0}}(this)),this.editor.on("selectionchanged",function(a){return function(b){return a.resetCaretPosition(),a.update()}}(this)),this.editor.on("focus",function(a){return function(b){return 0===a._stack.length?a._pushUndoState():void 0}}(this)),this.editor.on("blur",function(a){return function(b){return a.resetCaretPosition()}}(this))},c.prototype.resetCaretPosition=function(){return this._startPosition=null,this._endPosition=null},c.prototype.startPosition=function(){return this.editor.selection._range&&(this._startPosition||(this._startPosition=this._getPosition("start"))),this._startPosition},c.prototype.endPosition=function(){return this.editor.selection._range&&(this._endPosition||(this._endPosition=function(a){return function(){var b;return b=a.editor.selection.range(),b.collapsed?a._startPosition:a._getPosition("end")}}(this)())),this._endPosition},c.prototype._pushUndoState=function(){var a;if(this.editor.triggerHandler("pushundostate")!==!1&&(a=this.caretPosition(),a.start))return this._index+=1,this._stack.length=this._index,this._stack.push({html:this.editor.body.html(),caret:this.caretPosition()}),this._stack.length>this._capacity?(this._stack.shift(),this._index-=1):void 0},c.prototype.currentState=function(){return this._stack.length&&this._index>-1?this._stack[this._index]:null},c.prototype.undo=function(){var a;if(!(this._index<1||this._stack.length<2))return this.editor.hidePopover(),this._index-=1,a=this._stack[this._index],this.editor.body.get(0).innerHTML=a.html,this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["undo"])},c.prototype.redo=function(){var a;if(!(this._index<0||this._stack.length<this._index+2))return this.editor.hidePopover(),this._index+=1,a=this._stack[this._index],this.editor.body.get(0).innerHTML=a.html,this.caretPosition(a.caret),this.editor.body.find(".selected").removeClass("selected"),this.editor.sync(),this.editor.trigger("valuechanged",["redo"])},c.prototype.update=function(){var a;return(a=this.currentState())?(a.html=this.editor.body.html(),a.caret=this.caretPosition()):void 0},c.prototype._getNodeOffset=function(b,c){var d,e,f;return d=a.isNumeric(c)?a(b):a(b).parent(),f=0,e=!1,d.contents().each(function(a,d){return b===d||c===a&&0===a?!1:(d.nodeType===Node.TEXT_NODE?!e&&d.nodeValue.length>0&&(f+=1,e=!0):(f+=1,e=!1),c-1===a?!1:null)}),f},c.prototype._getPosition=function(b){var c,d,e,f,g,h,i;if(null==b&&(b="start"),i=this.editor.selection.range(),f=i[b+"Offset"],c=this.editor.selection[b+"Nodes"](),d=c.first()[0],d.nodeType===Node.TEXT_NODE){for(h=d.previousSibling;h&&h.nodeType===Node.TEXT_NODE;)d=h,f+=this.editor.util.getNodeLength(h),h=h.previousSibling;e=c.get(),e[0]=d,c=a(e)}else f=this._getNodeOffset(d,f);return g=[f],c.each(function(a){return function(b,c){return g.unshift(a._getNodeOffset(c))}}(this)),g},c.prototype._getNodeByPosition=function(b){var c,d,e,f,g,h,i,j;for(h=this.editor.body[0],j=b.slice(0,b.length-1),e=f=0,g=j.length;g>f;e=++f){if(i=j[e],d=h.childNodes,i>d.length-1){if(e!==b.length-2||!a(h).is("pre:empty")){h=null;break}c=document.createTextNode(""),h.appendChild(c),d=h.childNodes}h=d[i]}return h},c.prototype.caretPosition=function(a){var b,c,d,e,f;if(a){if(!a.start)return;return e=this._getNodeByPosition(a.start),f=a.start[a.start.length-1],a.collapsed?(b=e,c=f):(b=this._getNodeByPosition(a.end),c=a.start[a.start.length-1]),e&&b?(d=document.createRange(),d.setStart(e,f),d.setEnd(b,c),this.editor.selection.range(d)):void("undefined"!=typeof console&&null!==console&&"function"==typeof console.warn&&console.warn("simditor: invalid caret state"))}return d=this.editor.selection.range(),a=this.editor.inputManager.focused&&null!=d?{start:this.startPosition(),end:this.endPosition(),collapsed:d.collapsed}:{}},c}(b),L=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Util",c.prototype._init=function(){return this.editor=this._module,this.browser.msie&&this.browser.version<11?this.phBr="":void 0},c.prototype.phBr="<br/>",c.prototype.os=function(){var a;return a={},/Mac/.test(navigator.appVersion)?a.mac=!0:/Linux/.test(navigator.appVersion)?a.linux=!0:/Win/.test(navigator.appVersion)?a.win=!0:/X11/.test(navigator.appVersion)&&(a.unix=!0),/Mobi/.test(navigator.appVersion)&&(a.mobile=!0),a}(),c.prototype.browser=function(){var a,b,c,d,e,f,g,h,i,j,k;return k=navigator.userAgent,d=/(msie|trident)/i.test(k),a=/chrome|crios/i.test(k),j=/safari/i.test(k)&&!a,c=/firefox/i.test(k),b=/edge/i.test(k),d?{msie:!0,version:1*(null!=(e=k.match(/(msie |rv:)(\d+(\.\d+)?)/i))?e[2]:void 0)}:b?{edge:!0,webkit:!0,version:1*(null!=(f=k.match(/edge\/(\d+(\.\d+)?)/i))?f[1]:void 0)}:a?{webkit:!0,chrome:!0,version:1*(null!=(g=k.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i))?g[1]:void 0)}:j?{webkit:!0,safari:!0,version:1*(null!=(h=k.match(/version\/(\d+(\.\d+)?)/i))?h[1]:void 0)}:c?{mozilla:!0,firefox:!0,version:1*(null!=(i=k.match(/firefox\/(\d+(\.\d+)?)/i))?i[1]:void 0)}:{}}(),c.prototype.support=function(){return{onselectionchange:function(){var a,b;if(b=document.onselectionchange,void 0!==b)try{return document.onselectionchange=0,null===document.onselectionchange}catch(c){a=c}finally{document.onselectionchange=b}return!1}(),oninput:function(){return!/(msie|trident)/i.test(navigator.userAgent)}()}}(),c.prototype.reflow=function(b){return null==b&&(b=document),a(b)[0].offsetHeight},c.prototype.metaKey=function(a){var b;return b=/Mac/.test(navigator.userAgent),b?a.metaKey:a.ctrlKey},c.prototype.isEmptyNode=function(b){var c;return c=a(b),c.is(":empty")||!c.text()&&!c.find(":not(br, span, div)").length},c.prototype.isDecoratedNode=function(b){return a(b).is('[class^="simditor-"]')},c.prototype.blockNodes=["div","p","ul","ol","li","blockquote","hr","pre","h1","h2","h3","h4","h5","table"],c.prototype.isBlockNode=function(b){return b=a(b)[0],b&&3!==b.nodeType?new RegExp("^("+this.blockNodes.join("|")+")$").test(b.nodeName.toLowerCase()):!1},c.prototype.getNodeLength=function(b){switch(b=a(b)[0],b.nodeType){case 7:case 10:return 0;case 3:case 8:return b.length;default:return b.childNodes.length}},c.prototype.dataURLtoBlob=function(a){var b,c,d,e,f,g,h,i,j,k,l,m,n;if(h=window.Blob&&function(){var a;try{return Boolean(new Blob)}catch(b){return a=b,!1}}(),g=h&&window.Uint8Array&&function(){var a;try{return 100===new Blob([new Uint8Array(100)]).size}catch(b){return a=b,!1}}(),b=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder,n=h||b,!(n&&window.atob&&window.ArrayBuffer&&window.Uint8Array))return!1;for(f=a.split(",")[0].indexOf("base64")>=0?atob(a.split(",")[1]):decodeURIComponent(a.split(",")[1]),c=new ArrayBuffer(f.length),j=new Uint8Array(c),i=k=0,m=f.length;m>=0?m>=k:k>=m;i=m>=0?++k:--k)j[i]=f.charCodeAt(i);return l=a.split(",")[0].split(":")[1].split(";")[0],h?(e=g?j:c,new Blob([e],{type:l})):(d=new b,d.append(c),d.getBlob(l))},c.prototype.throttle=function(a,b){var c,d,e,f,g,h,i;return f=0,i=0,e=c=g=null,d=function(){return i=0,f=+new Date,g=a.apply(e,c),e=null,c=null},h=function(){var a;return e=this,c=arguments,a=new Date-f,i||(a>=b?d():i=setTimeout(d,b-a)),g},h.clear=function(){return i?(clearTimeout(i),d()):void 0},h},c.prototype.formatHTML=function(b){var c,d,e,f,g,h,i,j,k;for(h=/<(\/?)(.+?)(\/?)>/g,j="",f=0,e=null,d=" ",i=function(a,b){return new Array(b+1).join(a)};null!==(g=h.exec(b));)g.isBlockNode=a.inArray(g[2],this.blockNodes)>-1,g.isStartTag="/"!==g[1]&&"/"!==g[3],g.isEndTag="/"===g[1]||"/"===g[3],c=e?e.index+e[0].length:0,(k=b.substring(c,g.index)).length>0&&a.trim(k)&&(j+=k),g.isBlockNode&&g.isEndTag&&!g.isStartTag&&(f-=1),g.isBlockNode&&g.isStartTag&&(e&&e.isBlockNode&&e.isEndTag||(j+="\n"),j+=i(d,f)),j+=g[0],g.isBlockNode&&g.isEndTag&&(j+="\n"),g.isBlockNode&&g.isStartTag&&(f+=1),e=g;return a.trim(j)},c}(b),H=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Toolbar",c.prototype.opts={toolbar:!0,toolbarFloat:!0,
|
|
23
|
+toolbarHidden:!1,toolbarFloatOffset:0},c.prototype._tpl={wrapper:'<div class="simditor-toolbar"><ul></ul></div>',separator:'<li><span class="separator"></span></li>'},c.prototype._init=function(){var b,c,d;return this.editor=this._module,this.opts.toolbar?(a.isArray(this.opts.toolbar)||(this.opts.toolbar=["bold","italic","underline","strikethrough","|","ol","ul","blockquote","code","|","link","image","|","indent","outdent"]),this._render(),this.list.on("click",function(a){return!1}),this.wrapper.on("mousedown",function(a){return function(b){return a.list.find(".menu-on").removeClass(".menu-on")}}(this)),a(document).on("mousedown.simditor"+this.editor.id,function(a){return function(b){return a.list.find(".menu-on").removeClass(".menu-on")}}(this)),!this.opts.toolbarHidden&&this.opts.toolbarFloat&&(this.wrapper.css("top",this.opts.toolbarFloatOffset),d=0,c=function(a){return function(){return a.wrapper.css("position","static"),a.wrapper.width("auto"),a.editor.util.reflow(a.wrapper),a.wrapper.width(a.wrapper.outerWidth()),a.wrapper.css("left",a.editor.util.os.mobile?a.wrapper.position().left:a.wrapper.offset().left),a.wrapper.css("position",""),d=a.wrapper.outerHeight(),a.editor.placeholderEl.css("top",d),!0}}(this),b=null,a(window).on("resize.simditor-"+this.editor.id,function(a){return b=c()}),a(window).on("scroll.simditor-"+this.editor.id,function(e){return function(f){var g,h,i;if(e.wrapper.is(":visible"))if(i=e.editor.wrapper.offset().top,g=i+e.editor.wrapper.outerHeight()-80,h=a(document).scrollTop()+e.opts.toolbarFloatOffset,i>=h||h>=g){if(e.editor.wrapper.removeClass("toolbar-floating").css("padding-top",""),e.editor.util.os.mobile)return e.wrapper.css("top",e.opts.toolbarFloatOffset)}else if(b||(b=c()),e.editor.wrapper.addClass("toolbar-floating").css("padding-top",d),e.editor.util.os.mobile)return e.wrapper.css("top",h-i+e.opts.toolbarFloatOffset)}}(this))),this.editor.on("destroy",function(a){return function(){return a.buttons.length=0}}(this)),a(document).on("mousedown.simditor-"+this.editor.id,function(a){return function(b){return a.list.find("li.menu-on").removeClass("menu-on")}}(this))):void 0},c.prototype._render=function(){var b,c,d,e;for(this.buttons=[],this.wrapper=a(this._tpl.wrapper).prependTo(this.editor.wrapper),this.list=this.wrapper.find("ul"),e=this.opts.toolbar,b=0,c=e.length;c>b;b++)if(d=e[b],"|"!==d){if(!this.constructor.buttons[d])throw new Error("simditor: invalid toolbar button "+d);this.buttons.push(new this.constructor.buttons[d]({editor:this.editor}))}else a(this._tpl.separator).appendTo(this.list);return this.opts.toolbarHidden?this.wrapper.hide():void 0},c.prototype.findButton=function(a){var b;return b=this.list.find(".toolbar-item-"+a).data("button"),null!=b?b:null},c.addButton=function(a){return this.buttons[a.prototype.name]=a},c.buttons={},c}(b),s=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Indentation",c.prototype.opts={tabIndent:!0},c.prototype._init=function(){return this.editor=this._module,this.editor.keystroke.add("tab","*",function(a){return function(b){var c;return c=a.editor.toolbar.findButton("code"),a.opts.tabIndent||c&&c.active?a.indent(b.shiftKey):void 0}}(this))},c.prototype.indent=function(b){var c,d,e,f,g;return e=this.editor.selection.startNodes(),d=this.editor.selection.endNodes(),c=this.editor.selection.blockNodes(),f=[],c=c.each(function(b,c){var d,e,g,h,i;for(d=!0,e=g=0,h=f.length;h>g;e=++g){if(i=f[e],a.contains(c,i)){d=!1;break}if(a.contains(i,c)){f.splice(e,1,c),d=!1;break}}return d?f.push(c):void 0}),c=a(f),g=!1,c.each(function(a){return function(c,d){var e;return e=b?a.outdentBlock(d):a.indentBlock(d),e?g=e:void 0}}(this)),g},c.prototype.indentBlock=function(b){var c,d,e,f,g,h,i,j,k,l;if(c=a(b),c.length){if(c.is("pre")){if(h=this.editor.selection.containerNode(),!h.is(c)&&!h.closest("pre").is(c))return;this.indentText(this.editor.selection.range())}else if(c.is("li")){if(g=c.prev("li"),g.length<1)return;this.editor.selection.save(),l=c.parent()[0].tagName,d=g.children("ul, ol"),d.length>0?d.append(c):a("<"+l+"/>").append(c).appendTo(g),this.editor.selection.restore()}else if(c.is("p, h1, h2, h3, h4"))k=parseInt(c.css("margin-left"))||0,k=(Math.round(k/this.opts.indentWidth)+1)*this.opts.indentWidth,c.css("margin-left",k);else{if(!c.is("table")&&!c.is(".simditor-table"))return!1;if(i=this.editor.selection.containerNode().closest("td, th"),e=i.next("td, th"),e.length>0||(j=i.parent("tr"),f=j.next("tr"),f.length<1&&j.parent().is("thead")&&(f=j.parent("thead").next("tbody").find("tr:first")),e=f.find("td:first, th:first")),!(i.length>0&&e.length>0))return;this.editor.selection.setRangeAtEndOf(e)}return!0}},c.prototype.indentText=function(a){var b,c;return b=a.toString().replace(/^(?=.+)/gm," "),c=document.createTextNode(b||" "),a.deleteContents(),a.insertNode(c),b?(a.selectNode(c),this.editor.selection.range(a)):this.editor.selection.setRangeAfter(c)},c.prototype.outdentBlock=function(b){var c,d,e,f,g,h,i,j,k,l;if(c=a(b),c&&c.length>0){if(c.is("pre")){if(f=this.editor.selection.containerNode(),!f.is(c)&&!f.closest("pre").is(c))return;this.outdentText(l)}else if(c.is("li"))d=c.parent(),e=d.parent("li"),this.editor.selection.save(),e.length<1?(l=document.createRange(),l.setStartBefore(d[0]),l.setEndBefore(c[0]),d.before(l.extractContents()),a("<p/>").insertBefore(d).after(c.children("ul, ol")).append(c.contents()),c.remove()):(c.next("li").length>0&&a("<"+d[0].tagName+"/>").append(c.nextAll("li")).appendTo(c),c.insertAfter(e),d.children("li").length<1&&d.remove()),this.editor.selection.restore();else if(c.is("p, h1, h2, h3, h4"))k=parseInt(c.css("margin-left"))||0,k=Math.max(Math.round(k/this.opts.indentWidth)-1,0)*this.opts.indentWidth,c.css("margin-left",0===k?"":k);else{if(!c.is("table")&&!c.is(".simditor-table"))return!1;if(i=this.editor.selection.containerNode().closest("td, th"),g=i.prev("td, th"),g.length>0||(j=i.parent("tr"),h=j.prev("tr"),h.length<1&&j.parent().is("tbody")&&(h=j.parent("tbody").prev("thead").find("tr:first")),g=h.find("td:last, th:last")),!(i.length>0&&g.length>0))return;this.editor.selection.setRangeAtEndOf(g)}return!0}},c.prototype.outdentText=function(a){},c}(b),i=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.pluginName="Clipboard",c.prototype.opts={pasteImage:!1,cleanPaste:!1},c.prototype._init=function(){return this.editor=this._module,this.opts.pasteImage&&"string"!=typeof this.opts.pasteImage&&(this.opts.pasteImage="inline"),this.editor.body.on("paste",function(a){return function(b){var c;if(!a.pasting&&!a._pasteBin)return a.editor.triggerHandler(b)===!1?!1:(c=a.editor.selection.deleteRangeContents(),a.editor.body.html()?c.collapsed||c.collapse(!0):(a.editor.formatter.format(),a.editor.selection.setRangeAtStartOf(a.editor.body.find("p:first"))),a._processPasteByClipboardApi(b)?!1:(a.editor.inputManager.throttledValueChanged.clear(),a.editor.inputManager.throttledSelectionChanged.clear(),a.editor.undoManager.throttledPushState.clear(),a.editor.selection.reset(),a.editor.undoManager.resetCaretPosition(),a.pasting=!0,a._getPasteContent(function(b){return a._processPasteContent(b),a._pasteInBlockEl=null,a._pastePlainText=null,a.pasting=!1})))}}(this))},c.prototype._processPasteByClipboardApi=function(a){var b,c,d,e;if(!this.editor.util.browser.edge&&a.originalEvent.clipboardData&&a.originalEvent.clipboardData.items&&a.originalEvent.clipboardData.items.length>0&&(c=a.originalEvent.clipboardData.items[0],/^image\//.test(c.type))){if(b=c.getAsFile(),null==b||!this.opts.pasteImage)return;if(b.name||(b.name="Clipboard Image.png"),this.editor.triggerHandler("pasting",[b])===!1)return;return e={},e[this.opts.pasteImage]=!0,null!=(d=this.editor.uploader)&&d.upload(b,e),!0}},c.prototype._getPasteContent=function(b){var c;return this._pasteBin=a('<div contenteditable="true" />').addClass("simditor-paste-bin").attr("tabIndex","-1").appendTo(this.editor.el),c={html:this.editor.body.html(),caret:this.editor.undoManager.caretPosition()},this._pasteBin.focus(),setTimeout(function(d){return function(){var e;return d.editor.hidePopover(),d.editor.body.get(0).innerHTML=c.html,d.editor.undoManager.caretPosition(c.caret),d.editor.body.focus(),d.editor.selection.reset(),d.editor.selection.range(),d._pasteInBlockEl=d.editor.selection.blockNodes().last(),d._pastePlainText=d.opts.cleanPaste||d._pasteInBlockEl.is("pre, table"),d._pastePlainText?e=d.editor.formatter.clearHtml(d._pasteBin.html(),!0):(e=a("<div/>").append(d._pasteBin.contents()),e.find("table colgroup").remove(),d.editor.formatter.format(e),d.editor.formatter.decorate(e),d.editor.formatter.beautify(e.children()),e=e.contents()),d._pasteBin.remove(),d._pasteBin=null,b(e)}}(this),0)},c.prototype._processPasteContent=function(b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y;if(this.editor.triggerHandler("pasting",[b])!==!1&&(c=this._pasteInBlockEl,b)){if(this._pastePlainText)if(c.is("table")){for(q=b.split("\n"),j=q.pop(),h=0,k=q.length;k>h;h++)p=q[h],this.editor.selection.insertNode(document.createTextNode(p)),this.editor.selection.insertNode(a("<br/>"));this.editor.selection.insertNode(document.createTextNode(j))}else for(b=a("<div/>").text(b),v=b.contents(),i=0,l=v.length;l>i;i++)s=v[i],this.editor.selection.insertNode(a(s)[0]);else if(c.is(this.editor.body))for(r=0,m=b.length;m>r;r++)s=b[r],this.editor.selection.insertNode(s);else{if(b.length<1)return;if(1===b.length)if(b.is("p")){if(f=b.contents(),1===f.length&&f.is("img")){if(d=f,/^data:image/.test(d.attr("src"))){if(!this.opts.pasteImage)return;return e=this.editor.util.dataURLtoBlob(d.attr("src")),e.name="Clipboard Image.png",y={},y[this.opts.pasteImage]=!0,void(null!=(w=this.editor.uploader)&&w.upload(e,y))}if(d.is('img[src^="webkit-fake-url://"]'))return}for(t=0,n=f.length;n>t;t++)s=f[t],this.editor.selection.insertNode(s)}else if(c.is("p")&&this.editor.util.isEmptyNode(c))c.replaceWith(b),this.editor.selection.setRangeAtEndOf(b);else if(b.is("ul, ol"))if(1===b.find("li").length)for(b=a("<div/>").text(b.text()),x=b.contents(),u=0,o=x.length;o>u;u++)s=x[u],this.editor.selection.insertNode(a(s)[0]);else c.is("li")?(c.parent().after(b),this.editor.selection.setRangeAtEndOf(b)):(c.after(b),this.editor.selection.setRangeAtEndOf(b));else c.after(b),this.editor.selection.setRangeAtEndOf(b);else c.is("li")&&(c=c.parent()),this.editor.selection.rangeAtStartOf(c)?g="before":this.editor.selection.rangeAtEndOf(c)?g="after":(this.editor.selection.breakBlockEl(c),g="before"),c[g](b),this.editor.selection.setRangeAtEndOf(b.last())}return this.editor.inputManager.throttledValueChanged()}},c}(b),D=function(b){function e(){return e.__super__.constructor.apply(this,arguments)}return M(e,b),e.connect(L),e.connect(t),e.connect(C),e.connect(J),e.connect(v),e.connect(n),e.connect(H),e.connect(s),e.connect(i),e.count=0,e.prototype.opts={textarea:null,placeholder:"",defaultImage:"images/image.png",params:{},upload:!1,indentWidth:40},e.prototype._init=function(){var b,f,g,h;if(this.textarea=a(this.opts.textarea),this.opts.placeholder=this.opts.placeholder||this.textarea.attr("placeholder"),!this.textarea.length)throw new Error("simditor: param textarea is required.");if(f=this.textarea.data("simditor"),null!=f&&f.destroy(),this.id=++e.count,this._render(),!c)throw new Error("simditor: simple-hotkeys is required.");if(this.hotkeys=c({el:this.body}),this.opts.upload&&d&&(h="object"==typeof this.opts.upload?this.opts.upload:{},this.uploader=d(h)),g=this.textarea.closest("form"),g.length&&(g.on("submit.simditor-"+this.id,function(a){return function(){return a.sync()}}(this)),g.on("reset.simditor-"+this.id,function(a){return function(){return a.setValue("")}}(this))),this.on("initialized",function(a){return function(){return a.opts.placeholder&&a.on("valuechanged",function(){return a._placeholder()}),a.setValue(a.textarea.val().trim()||""),a.textarea.attr("autofocus")?a.focus():void 0}}(this)),this.util.browser.mozilla){this.util.reflow();try{return document.execCommand("enableObjectResizing",!1,!1),document.execCommand("enableInlineTableEditing",!1,!1)}catch(i){b=i}}},e.prototype._tpl='<div class="simditor">\n <div class="simditor-wrapper">\n <div class="simditor-placeholder"></div>\n <div class="simditor-body" contenteditable="true">\n </div>\n </div>\n</div>',e.prototype._render=function(){var b,c,d,e;if(this.el=a(this._tpl).insertBefore(this.textarea),this.wrapper=this.el.find(".simditor-wrapper"),this.body=this.wrapper.find(".simditor-body"),this.placeholderEl=this.wrapper.find(".simditor-placeholder").append(this.opts.placeholder),this.el.data("simditor",this),this.wrapper.append(this.textarea),this.textarea.data("simditor",this).blur(),this.body.attr("tabindex",this.textarea.attr("tabindex")),this.util.os.mac?this.el.addClass("simditor-mac"):this.util.os.linux&&this.el.addClass("simditor-linux"),this.util.os.mobile&&this.el.addClass("simditor-mobile"),this.opts.params){c=this.opts.params,d=[];for(b in c)e=c[b],d.push(a("<input/>",{type:"hidden",name:b,value:e}).insertAfter(this.textarea));return d}},e.prototype._placeholder=function(){var a;return a=this.body.children(),0===a.length||1===a.length&&this.util.isEmptyNode(a)&&parseInt(a.css("margin-left")||0)<this.opts.indentWidth?this.placeholderEl.show():this.placeholderEl.hide()},e.prototype.setValue=function(a){return this.hidePopover(),this.textarea.val(a),this.body.get(0).innerHTML=a,this.formatter.format(),this.formatter.decorate(),this.util.reflow(this.body),this.inputManager.lastCaretPosition=null,this.trigger("valuechanged")},e.prototype.getValue=function(){return this.sync()},e.prototype.sync=function(){var b,c,d,e,f,g;for(c=this.body.clone(),this.formatter.undecorate(c),this.formatter.format(c),this.formatter.autolink(c),b=c.children(),f=b.last("p"),e=b.first("p");f.is("p")&&this.util.isEmptyNode(f);)d=f,f=f.prev("p"),d.remove();for(;e.is("p")&&this.util.isEmptyNode(e);)d=e,e=f.next("p"),d.remove();return c.find("img.uploading").remove(),g=a.trim(c.html()),this.textarea.val(g),g},e.prototype.focus=function(){var b,c;return this.body.is(":visible")&&this.body.is("[contenteditable]")?this.inputManager.lastCaretPosition?(this.undoManager.caretPosition(this.inputManager.lastCaretPosition),this.inputManager.lastCaretPosition=null):(b=this.body.children().last(),b.is("p")||(b=a("<p/>").append(this.util.phBr).appendTo(this.body)),c=document.createRange(),this.selection.setRangeAtEndOf(b,c)):void this.el.find("textarea:visible").focus()},e.prototype.blur=function(){return this.body.is(":visible")&&this.body.is("[contenteditable]")?this.body.blur():this.body.find("textarea:visible").blur()},e.prototype.hidePopover=function(){return this.el.find(".simditor-popover").each(function(b,c){return c=a(c).data("popover"),c.active?c.hide():void 0})},e.prototype.destroy=function(){return this.triggerHandler("destroy"),this.textarea.closest("form").off(".simditor .simditor-"+this.id),this.selection.clear(),this.inputManager.focused=!1,this.textarea.insertBefore(this.el).hide().val("").removeData("simditor"),this.el.remove(),a(document).off(".simditor-"+this.id),a(window).off(".simditor-"+this.id),this.off()},e}(b),D.i18n={"zh-CN":{blockquote:"引用",bold:"加粗文字",code:"插入代码",color:"文字颜色",coloredText:"彩色文字",hr:"分隔线",image:"插入图片",externalImage:"外链图片",uploadImage:"上传图片",uploadFailed:"上传失败了",uploadError:"上传出错了",imageUrl:"图片地址",imageSize:"图片尺寸",imageAlt:"图片描述",restoreImageSize:"还原图片尺寸",uploading:"正在上传",indent:"向右缩进",outdent:"向左缩进",italic:"斜体文字",link:"插入链接",linkText:"链接文字",linkUrl:"链接地址",linkTarget:"打开方式",openLinkInCurrentWindow:"在新窗口中打开",openLinkInNewWindow:"在当前窗口中打开",removeLink:"移除链接",ol:"有序列表",ul:"无序列表",strikethrough:"删除线文字",table:"表格",deleteRow:"删除行",insertRowAbove:"在上面插入行",insertRowBelow:"在下面插入行",deleteColumn:"删除列",insertColumnLeft:"在左边插入列",insertColumnRight:"在右边插入列",deleteTable:"删除表格",title:"标题",normalText:"普通文本",underline:"下划线文字",alignment:"水平对齐",alignCenter:"居中",alignLeft:"居左",alignRight:"居右",selectLanguage:"选择程序语言",fontScale:"字体大小",fontScaleXLarge:"超大字体",fontScaleLarge:"大号字体",fontScaleNormal:"正常大小",fontScaleSmall:"小号字体",fontScaleXSmall:"超小字体"},"en-US":{blockquote:"Block Quote",bold:"Bold",code:"Code",color:"Text Color",coloredText:"Colored Text",hr:"Horizontal Line",image:"Insert Image",externalImage:"External Image",uploadImage:"Upload Image",uploadFailed:"Upload failed",uploadError:"Error occurs during upload",imageUrl:"Url",imageSize:"Size",imageAlt:"Alt",restoreImageSize:"Restore Origin Size",uploading:"Uploading",indent:"Indent",outdent:"Outdent",italic:"Italic",link:"Insert Link",linkText:"Text",linkUrl:"Url",linkTarget:"Target",openLinkInCurrentWindow:"Open link in current window",openLinkInNewWindow:"Open link in new window",removeLink:"Remove Link",ol:"Ordered List",ul:"Unordered List",strikethrough:"Strikethrough",table:"Table",deleteRow:"Delete Row",insertRowAbove:"Insert Row Above",insertRowBelow:"Insert Row Below",deleteColumn:"Delete Column",insertColumnLeft:"Insert Column Left",insertColumnRight:"Insert Column Right",deleteTable:"Delete Table",title:"Title",normalText:"Text",underline:"Underline",alignment:"Alignment",alignCenter:"Align Center",alignLeft:"Align Left",alignRight:"Align Right",selectLanguage:"Select Language",fontScale:"Font Size",fontScaleXLarge:"X Large Size",fontScaleLarge:"Large Size",fontScaleNormal:"Normal Size",fontScaleSmall:"Small Size",fontScaleXSmall:"X Small Size"}},h=function(b){function c(a){this.editor=a.editor,this.title=this._t(this.name),c.__super__.constructor.call(this,a)}return M(c,b),c.prototype._tpl={item:'<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',menuWrapper:'<div class="toolbar-menu"></div>',menuItem:'<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',separator:'<li><span class="separator"></span></li>'},c.prototype.name="",c.prototype.icon="",c.prototype.title="",c.prototype.text="",c.prototype.htmlTag="",c.prototype.disableTag="",c.prototype.menu=!1,c.prototype.active=!1,c.prototype.disabled=!1,c.prototype.needFocus=!0,c.prototype.shortcut=null,c.prototype._init=function(){var b,c,d,e;for(this.render(),this.el.on("mousedown",function(a){return function(b){var c,d,e;return b.preventDefault(),d=a.needFocus&&!a.editor.inputManager.focused,a.el.hasClass("disabled")||d?!1:a.menu?(a.wrapper.toggleClass("menu-on").siblings("li").removeClass("menu-on"),a.wrapper.is(".menu-on")&&(c=a.menuWrapper.offset().left+a.menuWrapper.outerWidth()+5-a.editor.wrapper.offset().left-a.editor.wrapper.outerWidth(),c>0&&a.menuWrapper.css({left:"auto",right:0}),a.trigger("menuexpand")),!1):(e=a.el.data("param"),a.command(e),!1)}}(this)),this.wrapper.on("click","a.menu-item",function(b){return function(c){var d,e,f;return c.preventDefault(),d=a(c.currentTarget),b.wrapper.removeClass("menu-on"),e=b.needFocus&&!b.editor.inputManager.focused,d.hasClass("disabled")||e?!1:(b.editor.toolbar.wrapper.removeClass("menu-on"),f=d.data("param"),b.command(f),!1)}}(this)),this.wrapper.on("mousedown","a.menu-item",function(a){return!1}),this.editor.on("blur",function(a){return function(){var b;return b=a.editor.body.is(":visible")&&a.editor.body.is("[contenteditable]"),b&&!a.editor.clipboard.pasting?(a.setActive(!1),a.setDisabled(!1)):void 0}}(this)),null!=this.shortcut&&this.editor.hotkeys.add(this.shortcut,function(a){return function(b){return a.el.mousedown(),!1}}(this)),d=this.htmlTag.split(","),b=0,c=d.length;c>b;b++)e=d[b],e=a.trim(e),e&&a.inArray(e,this.editor.formatter._allowedTags)<0&&this.editor.formatter._allowedTags.push(e);return this.editor.on("selectionchanged",function(a){return function(b){return a.editor.inputManager.focused?a._status():void 0}}(this))},c.prototype.iconClassOf=function(a){return a?"simditor-icon simditor-icon-"+a:""},c.prototype.setIcon=function(a){return this.el.find("span").removeClass().addClass(this.iconClassOf(a)).text(this.text)},c.prototype.render=function(){return this.wrapper=a(this._tpl.item).appendTo(this.editor.toolbar.list),this.el=this.wrapper.find("a.toolbar-item"),this.el.attr("title",this.title).addClass("toolbar-item-"+this.name).data("button",this),this.setIcon(this.icon),this.menu?(this.menuWrapper=a(this._tpl.menuWrapper).appendTo(this.wrapper),this.menuWrapper.addClass("toolbar-menu-"+this.name),this.renderMenu()):void 0},c.prototype.renderMenu=function(){var b,c,d,e,f,g,h,i;if(a.isArray(this.menu)){for(this.menuEl=a("<ul/>").appendTo(this.menuWrapper),g=this.menu,i=[],d=0,e=g.length;e>d;d++)f=g[d],"|"!==f?(c=a(this._tpl.menuItem).appendTo(this.menuEl),b=c.find("a.menu-item").attr({title:null!=(h=f.title)?h:f.text,"data-param":f.param}).addClass("menu-item-"+f.name),f.icon?i.push(b.find("span").addClass(this.iconClassOf(f.icon))):i.push(b.find("span").text(f.text))):a(this._tpl.separator).appendTo(this.menuEl);return i}},c.prototype.setActive=function(a){return a!==this.active?(this.active=a,this.el.toggleClass("active",this.active)):void 0},c.prototype.setDisabled=function(a){return a!==this.disabled?(this.disabled=a,this.el.toggleClass("disabled",this.disabled)):void 0},c.prototype._disableStatus=function(){var a,b,c;return c=this.editor.selection.startNodes(),b=this.editor.selection.endNodes(),a=c.filter(this.disableTag).length>0||b.filter(this.disableTag).length>0,this.setDisabled(a),this.disabled&&this.setActive(!1),this.disabled},c.prototype._activeStatus=function(){var a,b,c,d,e;return e=this.editor.selection.startNodes(),c=this.editor.selection.endNodes(),d=e.filter(this.htmlTag),b=c.filter(this.htmlTag),a=d.length>0&&b.length>0&&d.is(b),this.node=a?d:null,this.setActive(a),this.active},c.prototype._status=function(){return this._disableStatus(),this.disabled?void 0:this._activeStatus()},c.prototype.command=function(a){},c.prototype._t=function(){var a,b,d;return a=1<=arguments.length?P.call(arguments,0):[],d=c.__super__._t.apply(this,a),d||(d=(b=this.editor)._t.apply(b,a)),d},c}(b),D.Button=h,B=function(b){function c(a){this.button=a.button,this.editor=a.button.editor,c.__super__.constructor.call(this,a)}return M(c,b),c.prototype.offset={top:4,left:0},c.prototype.target=null,c.prototype.active=!1,c.prototype._init=function(){return this.el=a('<div class="simditor-popover"></div>').appendTo(this.editor.el).data("popover",this),this.render(),this.el.on("mouseenter",function(a){return function(b){return a.el.addClass("hover")}}(this)),this.el.on("mouseleave",function(a){return function(b){return a.el.removeClass("hover")}}(this))},c.prototype.render=function(){},c.prototype._initLabelWidth=function(){var b;return b=this.el.find(".settings-field"),b.length>0?(this._labelWidth=0,b.each(function(b){return function(c,d){var e,f;return e=a(d),f=e.find("label"),f.length>0?b._labelWidth=Math.max(b._labelWidth,f.width()):void 0}}(this)),b.find("label").width(this._labelWidth)):void 0},c.prototype.show=function(b,c){return null==c&&(c="bottom"),null!=b?(this.el.siblings(".simditor-popover").each(function(b,c){return c=a(c).data("popover"),c.active?c.hide():void 0}),this.active&&this.target&&this.target.removeClass("selected"),this.target=b.addClass("selected"),this.active?(this.refresh(c),this.trigger("popovershow")):(this.active=!0,this.el.css({left:-9999}).show(),this._labelWidth||this._initLabelWidth(),this.editor.util.reflow(),this.refresh(c),this.trigger("popovershow"))):void 0},c.prototype.hide=function(){return this.active?(this.target&&this.target.removeClass("selected"),this.target=null,this.active=!1,this.el.hide(),this.trigger("popoverhide")):void 0},c.prototype.refresh=function(a){var b,c,d,e,f,g;return null==a&&(a="bottom"),this.active?(b=this.editor.el.offset(),f=this.target.offset(),e=this.target.outerHeight(),"bottom"===a?g=f.top-b.top+e:"top"===a&&(g=f.top-b.top-this.el.height()),d=this.editor.wrapper.width()-this.el.outerWidth()-10,c=Math.min(f.left-b.left,d),this.el.css({top:g+this.offset.top,left:c+this.offset.left})):void 0},c.prototype.destroy=function(){return this.target=null,this.active=!1,this.editor.off(".linkpopover"),this.el.remove()},c.prototype._t=function(){var a,b,d;return a=1<=arguments.length?P.call(arguments,0):[],d=c.__super__._t.apply(this,a),d||(d=(b=this.button)._t.apply(b,a)),d},c}(b),D.Popover=B,G=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="title",c.prototype.htmlTag="h1, h2, h3, h4, h5",c.prototype.disableTag="pre, table",c.prototype._init=function(){return this.menu=[{name:"normal",text:this._t("normalText"),param:"p"},"|",{name:"h1",text:this._t("title")+" 1",param:"h1"},{name:"h2",text:this._t("title")+" 2",param:"h2"},{name:"h3",text:this._t("title")+" 3",param:"h3"},{name:"h4",text:this._t("title")+" 4",param:"h4"},{name:"h5",text:this._t("title")+" 5",param:"h5"}],c.__super__._init.call(this)},c.prototype.setActive=function(a,b){return c.__super__.setActive.call(this,a),a&&(b||(b=this.node[0].tagName.toLowerCase())),this.el.removeClass("active-p active-h1 active-h2 active-h3 active-h4 active-h5"),a?this.el.addClass("active active-"+b):void 0},c.prototype.command=function(b){var c;return c=this.editor.selection.rootNodes(),this.editor.selection.save(),c.each(function(c){return function(d,e){var f;return f=a(e),f.is("blockquote")||f.is(b)||f.is(c.disableTag)||c.editor.util.isDecoratedNode(f)?void 0:a("<"+b+"/>").append(f.contents()).replaceAll(f)}}(this)),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(G),m=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="fontScale",c.prototype.icon="font",c.prototype.disableTag="pre",c.prototype.htmlTag="span",c.prototype.sizeMap={"x-large":"1.5em",large:"1.25em",small:".75em","x-small":".5em"},c.prototype._init=function(){return this.menu=[{name:"150%",text:this._t("fontScaleXLarge"),param:"5"},{name:"125%",text:this._t("fontScaleLarge"),param:"4"},{name:"100%",text:this._t("fontScaleNormal"),param:"3"},{name:"75%",text:this._t("fontScaleSmall"),param:"2"},{name:"50%",text:this._t("fontScaleXSmall"),param:"1"}],c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a,b,c,d,e,f;return d=this.editor.selection.range(),f=this.editor.selection.startNodes(),c=this.editor.selection.endNodes(),e=f.filter('span[style*="font-size"]'),b=c.filter('span[style*="font-size"]'),a=f.length>0&&c.length>0&&e.is(b),this.setActive(a),this.active},c.prototype.command=function(b){var c,d,e;return e=this.editor.selection.range(),e.collapsed?void 0:(document.execCommand("styleWithCSS",!1,!0),document.execCommand("fontSize",!1,b),document.execCommand("styleWithCSS",!1,!1),this.editor.selection.reset(),this.editor.selection.range(),d=this.editor.selection.containerNode(),c=d[0].nodeType===Node.TEXT_NODE?d.closest('span[style*="font-size"]'):d.find('span[style*="font-size"]'),c.each(function(b){return function(c,d){var e,f;return e=a(d),f=d.style.fontSize,/large|x-large|small|x-small/.test(f)?e.css("fontSize",b.sizeMap[f]):"medium"===f?e.replaceWith(e.contents()):void 0}}(this)),this.editor.trigger("valuechanged"))},c}(h),D.Toolbar.addButton(m),g=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="bold",c.prototype.icon="bold",c.prototype.htmlTag="b, strong",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+b",c.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + b )":(this.title=this.title+" ( Ctrl + b )",this.shortcut="ctrl+b"),c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("bold")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("bold"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(g),u=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="italic",c.prototype.icon="italic",c.prototype.htmlTag="i",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+i",c.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + i )":(this.title=this.title+" ( Ctrl + i )",this.shortcut="ctrl+i"),c.__super__._init.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("italic")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("italic"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(u),I=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="underline",c.prototype.icon="underline",c.prototype.htmlTag="u",c.prototype.disableTag="pre",c.prototype.shortcut="cmd+u",c.prototype.render=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + u )":(this.title=this.title+" ( Ctrl + u )",this.shortcut="ctrl+u"),c.__super__.render.call(this)},c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("underline")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("underline"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(I),l=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="color",c.prototype.icon="tint",c.prototype.disableTag="pre",c.prototype.menu=!0,c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a)},c.prototype.renderMenu=function(){return a('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper),this.menuWrapper.on("mousedown",".color-list",function(a){return!1}),this.menuWrapper.on("click",".font-color",function(b){return function(c){var d,e,f,g,h,i;if(b.wrapper.removeClass("menu-on"),d=a(c.currentTarget),d.hasClass("font-color-default")){if(e=b.editor.body.find("p, li"),!(e.length>0))return;h=window.getComputedStyle(e[0],null).getPropertyValue("color"),f=b._convertRgbToHex(h)}else h=window.getComputedStyle(d[0],null).getPropertyValue("background-color"),f=b._convertRgbToHex(h);return f?(g=b.editor.selection.range(),!d.hasClass("font-color-default")&&g.collapsed&&(i=document.createTextNode(b._t("coloredText")),g.insertNode(i),g.selectNodeContents(i),b.editor.selection.range(g)),document.execCommand("styleWithCSS",!1,!0),document.execCommand("foreColor",!1,f),document.execCommand("styleWithCSS",!1,!1),b.editor.util.support.oninput?void 0:b.editor.trigger("valuechanged")):void 0}}(this))},c.prototype._convertRgbToHex=function(a){var b,c,d;return c=/rgb\((\d+),\s?(\d+),\s?(\d+)\)/g,(b=c.exec(a))?(d=function(a,b,c){var d;return d=function(a){var b;return b=a.toString(16),1===b.length?"0"+b:b},"#"+d(a)+d(b)+d(c)})(1*b[1],1*b[2],1*b[3]):""},c}(h),D.Toolbar.addButton(l),y=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.type="",c.prototype.disableTag="pre, table",c.prototype.command=function(b){var c,d,e;return d=this.editor.selection.blockNodes(),e="ul"===this.type?"ol":"ul",this.editor.selection.save(),c=null,d.each(function(b){return function(d,f){
|
|
24
|
+var g;return g=a(f),g.is("blockquote, li")||g.is(b.disableTag)||b.editor.util.isDecoratedNode(g)||!a.contains(document,f)?void 0:g.is(b.type)?(g.children("li").each(function(c,d){var e,f;return f=a(d),e=f.children("ul, ol").insertAfter(g),a("<p/>").append(a(d).html()||b.editor.util.phBr).insertBefore(g)}),g.remove()):g.is(e)?a("<"+b.type+"/>").append(g.contents()).replaceAll(g):c&&g.prev().is(c)?(a("<li/>").append(g.html()||b.editor.util.phBr).appendTo(c),g.remove()):(c=a("<"+b.type+"><li></li></"+b.type+">"),c.find("li").append(g.html()||b.editor.util.phBr),c.replaceAll(g))}}(this)),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),z=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.type="ol",b.prototype.name="ol",b.prototype.icon="list-ol",b.prototype.htmlTag="ol",b.prototype.shortcut="cmd+/",b.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + / )":(this.title=this.title+" ( ctrl + / )",this.shortcut="ctrl+/"),b.__super__._init.call(this)},b}(y),K=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.type="ul",b.prototype.name="ul",b.prototype.icon="list-ul",b.prototype.htmlTag="ul",b.prototype.shortcut="cmd+.",b.prototype._init=function(){return this.editor.util.os.mac?this.title=this.title+" ( Cmd + . )":(this.title=this.title+" ( Ctrl + . )",this.shortcut="ctrl+."),b.__super__._init.call(this)},b}(y),D.Toolbar.addButton(z),D.Toolbar.addButton(K),f=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="blockquote",c.prototype.icon="quote-left",c.prototype.htmlTag="blockquote",c.prototype.disableTag="pre, table",c.prototype.command=function(){var b,c,d;return b=this.editor.selection.rootNodes(),b=b.filter(function(b,c){return!a(c).parent().is("blockquote")}),this.editor.selection.save(),d=[],c=function(b){return function(){return d.length>0?(a("<"+b.htmlTag+"/>").insertBefore(d[0]).append(d),d.length=0):void 0}}(this),b.each(function(b){return function(e,f){var g;return g=a(f),g.parent().is(b.editor.body)?g.is(b.htmlTag)?(c(),g.children().unwrap()):g.is(b.disableTag)||b.editor.util.isDecoratedNode(g)?c():d.push(f):void 0}}(this)),c(),this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(f),j=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="code",c.prototype.icon="code",c.prototype.htmlTag="pre",c.prototype.disableTag="ul, ol, table",c.prototype._init=function(){return c.__super__._init.call(this),this.editor.on("decorate",function(b){return function(c,d){return d.find("pre").each(function(c,d){return b.decorate(a(d))})}}(this)),this.editor.on("undecorate",function(b){return function(c,d){return d.find("pre").each(function(c,d){return b.undecorate(a(d))})}}(this))},c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new k({button:this})},c.prototype._checkMode=function(){var b,c;return c=this.editor.selection.range(),(b=a(c.cloneContents()).find(this.editor.util.blockNodes.join(",")))>0||c.collapsed&&0===this.editor.selection.startNodes().filter("code").length?(this.inlineMode=!1,this.htmlTag="pre"):(this.inlineMode=!0,this.htmlTag="code")},c.prototype._status=function(){return this._checkMode(),c.__super__._status.call(this),this.inlineMode?void 0:this.active?this.popover.show(this.node):this.popover.hide()},c.prototype.decorate=function(a){var b,c,d,e;return b=a.find("> code"),b.length>0&&(c=null!=(d=b.attr("class"))&&null!=(e=d.match(/lang-(\S+)/))?e[1]:void 0,b.contents().unwrap(),c)?a.attr("data-lang",c):void 0},c.prototype.undecorate=function(b){var c,d;return d=b.attr("data-lang"),c=a("<code/>"),d&&-1!==d&&c.addClass("lang-"+d),b.wrapInner(c).removeAttr("data-lang")},c.prototype.command=function(){return this.inlineMode?this._inlineCommand():this._blockCommand()},c.prototype._blockCommand=function(){var b,c,d,e;return b=this.editor.selection.rootNodes(),d=[],e=[],c=function(b){return function(){var c;if(d.length>0)return c=a("<"+b.htmlTag+"/>").insertBefore(d[0]).text(b.editor.formatter.clearHtml(d)),e.push(c[0]),d.length=0}}(this),b.each(function(b){return function(f,g){var h,i;return h=a(g),h.is(b.htmlTag)?(c(),i=a("<p/>").append(h.html().replace("\n","<br/>")).replaceAll(h),e.push(i[0])):h.is(b.disableTag)||b.editor.util.isDecoratedNode(h)||h.is("blockquote")?c():d.push(g)}}(this)),c(),this.editor.selection.setRangeAtEndOf(a(e).last()),this.editor.trigger("valuechanged")},c.prototype._inlineCommand=function(){var b,c,d;return d=this.editor.selection.range(),this.active?(d.selectNodeContents(this.node[0]),this.editor.selection.save(d),this.node.contents().unwrap(),this.editor.selection.restore()):(c=a(d.extractContents()),b=a("<"+this.htmlTag+"/>").append(c.contents()),d.insertNode(b[0]),d.selectNodeContents(b[0]),this.editor.selection.range(d)),this.editor.trigger("valuechanged")},c}(h),k=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.render=function(){var b,c,d,e,f;for(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 </select>\n </div>\n</div>",this.langs=this.editor.opts.codeLanguages||[{name:"Bash",value:"bash"},{name:"C++",value:"c++"},{name:"C#",value:"cs"},{name:"CSS",value:"css"},{name:"Erlang",value:"erlang"},{name:"Less",value:"less"},{name:"Sass",value:"sass"},{name:"Diff",value:"diff"},{name:"CoffeeScript",value:"coffeescript"},{name:"HTML,XML",value:"html"},{name:"JSON",value:"json"},{name:"Java",value:"java"},{name:"JavaScript",value:"js"},{name:"Markdown",value:"markdown"},{name:"Objective C",value:"oc"},{name:"PHP",value:"php"},{name:"Perl",value:"parl"},{name:"Python",value:"python"},{name:"Ruby",value:"ruby"},{name:"SQL",value:"sql"}],this.el.addClass("code-popover").append(this._tpl),this.selectEl=this.el.find(".select-lang"),f=this.langs,c=0,e=f.length;e>c;c++)d=f[c],b=a("<option/>",{text:d.name,value:d.value}).appendTo(this.selectEl);return this.selectEl.on("change",function(a){return function(b){var c;return a.lang=a.selectEl.val(),c=a.target.hasClass("selected"),a.target.removeClass().removeAttr("data-lang"),-1!==a.lang&&a.target.attr("data-lang",a.lang),c&&a.target.addClass("selected"),a.editor.trigger("valuechanged")}}(this)),this.editor.on("valuechanged",function(a){return function(b){return a.active?a.refresh():void 0}}(this))},c.prototype.show=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,a),this.lang=this.target.attr("data-lang"),null!=this.lang?this.selectEl.val(this.lang):this.selectEl.val(-1)},c}(B),D.Toolbar.addButton(j),w=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="link",c.prototype.icon="link",c.prototype.htmlTag="a",c.prototype.disableTag="pre",c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new x({button:this})},c.prototype._status=function(){return c.__super__._status.call(this),this.active&&!this.editor.selection.rangeAtEndOf(this.node)?this.popover.show(this.node):this.popover.hide()},c.prototype.command=function(){var b,c,d,e,f,g;return f=this.editor.selection.range(),this.active?(g=document.createTextNode(this.node.text()),this.node.replaceWith(g),f.selectNode(g)):(b=a(f.extractContents()),e=this.editor.formatter.clearHtml(b.contents(),!1),c=a("<a/>",{href:"http://www.example.com",target:"_blank",text:e||this._t("linkText")}),this.editor.selection.blockNodes().length>0?f.insertNode(c[0]):(d=a("<p/>").append(c),f.insertNode(d[0])),f.selectNodeContents(c[0]),this.popover.one("popovershow",function(a){return function(){return e?(a.popover.urlEl.focus(),a.popover.urlEl[0].select()):(a.popover.textEl.focus(),a.popover.textEl[0].select())}}(this))),this.editor.selection.range(f),this.editor.trigger("valuechanged")},c}(h),x=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.render=function(){var b;return b='<div class="link-settings">\n <div class="settings-field">\n <label>'+this._t("linkText")+'</label>\n <input class="link-text" type="text"/>\n <a class="btn-unlink" href="javascript:;" title="'+this._t("removeLink")+'"\n tabindex="-1">\n <span class="simditor-icon simditor-icon-unlink"></span>\n </a>\n </div>\n <div class="settings-field">\n <label>'+this._t("linkUrl")+'</label>\n <input class="link-url" type="text"/>\n </div>\n <div class="settings-field">\n <label>'+this._t("linkTarget")+'</label>\n <select class="link-target">\n <option value="_blank">'+this._t("openLinkInNewWindow")+' (_blank)</option>\n <option value="_self">'+this._t("openLinkInCurrentWindow")+" (_self)</option>\n </select>\n </div>\n</div>",this.el.addClass("link-popover").append(b),this.textEl=this.el.find(".link-text"),this.urlEl=this.el.find(".link-url"),this.unlinkEl=this.el.find(".btn-unlink"),this.selectTarget=this.el.find(".link-target"),this.textEl.on("keyup",function(a){return function(b){return 13!==b.which?(a.target.text(a.textEl.val()),a.editor.inputManager.throttledValueChanged()):void 0}}(this)),this.urlEl.on("keyup",function(a){return function(b){var c;if(13!==b.which)return c=a.urlEl.val(),!/https?:\/\/|^\//gi.test(c)&&c&&(c="http://"+c),a.target.attr("href",c),a.editor.inputManager.throttledValueChanged()}}(this)),a([this.urlEl[0],this.textEl[0]]).on("keydown",function(b){return function(c){var d;return 13===c.which||27===c.which||!c.shiftKey&&9===c.which&&a(c.target).hasClass("link-url")?(c.preventDefault(),d=document.createRange(),b.editor.selection.setRangeAfter(b.target,d),b.hide(),b.editor.inputManager.throttledValueChanged()):void 0}}(this)),this.unlinkEl.on("click",function(a){return function(b){var c,d;return d=document.createTextNode(a.target.text()),a.target.replaceWith(d),a.hide(),c=document.createRange(),a.editor.selection.setRangeAfter(d,c),a.editor.inputManager.throttledValueChanged()}}(this)),this.selectTarget.on("change",function(a){return function(b){return a.target.attr("target",a.selectTarget.val()),a.editor.inputManager.throttledValueChanged()}}(this))},c.prototype.show=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,a),this.textEl.val(this.target.text()),this.urlEl.val(this.target.attr("href"))},c}(B),D.Toolbar.addButton(w),p=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="image",c.prototype.icon="picture-o",c.prototype.htmlTag="img",c.prototype.disableTag="pre, table",c.prototype.defaultImage="",c.prototype.needFocus=!1,c.prototype._init=function(){var b,d,e,f;if(this.editor.opts.imageButton)if(Array.isArray(this.editor.opts.imageButton))for(this.menu=[],f=this.editor.opts.imageButton,d=0,e=f.length;e>d;d++)b=f[d],this.menu.push({name:b+"-image",text:this._t(b+"Image")});else this.menu=!1;else null!=this.editor.uploader?this.menu=[{name:"upload-image",text:this._t("uploadImage")},{name:"external-image",text:this._t("externalImage")}]:this.menu=!1;return this.defaultImage=this.editor.opts.defaultImage,this.editor.body.on("click","img:not([data-non-image])",function(b){return function(c){var d,e;return d=a(c.currentTarget),e=document.createRange(),e.selectNode(d[0]),b.editor.selection.range(e),b.editor.util.support.onselectionchange||b.editor.trigger("selectionchanged"),!1}}(this)),this.editor.body.on("mouseup","img:not([data-non-image])",function(a){return!1}),this.editor.on("selectionchanged.image",function(b){return function(){var c,d,e;return e=b.editor.selection.range(),null!=e?(c=a(e.cloneContents()).contents(),1===c.length&&c.is("img:not([data-non-image])")?(d=a(e.startContainer).contents().eq(e.startOffset),b.popover.show(d)):b.popover.hide()):void 0}}(this)),this.editor.on("valuechanged.image",function(b){return function(){var c;return c=b.editor.wrapper.find(".simditor-image-loading"),c.length>0?c.each(function(c,d){var e,f,g;return f=a(d),e=f.data("img"),!(e&&e.parent().length>0)&&(f.remove(),e&&(g=e.data("file"),g&&(b.editor.uploader.cancel(g),b.editor.body.find("img.uploading").length<1)))?b.editor.uploader.trigger("uploadready",[g]):void 0}):void 0}}(this)),c.__super__._init.call(this)},c.prototype.render=function(){var a;return a=1<=arguments.length?P.call(arguments,0):[],c.__super__.render.apply(this,a),this.popover=new q({button:this}),"upload"===this.editor.opts.imageButton?this._initUploader(this.el):void 0},c.prototype.renderMenu=function(){return c.__super__.renderMenu.call(this),this._initUploader()},c.prototype._initUploader=function(b){var c,d,e;return null==b&&(b=this.menuEl.find(".menu-item-upload-image")),null==this.editor.uploader?void this.el.find(".btn-upload").remove():(c=null,d=function(d){return function(){return c&&c.remove(),c=a("<input/>",{type:"file",title:d._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),d(),b.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),b.on("change","input[type=file]",function(a){return function(b){return a.editor.inputManager.focused?(a.editor.uploader.upload(c,{inline:!0}),d()):(a.editor.one("focus",function(b){return a.editor.uploader.upload(c,{inline:!0}),d()}),a.editor.focus()),a.wrapper.removeClass("menu-on")}}(this)),this.editor.uploader.on("beforeupload",function(b){return function(c,d){var e;if(d.inline)return d.img?e=a(d.img):(e=b.createImage(d.name),d.img=e),e.addClass("uploading"),e.data("file",d),b.editor.uploader.readImageFile(d.obj,function(a){var c;if(e.hasClass("uploading"))return c=a?a.src:b.defaultImage,b.loadImage(e,c,function(){return b.popover.active?(b.popover.refresh(),b.popover.srcEl.val(b._t("uploading")).prop("disabled",!0)):void 0})})}}(this)),e=a.proxy(this.editor.util.throttle(function(a,b,c,d){var e,f,g;if(b.inline&&(f=b.img.data("mask")))return e=f.data("img"),e.hasClass("uploading")&&e.parent().length>0?(g=c/d,g=(100*g).toFixed(0),g>99&&(g=99),f.find(".progress").height(100-g+"%")):void f.remove()},500),this),this.editor.uploader.on("uploadprogress",e),this.editor.uploader.on("uploadsuccess",function(b){return function(c,d,e){var f,g,h;if(d.inline&&(f=d.img,f.hasClass("uploading")&&f.parent().length>0)){if("object"!=typeof e)try{e=a.parseJSON(e)}catch(i){c=i,e={success:!1}}return e.success===!1?(h=e.msg||b._t("uploadFailed"),alert(h),g=b.defaultImage):g=e.file_path,b.loadImage(f,g,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask"),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,e]):void 0}),b.popover.active?(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(e.file_path)):void 0}}}(this)),this.editor.uploader.on("uploaderror",function(b){return function(c,d,e){var f,g,h;if(d.inline&&"abort"!==e.statusText){if(e.responseText){try{h=a.parseJSON(e.responseText),g=h.msg}catch(i){c=i,g=b._t("uploadError")}alert(g)}if(f=d.img,f.hasClass("uploading")&&f.parent().length>0)return b.loadImage(f,b.defaultImage,function(){var a;return f.removeData("file"),f.removeClass("uploading").removeClass("loading"),a=f.data("mask"),a&&a.remove(),f.removeData("mask")}),b.popover.active&&(b.popover.srcEl.prop("disabled",!1),b.popover.srcEl.val(b.defaultImage)),b.editor.trigger("valuechanged"),b.editor.body.find("img.uploading").length<1?b.editor.uploader.trigger("uploadready",[d,h]):void 0}}}(this)))},c.prototype._status=function(){return this._disableStatus()},c.prototype.loadImage=function(b,c,d){var e,f,g;return g=function(a){return function(){var c,d;return c=b.offset(),d=a.editor.wrapper.offset(),e.css({top:c.top-d.top,left:c.left-d.left,width:b.width(),height:b.height()}).show()}}(this),b.addClass("loading"),e=b.data("mask"),e||(e=a('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper),g(),b.data("mask",e),e.data("img",b)),f=new Image,f.onload=function(h){return function(){var i,j;if(b.hasClass("loading")||b.hasClass("uploading"))return j=f.width,i=f.height,b.attr({src:c,width:j,height:i,"data-image-size":j+","+i}).removeClass("loading"),b.hasClass("uploading")?(h.editor.util.reflow(h.editor.body),g()):(e.remove(),b.removeData("mask")),a.isFunction(d)?d(f):void 0}}(this),f.onerror=function(){return a.isFunction(d)&&d(!1),e.remove(),b.removeData("mask").removeClass("loading")},f.src=c},c.prototype.createImage=function(b){var c,d;return null==b&&(b="Image"),this.editor.inputManager.focused||this.editor.focus(),d=this.editor.selection.range(),d.deleteContents(),this.editor.selection.range(d),c=a("<img/>").attr("alt",b),d.insertNode(c[0]),this.editor.selection.setRangeAfter(c,d),this.editor.trigger("valuechanged"),c},c.prototype.command=function(a){var b;return b=this.createImage(),this.loadImage(b,a||this.defaultImage,function(a){return function(){return a.editor.trigger("valuechanged"),a.editor.util.reflow(b),b.click(),a.popover.one("popovershow",function(){return a.popover.srcEl.focus(),a.popover.srcEl[0].select()})}}(this))},c}(h),q=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.offset={top:6,left:-4},c.prototype.render=function(){var b;return b='<div class="link-settings">\n <div class="settings-field">\n <label>'+this._t("imageUrl")+'</label>\n <input class="image-src" type="text" tabindex="1" />\n <a class="btn-upload" href="javascript:;"\n title="'+this._t("uploadImage")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-upload"></span>\n </a>\n </div>\n <div class=\'settings-field\'>\n <label>'+this._t("imageAlt")+'</label>\n <input class="image-alt" id="image-alt" type="text" tabindex="1" />\n </div>\n <div class="settings-field">\n <label>'+this._t("imageSize")+'</label>\n <input class="image-size" id="image-width" type="text" tabindex="2" />\n <span class="times">×</span>\n <input class="image-size" id="image-height" type="text" tabindex="3" />\n <a class="btn-restore" href="javascript:;"\n title="'+this._t("restoreImageSize")+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-undo"></span>\n </a>\n </div>\n</div>',this.el.addClass("image-popover").append(b),this.srcEl=this.el.find(".image-src"),this.widthEl=this.el.find("#image-width"),this.heightEl=this.el.find("#image-height"),this.altEl=this.el.find("#image-alt"),this.srcEl.on("keydown",function(a){return function(b){var c;if(13===b.which&&!a.target.hasClass("uploading"))return b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()}}(this)),this.srcEl.on("blur",function(a){return function(b){return a._loadImage(a.srcEl.val())}}(this)),this.el.find(".image-size").on("blur",function(b){return function(c){return b._resizeImg(a(c.currentTarget)),b.el.data("popover").refresh()}}(this)),this.el.find(".image-size").on("keyup",function(b){return function(c){var d;return d=a(c.currentTarget),13!==c.which&&27!==c.which&&9!==c.which?b._resizeImg(d,!0):void 0}}(this)),this.el.find(".image-size").on("keydown",function(b){return function(c){var d,e,f;return e=a(c.currentTarget),13===c.which||27===c.which?(c.preventDefault(),13===c.which?b._resizeImg(e):b._restoreImg(),d=b.target,b.hide(),f=document.createRange(),b.button.editor.selection.setRangeAfter(d,f)):9===c.which?b.el.data("popover").refresh():void 0}}(this)),this.altEl.on("keydown",function(a){return function(b){var c;return 13===b.which?(b.preventDefault(),c=document.createRange(),a.button.editor.selection.setRangeAfter(a.target,c),a.hide()):void 0}}(this)),this.altEl.on("keyup",function(a){return function(b){return 13!==b.which&&27!==b.which&&9!==b.which?(a.alt=a.altEl.val(),a.target.attr("alt",a.alt)):void 0}}(this)),this.el.find(".btn-restore").on("click",function(a){return function(b){return a._restoreImg(),a.el.data("popover").refresh()}}(this)),this.editor.on("valuechanged",function(a){return function(b){return a.active?a.refresh():void 0}}(this)),this._initUploader()},c.prototype._initUploader=function(){var b,c;return b=this.el.find(".btn-upload"),null==this.editor.uploader?void b.remove():(c=function(c){return function(){return c.input&&c.input.remove(),c.input=a("<input/>",{type:"file",title:c._t("uploadImage"),multiple:!0,accept:"image/*"}).appendTo(b)}}(this),c(),this.el.on("click mousedown","input[type=file]",function(a){return a.stopPropagation()}),this.el.on("change","input[type=file]",function(a){return function(b){return a.editor.uploader.upload(a.input,{inline:!0,img:a.target}),c()}}(this)))},c.prototype._resizeImg=function(b,c){var d,e,f;return null==c&&(c=!1),e=1*b.val(),this.target&&(a.isNumeric(e)||0>e)?(b.is(this.widthEl)?(f=e,d=this.height*e/this.width,this.heightEl.val(d)):(d=e,f=this.width*e/this.height,this.widthEl.val(f)),c?void 0:(this.target.attr({width:f,height:d}),this.editor.trigger("valuechanged"))):void 0},c.prototype._restoreImg=function(){var a,b;return b=(null!=(a=this.target.data("image-size"))?a.split(","):void 0)||[this.width,this.height],this.target.attr({width:1*b[0],height:1*b[1]}),this.widthEl.val(b[0]),this.heightEl.val(b[1]),this.editor.trigger("valuechanged")},c.prototype._loadImage=function(a,b){if(/^data:image/.test(a)&&!this.editor.uploader)return void(b&&b(!1));if(this.target.attr("src")!==a)return this.button.loadImage(this.target,a,function(c){return function(d){var e;if(d)return c.active&&(c.width=d.width,c.height=d.height,c.widthEl.val(c.width),c.heightEl.val(c.height)),/^data:image/.test(a)?(e=c.editor.util.dataURLtoBlob(a),e.name="Base64 Image.png",c.editor.uploader.upload(e,{inline:!0,img:c.target})):c.editor.trigger("valuechanged"),b?b(d):void 0}}(this))},c.prototype.show=function(){var a,b;return b=1<=arguments.length?P.call(arguments,0):[],c.__super__.show.apply(this,b),a=this.target,this.width=a.width(),this.height=a.height(),this.alt=a.attr("alt"),a.hasClass("uploading")?this.srcEl.val(this._t("uploading")).prop("disabled",!0):(this.srcEl.val(a.attr("src")).prop("disabled",!1),this.widthEl.val(this.width),this.heightEl.val(this.height),this.altEl.val(this.alt))},c}(B),D.Toolbar.addButton(p),r=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="indent",b.prototype.icon="indent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent()},b}(h),D.Toolbar.addButton(r),A=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="outdent",b.prototype.icon="outdent",b.prototype._init=function(){return this.title=this._t(this.name)+" (Shift + Tab)",b.__super__._init.call(this)},b.prototype._status=function(){},b.prototype.command=function(){return this.editor.indentation.indent(!0)},b}(h),D.Toolbar.addButton(A),o=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="hr",c.prototype.icon="minus",c.prototype.htmlTag="hr",c.prototype._status=function(){},c.prototype.command=function(){var b,c,d,e;return e=this.editor.selection.rootNodes().first(),d=e.next(),d.length>0?this.editor.selection.save():c=a("<p/>").append(this.editor.util.phBr),b=a("<hr/>").insertAfter(e),c?(c.insertAfter(b),this.editor.selection.setRangeAtStartOf(c)):this.editor.selection.restore(),this.editor.trigger("valuechanged")},c}(h),D.Toolbar.addButton(o),F=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="table",c.prototype.icon="table",c.prototype.htmlTag="table",c.prototype.disableTag="pre, li, blockquote",c.prototype.menu=!0,c.prototype._init=function(){return c.__super__._init.call(this),a.merge(this.editor.formatter._allowedTags,["thead","th","tbody","tr","td","colgroup","col"]),a.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]}),a.extend(this.editor.formatter._allowedStyles,{td:["text-align"],th:["text-align"]}),this._initShortcuts(),this.editor.on("decorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.decorate(a(d))})}}(this)),this.editor.on("undecorate",function(b){return function(c,d){return d.find("table").each(function(c,d){return b.undecorate(a(d))})}}(this)),this.editor.on("selectionchanged.table",function(a){return function(b){var c,d;return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active"),(d=a.editor.selection.range())?(c=a.editor.selection.containerNode(),d.collapsed&&c.is(".simditor-table")&&(c=a.editor.selection.rangeAtStartOf(c)?c.find("th:first"):c.find("td:last"),a.editor.selection.setRangeAtEndOf(c)),c.closest("td, th",a.editor.body).addClass("active")):void 0}}(this)),this.editor.on("blur.table",function(a){return function(b){return a.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active")}}(this)),this.editor.keystroke.add("up","td",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("up","th",function(a){return function(b,c){return a._tdNav(c,"up"),!0}}(this)),this.editor.keystroke.add("down","td",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this)),this.editor.keystroke.add("down","th",function(a){return function(b,c){return a._tdNav(c,"down"),!0}}(this))},c.prototype._tdNav=function(a,b){var c,d,e,f,g,h,i;return null==b&&(b="up"),e="up"===b?"prev":"next",i="up"===b?["tbody","thead"]:["thead","tbody"],h=i[0],f=i[1],d=a.parent("tr"),c=this["_"+e+"Row"](d),c.length>0?(g=d.find("td, th").index(a),this.editor.selection.setRangeAtEndOf(c.find("td, th").eq(g))):!0},c.prototype._nextRow=function(a){var b;return b=a.next("tr"),b.length<1&&a.parent("thead").length>0&&(b=a.parent("thead").next("tbody").find("tr:first")),b},c.prototype._prevRow=function(a){var b;return b=a.prev("tr"),b.length<1&&a.parent("tbody").length>0&&(b=a.parent("tbody").prev("thead").find("tr")),b},c.prototype.initResize=function(b){var c,d,e;return e=b.parent(".simditor-table"),c=b.find("colgroup"),c.length<1&&(c=a("<colgroup/>").prependTo(b),b.find("thead tr th").each(function(b,d){var e;return e=a("<col/>").appendTo(c)}),this.refreshTableWidth(b)),d=a("<div />",{"class":"simditor-resize-handle",contenteditable:"false"}).appendTo(e),e.on("mousemove","td, th",function(b){var f,g,h,i,j,k;if(!e.hasClass("resizing"))return g=a(b.currentTarget),k=b.pageX-a(b.currentTarget).offset().left,5>k&&g.prev().length>0&&(g=g.prev()),g.next("td, th").length<1?void d.hide():(null!=(i=d.data("td"))?i.is(g):void 0)?void d.show():(h=g.parent().find("td, th").index(g),f=c.find("col").eq(h),(null!=(j=d.data("col"))?j.is(f):void 0)?void d.show():d.css("left",g.position().left+g.outerWidth()-5).data("td",g).data("col",f).show())}),e.on("mouseleave",function(a){return d.hide()}),e.on("mousedown",".simditor-resize-handle",function(b){var c,d,f,g,h,i,j,k,l,m,n;return c=a(b.currentTarget),f=c.data("td"),d=c.data("col"),h=f.next("td, th"),g=d.next("col"),m=b.pageX,k=1*f.outerWidth(),l=1*h.outerWidth(),j=parseFloat(c.css("left")),n=f.closest("table").width(),i=50,a(document).on("mousemove.simditor-resize-table",function(a){var b,e,f;return b=a.pageX-m,e=k+b,f=l-b,i>e?(e=i,b=i-k,f=l-b):i>f&&(f=i,b=l-i,e=k+b),d.attr("width",e/n*100+"%"),g.attr("width",f/n*100+"%"),c.css("left",j+b)}),a(document).one("mouseup.simditor-resize-table",function(b){return a(document).off(".simditor-resize-table"),e.removeClass("resizing")}),e.addClass("resizing"),!1})},c.prototype._initShortcuts=function(){return this.editor.hotkeys.add("ctrl+alt+up",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowAbove]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+down",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertRowBelow]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+left",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColLeft]").click(),!1}}(this)),this.editor.hotkeys.add("ctrl+alt+right",function(a){return function(b){return a.editMenu.find(".menu-item[data-param=insertColRight]").click(),!1}}(this))},c.prototype.decorate=function(b){var c,d,e;return b.parent(".simditor-table").length>0&&this.undecorate(b),b.wrap('<div class="simditor-table"></div>'),b.find("thead").length<1&&(e=a("<thead />"),c=b.find("tr").first(),e.append(c),this._changeCellTag(c,"th"),d=b.find("tbody"),d.length>0?d.before(e):b.prepend(e)),this.initResize(b),b.parent()},c.prototype.undecorate=function(a){return a.parent(".simditor-table").length>0?a.parent().replaceWith(a):void 0},c.prototype.renderMenu=function(){var b;return a('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n <ul>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteRow">\n <span>'+this._t("deleteRow")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowAbove">\n <span>'+this._t("insertRowAbove")+' ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowBelow">\n <span>'+this._t("insertRowBelow")+' ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteCol">\n <span>'+this._t("deleteColumn")+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColLeft">\n <span>'+this._t("insertColumnLeft")+' ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColRight">\n <span>'+this._t("insertColumnRight")+' ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteTable">\n <span>'+this._t("deleteTable")+"</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper),this.createMenu=this.menuWrapper.find(".menu-create-table"),this.editMenu=this.menuWrapper.find(".menu-edit-table"),b=this.createTable(6,6).appendTo(this.createMenu),this.createMenu.on("mouseenter","td, th",function(c){return function(d){var e,f,g,h;return c.createMenu.find("td, th").removeClass("selected"),e=a(d.currentTarget),f=e.parent(),h=f.find("td, th").index(e)+1,g=f.prevAll("tr").addBack(),f.parent().is("tbody")&&(g=g.add(b.find("thead tr"))),g.find("td:lt("+h+"), th:lt("+h+")").addClass("selected")}}(this)),this.createMenu.on("mouseleave",function(b){return a(b.currentTarget).find("td, th").removeClass("selected")}),this.createMenu.on("mousedown","td, th",function(c){return function(d){var e,f,g,h,i;return c.wrapper.removeClass("menu-on"),c.editor.inputManager.focused?(f=a(d.currentTarget),g=f.parent(),h=g.find("td").index(f)+1,i=g.prevAll("tr").length+1,g.parent().is("tbody")&&(i+=1),b=c.createTable(i,h,!0),e=c.editor.selection.blockNodes().last(),c.editor.util.isEmptyNode(e)?e.replaceWith(b):e.after(b),c.decorate(b),c.editor.selection.setRangeAtStartOf(b.find("th:first")),
|
|
25
|
+c.editor.trigger("valuechanged"),!1):void 0}}(this))},c.prototype.createTable=function(b,c,d){var e,f,g,h,i,j,k,l,m,n,o;for(e=a("<table/>"),h=a("<thead/>").appendTo(e),f=a("<tbody/>").appendTo(e),m=k=0,n=b;n>=0?n>k:k>n;m=n>=0?++k:--k)for(i=a("<tr/>"),i.appendTo(0===m?h:f),j=l=0,o=c;o>=0?o>l:l>o;j=o>=0?++l:--l)g=a(0===m?"<th/>":"<td/>").appendTo(i),d&&g.append(this.editor.util.phBr);return e},c.prototype.refreshTableWidth=function(b){var c,d;return d=b.width(),c=b.find("col"),b.find("thead tr th").each(function(b,e){var f;return f=c.eq(b),f.attr("width",a(e).outerWidth()/d*100+"%")})},c.prototype.setActive=function(a){return c.__super__.setActive.call(this,a),a?(this.createMenu.hide(),this.editMenu.show()):(this.createMenu.show(),this.editMenu.hide())},c.prototype._changeCellTag=function(b,c){return b.find("td, th").each(function(b,d){var e;return e=a(d),e.replaceWith("<"+c+">"+e.html()+"</"+c+">")})},c.prototype.deleteRow=function(a){var b,c,d;return c=a.parent("tr"),c.closest("table").find("tr").length<1?this.deleteTable(a):(b=this._nextRow(c),b.length>0||(b=this._prevRow(c)),d=c.find("td, th").index(a),c.parent().is("thead")&&(b.appendTo(c.parent()),this._changeCellTag(b,"th")),c.remove(),this.editor.selection.setRangeAtEndOf(b.find("td, th").eq(d)))},c.prototype.insertRow=function(b,c){var d,e,f,g,h,i,j,k,l;for(null==c&&(c="after"),f=b.parent("tr"),e=f.closest("table"),h=0,e.find("tr").each(function(b,c){return h=Math.max(h,a(c).find("td").length)}),j=f.find("td, th").index(b),d=a("<tr/>"),g="td","after"===c&&f.parent().is("thead")?f.parent().next("tbody").prepend(d):"before"===c&&f.parent().is("thead")?(f.before(d),f.parent().next("tbody").prepend(f),this._changeCellTag(f,"td"),g="th"):f[c](d),i=k=1,l=h;l>=1?l>=k:k>=l;i=l>=1?++k:--k)a("<"+g+"/>").append(this.editor.util.phBr).appendTo(d);return this.editor.selection.setRangeAtStartOf(d.find("td, th").eq(j))},c.prototype.deleteCol=function(b){var c,d,e,f,g,h;return e=b.parent("tr"),h=e.closest("table").find("tr").length<2,g=b.siblings("td, th").length<1,h&&g?this.deleteTable(b):(f=e.find("td, th").index(b),c=b.next("td, th"),c.length>0||(c=e.prev("td, th")),d=e.closest("table"),d.find("col").eq(f).remove(),d.find("tr").each(function(b,c){return a(c).find("td, th").eq(f).remove()}),this.refreshTableWidth(d),this.editor.selection.setRangeAtEndOf(c))},c.prototype.insertCol=function(b,c){var d,e,f,g,h,i,j,k;return null==c&&(c="after"),h=b.parent("tr"),i=h.find("td, th").index(b),g=b.closest("table"),d=g.find("col").eq(i),g.find("tr").each(function(b){return function(d,e){var f,g;return g=a(e).parent().is("thead")?"th":"td",f=a("<"+g+"/>").append(b.editor.util.phBr),a(e).find("td, th").eq(i)[c](f)}}(this)),e=a("<col/>"),d[c](e),j=g.width(),k=Math.max(parseFloat(d.attr("width"))/2,50/j*100),d.attr("width",k+"%"),e.attr("width",k+"%"),this.refreshTableWidth(g),f="after"===c?b.next("td, th"):b.prev("td, th"),this.editor.selection.setRangeAtStartOf(f)},c.prototype.deleteTable=function(a){var b,c;return c=a.closest(".simditor-table"),b=c.next("p"),c.remove(),b.length>0?this.editor.selection.setRangeAtStartOf(b):void 0},c.prototype.command=function(a){var b;if(b=this.editor.selection.containerNode().closest("td, th"),b.length>0){if("deleteRow"===a)this.deleteRow(b);else if("insertRowAbove"===a)this.insertRow(b,"before");else if("insertRowBelow"===a)this.insertRow(b);else if("deleteCol"===a)this.deleteCol(b);else if("insertColLeft"===a)this.insertCol(b,"before");else if("insertColRight"===a)this.insertCol(b);else{if("deleteTable"!==a)return;this.deleteTable(b)}return this.editor.trigger("valuechanged")}},c}(h),D.Toolbar.addButton(F),E=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return M(c,b),c.prototype.name="strikethrough",c.prototype.icon="strikethrough",c.prototype.htmlTag="strike",c.prototype.disableTag="pre",c.prototype._activeStatus=function(){var a;return a=document.queryCommandState("strikethrough")===!0,this.setActive(a),this.active},c.prototype.command=function(){return document.execCommand("strikethrough"),this.editor.util.support.oninput||this.editor.trigger("valuechanged"),a(document).trigger("selectionchange")},c}(h),D.Toolbar.addButton(E),e=function(a){function b(){return b.__super__.constructor.apply(this,arguments)}return M(b,a),b.prototype.name="alignment",b.prototype.icon="align-left",b.prototype.htmlTag="p, h1, h2, h3, h4, td, th",b.prototype._init=function(){return this.menu=[{name:"left",text:this._t("alignLeft"),icon:"align-left",param:"left"},{name:"center",text:this._t("alignCenter"),icon:"align-center",param:"center"},{name:"right",text:this._t("alignRight"),icon:"align-right",param:"right"}],b.__super__._init.call(this)},b.prototype.setActive=function(a,c){return null==c&&(c="left"),"left"!==c&&"center"!==c&&"right"!==c&&(c="left"),"left"===c?b.__super__.setActive.call(this,!1):b.__super__.setActive.call(this,a),this.el.removeClass("align-left align-center align-right"),a&&this.el.addClass("align-"+c),this.setIcon("align-"+c),this.menuEl.find(".menu-item").show().end().find(".menu-item-"+c).hide()},b.prototype._status=function(){return this.nodes=this.editor.selection.nodes().filter(this.htmlTag),this.nodes.length<1?(this.setDisabled(!0),this.setActive(!1)):(this.setDisabled(!1),this.setActive(!0,this.nodes.first().css("text-align")))},b.prototype.command=function(a){if("left"!==a&&"center"!==a&&"right"!==a)throw new Error("simditor alignment button: invalid align "+a);return this.nodes.css({"text-align":"left"===a?"":a}),this.editor.trigger("valuechanged"),this.editor.inputManager.throttledSelectionChanged()},b}(h),D.Toolbar.addButton(e),D});(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor-checklist",["jquery","simditor"],function(a0,b1){return(root["ChecklistButton"]=factory(a0,b1))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simditor"))}else{root["ChecklistButton"]=factory(jQuery,Simditor)}}}(this,function($,Simditor){var ChecklistButton,extend=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},hasProp={}.hasOwnProperty,slice=[].slice;ChecklistButton=(function(superClass){extend(ChecklistButton,superClass);ChecklistButton.prototype.type="ul.simditor-checklist";ChecklistButton.prototype.name="checklist";ChecklistButton.prototype.icon="checklist";ChecklistButton.prototype.htmlTag="li";ChecklistButton.prototype.disableTag="pre, table";function ChecklistButton(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ChecklistButton.__super__.constructor.apply(this,args);if("input"&&$.inArray("input",this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push("input")}$.extend(this.editor.formatter._allowedAttributes,{input:["type","checked"]})}ChecklistButton.prototype._init=function(){ChecklistButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("ul > li input[type=checkbox]").each(function(i,checkbox){return _this._decorate($(checkbox))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find(".simditor-checklist > li").each(function(i,node){return _this._undecorate($(node))})}})(this));this.editor.body.on("click",".simditor-checklist > li",(function(_this){return function(e){var $node,range;e.preventDefault();e.stopPropagation();$node=$(e.currentTarget);range=document.createRange();_this.editor.selection.save();range.setStart($node[0],0);range.setEnd($node[0],_this.editor.util.getNodeLength($node[0]));_this.editor.selection.range(range);document.execCommand("strikethrough");$node.attr("checked",!$node.attr("checked"));_this.editor.selection.restore();return _this.editor.trigger("valuechanged")}})(this));return this.editor.keystroke.add("13","li",(function(_this){return function(e,$node){return setTimeout(function(){var $li;$li=_this.editor.selection.blockNodes().last().next();if($li.length){$li[0].removeAttribute("checked");if(document.queryCommandState("strikethrough")){return document.execCommand("strikethrough")}}},0)}})(this))};ChecklistButton.prototype._status=function(){var $node;ChecklistButton.__super__._status.call(this);$node=this.editor.selection.rootNodes();if($node.is(".simditor-checklist")){this.editor.toolbar.findButton("ul").setActive(false);this.editor.toolbar.findButton("ol").setActive(false);this.editor.toolbar.findButton("ul").setDisabled(true);return this.editor.toolbar.findButton("ol").setDisabled(true)}else{return this.editor.toolbar.findButton("checklist").setActive(false)}};ChecklistButton.prototype.command=function(param){var $list,$rootNodes;$rootNodes=this.editor.selection.blockNodes();this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||!$.contains(document,node)){return}if($node.is(".simditor-checklist")){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is("ul, ol")){return $('<ul class="simditor-checklist" />').append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$('<ul class="simditor-checklist"><li></li></ul>');$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};ChecklistButton.prototype._decorate=function($checkbox){var $node,checked;checked=!!$checkbox.attr("checked");$node=$checkbox.closest("li");$checkbox.remove();$node.attr("checked",checked);return $node.closest("ul").addClass("simditor-checklist")};ChecklistButton.prototype._undecorate=function($node){var $checkbox,checked;checked=!!$node.attr("checked");$checkbox=$('<input type="checkbox">').attr("checked",checked);return $node.attr("checked","").prepend($checkbox)};return ChecklistButton})(Simditor.Button);Simditor.Toolbar.addButton(ChecklistButton);return ChecklistButton}));
|
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+/*!
|
|
2
|
+* Simditor v2.3.6
|
|
3
|
+* http://simditor.tower.im/
|
|
4
|
+* 2015-12-21
|
|
5
|
+*/
|
|
6
|
+(function(root,factory){if(typeof define==="function"&&define.amd){define("simditor",["jquery","simple-module","simple-hotkeys","simple-uploader"],function($,SimpleModule,simpleHotkeys,simpleUploader){return(root["Simditor"]=factory($,SimpleModule,simpleHotkeys,simpleUploader))})}else{if(typeof exports==="object"){module.exports=factory(require("jquery"),require("simple-module"),require("simple-hotkeys"),require("simple-uploader"))}else{root["Simditor"]=factory(jQuery,SimpleModule,simple.hotkeys,simple.uploader)}}}(this,function($,SimpleModule,simpleHotkeys,simpleUploader){var AlignmentButton,BlockquoteButton,BoldButton,Button,Clipboard,CodeButton,CodePopover,ColorButton,FontScaleButton,Formatter,HrButton,ImageButton,ImagePopover,IndentButton,Indentation,InputManager,ItalicButton,Keystroke,LinkButton,LinkPopover,ListButton,OrderListButton,OutdentButton,Popover,Selection,Simditor,StrikethroughButton,TableButton,TitleButton,Toolbar,UnderlineButton,UndoManager,UnorderListButton,Util,extend=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},hasProp={}.hasOwnProperty,indexOf=[].indexOf||function(item){for(var i=0,l=this.length;i<l;i++){if(i in this&&this[i]===item){return i}}return -1},slice=[].slice;Selection=(function(superClass){extend(Selection,superClass);function Selection(){return Selection.__super__.constructor.apply(this,arguments)}Selection.pluginName="Selection";Selection.prototype._range=null;Selection.prototype._startNodes=null;Selection.prototype._endNodes=null;Selection.prototype._containerNode=null;Selection.prototype._nodes=null;Selection.prototype._blockNodes=null;Selection.prototype._rootNodes=null;Selection.prototype._init=function(){this.editor=this._module;this._selection=document.getSelection();this.editor.on("selectionchanged",(function(_this){return function(e){_this.reset();return _this._range=_this._selection.getRangeAt(0)}})(this));return this.editor.on("blur",(function(_this){return function(e){return _this.reset()}})(this))};Selection.prototype.reset=function(){this._range=null;this._startNodes=null;this._endNodes=null;this._containerNode=null;this._nodes=null;this._blockNodes=null;return this._rootNodes=null};Selection.prototype.clear=function(){var e;try{this._selection.removeAllRanges()}catch(_error){e=_error}return this.reset()};Selection.prototype.range=function(range){var ffOrIE;if(range){this.clear();this._selection.addRange(range);this._range=range;ffOrIE=this.editor.util.browser.firefox||this.editor.util.browser.msie;if(!this.editor.inputManager.focused&&ffOrIE){this.editor.body.focus()}}else{if(!this._range&&this.editor.inputManager.focused&&this._selection.rangeCount){this._range=this._selection.getRangeAt(0)}}return this._range};Selection.prototype.startNodes=function(){if(this._range){this._startNodes||(this._startNodes=(function(_this){return function(){var startNodes;startNodes=$(_this._range.startContainer).parentsUntil(_this.editor.body).get();startNodes.unshift(_this._range.startContainer);return $(startNodes)}})(this)())}return this._startNodes};Selection.prototype.endNodes=function(){var endNodes;if(this._range){this._endNodes||(this._endNodes=this._range.collapsed?this.startNodes():(endNodes=$(this._range.endContainer).parentsUntil(this.editor.body).get(),endNodes.unshift(this._range.endContainer),$(endNodes)))}return this._endNodes};Selection.prototype.containerNode=function(){if(this._range){this._containerNode||(this._containerNode=$(this._range.commonAncestorContainer))}return this._containerNode};Selection.prototype.nodes=function(){if(this._range){this._nodes||(this._nodes=(function(_this){return function(){var nodes;nodes=[];if(_this.startNodes().first().is(_this.endNodes().first())){nodes=_this.startNodes().get()}else{_this.startNodes().each(function(i,node){var $endNode,$node,$nodes,endIndex,index,sharedIndex,startIndex;$node=$(node);if(_this.endNodes().index($node)>-1){return nodes.push(node)}else{if($node.parent().is(_this.editor.body)||(sharedIndex=_this.endNodes().index($node.parent()))>-1){if(sharedIndex&&sharedIndex>-1){$endNode=_this.endNodes().eq(sharedIndex-1)}else{$endNode=_this.endNodes().last()}$nodes=$node.parent().contents();startIndex=$nodes.index($node);endIndex=$nodes.index($endNode);return $.merge(nodes,$nodes.slice(startIndex,endIndex).get())}else{$nodes=$node.parent().contents();index=$nodes.index($node);return $.merge(nodes,$nodes.slice(index).get())}}});_this.endNodes().each(function(i,node){var $node,$nodes,index;$node=$(node);if($node.parent().is(_this.editor.body)||_this.startNodes().index($node.parent())>-1){nodes.push(node);return false}else{$nodes=$node.parent().contents();index=$nodes.index($node);return $.merge(nodes,$nodes.slice(0,index+1))}})}return $($.unique(nodes))}
|
|
7
|
+})(this)())}return this._nodes};Selection.prototype.blockNodes=function(){if(!this._range){return}this._blockNodes||(this._blockNodes=(function(_this){return function(){return _this.nodes().filter(function(i,node){return _this.editor.util.isBlockNode(node)})}})(this)());return this._blockNodes};Selection.prototype.rootNodes=function(){if(!this._range){return}this._rootNodes||(this._rootNodes=(function(_this){return function(){return _this.nodes().filter(function(i,node){var $parent;$parent=$(node).parent();return $parent.is(_this.editor.body)||$parent.is("blockquote")})}})(this)());return this._rootNodes};Selection.prototype.rangeAtEndOf=function(node,range){var afterLastNode,beforeLastNode,endNode,endNodeLength,lastNodeIsBr,result;if(range==null){range=this.range()}if(!(range&&range.collapsed)){return}node=$(node)[0];endNode=range.endContainer;endNodeLength=this.editor.util.getNodeLength(endNode);beforeLastNode=range.endOffset===endNodeLength-1;lastNodeIsBr=$(endNode).contents().last().is("br");afterLastNode=range.endOffset===endNodeLength;if(!((beforeLastNode&&lastNodeIsBr)||afterLastNode)){return false}if(node===endNode){return true}else{if(!$.contains(node,endNode)){return false}}result=true;$(endNode).parentsUntil(node).addBack().each(function(i,n){var $lastChild,beforeLastbr,isLastNode,nodes;nodes=$(n).parent().contents().filter(function(){return !(this!==n&&this.nodeType===3&&!this.nodeValue)});$lastChild=nodes.last();isLastNode=$lastChild.get(0)===n;beforeLastbr=$lastChild.is("br")&&$lastChild.prev().get(0)===n;if(!(isLastNode||beforeLastbr)){result=false;return false}});return result};Selection.prototype.rangeAtStartOf=function(node,range){var result,startNode;if(range==null){range=this.range()}if(!(range&&range.collapsed)){return}node=$(node)[0];startNode=range.startContainer;if(range.startOffset!==0){return false}if(node===startNode){return true}else{if(!$.contains(node,startNode)){return false}}result=true;$(startNode).parentsUntil(node).addBack().each(function(i,n){var nodes;nodes=$(n).parent().contents().filter(function(){return !(this!==n&&this.nodeType===3&&!this.nodeValue)});if(nodes.first().get(0)!==n){return result=false}});return result};Selection.prototype.insertNode=function(node,range){if(range==null){range=this.range()}if(!range){return}node=$(node)[0];range.insertNode(node);return this.setRangeAfter(node,range)};Selection.prototype.setRangeAfter=function(node,range){if(range==null){range=this.range()}if(range==null){return}node=$(node)[0];range.setEndAfter(node);range.collapse(false);return this.range(range)};Selection.prototype.setRangeBefore=function(node,range){if(range==null){range=this.range()}if(range==null){return}node=$(node)[0];range.setEndBefore(node);range.collapse(false);return this.range(range)};Selection.prototype.setRangeAtStartOf=function(node,range){if(range==null){range=this.range()}node=$(node).get(0);range.setEnd(node,0);range.collapse(false);return this.range(range)};Selection.prototype.setRangeAtEndOf=function(node,range){var $lastNode,$node,contents,lastChild,lastChildLength,lastText,nodeLength;if(range==null){range=this.range()}$node=$(node);node=$node[0];if($node.is("pre")){contents=$node.contents();if(contents.length>0){lastChild=contents.last();lastText=lastChild.text();lastChildLength=this.editor.util.getNodeLength(lastChild[0]);if(lastText.charAt(lastText.length-1)==="\n"){range.setEnd(lastChild[0],lastChildLength-1)}else{range.setEnd(lastChild[0],lastChildLength)}}else{range.setEnd(node,0)}}else{nodeLength=this.editor.util.getNodeLength(node);if(node.nodeType!==3&&nodeLength>0){$lastNode=$(node).contents().last();if($lastNode.is("br")){nodeLength-=1}else{if($lastNode[0].nodeType!==3&&this.editor.util.isEmptyNode($lastNode)){$lastNode.append(this.editor.util.phBr);node=$lastNode[0];nodeLength=0}}}range.setEnd(node,nodeLength)}range.collapse(false);return this.range(range)};Selection.prototype.deleteRangeContents=function(range){var atEndOfBody,atStartOfBody,endRange,startRange;if(range==null){range=this.range()}startRange=range.cloneRange();endRange=range.cloneRange();startRange.collapse(true);endRange.collapse(false);atStartOfBody=this.rangeAtStartOf(this.editor.body,startRange);atEndOfBody=this.rangeAtEndOf(this.editor.body,endRange);if(!range.collapsed&&atStartOfBody&&atEndOfBody){this.editor.body.empty();range.setStart(this.editor.body[0],0);range.collapse(true);this.range(range)}else{range.deleteContents()}return range};Selection.prototype.breakBlockEl=function(el,range){var $el;if(range==null){range=this.range()}$el=$(el);if(!range.collapsed){return $el}range.setStartBefore($el.get(0));if(range.collapsed){return $el}return $el.before(range.extractContents())};Selection.prototype.save=function(range){var endCaret,endRange,startCaret;if(range==null){range=this.range()}if(this._selectionSaved){return}endRange=range.cloneRange();endRange.collapse(false);startCaret=$("<span/>").addClass("simditor-caret-start");endCaret=$("<span/>").addClass("simditor-caret-end");
|
|
8
|
+endRange.insertNode(endCaret[0]);range.insertNode(startCaret[0]);this.clear();return this._selectionSaved=true};Selection.prototype.restore=function(){var endCaret,endContainer,endOffset,range,startCaret,startContainer,startOffset;if(!this._selectionSaved){return false}startCaret=this.editor.body.find(".simditor-caret-start");endCaret=this.editor.body.find(".simditor-caret-end");if(startCaret.length&&endCaret.length){startContainer=startCaret.parent();startOffset=startContainer.contents().index(startCaret);endContainer=endCaret.parent();endOffset=endContainer.contents().index(endCaret);if(startContainer[0]===endContainer[0]){endOffset-=1}range=document.createRange();range.setStart(startContainer.get(0),startOffset);range.setEnd(endContainer.get(0),endOffset);startCaret.remove();endCaret.remove();this.range(range)}else{startCaret.remove();endCaret.remove()}this._selectionSaved=false;return range};return Selection})(SimpleModule);Formatter=(function(superClass){extend(Formatter,superClass);function Formatter(){return Formatter.__super__.constructor.apply(this,arguments)}Formatter.pluginName="Formatter";Formatter.prototype.opts={allowedTags:[],allowedAttributes:{},allowedStyles:{}};Formatter.prototype._init=function(){this.editor=this._module;this._allowedTags=$.merge(["br","span","a","img","b","strong","i","strike","u","font","p","ul","ol","li","blockquote","pre","code","h1","h2","h3","h4","hr"],this.opts.allowedTags);this._allowedAttributes=$.extend({img:["src","alt","width","height","data-non-image"],a:["href","target"],font:["color"],code:["class"]},this.opts.allowedAttributes);this._allowedStyles=$.extend({span:["color","font-size"],b:["color"],i:["color"],strong:["color"],strike:["color"],u:["color"],p:["margin-left","text-align"],h1:["margin-left","text-align"],h2:["margin-left","text-align"],h3:["margin-left","text-align"],h4:["margin-left","text-align"]},this.opts.allowedStyles);return this.editor.body.on("click","a",function(e){return false})};Formatter.prototype.decorate=function($el){if($el==null){$el=this.editor.body}this.editor.trigger("decorate",[$el]);return $el};Formatter.prototype.undecorate=function($el){if($el==null){$el=this.editor.body.clone()}this.editor.trigger("undecorate",[$el]);return $el};Formatter.prototype.autolink=function($el){var $link,$node,findLinkNode,k,lastIndex,len,linkNodes,match,re,replaceEls,subStr,text,uri;if($el==null){$el=this.editor.body}linkNodes=[];findLinkNode=function($parentNode){return $parentNode.contents().each(function(i,node){var $node,text;$node=$(node);if($node.is("a")||$node.closest("a, pre",$el).length){return}if(!$node.is("iframe")&&$node.contents().length){return findLinkNode($node)}else{if((text=$node.text())&&/https?:\/\/|www\./ig.test(text)){return linkNodes.push($node)}}})};findLinkNode($el);re=/(https?:\/\/|www\.)[\w\-\.\?&=\/#%:,@\!\+]+/ig;for(k=0,len=linkNodes.length;k<len;k++){$node=linkNodes[k];text=$node.text();replaceEls=[];match=null;lastIndex=0;while((match=re.exec(text))!==null){subStr=text.substring(lastIndex,match.index);replaceEls.push(document.createTextNode(subStr));lastIndex=re.lastIndex;uri=/^(http(s)?:\/\/|\/)/.test(match[0])?match[0]:"http://"+match[0];$link=$('<a href="'+uri+'" rel="nofollow"></a>').text(match[0]);replaceEls.push($link[0])}replaceEls.push(document.createTextNode(text.substring(lastIndex)));$node.replaceWith($(replaceEls))}return $el};Formatter.prototype.format=function($el){var $node,blockNode,k,l,len,len1,n,node,ref,ref1;if($el==null){$el=this.editor.body}if($el.is(":empty")){$el.append("<p>"+this.editor.util.phBr+"</p>");return $el}ref=$el.contents();for(k=0,len=ref.length;k<len;k++){n=ref[k];this.cleanNode(n,true)}ref1=$el.contents();for(l=0,len1=ref1.length;l<len1;l++){node=ref1[l];$node=$(node);if($node.is("br")){if(typeof blockNode!=="undefined"&&blockNode!==null){blockNode=null}$node.remove()}else{if(this.editor.util.isBlockNode(node)){if($node.is("li")){if(blockNode&&blockNode.is("ul, ol")){blockNode.append(node)}else{blockNode=$("<ul/>").insertBefore(node);blockNode.append(node)}}else{blockNode=null}}else{if(!blockNode||blockNode.is("ul, ol")){blockNode=$("<p/>").insertBefore(node)}blockNode.append(node);if(this.editor.util.isEmptyNode(blockNode)){blockNode.append(this.editor.util.phBr)}}}}return $el};Formatter.prototype.cleanNode=function(node,recursive){var $blockEls,$childImg,$node,$p,$td,allowedAttributes,attr,contents,isDecoration,k,l,len,len1,n,ref,ref1,text,textNode;$node=$(node);if(!($node.length>0)){return}if($node[0].nodeType===3){text=$node.text().replace(/(\r\n|\n|\r)/gm,"");if(text){textNode=document.createTextNode(text);$node.replaceWith(textNode)}else{$node.remove()}return}contents=$node.is("iframe")?null:$node.contents();isDecoration=this.editor.util.isDecoratedNode($node);if($node.is(this._allowedTags.join(","))||isDecoration){if($node.is("a")&&($childImg=$node.find("img")).length>0){$node.replaceWith($childImg);$node=$childImg;contents=null}if($node.is("td")&&($blockEls=$node.find(this.editor.util.blockNodes.join(","))).length>0){$blockEls.each((function(_this){return function(i,blockEl){return $(blockEl).contents().unwrap()
|
|
9
|
+}})(this));contents=$node.contents()}if($node.is("img")&&$node.hasClass("uploading")){$node.remove()}if(!isDecoration){allowedAttributes=this._allowedAttributes[$node[0].tagName.toLowerCase()];ref=$.makeArray($node[0].attributes);for(k=0,len=ref.length;k<len;k++){attr=ref[k];if(attr.name==="style"){continue}if(!((allowedAttributes!=null)&&(ref1=attr.name,indexOf.call(allowedAttributes,ref1)>=0))){$node.removeAttr(attr.name)}}this._cleanNodeStyles($node);if($node.is("span")&&$node[0].attributes.length===0){$node.contents().first().unwrap()}}}else{if($node[0].nodeType===1&&!$node.is(":empty")){if($node.is("div, article, dl, header, footer, tr")){$node.append("<br/>");contents.first().unwrap()}else{if($node.is("table")){$p=$("<p/>");$node.find("tr").each(function(i,tr){return $p.append($(tr).text()+"<br/>")});$node.replaceWith($p);contents=null}else{if($node.is("thead, tfoot")){$node.remove();contents=null}else{if($node.is("th")){$td=$("<td/>").append($node.contents());$node.replaceWith($td)}else{contents.first().unwrap()}}}}}else{$node.remove();contents=null}}if(recursive&&(contents!=null)&&!$node.is("pre")){for(l=0,len1=contents.length;l<len1;l++){n=contents[l];this.cleanNode(n,true)}}return null};Formatter.prototype._cleanNodeStyles=function($node){var allowedStyles,k,len,pair,ref,ref1,style,styleStr,styles;styleStr=$node.attr("style");if(!styleStr){return}$node.removeAttr("style");allowedStyles=this._allowedStyles[$node[0].tagName.toLowerCase()];if(!(allowedStyles&&allowedStyles.length>0)){return $node}styles={};ref=styleStr.split(";");for(k=0,len=ref.length;k<len;k++){style=ref[k];style=$.trim(style);pair=style.split(":");if(!(pair.length=2)){continue}if(ref1=pair[0],indexOf.call(allowedStyles,ref1)>=0){styles[$.trim(pair[0])]=$.trim(pair[1])}}if(Object.keys(styles).length>0){$node.css(styles)}return $node};Formatter.prototype.clearHtml=function(html,lineBreak){var container,contents,result;if(lineBreak==null){lineBreak=true}container=$("<div/>").append(html);contents=container.contents();result="";contents.each((function(_this){return function(i,node){var $node,children;if(node.nodeType===3){return result+=node.nodeValue}else{if(node.nodeType===1){$node=$(node);children=$node.is("iframe")?null:$node.contents();if(children&&children.length>0){result+=_this.clearHtml(children)}if(lineBreak&&i<contents.length-1&&$node.is("br, p, div, li,tr, pre, address, artticle, aside, dl, figcaption, footer, h1, h2,h3, h4, header")){return result+="\n"}}}}})(this));return result};Formatter.prototype.beautify=function($contents){var uselessP;uselessP=function($el){return !!($el.is("p")&&!$el.text()&&$el.children(":not(br)").length<1)};return $contents.each(function(i,el){var $el,invalid;$el=$(el);invalid=$el.is(':not(img, br, col, td, hr, [class^="simditor-"]):empty');if(invalid||uselessP($el)){$el.remove()}return $el.find(':not(img, br, col, td, hr, [class^="simditor-"]):empty').remove()})};return Formatter})(SimpleModule);InputManager=(function(superClass){extend(InputManager,superClass);function InputManager(){return InputManager.__super__.constructor.apply(this,arguments)}InputManager.pluginName="InputManager";InputManager.prototype._modifierKeys=[16,17,18,91,93,224];InputManager.prototype._arrowKeys=[37,38,39,40];InputManager.prototype._init=function(){var selectAllKey,submitKey;this.editor=this._module;this.throttledValueChanged=this.editor.util.throttle((function(_this){return function(params){return setTimeout(function(){return _this.editor.trigger("valuechanged",params)},10)}})(this),300);this.throttledSelectionChanged=this.editor.util.throttle((function(_this){return function(){return _this.editor.trigger("selectionchanged")}})(this),50);$(document).on("selectionchange.simditor"+this.editor.id,(function(_this){return function(e){var triggerEvent;if(!(_this.focused&&!_this.editor.clipboard.pasting)){return}triggerEvent=function(){if(_this._selectionTimer){clearTimeout(_this._selectionTimer);_this._selectionTimer=null}if(_this.editor.selection._selection.rangeCount>0){return _this.throttledSelectionChanged()}else{return _this._selectionTimer=setTimeout(function(){_this._selectionTimer=null;if(_this.focused){return triggerEvent()}},10)}};return triggerEvent()}})(this));this.editor.on("valuechanged",(function(_this){return function(){var $rootBlocks;_this.lastCaretPosition=null;$rootBlocks=_this.editor.body.children().filter(function(i,node){return _this.editor.util.isBlockNode(node)});if(_this.focused&&$rootBlocks.length===0){_this.editor.selection.save();_this.editor.formatter.format();_this.editor.selection.restore()}_this.editor.body.find("hr, pre, .simditor-table").each(function(i,el){var $el,formatted;$el=$(el);if($el.parent().is("blockquote")||$el.parent()[0]===_this.editor.body[0]){formatted=false;if($el.next().length===0){$("<p/>").append(_this.editor.util.phBr).insertAfter($el);formatted=true}if($el.prev().length===0){$("<p/>").append(_this.editor.util.phBr).insertBefore($el);formatted=true}if(formatted){return _this.throttledValueChanged()
|
|
10
|
+}}});_this.editor.body.find("pre:empty").append(_this.editor.util.phBr);if(!_this.editor.util.support.onselectionchange&&_this.focused){return _this.throttledSelectionChanged()}}})(this));this.editor.body.on("keydown",$.proxy(this._onKeyDown,this)).on("keypress",$.proxy(this._onKeyPress,this)).on("keyup",$.proxy(this._onKeyUp,this)).on("mouseup",$.proxy(this._onMouseUp,this)).on("focus",$.proxy(this._onFocus,this)).on("blur",$.proxy(this._onBlur,this)).on("drop",$.proxy(this._onDrop,this)).on("input",$.proxy(this._onInput,this));if(this.editor.util.browser.firefox){this.editor.hotkeys.add("cmd+left",(function(_this){return function(e){e.preventDefault();_this.editor.selection._selection.modify("move","backward","lineboundary");return false}})(this));this.editor.hotkeys.add("cmd+right",(function(_this){return function(e){e.preventDefault();_this.editor.selection._selection.modify("move","forward","lineboundary");return false}})(this));selectAllKey=this.editor.util.os.mac?"cmd+a":"ctrl+a";this.editor.hotkeys.add(selectAllKey,(function(_this){return function(e){var $children,firstBlock,lastBlock,range;$children=_this.editor.body.children();if(!($children.length>0)){return}firstBlock=$children.first().get(0);lastBlock=$children.last().get(0);range=document.createRange();range.setStart(firstBlock,0);range.setEnd(lastBlock,_this.editor.util.getNodeLength(lastBlock));_this.editor.selection.range(range);return false}})(this))}submitKey=this.editor.util.os.mac?"cmd+enter":"ctrl+enter";return this.editor.hotkeys.add(submitKey,(function(_this){return function(e){_this.editor.el.closest("form").find("button:submit").click();return false}})(this))};InputManager.prototype._onFocus=function(e){if(this.editor.clipboard.pasting){return}this.editor.el.addClass("focus").removeClass("error");this.focused=true;return setTimeout((function(_this){return function(){var $blockEl,range;range=_this.editor.selection._selection.getRangeAt(0);if(range.startContainer===_this.editor.body[0]){if(_this.lastCaretPosition){_this.editor.undoManager.caretPosition(_this.lastCaretPosition)}else{$blockEl=_this.editor.body.children().first();range=document.createRange();_this.editor.selection.setRangeAtStartOf($blockEl,range)}}_this.lastCaretPosition=null;_this.editor.triggerHandler("focus");if(!_this.editor.util.support.onselectionchange){return _this.throttledSelectionChanged()}}})(this),0)};InputManager.prototype._onBlur=function(e){var ref;if(this.editor.clipboard.pasting){return}this.editor.el.removeClass("focus");this.editor.sync();this.focused=false;this.lastCaretPosition=(ref=this.editor.undoManager.currentState())!=null?ref.caret:void 0;return this.editor.triggerHandler("blur")};InputManager.prototype._onMouseUp=function(e){if(!this.editor.util.support.onselectionchange){return this.throttledSelectionChanged()}};InputManager.prototype._onKeyDown=function(e){var ref,ref1;if(this.editor.triggerHandler(e)===false){return false}if(this.editor.hotkeys.respondTo(e)){return}if(this.editor.keystroke.respondTo(e)){this.throttledValueChanged();return false}if((ref=e.which,indexOf.call(this._modifierKeys,ref)>=0)||(ref1=e.which,indexOf.call(this._arrowKeys,ref1)>=0)){return}if(this.editor.util.metaKey(e)&&e.which===86){return}if(!this.editor.util.support.oninput){this.throttledValueChanged(["typing"])}return null};InputManager.prototype._onKeyPress=function(e){if(this.editor.triggerHandler(e)===false){return false}};InputManager.prototype._onKeyUp=function(e){var p,ref;if(this.editor.triggerHandler(e)===false){return false}if(!this.editor.util.support.onselectionchange&&(ref=e.which,indexOf.call(this._arrowKeys,ref)>=0)){this.throttledValueChanged();return}if((e.which===8||e.which===46)&&this.editor.util.isEmptyNode(this.editor.body)){this.editor.body.empty();p=$("<p/>").append(this.editor.util.phBr).appendTo(this.editor.body);this.editor.selection.setRangeAtStartOf(p)}};InputManager.prototype._onDrop=function(e){if(this.editor.triggerHandler(e)===false){return false}return this.throttledValueChanged()};InputManager.prototype._onInput=function(e){return this.throttledValueChanged(["oninput"])};return InputManager})(SimpleModule);Keystroke=(function(superClass){extend(Keystroke,superClass);function Keystroke(){return Keystroke.__super__.constructor.apply(this,arguments)}Keystroke.pluginName="Keystroke";Keystroke.prototype._init=function(){this.editor=this._module;this._keystrokeHandlers={};return this._initKeystrokeHandlers()};Keystroke.prototype.add=function(key,node,handler){key=key.toLowerCase();key=this.editor.hotkeys.constructor.aliases[key]||key;if(!this._keystrokeHandlers[key]){this._keystrokeHandlers[key]={}}return this._keystrokeHandlers[key][node]=handler};Keystroke.prototype.respondTo=function(e){var base,key,ref,result;key=(ref=this.editor.hotkeys.constructor.keyNameMap[e.which])!=null?ref.toLowerCase():void 0;if(!key){return}if(key in this._keystrokeHandlers){result=typeof(base=this._keystrokeHandlers[key])["*"]==="function"?base["*"](e):void 0;
|
|
11
|
+if(!result){this.editor.selection.startNodes().each((function(_this){return function(i,node){var handler,ref1;if(node.nodeType!==Node.ELEMENT_NODE){return}handler=(ref1=_this._keystrokeHandlers[key])!=null?ref1[node.tagName.toLowerCase()]:void 0;result=typeof handler==="function"?handler(e,$(node)):void 0;if(result===true||result===false){return false}}})(this))}if(result){return true}}};Keystroke.prototype._initKeystrokeHandlers=function(){var titleEnterHandler;if(this.editor.util.browser.safari){this.add("enter","*",(function(_this){return function(e){var $blockEl,$br;if(!e.shiftKey){return}$blockEl=_this.editor.selection.blockNodes().last();if($blockEl.is("pre")){return}$br=$("<br/>");if(_this.editor.selection.rangeAtEndOf($blockEl)){_this.editor.selection.insertNode($br);_this.editor.selection.insertNode($("<br/>"));_this.editor.selection.setRangeBefore($br)}else{_this.editor.selection.insertNode($br)}return true}})(this))}if(this.editor.util.browser.webkit||this.editor.util.browser.msie){titleEnterHandler=(function(_this){return function(e,$node){var $p;if(!_this.editor.selection.rangeAtEndOf($node)){return}$p=$("<p/>").append(_this.editor.util.phBr).insertAfter($node);_this.editor.selection.setRangeAtStartOf($p);return true}})(this);this.add("enter","h1",titleEnterHandler);this.add("enter","h2",titleEnterHandler);this.add("enter","h3",titleEnterHandler);this.add("enter","h4",titleEnterHandler);this.add("enter","h5",titleEnterHandler);this.add("enter","h6",titleEnterHandler)}this.add("backspace","*",(function(_this){return function(e){var $blockEl,$prevBlockEl,$rootBlock,isWebkit;$rootBlock=_this.editor.selection.rootNodes().first();$prevBlockEl=$rootBlock.prev();if($prevBlockEl.is("hr")&&_this.editor.selection.rangeAtStartOf($rootBlock)){_this.editor.selection.save();$prevBlockEl.remove();_this.editor.selection.restore();return true}$blockEl=_this.editor.selection.blockNodes().last();isWebkit=_this.editor.util.browser.webkit;if(isWebkit&&_this.editor.selection.rangeAtStartOf($blockEl)){_this.editor.selection.save();_this.editor.formatter.cleanNode($blockEl,true);_this.editor.selection.restore();return null}}})(this));this.add("enter","li",(function(_this){return function(e,$node){var $cloneNode,listEl,newBlockEl,newListEl;$cloneNode=$node.clone();$cloneNode.find("ul, ol").remove();if(!(_this.editor.util.isEmptyNode($cloneNode)&&$node.is(_this.editor.selection.blockNodes().last()))){return}listEl=$node.parent();if($node.next("li").length>0){if(!_this.editor.util.isEmptyNode($node)){return}if(listEl.parent("li").length>0){newBlockEl=$("<li/>").append(_this.editor.util.phBr).insertAfter(listEl.parent("li"));newListEl=$("<"+listEl[0].tagName+"/>").append($node.nextAll("li"));newBlockEl.append(newListEl)}else{newBlockEl=$("<p/>").append(_this.editor.util.phBr).insertAfter(listEl);newListEl=$("<"+listEl[0].tagName+"/>").append($node.nextAll("li"));newBlockEl.after(newListEl)}}else{if(listEl.parent("li").length>0){newBlockEl=$("<li/>").insertAfter(listEl.parent("li"));if($node.contents().length>0){newBlockEl.append($node.contents())}else{newBlockEl.append(_this.editor.util.phBr)}}else{newBlockEl=$("<p/>").append(_this.editor.util.phBr).insertAfter(listEl);if($node.children("ul, ol").length>0){newBlockEl.after($node.children("ul, ol"))}}}if($node.prev("li").length){$node.remove()}else{listEl.remove()}_this.editor.selection.setRangeAtStartOf(newBlockEl);return true}})(this));this.add("enter","pre",(function(_this){return function(e,$node){var $p,breakNode,range;e.preventDefault();if(e.shiftKey){$p=$("<p/>").append(_this.editor.util.phBr).insertAfter($node);_this.editor.selection.setRangeAtStartOf($p);return true}range=_this.editor.selection.range();breakNode=null;range.deleteContents();if(!_this.editor.util.browser.msie&&_this.editor.selection.rangeAtEndOf($node)){breakNode=document.createTextNode("\n\n");range.insertNode(breakNode);range.setEnd(breakNode,1)}else{breakNode=document.createTextNode("\n");range.insertNode(breakNode);range.setStartAfter(breakNode)}range.collapse(false);_this.editor.selection.range(range);return true}})(this));this.add("enter","blockquote",(function(_this){return function(e,$node){var $closestBlock,range;$closestBlock=_this.editor.selection.blockNodes().last();if(!($closestBlock.is("p")&&!$closestBlock.next().length&&_this.editor.util.isEmptyNode($closestBlock))){return}$node.after($closestBlock);range=document.createRange();_this.editor.selection.setRangeAtStartOf($closestBlock,range);return true}})(this));this.add("backspace","li",(function(_this){return function(e,$node){var $br,$childList,$newLi,$prevChildList,$prevNode,$textNode,isFF,range,text;$childList=$node.children("ul, ol");$prevNode=$node.prev("li");if(!($childList.length>0&&$prevNode.length>0)){return false}text="";$textNode=null;$node.contents().each(function(i,n){if(n.nodeType===1&&/UL|OL/.test(n.nodeName)){return false}if(n.nodeType===1&&/BR/.test(n.nodeName)){return}if(n.nodeType===3&&n.nodeValue){text+=n.nodeValue}else{if(n.nodeType===1){text+=$(n).text()
|
|
12
|
+}}return $textNode=$(n)});isFF=_this.editor.util.browser.firefox&&!$textNode.next("br").length;if($textNode&&text.length===1&&isFF){$br=$(_this.editor.util.phBr).insertAfter($textNode);$textNode.remove();_this.editor.selection.setRangeBefore($br);return true}else{if(text.length>0){return false}}range=document.createRange();$prevChildList=$prevNode.children("ul, ol");if($prevChildList.length>0){$newLi=$("<li/>").append(_this.editor.util.phBr).appendTo($prevChildList);$prevChildList.append($childList.children("li"));$node.remove();_this.editor.selection.setRangeAtEndOf($newLi,range)}else{_this.editor.selection.setRangeAtEndOf($prevNode,range);$prevNode.append($childList);$node.remove();_this.editor.selection.range(range)}return true}})(this));this.add("backspace","pre",(function(_this){return function(e,$node){var $newNode,codeStr,range;if(!_this.editor.selection.rangeAtStartOf($node)){return}codeStr=$node.html().replace("\n","<br/>")||_this.editor.util.phBr;$newNode=$("<p/>").append(codeStr).insertAfter($node);$node.remove();range=document.createRange();_this.editor.selection.setRangeAtStartOf($newNode,range);return true}})(this));return this.add("backspace","blockquote",(function(_this){return function(e,$node){var $firstChild,range;if(!_this.editor.selection.rangeAtStartOf($node)){return}$firstChild=$node.children().first().unwrap();range=document.createRange();_this.editor.selection.setRangeAtStartOf($firstChild,range);return true}})(this))};return Keystroke})(SimpleModule);UndoManager=(function(superClass){extend(UndoManager,superClass);function UndoManager(){return UndoManager.__super__.constructor.apply(this,arguments)}UndoManager.pluginName="UndoManager";UndoManager.prototype._index=-1;UndoManager.prototype._capacity=20;UndoManager.prototype._startPosition=null;UndoManager.prototype._endPosition=null;UndoManager.prototype._init=function(){var redoShortcut,undoShortcut;this.editor=this._module;this._stack=[];if(this.editor.util.os.mac){undoShortcut="cmd+z";redoShortcut="shift+cmd+z"}else{if(this.editor.util.os.win){undoShortcut="ctrl+z";redoShortcut="ctrl+y"}else{undoShortcut="ctrl+z";redoShortcut="shift+ctrl+z"}}this.editor.hotkeys.add(undoShortcut,(function(_this){return function(e){e.preventDefault();_this.undo();return false}})(this));this.editor.hotkeys.add(redoShortcut,(function(_this){return function(e){e.preventDefault();_this.redo();return false}})(this));this.throttledPushState=this.editor.util.throttle((function(_this){return function(){return _this._pushUndoState()}})(this),2000);this.editor.on("valuechanged",(function(_this){return function(e,src){if(src==="undo"||src==="redo"){return}return _this.throttledPushState()}})(this));this.editor.on("selectionchanged",(function(_this){return function(e){_this.resetCaretPosition();return _this.update()}})(this));this.editor.on("focus",(function(_this){return function(e){if(_this._stack.length===0){return _this._pushUndoState()}}})(this));return this.editor.on("blur",(function(_this){return function(e){return _this.resetCaretPosition()}})(this))};UndoManager.prototype.resetCaretPosition=function(){this._startPosition=null;return this._endPosition=null};UndoManager.prototype.startPosition=function(){if(this.editor.selection._range){this._startPosition||(this._startPosition=this._getPosition("start"))}return this._startPosition};UndoManager.prototype.endPosition=function(){if(this.editor.selection._range){this._endPosition||(this._endPosition=(function(_this){return function(){var range;range=_this.editor.selection.range();if(range.collapsed){return _this._startPosition}return _this._getPosition("end")}})(this)())}return this._endPosition};UndoManager.prototype._pushUndoState=function(){var caret;if(this.editor.triggerHandler("pushundostate")===false){return}caret=this.caretPosition();if(!caret.start){return}this._index+=1;this._stack.length=this._index;this._stack.push({html:this.editor.body.html(),caret:this.caretPosition()});if(this._stack.length>this._capacity){this._stack.shift();return this._index-=1}};UndoManager.prototype.currentState=function(){if(this._stack.length&&this._index>-1){return this._stack[this._index]}else{return null}};UndoManager.prototype.undo=function(){var state;if(this._index<1||this._stack.length<2){return}this.editor.hidePopover();this._index-=1;state=this._stack[this._index];this.editor.body.get(0).innerHTML=state.html;this.caretPosition(state.caret);this.editor.body.find(".selected").removeClass("selected");this.editor.sync();return this.editor.trigger("valuechanged",["undo"])};UndoManager.prototype.redo=function(){var state;if(this._index<0||this._stack.length<this._index+2){return}this.editor.hidePopover();this._index+=1;state=this._stack[this._index];this.editor.body.get(0).innerHTML=state.html;this.caretPosition(state.caret);this.editor.body.find(".selected").removeClass("selected");this.editor.sync();return this.editor.trigger("valuechanged",["redo"])};UndoManager.prototype.update=function(){var currentState;currentState=this.currentState();
|
|
13
|
+if(!currentState){return}currentState.html=this.editor.body.html();return currentState.caret=this.caretPosition()};UndoManager.prototype._getNodeOffset=function(node,index){var $parent,merging,offset;if($.isNumeric(index)){$parent=$(node)}else{$parent=$(node).parent()}offset=0;merging=false;$parent.contents().each(function(i,child){if(node===child||(index===i&&i===0)){return false}if(child.nodeType===Node.TEXT_NODE){if(!merging&&child.nodeValue.length>0){offset+=1;merging=true}}else{offset+=1;merging=false}if(index-1===i){return false}return null});return offset};UndoManager.prototype._getPosition=function(type){var $nodes,node,nodes,offset,position,prevNode,range;if(type==null){type="start"}range=this.editor.selection.range();offset=range[type+"Offset"];$nodes=this.editor.selection[type+"Nodes"]();node=$nodes.first()[0];if(node.nodeType===Node.TEXT_NODE){prevNode=node.previousSibling;while(prevNode&&prevNode.nodeType===Node.TEXT_NODE){node=prevNode;offset+=this.editor.util.getNodeLength(prevNode);prevNode=prevNode.previousSibling}nodes=$nodes.get();nodes[0]=node;$nodes=$(nodes)}else{offset=this._getNodeOffset(node,offset)}position=[offset];$nodes.each((function(_this){return function(i,node){return position.unshift(_this._getNodeOffset(node))}})(this));return position};UndoManager.prototype._getNodeByPosition=function(position){var child,childNodes,i,k,len,node,offset,ref;node=this.editor.body[0];ref=position.slice(0,position.length-1);for(i=k=0,len=ref.length;k<len;i=++k){offset=ref[i];childNodes=node.childNodes;if(offset>childNodes.length-1){if(i===position.length-2&&$(node).is("pre:empty")){child=document.createTextNode("");node.appendChild(child);childNodes=node.childNodes}else{node=null;break}}node=childNodes[offset]}return node};UndoManager.prototype.caretPosition=function(caret){var endContainer,endOffset,range,startContainer,startOffset;if(!caret){range=this.editor.selection.range();caret=this.editor.inputManager.focused&&(range!=null)?{start:this.startPosition(),end:this.endPosition(),collapsed:range.collapsed}:{};return caret}else{if(!caret.start){return}startContainer=this._getNodeByPosition(caret.start);startOffset=caret.start[caret.start.length-1];if(caret.collapsed){endContainer=startContainer;endOffset=startOffset}else{endContainer=this._getNodeByPosition(caret.end);endOffset=caret.start[caret.start.length-1]}if(!startContainer||!endContainer){if(typeof console!=="undefined"&&console!==null){if(typeof console.warn==="function"){console.warn("simditor: invalid caret state")}}return}range=document.createRange();range.setStart(startContainer,startOffset);range.setEnd(endContainer,endOffset);return this.editor.selection.range(range)}};return UndoManager})(SimpleModule);Util=(function(superClass){extend(Util,superClass);function Util(){return Util.__super__.constructor.apply(this,arguments)}Util.pluginName="Util";Util.prototype._init=function(){this.editor=this._module;if(this.browser.msie&&this.browser.version<11){return this.phBr=""}};Util.prototype.phBr="<br/>";Util.prototype.os=(function(){var os;os={};if(/Mac/.test(navigator.appVersion)){os.mac=true}else{if(/Linux/.test(navigator.appVersion)){os.linux=true}else{if(/Win/.test(navigator.appVersion)){os.win=true}else{if(/X11/.test(navigator.appVersion)){os.unix=true}}}}if(/Mobi/.test(navigator.appVersion)){os.mobile=true}return os})();Util.prototype.browser=(function(){var chrome,edge,firefox,ie,ref,ref1,ref2,ref3,ref4,safari,ua;ua=navigator.userAgent;ie=/(msie|trident)/i.test(ua);chrome=/chrome|crios/i.test(ua);safari=/safari/i.test(ua)&&!chrome;firefox=/firefox/i.test(ua);edge=/edge/i.test(ua);if(ie){return{msie:true,version:((ref=ua.match(/(msie |rv:)(\d+(\.\d+)?)/i))!=null?ref[2]:void 0)*1}}else{if(edge){return{edge:true,webkit:true,version:((ref1=ua.match(/edge\/(\d+(\.\d+)?)/i))!=null?ref1[1]:void 0)*1}}else{if(chrome){return{webkit:true,chrome:true,version:((ref2=ua.match(/(?:chrome|crios)\/(\d+(\.\d+)?)/i))!=null?ref2[1]:void 0)*1}}else{if(safari){return{webkit:true,safari:true,version:((ref3=ua.match(/version\/(\d+(\.\d+)?)/i))!=null?ref3[1]:void 0)*1}}else{if(firefox){return{mozilla:true,firefox:true,version:((ref4=ua.match(/firefox\/(\d+(\.\d+)?)/i))!=null?ref4[1]:void 0)*1}}else{return{}}}}}}})();Util.prototype.support=(function(){return{onselectionchange:(function(){var e,onselectionchange;onselectionchange=document.onselectionchange;if(onselectionchange!==void 0){try{document.onselectionchange=0;return document.onselectionchange===null}catch(_error){e=_error}finally{document.onselectionchange=onselectionchange}}return false})(),oninput:(function(){return !/(msie|trident)/i.test(navigator.userAgent)})()}})();Util.prototype.reflow=function(el){if(el==null){el=document}return $(el)[0].offsetHeight};Util.prototype.metaKey=function(e){var isMac;isMac=/Mac/.test(navigator.userAgent);if(isMac){return e.metaKey}else{return e.ctrlKey}};Util.prototype.isEmptyNode=function(node){var $node;$node=$(node);return $node.is(":empty")||(!$node.text()&&!$node.find(":not(br, span, div)").length)
|
|
14
|
+};Util.prototype.isDecoratedNode=function(node){return $(node).is('[class^="simditor-"]')};Util.prototype.blockNodes=["div","p","ul","ol","li","blockquote","hr","pre","h1","h2","h3","h4","h5","table"];Util.prototype.isBlockNode=function(node){node=$(node)[0];if(!node||node.nodeType===3){return false}return new RegExp("^("+(this.blockNodes.join("|"))+")$").test(node.nodeName.toLowerCase())};Util.prototype.getNodeLength=function(node){node=$(node)[0];switch(node.nodeType){case 7:case 10:return 0;case 3:case 8:return node.length;default:return node.childNodes.length}};Util.prototype.dataURLtoBlob=function(dataURL){var BlobBuilder,arrayBuffer,bb,blobArray,byteString,hasArrayBufferViewSupport,hasBlobConstructor,i,intArray,k,mimeString,ref,supportBlob;hasBlobConstructor=window.Blob&&(function(){var e;try{return Boolean(new Blob())}catch(_error){e=_error;return false}})();hasArrayBufferViewSupport=hasBlobConstructor&&window.Uint8Array&&(function(){var e;try{return new Blob([new Uint8Array(100)]).size===100}catch(_error){e=_error;return false}})();BlobBuilder=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;supportBlob=hasBlobConstructor||BlobBuilder;if(!(supportBlob&&window.atob&&window.ArrayBuffer&&window.Uint8Array)){return false}if(dataURL.split(",")[0].indexOf("base64")>=0){byteString=atob(dataURL.split(",")[1])}else{byteString=decodeURIComponent(dataURL.split(",")[1])}arrayBuffer=new ArrayBuffer(byteString.length);intArray=new Uint8Array(arrayBuffer);for(i=k=0,ref=byteString.length;0<=ref?k<=ref:k>=ref;i=0<=ref?++k:--k){intArray[i]=byteString.charCodeAt(i)}mimeString=dataURL.split(",")[0].split(":")[1].split(";")[0];if(hasBlobConstructor){blobArray=hasArrayBufferViewSupport?intArray:arrayBuffer;return new Blob([blobArray],{type:mimeString})}bb=new BlobBuilder();bb.append(arrayBuffer);return bb.getBlob(mimeString)};Util.prototype.throttle=function(func,wait){var args,call,ctx,last,rtn,throttled,timeoutID;last=0;timeoutID=0;ctx=args=rtn=null;call=function(){timeoutID=0;last=+new Date();rtn=func.apply(ctx,args);ctx=null;return args=null};throttled=function(){var delta;ctx=this;args=arguments;delta=new Date()-last;if(!timeoutID){if(delta>=wait){call()}else{timeoutID=setTimeout(call,wait-delta)}}return rtn};throttled.clear=function(){if(!timeoutID){return}clearTimeout(timeoutID);return call()};return throttled};Util.prototype.formatHTML=function(html){var cursor,indentString,lastMatch,level,match,re,repeatString,result,str;re=/<(\/?)(.+?)(\/?)>/g;result="";level=0;lastMatch=null;indentString=" ";repeatString=function(str,n){return new Array(n+1).join(str)};while((match=re.exec(html))!==null){match.isBlockNode=$.inArray(match[2],this.blockNodes)>-1;match.isStartTag=match[1]!=="/"&&match[3]!=="/";match.isEndTag=match[1]==="/"||match[3]==="/";cursor=lastMatch?lastMatch.index+lastMatch[0].length:0;if((str=html.substring(cursor,match.index)).length>0&&$.trim(str)){result+=str}if(match.isBlockNode&&match.isEndTag&&!match.isStartTag){level-=1}if(match.isBlockNode&&match.isStartTag){if(!(lastMatch&&lastMatch.isBlockNode&&lastMatch.isEndTag)){result+="\n"}result+=repeatString(indentString,level)}result+=match[0];if(match.isBlockNode&&match.isEndTag){result+="\n"}if(match.isBlockNode&&match.isStartTag){level+=1}lastMatch=match}return $.trim(result)};return Util})(SimpleModule);Toolbar=(function(superClass){extend(Toolbar,superClass);function Toolbar(){return Toolbar.__super__.constructor.apply(this,arguments)}Toolbar.pluginName="Toolbar";Toolbar.prototype.opts={toolbar:true,toolbarFloat:true,toolbarHidden:false,toolbarFloatOffset:0};Toolbar.prototype._tpl={wrapper:'<div class="simditor-toolbar"><ul></ul></div>',separator:'<li><span class="separator"></span></li>'};Toolbar.prototype._init=function(){var floatInitialized,initToolbarFloat,toolbarHeight;this.editor=this._module;if(!this.opts.toolbar){return}if(!$.isArray(this.opts.toolbar)){this.opts.toolbar=["bold","italic","underline","strikethrough","|","ol","ul","blockquote","code","|","link","image","|","indent","outdent"]}this._render();this.list.on("click",function(e){return false});this.wrapper.on("mousedown",(function(_this){return function(e){return _this.list.find(".menu-on").removeClass(".menu-on")}})(this));$(document).on("mousedown.simditor"+this.editor.id,(function(_this){return function(e){return _this.list.find(".menu-on").removeClass(".menu-on")}})(this));if(!this.opts.toolbarHidden&&this.opts.toolbarFloat){this.wrapper.css("top",this.opts.toolbarFloatOffset);toolbarHeight=0;initToolbarFloat=(function(_this){return function(){_this.wrapper.css("position","static");_this.wrapper.width("auto");_this.editor.util.reflow(_this.wrapper);_this.wrapper.width(_this.wrapper.outerWidth());_this.wrapper.css("left",_this.editor.util.os.mobile?_this.wrapper.position().left:_this.wrapper.offset().left);_this.wrapper.css("position","");_this.editor.wrapper.width(_this.wrapper.outerWidth());toolbarHeight=_this.wrapper.outerHeight();_this.editor.placeholderEl.css("top",toolbarHeight);
|
|
15
|
+return true}})(this);floatInitialized=null;$(window).on("resize.simditor-"+this.editor.id,function(e){return floatInitialized=initToolbarFloat()});$(window).on("scroll.simditor-"+this.editor.id,(function(_this){return function(e){var bottomEdge,scrollTop,topEdge;if(!_this.wrapper.is(":visible")){return}topEdge=_this.editor.wrapper.offset().top;bottomEdge=topEdge+_this.editor.wrapper.outerHeight()-80;scrollTop=$(document).scrollTop()+_this.opts.toolbarFloatOffset;if(scrollTop<=topEdge||scrollTop>=bottomEdge){_this.editor.wrapper.removeClass("toolbar-floating").css("padding-top","");if(_this.editor.util.os.mobile){return _this.wrapper.css("top",_this.opts.toolbarFloatOffset)}}else{floatInitialized||(floatInitialized=initToolbarFloat());_this.editor.wrapper.addClass("toolbar-floating").css("padding-top",toolbarHeight);if(_this.editor.util.os.mobile){return _this.wrapper.css("top",scrollTop-topEdge+_this.opts.toolbarFloatOffset)}}}})(this))}this.editor.on("destroy",(function(_this){return function(){return _this.buttons.length=0}})(this));return $(document).on("mousedown.simditor-"+this.editor.id,(function(_this){return function(e){return _this.list.find("li.menu-on").removeClass("menu-on")}})(this))};Toolbar.prototype._render=function(){var k,len,name,ref;this.buttons=[];this.wrapper=$(this._tpl.wrapper).prependTo(this.editor.wrapper);this.list=this.wrapper.find("ul");ref=this.opts.toolbar;for(k=0,len=ref.length;k<len;k++){name=ref[k];if(name==="|"){$(this._tpl.separator).appendTo(this.list);continue}if(!this.constructor.buttons[name]){throw new Error("simditor: invalid toolbar button "+name);continue}this.buttons.push(new this.constructor.buttons[name]({editor:this.editor}))}if(this.opts.toolbarHidden){return this.wrapper.hide()}};Toolbar.prototype.findButton=function(name){var button;button=this.list.find(".toolbar-item-"+name).data("button");return button!=null?button:null};Toolbar.addButton=function(btn){return this.buttons[btn.prototype.name]=btn};Toolbar.buttons={};return Toolbar})(SimpleModule);Indentation=(function(superClass){extend(Indentation,superClass);function Indentation(){return Indentation.__super__.constructor.apply(this,arguments)}Indentation.pluginName="Indentation";Indentation.prototype.opts={tabIndent:true};Indentation.prototype._init=function(){this.editor=this._module;return this.editor.keystroke.add("tab","*",(function(_this){return function(e){var codeButton;codeButton=_this.editor.toolbar.findButton("code");if(!(_this.opts.tabIndent||(codeButton&&codeButton.active))){return}return _this.indent(e.shiftKey)}})(this))};Indentation.prototype.indent=function(isBackward){var $blockNodes,$endNodes,$startNodes,nodes,result;$startNodes=this.editor.selection.startNodes();$endNodes=this.editor.selection.endNodes();$blockNodes=this.editor.selection.blockNodes();nodes=[];$blockNodes=$blockNodes.each(function(i,node){var include,j,k,len,n;include=true;for(j=k=0,len=nodes.length;k<len;j=++k){n=nodes[j];if($.contains(node,n)){include=false;break}else{if($.contains(n,node)){nodes.splice(j,1,node);include=false;break}}}if(include){return nodes.push(node)}});$blockNodes=$(nodes);result=false;$blockNodes.each((function(_this){return function(i,blockEl){var r;r=isBackward?_this.outdentBlock(blockEl):_this.indentBlock(blockEl);if(r){return result=r}}})(this));return result};Indentation.prototype.indentBlock=function(blockEl){var $blockEl,$childList,$nextTd,$nextTr,$parentLi,$pre,$td,$tr,marginLeft,tagName;$blockEl=$(blockEl);if(!$blockEl.length){return}if($blockEl.is("pre")){$pre=this.editor.selection.containerNode();if(!($pre.is($blockEl)||$pre.closest("pre").is($blockEl))){return}this.indentText(this.editor.selection.range())}else{if($blockEl.is("li")){$parentLi=$blockEl.prev("li");if($parentLi.length<1){return}this.editor.selection.save();tagName=$blockEl.parent()[0].tagName;$childList=$parentLi.children("ul, ol");if($childList.length>0){$childList.append($blockEl)}else{$("<"+tagName+"/>").append($blockEl).appendTo($parentLi)}this.editor.selection.restore()}else{if($blockEl.is("p, h1, h2, h3, h4")){marginLeft=parseInt($blockEl.css("margin-left"))||0;marginLeft=(Math.round(marginLeft/this.opts.indentWidth)+1)*this.opts.indentWidth;$blockEl.css("margin-left",marginLeft)}else{if($blockEl.is("table")||$blockEl.is(".simditor-table")){$td=this.editor.selection.containerNode().closest("td, th");$nextTd=$td.next("td, th");if(!($nextTd.length>0)){$tr=$td.parent("tr");$nextTr=$tr.next("tr");if($nextTr.length<1&&$tr.parent().is("thead")){$nextTr=$tr.parent("thead").next("tbody").find("tr:first")}$nextTd=$nextTr.find("td:first, th:first")}if(!($td.length>0&&$nextTd.length>0)){return}this.editor.selection.setRangeAtEndOf($nextTd)}else{return false}}}}return true};Indentation.prototype.indentText=function(range){var text,textNode;text=range.toString().replace(/^(?=.+)/mg,"\u00A0\u00A0");textNode=document.createTextNode(text||"\u00A0\u00A0");range.deleteContents();range.insertNode(textNode);if(text){range.selectNode(textNode);
|
|
16
|
+return this.editor.selection.range(range)}else{return this.editor.selection.setRangeAfter(textNode)}};Indentation.prototype.outdentBlock=function(blockEl){var $blockEl,$parent,$parentLi,$pre,$prevTd,$prevTr,$td,$tr,marginLeft,range;$blockEl=$(blockEl);if(!($blockEl&&$blockEl.length>0)){return}if($blockEl.is("pre")){$pre=this.editor.selection.containerNode();if(!($pre.is($blockEl)||$pre.closest("pre").is($blockEl))){return}this.outdentText(range)}else{if($blockEl.is("li")){$parent=$blockEl.parent();$parentLi=$parent.parent("li");this.editor.selection.save();if($parentLi.length<1){range=document.createRange();range.setStartBefore($parent[0]);range.setEndBefore($blockEl[0]);$parent.before(range.extractContents());$("<p/>").insertBefore($parent).after($blockEl.children("ul, ol")).append($blockEl.contents());$blockEl.remove()}else{if($blockEl.next("li").length>0){$("<"+$parent[0].tagName+"/>").append($blockEl.nextAll("li")).appendTo($blockEl)}$blockEl.insertAfter($parentLi);if($parent.children("li").length<1){$parent.remove()}}this.editor.selection.restore()}else{if($blockEl.is("p, h1, h2, h3, h4")){marginLeft=parseInt($blockEl.css("margin-left"))||0;marginLeft=Math.max(Math.round(marginLeft/this.opts.indentWidth)-1,0)*this.opts.indentWidth;$blockEl.css("margin-left",marginLeft===0?"":marginLeft)}else{if($blockEl.is("table")||$blockEl.is(".simditor-table")){$td=this.editor.selection.containerNode().closest("td, th");$prevTd=$td.prev("td, th");if(!($prevTd.length>0)){$tr=$td.parent("tr");$prevTr=$tr.prev("tr");if($prevTr.length<1&&$tr.parent().is("tbody")){$prevTr=$tr.parent("tbody").prev("thead").find("tr:first")}$prevTd=$prevTr.find("td:last, th:last")}if(!($td.length>0&&$prevTd.length>0)){return}this.editor.selection.setRangeAtEndOf($prevTd)}else{return false}}}}return true};Indentation.prototype.outdentText=function(range){};return Indentation})(SimpleModule);Clipboard=(function(superClass){extend(Clipboard,superClass);function Clipboard(){return Clipboard.__super__.constructor.apply(this,arguments)}Clipboard.pluginName="Clipboard";Clipboard.prototype.opts={pasteImage:false,cleanPaste:false};Clipboard.prototype._init=function(){this.editor=this._module;if(this.opts.pasteImage&&typeof this.opts.pasteImage!=="string"){this.opts.pasteImage="inline"}return this.editor.body.on("paste",(function(_this){return function(e){var range;if(_this.pasting||_this._pasteBin){return}if(_this.editor.triggerHandler(e)===false){return false}range=_this.editor.selection.deleteRangeContents();if(_this.editor.body.html()){if(!range.collapsed){range.collapse(true)}}else{_this.editor.formatter.format();_this.editor.selection.setRangeAtStartOf(_this.editor.body.find("p:first"))}if(_this._processPasteByClipboardApi(e)){return false}_this.editor.inputManager.throttledValueChanged.clear();_this.editor.inputManager.throttledSelectionChanged.clear();_this.editor.undoManager.throttledPushState.clear();_this.editor.selection.reset();_this.editor.undoManager.resetCaretPosition();_this.pasting=true;return _this._getPasteContent(function(pasteContent){_this._processPasteContent(pasteContent);_this._pasteInBlockEl=null;_this._pastePlainText=null;return _this.pasting=false})}})(this))};Clipboard.prototype._processPasteByClipboardApi=function(e){var imageFile,pasteItem,ref,uploadOpt;if(this.editor.util.browser.edge){return}if(e.originalEvent.clipboardData&&e.originalEvent.clipboardData.items&&e.originalEvent.clipboardData.items.length>0){pasteItem=e.originalEvent.clipboardData.items[0];if(/^image\//.test(pasteItem.type)){imageFile=pasteItem.getAsFile();if(!((imageFile!=null)&&this.opts.pasteImage)){return}if(!imageFile.name){imageFile.name="Clipboard Image.png"}if(this.editor.triggerHandler("pasting",[imageFile])===false){return}uploadOpt={};uploadOpt[this.opts.pasteImage]=true;if((ref=this.editor.uploader)!=null){ref.upload(imageFile,uploadOpt)}return true}}};Clipboard.prototype._getPasteContent=function(callback){var state;this._pasteBin=$('<div contenteditable="true" />').addClass("simditor-paste-bin").attr("tabIndex","-1").appendTo(this.editor.el);state={html:this.editor.body.html(),caret:this.editor.undoManager.caretPosition()};this._pasteBin.focus();return setTimeout((function(_this){return function(){var pasteContent;_this.editor.hidePopover();_this.editor.body.get(0).innerHTML=state.html;_this.editor.undoManager.caretPosition(state.caret);_this.editor.body.focus();_this.editor.selection.reset();_this.editor.selection.range();_this._pasteInBlockEl=_this.editor.selection.blockNodes().last();_this._pastePlainText=_this.opts.cleanPaste||_this._pasteInBlockEl.is("pre, table");if(_this._pastePlainText){pasteContent=_this.editor.formatter.clearHtml(_this._pasteBin.html(),true)}else{pasteContent=$("<div/>").append(_this._pasteBin.contents());pasteContent.find("table colgroup").remove();_this.editor.formatter.format(pasteContent);_this.editor.formatter.decorate(pasteContent);_this.editor.formatter.beautify(pasteContent.children());pasteContent=pasteContent.contents()
|
|
17
|
+}_this._pasteBin.remove();_this._pasteBin=null;return callback(pasteContent)}})(this),0)};Clipboard.prototype._processPasteContent=function(pasteContent){var $blockEl,$img,blob,children,insertPosition,k,l,lastLine,len,len1,len2,len3,len4,line,lines,m,node,o,q,ref,ref1,ref2,uploadOpt;if(this.editor.triggerHandler("pasting",[pasteContent])===false){return}$blockEl=this._pasteInBlockEl;if(!pasteContent){return}else{if(this._pastePlainText){if($blockEl.is("table")){lines=pasteContent.split("\n");lastLine=lines.pop();for(k=0,len=lines.length;k<len;k++){line=lines[k];this.editor.selection.insertNode(document.createTextNode(line));this.editor.selection.insertNode($("<br/>"))}this.editor.selection.insertNode(document.createTextNode(lastLine))}else{pasteContent=$("<div/>").text(pasteContent);ref=pasteContent.contents();for(l=0,len1=ref.length;l<len1;l++){node=ref[l];this.editor.selection.insertNode($(node)[0])}}}else{if($blockEl.is(this.editor.body)){for(m=0,len2=pasteContent.length;m<len2;m++){node=pasteContent[m];this.editor.selection.insertNode(node)}}else{if(pasteContent.length<1){return}else{if(pasteContent.length===1){if(pasteContent.is("p")){children=pasteContent.contents();if(children.length===1&&children.is("img")){$img=children;if(/^data:image/.test($img.attr("src"))){if(!this.opts.pasteImage){return}blob=this.editor.util.dataURLtoBlob($img.attr("src"));blob.name="Clipboard Image.png";uploadOpt={};uploadOpt[this.opts.pasteImage]=true;if((ref1=this.editor.uploader)!=null){ref1.upload(blob,uploadOpt)}return}else{if($img.is('img[src^="webkit-fake-url://"]')){return}}}for(o=0,len3=children.length;o<len3;o++){node=children[o];this.editor.selection.insertNode(node)}}else{if($blockEl.is("p")&&this.editor.util.isEmptyNode($blockEl)){$blockEl.replaceWith(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}else{if(pasteContent.is("ul, ol")){if(pasteContent.find("li").length===1){pasteContent=$("<div/>").text(pasteContent.text());ref2=pasteContent.contents();for(q=0,len4=ref2.length;q<len4;q++){node=ref2[q];this.editor.selection.insertNode($(node)[0])}}else{if($blockEl.is("li")){$blockEl.parent().after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}else{$blockEl.after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}}}else{$blockEl.after(pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent)}}}}else{if($blockEl.is("li")){$blockEl=$blockEl.parent()}if(this.editor.selection.rangeAtStartOf($blockEl)){insertPosition="before"}else{if(this.editor.selection.rangeAtEndOf($blockEl)){insertPosition="after"}else{this.editor.selection.breakBlockEl($blockEl);insertPosition="before"}}$blockEl[insertPosition](pasteContent);this.editor.selection.setRangeAtEndOf(pasteContent.last())}}}}}return this.editor.inputManager.throttledValueChanged()};return Clipboard})(SimpleModule);Simditor=(function(superClass){extend(Simditor,superClass);function Simditor(){return Simditor.__super__.constructor.apply(this,arguments)}Simditor.connect(Util);Simditor.connect(InputManager);Simditor.connect(Selection);Simditor.connect(UndoManager);Simditor.connect(Keystroke);Simditor.connect(Formatter);Simditor.connect(Toolbar);Simditor.connect(Indentation);Simditor.connect(Clipboard);Simditor.count=0;Simditor.prototype.opts={textarea:null,placeholder:"",defaultImage:"images/image.png",params:{},upload:false,indentWidth:40};Simditor.prototype._init=function(){var e,editor,form,uploadOpts;this.textarea=$(this.opts.textarea);this.opts.placeholder=this.opts.placeholder||this.textarea.attr("placeholder");if(!this.textarea.length){throw new Error("simditor: param textarea is required.");return}editor=this.textarea.data("simditor");if(editor!=null){editor.destroy()}this.id=++Simditor.count;this._render();if(simpleHotkeys){this.hotkeys=simpleHotkeys({el:this.body})}else{throw new Error("simditor: simple-hotkeys is required.");return}if(this.opts.upload&&simpleUploader){uploadOpts=typeof this.opts.upload==="object"?this.opts.upload:{};this.uploader=simpleUploader(uploadOpts)}form=this.textarea.closest("form");if(form.length){form.on("submit.simditor-"+this.id,(function(_this){return function(){return _this.sync()}})(this));form.on("reset.simditor-"+this.id,(function(_this){return function(){return _this.setValue("")}})(this))}this.on("initialized",(function(_this){return function(){if(_this.opts.placeholder){_this.on("valuechanged",function(){return _this._placeholder()})}_this.setValue(_this.textarea.val().trim()||"");if(_this.textarea.attr("autofocus")){return _this.focus()}}})(this));if(this.util.browser.mozilla){this.util.reflow();try{document.execCommand("enableObjectResizing",false,false);return document.execCommand("enableInlineTableEditing",false,false)}catch(_error){e=_error}}};Simditor.prototype._tpl='<div class="simditor">\n <div class="simditor-wrapper">\n <div class="simditor-placeholder"></div>\n <div class="simditor-body" contenteditable="true">\n </div>\n </div>\n</div>';Simditor.prototype._render=function(){var key,ref,results,val;
|
|
18
|
+this.el=$(this._tpl).insertBefore(this.textarea);this.wrapper=this.el.find(".simditor-wrapper");this.body=this.wrapper.find(".simditor-body");this.placeholderEl=this.wrapper.find(".simditor-placeholder").append(this.opts.placeholder);this.el.data("simditor",this);this.wrapper.append(this.textarea);this.textarea.data("simditor",this).blur();this.body.attr("tabindex",this.textarea.attr("tabindex"));if(this.util.os.mac){this.el.addClass("simditor-mac")}else{if(this.util.os.linux){this.el.addClass("simditor-linux")}}if(this.util.os.mobile){this.el.addClass("simditor-mobile")}if(this.opts.params){ref=this.opts.params;results=[];for(key in ref){val=ref[key];results.push($("<input/>",{type:"hidden",name:key,value:val}).insertAfter(this.textarea))}return results}};Simditor.prototype._placeholder=function(){var children;children=this.body.children();if(children.length===0||(children.length===1&&this.util.isEmptyNode(children)&&parseInt(children.css("margin-left")||0)<this.opts.indentWidth)){return this.placeholderEl.show()}else{return this.placeholderEl.hide()}};Simditor.prototype.setValue=function(val){this.hidePopover();this.textarea.val(val);this.body.get(0).innerHTML=val;this.formatter.format();this.formatter.decorate();this.util.reflow(this.body);this.inputManager.lastCaretPosition=null;return this.trigger("valuechanged")};Simditor.prototype.getValue=function(){return this.sync()};Simditor.prototype.sync=function(){var children,cloneBody,emptyP,firstP,lastP,val;cloneBody=this.body.clone();this.formatter.undecorate(cloneBody);this.formatter.format(cloneBody);this.formatter.autolink(cloneBody);children=cloneBody.children();lastP=children.last("p");firstP=children.first("p");while(lastP.is("p")&&this.util.isEmptyNode(lastP)){emptyP=lastP;lastP=lastP.prev("p");emptyP.remove()}while(firstP.is("p")&&this.util.isEmptyNode(firstP)){emptyP=firstP;firstP=lastP.next("p");emptyP.remove()}cloneBody.find("img.uploading").remove();val=$.trim(cloneBody.html());this.textarea.val(val);return val};Simditor.prototype.focus=function(){var $blockEl,range;if(!(this.body.is(":visible")&&this.body.is("[contenteditable]"))){this.el.find("textarea:visible").focus();return}if(this.inputManager.lastCaretPosition){this.undoManager.caretPosition(this.inputManager.lastCaretPosition);return this.inputManager.lastCaretPosition=null}else{$blockEl=this.body.children().last();if(!$blockEl.is("p")){$blockEl=$("<p/>").append(this.util.phBr).appendTo(this.body)}range=document.createRange();return this.selection.setRangeAtEndOf($blockEl,range)}};Simditor.prototype.blur=function(){if(this.body.is(":visible")&&this.body.is("[contenteditable]")){return this.body.blur()}else{return this.body.find("textarea:visible").blur()}};Simditor.prototype.hidePopover=function(){return this.el.find(".simditor-popover").each(function(i,popover){popover=$(popover).data("popover");if(popover.active){return popover.hide()}})};Simditor.prototype.destroy=function(){this.triggerHandler("destroy");this.textarea.closest("form").off(".simditor .simditor-"+this.id);this.selection.clear();this.inputManager.focused=false;this.textarea.insertBefore(this.el).hide().val("").removeData("simditor");this.el.remove();$(document).off(".simditor-"+this.id);$(window).off(".simditor-"+this.id);return this.off()};return Simditor})(SimpleModule);Simditor.i18n={"zh-CN":{"blockquote":"引用","bold":"加粗文字","code":"插入代码","color":"文字颜色","coloredText":"彩色文字","hr":"分隔线","image":"插入图片","externalImage":"外链图片","uploadImage":"上传图片","uploadFailed":"上传失败了","uploadError":"上传出错了","imageUrl":"图片地址","imageSize":"图片尺寸","imageAlt":"图片描述","restoreImageSize":"还原图片尺寸","uploading":"正在上传","indent":"向右缩进","outdent":"向左缩进","italic":"斜体文字","link":"插入链接","linkText":"链接文字","linkUrl":"链接地址","linkTarget":"打开方式","openLinkInCurrentWindow":"在新窗口中打开","openLinkInNewWindow":"在当前窗口中打开","removeLink":"移除链接","ol":"有序列表","ul":"无序列表","strikethrough":"删除线文字","table":"表格","deleteRow":"删除行","insertRowAbove":"在上面插入行","insertRowBelow":"在下面插入行","deleteColumn":"删除列","insertColumnLeft":"在左边插入列","insertColumnRight":"在右边插入列","deleteTable":"删除表格","title":"标题","normalText":"普通文本","underline":"下划线文字","alignment":"水平对齐","alignCenter":"居中","alignLeft":"居左","alignRight":"居右","selectLanguage":"选择程序语言","fontScale":"字体大小","fontScaleXLarge":"超大字体","fontScaleLarge":"大号字体","fontScaleNormal":"正常大小","fontScaleSmall":"小号字体","fontScaleXSmall":"超小字体"},"en-US":{"blockquote":"Block Quote","bold":"Bold","code":"Code","color":"Text Color","coloredText":"Colored Text","hr":"Horizontal Line","image":"Insert Image","externalImage":"External Image","uploadImage":"Upload Image","uploadFailed":"Upload failed","uploadError":"Error occurs during upload","imageUrl":"Url","imageSize":"Size","imageAlt":"Alt","restoreImageSize":"Restore Origin Size","uploading":"Uploading","indent":"Indent","outdent":"Outdent","italic":"Italic","link":"Insert Link","linkText":"Text","linkUrl":"Url","linkTarget":"Target","openLinkInCurrentWindow":"Open link in current window","openLinkInNewWindow":"Open link in new window","removeLink":"Remove Link","ol":"Ordered List","ul":"Unordered List","strikethrough":"Strikethrough","table":"Table","deleteRow":"Delete Row","insertRowAbove":"Insert Row Above","insertRowBelow":"Insert Row Below","deleteColumn":"Delete Column","insertColumnLeft":"Insert Column Left","insertColumnRight":"Insert Column Right","deleteTable":"Delete Table","title":"Title","normalText":"Text","underline":"Underline","alignment":"Alignment","alignCenter":"Align Center","alignLeft":"Align Left","alignRight":"Align Right","selectLanguage":"Select Language","fontScale":"Font Size","fontScaleXLarge":"X Large Size","fontScaleLarge":"Large Size","fontScaleNormal":"Normal Size","fontScaleSmall":"Small Size","fontScaleXSmall":"X Small Size"}};
|
|
19
|
+Button=(function(superClass){extend(Button,superClass);Button.prototype._tpl={item:'<li><a tabindex="-1" unselectable="on" class="toolbar-item" href="javascript:;"><span></span></a></li>',menuWrapper:'<div class="toolbar-menu"></div>',menuItem:'<li><a tabindex="-1" unselectable="on" class="menu-item" href="javascript:;"><span></span></a></li>',separator:'<li><span class="separator"></span></li>'};Button.prototype.name="";Button.prototype.icon="";Button.prototype.title="";Button.prototype.text="";Button.prototype.htmlTag="";Button.prototype.disableTag="";Button.prototype.menu=false;Button.prototype.active=false;Button.prototype.disabled=false;Button.prototype.needFocus=true;Button.prototype.shortcut=null;function Button(opts){this.editor=opts.editor;this.title=this._t(this.name);Button.__super__.constructor.call(this,opts)}Button.prototype._init=function(){var k,len,ref,tag;this.render();this.el.on("mousedown",(function(_this){return function(e){var exceed,noFocus,param;e.preventDefault();noFocus=_this.needFocus&&!_this.editor.inputManager.focused;if(_this.el.hasClass("disabled")||noFocus){return false}if(_this.menu){_this.wrapper.toggleClass("menu-on").siblings("li").removeClass("menu-on");if(_this.wrapper.is(".menu-on")){exceed=_this.menuWrapper.offset().left+_this.menuWrapper.outerWidth()+5-_this.editor.wrapper.offset().left-_this.editor.wrapper.outerWidth();if(exceed>0){_this.menuWrapper.css({"left":"auto","right":0})}_this.trigger("menuexpand")}return false}param=_this.el.data("param");_this.command(param);return false}})(this));this.wrapper.on("click","a.menu-item",(function(_this){return function(e){var btn,noFocus,param;e.preventDefault();btn=$(e.currentTarget);_this.wrapper.removeClass("menu-on");noFocus=_this.needFocus&&!_this.editor.inputManager.focused;if(btn.hasClass("disabled")||noFocus){return false}_this.editor.toolbar.wrapper.removeClass("menu-on");param=btn.data("param");_this.command(param);return false}})(this));this.wrapper.on("mousedown","a.menu-item",function(e){return false});this.editor.on("blur",(function(_this){return function(){var editorActive;editorActive=_this.editor.body.is(":visible")&&_this.editor.body.is("[contenteditable]");if(!(editorActive&&!_this.editor.clipboard.pasting)){return}_this.setActive(false);return _this.setDisabled(false)}})(this));if(this.shortcut!=null){this.editor.hotkeys.add(this.shortcut,(function(_this){return function(e){_this.el.mousedown();return false}})(this))}ref=this.htmlTag.split(",");for(k=0,len=ref.length;k<len;k++){tag=ref[k];tag=$.trim(tag);if(tag&&$.inArray(tag,this.editor.formatter._allowedTags)<0){this.editor.formatter._allowedTags.push(tag)}}return this.editor.on("selectionchanged",(function(_this){return function(e){if(_this.editor.inputManager.focused){return _this._status()}}})(this))};Button.prototype.iconClassOf=function(icon){if(icon){return"simditor-icon simditor-icon-"+icon}else{return""}};Button.prototype.setIcon=function(icon){return this.el.find("span").removeClass().addClass(this.iconClassOf(icon)).text(this.text)};Button.prototype.render=function(){this.wrapper=$(this._tpl.item).appendTo(this.editor.toolbar.list);this.el=this.wrapper.find("a.toolbar-item");this.el.attr("title",this.title).addClass("toolbar-item-"+this.name).data("button",this);this.setIcon(this.icon);if(!this.menu){return}this.menuWrapper=$(this._tpl.menuWrapper).appendTo(this.wrapper);this.menuWrapper.addClass("toolbar-menu-"+this.name);return this.renderMenu()};Button.prototype.renderMenu=function(){var $menuBtnEl,$menuItemEl,k,len,menuItem,ref,ref1,results;if(!$.isArray(this.menu)){return}this.menuEl=$("<ul/>").appendTo(this.menuWrapper);ref=this.menu;results=[];for(k=0,len=ref.length;k<len;k++){menuItem=ref[k];if(menuItem==="|"){$(this._tpl.separator).appendTo(this.menuEl);continue}$menuItemEl=$(this._tpl.menuItem).appendTo(this.menuEl);$menuBtnEl=$menuItemEl.find("a.menu-item").attr({"title":(ref1=menuItem.title)!=null?ref1:menuItem.text,"data-param":menuItem.param}).addClass("menu-item-"+menuItem.name);if(menuItem.icon){results.push($menuBtnEl.find("span").addClass(this.iconClassOf(menuItem.icon)))}else{results.push($menuBtnEl.find("span").text(menuItem.text))}}return results};Button.prototype.setActive=function(active){if(active===this.active){return}this.active=active;return this.el.toggleClass("active",this.active)};Button.prototype.setDisabled=function(disabled){if(disabled===this.disabled){return}this.disabled=disabled;return this.el.toggleClass("disabled",this.disabled)};Button.prototype._disableStatus=function(){var disabled,endNodes,startNodes;startNodes=this.editor.selection.startNodes();endNodes=this.editor.selection.endNodes();disabled=startNodes.filter(this.disableTag).length>0||endNodes.filter(this.disableTag).length>0;this.setDisabled(disabled);if(this.disabled){this.setActive(false)}return this.disabled};Button.prototype._activeStatus=function(){var active,endNode,endNodes,startNode,startNodes;startNodes=this.editor.selection.startNodes();
|
|
20
|
+endNodes=this.editor.selection.endNodes();startNode=startNodes.filter(this.htmlTag);endNode=endNodes.filter(this.htmlTag);active=startNode.length>0&&endNode.length>0&&startNode.is(endNode);this.node=active?startNode:null;this.setActive(active);return this.active};Button.prototype._status=function(){this._disableStatus();if(this.disabled){return}return this._activeStatus()};Button.prototype.command=function(param){};Button.prototype._t=function(){var args,ref,result;args=1<=arguments.length?slice.call(arguments,0):[];result=Button.__super__._t.apply(this,args);if(!result){result=(ref=this.editor)._t.apply(ref,args)}return result};return Button})(SimpleModule);Simditor.Button=Button;Popover=(function(superClass){extend(Popover,superClass);Popover.prototype.offset={top:4,left:0};Popover.prototype.target=null;Popover.prototype.active=false;function Popover(opts){this.button=opts.button;this.editor=opts.button.editor;Popover.__super__.constructor.call(this,opts)}Popover.prototype._init=function(){this.el=$('<div class="simditor-popover"></div>').appendTo(this.editor.el).data("popover",this);this.render();this.el.on("mouseenter",(function(_this){return function(e){return _this.el.addClass("hover")}})(this));return this.el.on("mouseleave",(function(_this){return function(e){return _this.el.removeClass("hover")}})(this))};Popover.prototype.render=function(){};Popover.prototype._initLabelWidth=function(){var $fields;$fields=this.el.find(".settings-field");if(!($fields.length>0)){return}this._labelWidth=0;$fields.each((function(_this){return function(i,field){var $field,$label;$field=$(field);$label=$field.find("label");if(!($label.length>0)){return}return _this._labelWidth=Math.max(_this._labelWidth,$label.width())}})(this));return $fields.find("label").width(this._labelWidth)};Popover.prototype.show=function($target,position){if(position==null){position="bottom"}if($target==null){return}this.el.siblings(".simditor-popover").each(function(i,popover){popover=$(popover).data("popover");if(popover.active){return popover.hide()}});if(this.active&&this.target){this.target.removeClass("selected")}this.target=$target.addClass("selected");if(this.active){this.refresh(position);return this.trigger("popovershow")}else{this.active=true;this.el.css({left:-9999}).show();if(!this._labelWidth){this._initLabelWidth()}this.editor.util.reflow();this.refresh(position);return this.trigger("popovershow")}};Popover.prototype.hide=function(){if(!this.active){return}if(this.target){this.target.removeClass("selected")}this.target=null;this.active=false;this.el.hide();return this.trigger("popoverhide")};Popover.prototype.refresh=function(position){var editorOffset,left,maxLeft,targetH,targetOffset,top;if(position==null){position="bottom"}if(!this.active){return}editorOffset=this.editor.el.offset();targetOffset=this.target.offset();targetH=this.target.outerHeight();if(position==="bottom"){top=targetOffset.top-editorOffset.top+targetH}else{if(position==="top"){top=targetOffset.top-editorOffset.top-this.el.height()}}maxLeft=this.editor.wrapper.width()-this.el.outerWidth()-10;left=Math.min(targetOffset.left-editorOffset.left,maxLeft);return this.el.css({top:top+this.offset.top,left:left+this.offset.left})};Popover.prototype.destroy=function(){this.target=null;this.active=false;this.editor.off(".linkpopover");return this.el.remove()};Popover.prototype._t=function(){var args,ref,result;args=1<=arguments.length?slice.call(arguments,0):[];result=Popover.__super__._t.apply(this,args);if(!result){result=(ref=this.button)._t.apply(ref,args)}return result};return Popover})(SimpleModule);Simditor.Popover=Popover;TitleButton=(function(superClass){extend(TitleButton,superClass);function TitleButton(){return TitleButton.__super__.constructor.apply(this,arguments)}TitleButton.prototype.name="title";TitleButton.prototype.htmlTag="h1, h2, h3, h4, h5";TitleButton.prototype.disableTag="pre, table";TitleButton.prototype._init=function(){this.menu=[{name:"normal",text:this._t("normalText"),param:"p"},"|",{name:"h1",text:this._t("title")+" 1",param:"h1"},{name:"h2",text:this._t("title")+" 2",param:"h2"},{name:"h3",text:this._t("title")+" 3",param:"h3"},{name:"h4",text:this._t("title")+" 4",param:"h4"},{name:"h5",text:this._t("title")+" 5",param:"h5"}];return TitleButton.__super__._init.call(this)};TitleButton.prototype.setActive=function(active,param){TitleButton.__super__.setActive.call(this,active);if(active){param||(param=this.node[0].tagName.toLowerCase())}this.el.removeClass("active-p active-h1 active-h2 active-h3 active-h4 active-h5");if(active){return this.el.addClass("active active-"+param)}};TitleButton.prototype.command=function(param){var $rootNodes;$rootNodes=this.editor.selection.rootNodes();this.editor.selection.save();$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote")||$node.is(param)||$node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)){return}return $("<"+param+"/>").append($node.contents()).replaceAll($node)
|
|
21
|
+}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};return TitleButton})(Button);Simditor.Toolbar.addButton(TitleButton);FontScaleButton=(function(superClass){extend(FontScaleButton,superClass);function FontScaleButton(){return FontScaleButton.__super__.constructor.apply(this,arguments)}FontScaleButton.prototype.name="fontScale";FontScaleButton.prototype.icon="font";FontScaleButton.prototype.disableTag="pre";FontScaleButton.prototype.htmlTag="span";FontScaleButton.prototype.sizeMap={"x-large":"1.5em","large":"1.25em","small":".75em","x-small":".5em"};FontScaleButton.prototype._init=function(){this.menu=[{name:"150%",text:this._t("fontScaleXLarge"),param:"5"},{name:"125%",text:this._t("fontScaleLarge"),param:"4"},{name:"100%",text:this._t("fontScaleNormal"),param:"3"},{name:"75%",text:this._t("fontScaleSmall"),param:"2"},{name:"50%",text:this._t("fontScaleXSmall"),param:"1"}];return FontScaleButton.__super__._init.call(this)};FontScaleButton.prototype._activeStatus=function(){var active,endNode,endNodes,range,startNode,startNodes;range=this.editor.selection.range();startNodes=this.editor.selection.startNodes();endNodes=this.editor.selection.endNodes();startNode=startNodes.filter('span[style*="font-size"]');endNode=endNodes.filter('span[style*="font-size"]');active=startNodes.length>0&&endNodes.length>0&&startNode.is(endNode);this.setActive(active);return this.active};FontScaleButton.prototype.command=function(param){var $scales,containerNode,range;range=this.editor.selection.range();if(range.collapsed){return}document.execCommand("styleWithCSS",false,true);document.execCommand("fontSize",false,param);document.execCommand("styleWithCSS",false,false);this.editor.selection.reset();this.editor.selection.range();containerNode=this.editor.selection.containerNode();if(containerNode[0].nodeType===Node.TEXT_NODE){$scales=containerNode.closest('span[style*="font-size"]')}else{$scales=containerNode.find('span[style*="font-size"]')}$scales.each((function(_this){return function(i,n){var $span,size;$span=$(n);size=n.style.fontSize;if(/large|x-large|small|x-small/.test(size)){return $span.css("fontSize",_this.sizeMap[size])}else{if(size==="medium"){return $span.replaceWith($span.contents())}}}})(this));return this.editor.trigger("valuechanged")};return FontScaleButton})(Button);Simditor.Toolbar.addButton(FontScaleButton);BoldButton=(function(superClass){extend(BoldButton,superClass);function BoldButton(){return BoldButton.__super__.constructor.apply(this,arguments)}BoldButton.prototype.name="bold";BoldButton.prototype.icon="bold";BoldButton.prototype.htmlTag="b, strong";BoldButton.prototype.disableTag="pre";BoldButton.prototype.shortcut="cmd+b";BoldButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + b )"}else{this.title=this.title+" ( Ctrl + b )";this.shortcut="ctrl+b"}return BoldButton.__super__._init.call(this)};BoldButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("bold")===true;this.setActive(active);return this.active};BoldButton.prototype.command=function(){document.execCommand("bold");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return BoldButton})(Button);Simditor.Toolbar.addButton(BoldButton);ItalicButton=(function(superClass){extend(ItalicButton,superClass);function ItalicButton(){return ItalicButton.__super__.constructor.apply(this,arguments)}ItalicButton.prototype.name="italic";ItalicButton.prototype.icon="italic";ItalicButton.prototype.htmlTag="i";ItalicButton.prototype.disableTag="pre";ItalicButton.prototype.shortcut="cmd+i";ItalicButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + i )"}else{this.title=this.title+" ( Ctrl + i )";this.shortcut="ctrl+i"}return ItalicButton.__super__._init.call(this)};ItalicButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("italic")===true;this.setActive(active);return this.active};ItalicButton.prototype.command=function(){document.execCommand("italic");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return ItalicButton})(Button);Simditor.Toolbar.addButton(ItalicButton);UnderlineButton=(function(superClass){extend(UnderlineButton,superClass);function UnderlineButton(){return UnderlineButton.__super__.constructor.apply(this,arguments)}UnderlineButton.prototype.name="underline";UnderlineButton.prototype.icon="underline";UnderlineButton.prototype.htmlTag="u";UnderlineButton.prototype.disableTag="pre";UnderlineButton.prototype.shortcut="cmd+u";UnderlineButton.prototype.render=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + u )"}else{this.title=this.title+" ( Ctrl + u )";this.shortcut="ctrl+u"}return UnderlineButton.__super__.render.call(this)};UnderlineButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("underline")===true;
|
|
22
|
+this.setActive(active);return this.active};UnderlineButton.prototype.command=function(){document.execCommand("underline");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return UnderlineButton})(Button);Simditor.Toolbar.addButton(UnderlineButton);ColorButton=(function(superClass){extend(ColorButton,superClass);function ColorButton(){return ColorButton.__super__.constructor.apply(this,arguments)}ColorButton.prototype.name="color";ColorButton.prototype.icon="tint";ColorButton.prototype.disableTag="pre";ColorButton.prototype.menu=true;ColorButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];return ColorButton.__super__.render.apply(this,args)};ColorButton.prototype.renderMenu=function(){$('<ul class="color-list">\n <li><a href="javascript:;" class="font-color font-color-1"></a></li>\n <li><a href="javascript:;" class="font-color font-color-2"></a></li>\n <li><a href="javascript:;" class="font-color font-color-3"></a></li>\n <li><a href="javascript:;" class="font-color font-color-4"></a></li>\n <li><a href="javascript:;" class="font-color font-color-5"></a></li>\n <li><a href="javascript:;" class="font-color font-color-6"></a></li>\n <li><a href="javascript:;" class="font-color font-color-7"></a></li>\n <li><a href="javascript:;" class="font-color font-color-default"></a></li>\n</ul>').appendTo(this.menuWrapper);this.menuWrapper.on("mousedown",".color-list",function(e){return false});return this.menuWrapper.on("click",".font-color",(function(_this){return function(e){var $link,$p,hex,range,rgb,textNode;_this.wrapper.removeClass("menu-on");$link=$(e.currentTarget);if($link.hasClass("font-color-default")){$p=_this.editor.body.find("p, li");if(!($p.length>0)){return}rgb=window.getComputedStyle($p[0],null).getPropertyValue("color");hex=_this._convertRgbToHex(rgb)}else{rgb=window.getComputedStyle($link[0],null).getPropertyValue("background-color");hex=_this._convertRgbToHex(rgb)}if(!hex){return}range=_this.editor.selection.range();if(!$link.hasClass("font-color-default")&&range.collapsed){textNode=document.createTextNode(_this._t("coloredText"));range.insertNode(textNode);range.selectNodeContents(textNode);_this.editor.selection.range(range)}document.execCommand("styleWithCSS",false,true);document.execCommand("foreColor",false,hex);document.execCommand("styleWithCSS",false,false);if(!_this.editor.util.support.oninput){return _this.editor.trigger("valuechanged")}}})(this))};ColorButton.prototype._convertRgbToHex=function(rgb){var match,re,rgbToHex;re=/rgb\((\d+),\s?(\d+),\s?(\d+)\)/g;match=re.exec(rgb);if(!match){return""}rgbToHex=function(r,g,b){var componentToHex;componentToHex=function(c){var hex;hex=c.toString(16);if(hex.length===1){return"0"+hex}else{return hex}};return"#"+componentToHex(r)+componentToHex(g)+componentToHex(b)};return rgbToHex(match[1]*1,match[2]*1,match[3]*1)};return ColorButton})(Button);Simditor.Toolbar.addButton(ColorButton);ListButton=(function(superClass){extend(ListButton,superClass);function ListButton(){return ListButton.__super__.constructor.apply(this,arguments)}ListButton.prototype.type="";ListButton.prototype.disableTag="pre, table";ListButton.prototype.command=function(param){var $list,$rootNodes,anotherType;$rootNodes=this.editor.selection.blockNodes();anotherType=this.type==="ul"?"ol":"ul";this.editor.selection.save();$list=null;$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if($node.is("blockquote, li")||$node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)||!$.contains(document,node)){return}if($node.is(_this.type)){$node.children("li").each(function(i,li){var $childList,$li;$li=$(li);$childList=$li.children("ul, ol").insertAfter($node);return $("<p/>").append($(li).html()||_this.editor.util.phBr).insertBefore($node)});return $node.remove()}else{if($node.is(anotherType)){return $("<"+_this.type+"/>").append($node.contents()).replaceAll($node)}else{if($list&&$node.prev().is($list)){$("<li/>").append($node.html()||_this.editor.util.phBr).appendTo($list);return $node.remove()}else{$list=$("<"+_this.type+"><li></li></"+_this.type+">");$list.find("li").append($node.html()||_this.editor.util.phBr);return $list.replaceAll($node)}}}}})(this));this.editor.selection.restore();return this.editor.trigger("valuechanged")};return ListButton})(Button);OrderListButton=(function(superClass){extend(OrderListButton,superClass);function OrderListButton(){return OrderListButton.__super__.constructor.apply(this,arguments)}OrderListButton.prototype.type="ol";OrderListButton.prototype.name="ol";OrderListButton.prototype.icon="list-ol";OrderListButton.prototype.htmlTag="ol";OrderListButton.prototype.shortcut="cmd+/";OrderListButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + / )"}else{this.title=this.title+" ( ctrl + / )";this.shortcut="ctrl+/"}return OrderListButton.__super__._init.call(this)
|
|
23
|
+};return OrderListButton})(ListButton);UnorderListButton=(function(superClass){extend(UnorderListButton,superClass);function UnorderListButton(){return UnorderListButton.__super__.constructor.apply(this,arguments)}UnorderListButton.prototype.type="ul";UnorderListButton.prototype.name="ul";UnorderListButton.prototype.icon="list-ul";UnorderListButton.prototype.htmlTag="ul";UnorderListButton.prototype.shortcut="cmd+.";UnorderListButton.prototype._init=function(){if(this.editor.util.os.mac){this.title=this.title+" ( Cmd + . )"}else{this.title=this.title+" ( Ctrl + . )";this.shortcut="ctrl+."}return UnorderListButton.__super__._init.call(this)};return UnorderListButton})(ListButton);Simditor.Toolbar.addButton(OrderListButton);Simditor.Toolbar.addButton(UnorderListButton);BlockquoteButton=(function(superClass){extend(BlockquoteButton,superClass);function BlockquoteButton(){return BlockquoteButton.__super__.constructor.apply(this,arguments)}BlockquoteButton.prototype.name="blockquote";BlockquoteButton.prototype.icon="quote-left";BlockquoteButton.prototype.htmlTag="blockquote";BlockquoteButton.prototype.disableTag="pre, table";BlockquoteButton.prototype.command=function(){var $rootNodes,clearCache,nodeCache;$rootNodes=this.editor.selection.rootNodes();$rootNodes=$rootNodes.filter(function(i,node){return !$(node).parent().is("blockquote")});this.editor.selection.save();nodeCache=[];clearCache=(function(_this){return function(){if(nodeCache.length>0){$("<"+_this.htmlTag+"/>").insertBefore(nodeCache[0]).append(nodeCache);return nodeCache.length=0}}})(this);$rootNodes.each((function(_this){return function(i,node){var $node;$node=$(node);if(!$node.parent().is(_this.editor.body)){return}if($node.is(_this.htmlTag)){clearCache();return $node.children().unwrap()}else{if($node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)){return clearCache()}else{return nodeCache.push(node)}}}})(this));clearCache();this.editor.selection.restore();return this.editor.trigger("valuechanged")};return BlockquoteButton})(Button);Simditor.Toolbar.addButton(BlockquoteButton);CodeButton=(function(superClass){extend(CodeButton,superClass);function CodeButton(){return CodeButton.__super__.constructor.apply(this,arguments)}CodeButton.prototype.name="code";CodeButton.prototype.icon="code";CodeButton.prototype.htmlTag="pre";CodeButton.prototype.disableTag="ul, ol, table";CodeButton.prototype._init=function(){CodeButton.__super__._init.call(this);this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("pre").each(function(i,pre){return _this.decorate($(pre))})}})(this));return this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find("pre").each(function(i,pre){return _this.undecorate($(pre))})}})(this))};CodeButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];CodeButton.__super__.render.apply(this,args);return this.popover=new CodePopover({button:this})};CodeButton.prototype._checkMode=function(){var $blockNodes,range;range=this.editor.selection.range();if(($blockNodes=$(range.cloneContents()).find(this.editor.util.blockNodes.join(",")))>0||(range.collapsed&&this.editor.selection.startNodes().filter("code").length===0)){this.inlineMode=false;return this.htmlTag="pre"}else{this.inlineMode=true;return this.htmlTag="code"}};CodeButton.prototype._status=function(){this._checkMode();CodeButton.__super__._status.call(this);if(this.inlineMode){return}if(this.active){return this.popover.show(this.node)}else{return this.popover.hide()}};CodeButton.prototype.decorate=function($pre){var $code,lang,ref,ref1;$code=$pre.find("> code");if($code.length>0){lang=(ref=$code.attr("class"))!=null?(ref1=ref.match(/lang-(\S+)/))!=null?ref1[1]:void 0:void 0;$code.contents().unwrap();if(lang){return $pre.attr("data-lang",lang)}}};CodeButton.prototype.undecorate=function($pre){var $code,lang;lang=$pre.attr("data-lang");$code=$("<code/>");if(lang&&lang!==-1){$code.addClass("lang-"+lang)}return $pre.wrapInner($code).removeAttr("data-lang")};CodeButton.prototype.command=function(){if(this.inlineMode){return this._inlineCommand()}else{return this._blockCommand()}};CodeButton.prototype._blockCommand=function(){var $rootNodes,clearCache,nodeCache,resultNodes;$rootNodes=this.editor.selection.rootNodes();nodeCache=[];resultNodes=[];clearCache=(function(_this){return function(){var $pre;if(!(nodeCache.length>0)){return}$pre=$("<"+_this.htmlTag+"/>").insertBefore(nodeCache[0]).text(_this.editor.formatter.clearHtml(nodeCache));resultNodes.push($pre[0]);return nodeCache.length=0}})(this);$rootNodes.each((function(_this){return function(i,node){var $node,$p;$node=$(node);if($node.is(_this.htmlTag)){clearCache();$p=$("<p/>").append($node.html().replace("\n","<br/>")).replaceAll($node);return resultNodes.push($p[0])}else{if($node.is(_this.disableTag)||_this.editor.util.isDecoratedNode($node)||$node.is("blockquote")){return clearCache()}else{return nodeCache.push(node)}}}})(this));clearCache();
|
|
24
|
+this.editor.selection.setRangeAtEndOf($(resultNodes).last());return this.editor.trigger("valuechanged")};CodeButton.prototype._inlineCommand=function(){var $code,$contents,range;range=this.editor.selection.range();if(this.active){range.selectNodeContents(this.node[0]);this.editor.selection.save(range);this.node.contents().unwrap();this.editor.selection.restore()}else{$contents=$(range.extractContents());$code=$("<"+this.htmlTag+"/>").append($contents.contents());range.insertNode($code[0]);range.selectNodeContents($code[0]);this.editor.selection.range(range)}return this.editor.trigger("valuechanged")};return CodeButton})(Button);CodePopover=(function(superClass){extend(CodePopover,superClass);function CodePopover(){return CodePopover.__super__.constructor.apply(this,arguments)}CodePopover.prototype.render=function(){var $option,k,lang,len,ref;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 </select>\n </div>\n</div>";this.langs=this.editor.opts.codeLanguages||[{name:"Bash",value:"bash"},{name:"C++",value:"c++"},{name:"C#",value:"cs"},{name:"CSS",value:"css"},{name:"Erlang",value:"erlang"},{name:"Less",value:"less"},{name:"Sass",value:"sass"},{name:"Diff",value:"diff"},{name:"CoffeeScript",value:"coffeescript"},{name:"HTML,XML",value:"html"},{name:"JSON",value:"json"},{name:"Java",value:"java"},{name:"JavaScript",value:"js"},{name:"Markdown",value:"markdown"},{name:"Objective C",value:"oc"},{name:"PHP",value:"php"},{name:"Perl",value:"parl"},{name:"Python",value:"python"},{name:"Ruby",value:"ruby"},{name:"SQL",value:"sql"}];this.el.addClass("code-popover").append(this._tpl);this.selectEl=this.el.find(".select-lang");ref=this.langs;for(k=0,len=ref.length;k<len;k++){lang=ref[k];$option=$("<option/>",{text:lang.name,value:lang.value}).appendTo(this.selectEl)}this.selectEl.on("change",(function(_this){return function(e){var selected;_this.lang=_this.selectEl.val();selected=_this.target.hasClass("selected");_this.target.removeClass().removeAttr("data-lang");if(_this.lang!==-1){_this.target.attr("data-lang",_this.lang)}if(selected){_this.target.addClass("selected")}return _this.editor.trigger("valuechanged")}})(this));return this.editor.on("valuechanged",(function(_this){return function(e){if(_this.active){return _this.refresh()}}})(this))};CodePopover.prototype.show=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];CodePopover.__super__.show.apply(this,args);this.lang=this.target.attr("data-lang");if(this.lang!=null){return this.selectEl.val(this.lang)}else{return this.selectEl.val(-1)}};return CodePopover})(Popover);Simditor.Toolbar.addButton(CodeButton);LinkButton=(function(superClass){extend(LinkButton,superClass);function LinkButton(){return LinkButton.__super__.constructor.apply(this,arguments)}LinkButton.prototype.name="link";LinkButton.prototype.icon="link";LinkButton.prototype.htmlTag="a";LinkButton.prototype.disableTag="pre";LinkButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];LinkButton.__super__.render.apply(this,args);return this.popover=new LinkPopover({button:this})};LinkButton.prototype._status=function(){LinkButton.__super__._status.call(this);if(this.active&&!this.editor.selection.rangeAtEndOf(this.node)){return this.popover.show(this.node)}else{return this.popover.hide()}};LinkButton.prototype.command=function(){var $contents,$link,$newBlock,linkText,range,txtNode;range=this.editor.selection.range();if(this.active){txtNode=document.createTextNode(this.node.text());this.node.replaceWith(txtNode);range.selectNode(txtNode)}else{$contents=$(range.extractContents());linkText=this.editor.formatter.clearHtml($contents.contents(),false);$link=$("<a/>",{href:"http://www.example.com",target:"_blank",text:linkText||this._t("linkText")});if(this.editor.selection.blockNodes().length>0){range.insertNode($link[0])}else{$newBlock=$("<p/>").append($link);range.insertNode($newBlock[0])}range.selectNodeContents($link[0]);this.popover.one("popovershow",(function(_this){return function(){if(linkText){_this.popover.urlEl.focus();return _this.popover.urlEl[0].select()}else{_this.popover.textEl.focus();return _this.popover.textEl[0].select()}}})(this))}this.editor.selection.range(range);return this.editor.trigger("valuechanged")};return LinkButton})(Button);LinkPopover=(function(superClass){extend(LinkPopover,superClass);function LinkPopover(){return LinkPopover.__super__.constructor.apply(this,arguments)}LinkPopover.prototype.render=function(){var tpl;tpl='<div class="link-settings">\n <div class="settings-field">\n <label>'+(this._t("linkText"))+'</label>\n <input class="link-text" type="text"/>\n <a class="btn-unlink" href="javascript:;" title="'+(this._t("removeLink"))+'"\n tabindex="-1">\n <span class="simditor-icon simditor-icon-unlink"></span>\n </a>\n </div>\n <div class="settings-field">\n <label>'+(this._t("linkUrl"))+'</label>\n <input class="link-url" type="text"/>\n </div>\n <div class="settings-field">\n <label>'+(this._t("linkTarget"))+'</label>\n <select class="link-target">\n <option value="_blank">'+(this._t("openLinkInNewWindow"))+' (_blank)</option>\n <option value="_self">'+(this._t("openLinkInCurrentWindow"))+" (_self)</option>\n </select>\n </div>\n</div>";
|
|
25
|
+this.el.addClass("link-popover").append(tpl);this.textEl=this.el.find(".link-text");this.urlEl=this.el.find(".link-url");this.unlinkEl=this.el.find(".btn-unlink");this.selectTarget=this.el.find(".link-target");this.textEl.on("keyup",(function(_this){return function(e){if(e.which===13){return}_this.target.text(_this.textEl.val());return _this.editor.inputManager.throttledValueChanged()}})(this));this.urlEl.on("keyup",(function(_this){return function(e){var val;if(e.which===13){return}val=_this.urlEl.val();if(!(/https?:\/\/|^\//ig.test(val)||!val)){val="http://"+val}_this.target.attr("href",val);return _this.editor.inputManager.throttledValueChanged()}})(this));$([this.urlEl[0],this.textEl[0]]).on("keydown",(function(_this){return function(e){var range;if(e.which===13||e.which===27||(!e.shiftKey&&e.which===9&&$(e.target).hasClass("link-url"))){e.preventDefault();range=document.createRange();_this.editor.selection.setRangeAfter(_this.target,range);_this.hide();return _this.editor.inputManager.throttledValueChanged()}}})(this));this.unlinkEl.on("click",(function(_this){return function(e){var range,txtNode;txtNode=document.createTextNode(_this.target.text());_this.target.replaceWith(txtNode);_this.hide();range=document.createRange();_this.editor.selection.setRangeAfter(txtNode,range);return _this.editor.inputManager.throttledValueChanged()}})(this));return this.selectTarget.on("change",(function(_this){return function(e){_this.target.attr("target",_this.selectTarget.val());return _this.editor.inputManager.throttledValueChanged()}})(this))};LinkPopover.prototype.show=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];LinkPopover.__super__.show.apply(this,args);this.textEl.val(this.target.text());return this.urlEl.val(this.target.attr("href"))};return LinkPopover})(Popover);Simditor.Toolbar.addButton(LinkButton);ImageButton=(function(superClass){extend(ImageButton,superClass);function ImageButton(){return ImageButton.__super__.constructor.apply(this,arguments)}ImageButton.prototype.name="image";ImageButton.prototype.icon="picture-o";ImageButton.prototype.htmlTag="img";ImageButton.prototype.disableTag="pre, table";ImageButton.prototype.defaultImage="";ImageButton.prototype.needFocus=false;ImageButton.prototype._init=function(){var item,k,len,ref;if(this.editor.opts.imageButton){if(Array.isArray(this.editor.opts.imageButton)){this.menu=[];ref=this.editor.opts.imageButton;for(k=0,len=ref.length;k<len;k++){item=ref[k];this.menu.push({name:item+"-image",text:this._t(item+"Image")})}}else{this.menu=false}}else{if(this.editor.uploader!=null){this.menu=[{name:"upload-image",text:this._t("uploadImage")},{name:"external-image",text:this._t("externalImage")}]}else{this.menu=false}}this.defaultImage=this.editor.opts.defaultImage;this.editor.body.on("click","img:not([data-non-image])",(function(_this){return function(e){var $img,range;$img=$(e.currentTarget);range=document.createRange();range.selectNode($img[0]);_this.editor.selection.range(range);if(!_this.editor.util.support.onselectionchange){_this.editor.trigger("selectionchanged")}return false}})(this));this.editor.body.on("mouseup","img:not([data-non-image])",function(e){return false});this.editor.on("selectionchanged.image",(function(_this){return function(){var $contents,$img,range;range=_this.editor.selection.range();if(range==null){return}$contents=$(range.cloneContents()).contents();if($contents.length===1&&$contents.is("img:not([data-non-image])")){$img=$(range.startContainer).contents().eq(range.startOffset);return _this.popover.show($img)}else{return _this.popover.hide()}}})(this));this.editor.on("valuechanged.image",(function(_this){return function(){var $masks;$masks=_this.editor.wrapper.find(".simditor-image-loading");if(!($masks.length>0)){return}return $masks.each(function(i,mask){var $img,$mask,file;$mask=$(mask);$img=$mask.data("img");if(!($img&&$img.parent().length>0)){$mask.remove();if($img){file=$img.data("file");if(file){_this.editor.uploader.cancel(file);if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file])}}}}})}})(this));return ImageButton.__super__._init.call(this)};ImageButton.prototype.render=function(){var args;args=1<=arguments.length?slice.call(arguments,0):[];ImageButton.__super__.render.apply(this,args);this.popover=new ImagePopover({button:this});if(this.editor.opts.imageButton==="upload"){return this._initUploader(this.el)}};ImageButton.prototype.renderMenu=function(){ImageButton.__super__.renderMenu.call(this);return this._initUploader()};ImageButton.prototype._initUploader=function($uploadItem){var $input,createInput,uploadProgress;if($uploadItem==null){$uploadItem=this.menuEl.find(".menu-item-upload-image")}if(this.editor.uploader==null){this.el.find(".btn-upload").remove();return}$input=null;createInput=(function(_this){return function(){if($input){$input.remove()}return $input=$("<input/>",{type:"file",title:_this._t("uploadImage"),multiple:true,accept:"image/*"}).appendTo($uploadItem)
|
|
26
|
+}})(this);createInput();$uploadItem.on("click mousedown","input[type=file]",function(e){return e.stopPropagation()});$uploadItem.on("change","input[type=file]",(function(_this){return function(e){if(_this.editor.inputManager.focused){_this.editor.uploader.upload($input,{inline:true});createInput()}else{_this.editor.one("focus",function(e){_this.editor.uploader.upload($input,{inline:true});return createInput()});_this.editor.focus()}return _this.wrapper.removeClass("menu-on")}})(this));this.editor.uploader.on("beforeupload",(function(_this){return function(e,file){var $img;if(!file.inline){return}if(file.img){$img=$(file.img)}else{$img=_this.createImage(file.name);file.img=$img}$img.addClass("uploading");$img.data("file",file);return _this.editor.uploader.readImageFile(file.obj,function(img){var src;if(!$img.hasClass("uploading")){return}src=img?img.src:_this.defaultImage;return _this.loadImage($img,src,function(){if(_this.popover.active){_this.popover.refresh();return _this.popover.srcEl.val(_this._t("uploading")).prop("disabled",true)}})})}})(this));uploadProgress=$.proxy(this.editor.util.throttle(function(e,file,loaded,total){var $img,$mask,percent;if(!file.inline){return}$mask=file.img.data("mask");if(!$mask){return}$img=$mask.data("img");if(!($img.hasClass("uploading")&&$img.parent().length>0)){$mask.remove();return}percent=loaded/total;percent=(percent*100).toFixed(0);if(percent>99){percent=99}return $mask.find(".progress").height((100-percent)+"%")},500),this);this.editor.uploader.on("uploadprogress",uploadProgress);this.editor.uploader.on("uploadsuccess",(function(_this){return function(e,file,result){var $img,img_path,msg;if(!file.inline){return}$img=file.img;if(!($img.hasClass("uploading")&&$img.parent().length>0)){return}if(typeof result!=="object"){try{result=$.parseJSON(result)}catch(_error){e=_error;result={success:false}}}if(result.success===false){msg=result.msg||_this._t("uploadFailed");alert(msg);img_path=_this.defaultImage}else{img_path=result.file_path}_this.loadImage($img,img_path,function(){var $mask;$img.removeData("file");$img.removeClass("uploading").removeClass("loading");$mask=$img.data("mask");if($mask){$mask.remove()}$img.removeData("mask");_this.editor.trigger("valuechanged");if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file,result])}});if(_this.popover.active){_this.popover.srcEl.prop("disabled",false);return _this.popover.srcEl.val(result.file_path)}}})(this));return this.editor.uploader.on("uploaderror",(function(_this){return function(e,file,xhr){var $img,msg,result;if(!file.inline){return}if(xhr.statusText==="abort"){return}if(xhr.responseText){try{result=$.parseJSON(xhr.responseText);msg=result.msg}catch(_error){e=_error;msg=_this._t("uploadError")}alert(msg)}$img=file.img;if(!($img.hasClass("uploading")&&$img.parent().length>0)){return}_this.loadImage($img,_this.defaultImage,function(){var $mask;$img.removeData("file");$img.removeClass("uploading").removeClass("loading");$mask=$img.data("mask");if($mask){$mask.remove()}return $img.removeData("mask")});if(_this.popover.active){_this.popover.srcEl.prop("disabled",false);_this.popover.srcEl.val(_this.defaultImage)}_this.editor.trigger("valuechanged");if(_this.editor.body.find("img.uploading").length<1){return _this.editor.uploader.trigger("uploadready",[file,result])}}})(this))};ImageButton.prototype._status=function(){return this._disableStatus()};ImageButton.prototype.loadImage=function($img,src,callback){var $mask,img,positionMask;positionMask=(function(_this){return function(){var imgOffset,wrapperOffset;imgOffset=$img.offset();wrapperOffset=_this.editor.wrapper.offset();return $mask.css({top:imgOffset.top-wrapperOffset.top,left:imgOffset.left-wrapperOffset.left,width:$img.width(),height:$img.height()}).show()}})(this);$img.addClass("loading");$mask=$img.data("mask");if(!$mask){$mask=$('<div class="simditor-image-loading">\n <div class="progress"></div>\n</div>').hide().appendTo(this.editor.wrapper);positionMask();$img.data("mask",$mask);$mask.data("img",$img)}img=new Image();img.onload=(function(_this){return function(){var height,width;if(!$img.hasClass("loading")&&!$img.hasClass("uploading")){return}width=img.width;height=img.height;$img.attr({src:src,width:width,height:height,"data-image-size":width+","+height}).removeClass("loading");if($img.hasClass("uploading")){_this.editor.util.reflow(_this.editor.body);positionMask()}else{$mask.remove();$img.removeData("mask")}if($.isFunction(callback)){return callback(img)}}})(this);img.onerror=function(){if($.isFunction(callback)){callback(false)}$mask.remove();return $img.removeData("mask").removeClass("loading")};return img.src=src};ImageButton.prototype.createImage=function(name){var $img,range;if(name==null){name="Image"}if(!this.editor.inputManager.focused){this.editor.focus()}range=this.editor.selection.range();range.deleteContents();this.editor.selection.range(range);$img=$("<img/>").attr("alt",name);range.insertNode($img[0]);
|
|
27
|
+this.editor.selection.setRangeAfter($img,range);this.editor.trigger("valuechanged");return $img};ImageButton.prototype.command=function(src){var $img;$img=this.createImage();return this.loadImage($img,src||this.defaultImage,(function(_this){return function(){_this.editor.trigger("valuechanged");_this.editor.util.reflow($img);$img.click();return _this.popover.one("popovershow",function(){_this.popover.srcEl.focus();return _this.popover.srcEl[0].select()})}})(this))};return ImageButton})(Button);ImagePopover=(function(superClass){extend(ImagePopover,superClass);function ImagePopover(){return ImagePopover.__super__.constructor.apply(this,arguments)}ImagePopover.prototype.offset={top:6,left:-4};ImagePopover.prototype.render=function(){var tpl;tpl='<div class="link-settings">\n <div class="settings-field">\n <label>'+(this._t("imageUrl"))+'</label>\n <input class="image-src" type="text" tabindex="1" />\n <a class="btn-upload" href="javascript:;"\n title="'+(this._t("uploadImage"))+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-upload"></span>\n </a>\n </div>\n <div class=\'settings-field\'>\n <label>'+(this._t("imageAlt"))+'</label>\n <input class="image-alt" id="image-alt" type="text" tabindex="1" />\n </div>\n <div class="settings-field">\n <label>'+(this._t("imageSize"))+'</label>\n <input class="image-size" id="image-width" type="text" tabindex="2" />\n <span class="times">×</span>\n <input class="image-size" id="image-height" type="text" tabindex="3" />\n <a class="btn-restore" href="javascript:;"\n title="'+(this._t("restoreImageSize"))+'" tabindex="-1">\n <span class="simditor-icon simditor-icon-undo"></span>\n </a>\n </div>\n</div>';this.el.addClass("image-popover").append(tpl);this.srcEl=this.el.find(".image-src");this.widthEl=this.el.find("#image-width");this.heightEl=this.el.find("#image-height");this.altEl=this.el.find("#image-alt");this.srcEl.on("keydown",(function(_this){return function(e){var range;if(!(e.which===13&&!_this.target.hasClass("uploading"))){return}e.preventDefault();range=document.createRange();_this.button.editor.selection.setRangeAfter(_this.target,range);return _this.hide()}})(this));this.srcEl.on("blur",(function(_this){return function(e){return _this._loadImage(_this.srcEl.val())}})(this));this.el.find(".image-size").on("blur",(function(_this){return function(e){_this._resizeImg($(e.currentTarget));return _this.el.data("popover").refresh()}})(this));this.el.find(".image-size").on("keyup",(function(_this){return function(e){var inputEl;inputEl=$(e.currentTarget);if(!(e.which===13||e.which===27||e.which===9)){return _this._resizeImg(inputEl,true)}}})(this));this.el.find(".image-size").on("keydown",(function(_this){return function(e){var $img,inputEl,range;inputEl=$(e.currentTarget);if(e.which===13||e.which===27){e.preventDefault();if(e.which===13){_this._resizeImg(inputEl)}else{_this._restoreImg()}$img=_this.target;_this.hide();range=document.createRange();return _this.button.editor.selection.setRangeAfter($img,range)}else{if(e.which===9){return _this.el.data("popover").refresh()}}}})(this));this.altEl.on("keydown",(function(_this){return function(e){var range;if(e.which===13){e.preventDefault();range=document.createRange();_this.button.editor.selection.setRangeAfter(_this.target,range);return _this.hide()}}})(this));this.altEl.on("keyup",(function(_this){return function(e){if(e.which===13||e.which===27||e.which===9){return}_this.alt=_this.altEl.val();return _this.target.attr("alt",_this.alt)}})(this));this.el.find(".btn-restore").on("click",(function(_this){return function(e){_this._restoreImg();return _this.el.data("popover").refresh()}})(this));this.editor.on("valuechanged",(function(_this){return function(e){if(_this.active){return _this.refresh()}}})(this));return this._initUploader()};ImagePopover.prototype._initUploader=function(){var $uploadBtn,createInput;$uploadBtn=this.el.find(".btn-upload");if(this.editor.uploader==null){$uploadBtn.remove();return}createInput=(function(_this){return function(){if(_this.input){_this.input.remove()}return _this.input=$("<input/>",{type:"file",title:_this._t("uploadImage"),multiple:true,accept:"image/*"}).appendTo($uploadBtn)}})(this);createInput();this.el.on("click mousedown","input[type=file]",function(e){return e.stopPropagation()});return this.el.on("change","input[type=file]",(function(_this){return function(e){_this.editor.uploader.upload(_this.input,{inline:true,img:_this.target});return createInput()}})(this))};ImagePopover.prototype._resizeImg=function(inputEl,onlySetVal){var height,value,width;if(onlySetVal==null){onlySetVal=false}value=inputEl.val()*1;if(!(this.target&&($.isNumeric(value)||value<0))){return}if(inputEl.is(this.widthEl)){width=value;height=this.height*value/this.width;this.heightEl.val(height)}else{height=value;width=this.width*value/this.height;this.widthEl.val(width)}if(!onlySetVal){this.target.attr({width:width,height:height});return this.editor.trigger("valuechanged")
|
|
28
|
+}};ImagePopover.prototype._restoreImg=function(){var ref,size;size=((ref=this.target.data("image-size"))!=null?ref.split(","):void 0)||[this.width,this.height];this.target.attr({width:size[0]*1,height:size[1]*1});this.widthEl.val(size[0]);this.heightEl.val(size[1]);return this.editor.trigger("valuechanged")};ImagePopover.prototype._loadImage=function(src,callback){if(/^data:image/.test(src)&&!this.editor.uploader){if(callback){callback(false)}return}if(this.target.attr("src")===src){return}return this.button.loadImage(this.target,src,(function(_this){return function(img){var blob;if(!img){return}if(_this.active){_this.width=img.width;_this.height=img.height;_this.widthEl.val(_this.width);_this.heightEl.val(_this.height)}if(/^data:image/.test(src)){blob=_this.editor.util.dataURLtoBlob(src);blob.name="Base64 Image.png";_this.editor.uploader.upload(blob,{inline:true,img:_this.target})}else{_this.editor.trigger("valuechanged")}if(callback){return callback(img)}}})(this))};ImagePopover.prototype.show=function(){var $img,args;args=1<=arguments.length?slice.call(arguments,0):[];ImagePopover.__super__.show.apply(this,args);$img=this.target;this.width=$img.width();this.height=$img.height();this.alt=$img.attr("alt");if($img.hasClass("uploading")){return this.srcEl.val(this._t("uploading")).prop("disabled",true)}else{this.srcEl.val($img.attr("src")).prop("disabled",false);this.widthEl.val(this.width);this.heightEl.val(this.height);return this.altEl.val(this.alt)}};return ImagePopover})(Popover);Simditor.Toolbar.addButton(ImageButton);IndentButton=(function(superClass){extend(IndentButton,superClass);function IndentButton(){return IndentButton.__super__.constructor.apply(this,arguments)}IndentButton.prototype.name="indent";IndentButton.prototype.icon="indent";IndentButton.prototype._init=function(){this.title=this._t(this.name)+" (Tab)";return IndentButton.__super__._init.call(this)};IndentButton.prototype._status=function(){};IndentButton.prototype.command=function(){return this.editor.indentation.indent()};return IndentButton})(Button);Simditor.Toolbar.addButton(IndentButton);OutdentButton=(function(superClass){extend(OutdentButton,superClass);function OutdentButton(){return OutdentButton.__super__.constructor.apply(this,arguments)}OutdentButton.prototype.name="outdent";OutdentButton.prototype.icon="outdent";OutdentButton.prototype._init=function(){this.title=this._t(this.name)+" (Shift + Tab)";return OutdentButton.__super__._init.call(this)};OutdentButton.prototype._status=function(){};OutdentButton.prototype.command=function(){return this.editor.indentation.indent(true)};return OutdentButton})(Button);Simditor.Toolbar.addButton(OutdentButton);HrButton=(function(superClass){extend(HrButton,superClass);function HrButton(){return HrButton.__super__.constructor.apply(this,arguments)}HrButton.prototype.name="hr";HrButton.prototype.icon="minus";HrButton.prototype.htmlTag="hr";HrButton.prototype._status=function(){};HrButton.prototype.command=function(){var $hr,$newBlock,$nextBlock,$rootBlock;$rootBlock=this.editor.selection.rootNodes().first();$nextBlock=$rootBlock.next();if($nextBlock.length>0){this.editor.selection.save()}else{$newBlock=$("<p/>").append(this.editor.util.phBr)}$hr=$("<hr/>").insertAfter($rootBlock);if($newBlock){$newBlock.insertAfter($hr);this.editor.selection.setRangeAtStartOf($newBlock)}else{this.editor.selection.restore()}return this.editor.trigger("valuechanged")};return HrButton})(Button);Simditor.Toolbar.addButton(HrButton);TableButton=(function(superClass){extend(TableButton,superClass);function TableButton(){return TableButton.__super__.constructor.apply(this,arguments)}TableButton.prototype.name="table";TableButton.prototype.icon="table";TableButton.prototype.htmlTag="table";TableButton.prototype.disableTag="pre, li, blockquote";TableButton.prototype.menu=true;TableButton.prototype._init=function(){TableButton.__super__._init.call(this);$.merge(this.editor.formatter._allowedTags,["thead","th","tbody","tr","td","colgroup","col"]);$.extend(this.editor.formatter._allowedAttributes,{td:["rowspan","colspan"],col:["width"]});$.extend(this.editor.formatter._allowedStyles,{td:["text-align"],th:["text-align"]});this._initShortcuts();this.editor.on("decorate",(function(_this){return function(e,$el){return $el.find("table").each(function(i,table){return _this.decorate($(table))})}})(this));this.editor.on("undecorate",(function(_this){return function(e,$el){return $el.find("table").each(function(i,table){return _this.undecorate($(table))})}})(this));this.editor.on("selectionchanged.table",(function(_this){return function(e){var $container,range;_this.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active");range=_this.editor.selection.range();if(!range){return}$container=_this.editor.selection.containerNode();if(range.collapsed&&$container.is(".simditor-table")){if(_this.editor.selection.rangeAtStartOf($container)){$container=$container.find("th:first")}else{$container=$container.find("td:last")
|
|
29
|
+}_this.editor.selection.setRangeAtEndOf($container)}return $container.closest("td, th",_this.editor.body).addClass("active")}})(this));this.editor.on("blur.table",(function(_this){return function(e){return _this.editor.body.find(".simditor-table td, .simditor-table th").removeClass("active")}})(this));this.editor.keystroke.add("up","td",(function(_this){return function(e,$node){_this._tdNav($node,"up");return true}})(this));this.editor.keystroke.add("up","th",(function(_this){return function(e,$node){_this._tdNav($node,"up");return true}})(this));this.editor.keystroke.add("down","td",(function(_this){return function(e,$node){_this._tdNav($node,"down");return true}})(this));return this.editor.keystroke.add("down","th",(function(_this){return function(e,$node){_this._tdNav($node,"down");return true}})(this))};TableButton.prototype._tdNav=function($td,direction){var $anotherTr,$tr,action,anotherTag,index,parentTag,ref;if(direction==null){direction="up"}action=direction==="up"?"prev":"next";ref=direction==="up"?["tbody","thead"]:["thead","tbody"],parentTag=ref[0],anotherTag=ref[1];$tr=$td.parent("tr");$anotherTr=this["_"+action+"Row"]($tr);if(!($anotherTr.length>0)){return true}index=$tr.find("td, th").index($td);return this.editor.selection.setRangeAtEndOf($anotherTr.find("td, th").eq(index))};TableButton.prototype._nextRow=function($tr){var $nextTr;$nextTr=$tr.next("tr");if($nextTr.length<1&&$tr.parent("thead").length>0){$nextTr=$tr.parent("thead").next("tbody").find("tr:first")}return $nextTr};TableButton.prototype._prevRow=function($tr){var $prevTr;$prevTr=$tr.prev("tr");if($prevTr.length<1&&$tr.parent("tbody").length>0){$prevTr=$tr.parent("tbody").prev("thead").find("tr")}return $prevTr};TableButton.prototype.initResize=function($table){var $colgroup,$resizeHandle,$wrapper;$wrapper=$table.parent(".simditor-table");$colgroup=$table.find("colgroup");if($colgroup.length<1){$colgroup=$("<colgroup/>").prependTo($table);$table.find("thead tr th").each(function(i,td){var $col;return $col=$("<col/>").appendTo($colgroup)});this.refreshTableWidth($table)}$resizeHandle=$("<div />",{"class":"simditor-resize-handle",contenteditable:"false"}).appendTo($wrapper);$wrapper.on("mousemove","td, th",function(e){var $col,$td,index,ref,ref1,x;if($wrapper.hasClass("resizing")){return}$td=$(e.currentTarget);x=e.pageX-$(e.currentTarget).offset().left;if(x<5&&$td.prev().length>0){$td=$td.prev()}if($td.next("td, th").length<1){$resizeHandle.hide();return}if((ref=$resizeHandle.data("td"))!=null?ref.is($td):void 0){$resizeHandle.show();return}index=$td.parent().find("td, th").index($td);$col=$colgroup.find("col").eq(index);if((ref1=$resizeHandle.data("col"))!=null?ref1.is($col):void 0){$resizeHandle.show();return}return $resizeHandle.css("left",$td.position().left+$td.outerWidth()-5).data("td",$td).data("col",$col).show()});$wrapper.on("mouseleave",function(e){return $resizeHandle.hide()});return $wrapper.on("mousedown",".simditor-resize-handle",function(e){var $handle,$leftCol,$leftTd,$rightCol,$rightTd,minWidth,startHandleLeft,startLeftWidth,startRightWidth,startX,tableWidth;$handle=$(e.currentTarget);$leftTd=$handle.data("td");$leftCol=$handle.data("col");$rightTd=$leftTd.next("td, th");$rightCol=$leftCol.next("col");startX=e.pageX;startLeftWidth=$leftTd.outerWidth()*1;startRightWidth=$rightTd.outerWidth()*1;startHandleLeft=parseFloat($handle.css("left"));tableWidth=$leftTd.closest("table").width();minWidth=50;$(document).on("mousemove.simditor-resize-table",function(e){var deltaX,leftWidth,rightWidth;deltaX=e.pageX-startX;leftWidth=startLeftWidth+deltaX;rightWidth=startRightWidth-deltaX;if(leftWidth<minWidth){leftWidth=minWidth;deltaX=minWidth-startLeftWidth;rightWidth=startRightWidth-deltaX}else{if(rightWidth<minWidth){rightWidth=minWidth;deltaX=startRightWidth-minWidth;leftWidth=startLeftWidth+deltaX}}$leftCol.attr("width",(leftWidth/tableWidth*100)+"%");$rightCol.attr("width",(rightWidth/tableWidth*100)+"%");return $handle.css("left",startHandleLeft+deltaX)});$(document).one("mouseup.simditor-resize-table",function(e){$(document).off(".simditor-resize-table");return $wrapper.removeClass("resizing")});$wrapper.addClass("resizing");return false})};TableButton.prototype._initShortcuts=function(){this.editor.hotkeys.add("ctrl+alt+up",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertRowAbove]").click();return false}})(this));this.editor.hotkeys.add("ctrl+alt+down",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertRowBelow]").click();return false}})(this));this.editor.hotkeys.add("ctrl+alt+left",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertColLeft]").click();return false}})(this));return this.editor.hotkeys.add("ctrl+alt+right",(function(_this){return function(e){_this.editMenu.find(".menu-item[data-param=insertColRight]").click();return false}})(this))};TableButton.prototype.decorate=function($table){var $headRow,$tbody,$thead;
|
|
30
|
+if($table.parent(".simditor-table").length>0){this.undecorate($table)}$table.wrap('<div class="simditor-table"></div>');if($table.find("thead").length<1){$thead=$("<thead />");$headRow=$table.find("tr").first();$thead.append($headRow);this._changeCellTag($headRow,"th");$tbody=$table.find("tbody");if($tbody.length>0){$tbody.before($thead)}else{$table.prepend($thead)}}this.initResize($table);return $table.parent()};TableButton.prototype.undecorate=function($table){if(!($table.parent(".simditor-table").length>0)){return}return $table.parent().replaceWith($table)};TableButton.prototype.renderMenu=function(){var $table;$('<div class="menu-create-table">\n</div>\n<div class="menu-edit-table">\n <ul>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteRow">\n <span>'+(this._t("deleteRow"))+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowAbove">\n <span>'+(this._t("insertRowAbove"))+' ( Ctrl + Alt + ↑ )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertRowBelow">\n <span>'+(this._t("insertRowBelow"))+' ( Ctrl + Alt + ↓ )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteCol">\n <span>'+(this._t("deleteColumn"))+'</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColLeft">\n <span>'+(this._t("insertColumnLeft"))+' ( Ctrl + Alt + ← )</span>\n </a>\n </li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="insertColRight">\n <span>'+(this._t("insertColumnRight"))+' ( Ctrl + Alt + → )</span>\n </a>\n </li>\n <li><span class="separator"></span></li>\n <li>\n <a tabindex="-1" unselectable="on" class="menu-item"\n href="javascript:;" data-param="deleteTable">\n <span>'+(this._t("deleteTable"))+"</span>\n </a>\n </li>\n </ul>\n</div>").appendTo(this.menuWrapper);this.createMenu=this.menuWrapper.find(".menu-create-table");this.editMenu=this.menuWrapper.find(".menu-edit-table");$table=this.createTable(6,6).appendTo(this.createMenu);this.createMenu.on("mouseenter","td, th",(function(_this){return function(e){var $td,$tr,$trs,num;_this.createMenu.find("td, th").removeClass("selected");$td=$(e.currentTarget);$tr=$td.parent();num=$tr.find("td, th").index($td)+1;$trs=$tr.prevAll("tr").addBack();if($tr.parent().is("tbody")){$trs=$trs.add($table.find("thead tr"))}return $trs.find("td:lt("+num+"), th:lt("+num+")").addClass("selected")}})(this));this.createMenu.on("mouseleave",function(e){return $(e.currentTarget).find("td, th").removeClass("selected")});return this.createMenu.on("mousedown","td, th",(function(_this){return function(e){var $closestBlock,$td,$tr,colNum,rowNum;_this.wrapper.removeClass("menu-on");if(!_this.editor.inputManager.focused){return}$td=$(e.currentTarget);$tr=$td.parent();colNum=$tr.find("td").index($td)+1;rowNum=$tr.prevAll("tr").length+1;if($tr.parent().is("tbody")){rowNum+=1}$table=_this.createTable(rowNum,colNum,true);$closestBlock=_this.editor.selection.blockNodes().last();if(_this.editor.util.isEmptyNode($closestBlock)){$closestBlock.replaceWith($table)}else{$closestBlock.after($table)}_this.decorate($table);_this.editor.selection.setRangeAtStartOf($table.find("th:first"));_this.editor.trigger("valuechanged");return false}})(this))};TableButton.prototype.createTable=function(row,col,phBr){var $table,$tbody,$td,$thead,$tr,c,k,l,r,ref,ref1;$table=$("<table/>");$thead=$("<thead/>").appendTo($table);$tbody=$("<tbody/>").appendTo($table);for(r=k=0,ref=row;0<=ref?k<ref:k>ref;r=0<=ref?++k:--k){$tr=$("<tr/>");$tr.appendTo(r===0?$thead:$tbody);for(c=l=0,ref1=col;0<=ref1?l<ref1:l>ref1;c=0<=ref1?++l:--l){$td=$(r===0?"<th/>":"<td/>").appendTo($tr);if(phBr){$td.append(this.editor.util.phBr)}}}return $table};TableButton.prototype.refreshTableWidth=function($table){var cols,tableWidth;tableWidth=$table.width();cols=$table.find("col");return $table.find("thead tr th").each(function(i,td){var $col;$col=cols.eq(i);return $col.attr("width",($(td).outerWidth()/tableWidth*100)+"%")})};TableButton.prototype.setActive=function(active){TableButton.__super__.setActive.call(this,active);if(active){this.createMenu.hide();return this.editMenu.show()}else{this.createMenu.show();return this.editMenu.hide()}};TableButton.prototype._changeCellTag=function($tr,tagName){return $tr.find("td, th").each(function(i,cell){var $cell;$cell=$(cell);return $cell.replaceWith("<"+tagName+">"+($cell.html())+"</"+tagName+">")})};TableButton.prototype.deleteRow=function($td){var $newTr,$tr,index;$tr=$td.parent("tr");
|
|
31
|
+if($tr.closest("table").find("tr").length<1){return this.deleteTable($td)}else{$newTr=this._nextRow($tr);if(!($newTr.length>0)){$newTr=this._prevRow($tr)}index=$tr.find("td, th").index($td);if($tr.parent().is("thead")){$newTr.appendTo($tr.parent());this._changeCellTag($newTr,"th")}$tr.remove();return this.editor.selection.setRangeAtEndOf($newTr.find("td, th").eq(index))}};TableButton.prototype.insertRow=function($td,direction){var $newTr,$table,$tr,cellTag,colNum,i,index,k,ref;if(direction==null){direction="after"}$tr=$td.parent("tr");$table=$tr.closest("table");colNum=0;$table.find("tr").each(function(i,tr){return colNum=Math.max(colNum,$(tr).find("td").length)});index=$tr.find("td, th").index($td);$newTr=$("<tr/>");cellTag="td";if(direction==="after"&&$tr.parent().is("thead")){$tr.parent().next("tbody").prepend($newTr)}else{if(direction==="before"&&$tr.parent().is("thead")){$tr.before($newTr);$tr.parent().next("tbody").prepend($tr);this._changeCellTag($tr,"td");cellTag="th"}else{$tr[direction]($newTr)}}for(i=k=1,ref=colNum;1<=ref?k<=ref:k>=ref;i=1<=ref?++k:--k){$("<"+cellTag+"/>").append(this.editor.util.phBr).appendTo($newTr)}return this.editor.selection.setRangeAtStartOf($newTr.find("td, th").eq(index))};TableButton.prototype.deleteCol=function($td){var $newTd,$table,$tr,index,noOtherCol,noOtherRow;$tr=$td.parent("tr");noOtherRow=$tr.closest("table").find("tr").length<2;noOtherCol=$td.siblings("td, th").length<1;if(noOtherRow&&noOtherCol){return this.deleteTable($td)}else{index=$tr.find("td, th").index($td);$newTd=$td.next("td, th");if(!($newTd.length>0)){$newTd=$tr.prev("td, th")}$table=$tr.closest("table");$table.find("col").eq(index).remove();$table.find("tr").each(function(i,tr){return $(tr).find("td, th").eq(index).remove()});this.refreshTableWidth($table);return this.editor.selection.setRangeAtEndOf($newTd)}};TableButton.prototype.insertCol=function($td,direction){var $col,$newCol,$newTd,$table,$tr,index,tableWidth,width;if(direction==null){direction="after"}$tr=$td.parent("tr");index=$tr.find("td, th").index($td);$table=$td.closest("table");$col=$table.find("col").eq(index);$table.find("tr").each((function(_this){return function(i,tr){var $newTd,cellTag;cellTag=$(tr).parent().is("thead")?"th":"td";$newTd=$("<"+cellTag+"/>").append(_this.editor.util.phBr);return $(tr).find("td, th").eq(index)[direction]($newTd)}})(this));$newCol=$("<col/>");$col[direction]($newCol);tableWidth=$table.width();width=Math.max(parseFloat($col.attr("width"))/2,50/tableWidth*100);$col.attr("width",width+"%");$newCol.attr("width",width+"%");this.refreshTableWidth($table);$newTd=direction==="after"?$td.next("td, th"):$td.prev("td, th");return this.editor.selection.setRangeAtStartOf($newTd)};TableButton.prototype.deleteTable=function($td){var $block,$table;$table=$td.closest(".simditor-table");$block=$table.next("p");$table.remove();if($block.length>0){return this.editor.selection.setRangeAtStartOf($block)}};TableButton.prototype.command=function(param){var $td;$td=this.editor.selection.containerNode().closest("td, th");if(!($td.length>0)){return}if(param==="deleteRow"){this.deleteRow($td)}else{if(param==="insertRowAbove"){this.insertRow($td,"before")}else{if(param==="insertRowBelow"){this.insertRow($td)}else{if(param==="deleteCol"){this.deleteCol($td)}else{if(param==="insertColLeft"){this.insertCol($td,"before")}else{if(param==="insertColRight"){this.insertCol($td)}else{if(param==="deleteTable"){this.deleteTable($td)}else{return}}}}}}}return this.editor.trigger("valuechanged")};return TableButton})(Button);Simditor.Toolbar.addButton(TableButton);StrikethroughButton=(function(superClass){extend(StrikethroughButton,superClass);function StrikethroughButton(){return StrikethroughButton.__super__.constructor.apply(this,arguments)}StrikethroughButton.prototype.name="strikethrough";StrikethroughButton.prototype.icon="strikethrough";StrikethroughButton.prototype.htmlTag="strike";StrikethroughButton.prototype.disableTag="pre";StrikethroughButton.prototype._activeStatus=function(){var active;active=document.queryCommandState("strikethrough")===true;this.setActive(active);return this.active};StrikethroughButton.prototype.command=function(){document.execCommand("strikethrough");if(!this.editor.util.support.oninput){this.editor.trigger("valuechanged")}return $(document).trigger("selectionchange")};return StrikethroughButton})(Button);Simditor.Toolbar.addButton(StrikethroughButton);AlignmentButton=(function(superClass){extend(AlignmentButton,superClass);function AlignmentButton(){return AlignmentButton.__super__.constructor.apply(this,arguments)}AlignmentButton.prototype.name="alignment";AlignmentButton.prototype.icon="align-left";AlignmentButton.prototype.htmlTag="p, h1, h2, h3, h4, td, th";AlignmentButton.prototype._init=function(){this.menu=[{name:"left",text:this._t("alignLeft"),icon:"align-left",param:"left"},{name:"center",text:this._t("alignCenter"),icon:"align-center",param:"center"},{name:"right",text:this._t("alignRight"),icon:"align-right",param:"right"}];
|
|
32
|
+return AlignmentButton.__super__._init.call(this)};AlignmentButton.prototype.setActive=function(active,align){if(align==null){align="left"}if(align!=="left"&&align!=="center"&&align!=="right"){align="left"}if(align==="left"){AlignmentButton.__super__.setActive.call(this,false)}else{AlignmentButton.__super__.setActive.call(this,active)}this.el.removeClass("align-left align-center align-right");if(active){this.el.addClass("align-"+align)}this.setIcon("align-"+align);return this.menuEl.find(".menu-item").show().end().find(".menu-item-"+align).hide()};AlignmentButton.prototype._status=function(){this.nodes=this.editor.selection.nodes().filter(this.htmlTag);if(this.nodes.length<1){this.setDisabled(true);return this.setActive(false)}else{this.setDisabled(false);return this.setActive(true,this.nodes.first().css("text-align"))}};AlignmentButton.prototype.command=function(align){if(align!=="left"&&align!=="center"&&align!=="right"){throw new Error("simditor alignment button: invalid align "+align)}this.nodes.css({"text-align":align==="left"?"":align});this.editor.trigger("valuechanged");return this.editor.inputManager.throttledSelectionChanged()};return AlignmentButton})(Button);Simditor.Toolbar.addButton(AlignmentButton);return Simditor}));
|
|
|
@@ -0,0 +1,789 @@
|
|
1
|
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.toMarkdown = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
2
|
+/*
|
|
3
|
+ * to-markdown - an HTML to Markdown converter
|
|
4
|
+ *
|
|
5
|
+ * Copyright 2011+, Dom Christie
|
|
6
|
+ * Licenced under the MIT licence
|
|
7
|
+ *
|
|
8
|
+ */
|
|
9
|
+
|
|
10
|
+'use strict'
|
|
11
|
+
|
|
12
|
+var toMarkdown
|
|
13
|
+var converters
|
|
14
|
+var mdConverters = require('./lib/md-converters')
|
|
15
|
+var gfmConverters = require('./lib/gfm-converters')
|
|
16
|
+var HtmlParser = require('./lib/html-parser')
|
|
17
|
+var collapse = require('collapse-whitespace')
|
|
18
|
+
|
|
19
|
+/*
|
|
20
|
+ * Utilities
|
|
21
|
+ */
|
|
22
|
+
|
|
23
|
+var blocks = ['address', 'article', 'aside', 'audio', 'blockquote', 'body',
|
|
24
|
+ 'canvas', 'center', 'dd', 'dir', 'div', 'dl', 'dt', 'fieldset', 'figcaption',
|
|
25
|
+ 'figure', 'footer', 'form', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6',
|
|
26
|
+ 'header', 'hgroup', 'hr', 'html', 'isindex', 'li', 'main', 'menu', 'nav',
|
|
27
|
+ 'noframes', 'noscript', 'ol', 'output', 'p', 'pre', 'section', 'table',
|
|
28
|
+ 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'ul'
|
|
29
|
+]
|
|
30
|
+
|
|
31
|
+function isBlock (node) {
|
|
32
|
+ return blocks.indexOf(node.nodeName.toLowerCase()) !== -1
|
|
33
|
+}
|
|
34
|
+
|
|
35
|
+var voids = [
|
|
36
|
+ 'area', 'base', 'br', 'col', 'command', 'embed', 'hr', 'img', 'input',
|
|
37
|
+ 'keygen', 'link', 'meta', 'param', 'source', 'track', 'wbr'
|
|
38
|
+]
|
|
39
|
+
|
|
40
|
+function isVoid (node) {
|
|
41
|
+ return voids.indexOf(node.nodeName.toLowerCase()) !== -1
|
|
42
|
+}
|
|
43
|
+
|
|
44
|
+function htmlToDom (string) {
|
|
45
|
+ var tree = new HtmlParser().parseFromString(string, 'text/html')
|
|
46
|
+ collapse(tree.documentElement, isBlock)
|
|
47
|
+ return tree
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+/*
|
|
51
|
+ * Flattens DOM tree into single array
|
|
52
|
+ */
|
|
53
|
+
|
|
54
|
+function bfsOrder (node) {
|
|
55
|
+ var inqueue = [node]
|
|
56
|
+ var outqueue = []
|
|
57
|
+ var elem
|
|
58
|
+ var children
|
|
59
|
+ var i
|
|
60
|
+
|
|
61
|
+ while (inqueue.length > 0) {
|
|
62
|
+ elem = inqueue.shift()
|
|
63
|
+ outqueue.push(elem)
|
|
64
|
+ children = elem.childNodes
|
|
65
|
+ for (i = 0; i < children.length; i++) {
|
|
66
|
+ if (children[i].nodeType === 1) inqueue.push(children[i])
|
|
67
|
+ }
|
|
68
|
+ }
|
|
69
|
+ outqueue.shift()
|
|
70
|
+ return outqueue
|
|
71
|
+}
|
|
72
|
+
|
|
73
|
+/*
|
|
74
|
+ * Contructs a Markdown string of replacement text for a given node
|
|
75
|
+ */
|
|
76
|
+
|
|
77
|
+function getContent (node) {
|
|
78
|
+ var text = ''
|
|
79
|
+ for (var i = 0; i < node.childNodes.length; i++) {
|
|
80
|
+ if (node.childNodes[i].nodeType === 1) {
|
|
81
|
+ text += node.childNodes[i]._replacement
|
|
82
|
+ } else if (node.childNodes[i].nodeType === 3) {
|
|
83
|
+ text += node.childNodes[i].data
|
|
84
|
+ } else continue
|
|
85
|
+ }
|
|
86
|
+ return text
|
|
87
|
+}
|
|
88
|
+
|
|
89
|
+/*
|
|
90
|
+ * Returns the HTML string of an element with its contents converted
|
|
91
|
+ */
|
|
92
|
+
|
|
93
|
+function outer (node, content) {
|
|
94
|
+ return node.cloneNode(false).outerHTML.replace('><', '>' + content + '<')
|
|
95
|
+}
|
|
96
|
+
|
|
97
|
+function canConvert (node, filter) {
|
|
98
|
+ if (typeof filter === 'string') {
|
|
99
|
+ return filter === node.nodeName.toLowerCase()
|
|
100
|
+ }
|
|
101
|
+ if (Array.isArray(filter)) {
|
|
102
|
+ return filter.indexOf(node.nodeName.toLowerCase()) !== -1
|
|
103
|
+ } else if (typeof filter === 'function') {
|
|
104
|
+ return filter.call(toMarkdown, node)
|
|
105
|
+ } else {
|
|
106
|
+ throw new TypeError('`filter` needs to be a string, array, or function')
|
|
107
|
+ }
|
|
108
|
+}
|
|
109
|
+
|
|
110
|
+function isFlankedByWhitespace (side, node) {
|
|
111
|
+ var sibling
|
|
112
|
+ var regExp
|
|
113
|
+ var isFlanked
|
|
114
|
+
|
|
115
|
+ if (side === 'left') {
|
|
116
|
+ sibling = node.previousSibling
|
|
117
|
+ regExp = / $/
|
|
118
|
+ } else {
|
|
119
|
+ sibling = node.nextSibling
|
|
120
|
+ regExp = /^ /
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ if (sibling) {
|
|
124
|
+ if (sibling.nodeType === 3) {
|
|
125
|
+ isFlanked = regExp.test(sibling.nodeValue)
|
|
126
|
+ } else if (sibling.nodeType === 1 && !isBlock(sibling)) {
|
|
127
|
+ isFlanked = regExp.test(sibling.textContent)
|
|
128
|
+ }
|
|
129
|
+ }
|
|
130
|
+ return isFlanked
|
|
131
|
+}
|
|
132
|
+
|
|
133
|
+function flankingWhitespace (node, content) {
|
|
134
|
+ var leading = ''
|
|
135
|
+ var trailing = ''
|
|
136
|
+
|
|
137
|
+ if (!isBlock(node)) {
|
|
138
|
+ var hasLeading = /^[ \r\n\t]/.test(content)
|
|
139
|
+ var hasTrailing = /[ \r\n\t]$/.test(content)
|
|
140
|
+
|
|
141
|
+ if (hasLeading && !isFlankedByWhitespace('left', node)) {
|
|
142
|
+ leading = ' '
|
|
143
|
+ }
|
|
144
|
+ if (hasTrailing && !isFlankedByWhitespace('right', node)) {
|
|
145
|
+ trailing = ' '
|
|
146
|
+ }
|
|
147
|
+ }
|
|
148
|
+
|
|
149
|
+ return { leading: leading, trailing: trailing }
|
|
150
|
+}
|
|
151
|
+
|
|
152
|
+/*
|
|
153
|
+ * Finds a Markdown converter, gets the replacement, and sets it on
|
|
154
|
+ * `_replacement`
|
|
155
|
+ */
|
|
156
|
+
|
|
157
|
+function process (node) {
|
|
158
|
+ var replacement
|
|
159
|
+ var content = getContent(node)
|
|
160
|
+
|
|
161
|
+ // Remove blank nodes
|
|
162
|
+ if (!isVoid(node) && !/A|TH|TD/.test(node.nodeName) && /^\s*$/i.test(content)) {
|
|
163
|
+ node._replacement = ''
|
|
164
|
+ return
|
|
165
|
+ }
|
|
166
|
+
|
|
167
|
+ for (var i = 0; i < converters.length; i++) {
|
|
168
|
+ var converter = converters[i]
|
|
169
|
+
|
|
170
|
+ if (canConvert(node, converter.filter)) {
|
|
171
|
+ if (typeof converter.replacement !== 'function') {
|
|
172
|
+ throw new TypeError(
|
|
173
|
+ '`replacement` needs to be a function that returns a string'
|
|
174
|
+ )
|
|
175
|
+ }
|
|
176
|
+
|
|
177
|
+ var whitespace = flankingWhitespace(node, content)
|
|
178
|
+
|
|
179
|
+ if (whitespace.leading || whitespace.trailing) {
|
|
180
|
+ content = content.trim()
|
|
181
|
+ }
|
|
182
|
+ replacement = whitespace.leading +
|
|
183
|
+ converter.replacement.call(toMarkdown, content, node) +
|
|
184
|
+ whitespace.trailing
|
|
185
|
+ break
|
|
186
|
+ }
|
|
187
|
+ }
|
|
188
|
+
|
|
189
|
+ node._replacement = replacement
|
|
190
|
+}
|
|
191
|
+
|
|
192
|
+toMarkdown = function (input, options) {
|
|
193
|
+ options = options || {}
|
|
194
|
+
|
|
195
|
+ if (typeof input !== 'string') {
|
|
196
|
+ throw new TypeError(input + ' is not a string')
|
|
197
|
+ }
|
|
198
|
+
|
|
199
|
+ if (input === '') {
|
|
200
|
+ return ''
|
|
201
|
+ }
|
|
202
|
+
|
|
203
|
+ // Escape potential ol triggers
|
|
204
|
+ input = input.replace(/(\d+)\. /g, '$1\\. ')
|
|
205
|
+
|
|
206
|
+ var clone = htmlToDom(input).body
|
|
207
|
+ var nodes = bfsOrder(clone)
|
|
208
|
+ var output
|
|
209
|
+
|
|
210
|
+ converters = mdConverters.slice(0)
|
|
211
|
+ if (options.gfm) {
|
|
212
|
+ converters = gfmConverters.concat(converters)
|
|
213
|
+ }
|
|
214
|
+
|
|
215
|
+ if (options.converters) {
|
|
216
|
+ converters = options.converters.concat(converters)
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ // Process through nodes in reverse (so deepest child elements are first).
|
|
220
|
+ for (var i = nodes.length - 1; i >= 0; i--) {
|
|
221
|
+ process(nodes[i])
|
|
222
|
+ }
|
|
223
|
+ output = getContent(clone)
|
|
224
|
+
|
|
225
|
+ return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g, '')
|
|
226
|
+ .replace(/\n\s+\n/g, '\n\n')
|
|
227
|
+ .replace(/\n{3,}/g, '\n\n')
|
|
228
|
+}
|
|
229
|
+
|
|
230
|
+toMarkdown.isBlock = isBlock
|
|
231
|
+toMarkdown.isVoid = isVoid
|
|
232
|
+toMarkdown.outer = outer
|
|
233
|
+
|
|
234
|
+module.exports = toMarkdown
|
|
235
|
+
|
|
236
|
+},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){
|
|
237
|
+'use strict'
|
|
238
|
+
|
|
239
|
+function cell (content, node) {
|
|
240
|
+ var index = Array.prototype.indexOf.call(node.parentNode.childNodes, node)
|
|
241
|
+ var prefix = ' '
|
|
242
|
+ if (index === 0) prefix = '| '
|
|
243
|
+ return prefix + content + ' |'
|
|
244
|
+}
|
|
245
|
+
|
|
246
|
+var highlightRegEx = /highlight highlight-(\S+)/
|
|
247
|
+
|
|
248
|
+module.exports = [
|
|
249
|
+ {
|
|
250
|
+ filter: 'br',
|
|
251
|
+ replacement: function () {
|
|
252
|
+ return '\n'
|
|
253
|
+ }
|
|
254
|
+ },
|
|
255
|
+ {
|
|
256
|
+ filter: ['del', 's', 'strike'],
|
|
257
|
+ replacement: function (content) {
|
|
258
|
+ return '~~' + content + '~~'
|
|
259
|
+ }
|
|
260
|
+ },
|
|
261
|
+
|
|
262
|
+ {
|
|
263
|
+ filter: function (node) {
|
|
264
|
+ return node.type === 'checkbox' && node.parentNode.nodeName === 'LI'
|
|
265
|
+ },
|
|
266
|
+ replacement: function (content, node) {
|
|
267
|
+ return (node.checked ? '[x]' : '[ ]') + ' '
|
|
268
|
+ }
|
|
269
|
+ },
|
|
270
|
+
|
|
271
|
+ {
|
|
272
|
+ filter: ['th', 'td'],
|
|
273
|
+ replacement: function (content, node) {
|
|
274
|
+ return cell(content, node)
|
|
275
|
+ }
|
|
276
|
+ },
|
|
277
|
+
|
|
278
|
+ {
|
|
279
|
+ filter: 'tr',
|
|
280
|
+ replacement: function (content, node) {
|
|
281
|
+ var borderCells = ''
|
|
282
|
+ var alignMap = { left: ':--', right: '--:', center: ':-:' }
|
|
283
|
+
|
|
284
|
+ if (node.parentNode.nodeName === 'THEAD') {
|
|
285
|
+ for (var i = 0; i < node.childNodes.length; i++) {
|
|
286
|
+ var align = node.childNodes[i].attributes.align
|
|
287
|
+ var border = '---'
|
|
288
|
+
|
|
289
|
+ if (align) border = alignMap[align.value] || border
|
|
290
|
+
|
|
291
|
+ borderCells += cell(border, node.childNodes[i])
|
|
292
|
+ }
|
|
293
|
+ }
|
|
294
|
+ return '\n' + content + (borderCells ? '\n' + borderCells : '')
|
|
295
|
+ }
|
|
296
|
+ },
|
|
297
|
+
|
|
298
|
+ {
|
|
299
|
+ filter: 'table',
|
|
300
|
+ replacement: function (content) {
|
|
301
|
+ return '\n\n' + content + '\n\n'
|
|
302
|
+ }
|
|
303
|
+ },
|
|
304
|
+
|
|
305
|
+ {
|
|
306
|
+ filter: ['thead', 'tbody', 'tfoot'],
|
|
307
|
+ replacement: function (content) {
|
|
308
|
+ return content
|
|
309
|
+ }
|
|
310
|
+ },
|
|
311
|
+
|
|
312
|
+ // Fenced code blocks
|
|
313
|
+ {
|
|
314
|
+ filter: function (node) {
|
|
315
|
+ return node.nodeName === 'PRE' &&
|
|
316
|
+ node.firstChild &&
|
|
317
|
+ node.firstChild.nodeName === 'CODE'
|
|
318
|
+ },
|
|
319
|
+ replacement: function (content, node) {
|
|
320
|
+ return '\n\n```\n' + node.firstChild.textContent + '\n```\n\n'
|
|
321
|
+ }
|
|
322
|
+ },
|
|
323
|
+
|
|
324
|
+ // Syntax-highlighted code blocks
|
|
325
|
+ {
|
|
326
|
+ filter: function (node) {
|
|
327
|
+ return node.nodeName === 'PRE' &&
|
|
328
|
+ node.parentNode.nodeName === 'DIV' &&
|
|
329
|
+ highlightRegEx.test(node.parentNode.className)
|
|
330
|
+ },
|
|
331
|
+ replacement: function (content, node) {
|
|
332
|
+ var language = node.parentNode.className.match(highlightRegEx)[1]
|
|
333
|
+ return '\n\n```' + language + '\n' + node.textContent + '\n```\n\n'
|
|
334
|
+ }
|
|
335
|
+ },
|
|
336
|
+
|
|
337
|
+ {
|
|
338
|
+ filter: function (node) {
|
|
339
|
+ return node.nodeName === 'DIV' &&
|
|
340
|
+ highlightRegEx.test(node.className)
|
|
341
|
+ },
|
|
342
|
+ replacement: function (content) {
|
|
343
|
+ return '\n\n' + content + '\n\n'
|
|
344
|
+ }
|
|
345
|
+ }
|
|
346
|
+]
|
|
347
|
+
|
|
348
|
+},{}],3:[function(require,module,exports){
|
|
349
|
+/*
|
|
350
|
+ * Set up window for Node.js
|
|
351
|
+ */
|
|
352
|
+
|
|
353
|
+var _window = (typeof window !== 'undefined' ? window : this)
|
|
354
|
+
|
|
355
|
+/*
|
|
356
|
+ * Parsing HTML strings
|
|
357
|
+ */
|
|
358
|
+
|
|
359
|
+function canParseHtmlNatively () {
|
|
360
|
+ var Parser = _window.DOMParser
|
|
361
|
+ var canParse = false
|
|
362
|
+
|
|
363
|
+ // Adapted from https://gist.github.com/1129031
|
|
364
|
+ // Firefox/Opera/IE throw errors on unsupported types
|
|
365
|
+ try {
|
|
366
|
+ // WebKit returns null on unsupported types
|
|
367
|
+ if (new Parser().parseFromString('', 'text/html')) {
|
|
368
|
+ canParse = true
|
|
369
|
+ }
|
|
370
|
+ } catch (e) {}
|
|
371
|
+
|
|
372
|
+ return canParse
|
|
373
|
+}
|
|
374
|
+
|
|
375
|
+function createHtmlParser () {
|
|
376
|
+ var Parser = function () {}
|
|
377
|
+
|
|
378
|
+ // For Node.js environments
|
|
379
|
+ if (typeof document === 'undefined') {
|
|
380
|
+ var jsdom = require('jsdom')
|
|
381
|
+ Parser.prototype.parseFromString = function (string) {
|
|
382
|
+ return jsdom.jsdom(string, {
|
|
383
|
+ features: {
|
|
384
|
+ FetchExternalResources: [],
|
|
385
|
+ ProcessExternalResources: false
|
|
386
|
+ }
|
|
387
|
+ })
|
|
388
|
+ }
|
|
389
|
+ } else {
|
|
390
|
+ if (!shouldUseActiveX()) {
|
|
391
|
+ Parser.prototype.parseFromString = function (string) {
|
|
392
|
+ var doc = document.implementation.createHTMLDocument('')
|
|
393
|
+ doc.open()
|
|
394
|
+ doc.write(string)
|
|
395
|
+ doc.close()
|
|
396
|
+ return doc
|
|
397
|
+ }
|
|
398
|
+ } else {
|
|
399
|
+ Parser.prototype.parseFromString = function (string) {
|
|
400
|
+ var doc = new window.ActiveXObject('htmlfile')
|
|
401
|
+ doc.designMode = 'on' // disable on-page scripts
|
|
402
|
+ doc.open()
|
|
403
|
+ doc.write(string)
|
|
404
|
+ doc.close()
|
|
405
|
+ return doc
|
|
406
|
+ }
|
|
407
|
+ }
|
|
408
|
+ }
|
|
409
|
+ return Parser
|
|
410
|
+}
|
|
411
|
+
|
|
412
|
+function shouldUseActiveX () {
|
|
413
|
+ var useActiveX = false
|
|
414
|
+
|
|
415
|
+ try {
|
|
416
|
+ document.implementation.createHTMLDocument('').open()
|
|
417
|
+ } catch (e) {
|
|
418
|
+ if (window.ActiveXObject) useActiveX = true
|
|
419
|
+ }
|
|
420
|
+
|
|
421
|
+ return useActiveX
|
|
422
|
+}
|
|
423
|
+
|
|
424
|
+module.exports = canParseHtmlNatively() ? _window.DOMParser : createHtmlParser()
|
|
425
|
+
|
|
426
|
+},{"jsdom":6}],4:[function(require,module,exports){
|
|
427
|
+'use strict'
|
|
428
|
+
|
|
429
|
+module.exports = [
|
|
430
|
+ {
|
|
431
|
+ filter: 'p',
|
|
432
|
+ replacement: function (content) {
|
|
433
|
+ return '\n\n' + content + '\n\n'
|
|
434
|
+ }
|
|
435
|
+ },
|
|
436
|
+
|
|
437
|
+ {
|
|
438
|
+ filter: 'br',
|
|
439
|
+ replacement: function () {
|
|
440
|
+ return ' \n'
|
|
441
|
+ }
|
|
442
|
+ },
|
|
443
|
+
|
|
444
|
+ {
|
|
445
|
+ filter: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
|
|
446
|
+ replacement: function (content, node) {
|
|
447
|
+ var hLevel = node.nodeName.charAt(1)
|
|
448
|
+ var hPrefix = ''
|
|
449
|
+ for (var i = 0; i < hLevel; i++) {
|
|
450
|
+ hPrefix += '#'
|
|
451
|
+ }
|
|
452
|
+ return '\n\n' + hPrefix + ' ' + content + '\n\n'
|
|
453
|
+ }
|
|
454
|
+ },
|
|
455
|
+
|
|
456
|
+ {
|
|
457
|
+ filter: 'hr',
|
|
458
|
+ replacement: function () {
|
|
459
|
+ return '\n\n* * *\n\n'
|
|
460
|
+ }
|
|
461
|
+ },
|
|
462
|
+
|
|
463
|
+ {
|
|
464
|
+ filter: ['em', 'i'],
|
|
465
|
+ replacement: function (content) {
|
|
466
|
+ return '_' + content + '_'
|
|
467
|
+ }
|
|
468
|
+ },
|
|
469
|
+
|
|
470
|
+ {
|
|
471
|
+ filter: ['strong', 'b'],
|
|
472
|
+ replacement: function (content) {
|
|
473
|
+ return '**' + content + '**'
|
|
474
|
+ }
|
|
475
|
+ },
|
|
476
|
+
|
|
477
|
+ // Inline code
|
|
478
|
+ {
|
|
479
|
+ filter: function (node) {
|
|
480
|
+ var hasSiblings = node.previousSibling || node.nextSibling
|
|
481
|
+ var isCodeBlock = node.parentNode.nodeName === 'PRE' && !hasSiblings
|
|
482
|
+
|
|
483
|
+ return node.nodeName === 'CODE' && !isCodeBlock
|
|
484
|
+ },
|
|
485
|
+ replacement: function (content) {
|
|
486
|
+ return '`' + content + '`'
|
|
487
|
+ }
|
|
488
|
+ },
|
|
489
|
+
|
|
490
|
+ {
|
|
491
|
+ filter: function (node) {
|
|
492
|
+ return node.nodeName === 'A' && node.getAttribute('href')
|
|
493
|
+ },
|
|
494
|
+ replacement: function (content, node) {
|
|
495
|
+ var titlePart = node.title ? ' "' + node.title + '"' : ''
|
|
496
|
+ return '[' + content + '](' + node.getAttribute('href') + titlePart + ')'
|
|
497
|
+ }
|
|
498
|
+ },
|
|
499
|
+
|
|
500
|
+ {
|
|
501
|
+ filter: 'img',
|
|
502
|
+ replacement: function (content, node) {
|
|
503
|
+ var alt = node.alt || ''
|
|
504
|
+ var src = node.getAttribute('src') || ''
|
|
505
|
+ var title = node.title || ''
|
|
506
|
+ var titlePart = title ? ' "' + title + '"' : ''
|
|
507
|
+ return src ? '![' + alt + ']' + '(' + src + titlePart + ')' : ''
|
|
508
|
+ }
|
|
509
|
+ },
|
|
510
|
+
|
|
511
|
+ // Code blocks
|
|
512
|
+ {
|
|
513
|
+ filter: function (node) {
|
|
514
|
+ return node.nodeName === 'PRE' && node.firstChild.nodeName === 'CODE'
|
|
515
|
+ },
|
|
516
|
+ replacement: function (content, node) {
|
|
517
|
+ return '\n\n ' + node.firstChild.textContent.replace(/\n/g, '\n ') + '\n\n'
|
|
518
|
+ }
|
|
519
|
+ },
|
|
520
|
+
|
|
521
|
+ {
|
|
522
|
+ filter: 'blockquote',
|
|
523
|
+ replacement: function (content) {
|
|
524
|
+ content = content.trim()
|
|
525
|
+ content = content.replace(/\n{3,}/g, '\n\n')
|
|
526
|
+ content = content.replace(/^/gm, '> ')
|
|
527
|
+ return '\n\n' + content + '\n\n'
|
|
528
|
+ }
|
|
529
|
+ },
|
|
530
|
+
|
|
531
|
+ {
|
|
532
|
+ filter: 'li',
|
|
533
|
+ replacement: function (content, node) {
|
|
534
|
+ content = content.replace(/^\s+/, '').replace(/\n/gm, '\n ')
|
|
535
|
+ var prefix = '* '
|
|
536
|
+ var parent = node.parentNode
|
|
537
|
+ var index = Array.prototype.indexOf.call(parent.children, node) + 1
|
|
538
|
+
|
|
539
|
+ prefix = /ol/i.test(parent.nodeName) ? index + '. ' : '* '
|
|
540
|
+ return prefix + content
|
|
541
|
+ }
|
|
542
|
+ },
|
|
543
|
+
|
|
544
|
+ {
|
|
545
|
+ filter: ['ul', 'ol'],
|
|
546
|
+ replacement: function (content, node) {
|
|
547
|
+ var strings = []
|
|
548
|
+ for (var i = 0; i < node.childNodes.length; i++) {
|
|
549
|
+ strings.push(node.childNodes[i]._replacement)
|
|
550
|
+ }
|
|
551
|
+
|
|
552
|
+ if (/li/i.test(node.parentNode.nodeName)) {
|
|
553
|
+ return '\n' + strings.join('\n')
|
|
554
|
+ }
|
|
555
|
+ return '\n\n' + strings.join('\n') + '\n\n'
|
|
556
|
+ }
|
|
557
|
+ },
|
|
558
|
+
|
|
559
|
+ {
|
|
560
|
+ filter: function (node) {
|
|
561
|
+ return this.isBlock(node)
|
|
562
|
+ },
|
|
563
|
+ replacement: function (content, node) {
|
|
564
|
+ return '\n\n' + this.outer(node, content) + '\n\n'
|
|
565
|
+ }
|
|
566
|
+ },
|
|
567
|
+
|
|
568
|
+ // Anything else!
|
|
569
|
+ {
|
|
570
|
+ filter: function () {
|
|
571
|
+ return true
|
|
572
|
+ },
|
|
573
|
+ replacement: function (content, node) {
|
|
574
|
+ return this.outer(node, content)
|
|
575
|
+ }
|
|
576
|
+ }
|
|
577
|
+]
|
|
578
|
+
|
|
579
|
+},{}],5:[function(require,module,exports){
|
|
580
|
+/**
|
|
581
|
+ * This file automatically generated from `build.js`.
|
|
582
|
+ * Do not manually edit.
|
|
583
|
+ */
|
|
584
|
+
|
|
585
|
+module.exports = [
|
|
586
|
+ "address",
|
|
587
|
+ "article",
|
|
588
|
+ "aside",
|
|
589
|
+ "audio",
|
|
590
|
+ "blockquote",
|
|
591
|
+ "canvas",
|
|
592
|
+ "dd",
|
|
593
|
+ "div",
|
|
594
|
+ "dl",
|
|
595
|
+ "fieldset",
|
|
596
|
+ "figcaption",
|
|
597
|
+ "figure",
|
|
598
|
+ "footer",
|
|
599
|
+ "form",
|
|
600
|
+ "h1",
|
|
601
|
+ "h2",
|
|
602
|
+ "h3",
|
|
603
|
+ "h4",
|
|
604
|
+ "h5",
|
|
605
|
+ "h6",
|
|
606
|
+ "header",
|
|
607
|
+ "hgroup",
|
|
608
|
+ "hr",
|
|
609
|
+ "main",
|
|
610
|
+ "nav",
|
|
611
|
+ "noscript",
|
|
612
|
+ "ol",
|
|
613
|
+ "output",
|
|
614
|
+ "p",
|
|
615
|
+ "pre",
|
|
616
|
+ "section",
|
|
617
|
+ "table",
|
|
618
|
+ "tfoot",
|
|
619
|
+ "ul",
|
|
620
|
+ "video"
|
|
621
|
+];
|
|
622
|
+
|
|
623
|
+},{}],6:[function(require,module,exports){
|
|
624
|
+
|
|
625
|
+},{}],7:[function(require,module,exports){
|
|
626
|
+'use strict';
|
|
627
|
+
|
|
628
|
+var voidElements = require('void-elements');
|
|
629
|
+Object.keys(voidElements).forEach(function (name) {
|
|
630
|
+ voidElements[name.toUpperCase()] = 1;
|
|
631
|
+});
|
|
632
|
+
|
|
633
|
+var blockElements = {};
|
|
634
|
+require('block-elements').forEach(function (name) {
|
|
635
|
+ blockElements[name.toUpperCase()] = 1;
|
|
636
|
+});
|
|
637
|
+
|
|
638
|
+/**
|
|
639
|
+ * isBlockElem(node) determines if the given node is a block element.
|
|
640
|
+ *
|
|
641
|
+ * @param {Node} node
|
|
642
|
+ * @return {Boolean}
|
|
643
|
+ */
|
|
644
|
+function isBlockElem(node) {
|
|
645
|
+ return !!(node && blockElements[node.nodeName]);
|
|
646
|
+}
|
|
647
|
+
|
|
648
|
+/**
|
|
649
|
+ * isVoid(node) determines if the given node is a void element.
|
|
650
|
+ *
|
|
651
|
+ * @param {Node} node
|
|
652
|
+ * @return {Boolean}
|
|
653
|
+ */
|
|
654
|
+function isVoid(node) {
|
|
655
|
+ return !!(node && voidElements[node.nodeName]);
|
|
656
|
+}
|
|
657
|
+
|
|
658
|
+/**
|
|
659
|
+ * whitespace(elem [, isBlock]) removes extraneous whitespace from an
|
|
660
|
+ * the given element. The function isBlock may optionally be passed in
|
|
661
|
+ * to determine whether or not an element is a block element; if none
|
|
662
|
+ * is provided, defaults to using the list of block elements provided
|
|
663
|
+ * by the `block-elements` module.
|
|
664
|
+ *
|
|
665
|
+ * @param {Node} elem
|
|
666
|
+ * @param {Function} blockTest
|
|
667
|
+ */
|
|
668
|
+function collapseWhitespace(elem, isBlock) {
|
|
669
|
+ if (!elem.firstChild || elem.nodeName === 'PRE') return;
|
|
670
|
+
|
|
671
|
+ if (typeof isBlock !== 'function') {
|
|
672
|
+ isBlock = isBlockElem;
|
|
673
|
+ }
|
|
674
|
+
|
|
675
|
+ var prevText = null;
|
|
676
|
+ var prevVoid = false;
|
|
677
|
+
|
|
678
|
+ var prev = null;
|
|
679
|
+ var node = next(prev, elem);
|
|
680
|
+
|
|
681
|
+ while (node !== elem) {
|
|
682
|
+ if (node.nodeType === 3) {
|
|
683
|
+ // Node.TEXT_NODE
|
|
684
|
+ var text = node.data.replace(/[ \r\n\t]+/g, ' ');
|
|
685
|
+
|
|
686
|
+ if ((!prevText || / $/.test(prevText.data)) && !prevVoid && text[0] === ' ') {
|
|
687
|
+ text = text.substr(1);
|
|
688
|
+ }
|
|
689
|
+
|
|
690
|
+ // `text` might be empty at this point.
|
|
691
|
+ if (!text) {
|
|
692
|
+ node = remove(node);
|
|
693
|
+ continue;
|
|
694
|
+ }
|
|
695
|
+
|
|
696
|
+ node.data = text;
|
|
697
|
+ prevText = node;
|
|
698
|
+ } else if (node.nodeType === 1) {
|
|
699
|
+ // Node.ELEMENT_NODE
|
|
700
|
+ if (isBlock(node) || node.nodeName === 'BR') {
|
|
701
|
+ if (prevText) {
|
|
702
|
+ prevText.data = prevText.data.replace(/ $/, '');
|
|
703
|
+ }
|
|
704
|
+
|
|
705
|
+ prevText = null;
|
|
706
|
+ prevVoid = false;
|
|
707
|
+ } else if (isVoid(node)) {
|
|
708
|
+ // Avoid trimming space around non-block, non-BR void elements.
|
|
709
|
+ prevText = null;
|
|
710
|
+ prevVoid = true;
|
|
711
|
+ }
|
|
712
|
+ } else {
|
|
713
|
+ node = remove(node);
|
|
714
|
+ continue;
|
|
715
|
+ }
|
|
716
|
+
|
|
717
|
+ var nextNode = next(prev, node);
|
|
718
|
+ prev = node;
|
|
719
|
+ node = nextNode;
|
|
720
|
+ }
|
|
721
|
+
|
|
722
|
+ if (prevText) {
|
|
723
|
+ prevText.data = prevText.data.replace(/ $/, '');
|
|
724
|
+ if (!prevText.data) {
|
|
725
|
+ remove(prevText);
|
|
726
|
+ }
|
|
727
|
+ }
|
|
728
|
+}
|
|
729
|
+
|
|
730
|
+/**
|
|
731
|
+ * remove(node) removes the given node from the DOM and returns the
|
|
732
|
+ * next node in the sequence.
|
|
733
|
+ *
|
|
734
|
+ * @param {Node} node
|
|
735
|
+ * @return {Node} node
|
|
736
|
+ */
|
|
737
|
+function remove(node) {
|
|
738
|
+ var next = node.nextSibling || node.parentNode;
|
|
739
|
+
|
|
740
|
+ node.parentNode.removeChild(node);
|
|
741
|
+
|
|
742
|
+ return next;
|
|
743
|
+}
|
|
744
|
+
|
|
745
|
+/**
|
|
746
|
+ * next(prev, current) returns the next node in the sequence, given the
|
|
747
|
+ * current and previous nodes.
|
|
748
|
+ *
|
|
749
|
+ * @param {Node} prev
|
|
750
|
+ * @param {Node} current
|
|
751
|
+ * @return {Node}
|
|
752
|
+ */
|
|
753
|
+function next(prev, current) {
|
|
754
|
+ if (prev && prev.parentNode === current || current.nodeName === 'PRE') {
|
|
755
|
+ return current.nextSibling || current.parentNode;
|
|
756
|
+ }
|
|
757
|
+
|
|
758
|
+ return current.firstChild || current.nextSibling || current.parentNode;
|
|
759
|
+}
|
|
760
|
+
|
|
761
|
+module.exports = collapseWhitespace;
|
|
762
|
+
|
|
763
|
+},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){
|
|
764
|
+/**
|
|
765
|
+ * This file automatically generated from `pre-publish.js`.
|
|
766
|
+ * Do not manually edit.
|
|
767
|
+ */
|
|
768
|
+
|
|
769
|
+module.exports = {
|
|
770
|
+ "area": true,
|
|
771
|
+ "base": true,
|
|
772
|
+ "br": true,
|
|
773
|
+ "col": true,
|
|
774
|
+ "embed": true,
|
|
775
|
+ "hr": true,
|
|
776
|
+ "img": true,
|
|
777
|
+ "input": true,
|
|
778
|
+ "keygen": true,
|
|
779
|
+ "link": true,
|
|
780
|
+ "menuitem": true,
|
|
781
|
+ "meta": true,
|
|
782
|
+ "param": true,
|
|
783
|
+ "source": true,
|
|
784
|
+ "track": true,
|
|
785
|
+ "wbr": true
|
|
786
|
+};
|
|
787
|
+
|
|
788
|
+},{}]},{},[1])(1)
|
|
789
|
+});
|
|
|
@@ -0,0 +1,3 @@
|
|
1
|
+(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else{if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else{if(typeof global!=="undefined"){g=global}else{if(typeof self!=="undefined"){g=self}else{g=this}}}g.toMarkdown=f()}}})(function(){var define,module,exports;return(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a){return a(o,!0)}if(i){return i(o,!0)}var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++){s(r[o])}return s})({1:[function(require,module,exports){var toMarkdown;var converters;var mdConverters=require("./lib/md-converters");var gfmConverters=require("./lib/gfm-converters");var HtmlParser=require("./lib/html-parser");var collapse=require("collapse-whitespace");var blocks=["address","article","aside","audio","blockquote","body","canvas","center","dd","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frameset","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","isindex","li","main","menu","nav","noframes","noscript","ol","output","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"];function isBlock(node){return blocks.indexOf(node.nodeName.toLowerCase())!==-1}var voids=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"];function isVoid(node){return voids.indexOf(node.nodeName.toLowerCase())!==-1}function htmlToDom(string){var tree=new HtmlParser().parseFromString(string,"text/html");collapse(tree.documentElement,isBlock);return tree}function bfsOrder(node){var inqueue=[node];var outqueue=[];var elem;var children;var i;while(inqueue.length>0){elem=inqueue.shift();outqueue.push(elem);children=elem.childNodes;for(i=0;i<children.length;i++){if(children[i].nodeType===1){inqueue.push(children[i])}}}outqueue.shift();return outqueue}function getContent(node){var text="";for(var i=0;i<node.childNodes.length;i++){if(node.childNodes[i].nodeType===1){text+=node.childNodes[i]._replacement}else{if(node.childNodes[i].nodeType===3){text+=node.childNodes[i].data}else{continue}}}return text}function outer(node,content){return node.cloneNode(false).outerHTML.replace("><",">"+content+"<")}function canConvert(node,filter){if(typeof filter==="string"){return filter===node.nodeName.toLowerCase()}if(Array.isArray(filter)){return filter.indexOf(node.nodeName.toLowerCase())!==-1}else{if(typeof filter==="function"){return filter.call(toMarkdown,node)}else{throw new TypeError("`filter` needs to be a string, array, or function")}}}function isFlankedByWhitespace(side,node){var sibling;var regExp;var isFlanked;if(side==="left"){sibling=node.previousSibling;regExp=/ $/}else{sibling=node.nextSibling;regExp=/^ /}if(sibling){if(sibling.nodeType===3){isFlanked=regExp.test(sibling.nodeValue)}else{if(sibling.nodeType===1&&!isBlock(sibling)){isFlanked=regExp.test(sibling.textContent)}}}return isFlanked}function flankingWhitespace(node,content){var leading="";var trailing="";if(!isBlock(node)){var hasLeading=/^[ \r\n\t]/.test(content);var hasTrailing=/[ \r\n\t]$/.test(content);if(hasLeading&&!isFlankedByWhitespace("left",node)){leading=" "}if(hasTrailing&&!isFlankedByWhitespace("right",node)){trailing=" "}}return{leading:leading,trailing:trailing}}function process(node){var replacement;var content=getContent(node);if(!isVoid(node)&&!/A|TH|TD/.test(node.nodeName)&&/^\s*$/i.test(content)){node._replacement="";return}for(var i=0;i<converters.length;i++){var converter=converters[i];if(canConvert(node,converter.filter)){if(typeof converter.replacement!=="function"){throw new TypeError("`replacement` needs to be a function that returns a string")}var whitespace=flankingWhitespace(node,content);if(whitespace.leading||whitespace.trailing){content=content.trim()}replacement=whitespace.leading+converter.replacement.call(toMarkdown,content,node)+whitespace.trailing;break}}node._replacement=replacement}toMarkdown=function(input,options){options=options||{};if(typeof input!=="string"){throw new TypeError(input+" is not a string")}if(input===""){return""}input=input.replace(/(\d+)\. /g,"$1\\. ");var clone=htmlToDom(input).body;var nodes=bfsOrder(clone);var output;converters=mdConverters.slice(0);if(options.gfm){converters=gfmConverters.concat(converters)}if(options.converters){converters=options.converters.concat(converters)}for(var i=nodes.length-1;i>=0;i--){process(nodes[i])}output=getContent(clone);return output.replace(/^[\t\r\n]+|[\t\r\n\s]+$/g,"").replace(/\n\s+\n/g,"\n\n").replace(/\n{3,}/g,"\n\n")};toMarkdown.isBlock=isBlock;toMarkdown.isVoid=isVoid;toMarkdown.outer=outer;module.exports=toMarkdown},{"./lib/gfm-converters":2,"./lib/html-parser":3,"./lib/md-converters":4,"collapse-whitespace":7}],2:[function(require,module,exports){function cell(content,node){var index=Array.prototype.indexOf.call(node.parentNode.childNodes,node);
|
|
2
|
+var prefix=" ";if(index===0){prefix="| "}return prefix+content+" |"}var highlightRegEx=/highlight highlight-(\S+)/;module.exports=[{filter:"br",replacement:function(){return"\n"}},{filter:["del","s","strike"],replacement:function(content){return"~~"+content+"~~"}},{filter:function(node){return node.type==="checkbox"&&node.parentNode.nodeName==="LI"},replacement:function(content,node){return(node.checked?"[x]":"[ ]")+" "}},{filter:["th","td"],replacement:function(content,node){return cell(content,node)}},{filter:"tr",replacement:function(content,node){var borderCells="";var alignMap={left:":--",right:"--:",center:":-:"};if(node.parentNode.nodeName==="THEAD"){for(var i=0;i<node.childNodes.length;i++){var align=node.childNodes[i].attributes.align;var border="---";if(align){border=alignMap[align.value]||border}borderCells+=cell(border,node.childNodes[i])}}return"\n"+content+(borderCells?"\n"+borderCells:"")}},{filter:"table",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:["thead","tbody","tfoot"],replacement:function(content){return content}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n```\n"+node.firstChild.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="PRE"&&node.parentNode.nodeName==="DIV"&&highlightRegEx.test(node.parentNode.className)},replacement:function(content,node){var language=node.parentNode.className.match(highlightRegEx)[1];return"\n\n```"+language+"\n"+node.textContent+"\n```\n\n"}},{filter:function(node){return node.nodeName==="DIV"&&highlightRegEx.test(node.className)},replacement:function(content){return"\n\n"+content+"\n\n"}}]},{}],3:[function(require,module,exports){var _window=(typeof window!=="undefined"?window:this);function canParseHtmlNatively(){var Parser=_window.DOMParser;var canParse=false;try{if(new Parser().parseFromString("","text/html")){canParse=true}}catch(e){}return canParse}function createHtmlParser(){var Parser=function(){};if(typeof document==="undefined"){var jsdom=require("jsdom");Parser.prototype.parseFromString=function(string){return jsdom.jsdom(string,{features:{FetchExternalResources:[],ProcessExternalResources:false}})}}else{if(!shouldUseActiveX()){Parser.prototype.parseFromString=function(string){var doc=document.implementation.createHTMLDocument("");doc.open();doc.write(string);doc.close();return doc}}else{Parser.prototype.parseFromString=function(string){var doc=new window.ActiveXObject("htmlfile");doc.designMode="on";doc.open();doc.write(string);doc.close();return doc}}}return Parser}function shouldUseActiveX(){var useActiveX=false;try{document.implementation.createHTMLDocument("").open()}catch(e){if(window.ActiveXObject){useActiveX=true}}return useActiveX}module.exports=canParseHtmlNatively()?_window.DOMParser:createHtmlParser()},{"jsdom":6}],4:[function(require,module,exports){module.exports=[{filter:"p",replacement:function(content){return"\n\n"+content+"\n\n"}},{filter:"br",replacement:function(){return" \n"}},{filter:["h1","h2","h3","h4","h5","h6"],replacement:function(content,node){var hLevel=node.nodeName.charAt(1);var hPrefix="";for(var i=0;i<hLevel;i++){hPrefix+="#"}return"\n\n"+hPrefix+" "+content+"\n\n"}},{filter:"hr",replacement:function(){return"\n\n* * *\n\n"}},{filter:["em","i"],replacement:function(content){return"_"+content+"_"}},{filter:["strong","b"],replacement:function(content){return"**"+content+"**"}},{filter:function(node){var hasSiblings=node.previousSibling||node.nextSibling;var isCodeBlock=node.parentNode.nodeName==="PRE"&&!hasSiblings;return node.nodeName==="CODE"&&!isCodeBlock},replacement:function(content){return"`"+content+"`"}},{filter:function(node){return node.nodeName==="A"&&node.getAttribute("href")},replacement:function(content,node){var titlePart=node.title?' "'+node.title+'"':"";return"["+content+"]("+node.getAttribute("href")+titlePart+")"}},{filter:"img",replacement:function(content,node){var alt=node.alt||"";var src=node.getAttribute("src")||"";var title=node.title||"";var titlePart=title?' "'+title+'"':"";return src?"!["+alt+"]"+"("+src+titlePart+")":""}},{filter:function(node){return node.nodeName==="PRE"&&node.firstChild.nodeName==="CODE"},replacement:function(content,node){return"\n\n "+node.firstChild.textContent.replace(/\n/g,"\n ")+"\n\n"}},{filter:"blockquote",replacement:function(content){content=content.trim();content=content.replace(/\n{3,}/g,"\n\n");content=content.replace(/^/gm,"> ");return"\n\n"+content+"\n\n"}},{filter:"li",replacement:function(content,node){content=content.replace(/^\s+/,"").replace(/\n/gm,"\n ");var prefix="* ";var parent=node.parentNode;var index=Array.prototype.indexOf.call(parent.children,node)+1;prefix=/ol/i.test(parent.nodeName)?index+". ":"* ";return prefix+content}},{filter:["ul","ol"],replacement:function(content,node){var strings=[];for(var i=0;i<node.childNodes.length;i++){strings.push(node.childNodes[i]._replacement)
|
|
3
|
+}if(/li/i.test(node.parentNode.nodeName)){return"\n"+strings.join("\n")}return"\n\n"+strings.join("\n")+"\n\n"}},{filter:function(node){return this.isBlock(node)},replacement:function(content,node){return"\n\n"+this.outer(node,content)+"\n\n"}},{filter:function(){return true},replacement:function(content,node){return this.outer(node,content)}}]},{}],5:[function(require,module,exports){module.exports=["address","article","aside","audio","blockquote","canvas","dd","div","dl","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","main","nav","noscript","ol","output","p","pre","section","table","tfoot","ul","video"]},{}],6:[function(require,module,exports){},{}],7:[function(require,module,exports){var voidElements=require("void-elements");Object.keys(voidElements).forEach(function(name){voidElements[name.toUpperCase()]=1});var blockElements={};require("block-elements").forEach(function(name){blockElements[name.toUpperCase()]=1});function isBlockElem(node){return !!(node&&blockElements[node.nodeName])}function isVoid(node){return !!(node&&voidElements[node.nodeName])}function collapseWhitespace(elem,isBlock){if(!elem.firstChild||elem.nodeName==="PRE"){return}if(typeof isBlock!=="function"){isBlock=isBlockElem}var prevText=null;var prevVoid=false;var prev=null;var node=next(prev,elem);while(node!==elem){if(node.nodeType===3){var text=node.data.replace(/[ \r\n\t]+/g," ");if((!prevText||/ $/.test(prevText.data))&&!prevVoid&&text[0]===" "){text=text.substr(1)}if(!text){node=remove(node);continue}node.data=text;prevText=node}else{if(node.nodeType===1){if(isBlock(node)||node.nodeName==="BR"){if(prevText){prevText.data=prevText.data.replace(/ $/,"")}prevText=null;prevVoid=false}else{if(isVoid(node)){prevText=null;prevVoid=true}}}else{node=remove(node);continue}}var nextNode=next(prev,node);prev=node;node=nextNode}if(prevText){prevText.data=prevText.data.replace(/ $/,"");if(!prevText.data){remove(prevText)}}}function remove(node){var next=node.nextSibling||node.parentNode;node.parentNode.removeChild(node);return next}function next(prev,current){if(prev&&prev.parentNode===current||current.nodeName==="PRE"){return current.nextSibling||current.parentNode}return current.firstChild||current.nextSibling||current.parentNode}module.exports=collapseWhitespace},{"block-elements":5,"void-elements":8}],8:[function(require,module,exports){module.exports={"area":true,"base":true,"br":true,"col":true,"embed":true,"hr":true,"img":true,"input":true,"keygen":true,"link":true,"menuitem":true,"meta":true,"param":true,"source":true,"track":true,"wbr":true}},{}]},{},[1])(1)});
|
|
|
@@ -0,0 +1,261 @@
|
|
1
|
+(function (root, factory) {
|
|
2
|
+ if (typeof define === 'function' && define.amd) {
|
|
3
|
+ // AMD. Register as an anonymous module unless amdModuleId is set
|
|
4
|
+ define('simple-uploader', ["jquery","simple-module"], function ($, SimpleModule) {
|
|
5
|
+ return (root['uploader'] = factory($, SimpleModule));
|
|
6
|
+ });
|
|
7
|
+ } else if (typeof exports === 'object') {
|
|
8
|
+ // Node. Does not work with strict CommonJS, but
|
|
9
|
+ // only CommonJS-like environments that support module.exports,
|
|
10
|
+ // like Node.
|
|
11
|
+ module.exports = factory(require("jquery"),require("simple-module"));
|
|
12
|
+ } else {
|
|
13
|
+ root.simple = root.simple || {};
|
|
14
|
+ root.simple['uploader'] = factory(jQuery,SimpleModule);
|
|
15
|
+ }
|
|
16
|
+}(this, function ($, SimpleModule) {
|
|
17
|
+
|
|
18
|
+var Uploader, uploader,
|
|
19
|
+ extend = 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; },
|
|
20
|
+ hasProp = {}.hasOwnProperty;
|
|
21
|
+
|
|
22
|
+Uploader = (function(superClass) {
|
|
23
|
+ extend(Uploader, superClass);
|
|
24
|
+
|
|
25
|
+ function Uploader() {
|
|
26
|
+ return Uploader.__super__.constructor.apply(this, arguments);
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ Uploader.count = 0;
|
|
30
|
+
|
|
31
|
+ Uploader.prototype.opts = {
|
|
32
|
+ url: '',
|
|
33
|
+ params: null,
|
|
34
|
+ fileKey: 'upload_file',
|
|
35
|
+ connectionCount: 3
|
|
36
|
+ };
|
|
37
|
+
|
|
38
|
+ Uploader.prototype._init = function() {
|
|
39
|
+ this.files = [];
|
|
40
|
+ this.queue = [];
|
|
41
|
+ this.id = ++Uploader.count;
|
|
42
|
+ this.on('uploadcomplete', (function(_this) {
|
|
43
|
+ return function(e, file) {
|
|
44
|
+ _this.files.splice($.inArray(file, _this.files), 1);
|
|
45
|
+ if (_this.queue.length > 0 && _this.files.length < _this.opts.connectionCount) {
|
|
46
|
+ return _this.upload(_this.queue.shift());
|
|
47
|
+ } else {
|
|
48
|
+ return _this.uploading = false;
|
|
49
|
+ }
|
|
50
|
+ };
|
|
51
|
+ })(this));
|
|
52
|
+ return $(window).on('beforeunload.uploader-' + this.id, (function(_this) {
|
|
53
|
+ return function(e) {
|
|
54
|
+ if (!_this.uploading) {
|
|
55
|
+ return;
|
|
56
|
+ }
|
|
57
|
+ e.originalEvent.returnValue = _this._t('leaveConfirm');
|
|
58
|
+ return _this._t('leaveConfirm');
|
|
59
|
+ };
|
|
60
|
+ })(this));
|
|
61
|
+ };
|
|
62
|
+
|
|
63
|
+ Uploader.prototype.generateId = (function() {
|
|
64
|
+ var id;
|
|
65
|
+ id = 0;
|
|
66
|
+ return function() {
|
|
67
|
+ return id += 1;
|
|
68
|
+ };
|
|
69
|
+ })();
|
|
70
|
+
|
|
71
|
+ Uploader.prototype.upload = function(file, opts) {
|
|
72
|
+ var f, i, key, len;
|
|
73
|
+ if (opts == null) {
|
|
74
|
+ opts = {};
|
|
75
|
+ }
|
|
76
|
+ if (file == null) {
|
|
77
|
+ return;
|
|
78
|
+ }
|
|
79
|
+ if ($.isArray(file) || file instanceof FileList) {
|
|
80
|
+ for (i = 0, len = file.length; i < len; i++) {
|
|
81
|
+ f = file[i];
|
|
82
|
+ this.upload(f, opts);
|
|
83
|
+ }
|
|
84
|
+ } else if ($(file).is('input:file')) {
|
|
85
|
+ key = $(file).attr('name');
|
|
86
|
+ if (key) {
|
|
87
|
+ opts.fileKey = key;
|
|
88
|
+ }
|
|
89
|
+ this.upload($.makeArray($(file)[0].files), opts);
|
|
90
|
+ } else if (!file.id || !file.obj) {
|
|
91
|
+ file = this.getFile(file);
|
|
92
|
+ }
|
|
93
|
+ if (!(file && file.obj)) {
|
|
94
|
+ return;
|
|
95
|
+ }
|
|
96
|
+ $.extend(file, opts);
|
|
97
|
+ if (this.files.length >= this.opts.connectionCount) {
|
|
98
|
+ this.queue.push(file);
|
|
99
|
+ return;
|
|
100
|
+ }
|
|
101
|
+ if (this.triggerHandler('beforeupload', [file]) === false) {
|
|
102
|
+ return;
|
|
103
|
+ }
|
|
104
|
+ this.files.push(file);
|
|
105
|
+ this._xhrUpload(file);
|
|
106
|
+ return this.uploading = true;
|
|
107
|
+ };
|
|
108
|
+
|
|
109
|
+ Uploader.prototype.getFile = function(fileObj) {
|
|
110
|
+ var name, ref, ref1;
|
|
111
|
+ if (fileObj instanceof window.File || fileObj instanceof window.Blob) {
|
|
112
|
+ name = (ref = fileObj.fileName) != null ? ref : fileObj.name;
|
|
113
|
+ } else {
|
|
114
|
+ return null;
|
|
115
|
+ }
|
|
116
|
+ return {
|
|
117
|
+ id: this.generateId(),
|
|
118
|
+ url: this.opts.url,
|
|
119
|
+ params: this.opts.params,
|
|
120
|
+ fileKey: this.opts.fileKey,
|
|
121
|
+ name: name,
|
|
122
|
+ size: (ref1 = fileObj.fileSize) != null ? ref1 : fileObj.size,
|
|
123
|
+ ext: name ? name.split('.').pop().toLowerCase() : '',
|
|
124
|
+ obj: fileObj
|
|
125
|
+ };
|
|
126
|
+ };
|
|
127
|
+
|
|
128
|
+ Uploader.prototype._xhrUpload = function(file) {
|
|
129
|
+ var formData, k, ref, v;
|
|
130
|
+ formData = new FormData();
|
|
131
|
+ formData.append(file.fileKey, file.obj);
|
|
132
|
+ formData.append("original_filename", file.name);
|
|
133
|
+ if (file.params) {
|
|
134
|
+ ref = file.params;
|
|
135
|
+ for (k in ref) {
|
|
136
|
+ v = ref[k];
|
|
137
|
+ formData.append(k, v);
|
|
138
|
+ }
|
|
139
|
+ }
|
|
140
|
+ return file.xhr = $.ajax({
|
|
141
|
+ url: file.url,
|
|
142
|
+ data: formData,
|
|
143
|
+ processData: false,
|
|
144
|
+ contentType: false,
|
|
145
|
+ type: 'POST',
|
|
146
|
+ headers: {
|
|
147
|
+ 'X-File-Name': encodeURIComponent(file.name)
|
|
148
|
+ },
|
|
149
|
+ xhr: function() {
|
|
150
|
+ var req;
|
|
151
|
+ req = $.ajaxSettings.xhr();
|
|
152
|
+ if (req) {
|
|
153
|
+ req.upload.onprogress = (function(_this) {
|
|
154
|
+ return function(e) {
|
|
155
|
+ return _this.progress(e);
|
|
156
|
+ };
|
|
157
|
+ })(this);
|
|
158
|
+ }
|
|
159
|
+ return req;
|
|
160
|
+ },
|
|
161
|
+ progress: (function(_this) {
|
|
162
|
+ return function(e) {
|
|
163
|
+ if (!e.lengthComputable) {
|
|
164
|
+ return;
|
|
165
|
+ }
|
|
166
|
+ return _this.trigger('uploadprogress', [file, e.loaded, e.total]);
|
|
167
|
+ };
|
|
168
|
+ })(this),
|
|
169
|
+ error: (function(_this) {
|
|
170
|
+ return function(xhr, status, err) {
|
|
171
|
+ return _this.trigger('uploaderror', [file, xhr, status]);
|
|
172
|
+ };
|
|
173
|
+ })(this),
|
|
174
|
+ success: (function(_this) {
|
|
175
|
+ return function(result) {
|
|
176
|
+ _this.trigger('uploadprogress', [file, file.size, file.size]);
|
|
177
|
+ _this.trigger('uploadsuccess', [file, result]);
|
|
178
|
+ return $(document).trigger('uploadsuccess', [file, result, _this]);
|
|
179
|
+ };
|
|
180
|
+ })(this),
|
|
181
|
+ complete: (function(_this) {
|
|
182
|
+ return function(xhr, status) {
|
|
183
|
+ return _this.trigger('uploadcomplete', [file, xhr.responseText]);
|
|
184
|
+ };
|
|
185
|
+ })(this)
|
|
186
|
+ });
|
|
187
|
+ };
|
|
188
|
+
|
|
189
|
+ Uploader.prototype.cancel = function(file) {
|
|
190
|
+ var f, i, len, ref;
|
|
191
|
+ if (!file.id) {
|
|
192
|
+ ref = this.files;
|
|
193
|
+ for (i = 0, len = ref.length; i < len; i++) {
|
|
194
|
+ f = ref[i];
|
|
195
|
+ if (f.id === file * 1) {
|
|
196
|
+ file = f;
|
|
197
|
+ break;
|
|
198
|
+ }
|
|
199
|
+ }
|
|
200
|
+ }
|
|
201
|
+ this.trigger('uploadcancel', [file]);
|
|
202
|
+ if (file.xhr) {
|
|
203
|
+ file.xhr.abort();
|
|
204
|
+ }
|
|
205
|
+ return file.xhr = null;
|
|
206
|
+ };
|
|
207
|
+
|
|
208
|
+ Uploader.prototype.readImageFile = function(fileObj, callback) {
|
|
209
|
+ var fileReader, img;
|
|
210
|
+ if (!$.isFunction(callback)) {
|
|
211
|
+ return;
|
|
212
|
+ }
|
|
213
|
+ img = new Image();
|
|
214
|
+ img.onload = function() {
|
|
215
|
+ return callback(img);
|
|
216
|
+ };
|
|
217
|
+ img.onerror = function() {
|
|
218
|
+ return callback();
|
|
219
|
+ };
|
|
220
|
+ if (window.FileReader && FileReader.prototype.readAsDataURL && /^image/.test(fileObj.type)) {
|
|
221
|
+ fileReader = new FileReader();
|
|
222
|
+ fileReader.onload = function(e) {
|
|
223
|
+ return img.src = e.target.result;
|
|
224
|
+ };
|
|
225
|
+ return fileReader.readAsDataURL(fileObj);
|
|
226
|
+ } else {
|
|
227
|
+ return callback();
|
|
228
|
+ }
|
|
229
|
+ };
|
|
230
|
+
|
|
231
|
+ Uploader.prototype.destroy = function() {
|
|
232
|
+ var file, i, len, ref;
|
|
233
|
+ this.queue.length = 0;
|
|
234
|
+ ref = this.files;
|
|
235
|
+ for (i = 0, len = ref.length; i < len; i++) {
|
|
236
|
+ file = ref[i];
|
|
237
|
+ this.cancel(file);
|
|
238
|
+ }
|
|
239
|
+ $(window).off('.uploader-' + this.id);
|
|
240
|
+ return $(document).off('.uploader-' + this.id);
|
|
241
|
+ };
|
|
242
|
+
|
|
243
|
+ Uploader.i18n = {
|
|
244
|
+ 'zh-CN': {
|
|
245
|
+ leaveConfirm: '正在上传文件,如果离开上传会自动取消'
|
|
246
|
+ }
|
|
247
|
+ };
|
|
248
|
+
|
|
249
|
+ Uploader.locale = 'zh-CN';
|
|
250
|
+
|
|
251
|
+ return Uploader;
|
|
252
|
+
|
|
253
|
+})(SimpleModule);
|
|
254
|
+
|
|
255
|
+uploader = function(opts) {
|
|
256
|
+ return new Uploader(opts);
|
|
257
|
+};
|
|
258
|
+
|
|
259
|
+return uploader;
|
|
260
|
+
|
|
261
|
+}));
|
|
|
@@ -0,0 +1,7 @@
|
|
1
|
+!function(a,b){"function"==typeof define&&define.amd?
|
|
2
|
+// AMD. Register as an anonymous module unless amdModuleId is set
|
|
3
|
+define("simple-uploader",["jquery","simple-module"],function(c,d){return a.uploader=b(c,d)}):"object"==typeof exports?
|
|
4
|
+// Node. Does not work with strict CommonJS, but
|
|
5
|
+// only CommonJS-like environments that support module.exports,
|
|
6
|
+// like Node.
|
|
7
|
+module.exports=b(require("jquery"),require("simple-module")):(a.simple=a.simple||{},a.simple.uploader=b(jQuery,SimpleModule))}(this,function(a,b){var c,d,e=function(a,b){function c(){this.constructor=a}for(var d in b)f.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},f={}.hasOwnProperty;return c=function(b){function c(){return c.__super__.constructor.apply(this,arguments)}return e(c,b),c.count=0,c.prototype.opts={url:"",params:null,fileKey:"upload_file",connectionCount:3},c.prototype._init=function(){return this.files=[],this.queue=[],this.id=++c.count,this.on("uploadcomplete",function(b){return function(c,d){return b.files.splice(a.inArray(d,b.files),1),b.queue.length>0&&b.files.length<b.opts.connectionCount?b.upload(b.queue.shift()):b.uploading=!1}}(this)),a(window).on("beforeunload.uploader-"+this.id,function(a){return function(b){return a.uploading?(b.originalEvent.returnValue=a._t("leaveConfirm"),a._t("leaveConfirm")):void 0}}(this))},c.prototype.generateId=function(){var a;return a=0,function(){return a+=1}}(),c.prototype.upload=function(b,c){var d,e,f,g;if(null==c&&(c={}),null!=b){if(a.isArray(b)||b instanceof FileList)for(e=0,g=b.length;g>e;e++)d=b[e],this.upload(d,c);else a(b).is("input:file")?(f=a(b).attr("name"),f&&(c.fileKey=f),this.upload(a.makeArray(a(b)[0].files),c)):b.id&&b.obj||(b=this.getFile(b));if(b&&b.obj){if(a.extend(b,c),this.files.length>=this.opts.connectionCount)return void this.queue.push(b);if(this.triggerHandler("beforeupload",[b])!==!1)return this.files.push(b),this._xhrUpload(b),this.uploading=!0}}},c.prototype.getFile=function(a){var b,c,d;return a instanceof window.File||a instanceof window.Blob?(b=null!=(c=a.fileName)?c:a.name,{id:this.generateId(),url:this.opts.url,params:this.opts.params,fileKey:this.opts.fileKey,name:b,size:null!=(d=a.fileSize)?d:a.size,ext:b?b.split(".").pop().toLowerCase():"",obj:a}):null},c.prototype._xhrUpload=function(b){var c,d,e,f;if(c=new FormData,c.append(b.fileKey,b.obj),c.append("original_filename",b.name),b.params){e=b.params;for(d in e)f=e[d],c.append(d,f)}return b.xhr=a.ajax({url:b.url,data:c,processData:!1,contentType:!1,type:"POST",headers:{"X-File-Name":encodeURIComponent(b.name)},xhr:function(){var b;return b=a.ajaxSettings.xhr(),b&&(b.upload.onprogress=function(a){return function(b){return a.progress(b)}}(this)),b},progress:function(a){return function(c){return c.lengthComputable?a.trigger("uploadprogress",[b,c.loaded,c.total]):void 0}}(this),error:function(a){return function(c,d,e){return a.trigger("uploaderror",[b,c,d])}}(this),success:function(c){return function(d){return c.trigger("uploadprogress",[b,b.size,b.size]),c.trigger("uploadsuccess",[b,d]),a(document).trigger("uploadsuccess",[b,d,c])}}(this),complete:function(a){return function(c,d){return a.trigger("uploadcomplete",[b,c.responseText])}}(this)})},c.prototype.cancel=function(a){var b,c,d,e;if(!a.id)for(e=this.files,c=0,d=e.length;d>c;c++)if(b=e[c],b.id===1*a){a=b;break}return this.trigger("uploadcancel",[a]),a.xhr&&a.xhr.abort(),a.xhr=null},c.prototype.readImageFile=function(b,c){var d,e;if(a.isFunction(c))return e=new Image,e.onload=function(){return c(e)},e.onerror=function(){return c()},window.FileReader&&FileReader.prototype.readAsDataURL&&/^image/.test(b.type)?(d=new FileReader,d.onload=function(a){return e.src=a.target.result},d.readAsDataURL(b)):c()},c.prototype.destroy=function(){var b,c,d,e;for(this.queue.length=0,e=this.files,c=0,d=e.length;d>c;c++)b=e[c],this.cancel(b);return a(window).off(".uploader-"+this.id),a(document).off(".uploader-"+this.id)},c.i18n={"zh-CN":{leaveConfirm:"正在上传文件,如果离开上传会自动取消"}},c.locale="zh-CN",c}(b),d=function(a){return new c(a)}});
|
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+(function() {
|
|
2
|
+ var djangoJQuery;
|
|
3
|
+ if (typeof jQuery == 'undefined' && typeof django == 'undefined') {
|
|
4
|
+ console.error('ERROR django-simditor missing jQuery. Set SIMDITOR_JQUERY_URL or provide jQuery in the template.');
|
|
5
|
+ } else if (typeof django != 'undefined') {
|
|
6
|
+ djangoJQuery = django.jQuery;
|
|
7
|
+ }
|
|
8
|
+
|
|
9
|
+ var $ = jQuery || djangoJQuery;
|
|
10
|
+ $(function() {
|
|
11
|
+
|
|
12
|
+ initialiseSimditor();
|
|
13
|
+ function initialiseSimditor() {
|
|
14
|
+ $('textarea[data-type=simditortype]').each(function() {
|
|
15
|
+
|
|
16
|
+ if($(this).data('processed') == "0" && $(this).attr('data-id').indexOf('__prefix__') == -1){
|
|
17
|
+ $(this).data('processed', "1");
|
|
18
|
+ var dataConfig = $(this).data('config');
|
|
19
|
+ new Simditor({
|
|
20
|
+ textarea: $(this),
|
|
21
|
+ upload: dataConfig.upload,
|
|
22
|
+ cleanPaste: dataConfig.cleanPaste,
|
|
23
|
+ tabIndent: dataConfig.tabIndent,
|
|
24
|
+ pasteImage: dataConfig.pasteImage,
|
|
25
|
+ toolbar: dataConfig.toolbar,
|
|
26
|
+ emoji: dataConfig.emoji
|
|
27
|
+ });
|
|
28
|
+ }
|
|
29
|
+ });
|
|
30
|
+ }
|
|
31
|
+
|
|
32
|
+ });
|
|
33
|
+
|
|
34
|
+})();
|
|
|
@@ -0,0 +1,696 @@
|
|
1
|
+@charset "UTF-8";
|
|
2
|
+
|
|
3
|
+$simditor-button-height: 40px;
|
|
4
|
+$simditor-button-width: 46px;
|
|
5
|
+
|
|
6
|
+.simditor {
|
|
7
|
+ position: relative;
|
|
8
|
+ border: 1px solid #c9d8db;
|
|
9
|
+
|
|
10
|
+ .simditor-wrapper {
|
|
11
|
+ position: relative;
|
|
12
|
+ background: #ffffff;
|
|
13
|
+
|
|
14
|
+ & > textarea {
|
|
15
|
+ display: none !important;
|
|
16
|
+ width: 100%;
|
|
17
|
+ box-sizing: border-box;
|
|
18
|
+ font-family: monaco;
|
|
19
|
+ font-size: 16px;
|
|
20
|
+ line-height: 1.6;
|
|
21
|
+ border: none;
|
|
22
|
+ padding: 22px 15px 40px;
|
|
23
|
+ min-height: 300px;
|
|
24
|
+ outline: none;
|
|
25
|
+ background: transparent;
|
|
26
|
+ resize: none;
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+ .simditor-placeholder {
|
|
30
|
+ display: none;
|
|
31
|
+ position: absolute;
|
|
32
|
+ left: 0;
|
|
33
|
+ z-index: 0;
|
|
34
|
+ padding: 22px 15px;
|
|
35
|
+ font-size: 16px;
|
|
36
|
+ font-family: arial, sans-serif;
|
|
37
|
+ line-height: 1.5;
|
|
38
|
+ color: #999999;
|
|
39
|
+ background: transparent;
|
|
40
|
+ }
|
|
41
|
+
|
|
42
|
+ &.toolbar-floating {
|
|
43
|
+ .simditor-toolbar {
|
|
44
|
+ position: fixed;
|
|
45
|
+ top: 0;
|
|
46
|
+ z-index: 10;
|
|
47
|
+ box-shadow: 0 0 6px rgba(0,0,0,0.1);
|
|
48
|
+ }
|
|
49
|
+ }
|
|
50
|
+
|
|
51
|
+ .simditor-image-loading {
|
|
52
|
+ width: 100%;
|
|
53
|
+ height: 100%;
|
|
54
|
+ position: absolute;
|
|
55
|
+ top: 0;
|
|
56
|
+ left: 0;
|
|
57
|
+ z-index: 2;
|
|
58
|
+
|
|
59
|
+ .progress {
|
|
60
|
+ width: 100%;
|
|
61
|
+ height: 100%;
|
|
62
|
+ background: rgba(0,0,0,0.4);
|
|
63
|
+ position: absolute;
|
|
64
|
+ bottom: 0;
|
|
65
|
+ left: 0;
|
|
66
|
+ }
|
|
67
|
+ }
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ .simditor-body {
|
|
71
|
+ padding: 22px 15px 40px;
|
|
72
|
+ min-height: 300px;
|
|
73
|
+ outline: none;
|
|
74
|
+ cursor: text;
|
|
75
|
+ position: relative;
|
|
76
|
+ z-index: 1;
|
|
77
|
+ background: transparent;
|
|
78
|
+
|
|
79
|
+ a.selected {
|
|
80
|
+ background: #b3d4fd;
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ a.simditor-mention {
|
|
84
|
+ cursor: pointer;
|
|
85
|
+ }
|
|
86
|
+
|
|
87
|
+ .simditor-table {
|
|
88
|
+ position: relative;
|
|
89
|
+
|
|
90
|
+ &.resizing {
|
|
91
|
+ cursor: col-resize;
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ .simditor-resize-handle {
|
|
95
|
+ position: absolute;
|
|
96
|
+ left: 0;
|
|
97
|
+ top: 0;
|
|
98
|
+ width: 10px;
|
|
99
|
+ height: 100%;
|
|
100
|
+ cursor: col-resize;
|
|
101
|
+ }
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ pre {
|
|
105
|
+ /*min-height: 28px;*/
|
|
106
|
+ box-sizing: border-box;
|
|
107
|
+ -moz-box-sizing: border-box;
|
|
108
|
+ word-wrap: break-word!important;
|
|
109
|
+ white-space: pre-wrap!important;
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ img {
|
|
113
|
+ cursor: pointer;
|
|
114
|
+
|
|
115
|
+ &.selected {
|
|
116
|
+ box-shadow: 0 0 0 4px #cccccc;
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ }
|
|
120
|
+
|
|
121
|
+ .simditor-paste-bin {
|
|
122
|
+ position: fixed;
|
|
123
|
+ bottom: 10px;
|
|
124
|
+ right: 10px;
|
|
125
|
+ width: 1px;
|
|
126
|
+ height: 20px;
|
|
127
|
+ font-size: 1px;
|
|
128
|
+ line-height: 1px;
|
|
129
|
+ overflow: hidden;
|
|
130
|
+ padding: 0;
|
|
131
|
+ margin: 0;
|
|
132
|
+ opacity: 0;
|
|
133
|
+ -webkit-user-select: text;
|
|
134
|
+ }
|
|
135
|
+
|
|
136
|
+ .simditor-toolbar {
|
|
137
|
+ border-bottom: 1px solid #eeeeee;
|
|
138
|
+ background: #ffffff;
|
|
139
|
+ width: 100%;
|
|
140
|
+
|
|
141
|
+ & > ul {
|
|
142
|
+ margin: 0;
|
|
143
|
+ padding: 0 0 0 6px;
|
|
144
|
+ list-style: none;
|
|
145
|
+
|
|
146
|
+ & > li {
|
|
147
|
+ position: relative;
|
|
148
|
+ display: inline-block;
|
|
149
|
+ font-size: 0;
|
|
150
|
+
|
|
151
|
+ & > span.separator {
|
|
152
|
+ display: inline-block;
|
|
153
|
+ background: #cfcfcf;
|
|
154
|
+ width: 1px;
|
|
155
|
+ height: 18px;
|
|
156
|
+ margin: ($simditor-button-height - 18px) / 2 15px;
|
|
157
|
+ vertical-align: middle;
|
|
158
|
+ }
|
|
159
|
+
|
|
160
|
+ & > .toolbar-item {
|
|
161
|
+ display: inline-block;
|
|
162
|
+ width: $simditor-button-width;
|
|
163
|
+ height: $simditor-button-height;
|
|
164
|
+ outline: none;
|
|
165
|
+ color: #333333;
|
|
166
|
+ font-size: 15px;
|
|
167
|
+ line-height: $simditor-button-height;
|
|
168
|
+ vertical-align: middle;
|
|
169
|
+ text-align: center;
|
|
170
|
+ text-decoration: none;
|
|
171
|
+
|
|
172
|
+ span {
|
|
173
|
+ opacity: 0.6;
|
|
174
|
+
|
|
175
|
+ &.simditor-icon {
|
|
176
|
+ display: inline;
|
|
177
|
+ line-height: normal;
|
|
178
|
+ }
|
|
179
|
+ }
|
|
180
|
+
|
|
181
|
+ &:hover span {
|
|
182
|
+ opacity: 1;
|
|
183
|
+ }
|
|
184
|
+
|
|
185
|
+ &.active {
|
|
186
|
+ background: #eeeeee;
|
|
187
|
+
|
|
188
|
+ span {
|
|
189
|
+ opacity: 1;
|
|
190
|
+ }
|
|
191
|
+ }
|
|
192
|
+
|
|
193
|
+ &.disabled {
|
|
194
|
+ cursor: default;
|
|
195
|
+
|
|
196
|
+ span {
|
|
197
|
+ opacity: 0.3;
|
|
198
|
+ }
|
|
199
|
+ }
|
|
200
|
+
|
|
201
|
+ &.toolbar-item-title {
|
|
202
|
+ span:before {
|
|
203
|
+ content: "H";
|
|
204
|
+ font-size: 19px;
|
|
205
|
+ font-weight: bold;
|
|
206
|
+ font-family: 'Times New Roman';
|
|
207
|
+ }
|
|
208
|
+
|
|
209
|
+ &.active-h1 span:before {
|
|
210
|
+ content: 'H1';
|
|
211
|
+ font-size: 18px;
|
|
212
|
+ }
|
|
213
|
+
|
|
214
|
+ &.active-h2 span:before {
|
|
215
|
+ content: 'H2';
|
|
216
|
+ font-size: 18px;
|
|
217
|
+ }
|
|
218
|
+
|
|
219
|
+ &.active-h3 span:before {
|
|
220
|
+ content: 'H3';
|
|
221
|
+ font-size: 18px;
|
|
222
|
+ }
|
|
223
|
+ }
|
|
224
|
+
|
|
225
|
+ &.toolbar-item-image {
|
|
226
|
+ position: relative;
|
|
227
|
+ overflow: hidden;
|
|
228
|
+
|
|
229
|
+ & > input[type=file] {
|
|
230
|
+ position: absolute;
|
|
231
|
+ right: 0px;
|
|
232
|
+ top: 0px;
|
|
233
|
+ opacity: 0;
|
|
234
|
+ font-size: 100px;
|
|
235
|
+ cursor: pointer;
|
|
236
|
+ }
|
|
237
|
+ }
|
|
238
|
+ }
|
|
239
|
+
|
|
240
|
+ &.menu-on {
|
|
241
|
+ .toolbar-item {
|
|
242
|
+ position: relative;
|
|
243
|
+ z-index: 20;
|
|
244
|
+ background: #ffffff;
|
|
245
|
+ box-shadow: 0 1px 4px rgba(0,0,0,0.3);
|
|
246
|
+
|
|
247
|
+ span {
|
|
248
|
+ opacity: 1;
|
|
249
|
+ }
|
|
250
|
+ }
|
|
251
|
+
|
|
252
|
+ .toolbar-menu {
|
|
253
|
+ display: block;
|
|
254
|
+ }
|
|
255
|
+ }
|
|
256
|
+ }
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ .toolbar-menu {
|
|
260
|
+ display: none;
|
|
261
|
+ position: absolute;
|
|
262
|
+ top: $simditor-button-height;
|
|
263
|
+ left: 0;
|
|
264
|
+ z-index: 21;
|
|
265
|
+ background: #ffffff;
|
|
266
|
+ text-align: left;
|
|
267
|
+ box-shadow: 0 0 4px rgba(0,0,0,0.3);
|
|
268
|
+
|
|
269
|
+ &:before {
|
|
270
|
+ content: '';
|
|
271
|
+ display: block;
|
|
272
|
+ width: $simditor-button-width;
|
|
273
|
+ height: 4px;
|
|
274
|
+ background: #ffffff;
|
|
275
|
+ position: absolute;
|
|
276
|
+ top: -3px;
|
|
277
|
+ left: 0;
|
|
278
|
+ }
|
|
279
|
+
|
|
280
|
+ ul {
|
|
281
|
+ min-width: 160px;
|
|
282
|
+ list-style: none;
|
|
283
|
+ margin: 0;
|
|
284
|
+ padding: 10px 1px;
|
|
285
|
+
|
|
286
|
+ & > li {
|
|
287
|
+
|
|
288
|
+ .menu-item {
|
|
289
|
+ display: block;
|
|
290
|
+ font-size:16px;
|
|
291
|
+ line-height: 2em;
|
|
292
|
+ padding: 0 10px;
|
|
293
|
+ text-decoration: none;
|
|
294
|
+ color: #666666;
|
|
295
|
+
|
|
296
|
+ &:hover {
|
|
297
|
+ background: #f6f6f6;
|
|
298
|
+ }
|
|
299
|
+
|
|
300
|
+ &.menu-item-h1 {
|
|
301
|
+ font-size: 24px;
|
|
302
|
+ color: #333333;
|
|
303
|
+ }
|
|
304
|
+
|
|
305
|
+ &.menu-item-h2 {
|
|
306
|
+ font-size: 22px;
|
|
307
|
+ color: #333333;
|
|
308
|
+ }
|
|
309
|
+
|
|
310
|
+ &.menu-item-h3 {
|
|
311
|
+ font-size: 20px;
|
|
312
|
+ color: #333333;
|
|
313
|
+ }
|
|
314
|
+
|
|
315
|
+ &.menu-item-h4 {
|
|
316
|
+ font-size: 18px;
|
|
317
|
+ color: #333333;
|
|
318
|
+ }
|
|
319
|
+
|
|
320
|
+ &.menu-item-h5 {
|
|
321
|
+ font-size: 16px;
|
|
322
|
+ color: #333333;
|
|
323
|
+ }
|
|
324
|
+ }
|
|
325
|
+
|
|
326
|
+ .separator {
|
|
327
|
+ display: block;
|
|
328
|
+ border-top: 1px solid #cccccc;
|
|
329
|
+ height: 0;
|
|
330
|
+ line-height: 0;
|
|
331
|
+ font-size: 0;
|
|
332
|
+ margin: 6px 0;
|
|
333
|
+ }
|
|
334
|
+ }
|
|
335
|
+
|
|
336
|
+ }
|
|
337
|
+
|
|
338
|
+ &.toolbar-menu-color {
|
|
339
|
+ width: 96px;
|
|
340
|
+
|
|
341
|
+ .color-list {
|
|
342
|
+ height: 40px;
|
|
343
|
+ margin: 10px 6px 6px 10px;
|
|
344
|
+ padding: 0;
|
|
345
|
+
|
|
346
|
+ min-width: 0;
|
|
347
|
+
|
|
348
|
+ li {
|
|
349
|
+ float: left;
|
|
350
|
+ margin: 0 4px 4px 0;
|
|
351
|
+
|
|
352
|
+ .font-color {
|
|
353
|
+ display: block;
|
|
354
|
+ width: 16px;
|
|
355
|
+ height: 16px;
|
|
356
|
+ background: #dfdfdf;
|
|
357
|
+ border-radius: 2px;
|
|
358
|
+
|
|
359
|
+ &:hover {
|
|
360
|
+ opacity: 0.8;
|
|
361
|
+ }
|
|
362
|
+
|
|
363
|
+ &.font-color-default {
|
|
364
|
+ background: #333333;
|
|
365
|
+ }
|
|
366
|
+ }
|
|
367
|
+
|
|
368
|
+ $font-colors: #E33737 #e28b41 #c8a732 #209361 #418caf #aa8773 #999999;
|
|
369
|
+ $i: 1;
|
|
370
|
+ @each $color in $font-colors {
|
|
371
|
+ .font-color-#{$i} {
|
|
372
|
+ background: $color;
|
|
373
|
+ }
|
|
374
|
+ $i: $i + 1;
|
|
375
|
+ }
|
|
376
|
+ }
|
|
377
|
+ }
|
|
378
|
+ }
|
|
379
|
+
|
|
380
|
+ &.toolbar-menu-table {
|
|
381
|
+ .menu-create-table {
|
|
382
|
+ background: #ffffff;
|
|
383
|
+ padding: 1px;
|
|
384
|
+
|
|
385
|
+ table {
|
|
386
|
+ border: none;
|
|
387
|
+ border-collapse: collapse;
|
|
388
|
+ border-spacing: 0;
|
|
389
|
+ table-layout: fixed;
|
|
390
|
+
|
|
391
|
+ td {
|
|
392
|
+ padding: 0;
|
|
393
|
+ cursor: pointer;
|
|
394
|
+
|
|
395
|
+ &:before {
|
|
396
|
+ width: 16px;
|
|
397
|
+ height: 16px;
|
|
398
|
+ border: 1px solid #ffffff;
|
|
399
|
+ background: #f3f3f3;
|
|
400
|
+ display: block;
|
|
401
|
+ content: ''
|
|
402
|
+ }
|
|
403
|
+
|
|
404
|
+ &.selected:before {
|
|
405
|
+ background: #cfcfcf;
|
|
406
|
+ }
|
|
407
|
+ }
|
|
408
|
+ }
|
|
409
|
+ }
|
|
410
|
+
|
|
411
|
+ .menu-edit-table {
|
|
412
|
+ display: none;
|
|
413
|
+
|
|
414
|
+ ul {
|
|
415
|
+ li {
|
|
416
|
+ white-space: nowrap;
|
|
417
|
+ }
|
|
418
|
+ }
|
|
419
|
+ }
|
|
420
|
+ }
|
|
421
|
+
|
|
422
|
+ &.toolbar-menu-image {
|
|
423
|
+ .menu-item-upload-image {
|
|
424
|
+ position: relative;
|
|
425
|
+ overflow: hidden;
|
|
426
|
+
|
|
427
|
+ input[type=file] {
|
|
428
|
+ position: absolute;
|
|
429
|
+ right: 0px;
|
|
430
|
+ top: 0px;
|
|
431
|
+ opacity: 0;
|
|
432
|
+ font-size: 100px;
|
|
433
|
+ cursor: pointer;
|
|
434
|
+ }
|
|
435
|
+ }
|
|
436
|
+ }
|
|
437
|
+
|
|
438
|
+ &.toolbar-menu-alignment {
|
|
439
|
+ width: 100%;
|
|
440
|
+ ul {
|
|
441
|
+ min-width: 100%;
|
|
442
|
+ }
|
|
443
|
+ .menu-item {
|
|
444
|
+ text-align: center;
|
|
445
|
+ }
|
|
446
|
+ }
|
|
447
|
+ }
|
|
448
|
+ }
|
|
449
|
+
|
|
450
|
+ .simditor-popover {
|
|
451
|
+ display: none;
|
|
452
|
+ padding: 5px 8px 0;
|
|
453
|
+ background: #ffffff;
|
|
454
|
+ box-shadow: 0 1px 4px rgba(0,0,0,0.4);
|
|
455
|
+ border-radius: 2px;
|
|
456
|
+ position: absolute;
|
|
457
|
+ z-index: 2;
|
|
458
|
+
|
|
459
|
+ .settings-field {
|
|
460
|
+ margin: 0 0 5px 0;
|
|
461
|
+ font-size: 12px;
|
|
462
|
+ height: 25px;
|
|
463
|
+ line-height: 25px;
|
|
464
|
+
|
|
465
|
+ label {
|
|
466
|
+ display: inline-block;
|
|
467
|
+ margin: 0 5px 0 0;
|
|
468
|
+ }
|
|
469
|
+
|
|
470
|
+ input[type=text] {
|
|
471
|
+ display: inline-block;
|
|
472
|
+ width: 200px;
|
|
473
|
+ box-sizing: border-box;
|
|
474
|
+ font-size: 12px;
|
|
475
|
+
|
|
476
|
+ &.image-size {
|
|
477
|
+ width: 83px;
|
|
478
|
+ }
|
|
479
|
+ }
|
|
480
|
+
|
|
481
|
+ .times {
|
|
482
|
+ display: inline-block;
|
|
483
|
+ width: 26px;
|
|
484
|
+ font-size: 12px;
|
|
485
|
+ text-align: center;
|
|
486
|
+ }
|
|
487
|
+ }
|
|
488
|
+
|
|
489
|
+ &.link-popover .btn-unlink,
|
|
490
|
+ &.image-popover .btn-upload,
|
|
491
|
+ &.image-popover .btn-restore {
|
|
492
|
+ display: inline-block;
|
|
493
|
+ margin: 0 0 0 5px;
|
|
494
|
+ color: #333333;
|
|
495
|
+ font-size: 14px;
|
|
496
|
+ outline: 0;
|
|
497
|
+
|
|
498
|
+ span {
|
|
499
|
+ opacity: 0.6;
|
|
500
|
+ }
|
|
501
|
+
|
|
502
|
+ &:hover span {
|
|
503
|
+ opacity: 1;
|
|
504
|
+ }
|
|
505
|
+ }
|
|
506
|
+
|
|
507
|
+ &.image-popover .btn-upload {
|
|
508
|
+ position: relative;
|
|
509
|
+ display: inline-block;
|
|
510
|
+ overflow: hidden;
|
|
511
|
+ vertical-align: middle;
|
|
512
|
+
|
|
513
|
+ input[type=file] {
|
|
514
|
+ position: absolute;
|
|
515
|
+ right: 0px;
|
|
516
|
+ top: 0px;
|
|
517
|
+ opacity: 0;
|
|
518
|
+ height: 100%;
|
|
519
|
+ width: 28px;
|
|
520
|
+ }
|
|
521
|
+ }
|
|
522
|
+ }
|
|
523
|
+
|
|
524
|
+ &.simditor-mobile {
|
|
525
|
+ .simditor-wrapper.toolbar-floating .simditor-toolbar {
|
|
526
|
+ position: absolute;
|
|
527
|
+ top: 0;
|
|
528
|
+ z-index: 10;
|
|
529
|
+ box-shadow: 0 0 6px rgba(0,0,0,0.1);
|
|
530
|
+ }
|
|
531
|
+ }
|
|
532
|
+}
|
|
533
|
+
|
|
534
|
+
|
|
535
|
+
|
|
536
|
+.simditor .simditor-body, .editor-style {
|
|
537
|
+ font-size: 16px;
|
|
538
|
+ font-family: arial, sans-serif;
|
|
539
|
+ line-height: 1.6;
|
|
540
|
+ color: #333;
|
|
541
|
+ outline: none;
|
|
542
|
+ word-wrap: break-word;
|
|
543
|
+
|
|
544
|
+ & > :first-child {
|
|
545
|
+ margin-top: 0!important;
|
|
546
|
+ }
|
|
547
|
+
|
|
548
|
+ a{ color: #4298BA; text-decoration: none; word-break: break-all;}
|
|
549
|
+ a:visited{ color: #4298BA; }
|
|
550
|
+ a:hover{ color: #0F769F; }
|
|
551
|
+ a:active{ color:#9E792E; }
|
|
552
|
+ a:hover, a:active{ outline: 0; }
|
|
553
|
+
|
|
554
|
+ h1,h2,h3,h4,h5,h6 {
|
|
555
|
+ font-weight: normal;
|
|
556
|
+ margin: 40px 0 20px;
|
|
557
|
+ color: #000000;
|
|
558
|
+ }
|
|
559
|
+
|
|
560
|
+ h1 { font-size: 24px; }
|
|
561
|
+ h2 { font-size: 22px; }
|
|
562
|
+ h3 { font-size: 20px; }
|
|
563
|
+ h4 { font-size: 18px; }
|
|
564
|
+ h5 { font-size: 16px; }
|
|
565
|
+ h6 { font-size: 16px; }
|
|
566
|
+
|
|
567
|
+ p, div {
|
|
568
|
+ word-wrap: break-word;
|
|
569
|
+ margin: 0 0 15px 0;
|
|
570
|
+ color: #333;
|
|
571
|
+ word-wrap: break-word;
|
|
572
|
+ }
|
|
573
|
+
|
|
574
|
+ b, strong {
|
|
575
|
+ font-weight: bold;
|
|
576
|
+ }
|
|
577
|
+
|
|
578
|
+ i, em {
|
|
579
|
+ font-style: italic;
|
|
580
|
+ }
|
|
581
|
+
|
|
582
|
+ u {
|
|
583
|
+ text-decoration: underline;
|
|
584
|
+ }
|
|
585
|
+
|
|
586
|
+ strike, del {
|
|
587
|
+ text-decoration: line-through;
|
|
588
|
+ }
|
|
589
|
+
|
|
590
|
+ ul, ol {
|
|
591
|
+ list-style:disc outside none;
|
|
592
|
+ margin: 15px 0;
|
|
593
|
+ padding: 0 0 0 40px;
|
|
594
|
+ line-height: 1.6;
|
|
595
|
+
|
|
596
|
+ ul, ol {
|
|
597
|
+ padding-left: 30px;
|
|
598
|
+ }
|
|
599
|
+
|
|
600
|
+ ul {
|
|
601
|
+ list-style: circle outside none;
|
|
602
|
+
|
|
603
|
+ ul {
|
|
604
|
+ list-style: square outside none;
|
|
605
|
+ }
|
|
606
|
+ }
|
|
607
|
+ }
|
|
608
|
+
|
|
609
|
+ ol {
|
|
610
|
+ list-style:decimal;
|
|
611
|
+ }
|
|
612
|
+
|
|
613
|
+ blockquote {
|
|
614
|
+ border-left: 6px solid #ddd;
|
|
615
|
+ padding: 5px 0 5px 10px;
|
|
616
|
+ margin: 15px 0 15px 15px;
|
|
617
|
+
|
|
618
|
+ & > :first-child {
|
|
619
|
+ margin-top: 0;
|
|
620
|
+ }
|
|
621
|
+ }
|
|
622
|
+
|
|
623
|
+ code {
|
|
624
|
+ display: inline-block;
|
|
625
|
+ padding: 0 4px;
|
|
626
|
+ margin: 0 5px;
|
|
627
|
+ background: #eeeeee;
|
|
628
|
+ border-radius: 3px;
|
|
629
|
+ font-size: 13px;
|
|
630
|
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
|
631
|
+ }
|
|
632
|
+
|
|
633
|
+ pre {
|
|
634
|
+ padding: 10px 5px 10px 10px;
|
|
635
|
+ margin: 15px 0;
|
|
636
|
+ display: block;
|
|
637
|
+ line-height: 18px;
|
|
638
|
+ background: #F0F0F0;
|
|
639
|
+ border-radius: 3px;
|
|
640
|
+ font-size:13px;
|
|
641
|
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
|
642
|
+ white-space: pre;
|
|
643
|
+ word-wrap: normal;
|
|
644
|
+ overflow-x: auto;
|
|
645
|
+
|
|
646
|
+ code {
|
|
647
|
+ display: block;
|
|
648
|
+ padding: 0;
|
|
649
|
+ margin: 0;
|
|
650
|
+ background: none;
|
|
651
|
+ border-radius: 0;
|
|
652
|
+ }
|
|
653
|
+ }
|
|
654
|
+
|
|
655
|
+ hr {
|
|
656
|
+ display: block;
|
|
657
|
+ height: 0px;
|
|
658
|
+ border: 0;
|
|
659
|
+ border-top: 1px solid #ccc;
|
|
660
|
+ margin: 15px 0;
|
|
661
|
+ padding: 0;
|
|
662
|
+ }
|
|
663
|
+
|
|
664
|
+ table {
|
|
665
|
+ width: 100%;
|
|
666
|
+ table-layout: fixed;
|
|
667
|
+ border-collapse: collapse;
|
|
668
|
+ border-spacing: 0;
|
|
669
|
+ margin: 15px 0;
|
|
670
|
+
|
|
671
|
+ thead {
|
|
672
|
+ background-color: #f9f9f9;
|
|
673
|
+ }
|
|
674
|
+
|
|
675
|
+ td, th {
|
|
676
|
+ min-width: 40px;
|
|
677
|
+ height: 30px;
|
|
678
|
+ border: 1px solid #ccc;
|
|
679
|
+ vertical-align: top;
|
|
680
|
+ padding: 2px 4px;
|
|
681
|
+ text-align: left;
|
|
682
|
+ box-sizing: border-box;
|
|
683
|
+
|
|
684
|
+ &.active {
|
|
685
|
+ background-color: #ffffee;
|
|
686
|
+ }
|
|
687
|
+ }
|
|
688
|
+ }
|
|
689
|
+
|
|
690
|
+
|
|
691
|
+ img {
|
|
692
|
+ margin: 0 5px;
|
|
693
|
+ vertical-align: middle;
|
|
694
|
+ }
|
|
695
|
+
|
|
696
|
+}
|
|
|
@@ -0,0 +1 @@
|
|
1
|
+@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,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) format('woff');font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'}
|
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+.simditor .simditor-body .simditor-checklist {
|
|
2
|
+ margin: 15px 0;
|
|
3
|
+ padding: 0 0 0 40px;
|
|
4
|
+ line-height: 1.6;
|
|
5
|
+ list-style-type: none;
|
|
6
|
+}
|
|
7
|
+
|
|
8
|
+.simditor .simditor-body .simditor-checklist > li {
|
|
9
|
+ margin: 0;
|
|
10
|
+ pointer-events: none;
|
|
11
|
+}
|
|
12
|
+.simditor .simditor-body .simditor-checklist > li::before {
|
|
13
|
+ content: '';
|
|
14
|
+ pointer-events: all;
|
|
15
|
+ display: inline-block;
|
|
16
|
+ margin: 0 5px 0 -25px;
|
|
17
|
+ width: 20px;
|
|
18
|
+ height: 20px;
|
|
19
|
+ cursor: default;
|
|
20
|
+ vertical-align: middle;
|
|
21
|
+ background-image: url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw==");
|
|
22
|
+}
|
|
23
|
+.simditor .simditor-body .simditor-checklist > li[checked]::before {
|
|
24
|
+ background-image: url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw==");
|
|
25
|
+}
|
|
|
@@ -0,0 +1 @@
|
|
1
|
+.simditor .simditor-body .simditor-checklist{margin:15px 0;padding:0 0 0 40px;line-height:1.6;list-style-type:none}.simditor .simditor-body .simditor-checklist>li{margin:0;pointer-events:none}.simditor .simditor-body .simditor-checklist>li::before{content:'';pointer-events:all;display:inline-block;margin:0 5px 0 -25px;width:20px;height:20px;cursor:default;vertical-align:middle;background-image:url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw==")}.simditor .simditor-body .simditor-checklist>li[checked]::before{background-image:url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw==")}
|
|
|
@@ -0,0 +1,37 @@
|
|
1
|
+@font-face {
|
|
2
|
+ font-family: 'icomoon';
|
|
3
|
+ src: url("../fonts/icomoon.eot?4vkjot");
|
|
4
|
+ src: url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"), url("../fonts/icomoon.ttf?4vkjot") format("truetype"), url("../fonts/icomoon.woff?4vkjot") format("woff"), url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg");
|
|
5
|
+ font-weight: normal;
|
|
6
|
+ font-style: normal;
|
|
7
|
+}
|
|
8
|
+[class^="icon-"], [class*=" icon-"] {
|
|
9
|
+ font-family: 'icomoon';
|
|
10
|
+ speak: none;
|
|
11
|
+ font-style: normal;
|
|
12
|
+ font-weight: normal;
|
|
13
|
+ font-variant: normal;
|
|
14
|
+ text-transform: none;
|
|
15
|
+ line-height: 1;
|
|
16
|
+ /* Better Font Rendering =========== */
|
|
17
|
+ -webkit-font-smoothing: antialiased;
|
|
18
|
+ -moz-osx-font-smoothing: grayscale;
|
|
19
|
+}
|
|
20
|
+
|
|
21
|
+.icon-fullscreen:before {
|
|
22
|
+ content: "\e600";
|
|
23
|
+}
|
|
24
|
+
|
|
25
|
+.simditor-fullscreen {
|
|
26
|
+ overflow: hidden;
|
|
27
|
+}
|
|
28
|
+.simditor-fullscreen .simditor {
|
|
29
|
+ position: fixed;
|
|
30
|
+ top: 0;
|
|
31
|
+ left: 0;
|
|
32
|
+ z-index: 9999;
|
|
33
|
+ width: 100%;
|
|
34
|
+}
|
|
35
|
+.simditor-fullscreen .simditor .simditor-body {
|
|
36
|
+ overflow: auto;
|
|
37
|
+}
|
|
|
@@ -0,0 +1 @@
|
|
1
|
+@font-face{font-family:'icomoon';src:url("../fonts/icomoon.eot?4vkjot");src:url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"),url("../fonts/icomoon.ttf?4vkjot") format("truetype"),url("../fonts/icomoon.woff?4vkjot") format("woff"),url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg");font-weight:normal;font-style:normal}[class^="icon-"],[class*=" icon-"]{font-family:'icomoon';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-fullscreen:before{content:"\e600"}.simditor-fullscreen{overflow:hidden}.simditor-fullscreen .simditor{position:fixed;top:0;left:0;z-index:9999;width:100%}.simditor-fullscreen .simditor .simditor-body{overflow:auto}
|
|
|
@@ -0,0 +1,28 @@
|
|
1
|
+.simditor .markdown-editor {
|
|
2
|
+ display: none;
|
|
3
|
+}
|
|
4
|
+.simditor .markdown-editor textarea {
|
|
5
|
+ display: block;
|
|
6
|
+ width: 100%;
|
|
7
|
+ min-height: 200px;
|
|
8
|
+ box-sizing: border-box;
|
|
9
|
+ padding: 22px 15px 40px;
|
|
10
|
+ border: none;
|
|
11
|
+ border-bottom: 1px solid #dfdfdf;
|
|
12
|
+ resize: none;
|
|
13
|
+ outline: none;
|
|
14
|
+ font-size: 16px;
|
|
15
|
+}
|
|
16
|
+.simditor.simditor-markdown .markdown-editor {
|
|
17
|
+ display: block;
|
|
18
|
+}
|
|
19
|
+.simditor.simditor-markdown .simditor-body {
|
|
20
|
+ min-height: 100px;
|
|
21
|
+ background: #f3f3f3;
|
|
22
|
+}
|
|
23
|
+.simditor.simditor-markdown .simditor-placeholder {
|
|
24
|
+ display: none !important;
|
|
25
|
+}
|
|
26
|
+.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon {
|
|
27
|
+ font-size: 18px;
|
|
28
|
+}
|
|
|
@@ -0,0 +1 @@
|
|
1
|
+.simditor .markdown-editor{display:none}.simditor .markdown-editor textarea{display:block;width:100%;min-height:200px;box-sizing:border-box;padding:22px 15px 40px;border:0;border-bottom:1px solid #dfdfdf;resize:none;outline:0;font-size:16px}.simditor.simditor-markdown .markdown-editor{display:block}.simditor.simditor-markdown .simditor-body{min-height:100px;background:#f3f3f3}.simditor.simditor-markdown .simditor-placeholder{display:none!important}.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon{font-size:18px}
|
|
|
@@ -0,0 +1,746 @@
|
|
1
|
+/*!
|
|
2
|
+* Simditor v2.3.6
|
|
3
|
+* http://simditor.tower.im/
|
|
4
|
+* 2015-12-21
|
|
5
|
+*/
|
|
6
|
+@font-face {
|
|
7
|
+ font-family: 'Simditor';
|
|
8
|
+ src: url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAABp8AA4AAAAAKmwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAaYAAAABoAAAAcdO8GE09TLzIAAAG0AAAARQAAAGAQ+ZFXY21hcAAAAkgAAABRAAABWuA2Gx9jdnQgAAAEgAAAAAoAAAAKAwQAxGZwZ20AAAKcAAABsQAAAmUPtC+nZ2x5ZgAABNgAABPeAAAgZG/p6QxoZWFkAAABRAAAADAAAAA2BvuCgGhoZWEAAAF0AAAAHgAAACQH9QTlaG10eAAAAfwAAABKAAAAlHv7AItsb2NhAAAEjAAAAEwAAABMi4qTXm1heHAAAAGUAAAAIAAAACABRwHNbmFtZQAAGLgAAAEFAAAB12vS/ulwb3N0AAAZwAAAAJ4AAAFsyCrvunByZXAAAARQAAAALgAAAC6w8isUeNpjYGRgYADiKAkPy3h+m68M8swfgCIMF0/IVyDo/84sFswJQC4HAxNIFAAZwAnyeNpjYGRgYE5gmMAQzWLBwPD/O5AEiqAAVQBa6wPkAAAAAQAAACUAoAAKAAAAAAACAAEAAgAWAAABAAEpAAAAAHjaY2BhnsA4gYGVgYGpn+kgAwNDL4RmfMxgxMgCFGVgZWaAAUYBBjTQwMDwQY454X8BQzRzAsMEIJcRSVaBgREAQ9oK6QAAAHjaY8xhUGQAAsYABgbmDwjMYsEgxCzBwMDkAOQnALEEgx1UjhNMr4BjTqBakDxC/wqIPsYMqJoEKIbpk0C1C4zXM3DA5AEzchbtAAB42mNgYGBmgGAZBkYGEAgB8hjBfBYGCyDNxcDBwASEDAy8DAof5P7/B6sCsRmAbOb/3/8/FWCD6oUCRjaIkWA2SCcLAyoAqmZlGN4AALmUC0kAAAB42l1Ru05bQRDdDQ8DgcTYIDnaFLOZkALvhTZIIK4uwsh2YzlC2o1c5GJcwAdQIFGD9msGaChTpE2DkAskPoFPiJSZNYmiNDs7s3POmTNLypGqd2m956lzFkjhboNmm34npNpFgAfS9Y1GRtrBIy02M3rlun2/j8FmNOVOGkB5z1vKQ0bTTqAW7bl/Mj+D4T7/yzwHg5Zmmp5aZyE9hMB8M25p8DWjWXf9QV+xOlwNBoYU01Tc9cdUyv+W5lxtGbY2M5p3cCEiP5gGaGqtjUDTnzqkej6OYgly+WysDSamrD/JRHBhMl3VVC0zvnZwn+wsOtikSnPgAQ6wVZ6Ch+OjCYX0LYkyS0OEg9gqMULEJIdCTjl3sj8pUD6ShDFvktLOuGGtgXHkNTCozdMcvsxmU9tbhzB+EUfw3S/Gkg4+sqE2RoTYjlgKYAKRkFFVvqHGcy+LAbnU/jMQJWB5+u1fJwKtOzYRL2VtnWOMFYKe3zbf+WXF3apc50Whu3dVNVTplOZDL2ff4xFPj4XhoLHgzed9f6NA7Q2LGw2aA8GQ3o3e/9FadcRV3gsf2W81s7EWAAAAuAH/hbABjQBLsAhQWLEBAY5ZsUYGK1ghsBBZS7AUUlghsIBZHbAGK1xYWbAUKwAAAAAAowCFACECfwAAAAAAKgAqACoAKgAqACoAfgEkAcAChAK+A2oElgU2BbQGxgeYCBgIPgjGCU4KZgqKCq4LQAuYDDoMcAzuDXINoA4MDngO4g86D6QQMnjazVl5cBvXeX9vF4tdXHsBuwBBEvdBAgQXxOIgRPGQSEkULcoJJds6Yku2Na6TKJXHsnx0XNptHcvNpLaSJpkczthV68Zu0ulbQE58qXXaHK3j7ThjD6PmmnQmaTydSaqkmdbxkFC/tyApinXiuP2jlcC37/vegX3f8fu+7wExKIkQLjCPIxbxaNjCyNja4l3sTyqWm/vu1hbLQBdZLGVzlN3i3a7lrS1M+aaSVPKmkk5iz+tf/zrz+MrRJHMDgp3US3/tyjEvIQn1oiJCWd6dx7kGrsexLuGwjlm3AXSQ0h5M+5M4D3/1MNbx4b5AoPNmIIDdgQB0v/e9AJ78JqemVLfT4uN0sDtAHzBtvvvYsIK5aqWgcF6XyizRR+f+K9cAhRB9T3TpGTbCRlAARdAEehiRCYNwNulNLCmkzyZ+g6g2GTSIaJKCTUo2JpMGSS0RZBOp0kohb7E9lerzFMlghSDZ4nGRbLGJRpdXbGsKFy2UUlRL7Gk2iaacYzlfeCITbhJeJY0msvycorZj8eYWylMV4JFBtaXlKs1mszyS5UNh3azUqvlhnOLZsAZEvZpLp9gU35jAjfo4lvM5GEzn6xkzXAnrWogXMR/DITfvTuMy9hSyr0XSx+6VXa6+1NFbTrwrPvD+v8OevSHFLzT9cYbZgqXZ+U9cVahEC7nrTo6ZN33w2fdsCykvTOaaCTc+/vn7XbOf27X840CNEYXYRJYp6gEOswb24YPlHbsHtIgSvO1Tt/aNgglRWTJTIMsB9FeIDIAcTZKzidsmIYNoNumpEE0mvSDCQcMqgKDq0ecmDv/sY0grekXil4n0opXCvyTxF4Foi34pWCQpuZ1IxYPFdpK2LWAmPpT4UNotKmqzBTx4kEQTPe0X44lkatj5h6+gyFQUI8s9AErADCghpxChSUIq6W9aWq+iEh0EzeVzKTffqK/+V2sg03wjXKk33FSeImbcYKhhN4/fd9OemVtlr18f6ZF5rjKH9R0+33cKp0KsIC1o7ti2EsbaPoaf9TE+XHZxvoCWEf8N39gvBlhmi0fAkSinC+Kfdr71j6KX8/f3IsaxwaMgt13oOvSHqDWPUJHst4lgUJPbYrSVYGw6EzbJmG2FpioVMiaTCDWwcZMkbLKjgskBgwSWSMZuZQLUIDMxT7EVyNBuIAi2mZGtEbDEg/A3kgGDi/RuGQODQ1aiABSWA3WgrMgWkMa2JhlTyCTIBLxUhbO706lhZhxXc/mUgetmuFGpm3xYc6d4dz+mQgGbBJFN4OowNjCYIp9vmGG9EdZDsFbEwRoYbDIFk0O6mazUmTcx5w8nC4c/c/3p7WF9p8ozvPRZIiZYjLPTXh4L3N6Rxs1jUZ8Wcgksy/T3NAXGODmw0+tiotqg/xavsPwVwesV2K2Cl/ly0tv5m+Nbkjur+2+/7oX3J1hmBPMc5rMcJ/LTyd/77O8O9A6F5NSO04195WQ+hpmymxFwMCDybv/ymxm6EW2o/U5c+g/m28xHURrwSg9J2A0n5mmTq1J0gqZeiYPXQUOHmZdkeY9cVJ94Qi1CR37iiU30Y7+Cv0av4c9F0L2EBtEcWkTENMiMo3vJJmmD6OAuVwEILZGs3Z7IqkKRTNokK1uz4EAl29oDOp2cAMXJTZJVqPpm1afj+kChYlJIKSnnIv3R4qCjbWEGtF0ojU5SbaclIGQ12k+n6QqJUJVXdFCTG9SVA43XzUauVm3UzUoYAEUC7eaom4RA5WHeBPWKbIpqnBoHIFEjhqktgCHkc+z3qVyXq7TtjF6156NX3+4OMLwh9MVGPrhn7u6bzQd+7Ar7hq87cLq0N+lnmKasspMnM/trJQXf2tUIbTKzV98yuyunv6/pYVhmf9zcfnhPKp4+ox3a2j88qgd0r9fDjw8N4giTLrtu7Js5MCBRXHcjz6XbQK6HURiV0RSaR9ejD+BB1KpT3xq3iatCxmXC2hTHAeNlm0QNMmyTsk32GeSQTVIGydvkZoNsN8n7bKqSbZXWzM3UpWau8hQx+W2DsEtkrkIYmzCytQPUMW8TvtLaMU8n7Zj2FNvq/A7QV8IkXruleilbpaFiXrYMX5FE6J7WCVAgwyoqgJYWy+ym2tihtEOl4V1OSFCfllE4lb+KEvOK5RsCCPOqbTc3WHB0KvsB2LwB4NaVtkcMhuhEVrV4DVhIIUCNq8TdtIajYCS9TbIP4lqTlFVSapJDyrlYojCUoWtSKsk2SV4hg2AIDV5L10zNCSSpfMOJQXy+Pom1dK4KCFmrplNAmxWdBhrerHHaBrNJVnRM19fSbgoG2uZBZRP9QH3r87X+5Ph7s4m+SHlMqgT2v8wOhKfi0WA5tnNwNBceZ3ax+73Cyn5qF8wXBO/y6+fHsSsyMD/GXrORv7F/iOm/ZmQbPzhXzVaiiSwX3+a/cFAyG2IuEksmx40Zw5+KJNvH6Xza4J81Gmc8WnHXD//pMi+y3u3aFbr0XfYi8wvIlCQUR3nUANQ+gVoatSvIF1iKyzwkCgap2sRHKfDjccen05TKgz/PQmhcsvwZgHJsW0KiUrF24yKy+jSKxi4OUf+sloDw+AMCJWbGgUhmsgkgyiN1UAqoobL2xJvkiX4Ff7PcL0wemlz7sNddKd63YG7sn3KW/bPTdv5iXUaMsZlzpQAZJ+l6EvAujibRAmpxVG4Zk4puK6QHIDWT+G0yBDFtyiDCEgiI9NitHoE6T48CzoNlawB8LWmTpt1qDlB+c8RTtLaBBAHB4IhFnMrVlGp9bBXOgHaiD6W5txmH9K50oTT51F0ZSdOkzNg1CX2xNInfeEvuDPAmS/jDdz2lSbOSds2Yqiecif+NSY/tXT87tRwDzn81OgK2cx96BD2GHkStj1NZ+G1r6D1gGJxhZfabVDDWnnsrVDTWzB1Ab7Wt4x8GumZYxx4A+lGwp8cN8skl4rGtyCiMeGQLAabIZegP2tbsrfQpWwngTR2F/kHbuvsh+pStdwHvtvuh/xHb+hNHflmI1hvkUafYvpHmNo3j2q8ff6fzN39fQ+maLNWXgysJr3COGtQVzUZu5wdvzf9N5lxuZmvZFX+2Vssyv8hVD62b8A/We69ctvBn3oL5NsOX93lh5VHna46B5Gk+4Ln0ZfYx9jqomhqQDT7u1CNRm+x0ckE3RZBrneC013ayvrklmmLnZCsGPrFgk+10hm6TBdlinFLESfq25yC+JPtmds7vpWiixyBmTO+DALGgWKH98GTUds/4xLVORNkJgeJphm9u2TZNJxfcMHmGTrpWsYp0UUpt53bPvduBomy9CmlBio8xkO+5U8Ns3h2C7KgClZ4zAElUlx5m8hSSYiy3llnlqo38WnLVTan4cL0SZtOyfEoaVlnFzXkTMUnkZVaV7pBLUuer3ec+mCCXNk7A3zfK+4wHyyeNSqV8euTUFdTDsOQUpBcyz/sHEi6fW2FVAzaS8He6zwV5SL5ywr+PPDi8YJTvGDkNTmScuoJCLpqzuUbBj3kkohgaRu9FrbCDY4D/BkV/2SBF0I8BOcQSCUH9I1scaMNL8b6FOYpZ2NPFsl7gJ2yrDFrCUAsSf5P0KiQAemDDgPkCRACnXFSICOK+jOzJWiOMs5BXa0o3rwYPyYU3e8utDowz9y2/fu4QTuDE8r1O4vwAtAu17PK91N3ZB3JVZncXt19YPk4nnt0I9erKfsdCv5CrVimEQZ2HE2wEvwE4piEAKgrYfjiubFjKOghvjDNsJKGv7NcTCZ35gp7Af3ucdmmDOAcTLzr1dz8qoXHI1OqoFaTSjDr5r8upuyEphqoa5DcNJg9ftdewrqYR0yzQsg7RWll1zMo5OhjT5leovUP6a9xZXvR6Rf4sa6wlsuzLTgx81BHMsc39y3PwR/38Wc4r4BnBy53t/OjXwsMrV+QXby8PdoM8fG8tD4Gn8giCLax7l/6/lccFKgrOEQobeacCYYY7L1BR8I5cOrO/uUAEpz56kj2KPGBrSdRE74ZM/r3oJPo2apWpVAbsFiQVxTY7UIZUe4DCH2TycZtca5DDNkVPipR3OEi5HfBRtmTwOB8IT7aOQe+ITY7IVhVT77VOUaycAxEyHOCcrHzRo4fHZ3bMUw/0qWRvkxxT2kMlp3gmR1Qy0CRV5UtGvt44cPD4CcrMqOQk+G60rKhfFELBzFCpStlxhaQBQNV2vTGzgzIOK2R3k0yoX9oytn3uxpuOf4Ay9yrkdif5hpyb3oXpYY36O9VBRc91ExcnbVmvTnN5qLMrkw7YNvRwns+vQS6f24Csrg1r8YY9w+vf9J9nQDmBwJlAdMEre+GzuB4LmbMAp6WHys97xdOfkoYp/H7aKyknLhOqeH5tCr59fV3nQnenH61v/fEzHOd0MuuxdtGZ0tNF2Be8uvfTFI9L0mdOe6Tfukz4/efXpow7K3BifYvr13btYhM6x0wBNgWQiojbcIBJNCzJASZ0OfaAVTNFzbfsSXiWfZqE38BvaHHoAieuOfvM4hnmIdgniJwdeKjYIFtf3ehKsJlxVtH1+O61/STYvBsrwH63OvVCHnK+21CLp3Yrmt3AQG9wIGh4TRo9+rppr7lEhiAHli0MZhmwSUC2PNBT7JZHobHDE+nmu9aQCbY6thVsFSuWKwPPgEomwf4yCRgwyhQHMlWnZqf3hs6zscGzx3AMO1kWFHIsmMhqcjyO012zoLbDvKLFNC32hNNen9CXv0LR+6JvNH0mPeq7qCe+JPSc0aQzknYGsnR12dfnW1adyaufs+foAtoMDCQS+Fp9mSbRy3pYptKWu/eGzv1XDlURFYbk3BjmQHN55+YDxD5A0S0kKeo5jLzRXuotOcVKZegJkexOp3KrHhPDzhVpig/r/Ophqo16HNcT7NFO68a/nPD5592Ka/Cu6bueeur1ffOqV+iBF4K32X0fvp6Jdh7tLMwFfPNuhquNPfXTp+b3ymEdXpeebfauVYxefd8gZGlpVEQm+ghqFalWDUeZoLKwQWIm6YVUrUIPYcJZqgYZWYKMnCbjPaBOzSaabCWh12+TftnKdi90aqBXrQdSMJ87XzAq9KRJpc0yAT/t9qtPS8Fccdh0UrVwAOYJSmawVKaDvUo7OzA04iRmWMRUJhOYiqRC7+dieC17cK0+VTmXcMt6AgSYyMn1BLOo3f7w7Ron9vW5xD037BFdfX1i50eFrYXCVjznPJ57tbP06qu4gHtXOp9eWcG3YHZm374ZsdcjiqXR0ZIoenoxR2eufjp/jAuv0kVMb3fBytq9+zTEORP8wgtZVA61/FR+gMuQT3hAWpJBgRpZnF9RW4ybd+7DsYnT+SSfxmwS15Ia/sZRvGtxrvOZubvwyT/C0ZV76ZYr/mefZe7s/NnKv54/j7o1p+ODEajeG2gvIl6jFUs2TCiefHarN12tQAEEzlc0wNAwGTWsJv1inxdciI+DT2WUViBqwguQotrWI8MGlTVWiOZcklbqZi5Pr0kbE2wDm0HIhGNMHIf4fIoH/KXgXAN0FnEoxgKe83j0SU7jyo3OT3rLW7BY6U8KOD17j7qQjhSjewUWL2l/z8xh3tu7sCI35EQk78J4gMGPnFh5zCWUXALfozE/7/xL4Rt7x09oMpv0cB5BjEkMK8jaeZz7RFT1cC6c9HKrZ/+Y8/uGgnT0eUQ8Br30gvxUMgFPCKoQBo5t0h85ggA+YcOKdC/mXxx/c5FezBN1WCT6i5zFML8UiffF5ya/8eYFOsARDCMijATpSOhFjohyG4k4WCSMDAbrDRbbHtpSvkT5LGp7xZDu3NFP+RFmWI9XlNRgl7X2j0xFaQ7ZSAaT9M4xHcdmrRFM5nGS5bLMvUJHjuID/hMn+Jv8LzMv9XU+4bmE2Mhs5/nOeUa+ufPq/bHY1Y828SgeuQULy986fHhVDmBvzEtgeSEaGVBX2VBV6w6ga2BOWUANiKCN/AQex9gMa+zFlWeDmd7snj/4UEIKM8K7m+cPHnwt0BPfw39wiNVEE3+nuYdi/GrOtlbX51bvNSAv1gx6tZE1KKDXDKjeKcCv3lVkN+VY+U10423G2YuASwcomLJPStoFTeoIlKChBwB5+XVnJNId+aQzcqukHZ+lPdr8w6/tof9H51opU4J5pXuux52Ro92Ru52Rh/5PzvVOc+grz7XxWBtP9T86FIuESyfZZ5ivQkSKoRTUDEQwWu6gTlHOY7c4NUxRLmBArMFQRlgZCnEegUJciKYNCmG6+KrHsZbna3VwPBGHIQPNSbg2gScxZs0gVJ34z3fjqbypLn3zHtfCG2bIJd3w+B2l2jjLYu3I157BLuary52g12X4vcNy9OWTh4WouyT6XEWfznGM2rmEv3XgAMV/qgPmTuf34RQ6hloC1YAO2OTcdSlxeHHJeVfiW6J8XabVJb33S3ZvO1ibnsJKKlA1p5ok5txrs/R3PWTpcDJKasq5YKQ/meqGxIqubSyQsZLm82nFrIUbGtdI19Jamv1cvFCIL5+lLf7p4g1HFheP3IC3PHZk8QbmzkK80+cM/DBe6Aj4dxYXOw+ev+ee8/HvOoHm8t1mEU2hQ6s2lbBbCVrwo0QBCv4ep1im59rm3G52Iz8cg+Y42+E0mX4o+pXhStOJ7z2QxrWH6036gw2RFCfVu1xer1b5EN8hGS1i51e2tdsAsDkIPGYliDdesazes7CRI9OdoekjR6bxa8mk4OL7XB7OJ3aGoMLP4ddyVS7j5kK/36mLGfHnojgBj4/h49BOiPiadnfd9BGRDfJ9nKua6657hIdVGMMiWEOnOmvoYoT+C93/Vj8AAHjafY+/asMwEIc/JU6aQhsyltJBQ6eCg20IgdCt1GTwlNJsHUJijCCxwHaeqVufpM/Qta/Ri31ZOkTipO9Ov/sjYMwXhm7d8qBsGPGs3OOKd+U+j3wqB6L5UR5wY4zykJGxojTBtXj3bdaJDROelHvS91W5z5IP5UA038oD7vhVHjIxY1I8JQ2ObUs1lkz2C6S+bNzWl7XNMnHfRHNgJ2cjykoC7rBzjRdakVNwZM/m9LDKi+N+I3AunrYJhagsCVMiuRdi/0t20Vg0IXOxRJQxs26U1FdFbpNpZBf23FowTsJ5mETx7OKEa+ldyedcO9GpRzcF67yqnS9tLHUvVfgDz/ZF8gAAAHjabc25DgFhGIXh/53B2Pd9J9HPN/bSWolC4iI0OjfgxhFO6SQnT/k6z333errI/dvkc5yHh+98YsRJEJAkRZoMWXLkKVCkRJkKVWrUadCkRZsOXXr0GTBkxDh2vp5O3u4SPO63YxiG0mQkp3Im53Ihl3Il13Ijt3In9/Igjz9NfVPf1Df1TX1T39Q39U19U9/UN/VNfVPfDm8tR0peAAB42mNgYGBkAIKLcceVwfQJ+XIoXQEARe8GegAA) format("woff");
|
|
9
|
+ font-weight: normal;
|
|
10
|
+ font-style: normal;
|
|
11
|
+}
|
|
12
|
+.simditor-icon {
|
|
13
|
+ display: inline-block;
|
|
14
|
+ font: normal normal normal 14px/1 'Simditor';
|
|
15
|
+ font-size: inherit;
|
|
16
|
+ text-rendering: auto;
|
|
17
|
+ -webkit-font-smoothing: antialiased;
|
|
18
|
+ -moz-osx-font-smoothing: grayscale;
|
|
19
|
+ transform: translate(0, 0);
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+.simditor-icon-code:before {
|
|
23
|
+ content: '\f000';
|
|
24
|
+}
|
|
25
|
+
|
|
26
|
+.simditor-icon-bold:before {
|
|
27
|
+ content: '\f001';
|
|
28
|
+}
|
|
29
|
+
|
|
30
|
+.simditor-icon-italic:before {
|
|
31
|
+ content: '\f002';
|
|
32
|
+}
|
|
33
|
+
|
|
34
|
+.simditor-icon-underline:before {
|
|
35
|
+ content: '\f003';
|
|
36
|
+}
|
|
37
|
+
|
|
38
|
+.simditor-icon-times:before {
|
|
39
|
+ content: '\f004';
|
|
40
|
+}
|
|
41
|
+
|
|
42
|
+.simditor-icon-strikethrough:before {
|
|
43
|
+ content: '\f005';
|
|
44
|
+}
|
|
45
|
+
|
|
46
|
+.simditor-icon-list-ol:before {
|
|
47
|
+ content: '\f006';
|
|
48
|
+}
|
|
49
|
+
|
|
50
|
+.simditor-icon-list-ul:before {
|
|
51
|
+ content: '\f007';
|
|
52
|
+}
|
|
53
|
+
|
|
54
|
+.simditor-icon-quote-left:before {
|
|
55
|
+ content: '\f008';
|
|
56
|
+}
|
|
57
|
+
|
|
58
|
+.simditor-icon-table:before {
|
|
59
|
+ content: '\f009';
|
|
60
|
+}
|
|
61
|
+
|
|
62
|
+.simditor-icon-link:before {
|
|
63
|
+ content: '\f00a';
|
|
64
|
+}
|
|
65
|
+
|
|
66
|
+.simditor-icon-picture-o:before {
|
|
67
|
+ content: '\f00b';
|
|
68
|
+}
|
|
69
|
+
|
|
70
|
+.simditor-icon-minus:before {
|
|
71
|
+ content: '\f00c';
|
|
72
|
+}
|
|
73
|
+
|
|
74
|
+.simditor-icon-indent:before {
|
|
75
|
+ content: '\f00d';
|
|
76
|
+}
|
|
77
|
+
|
|
78
|
+.simditor-icon-outdent:before {
|
|
79
|
+ content: '\f00e';
|
|
80
|
+}
|
|
81
|
+
|
|
82
|
+.simditor-icon-unlink:before {
|
|
83
|
+ content: '\f00f';
|
|
84
|
+}
|
|
85
|
+
|
|
86
|
+.simditor-icon-caret-down:before {
|
|
87
|
+ content: '\f010';
|
|
88
|
+}
|
|
89
|
+
|
|
90
|
+.simditor-icon-caret-right:before {
|
|
91
|
+ content: '\f011';
|
|
92
|
+}
|
|
93
|
+
|
|
94
|
+.simditor-icon-upload:before {
|
|
95
|
+ content: '\f012';
|
|
96
|
+}
|
|
97
|
+
|
|
98
|
+.simditor-icon-undo:before {
|
|
99
|
+ content: '\f013';
|
|
100
|
+}
|
|
101
|
+
|
|
102
|
+.simditor-icon-smile-o:before {
|
|
103
|
+ content: '\f014';
|
|
104
|
+}
|
|
105
|
+
|
|
106
|
+.simditor-icon-tint:before {
|
|
107
|
+ content: '\f015';
|
|
108
|
+}
|
|
109
|
+
|
|
110
|
+.simditor-icon-font:before {
|
|
111
|
+ content: '\f016';
|
|
112
|
+}
|
|
113
|
+
|
|
114
|
+.simditor-icon-html5:before {
|
|
115
|
+ content: '\f017';
|
|
116
|
+}
|
|
117
|
+
|
|
118
|
+.simditor-icon-mark:before {
|
|
119
|
+ content: '\f018';
|
|
120
|
+}
|
|
121
|
+
|
|
122
|
+.simditor-icon-align-center:before {
|
|
123
|
+ content: '\f019';
|
|
124
|
+}
|
|
125
|
+
|
|
126
|
+.simditor-icon-align-left:before {
|
|
127
|
+ content: '\f01a';
|
|
128
|
+}
|
|
129
|
+
|
|
130
|
+.simditor-icon-align-right:before {
|
|
131
|
+ content: '\f01b';
|
|
132
|
+}
|
|
133
|
+
|
|
134
|
+.simditor-icon-font-minus:before {
|
|
135
|
+ content: '\f01c';
|
|
136
|
+}
|
|
137
|
+
|
|
138
|
+.simditor-icon-markdown:before {
|
|
139
|
+ content: '\f01d';
|
|
140
|
+}
|
|
141
|
+
|
|
142
|
+.simditor-icon-checklist:before {
|
|
143
|
+ content: '\f01e';
|
|
144
|
+}
|
|
145
|
+
|
|
146
|
+.simditor {
|
|
147
|
+ position: relative;
|
|
148
|
+ border: 1px solid #c9d8db;
|
|
149
|
+}
|
|
150
|
+.simditor .simditor-wrapper {
|
|
151
|
+ position: relative;
|
|
152
|
+ background: #ffffff;
|
|
153
|
+}
|
|
154
|
+.simditor .simditor-wrapper > textarea {
|
|
155
|
+ display: none !important;
|
|
156
|
+ width: 100%;
|
|
157
|
+ box-sizing: border-box;
|
|
158
|
+ font-family: monaco;
|
|
159
|
+ font-size: 16px;
|
|
160
|
+ line-height: 1.6;
|
|
161
|
+ border: none;
|
|
162
|
+ padding: 22px 15px 40px;
|
|
163
|
+ min-height: 300px;
|
|
164
|
+ outline: none;
|
|
165
|
+ background: transparent;
|
|
166
|
+ resize: none;
|
|
167
|
+}
|
|
168
|
+.simditor .simditor-wrapper .simditor-placeholder {
|
|
169
|
+ display: none;
|
|
170
|
+ position: absolute;
|
|
171
|
+ left: 0;
|
|
172
|
+ z-index: 0;
|
|
173
|
+ padding: 22px 15px;
|
|
174
|
+ font-size: 16px;
|
|
175
|
+ font-family: arial, sans-serif;
|
|
176
|
+ line-height: 1.5;
|
|
177
|
+ color: #999999;
|
|
178
|
+ background: transparent;
|
|
179
|
+}
|
|
180
|
+.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar {
|
|
181
|
+ position: fixed;
|
|
182
|
+ top: 0;
|
|
183
|
+ z-index: 10;
|
|
184
|
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
|
|
185
|
+}
|
|
186
|
+.simditor .simditor-wrapper .simditor-image-loading {
|
|
187
|
+ width: 100%;
|
|
188
|
+ height: 100%;
|
|
189
|
+ position: absolute;
|
|
190
|
+ top: 0;
|
|
191
|
+ left: 0;
|
|
192
|
+ z-index: 2;
|
|
193
|
+}
|
|
194
|
+.simditor .simditor-wrapper .simditor-image-loading .progress {
|
|
195
|
+ width: 100%;
|
|
196
|
+ height: 100%;
|
|
197
|
+ background: rgba(0, 0, 0, 0.4);
|
|
198
|
+ position: absolute;
|
|
199
|
+ bottom: 0;
|
|
200
|
+ left: 0;
|
|
201
|
+}
|
|
202
|
+.simditor .simditor-body {
|
|
203
|
+ padding: 22px 15px 40px;
|
|
204
|
+ min-height: 300px;
|
|
205
|
+ outline: none;
|
|
206
|
+ cursor: text;
|
|
207
|
+ position: relative;
|
|
208
|
+ z-index: 1;
|
|
209
|
+ background: transparent;
|
|
210
|
+}
|
|
211
|
+.simditor .simditor-body a.selected {
|
|
212
|
+ background: #b3d4fd;
|
|
213
|
+}
|
|
214
|
+.simditor .simditor-body a.simditor-mention {
|
|
215
|
+ cursor: pointer;
|
|
216
|
+}
|
|
217
|
+.simditor .simditor-body .simditor-table {
|
|
218
|
+ position: relative;
|
|
219
|
+}
|
|
220
|
+.simditor .simditor-body .simditor-table.resizing {
|
|
221
|
+ cursor: col-resize;
|
|
222
|
+}
|
|
223
|
+.simditor .simditor-body .simditor-table .simditor-resize-handle {
|
|
224
|
+ position: absolute;
|
|
225
|
+ left: 0;
|
|
226
|
+ top: 0;
|
|
227
|
+ width: 10px;
|
|
228
|
+ height: 100%;
|
|
229
|
+ cursor: col-resize;
|
|
230
|
+}
|
|
231
|
+.simditor .simditor-body pre {
|
|
232
|
+ /*min-height: 28px;*/
|
|
233
|
+ box-sizing: border-box;
|
|
234
|
+ -moz-box-sizing: border-box;
|
|
235
|
+ word-wrap: break-word !important;
|
|
236
|
+ white-space: pre-wrap !important;
|
|
237
|
+}
|
|
238
|
+.simditor .simditor-body img {
|
|
239
|
+ cursor: pointer;
|
|
240
|
+}
|
|
241
|
+.simditor .simditor-body img.selected {
|
|
242
|
+ box-shadow: 0 0 0 4px #cccccc;
|
|
243
|
+}
|
|
244
|
+.simditor .simditor-paste-bin {
|
|
245
|
+ position: fixed;
|
|
246
|
+ bottom: 10px;
|
|
247
|
+ right: 10px;
|
|
248
|
+ width: 1px;
|
|
249
|
+ height: 20px;
|
|
250
|
+ font-size: 1px;
|
|
251
|
+ line-height: 1px;
|
|
252
|
+ overflow: hidden;
|
|
253
|
+ padding: 0;
|
|
254
|
+ margin: 0;
|
|
255
|
+ opacity: 0;
|
|
256
|
+ -webkit-user-select: text;
|
|
257
|
+}
|
|
258
|
+.simditor .simditor-toolbar {
|
|
259
|
+ border-bottom: 1px solid #eeeeee;
|
|
260
|
+ background: #ffffff;
|
|
261
|
+ width: 100%;
|
|
262
|
+}
|
|
263
|
+.simditor .simditor-toolbar > ul {
|
|
264
|
+ margin: 0;
|
|
265
|
+ padding: 0 0 0 6px;
|
|
266
|
+ list-style: none;
|
|
267
|
+}
|
|
268
|
+.simditor .simditor-toolbar > ul > li {
|
|
269
|
+ position: relative;
|
|
270
|
+ display: inline-block;
|
|
271
|
+ font-size: 0;
|
|
272
|
+}
|
|
273
|
+.simditor .simditor-toolbar > ul > li > span.separator {
|
|
274
|
+ display: inline-block;
|
|
275
|
+ background: #cfcfcf;
|
|
276
|
+ width: 1px;
|
|
277
|
+ height: 18px;
|
|
278
|
+ margin: 11px 15px;
|
|
279
|
+ vertical-align: middle;
|
|
280
|
+}
|
|
281
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item {
|
|
282
|
+ display: inline-block;
|
|
283
|
+ width: 46px;
|
|
284
|
+ height: 40px;
|
|
285
|
+ outline: none;
|
|
286
|
+ color: #333333;
|
|
287
|
+ font-size: 15px;
|
|
288
|
+ line-height: 40px;
|
|
289
|
+ vertical-align: middle;
|
|
290
|
+ text-align: center;
|
|
291
|
+ text-decoration: none;
|
|
292
|
+}
|
|
293
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item span {
|
|
294
|
+ opacity: 0.6;
|
|
295
|
+}
|
|
296
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item span.simditor-icon {
|
|
297
|
+ display: inline;
|
|
298
|
+ line-height: normal;
|
|
299
|
+}
|
|
300
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item:hover span {
|
|
301
|
+ opacity: 1;
|
|
302
|
+}
|
|
303
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.active {
|
|
304
|
+ background: #eeeeee;
|
|
305
|
+}
|
|
306
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.active span {
|
|
307
|
+ opacity: 1;
|
|
308
|
+}
|
|
309
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled {
|
|
310
|
+ cursor: default;
|
|
311
|
+}
|
|
312
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.disabled span {
|
|
313
|
+ opacity: 0.3;
|
|
314
|
+}
|
|
315
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title span:before {
|
|
316
|
+ content: "H";
|
|
317
|
+ font-size: 19px;
|
|
318
|
+ font-weight: bold;
|
|
319
|
+ font-family: 'Times New Roman';
|
|
320
|
+}
|
|
321
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h1 span:before {
|
|
322
|
+ content: 'H1';
|
|
323
|
+ font-size: 18px;
|
|
324
|
+}
|
|
325
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h2 span:before {
|
|
326
|
+ content: 'H2';
|
|
327
|
+ font-size: 18px;
|
|
328
|
+}
|
|
329
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-title.active-h3 span:before {
|
|
330
|
+ content: 'H3';
|
|
331
|
+ font-size: 18px;
|
|
332
|
+}
|
|
333
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image {
|
|
334
|
+ position: relative;
|
|
335
|
+ overflow: hidden;
|
|
336
|
+}
|
|
337
|
+.simditor .simditor-toolbar > ul > li > .toolbar-item.toolbar-item-image > input[type=file] {
|
|
338
|
+ position: absolute;
|
|
339
|
+ right: 0px;
|
|
340
|
+ top: 0px;
|
|
341
|
+ opacity: 0;
|
|
342
|
+ font-size: 100px;
|
|
343
|
+ cursor: pointer;
|
|
344
|
+}
|
|
345
|
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item {
|
|
346
|
+ position: relative;
|
|
347
|
+ z-index: 20;
|
|
348
|
+ background: #ffffff;
|
|
349
|
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
|
|
350
|
+}
|
|
351
|
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-item span {
|
|
352
|
+ opacity: 1;
|
|
353
|
+}
|
|
354
|
+.simditor .simditor-toolbar > ul > li.menu-on .toolbar-menu {
|
|
355
|
+ display: block;
|
|
356
|
+}
|
|
357
|
+.simditor .simditor-toolbar .toolbar-menu {
|
|
358
|
+ display: none;
|
|
359
|
+ position: absolute;
|
|
360
|
+ top: 40px;
|
|
361
|
+ left: 0;
|
|
362
|
+ z-index: 21;
|
|
363
|
+ background: #ffffff;
|
|
364
|
+ text-align: left;
|
|
365
|
+ box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
|
|
366
|
+}
|
|
367
|
+.simditor .simditor-toolbar .toolbar-menu:before {
|
|
368
|
+ content: '';
|
|
369
|
+ display: block;
|
|
370
|
+ width: 46px;
|
|
371
|
+ height: 4px;
|
|
372
|
+ background: #ffffff;
|
|
373
|
+ position: absolute;
|
|
374
|
+ top: -3px;
|
|
375
|
+ left: 0;
|
|
376
|
+}
|
|
377
|
+.simditor .simditor-toolbar .toolbar-menu ul {
|
|
378
|
+ min-width: 160px;
|
|
379
|
+ list-style: none;
|
|
380
|
+ margin: 0;
|
|
381
|
+ padding: 10px 1px;
|
|
382
|
+}
|
|
383
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item {
|
|
384
|
+ display: block;
|
|
385
|
+ font-size: 16px;
|
|
386
|
+ line-height: 2em;
|
|
387
|
+ padding: 0 10px;
|
|
388
|
+ text-decoration: none;
|
|
389
|
+ color: #666666;
|
|
390
|
+}
|
|
391
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item:hover {
|
|
392
|
+ background: #f6f6f6;
|
|
393
|
+}
|
|
394
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h1 {
|
|
395
|
+ font-size: 24px;
|
|
396
|
+ color: #333333;
|
|
397
|
+}
|
|
398
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h2 {
|
|
399
|
+ font-size: 22px;
|
|
400
|
+ color: #333333;
|
|
401
|
+}
|
|
402
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h3 {
|
|
403
|
+ font-size: 20px;
|
|
404
|
+ color: #333333;
|
|
405
|
+}
|
|
406
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h4 {
|
|
407
|
+ font-size: 18px;
|
|
408
|
+ color: #333333;
|
|
409
|
+}
|
|
410
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .menu-item.menu-item-h5 {
|
|
411
|
+ font-size: 16px;
|
|
412
|
+ color: #333333;
|
|
413
|
+}
|
|
414
|
+.simditor .simditor-toolbar .toolbar-menu ul > li .separator {
|
|
415
|
+ display: block;
|
|
416
|
+ border-top: 1px solid #cccccc;
|
|
417
|
+ height: 0;
|
|
418
|
+ line-height: 0;
|
|
419
|
+ font-size: 0;
|
|
420
|
+ margin: 6px 0;
|
|
421
|
+}
|
|
422
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color {
|
|
423
|
+ width: 96px;
|
|
424
|
+}
|
|
425
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list {
|
|
426
|
+ height: 40px;
|
|
427
|
+ margin: 10px 6px 6px 10px;
|
|
428
|
+ padding: 0;
|
|
429
|
+ min-width: 0;
|
|
430
|
+}
|
|
431
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li {
|
|
432
|
+ float: left;
|
|
433
|
+ margin: 0 4px 4px 0;
|
|
434
|
+}
|
|
435
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color {
|
|
436
|
+ display: block;
|
|
437
|
+ width: 16px;
|
|
438
|
+ height: 16px;
|
|
439
|
+ background: #dfdfdf;
|
|
440
|
+ border-radius: 2px;
|
|
441
|
+}
|
|
442
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover {
|
|
443
|
+ opacity: 0.8;
|
|
444
|
+}
|
|
445
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default {
|
|
446
|
+ background: #333333;
|
|
447
|
+}
|
|
448
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1 {
|
|
449
|
+ background: #E33737;
|
|
450
|
+}
|
|
451
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2 {
|
|
452
|
+ background: #e28b41;
|
|
453
|
+}
|
|
454
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3 {
|
|
455
|
+ background: #c8a732;
|
|
456
|
+}
|
|
457
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4 {
|
|
458
|
+ background: #209361;
|
|
459
|
+}
|
|
460
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5 {
|
|
461
|
+ background: #418caf;
|
|
462
|
+}
|
|
463
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6 {
|
|
464
|
+ background: #aa8773;
|
|
465
|
+}
|
|
466
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7 {
|
|
467
|
+ background: #999999;
|
|
468
|
+}
|
|
469
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table {
|
|
470
|
+ background: #ffffff;
|
|
471
|
+ padding: 1px;
|
|
472
|
+}
|
|
473
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table {
|
|
474
|
+ border: none;
|
|
475
|
+ border-collapse: collapse;
|
|
476
|
+ border-spacing: 0;
|
|
477
|
+ table-layout: fixed;
|
|
478
|
+}
|
|
479
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td {
|
|
480
|
+ padding: 0;
|
|
481
|
+ cursor: pointer;
|
|
482
|
+}
|
|
483
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before {
|
|
484
|
+ width: 16px;
|
|
485
|
+ height: 16px;
|
|
486
|
+ border: 1px solid #ffffff;
|
|
487
|
+ background: #f3f3f3;
|
|
488
|
+ display: block;
|
|
489
|
+ content: "";
|
|
490
|
+}
|
|
491
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before {
|
|
492
|
+ background: #cfcfcf;
|
|
493
|
+}
|
|
494
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table {
|
|
495
|
+ display: none;
|
|
496
|
+}
|
|
497
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li {
|
|
498
|
+ white-space: nowrap;
|
|
499
|
+}
|
|
500
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image {
|
|
501
|
+ position: relative;
|
|
502
|
+ overflow: hidden;
|
|
503
|
+}
|
|
504
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file] {
|
|
505
|
+ position: absolute;
|
|
506
|
+ right: 0px;
|
|
507
|
+ top: 0px;
|
|
508
|
+ opacity: 0;
|
|
509
|
+ font-size: 100px;
|
|
510
|
+ cursor: pointer;
|
|
511
|
+}
|
|
512
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment {
|
|
513
|
+ width: 100%;
|
|
514
|
+}
|
|
515
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul {
|
|
516
|
+ min-width: 100%;
|
|
517
|
+}
|
|
518
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item {
|
|
519
|
+ text-align: center;
|
|
520
|
+}
|
|
521
|
+.simditor .simditor-popover {
|
|
522
|
+ display: none;
|
|
523
|
+ padding: 5px 8px 0;
|
|
524
|
+ background: #ffffff;
|
|
525
|
+ box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
|
|
526
|
+ border-radius: 2px;
|
|
527
|
+ position: absolute;
|
|
528
|
+ z-index: 2;
|
|
529
|
+}
|
|
530
|
+.simditor .simditor-popover .settings-field {
|
|
531
|
+ margin: 0 0 5px 0;
|
|
532
|
+ font-size: 12px;
|
|
533
|
+ height: 25px;
|
|
534
|
+ line-height: 25px;
|
|
535
|
+}
|
|
536
|
+.simditor .simditor-popover .settings-field label {
|
|
537
|
+ display: inline-block;
|
|
538
|
+ margin: 0 5px 0 0;
|
|
539
|
+}
|
|
540
|
+.simditor .simditor-popover .settings-field input[type=text] {
|
|
541
|
+ display: inline-block;
|
|
542
|
+ width: 200px;
|
|
543
|
+ box-sizing: border-box;
|
|
544
|
+ font-size: 12px;
|
|
545
|
+}
|
|
546
|
+.simditor .simditor-popover .settings-field input[type=text].image-size {
|
|
547
|
+ width: 83px;
|
|
548
|
+}
|
|
549
|
+.simditor .simditor-popover .settings-field .times {
|
|
550
|
+ display: inline-block;
|
|
551
|
+ width: 26px;
|
|
552
|
+ font-size: 12px;
|
|
553
|
+ text-align: center;
|
|
554
|
+}
|
|
555
|
+.simditor .simditor-popover.link-popover .btn-unlink, .simditor .simditor-popover.image-popover .btn-upload, .simditor .simditor-popover.image-popover .btn-restore {
|
|
556
|
+ display: inline-block;
|
|
557
|
+ margin: 0 0 0 5px;
|
|
558
|
+ color: #333333;
|
|
559
|
+ font-size: 14px;
|
|
560
|
+ outline: 0;
|
|
561
|
+}
|
|
562
|
+.simditor .simditor-popover.link-popover .btn-unlink span, .simditor .simditor-popover.image-popover .btn-upload span, .simditor .simditor-popover.image-popover .btn-restore span {
|
|
563
|
+ opacity: 0.6;
|
|
564
|
+}
|
|
565
|
+.simditor .simditor-popover.link-popover .btn-unlink:hover span, .simditor .simditor-popover.image-popover .btn-upload:hover span, .simditor .simditor-popover.image-popover .btn-restore:hover span {
|
|
566
|
+ opacity: 1;
|
|
567
|
+}
|
|
568
|
+.simditor .simditor-popover.image-popover .btn-upload {
|
|
569
|
+ position: relative;
|
|
570
|
+ display: inline-block;
|
|
571
|
+ overflow: hidden;
|
|
572
|
+ vertical-align: middle;
|
|
573
|
+}
|
|
574
|
+.simditor .simditor-popover.image-popover .btn-upload input[type=file] {
|
|
575
|
+ position: absolute;
|
|
576
|
+ right: 0px;
|
|
577
|
+ top: 0px;
|
|
578
|
+ opacity: 0;
|
|
579
|
+ height: 100%;
|
|
580
|
+ width: 28px;
|
|
581
|
+}
|
|
582
|
+.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar {
|
|
583
|
+ position: absolute;
|
|
584
|
+ top: 0;
|
|
585
|
+ z-index: 10;
|
|
586
|
+ box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
|
|
587
|
+}
|
|
588
|
+
|
|
589
|
+.simditor .simditor-body, .editor-style {
|
|
590
|
+ font-size: 16px;
|
|
591
|
+ font-family: arial, sans-serif;
|
|
592
|
+ line-height: 1.6;
|
|
593
|
+ color: #333;
|
|
594
|
+ outline: none;
|
|
595
|
+ word-wrap: break-word;
|
|
596
|
+}
|
|
597
|
+.simditor .simditor-body > :first-child, .editor-style > :first-child {
|
|
598
|
+ margin-top: 0 !important;
|
|
599
|
+}
|
|
600
|
+.simditor .simditor-body a, .editor-style a {
|
|
601
|
+ color: #4298BA;
|
|
602
|
+ text-decoration: none;
|
|
603
|
+ word-break: break-all;
|
|
604
|
+}
|
|
605
|
+.simditor .simditor-body a:visited, .editor-style a:visited {
|
|
606
|
+ color: #4298BA;
|
|
607
|
+}
|
|
608
|
+.simditor .simditor-body a:hover, .editor-style a:hover {
|
|
609
|
+ color: #0F769F;
|
|
610
|
+}
|
|
611
|
+.simditor .simditor-body a:active, .editor-style a:active {
|
|
612
|
+ color: #9E792E;
|
|
613
|
+}
|
|
614
|
+.simditor .simditor-body a:hover, .simditor .simditor-body a:active, .editor-style a:hover, .editor-style a:active {
|
|
615
|
+ outline: 0;
|
|
616
|
+}
|
|
617
|
+.simditor .simditor-body h1, .simditor .simditor-body h2, .simditor .simditor-body h3, .simditor .simditor-body h4, .simditor .simditor-body h5, .simditor .simditor-body h6, .editor-style h1, .editor-style h2, .editor-style h3, .editor-style h4, .editor-style h5, .editor-style h6 {
|
|
618
|
+ font-weight: normal;
|
|
619
|
+ margin: 40px 0 20px;
|
|
620
|
+ color: #000000;
|
|
621
|
+}
|
|
622
|
+.simditor .simditor-body h1, .editor-style h1 {
|
|
623
|
+ font-size: 24px;
|
|
624
|
+}
|
|
625
|
+.simditor .simditor-body h2, .editor-style h2 {
|
|
626
|
+ font-size: 22px;
|
|
627
|
+}
|
|
628
|
+.simditor .simditor-body h3, .editor-style h3 {
|
|
629
|
+ font-size: 20px;
|
|
630
|
+}
|
|
631
|
+.simditor .simditor-body h4, .editor-style h4 {
|
|
632
|
+ font-size: 18px;
|
|
633
|
+}
|
|
634
|
+.simditor .simditor-body h5, .editor-style h5 {
|
|
635
|
+ font-size: 16px;
|
|
636
|
+}
|
|
637
|
+.simditor .simditor-body h6, .editor-style h6 {
|
|
638
|
+ font-size: 16px;
|
|
639
|
+}
|
|
640
|
+.simditor .simditor-body p, .simditor .simditor-body div, .editor-style p, .editor-style div {
|
|
641
|
+ word-wrap: break-word;
|
|
642
|
+ margin: 0 0 15px 0;
|
|
643
|
+ color: #333;
|
|
644
|
+ word-wrap: break-word;
|
|
645
|
+}
|
|
646
|
+.simditor .simditor-body b, .simditor .simditor-body strong, .editor-style b, .editor-style strong {
|
|
647
|
+ font-weight: bold;
|
|
648
|
+}
|
|
649
|
+.simditor .simditor-body i, .simditor .simditor-body em, .editor-style i, .editor-style em {
|
|
650
|
+ font-style: italic;
|
|
651
|
+}
|
|
652
|
+.simditor .simditor-body u, .editor-style u {
|
|
653
|
+ text-decoration: underline;
|
|
654
|
+}
|
|
655
|
+.simditor .simditor-body strike, .simditor .simditor-body del, .editor-style strike, .editor-style del {
|
|
656
|
+ text-decoration: line-through;
|
|
657
|
+}
|
|
658
|
+.simditor .simditor-body ul, .simditor .simditor-body ol, .editor-style ul, .editor-style ol {
|
|
659
|
+ list-style: disc outside none;
|
|
660
|
+ margin: 15px 0;
|
|
661
|
+ padding: 0 0 0 40px;
|
|
662
|
+ line-height: 1.6;
|
|
663
|
+}
|
|
664
|
+.simditor .simditor-body ul ul, .simditor .simditor-body ul ol, .simditor .simditor-body ol ul, .simditor .simditor-body ol ol, .editor-style ul ul, .editor-style ul ol, .editor-style ol ul, .editor-style ol ol {
|
|
665
|
+ padding-left: 30px;
|
|
666
|
+}
|
|
667
|
+.simditor .simditor-body ul ul, .simditor .simditor-body ol ul, .editor-style ul ul, .editor-style ol ul {
|
|
668
|
+ list-style: circle outside none;
|
|
669
|
+}
|
|
670
|
+.simditor .simditor-body ul ul ul, .simditor .simditor-body ol ul ul, .editor-style ul ul ul, .editor-style ol ul ul {
|
|
671
|
+ list-style: square outside none;
|
|
672
|
+}
|
|
673
|
+.simditor .simditor-body ol, .editor-style ol {
|
|
674
|
+ list-style: decimal;
|
|
675
|
+}
|
|
676
|
+.simditor .simditor-body blockquote, .editor-style blockquote {
|
|
677
|
+ border-left: 6px solid #ddd;
|
|
678
|
+ padding: 5px 0 5px 10px;
|
|
679
|
+ margin: 15px 0 15px 15px;
|
|
680
|
+}
|
|
681
|
+.simditor .simditor-body blockquote > :first-child, .editor-style blockquote > :first-child {
|
|
682
|
+ margin-top: 0;
|
|
683
|
+}
|
|
684
|
+.simditor .simditor-body code, .editor-style code {
|
|
685
|
+ display: inline-block;
|
|
686
|
+ padding: 0 4px;
|
|
687
|
+ margin: 0 5px;
|
|
688
|
+ background: #eeeeee;
|
|
689
|
+ border-radius: 3px;
|
|
690
|
+ font-size: 13px;
|
|
691
|
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
|
692
|
+}
|
|
693
|
+.simditor .simditor-body pre, .editor-style pre {
|
|
694
|
+ padding: 10px 5px 10px 10px;
|
|
695
|
+ margin: 15px 0;
|
|
696
|
+ display: block;
|
|
697
|
+ line-height: 18px;
|
|
698
|
+ background: #F0F0F0;
|
|
699
|
+ border-radius: 3px;
|
|
700
|
+ font-size: 13px;
|
|
701
|
+ font-family: 'monaco', 'Consolas', "Liberation Mono", Courier, monospace;
|
|
702
|
+ white-space: pre;
|
|
703
|
+ word-wrap: normal;
|
|
704
|
+ overflow-x: auto;
|
|
705
|
+}
|
|
706
|
+.simditor .simditor-body pre code, .editor-style pre code {
|
|
707
|
+ display: block;
|
|
708
|
+ padding: 0;
|
|
709
|
+ margin: 0;
|
|
710
|
+ background: none;
|
|
711
|
+ border-radius: 0;
|
|
712
|
+}
|
|
713
|
+.simditor .simditor-body hr, .editor-style hr {
|
|
714
|
+ display: block;
|
|
715
|
+ height: 0px;
|
|
716
|
+ border: 0;
|
|
717
|
+ border-top: 1px solid #ccc;
|
|
718
|
+ margin: 15px 0;
|
|
719
|
+ padding: 0;
|
|
720
|
+}
|
|
721
|
+.simditor .simditor-body table, .editor-style table {
|
|
722
|
+ width: 100%;
|
|
723
|
+ table-layout: fixed;
|
|
724
|
+ border-collapse: collapse;
|
|
725
|
+ border-spacing: 0;
|
|
726
|
+ margin: 15px 0;
|
|
727
|
+}
|
|
728
|
+.simditor .simditor-body table thead, .editor-style table thead {
|
|
729
|
+ background-color: #f9f9f9;
|
|
730
|
+}
|
|
731
|
+.simditor .simditor-body table td, .simditor .simditor-body table th, .editor-style table td, .editor-style table th {
|
|
732
|
+ min-width: 40px;
|
|
733
|
+ height: 30px;
|
|
734
|
+ border: 1px solid #ccc;
|
|
735
|
+ vertical-align: top;
|
|
736
|
+ padding: 2px 4px;
|
|
737
|
+ text-align: left;
|
|
738
|
+ box-sizing: border-box;
|
|
739
|
+}
|
|
740
|
+.simditor .simditor-body table td.active, .simditor .simditor-body table th.active, .editor-style table td.active, .editor-style table th.active {
|
|
741
|
+ background-color: #ffffee;
|
|
742
|
+}
|
|
743
|
+.simditor .simditor-body img, .editor-style img {
|
|
744
|
+ margin: 0 5px;
|
|
745
|
+ vertical-align: middle;
|
|
746
|
+}
|
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+/*!
|
|
2
|
+* Simditor v2.3.6
|
|
3
|
+* http://simditor.tower.im/
|
|
4
|
+* 2015-12-21
|
|
5
|
+*/@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,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) format("woff");font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'}.simditor{position:relative;border:1px solid #c9d8db}.simditor .simditor-wrapper{position:relative;background:#fff}.simditor .simditor-wrapper>textarea{display:none!important;width:100%;box-sizing:border-box;font-family:monaco;font-size:16px;line-height:1.6;border:0;padding:22px 15px 40px;min-height:300px;outline:0;background:transparent;resize:none}.simditor .simditor-wrapper .simditor-placeholder{display:none;position:absolute;left:0;z-index:0;padding:22px 15px;font-size:16px;font-family:arial,sans-serif;line-height:1.5;color:#999;background:transparent}.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar{position:fixed;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-wrapper .simditor-image-loading{width:100%;height:100%;position:absolute;top:0;left:0;z-index:2}.simditor .simditor-wrapper .simditor-image-loading .progress{width:100%;height:100%;background:rgba(0,0,0,0.4);position:absolute;bottom:0;left:0}.simditor .simditor-body{padding:22px 15px 40px;min-height:300px;outline:0;cursor:text;position:relative;z-index:1;background:transparent}.simditor .simditor-body a.selected{background:#b3d4fd}.simditor .simditor-body a.simditor-mention{cursor:pointer}.simditor .simditor-body .simditor-table{position:relative}.simditor .simditor-body .simditor-table.resizing{cursor:col-resize}.simditor .simditor-body .simditor-table .simditor-resize-handle{position:absolute;left:0;top:0;width:10px;height:100%;cursor:col-resize}.simditor .simditor-body pre{box-sizing:border-box;-moz-box-sizing:border-box;word-wrap:break-word!important;white-space:pre-wrap!important}.simditor .simditor-body img{cursor:pointer}.simditor .simditor-body img.selected{box-shadow:0 0 0 4px #ccc}.simditor .simditor-paste-bin{position:fixed;bottom:10px;right:10px;width:1px;height:20px;font-size:1px;line-height:1px;overflow:hidden;padding:0;margin:0;opacity:0;-webkit-user-select:text}.simditor .simditor-toolbar{border-bottom:1px solid #eee;background:#fff;width:100%}.simditor .simditor-toolbar>ul{margin:0;padding:0 0 0 6px;list-style:none}.simditor .simditor-toolbar>ul>li{position:relative;display:inline-block;font-size:0}.simditor .simditor-toolbar>ul>li>span.separator{display:inline-block;background:#cfcfcf;width:1px;height:18px;margin:11px 15px;vertical-align:middle}
|
|
6
|
+.simditor .simditor-toolbar>ul>li>.toolbar-item{display:inline-block;width:46px;height:40px;outline:0;color:#333;font-size:15px;line-height:40px;vertical-align:middle;text-align:center;text-decoration:none}.simditor .simditor-toolbar>ul>li>.toolbar-item span{opacity:.6}.simditor .simditor-toolbar>ul>li>.toolbar-item span.simditor-icon{display:inline;line-height:normal}.simditor .simditor-toolbar>ul>li>.toolbar-item:hover span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.active{background:#eee}.simditor .simditor-toolbar>ul>li>.toolbar-item.active span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled{cursor:default}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled span{opacity:.3}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title span:before{content:"H";font-size:19px;font-weight:bold;font-family:'Times New Roman'}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h1 span:before{content:'H1';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h2 span:before{content:'H2';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h3 span:before{content:'H3';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image{position:relative;overflow:hidden}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image>input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item{position:relative;z-index:20;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item span{opacity:1}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-menu{display:block}.simditor .simditor-toolbar .toolbar-menu{display:none;position:absolute;top:40px;left:0;z-index:21;background:#fff;text-align:left;box-shadow:0 0 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar .toolbar-menu:before{content:'';display:block;width:46px;height:4px;background:#fff;position:absolute;top:-3px;left:0}.simditor .simditor-toolbar .toolbar-menu ul{min-width:160px;list-style:none;margin:0;padding:10px 1px}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item{display:block;font-size:16px;line-height:2em;padding:0 10px;text-decoration:none;color:#666}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item:hover{background:#f6f6f6}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h1{font-size:24px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h2{font-size:22px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h3{font-size:20px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h4{font-size:18px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h5{font-size:16px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .separator{display:block;border-top:1px solid #ccc;height:0;line-height:0;font-size:0;margin:6px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color{width:96px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list{height:40px;margin:10px 6px 6px 10px;padding:0;min-width:0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li{float:left;margin:0 4px 4px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color{display:block;width:16px;height:16px;background:#dfdfdf;border-radius:2px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover{opacity:.8}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default{background:#333}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1{background:#e33737}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2{background:#e28b41}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3{background:#c8a732}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4{background:#209361}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5{background:#418caf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6{background:#aa8773}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7{background:#999}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table{background:#fff;padding:1px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table{border:0;border-collapse:collapse;border-spacing:0;table-layout:fixed}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td{padding:0;cursor:pointer}
|
|
7
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before{width:16px;height:16px;border:1px solid #fff;background:#f3f3f3;display:block;content:""}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before{background:#cfcfcf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table{display:none}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li{white-space:nowrap}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image{position:relative;overflow:hidden}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment{width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul{min-width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item{text-align:center}.simditor .simditor-popover{display:none;padding:5px 8px 0;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.4);border-radius:2px;position:absolute;z-index:2}.simditor .simditor-popover .settings-field{margin:0 0 5px 0;font-size:12px;height:25px;line-height:25px}.simditor .simditor-popover .settings-field label{display:inline-block;margin:0 5px 0 0}.simditor .simditor-popover .settings-field input[type=text]{display:inline-block;width:200px;box-sizing:border-box;font-size:12px}.simditor .simditor-popover .settings-field input[type=text].image-size{width:83px}.simditor .simditor-popover .settings-field .times{display:inline-block;width:26px;font-size:12px;text-align:center}.simditor .simditor-popover.link-popover .btn-unlink,.simditor .simditor-popover.image-popover .btn-upload,.simditor .simditor-popover.image-popover .btn-restore{display:inline-block;margin:0 0 0 5px;color:#333;font-size:14px;outline:0}.simditor .simditor-popover.link-popover .btn-unlink span,.simditor .simditor-popover.image-popover .btn-upload span,.simditor .simditor-popover.image-popover .btn-restore span{opacity:.6}.simditor .simditor-popover.link-popover .btn-unlink:hover span,.simditor .simditor-popover.image-popover .btn-upload:hover span,.simditor .simditor-popover.image-popover .btn-restore:hover span{opacity:1}.simditor .simditor-popover.image-popover .btn-upload{position:relative;display:inline-block;overflow:hidden;vertical-align:middle}.simditor .simditor-popover.image-popover .btn-upload input[type=file]{position:absolute;right:0;top:0;opacity:0;height:100%;width:28px}.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar{position:absolute;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-body,.editor-style{font-size:16px;font-family:arial,sans-serif;line-height:1.6;color:#333;outline:0;word-wrap:break-word}.simditor .simditor-body>:first-child,.editor-style>:first-child{margin-top:0!important}.simditor .simditor-body a,.editor-style a{color:#4298ba;text-decoration:none;word-break:break-all}.simditor .simditor-body a:visited,.editor-style a:visited{color:#4298ba}.simditor .simditor-body a:hover,.editor-style a:hover{color:#0f769f}.simditor .simditor-body a:active,.editor-style a:active{color:#9e792e}.simditor .simditor-body a:hover,.simditor .simditor-body a:active,.editor-style a:hover,.editor-style a:active{outline:0}.simditor .simditor-body h1,.simditor .simditor-body h2,.simditor .simditor-body h3,.simditor .simditor-body h4,.simditor .simditor-body h5,.simditor .simditor-body h6,.editor-style h1,.editor-style h2,.editor-style h3,.editor-style h4,.editor-style h5,.editor-style h6{font-weight:normal;margin:40px 0 20px;color:#000}.simditor .simditor-body h1,.editor-style h1{font-size:24px}.simditor .simditor-body h2,.editor-style h2{font-size:22px}.simditor .simditor-body h3,.editor-style h3{font-size:20px}.simditor .simditor-body h4,.editor-style h4{font-size:18px}.simditor .simditor-body h5,.editor-style h5{font-size:16px}.simditor .simditor-body h6,.editor-style h6{font-size:16px}.simditor .simditor-body p,.simditor .simditor-body div,.editor-style p,.editor-style div{word-wrap:break-word;margin:0 0 15px 0;color:#333;word-wrap:break-word}.simditor .simditor-body b,.simditor .simditor-body strong,.editor-style b,.editor-style strong{font-weight:bold}.simditor .simditor-body i,.simditor .simditor-body em,.editor-style i,.editor-style em{font-style:italic}.simditor .simditor-body u,.editor-style u{text-decoration:underline}.simditor .simditor-body strike,.simditor .simditor-body del,.editor-style strike,.editor-style del{text-decoration:line-through}.simditor .simditor-body ul,.simditor .simditor-body ol,.editor-style ul,.editor-style ol{list-style:disc outside none;margin:15px 0;padding:0 0 0 40px;line-height:1.6}.simditor .simditor-body ul ul,.simditor .simditor-body ul ol,.simditor .simditor-body ol ul,.simditor .simditor-body ol ol,.editor-style ul ul,.editor-style ul ol,.editor-style ol ul,.editor-style ol ol{padding-left:30px}
|
|
8
|
+.simditor .simditor-body ul ul,.simditor .simditor-body ol ul,.editor-style ul ul,.editor-style ol ul{list-style:circle outside none}.simditor .simditor-body ul ul ul,.simditor .simditor-body ol ul ul,.editor-style ul ul ul,.editor-style ol ul ul{list-style:square outside none}.simditor .simditor-body ol,.editor-style ol{list-style:decimal}.simditor .simditor-body blockquote,.editor-style blockquote{border-left:6px solid #ddd;padding:5px 0 5px 10px;margin:15px 0 15px 15px}.simditor .simditor-body blockquote>:first-child,.editor-style blockquote>:first-child{margin-top:0}.simditor .simditor-body code,.editor-style code{display:inline-block;padding:0 4px;margin:0 5px;background:#eee;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace}.simditor .simditor-body pre,.editor-style pre{padding:10px 5px 10px 10px;margin:15px 0;display:block;line-height:18px;background:#f0f0f0;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace;white-space:pre;word-wrap:normal;overflow-x:auto}.simditor .simditor-body pre code,.editor-style pre code{display:block;padding:0;margin:0;background:0;border-radius:0}.simditor .simditor-body hr,.editor-style hr{display:block;height:0;border:0;border-top:1px solid #ccc;margin:15px 0;padding:0}.simditor .simditor-body table,.editor-style table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:15px 0}.simditor .simditor-body table thead,.editor-style table thead{background-color:#f9f9f9}.simditor .simditor-body table td,.simditor .simditor-body table th,.editor-style table td,.editor-style table th{min-width:40px;height:30px;border:1px solid #ccc;vertical-align:top;padding:2px 4px;text-align:left;box-sizing:border-box}.simditor .simditor-body table td.active,.simditor .simditor-body table th.active,.editor-style table td.active,.editor-style table th.active{background-color:#ffe}.simditor .simditor-body img,.editor-style img{margin:0 5px;vertical-align:middle}.simditor .markdown-editor{display:none}.simditor .markdown-editor textarea{display:block;width:100%;min-height:200px;box-sizing:border-box;padding:22px 15px 40px;border:0;border-bottom:1px solid #dfdfdf;resize:none;outline:0;font-size:16px}.simditor.simditor-markdown .markdown-editor{display:block}.simditor.simditor-markdown .simditor-body{min-height:100px;background:#f3f3f3}.simditor.simditor-markdown .simditor-placeholder{display:none!important}.simditor .simditor-toolbar .toolbar-item.toolbar-item-markdown .simditor-icon{font-size:18px}.simditor .simditor-body .simditor-checklist{margin:15px 0;padding:0 0 0 40px;line-height:1.6;list-style-type:none}.simditor .simditor-body .simditor-checklist>li{margin:0;pointer-events:none}.simditor .simditor-body .simditor-checklist>li::before{content:'';pointer-events:all;display:inline-block;margin:0 5px 0 -25px;width:20px;height:20px;cursor:default;vertical-align:middle;background-image:url("data:image/gif;base64,R0lGODlhFAAUAPUAAP///9nZ2XV1dWNjY3Z2dv7+/mpqasbGxsPDw21tbfv7+2RkZM/Pz/X19crKymdnZ+/v725ubsvLy/Hx8XBwcO7u7nd3d83Nzezs7Hp6eoCAgNfX14SEhIqKitLS0uDg4I2NjZSUlNTU1Ojo6NXV1ZaWlp6entjY2J+fn6WlpeXl5ebm5qmpqY6OjvPz85CQkP39/Xt7e/Ly8t3d3dzc3P///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAAA1ACwAAAAAFAAUAAAG/8BarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9WAtVpAMBgMBoPBYEAI1Gq1Wq1WKxgOAAAAAAAAAIhEoVar1Wo1xYLRaDQajUaj4XgoarVarVaDACOSyWQymUwmEwkFUqvVarVaxXLBYDAYDAaDuWQqtVqtVqtVNIzNZrPZbDYbBqdSq9VqtVql4wF+Pp/P5/P5eECVWq1Wq9UqIdFoNBqNRqMRqVSp1Wq1Wq1i2kwmk8lkMpmcUJVarVar1SopFQAABAAAAABgxarUarVaraZoOVwul8vlcrkuL0WtVqvVajBHTGYgEAgEAoEg5oDVarVarVaDyWY0Gg1Io9FmMlitVqvVarVarVYoFAqFQqFQq9VqtVqtVqvVarVarVar1Wq1Wq1Wq9VqtVqtVqvVarUasFar1Wq1Wq1Wq9VqtVqtVqvVarVarVar1YIAOw==")}.simditor .simditor-body .simditor-checklist>li[checked]::before{background-image:url("data:image/gif;base64,R0lGODlhFAAUAPYAAAAAAHeHkD9QYB8wSOjo6Haw6C1huLbn8MfY8Ja42I630Ia48NjY2IefoJbH6Ja44H648D9CkCVZsE9XWFWY2D5wqI+foH6gwE9fYHeIoF93iPj4+J7P+J7A4IegyE54sPDw8I+nuB5BmAAHCEdXWC9BiFaAuFdveF2g4F9veB5JoA8PD12Y4GWg4CZRqKbI6GWo4BcoOK7Q8Cc4SDVwwAcPEEdQYA8YIDc/QBYykC1pwD9IWGaY0C8/SE2Q0B84UF6QyFWY4E2Q2D5omAcIGA8gMEZoiEZvkC5ZsE9ZmP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAABKACwAAAAAFAAUAAAH/4BKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKEys4SkpKSkpKSkpKSkpKSkpKShYAIyBKSkpKSkpKIUkRERERERERNwA2SkpKSkpKShslHggICAgICAEANyUbSkpKSkpKGzkoMjIyMjIdKwAVORtKSkpKSkogIhSAOz0ZMjI2ADZBIiBKSkpKSkogKkEaACsJFwArHUEqIEpKSkpKSiAuQSgxAD8xAEMoQS4gSkpKSkpKIEgoMDw1AAADMDAoSCBKSkpKSkogBigFBUcANTwFBS0GIEpKSkpKSiA0MAsLCzNHCwsLLTQgSkpKSkpKICYLHBwcDhwcgJYcHAsmIEpKSkpKShspCgcHBwcHBwcHCikbSkpKSkpKGxYYGBgYGBgYGBgYFhtKSkpKSkpKGyAMDAwMDAwMDCAbSkpKSkpKSkpKShsbGxsbGxsbSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkpKSkqASkpKSkpKSkpKSkpKSkpKSkpKSkpKSoEAOw==")}@font-face{font-family:'icomoon';src:url("../fonts/icomoon.eot?4vkjot");src:url("../fonts/icomoon.eot?#iefix4vkjot") format("embedded-opentype"),url("../fonts/icomoon.ttf?4vkjot") format("truetype"),url("../fonts/icomoon.woff?4vkjot") format("woff"),url("../fonts/icomoon.svg?4vkjot#icomoon") format("svg");font-weight:normal;font-style:normal}[class^="icon-"],[class*=" icon-"]{font-family:'icomoon';speak:none;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.icon-fullscreen:before{content:"\e600"}.simditor-fullscreen{overflow:hidden}.simditor-fullscreen .simditor{position:fixed;top:0;left:0;z-index:9999;width:100%}.simditor-fullscreen .simditor .simditor-body{overflow:auto}
|
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+/*!
|
|
2
|
+* Simditor v2.3.6
|
|
3
|
+* http://simditor.tower.im/
|
|
4
|
+* 2015-12-21
|
|
5
|
+*/@font-face{font-family:'Simditor';src:url(data:application/font-woff;charset=utf-8;base64,d09GRgABAAAAABp8AA4AAAAAKmwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABGRlRNAAAaYAAAABoAAAAcdO8GE09TLzIAAAG0AAAARQAAAGAQ+ZFXY21hcAAAAkgAAABRAAABWuA2Gx9jdnQgAAAEgAAAAAoAAAAKAwQAxGZwZ20AAAKcAAABsQAAAmUPtC+nZ2x5ZgAABNgAABPeAAAgZG/p6QxoZWFkAAABRAAAADAAAAA2BvuCgGhoZWEAAAF0AAAAHgAAACQH9QTlaG10eAAAAfwAAABKAAAAlHv7AItsb2NhAAAEjAAAAEwAAABMi4qTXm1heHAAAAGUAAAAIAAAACABRwHNbmFtZQAAGLgAAAEFAAAB12vS/ulwb3N0AAAZwAAAAJ4AAAFsyCrvunByZXAAAARQAAAALgAAAC6w8isUeNpjYGRgYADiKAkPy3h+m68M8swfgCIMF0/IVyDo/84sFswJQC4HAxNIFAAZwAnyeNpjYGRgYE5gmMAQzWLBwPD/O5AEiqAAVQBa6wPkAAAAAQAAACUAoAAKAAAAAAACAAEAAgAWAAABAAEpAAAAAHjaY2BhnsA4gYGVgYGpn+kgAwNDL4RmfMxgxMgCFGVgZWaAAUYBBjTQwMDwQY454X8BQzRzAsMEIJcRSVaBgREAQ9oK6QAAAHjaY8xhUGQAAsYABgbmDwjMYsEgxCzBwMDkAOQnALEEgx1UjhNMr4BjTqBakDxC/wqIPsYMqJoEKIbpk0C1C4zXM3DA5AEzchbtAAB42mNgYGBmgGAZBkYGEAgB8hjBfBYGCyDNxcDBwASEDAy8DAof5P7/B6sCsRmAbOb/3/8/FWCD6oUCRjaIkWA2SCcLAyoAqmZlGN4AALmUC0kAAAB42l1Ru05bQRDdDQ8DgcTYIDnaFLOZkALvhTZIIK4uwsh2YzlC2o1c5GJcwAdQIFGD9msGaChTpE2DkAskPoFPiJSZNYmiNDs7s3POmTNLypGqd2m956lzFkjhboNmm34npNpFgAfS9Y1GRtrBIy02M3rlun2/j8FmNOVOGkB5z1vKQ0bTTqAW7bl/Mj+D4T7/yzwHg5Zmmp5aZyE9hMB8M25p8DWjWXf9QV+xOlwNBoYU01Tc9cdUyv+W5lxtGbY2M5p3cCEiP5gGaGqtjUDTnzqkej6OYgly+WysDSamrD/JRHBhMl3VVC0zvnZwn+wsOtikSnPgAQ6wVZ6Ch+OjCYX0LYkyS0OEg9gqMULEJIdCTjl3sj8pUD6ShDFvktLOuGGtgXHkNTCozdMcvsxmU9tbhzB+EUfw3S/Gkg4+sqE2RoTYjlgKYAKRkFFVvqHGcy+LAbnU/jMQJWB5+u1fJwKtOzYRL2VtnWOMFYKe3zbf+WXF3apc50Whu3dVNVTplOZDL2ff4xFPj4XhoLHgzed9f6NA7Q2LGw2aA8GQ3o3e/9FadcRV3gsf2W81s7EWAAAAuAH/hbABjQBLsAhQWLEBAY5ZsUYGK1ghsBBZS7AUUlghsIBZHbAGK1xYWbAUKwAAAAAAowCFACECfwAAAAAAKgAqACoAKgAqACoAfgEkAcAChAK+A2oElgU2BbQGxgeYCBgIPgjGCU4KZgqKCq4LQAuYDDoMcAzuDXINoA4MDngO4g86D6QQMnjazVl5cBvXeX9vF4tdXHsBuwBBEvdBAgQXxOIgRPGQSEkULcoJJds6Yku2Na6TKJXHsnx0XNptHcvNpLaSJpkczthV68Zu0ulbQE58qXXaHK3j7ThjD6PmmnQmaTydSaqkmdbxkFC/tyApinXiuP2jlcC37/vegX3f8fu+7wExKIkQLjCPIxbxaNjCyNja4l3sTyqWm/vu1hbLQBdZLGVzlN3i3a7lrS1M+aaSVPKmkk5iz+tf/zrz+MrRJHMDgp3US3/tyjEvIQn1oiJCWd6dx7kGrsexLuGwjlm3AXSQ0h5M+5M4D3/1MNbx4b5AoPNmIIDdgQB0v/e9AJ78JqemVLfT4uN0sDtAHzBtvvvYsIK5aqWgcF6XyizRR+f+K9cAhRB9T3TpGTbCRlAARdAEehiRCYNwNulNLCmkzyZ+g6g2GTSIaJKCTUo2JpMGSS0RZBOp0kohb7E9lerzFMlghSDZ4nGRbLGJRpdXbGsKFy2UUlRL7Gk2iaacYzlfeCITbhJeJY0msvycorZj8eYWylMV4JFBtaXlKs1mszyS5UNh3azUqvlhnOLZsAZEvZpLp9gU35jAjfo4lvM5GEzn6xkzXAnrWogXMR/DITfvTuMy9hSyr0XSx+6VXa6+1NFbTrwrPvD+v8OevSHFLzT9cYbZgqXZ+U9cVahEC7nrTo6ZN33w2fdsCykvTOaaCTc+/vn7XbOf27X840CNEYXYRJYp6gEOswb24YPlHbsHtIgSvO1Tt/aNgglRWTJTIMsB9FeIDIAcTZKzidsmIYNoNumpEE0mvSDCQcMqgKDq0ecmDv/sY0grekXil4n0opXCvyTxF4Foi34pWCQpuZ1IxYPFdpK2LWAmPpT4UNotKmqzBTx4kEQTPe0X44lkatj5h6+gyFQUI8s9AErADCghpxChSUIq6W9aWq+iEh0EzeVzKTffqK/+V2sg03wjXKk33FSeImbcYKhhN4/fd9OemVtlr18f6ZF5rjKH9R0+33cKp0KsIC1o7ti2EsbaPoaf9TE+XHZxvoCWEf8N39gvBlhmi0fAkSinC+Kfdr71j6KX8/f3IsaxwaMgt13oOvSHqDWPUJHst4lgUJPbYrSVYGw6EzbJmG2FpioVMiaTCDWwcZMkbLKjgskBgwSWSMZuZQLUIDMxT7EVyNBuIAi2mZGtEbDEg/A3kgGDi/RuGQODQ1aiABSWA3WgrMgWkMa2JhlTyCTIBLxUhbO706lhZhxXc/mUgetmuFGpm3xYc6d4dz+mQgGbBJFN4OowNjCYIp9vmGG9EdZDsFbEwRoYbDIFk0O6mazUmTcx5w8nC4c/c/3p7WF9p8ozvPRZIiZYjLPTXh4L3N6Rxs1jUZ8Wcgksy/T3NAXGODmw0+tiotqg/xavsPwVwesV2K2Cl/ly0tv5m+Nbkjur+2+/7oX3J1hmBPMc5rMcJ/LTyd/77O8O9A6F5NSO04195WQ+hpmymxFwMCDybv/ymxm6EW2o/U5c+g/m28xHURrwSg9J2A0n5mmTq1J0gqZeiYPXQUOHmZdkeY9cVJ94Qi1CR37iiU30Y7+Cv0av4c9F0L2EBtEcWkTENMiMo3vJJmmD6OAuVwEILZGs3Z7IqkKRTNokK1uz4EAl29oDOp2cAMXJTZJVqPpm1afj+kChYlJIKSnnIv3R4qCjbWEGtF0ojU5SbaclIGQ12k+n6QqJUJVXdFCTG9SVA43XzUauVm3UzUoYAEUC7eaom4RA5WHeBPWKbIpqnBoHIFEjhqktgCHkc+z3qVyXq7TtjF6156NX3+4OMLwh9MVGPrhn7u6bzQd+7Ar7hq87cLq0N+lnmKasspMnM/trJQXf2tUIbTKzV98yuyunv6/pYVhmf9zcfnhPKp4+ox3a2j88qgd0r9fDjw8N4giTLrtu7Js5MCBRXHcjz6XbQK6HURiV0RSaR9ejD+BB1KpT3xq3iatCxmXC2hTHAeNlm0QNMmyTsk32GeSQTVIGydvkZoNsN8n7bKqSbZXWzM3UpWau8hQx+W2DsEtkrkIYmzCytQPUMW8TvtLaMU8n7Zj2FNvq/A7QV8IkXruleilbpaFiXrYMX5FE6J7WCVAgwyoqgJYWy+ym2tihtEOl4V1OSFCfllE4lb+KEvOK5RsCCPOqbTc3WHB0KvsB2LwB4NaVtkcMhuhEVrV4DVhIIUCNq8TdtIajYCS9TbIP4lqTlFVSapJDyrlYojCUoWtSKsk2SV4hg2AIDV5L10zNCSSpfMOJQXy+Pom1dK4KCFmrplNAmxWdBhrerHHaBrNJVnRM19fSbgoG2uZBZRP9QH3r87X+5Ph7s4m+SHlMqgT2v8wOhKfi0WA5tnNwNBceZ3ax+73Cyn5qF8wXBO/y6+fHsSsyMD/GXrORv7F/iOm/ZmQbPzhXzVaiiSwX3+a/cFAyG2IuEksmx40Zw5+KJNvH6Xza4J81Gmc8WnHXD//pMi+y3u3aFbr0XfYi8wvIlCQUR3nUANQ+gVoatSvIF1iKyzwkCgap2sRHKfDjccen05TKgz/PQmhcsvwZgHJsW0KiUrF24yKy+jSKxi4OUf+sloDw+AMCJWbGgUhmsgkgyiN1UAqoobL2xJvkiX4Ff7PcL0wemlz7sNddKd63YG7sn3KW/bPTdv5iXUaMsZlzpQAZJ+l6EvAujibRAmpxVG4Zk4puK6QHIDWT+G0yBDFtyiDCEgiI9NitHoE6T48CzoNlawB8LWmTpt1qDlB+c8RTtLaBBAHB4IhFnMrVlGp9bBXOgHaiD6W5txmH9K50oTT51F0ZSdOkzNg1CX2xNInfeEvuDPAmS/jDdz2lSbOSds2Yqiecif+NSY/tXT87tRwDzn81OgK2cx96BD2GHkStj1NZ+G1r6D1gGJxhZfabVDDWnnsrVDTWzB1Ab7Wt4x8GumZYxx4A+lGwp8cN8skl4rGtyCiMeGQLAabIZegP2tbsrfQpWwngTR2F/kHbuvsh+pStdwHvtvuh/xHb+hNHflmI1hvkUafYvpHmNo3j2q8ff6fzN39fQ+maLNWXgysJr3COGtQVzUZu5wdvzf9N5lxuZmvZFX+2Vssyv8hVD62b8A/We69ctvBn3oL5NsOX93lh5VHna46B5Gk+4Ln0ZfYx9jqomhqQDT7u1CNRm+x0ckE3RZBrneC013ayvrklmmLnZCsGPrFgk+10hm6TBdlinFLESfq25yC+JPtmds7vpWiixyBmTO+DALGgWKH98GTUds/4xLVORNkJgeJphm9u2TZNJxfcMHmGTrpWsYp0UUpt53bPvduBomy9CmlBio8xkO+5U8Ns3h2C7KgClZ4zAElUlx5m8hSSYiy3llnlqo38WnLVTan4cL0SZtOyfEoaVlnFzXkTMUnkZVaV7pBLUuer3ec+mCCXNk7A3zfK+4wHyyeNSqV8euTUFdTDsOQUpBcyz/sHEi6fW2FVAzaS8He6zwV5SL5ywr+PPDi8YJTvGDkNTmScuoJCLpqzuUbBj3kkohgaRu9FrbCDY4D/BkV/2SBF0I8BOcQSCUH9I1scaMNL8b6FOYpZ2NPFsl7gJ2yrDFrCUAsSf5P0KiQAemDDgPkCRACnXFSICOK+jOzJWiOMs5BXa0o3rwYPyYU3e8utDowz9y2/fu4QTuDE8r1O4vwAtAu17PK91N3ZB3JVZncXt19YPk4nnt0I9erKfsdCv5CrVimEQZ2HE2wEvwE4piEAKgrYfjiubFjKOghvjDNsJKGv7NcTCZ35gp7Af3ucdmmDOAcTLzr1dz8qoXHI1OqoFaTSjDr5r8upuyEphqoa5DcNJg9ftdewrqYR0yzQsg7RWll1zMo5OhjT5leovUP6a9xZXvR6Rf4sa6wlsuzLTgx81BHMsc39y3PwR/38Wc4r4BnBy53t/OjXwsMrV+QXby8PdoM8fG8tD4Gn8giCLax7l/6/lccFKgrOEQobeacCYYY7L1BR8I5cOrO/uUAEpz56kj2KPGBrSdRE74ZM/r3oJPo2apWpVAbsFiQVxTY7UIZUe4DCH2TycZtca5DDNkVPipR3OEi5HfBRtmTwOB8IT7aOQe+ITY7IVhVT77VOUaycAxEyHOCcrHzRo4fHZ3bMUw/0qWRvkxxT2kMlp3gmR1Qy0CRV5UtGvt44cPD4CcrMqOQk+G60rKhfFELBzFCpStlxhaQBQNV2vTGzgzIOK2R3k0yoX9oytn3uxpuOf4Ay9yrkdif5hpyb3oXpYY36O9VBRc91ExcnbVmvTnN5qLMrkw7YNvRwns+vQS6f24Csrg1r8YY9w+vf9J9nQDmBwJlAdMEre+GzuB4LmbMAp6WHys97xdOfkoYp/H7aKyknLhOqeH5tCr59fV3nQnenH61v/fEzHOd0MuuxdtGZ0tNF2Be8uvfTFI9L0mdOe6Tfukz4/efXpow7K3BifYvr13btYhM6x0wBNgWQiojbcIBJNCzJASZ0OfaAVTNFzbfsSXiWfZqE38BvaHHoAieuOfvM4hnmIdgniJwdeKjYIFtf3ehKsJlxVtH1+O61/STYvBsrwH63OvVCHnK+21CLp3Yrmt3AQG9wIGh4TRo9+rppr7lEhiAHli0MZhmwSUC2PNBT7JZHobHDE+nmu9aQCbY6thVsFSuWKwPPgEomwf4yCRgwyhQHMlWnZqf3hs6zscGzx3AMO1kWFHIsmMhqcjyO012zoLbDvKLFNC32hNNen9CXv0LR+6JvNH0mPeq7qCe+JPSc0aQzknYGsnR12dfnW1adyaufs+foAtoMDCQS+Fp9mSbRy3pYptKWu/eGzv1XDlURFYbk3BjmQHN55+YDxD5A0S0kKeo5jLzRXuotOcVKZegJkexOp3KrHhPDzhVpig/r/Ophqo16HNcT7NFO68a/nPD5592Ka/Cu6bueeur1ffOqV+iBF4K32X0fvp6Jdh7tLMwFfPNuhquNPfXTp+b3ymEdXpeebfauVYxefd8gZGlpVEQm+ghqFalWDUeZoLKwQWIm6YVUrUIPYcJZqgYZWYKMnCbjPaBOzSaabCWh12+TftnKdi90aqBXrQdSMJ87XzAq9KRJpc0yAT/t9qtPS8Fccdh0UrVwAOYJSmawVKaDvUo7OzA04iRmWMRUJhOYiqRC7+dieC17cK0+VTmXcMt6AgSYyMn1BLOo3f7w7Ron9vW5xD037BFdfX1i50eFrYXCVjznPJ57tbP06qu4gHtXOp9eWcG3YHZm374ZsdcjiqXR0ZIoenoxR2eufjp/jAuv0kVMb3fBytq9+zTEORP8wgtZVA61/FR+gMuQT3hAWpJBgRpZnF9RW4ybd+7DsYnT+SSfxmwS15Ia/sZRvGtxrvOZubvwyT/C0ZV76ZYr/mefZe7s/NnKv54/j7o1p+ODEajeG2gvIl6jFUs2TCiefHarN12tQAEEzlc0wNAwGTWsJv1inxdciI+DT2WUViBqwguQotrWI8MGlTVWiOZcklbqZi5Pr0kbE2wDm0HIhGNMHIf4fIoH/KXgXAN0FnEoxgKe83j0SU7jyo3OT3rLW7BY6U8KOD17j7qQjhSjewUWL2l/z8xh3tu7sCI35EQk78J4gMGPnFh5zCWUXALfozE/7/xL4Rt7x09oMpv0cB5BjEkMK8jaeZz7RFT1cC6c9HKrZ/+Y8/uGgnT0eUQ8Br30gvxUMgFPCKoQBo5t0h85ggA+YcOKdC/mXxx/c5FezBN1WCT6i5zFML8UiffF5ya/8eYFOsARDCMijATpSOhFjohyG4k4WCSMDAbrDRbbHtpSvkT5LGp7xZDu3NFP+RFmWI9XlNRgl7X2j0xFaQ7ZSAaT9M4xHcdmrRFM5nGS5bLMvUJHjuID/hMn+Jv8LzMv9XU+4bmE2Mhs5/nOeUa+ufPq/bHY1Y828SgeuQULy986fHhVDmBvzEtgeSEaGVBX2VBV6w6ga2BOWUANiKCN/AQex9gMa+zFlWeDmd7snj/4UEIKM8K7m+cPHnwt0BPfw39wiNVEE3+nuYdi/GrOtlbX51bvNSAv1gx6tZE1KKDXDKjeKcCv3lVkN+VY+U10423G2YuASwcomLJPStoFTeoIlKChBwB5+XVnJNId+aQzcqukHZ+lPdr8w6/tof9H51opU4J5pXuux52Ro92Ru52Rh/5PzvVOc+grz7XxWBtP9T86FIuESyfZZ5ivQkSKoRTUDEQwWu6gTlHOY7c4NUxRLmBArMFQRlgZCnEegUJciKYNCmG6+KrHsZbna3VwPBGHIQPNSbg2gScxZs0gVJ34z3fjqbypLn3zHtfCG2bIJd3w+B2l2jjLYu3I157BLuary52g12X4vcNy9OWTh4WouyT6XEWfznGM2rmEv3XgAMV/qgPmTuf34RQ6hloC1YAO2OTcdSlxeHHJeVfiW6J8XabVJb33S3ZvO1ibnsJKKlA1p5ok5txrs/R3PWTpcDJKasq5YKQ/meqGxIqubSyQsZLm82nFrIUbGtdI19Jamv1cvFCIL5+lLf7p4g1HFheP3IC3PHZk8QbmzkK80+cM/DBe6Aj4dxYXOw+ev+ee8/HvOoHm8t1mEU2hQ6s2lbBbCVrwo0QBCv4ep1im59rm3G52Iz8cg+Y42+E0mX4o+pXhStOJ7z2QxrWH6036gw2RFCfVu1xer1b5EN8hGS1i51e2tdsAsDkIPGYliDdesazes7CRI9OdoekjR6bxa8mk4OL7XB7OJ3aGoMLP4ddyVS7j5kK/36mLGfHnojgBj4/h49BOiPiadnfd9BGRDfJ9nKua6657hIdVGMMiWEOnOmvoYoT+C93/Vj8AAHjafY+/asMwEIc/JU6aQhsyltJBQ6eCg20IgdCt1GTwlNJsHUJijCCxwHaeqVufpM/Qta/Ri31ZOkTipO9Ov/sjYMwXhm7d8qBsGPGs3OOKd+U+j3wqB6L5UR5wY4zykJGxojTBtXj3bdaJDROelHvS91W5z5IP5UA038oD7vhVHjIxY1I8JQ2ObUs1lkz2C6S+bNzWl7XNMnHfRHNgJ2cjykoC7rBzjRdakVNwZM/m9LDKi+N+I3AunrYJhagsCVMiuRdi/0t20Vg0IXOxRJQxs26U1FdFbpNpZBf23FowTsJ5mETx7OKEa+ldyedcO9GpRzcF67yqnS9tLHUvVfgDz/ZF8gAAAHjabc25DgFhGIXh/53B2Pd9J9HPN/bSWolC4iI0OjfgxhFO6SQnT/k6z333errI/dvkc5yHh+98YsRJEJAkRZoMWXLkKVCkRJkKVWrUadCkRZsOXXr0GTBkxDh2vp5O3u4SPO63YxiG0mQkp3Im53Ihl3Il13Ijt3In9/Igjz9NfVPf1Df1TX1T39Q39U19U9/UN/VNfVPfDm8tR0peAAB42mNgYGBkAIKLcceVwfQJ+XIoXQEARe8GegAA) format("woff");font-weight:normal;font-style:normal}.simditor-icon{display:inline-block;font:normal normal normal 14px/1 'Simditor';font-size:inherit;text-rendering:auto;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;transform:translate(0,0)}.simditor-icon-code:before{content:'\f000'}.simditor-icon-bold:before{content:'\f001'}.simditor-icon-italic:before{content:'\f002'}.simditor-icon-underline:before{content:'\f003'}.simditor-icon-times:before{content:'\f004'}.simditor-icon-strikethrough:before{content:'\f005'}.simditor-icon-list-ol:before{content:'\f006'}.simditor-icon-list-ul:before{content:'\f007'}.simditor-icon-quote-left:before{content:'\f008'}.simditor-icon-table:before{content:'\f009'}.simditor-icon-link:before{content:'\f00a'}.simditor-icon-picture-o:before{content:'\f00b'}.simditor-icon-minus:before{content:'\f00c'}.simditor-icon-indent:before{content:'\f00d'}.simditor-icon-outdent:before{content:'\f00e'}.simditor-icon-unlink:before{content:'\f00f'}.simditor-icon-caret-down:before{content:'\f010'}.simditor-icon-caret-right:before{content:'\f011'}.simditor-icon-upload:before{content:'\f012'}.simditor-icon-undo:before{content:'\f013'}.simditor-icon-smile-o:before{content:'\f014'}.simditor-icon-tint:before{content:'\f015'}.simditor-icon-font:before{content:'\f016'}.simditor-icon-html5:before{content:'\f017'}.simditor-icon-mark:before{content:'\f018'}.simditor-icon-align-center:before{content:'\f019'}.simditor-icon-align-left:before{content:'\f01a'}.simditor-icon-align-right:before{content:'\f01b'}.simditor-icon-font-minus:before{content:'\f01c'}.simditor-icon-markdown:before{content:'\f01d'}.simditor-icon-checklist:before{content:'\f01e'}.simditor{position:relative;border:1px solid #c9d8db}.simditor .simditor-wrapper{position:relative;background:#fff}.simditor .simditor-wrapper>textarea{display:none!important;width:100%;box-sizing:border-box;font-family:monaco;font-size:16px;line-height:1.6;border:0;padding:22px 15px 40px;min-height:300px;outline:0;background:transparent;resize:none}.simditor .simditor-wrapper .simditor-placeholder{display:none;position:absolute;left:0;z-index:0;padding:22px 15px;font-size:16px;font-family:arial,sans-serif;line-height:1.5;color:#999;background:transparent}.simditor .simditor-wrapper.toolbar-floating .simditor-toolbar{position:fixed;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-wrapper .simditor-image-loading{width:100%;height:100%;position:absolute;top:0;left:0;z-index:2}.simditor .simditor-wrapper .simditor-image-loading .progress{width:100%;height:100%;background:rgba(0,0,0,0.4);position:absolute;bottom:0;left:0}.simditor .simditor-body{padding:22px 15px 40px;min-height:300px;outline:0;cursor:text;position:relative;z-index:1;background:transparent}.simditor .simditor-body a.selected{background:#b3d4fd}.simditor .simditor-body a.simditor-mention{cursor:pointer}.simditor .simditor-body .simditor-table{position:relative}.simditor .simditor-body .simditor-table.resizing{cursor:col-resize}.simditor .simditor-body .simditor-table .simditor-resize-handle{position:absolute;left:0;top:0;width:10px;height:100%;cursor:col-resize}.simditor .simditor-body pre{box-sizing:border-box;-moz-box-sizing:border-box;word-wrap:break-word!important;white-space:pre-wrap!important}.simditor .simditor-body img{cursor:pointer}.simditor .simditor-body img.selected{box-shadow:0 0 0 4px #ccc}.simditor .simditor-paste-bin{position:fixed;bottom:10px;right:10px;width:1px;height:20px;font-size:1px;line-height:1px;overflow:hidden;padding:0;margin:0;opacity:0;-webkit-user-select:text}.simditor .simditor-toolbar{border-bottom:1px solid #eee;background:#fff;width:100%}.simditor .simditor-toolbar>ul{margin:0;padding:0 0 0 6px;list-style:none}.simditor .simditor-toolbar>ul>li{position:relative;display:inline-block;font-size:0}.simditor .simditor-toolbar>ul>li>span.separator{display:inline-block;background:#cfcfcf;width:1px;height:18px;margin:11px 15px;vertical-align:middle}
|
|
6
|
+.simditor .simditor-toolbar>ul>li>.toolbar-item{display:inline-block;width:46px;height:40px;outline:0;color:#333;font-size:15px;line-height:40px;vertical-align:middle;text-align:center;text-decoration:none}.simditor .simditor-toolbar>ul>li>.toolbar-item span{opacity:.6}.simditor .simditor-toolbar>ul>li>.toolbar-item span.simditor-icon{display:inline;line-height:normal}.simditor .simditor-toolbar>ul>li>.toolbar-item:hover span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.active{background:#eee}.simditor .simditor-toolbar>ul>li>.toolbar-item.active span{opacity:1}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled{cursor:default}.simditor .simditor-toolbar>ul>li>.toolbar-item.disabled span{opacity:.3}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title span:before{content:"H";font-size:19px;font-weight:bold;font-family:'Times New Roman'}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h1 span:before{content:'H1';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h2 span:before{content:'H2';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-title.active-h3 span:before{content:'H3';font-size:18px}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image{position:relative;overflow:hidden}.simditor .simditor-toolbar>ul>li>.toolbar-item.toolbar-item-image>input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item{position:relative;z-index:20;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-item span{opacity:1}.simditor .simditor-toolbar>ul>li.menu-on .toolbar-menu{display:block}.simditor .simditor-toolbar .toolbar-menu{display:none;position:absolute;top:40px;left:0;z-index:21;background:#fff;text-align:left;box-shadow:0 0 4px rgba(0,0,0,0.3)}.simditor .simditor-toolbar .toolbar-menu:before{content:'';display:block;width:46px;height:4px;background:#fff;position:absolute;top:-3px;left:0}.simditor .simditor-toolbar .toolbar-menu ul{min-width:160px;list-style:none;margin:0;padding:10px 1px}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item{display:block;font-size:16px;line-height:2em;padding:0 10px;text-decoration:none;color:#666}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item:hover{background:#f6f6f6}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h1{font-size:24px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h2{font-size:22px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h3{font-size:20px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h4{font-size:18px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .menu-item.menu-item-h5{font-size:16px;color:#333}.simditor .simditor-toolbar .toolbar-menu ul>li .separator{display:block;border-top:1px solid #ccc;height:0;line-height:0;font-size:0;margin:6px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color{width:96px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list{height:40px;margin:10px 6px 6px 10px;padding:0;min-width:0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li{float:left;margin:0 4px 4px 0}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color{display:block;width:16px;height:16px;background:#dfdfdf;border-radius:2px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color:hover{opacity:.8}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color.font-color-default{background:#333}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-1{background:#e33737}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-2{background:#e28b41}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-3{background:#c8a732}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-4{background:#209361}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-5{background:#418caf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-6{background:#aa8773}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-color .color-list li .font-color-7{background:#999}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table{background:#fff;padding:1px}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table{border:0;border-collapse:collapse;border-spacing:0;table-layout:fixed}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td{padding:0;cursor:pointer}
|
|
7
|
+.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td:before{width:16px;height:16px;border:1px solid #fff;background:#f3f3f3;display:block;content:""}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-create-table table td.selected:before{background:#cfcfcf}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table{display:none}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-table .menu-edit-table ul li{white-space:nowrap}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image{position:relative;overflow:hidden}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-image .menu-item-upload-image input[type=file]{position:absolute;right:0;top:0;opacity:0;font-size:100px;cursor:pointer}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment{width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment ul{min-width:100%}.simditor .simditor-toolbar .toolbar-menu.toolbar-menu-alignment .menu-item{text-align:center}.simditor .simditor-popover{display:none;padding:5px 8px 0;background:#fff;box-shadow:0 1px 4px rgba(0,0,0,0.4);border-radius:2px;position:absolute;z-index:2}.simditor .simditor-popover .settings-field{margin:0 0 5px 0;font-size:12px;height:25px;line-height:25px}.simditor .simditor-popover .settings-field label{display:inline-block;margin:0 5px 0 0}.simditor .simditor-popover .settings-field input[type=text]{display:inline-block;width:200px;box-sizing:border-box;font-size:12px}.simditor .simditor-popover .settings-field input[type=text].image-size{width:83px}.simditor .simditor-popover .settings-field .times{display:inline-block;width:26px;font-size:12px;text-align:center}.simditor .simditor-popover.link-popover .btn-unlink,.simditor .simditor-popover.image-popover .btn-upload,.simditor .simditor-popover.image-popover .btn-restore{display:inline-block;margin:0 0 0 5px;color:#333;font-size:14px;outline:0}.simditor .simditor-popover.link-popover .btn-unlink span,.simditor .simditor-popover.image-popover .btn-upload span,.simditor .simditor-popover.image-popover .btn-restore span{opacity:.6}.simditor .simditor-popover.link-popover .btn-unlink:hover span,.simditor .simditor-popover.image-popover .btn-upload:hover span,.simditor .simditor-popover.image-popover .btn-restore:hover span{opacity:1}.simditor .simditor-popover.image-popover .btn-upload{position:relative;display:inline-block;overflow:hidden;vertical-align:middle}.simditor .simditor-popover.image-popover .btn-upload input[type=file]{position:absolute;right:0;top:0;opacity:0;height:100%;width:28px}.simditor.simditor-mobile .simditor-wrapper.toolbar-floating .simditor-toolbar{position:absolute;top:0;z-index:10;box-shadow:0 0 6px rgba(0,0,0,0.1)}.simditor .simditor-body,.editor-style{font-size:16px;font-family:arial,sans-serif;line-height:1.6;color:#333;outline:0;word-wrap:break-word}.simditor .simditor-body>:first-child,.editor-style>:first-child{margin-top:0!important}.simditor .simditor-body a,.editor-style a{color:#4298ba;text-decoration:none;word-break:break-all}.simditor .simditor-body a:visited,.editor-style a:visited{color:#4298ba}.simditor .simditor-body a:hover,.editor-style a:hover{color:#0f769f}.simditor .simditor-body a:active,.editor-style a:active{color:#9e792e}.simditor .simditor-body a:hover,.simditor .simditor-body a:active,.editor-style a:hover,.editor-style a:active{outline:0}.simditor .simditor-body h1,.simditor .simditor-body h2,.simditor .simditor-body h3,.simditor .simditor-body h4,.simditor .simditor-body h5,.simditor .simditor-body h6,.editor-style h1,.editor-style h2,.editor-style h3,.editor-style h4,.editor-style h5,.editor-style h6{font-weight:normal;margin:40px 0 20px;color:#000}.simditor .simditor-body h1,.editor-style h1{font-size:24px}.simditor .simditor-body h2,.editor-style h2{font-size:22px}.simditor .simditor-body h3,.editor-style h3{font-size:20px}.simditor .simditor-body h4,.editor-style h4{font-size:18px}.simditor .simditor-body h5,.editor-style h5{font-size:16px}.simditor .simditor-body h6,.editor-style h6{font-size:16px}.simditor .simditor-body p,.simditor .simditor-body div,.editor-style p,.editor-style div{word-wrap:break-word;margin:0 0 15px 0;color:#333;word-wrap:break-word}.simditor .simditor-body b,.simditor .simditor-body strong,.editor-style b,.editor-style strong{font-weight:bold}.simditor .simditor-body i,.simditor .simditor-body em,.editor-style i,.editor-style em{font-style:italic}.simditor .simditor-body u,.editor-style u{text-decoration:underline}.simditor .simditor-body strike,.simditor .simditor-body del,.editor-style strike,.editor-style del{text-decoration:line-through}.simditor .simditor-body ul,.simditor .simditor-body ol,.editor-style ul,.editor-style ol{list-style:disc outside none;margin:15px 0;padding:0 0 0 40px;line-height:1.6}.simditor .simditor-body ul ul,.simditor .simditor-body ul ol,.simditor .simditor-body ol ul,.simditor .simditor-body ol ol,.editor-style ul ul,.editor-style ul ol,.editor-style ol ul,.editor-style ol ol{padding-left:30px}
|
|
8
|
+.simditor .simditor-body ul ul,.simditor .simditor-body ol ul,.editor-style ul ul,.editor-style ol ul{list-style:circle outside none}.simditor .simditor-body ul ul ul,.simditor .simditor-body ol ul ul,.editor-style ul ul ul,.editor-style ol ul ul{list-style:square outside none}.simditor .simditor-body ol,.editor-style ol{list-style:decimal}.simditor .simditor-body blockquote,.editor-style blockquote{border-left:6px solid #ddd;padding:5px 0 5px 10px;margin:15px 0 15px 15px}.simditor .simditor-body blockquote>:first-child,.editor-style blockquote>:first-child{margin-top:0}.simditor .simditor-body code,.editor-style code{display:inline-block;padding:0 4px;margin:0 5px;background:#eee;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace}.simditor .simditor-body pre,.editor-style pre{padding:10px 5px 10px 10px;margin:15px 0;display:block;line-height:18px;background:#f0f0f0;border-radius:3px;font-size:13px;font-family:'monaco','Consolas',"Liberation Mono",Courier,monospace;white-space:pre;word-wrap:normal;overflow-x:auto}.simditor .simditor-body pre code,.editor-style pre code{display:block;padding:0;margin:0;background:0;border-radius:0}.simditor .simditor-body hr,.editor-style hr{display:block;height:0;border:0;border-top:1px solid #ccc;margin:15px 0;padding:0}.simditor .simditor-body table,.editor-style table{width:100%;table-layout:fixed;border-collapse:collapse;border-spacing:0;margin:15px 0}.simditor .simditor-body table thead,.editor-style table thead{background-color:#f9f9f9}.simditor .simditor-body table td,.simditor .simditor-body table th,.editor-style table td,.editor-style table th{min-width:40px;height:30px;border:1px solid #ccc;vertical-align:top;padding:2px 4px;text-align:left;box-sizing:border-box}.simditor .simditor-body table td.active,.simditor .simditor-body table th.active,.editor-style table td.active,.editor-style table th.active{background-color:#ffe}.simditor .simditor-body img,.editor-style img{margin:0 5px;vertical-align:middle}
|
|
|
@@ -0,0 +1,4 @@
|
|
1
|
+@charset "UTF-8";
|
|
2
|
+
|
|
3
|
+@import 'fonticon';
|
|
4
|
+@import 'editor';
|
|
|
@@ -0,0 +1,3 @@
|
|
1
|
+<div class="django-simditor-widget" data-field-id="{{id}}" style="display: inline-block;">
|
|
2
|
+ <textarea{{ final_attrs|safe }} data-processed="0" data-config='{{config|safe}}' data-id="{{id}}" data-type="simditortype">{{ value }}</textarea>
|
|
3
|
+</div>
|
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+"""simditor urls."""
|
|
2
|
+from __future__ import absolute_import
|
|
3
|
+
|
|
4
|
+import django
|
|
5
|
+
|
|
6
|
+from django.conf import settings
|
|
7
|
+from django.conf.urls import url, static
|
|
8
|
+from django.contrib.admin.views.decorators import staff_member_required
|
|
9
|
+
|
|
10
|
+from . import views
|
|
11
|
+
|
|
12
|
+if django.VERSION >= (2, 0):
|
|
13
|
+ # pylint disable=C0103
|
|
14
|
+ from django.urls import path
|
|
15
|
+ urlpatterns = [
|
|
16
|
+ path('upload/', staff_member_required(views.UPLOAD),
|
|
17
|
+ name='simditor_upload'),
|
|
18
|
+ ]
|
|
19
|
+elif django.VERSION >= (1, 8):
|
|
20
|
+ # pylint disable=C0103
|
|
21
|
+ urlpatterns = [
|
|
22
|
+ url(r'^upload/', staff_member_required(views.UPLOAD),
|
|
23
|
+ name='simditor_upload'),
|
|
24
|
+ ]
|
|
25
|
+else:
|
|
26
|
+ from django.conf.urls import patterns # pylint disable=C0411
|
|
27
|
+
|
|
28
|
+ # pylint disable=C0103
|
|
29
|
+ urlpatterns = patterns(
|
|
30
|
+ '',
|
|
31
|
+ url(r'^upload/', staff_member_required(views.UPLOAD),
|
|
32
|
+ name='simditor_upload'),
|
|
33
|
+ )
|
|
34
|
+
|
|
35
|
+if settings.DEBUG:
|
|
36
|
+ urlpatterns += static.static(settings.MEDIA_URL,
|
|
37
|
+ document_root=settings.MEDIA_ROOT)
|
|
38
|
+ urlpatterns += static.static(settings.STATIC_URL,
|
|
39
|
+ document_root=settings.STATIC_ROOT)
|
|
|
@@ -0,0 +1,46 @@
|
|
1
|
+"""simditor utils."""
|
|
2
|
+from __future__ import absolute_import
|
|
3
|
+
|
|
4
|
+import os.path
|
|
5
|
+import random
|
|
6
|
+
|
|
7
|
+import string
|
|
8
|
+
|
|
9
|
+from django.core.files.storage import default_storage
|
|
10
|
+from django.template.defaultfilters import slugify
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+class NotAnImageException(Exception):
|
|
14
|
+ pass
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+def get_random_string():
|
|
18
|
+ """Get random string."""
|
|
19
|
+ return ''.join(random.sample(string.ascii_lowercase * 6, 6))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+def get_slugified_name(filename):
|
|
23
|
+ """get_slugified_name."""
|
|
24
|
+ slugified = slugify(filename)
|
|
25
|
+ return slugified or get_random_string()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+def slugify_filename(filename):
|
|
29
|
+ """ Slugify filename """
|
|
30
|
+ name, ext = os.path.splitext(filename)
|
|
31
|
+ slugified = get_slugified_name(name)
|
|
32
|
+ return slugified + ext
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+def get_media_url(path):
|
|
36
|
+ """
|
|
37
|
+ Determine system file's media URL.
|
|
38
|
+ """
|
|
39
|
+ return default_storage.url(path)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+def is_valid_image_extension(file_path):
|
|
43
|
+ """is_valid_image_extension."""
|
|
44
|
+ valid_extensions = ['.jpeg', '.jpg', '.gif', '.png']
|
|
45
|
+ _, extension = os.path.splitext(file_path)
|
|
46
|
+ return extension.lower() in valid_extensions
|
|
|
@@ -0,0 +1,84 @@
|
|
1
|
+"""simditor views."""
|
|
2
|
+from __future__ import absolute_import
|
|
3
|
+
|
|
4
|
+import os
|
|
5
|
+from datetime import datetime
|
|
6
|
+
|
|
7
|
+from django.conf import settings
|
|
8
|
+from django.core.files.storage import default_storage
|
|
9
|
+
|
|
10
|
+from django.http import JsonResponse
|
|
11
|
+
|
|
12
|
+from django.views import generic
|
|
13
|
+from django.views.decorators.csrf import csrf_exempt
|
|
14
|
+
|
|
15
|
+from . import utils, image_processing
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+def get_upload_filename(upload_name):
|
|
19
|
+ # Generate date based path to put uploaded file.
|
|
20
|
+ date_path = datetime.now().strftime('%Y/%m/%d')
|
|
21
|
+
|
|
22
|
+ # Complete upload path (upload_path + date_path).
|
|
23
|
+ upload_path = os.path.join(settings.SIMDITOR_UPLOAD_PATH, date_path)
|
|
24
|
+
|
|
25
|
+ if getattr(settings, 'SIMDITOR_UPLOAD_SLUGIFY_FILENAME', True):
|
|
26
|
+ upload_name = utils.slugify_filename(upload_name)
|
|
27
|
+
|
|
28
|
+ return default_storage.get_available_name(os.path.join(upload_path, upload_name))
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+def upload_handler(request):
|
|
32
|
+ files = request.FILES
|
|
33
|
+
|
|
34
|
+ upload_config = settings.SIMDITOR_CONFIGS.get(
|
|
35
|
+ 'upload', {'fileKey': 'upload'})
|
|
36
|
+ filekey = upload_config.get('fileKey', 'upload')
|
|
37
|
+
|
|
38
|
+ uploaded_file = files.get(filekey)
|
|
39
|
+
|
|
40
|
+ if not uploaded_file:
|
|
41
|
+ retdata = {'file_path': '', 'success': False,
|
|
42
|
+ 'msg': '图片上传失败,无法获取到图片对象!'}
|
|
43
|
+ return JsonResponse(retdata)
|
|
44
|
+
|
|
45
|
+ image_size = upload_config.get('image_size')
|
|
46
|
+ if image_size and uploaded_file.size > image_size:
|
|
47
|
+ retdata = {'file_path': '', 'success': False,
|
|
48
|
+ 'msg': '上传失败,已超出图片最大限制!'}
|
|
49
|
+ return JsonResponse(retdata)
|
|
50
|
+
|
|
51
|
+ backend = image_processing.get_backend()
|
|
52
|
+
|
|
53
|
+ if not getattr(settings, 'SIMDITOR_ALLOW_NONIMAGE_FILES', True):
|
|
54
|
+ try:
|
|
55
|
+ backend.image_verify(uploaded_file)
|
|
56
|
+ except utils.NotAnImageException:
|
|
57
|
+ retdata = {'file_path': '', 'success': False,
|
|
58
|
+ 'msg': '图片格式错误!'}
|
|
59
|
+ return JsonResponse(retdata)
|
|
60
|
+
|
|
61
|
+ filename = get_upload_filename(uploaded_file.name)
|
|
62
|
+ saved_path = default_storage.save(filename, uploaded_file)
|
|
63
|
+
|
|
64
|
+ url = utils.get_media_url(saved_path)
|
|
65
|
+
|
|
66
|
+ is_api = settings.SIMDITOR_CONFIGS.get('is_api', False)
|
|
67
|
+ url = request.META.get('HTTP_ORIGIN') + url if is_api else url
|
|
68
|
+
|
|
69
|
+ retdata = {'file_path': url, 'success': True, 'msg': '上传成功!'}
|
|
70
|
+
|
|
71
|
+ return JsonResponse(retdata)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+class ImageUploadView(generic.View):
|
|
75
|
+ """ImageUploadView."""
|
|
76
|
+
|
|
77
|
+ http_method_names = ['post']
|
|
78
|
+
|
|
79
|
+ def post(self, request, **kwargs):
|
|
80
|
+ """Post."""
|
|
81
|
+ return upload_handler(request)
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+UPLOAD = csrf_exempt(ImageUploadView.as_view())
|
|
|
@@ -0,0 +1,170 @@
|
|
1
|
+"""simditor widgets."""
|
|
2
|
+from __future__ import absolute_import
|
|
3
|
+
|
|
4
|
+from django import forms
|
|
5
|
+from django.conf import settings
|
|
6
|
+from django.core.exceptions import ImproperlyConfigured
|
|
7
|
+from django.core.serializers.json import DjangoJSONEncoder
|
|
8
|
+
|
|
9
|
+from django.template.loader import render_to_string
|
|
10
|
+from django.utils.encoding import force_text
|
|
11
|
+from django.utils.safestring import mark_safe
|
|
12
|
+from django.utils.html import conditional_escape
|
|
13
|
+from django.utils.functional import Promise
|
|
14
|
+
|
|
15
|
+try:
|
|
16
|
+ # Django >=2.1
|
|
17
|
+ from django.forms.widgets import get_default_renderer
|
|
18
|
+ IS_NEW_WIDGET = True
|
|
19
|
+except ImportError:
|
|
20
|
+ IS_NEW_WIDGET = False
|
|
21
|
+
|
|
22
|
+try:
|
|
23
|
+ # Django >=1.7
|
|
24
|
+ from django.forms.utils import flatatt
|
|
25
|
+except ImportError:
|
|
26
|
+ # Django <1.7
|
|
27
|
+ from django.forms.util import flatatt # pylint disable=E0611, E0401
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+class LazyEncoder(DjangoJSONEncoder):
|
|
31
|
+ """LazyEncoder."""
|
|
32
|
+
|
|
33
|
+ # pylint disable=E0202
|
|
34
|
+ def default(self, obj):
|
|
35
|
+ if isinstance(obj, Promise):
|
|
36
|
+ return force_text(obj)
|
|
37
|
+ return super(LazyEncoder, self).default(obj)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+JSON_ENCODE = LazyEncoder().encode
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+FULL_TOOLBAR = [
|
|
44
|
+ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
|
|
45
|
+ 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link',
|
|
46
|
+ 'image', 'hr', '|', 'indent', 'outdent', 'alignment', 'checklist',
|
|
47
|
+ 'markdown', 'fullscreen'
|
|
48
|
+]
|
|
49
|
+
|
|
50
|
+DEFAULT_TOOLBAR = [
|
|
51
|
+ 'title', 'bold', 'italic', 'underline', 'strikethrough', 'fontScale',
|
|
52
|
+ 'color', '|', 'ol', 'ul', 'blockquote', 'table', '|', 'link',
|
|
53
|
+ 'image', 'hr', '|', 'indent', 'outdent', 'alignment'
|
|
54
|
+]
|
|
55
|
+
|
|
56
|
+DEFAULT_CONFIG = {
|
|
57
|
+ 'toolbar': DEFAULT_TOOLBAR,
|
|
58
|
+ 'cleanPaste': True,
|
|
59
|
+ 'tabIndent': True,
|
|
60
|
+ 'pasteImage': True,
|
|
61
|
+ 'upload': {
|
|
62
|
+ 'url': '/',
|
|
63
|
+ 'fileKey': 'file'
|
|
64
|
+ }
|
|
65
|
+}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+class SimditorWidget(forms.Textarea):
|
|
69
|
+ """
|
|
70
|
+ Widget providing Simditor for Rich Text Editing.abs
|
|
71
|
+ Supports direct image uploads and embed.
|
|
72
|
+ """
|
|
73
|
+ class Media:
|
|
74
|
+ """Media."""
|
|
75
|
+
|
|
76
|
+ css_list = [
|
|
77
|
+ 'simditor/styles/simditor.min.css'
|
|
78
|
+ ]
|
|
79
|
+
|
|
80
|
+ if 'emoji' in settings.SIMDITOR_TOOLBAR:
|
|
81
|
+ css_list.append('simditor/styles/simditor-emoji.css')
|
|
82
|
+
|
|
83
|
+ if 'fullscreen' in settings.SIMDITOR_TOOLBAR:
|
|
84
|
+ css_list.append('simditor/styles/simditor-fullscreen.min.css')
|
|
85
|
+
|
|
86
|
+ if 'checklist' in settings.SIMDITOR_TOOLBAR:
|
|
87
|
+ css_list.append('simditor/styles/simditor-checklist.min.css')
|
|
88
|
+
|
|
89
|
+ if 'markdown' in settings.SIMDITOR_TOOLBAR:
|
|
90
|
+ css_list.append('simditor/styles/simditor-markdown.min.css')
|
|
91
|
+
|
|
92
|
+ css = {'all': tuple(settings.STATIC_URL + url for url in css_list)}
|
|
93
|
+
|
|
94
|
+ jquery_list = ['simditor/scripts/jquery.min.js',
|
|
95
|
+ 'simditor/scripts/module.min.js',
|
|
96
|
+ 'simditor/scripts/hotkeys.min.js',
|
|
97
|
+ 'simditor/scripts/uploader.min.js',
|
|
98
|
+ 'simditor/scripts/simditor.min.js']
|
|
99
|
+
|
|
100
|
+ if 'fullscreen' in settings.SIMDITOR_TOOLBAR:
|
|
101
|
+ jquery_list.append('simditor/scripts/simditor-fullscreen.min.js')
|
|
102
|
+
|
|
103
|
+ if 'checklist' in settings.SIMDITOR_TOOLBAR:
|
|
104
|
+ jquery_list.append('simditor/scripts/simditor-checklist.min.js')
|
|
105
|
+
|
|
106
|
+ if 'markdown' in settings.SIMDITOR_TOOLBAR:
|
|
107
|
+ jquery_list.append('simditor/scripts/marked.min.js')
|
|
108
|
+ jquery_list.append('simditor/scripts/to-markdown.min.js')
|
|
109
|
+ jquery_list.append('simditor/scripts/simditor-markdown.min.js')
|
|
110
|
+
|
|
111
|
+ if 'image' in settings.SIMDITOR_TOOLBAR:
|
|
112
|
+ jquery_list.append('simditor/scripts/simditor-dropzone.min.js')
|
|
113
|
+
|
|
114
|
+ if 'emoji' in settings.SIMDITOR_TOOLBAR:
|
|
115
|
+ jquery_list.append('simditor/scripts/simditor-emoji.js')
|
|
116
|
+
|
|
117
|
+ js = tuple(settings.STATIC_URL + url for url in jquery_list)
|
|
118
|
+
|
|
119
|
+ try:
|
|
120
|
+
|
|
121
|
+ js += (settings.STATIC_URL + 'simditor/simditor-init.js',)
|
|
122
|
+ except AttributeError:
|
|
123
|
+ raise ImproperlyConfigured("django-simditor requires \
|
|
124
|
+ SIMDITOR_MEDIA_PREFIX setting. This setting specifies a \
|
|
125
|
+ URL prefix to the ckeditor JS and CSS media (not \
|
|
126
|
+ uploaded media). Make sure to use a trailing slash: \
|
|
127
|
+ SIMDITOR_MEDIA_PREFIX = '/media/simditor/'")
|
|
128
|
+
|
|
129
|
+ def __init__(self, *args, **kwargs):
|
|
130
|
+ super(SimditorWidget, self).__init__(*args, **kwargs)
|
|
131
|
+ # Setup config from defaults.
|
|
132
|
+ self.config = DEFAULT_CONFIG.copy()
|
|
133
|
+
|
|
134
|
+ # Try to get valid config from settings.
|
|
135
|
+ configs = getattr(settings, 'SIMDITOR_CONFIGS', None)
|
|
136
|
+ if configs:
|
|
137
|
+ if isinstance(configs, dict):
|
|
138
|
+ self.config.update(configs)
|
|
139
|
+ else:
|
|
140
|
+ raise ImproperlyConfigured(
|
|
141
|
+ 'SIMDITOR_CONFIGS setting must be a dictionary type.')
|
|
142
|
+
|
|
143
|
+ def build_attrs(self, base_attrs, extra_attrs=None, **kwargs):
|
|
144
|
+ """
|
|
145
|
+ Helper function for building an attribute dictionary.
|
|
146
|
+ This is combination of the same method from Django<=1.10 and Django1.11
|
|
147
|
+ """
|
|
148
|
+ attrs = dict(base_attrs, **kwargs)
|
|
149
|
+ if extra_attrs:
|
|
150
|
+ attrs.update(extra_attrs)
|
|
151
|
+ return attrs
|
|
152
|
+
|
|
153
|
+ def render(self, name, value, attrs=None, renderer=None):
|
|
154
|
+ if value is None:
|
|
155
|
+ value = ''
|
|
156
|
+ final_attrs = self.build_attrs(self.attrs, attrs, name=name)
|
|
157
|
+
|
|
158
|
+ params = ('simditor/widget.html', {
|
|
159
|
+ 'final_attrs': flatatt(final_attrs),
|
|
160
|
+ 'value': conditional_escape(force_text(value)),
|
|
161
|
+ 'id': final_attrs['id'],
|
|
162
|
+ 'config': JSON_ENCODE(self.config)
|
|
163
|
+ })
|
|
164
|
+
|
|
165
|
+ if renderer is None and IS_NEW_WIDGET:
|
|
166
|
+ renderer = get_default_renderer()
|
|
167
|
+
|
|
168
|
+ data = renderer.render(*params) if IS_NEW_WIDGET else render_to_string(*params)
|
|
169
|
+
|
|
170
|
+ return mark_safe(data)
|