Skip to content

Commit cef2623

Browse files
author
Wes Cossick
committed
Recompile files with latest commits
1 parent 9157e86 commit cef2623

File tree

6 files changed

+224
-120
lines changed

6 files changed

+224
-120
lines changed

debug/simplemde.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ span.CodeMirror-selectedtext { background: none; }
608608
border: 1px solid #ddd;
609609
padding: 5px;
610610
}
611-
611+
612612
.CodeMirror .CodeMirror-code .cm-tag {
613613
color: #63a35c;
614614
}

debug/simplemde.debug.js

Lines changed: 89 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

debug/simplemde.js

Lines changed: 88 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
14751475
if (horiz.clientWidth) scroll(horiz.scrollLeft, "horizontal");
14761476
});
14771477

1478-
this.checkedOverlay = false;
1478+
this.checkedZeroWidth = false;
14791479
// Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
14801480
if (ie && ie_version < 8) this.horiz.style.minHeight = this.vert.style.minWidth = "18px";
14811481
}
@@ -1510,29 +1510,43 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
15101510
this.horiz.firstChild.style.width = "0";
15111511
}
15121512

1513-
if (!this.checkedOverlay && measure.clientHeight > 0) {
1514-
if (sWidth == 0) this.overlayHack();
1515-
this.checkedOverlay = true;
1513+
if (!this.checkedZeroWidth && measure.clientHeight > 0) {
1514+
if (sWidth == 0) this.zeroWidthHack();
1515+
this.checkedZeroWidth = true;
15161516
}
15171517

15181518
return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0};
15191519
},
15201520
setScrollLeft: function(pos) {
15211521
if (this.horiz.scrollLeft != pos) this.horiz.scrollLeft = pos;
1522+
if (this.disableHoriz) this.enableZeroWidthBar(this.horiz, this.disableHoriz);
15221523
},
15231524
setScrollTop: function(pos) {
15241525
if (this.vert.scrollTop != pos) this.vert.scrollTop = pos;
1526+
if (this.disableVert) this.enableZeroWidthBar(this.vert, this.disableVert);
15251527
},
1526-
overlayHack: function() {
1528+
zeroWidthHack: function() {
15271529
var w = mac && !mac_geMountainLion ? "12px" : "18px";
1528-
this.horiz.style.minHeight = this.vert.style.minWidth = w;
1529-
var self = this;
1530-
var barMouseDown = function(e) {
1531-
if (e_target(e) != self.vert && e_target(e) != self.horiz)
1532-
operation(self.cm, onMouseDown)(e);
1533-
};
1534-
on(this.vert, "mousedown", barMouseDown);
1535-
on(this.horiz, "mousedown", barMouseDown);
1530+
this.horiz.style.height = this.vert.style.width = w;
1531+
this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
1532+
this.disableHoriz = new Delayed;
1533+
this.disableVert = new Delayed;
1534+
},
1535+
enableZeroWidthBar: function(bar, delay) {
1536+
bar.style.pointerEvents = "auto";
1537+
function maybeDisable() {
1538+
// To find out whether the scrollbar is still visible, we
1539+
// check whether the element under the pixel in the bottom
1540+
// left corner of the scrollbar box is the scrollbar box
1541+
// itself (when the bar is still visible) or its filler child
1542+
// (when the bar is hidden). If it is still visible, we keep
1543+
// it enabled, if it's hidden, we disable pointer events.
1544+
var box = bar.getBoundingClientRect();
1545+
var elt = document.elementFromPoint(box.left + 1, box.bottom - 1);
1546+
if (elt != bar) bar.style.pointerEvents = "none";
1547+
else delay.set(1000, maybeDisable);
1548+
}
1549+
delay.set(1000, maybeDisable);
15361550
},
15371551
clear: function() {
15381552
var parent = this.horiz.parentNode;
@@ -4158,7 +4172,8 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
41584172

41594173
if (cm.state.focused && op.updateInput)
41604174
cm.display.input.reset(op.typing);
4161-
if (op.focus && op.focus == activeElt()) ensureFocus(op.cm);
4175+
if (op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus()))
4176+
ensureFocus(op.cm);
41624177
}
41634178

41644179
function endOperation_finish(op) {
@@ -4843,7 +4858,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
48434858

48444859
// Determines whether an event happened in the gutter, and fires the
48454860
// handlers for the corresponding event.
4846-
function gutterEvent(cm, e, type, prevent, signalfn) {
4861+
function gutterEvent(cm, e, type, prevent) {
48474862
try { var mX = e.clientX, mY = e.clientY; }
48484863
catch(e) { return false; }
48494864
if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) return false;
@@ -4860,14 +4875,14 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
48604875
if (g && g.getBoundingClientRect().right >= mX) {
48614876
var line = lineAtHeight(cm.doc, mY);
48624877
var gutter = cm.options.gutters[i];
4863-
signalfn(cm, type, cm, line, gutter, e);
4878+
signal(cm, type, cm, line, gutter, e);
48644879
return e_defaultPrevented(e);
48654880
}
48664881
}
48674882
}
48684883

48694884
function clickInGutter(cm, e) {
4870-
return gutterEvent(cm, e, "gutterClick", true, signalLater);
4885+
return gutterEvent(cm, e, "gutterClick", true);
48714886
}
48724887

48734888
// Kludge to work around strange IE behavior where it'll sometimes
@@ -5306,7 +5321,7 @@ CodeMirror.overlayMode = function(base, overlay, combine) {
53065321

53075322
function contextMenuInGutter(cm, e) {
53085323
if (!hasHandler(cm, "gutterContextMenu")) return false;
5309-
return gutterEvent(cm, e, "gutterContextMenu", false, signal);
5324+
return gutterEvent(cm, e, "gutterContextMenu", false);
53105325
}
53115326

53125327
// UPDATING
@@ -12811,7 +12826,9 @@ var shortcuts = {
1281112826

1281212827
var isMobile = function() {
1281312828
var check = false;
12814-
(function(a){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))check = true;})(navigator.userAgent||navigator.vendor||window.opera);
12829+
(function(a) {
12830+
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
12831+
})(navigator.userAgent || navigator.vendor || window.opera);
1281512832
return check;
1281612833
};
1281712834

@@ -13041,34 +13058,34 @@ function toggleOrderedList(editor) {
1304113058
_toggleLine(cm, "ordered-list");
1304213059
}
1304313060

13044-
1304513061
/**
1304613062
* Action for drawing a link.
1304713063
*/
1304813064
function drawLink(editor) {
1304913065
var cm = editor.codemirror;
1305013066
var stat = getState(cm);
13051-
_replaceSelection(cm, stat.link, "[", "](http://)");
13067+
var options = editor.options;
13068+
_replaceSelection(cm, stat.link, options.replaceTexts.link);
1305213069
}
1305313070

13054-
1305513071
/**
1305613072
* Action for drawing an img.
1305713073
*/
1305813074
function drawImage(editor) {
1305913075
var cm = editor.codemirror;
1306013076
var stat = getState(cm);
13061-
_replaceSelection(cm, stat.image, "![](http://", ")");
13077+
var options = editor.options;
13078+
_replaceSelection(cm, stat.image, options.replaceTexts.image);
1306213079
}
1306313080

13064-
1306513081
/**
1306613082
* Action for drawing a horizontal rule.
1306713083
*/
1306813084
function drawHorizontalRule(editor) {
1306913085
var cm = editor.codemirror;
1307013086
var stat = getState(cm);
13071-
_replaceSelection(cm, stat.image, "", "\n\n-----\n\n");
13087+
var options = editor.options;
13088+
_replaceSelection(cm, stat.image, options.replaceTexts.horizontalRule);
1307213089
}
1307313090

1307413091

@@ -13180,11 +13197,13 @@ function togglePreview(editor) {
1318013197
toggleSideBySide(editor);
1318113198
}
1318213199

13183-
function _replaceSelection(cm, active, start, end) {
13200+
function _replaceSelection(cm, active, startEnd) {
1318413201
if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
1318513202
return;
1318613203

1318713204
var text;
13205+
var start = startEnd[0];
13206+
var end = startEnd[1];
1318813207
var startPoint = cm.getCursor("start");
1318913208
var endPoint = cm.getCursor("end");
1319013209
if(active) {
@@ -13385,6 +13404,35 @@ function _toggleBlock(editor, type, start_chars, end_chars) {
1338513404
cm.focus();
1338613405
}
1338713406

13407+
// Merge the properties of one object into another.
13408+
function _mergeProperties(target, source) {
13409+
for(var property in source) {
13410+
if(source.hasOwnProperty(property)) {
13411+
if(source[property] instanceof Array) {
13412+
target[property] = source[property].concat(target[property] instanceof Array ? target[property] : []);
13413+
} else if(
13414+
source[property] !== null &&
13415+
typeof source[property] === "object" &&
13416+
source[property].constructor === Object
13417+
) {
13418+
target[property] = _mergeProperties(target[property] || {}, source[property]);
13419+
} else {
13420+
target[property] = source[property];
13421+
}
13422+
}
13423+
}
13424+
13425+
return target;
13426+
}
13427+
13428+
// Merge an arbitrary number of objects into one.
13429+
function extend(target) {
13430+
for(var i = 1; i < arguments.length; i++) {
13431+
target = _mergeProperties(target, arguments[i]);
13432+
}
13433+
13434+
return target;
13435+
}
1338813436

1338913437
/* The right word count in respect for CJK. */
1339013438
function wordCount(data) {
@@ -13526,6 +13574,12 @@ var toolbarBuiltInButtons = {
1352613574
}
1352713575
};
1352813576

13577+
var replaceTexts = {
13578+
link: ["[", "](http://)"],
13579+
image: ["![](http://", ")"],
13580+
horizontalRule: ["", "\n\n-----\n\n"]
13581+
};
13582+
1352913583

1353013584
/**
1353113585
* Interface of SimpleMDE.
@@ -13598,6 +13652,10 @@ function SimpleMDE(options) {
1359813652
options.parsingConfig = options.parsingConfig || {};
1359913653

1360013654

13655+
// Merging the replaceTexts, with the given options
13656+
options.replaceTexts = extend({}, replaceTexts, options.replaceTexts || {});
13657+
13658+
1360113659
// Update this options
1360213660
this.options = options;
1360313661

@@ -13848,7 +13906,7 @@ SimpleMDE.prototype.createToolbar = function(items) {
1384813906

1384913907
if(self.options.hideIcons && self.options.hideIcons.indexOf(items[i].name) != -1)
1385013908
continue;
13851-
13909+
1385213910
// Fullscreen does not work well on mobile devices (even tablets)
1385313911
// In the future, hopefully this can be resolved
1385413912
if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
@@ -14050,21 +14108,21 @@ SimpleMDE.prototype.isPreviewActive = function() {
1405014108
var cm = this.codemirror;
1405114109
var wrapper = cm.getWrapperElement();
1405214110
var preview = wrapper.lastChild;
14053-
14111+
1405414112
return /editor-preview-active/.test(preview.className);
1405514113
};
1405614114

1405714115
SimpleMDE.prototype.isSideBySideActive = function() {
1405814116
var cm = this.codemirror;
1405914117
var wrapper = cm.getWrapperElement();
1406014118
var preview = wrapper.nextSibling;
14061-
14119+
1406214120
return /editor-preview-active-side/.test(preview.className);
1406314121
};
1406414122

1406514123
SimpleMDE.prototype.isFullscreenActive = function() {
1406614124
var cm = this.codemirror;
14067-
14125+
1406814126
return cm.getOption("fullScreen");
1406914127
};
1407014128

dist/simplemde.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/css/simplemde.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(125, 185, 232, 0.01) 100%);
9393
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(125, 185, 232, 0.01) 100%);
9494
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(125, 185, 232, 0.01) 100%);
95-
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#037db9e8', GradientType=1);
95+
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#037db9e8', GradientType=1);
9696
position: fixed;
9797
top: 0;
9898
left: 0;
@@ -109,7 +109,7 @@
109109
background: -o-linear-gradient(left, rgba(125, 185, 232, 0.01) 0%, rgba(254, 254, 255, 1) 99%, rgba(255, 255, 255, 1) 100%);
110110
background: -ms-linear-gradient(left, rgba(125, 185, 232, 0.01) 0%, rgba(254, 254, 255, 1) 99%, rgba(255, 255, 255, 1) 100%);
111111
background: linear-gradient(to right, rgba(125, 185, 232, 0.01) 0%, rgba(254, 254, 255, 1) 99%, rgba(255, 255, 255, 1) 100%);
112-
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#037db9e8', endColorstr='#ffffff', GradientType=1);
112+
filter: progid: DXImageTransform.Microsoft.gradient( startColorstr='#037db9e8', endColorstr='#ffffff', GradientType=1);
113113
position: fixed;
114114
top: 0;
115115
right: 0;
@@ -267,7 +267,7 @@
267267
border: 1px solid #ddd;
268268
padding: 5px;
269269
}
270-
270+
271271
.CodeMirror .CodeMirror-code .cm-tag {
272272
color: #63a35c;
273273
}
@@ -319,4 +319,4 @@
319319

320320
.CodeMirror .CodeMirror-code .cm-strikethrough {
321321
text-decoration: line-through;
322-
}
322+
}

0 commit comments

Comments
 (0)