From 051128c16ff939d329eb0aa4ba9d9d511211b1b7 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Tue, 11 Mar 2014 18:30:20 +0400
Subject: [PATCH 1/8] restore ie8 compatibility
---
doc/site/js/main.js | 7 ++++++-
index.html | 11 +++++++----
lib/ace/ext/old_ie.js | 6 ++++++
lib/ace/ext/themelist.js | 1 +
lib/ace/layer/font_metrics.js | 21 ++++++++++++++-------
5 files changed, 34 insertions(+), 12 deletions(-)
diff --git a/doc/site/js/main.js b/doc/site/js/main.js
index 78595c6a..e6cd609c 100644
--- a/doc/site/js/main.js
+++ b/doc/site/js/main.js
@@ -161,7 +161,12 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
- return [].slice.call(document.querySelectorAll(sel));
+ var items = document.querySelectorAll(sel);
+ var result = [];
+ for (var i = 0; i < items.length; i++) {
+ result.push(items[i]);
+ }
+ return result;
}
qsa("code[class]").forEach(function(el) {
diff --git a/index.html b/index.html
index 8d65f8ea..9c416582 100644
--- a/index.html
+++ b/index.html
@@ -11,6 +11,9 @@
+
@@ -65,7 +68,7 @@
and is the successor of the Mozilla Skywriter (Bespin) project.
- /**
+
/**
* In fact, you're looking at ACE right now. Go ahead and play with it!
*
* We are currently showing off the JavaScript mode. ACE has support for 45
@@ -80,7 +83,7 @@ function add(x, y) {
var addResult = add(3, 2);
console.log(addResult);
-
+
Learn how to embed this in your own site
Looking for a more full-featured demo? Check out the
kitchen sink .
@@ -140,7 +143,7 @@ console.log(addResult);
Embedding Ace in Your Site
Ace can be easily embedded into a web page. Get prebuilt version of ace from
ace-builds repository and use the code below:
- <!DOCTYPE html>
+
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
@@ -168,7 +171,7 @@ console.log(addResult);
editor.getSession().setMode("ace/mode/javascript");
</script>
</body>
-</html>
+</html>
Now check out the How-To Guide for instructions on
common operations, such as setting a different language mode or
getting the contents from the editor.
diff --git a/lib/ace/ext/old_ie.js b/lib/ace/ext/old_ie.js
index ca67888f..ce3f4e72 100644
--- a/lib/ace/ext/old_ie.js
+++ b/lib/ace/ext/old_ie.js
@@ -103,6 +103,12 @@ patch(
}"
);
+patch(
+ require("ace/mode/text").Mode.prototype, "getTokenizer",
+ /Tokenizer/,
+ "TokenizerModule.Tokenizer"
+);
+
useragent.isOldIE = true;
});
diff --git a/lib/ace/ext/themelist.js b/lib/ace/ext/themelist.js
index 9eb4b71e..8914c776 100644
--- a/lib/ace/ext/themelist.js
+++ b/lib/ace/ext/themelist.js
@@ -41,6 +41,7 @@
define(function(require, exports, module) {
"use strict";
+require("ace/lib/fixoldbrowsers");
var themeData = [
["Chrome" ],
diff --git a/lib/ace/layer/font_metrics.js b/lib/ace/layer/font_metrics.js
index 45fa44cb..a65e100d 100644
--- a/lib/ace/layer/font_metrics.js
+++ b/lib/ace/layer/font_metrics.js
@@ -54,7 +54,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
if (!CHAR_COUNT)
this.$testFractionalRect();
- this.$measureNode.textContent = lang.stringRepeat("X", CHAR_COUNT);
+ this.$measureNode.innerHTML = lang.stringRepeat("X", CHAR_COUNT);
this.$characterSize = {width: 0, height: 0};
this.checkForSizeChanges();
@@ -121,11 +121,18 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
};
this.$measureSizes = function() {
- var rect = this.$measureNode.getBoundingClientRect();
- var size = {
- height: rect.height,
- width: rect.width / CHAR_COUNT
- };
+ if (CHAR_COUNT === 1) {
+ var rect = this.$measureNode.getBoundingClientRect();
+ var size = {
+ height: rect.height,
+ width: rect.width
+ };
+ } else {
+ var size = {
+ height: this.$measureNode.clientHeight,
+ width: this.$measureNode.clientWidth / CHAR_COUNT
+ };
+ }
// Size and width can be null if the editor is not visible or
// detached from the document
if (size.width === 0 || size.height === 0)
@@ -134,7 +141,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) {
};
this.$measureCharWidth = function(ch) {
- this.$main.textContent = lang.stringRepeat(ch, CHAR_COUNT);
+ this.$main.innerHTML = lang.stringRepeat(ch, CHAR_COUNT);
var rect = this.$main.getBoundingClientRect();
return rect.width / CHAR_COUNT;
};
From 09d6741a024603ebae5bd098b3bc747ba6511713 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Wed, 12 Mar 2014 02:42:47 +0400
Subject: [PATCH 2/8] fix clipboard on old webkit versions
---
lib/ace/keyboard/textinput.js | 92 ++++++++++++++---------------------
lib/ace/lib/useragent.js | 5 +-
2 files changed, 39 insertions(+), 58 deletions(-)
diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js
index eb27026a..7cba4077 100644
--- a/lib/ace/keyboard/textinput.js
+++ b/lib/ace/keyboard/textinput.js
@@ -36,6 +36,7 @@ var useragent = require("../lib/useragent");
var dom = require("../lib/dom");
var lang = require("../lib/lang");
var BROKEN_SETDATA = useragent.isChrome < 18;
+var USE_IE_MIME_TIPE = useragent.isIE;
var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
@@ -54,7 +55,6 @@ var TextInput = function(parentNode, host) {
var PLACEHOLDER = "\x01\x01";
- var cut = false;
var copied = false;
var pasted = false;
var inComposition = false;
@@ -186,9 +186,7 @@ var TextInput = function(parentNode, host) {
}
var onSelect = function(e) {
- if (cut) {
- cut = false;
- } else if (copied) {
+ if (copied) {
copied = false;
} else if (isAllSelected(text)) {
host.selectAll();
@@ -243,55 +241,31 @@ var TextInput = function(parentNode, host) {
sendText(data);
resetValue();
};
-
- var onCut = function(e) {
- var data = host.getCopyText();
- if (!data) {
- event.preventDefault(e);
- return;
- }
-
+
+ var handleClipboardData = function(e, data) {
var clipboardData = e.clipboardData || window.clipboardData;
-
- if (clipboardData && !BROKEN_SETDATA) {
- // Safari 5 has clipboardData object, but does not handle setData()
- var supported = clipboardData.setData("Text", data);
- if (supported) {
- host.onCut();
- event.preventDefault(e);
- }
- }
-
- if (!supported) {
- cut = true;
- text.value = data;
- text.select();
- setTimeout(function(){
- cut = false;
- resetValue();
- resetSelection();
- host.onCut();
- });
- }
- };
-
- var onCopy = function(e) {
- var data = host.getCopyText();
- if (!data) {
- event.preventDefault(e);
+ if (!clipboardData || BROKEN_SETDATA)
return;
- }
-
- var clipboardData = e.clipboardData || window.clipboardData;
- if (clipboardData && !BROKEN_SETDATA) {
+ // using "Text" doesn't work on old webkit but ie needs it
+ // TODO are there other browsers that require "Text"?
+ var mime = USE_IE_MIME_TIPE ? "Text" : "text/plain";
+ if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
- var supported = clipboardData.setData("Text", data);
- if (supported) {
- host.onCopy();
- event.preventDefault(e);
- }
+ return clipboardData.setData(mime, data);
+ } else {
+ return clipboardData.getData(mime);
}
- if (!supported) {
+ }
+
+ var doCopy = function(e, isCut) {
+ var data = host.getCopyText();
+ if (!data)
+ return event.preventDefault(e);
+
+ if (handleClipboardData(e, data)) {
+ isCut ? host.onCut() : host.onCopy();
+ event.preventDefault(e);
+ } else {
copied = true;
text.value = data;
text.select();
@@ -299,16 +273,22 @@ var TextInput = function(parentNode, host) {
copied = false;
resetValue();
resetSelection();
- host.onCopy();
+ isCut ? host.onCut() : host.onCopy();
});
}
};
-
+
+ var onCut = function(e) {
+ doCopy(e, true);
+ }
+
+ var onCopy = function(e) {
+ doCopy(e, false);
+ }
+
var onPaste = function(e) {
- var clipboardData = e.clipboardData || window.clipboardData;
-
- if (clipboardData) {
- var data = clipboardData.getData("Text");
+ var data = handleClipboardData(e);
+ if (typeof data == "string") {
if (data)
host.onPaste(data);
if (useragent.isIE)
@@ -336,7 +316,7 @@ var TextInput = function(parentNode, host) {
if (!('oncut' in text) || !('oncopy' in text) || !('onpaste' in text)){
event.addListener(parentNode, "keydown", function(e) {
if ((useragent.isMac && !e.metaKey) || !e.ctrlKey)
- return;
+ return;
switch (e.keyCode) {
case 67:
diff --git a/lib/ace/lib/useragent.js b/lib/ace/lib/useragent.js
index 908a2a4c..e56e89a9 100644
--- a/lib/ace/lib/useragent.js
+++ b/lib/ace/lib/useragent.js
@@ -76,7 +76,8 @@ exports.isLinux = (os == "linux");
// Windows Store JavaScript apps (aka Metro apps written in HTML5 and JavaScript) do not use the "Microsoft Internet Explorer" string in their user agent, but "MSAppHost" instead.
exports.isIE =
(navigator.appName == "Microsoft Internet Explorer" || navigator.appName.indexOf("MSAppHost") >= 0)
- && parseFloat(navigator.userAgent.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:|MSIE )([0-9]+[\.0-9]+)/)[1]);
+ ? parseFloat((ua.match(/(?:MSIE |Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1])
+ : parseFloat((ua.match(/(?:Trident\/[0-9]+[\.0-9]+;.*rv:)([0-9]+[\.0-9]+)/)||[])[1]); // for ie
exports.isOldIE = exports.isIE && exports.isIE < 9;
@@ -84,7 +85,7 @@ exports.isOldIE = exports.isIE && exports.isIE < 9;
exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
// oldGecko == rev < 2.0
-exports.isOldGecko = exports.isGecko && parseInt((navigator.userAgent.match(/rv\:(\d+)/)||[])[1], 10) < 4;
+exports.isOldGecko = exports.isGecko && parseInt((ua.match(/rv\:(\d+)/)||[])[1], 10) < 4;
// Is this Opera
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
From 6e14e92912d03d4ab6dfdfc7af9204644581dbb1 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Wed, 12 Mar 2014 03:24:14 +0400
Subject: [PATCH 3/8] fix #1751 sticky selection on in IE11
---
lib/ace/lib/event.js | 9 ++++++---
lib/ace/mouse/mouse_handler.js | 6 +++---
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/lib/ace/lib/event.js b/lib/ace/lib/event.js
index 9ad0c3ac..e904e024 100644
--- a/lib/ace/lib/event.js
+++ b/lib/ace/lib/event.js
@@ -161,7 +161,7 @@ exports.addMouseWheelListener = function(el, callback) {
exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbackName) {
var clicks = 0;
- var startX, startY, timer;
+ var startX, startY, timer;
var eventNames = {
2: "dblclick",
3: "tripleclick",
@@ -180,9 +180,12 @@ exports.addMultiMouseDownListener = function(el, timeouts, eventHandler, callbac
}
if (useragent.isIE) {
var isNewClick = Math.abs(e.clientX - startX) > 5 || Math.abs(e.clientY - startY) > 5;
- if (isNewClick) {
+ if (!timer || isNewClick)
clicks = 1;
- }
+ if (timer)
+ clearTimeout(timer)
+ timer = setTimeout(function() {timer = null}, timeouts[clicks - 1] || 600);
+
if (clicks == 1) {
startX = e.clientX;
startY = e.clientY;
diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js
index 47457f17..cac4ce42 100644
--- a/lib/ace/mouse/mouse_handler.js
+++ b/lib/ace/mouse/mouse_handler.js
@@ -49,10 +49,10 @@ var MouseHandler = function(editor) {
var mouseTarget = editor.renderer.getMouseEventTarget();
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
- event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent");
+ event.addMultiMouseDownListener(mouseTarget, [400, 300, 250], this, "onMouseEvent");
if (editor.renderer.scrollBarV) {
- event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [300, 300, 250], this, "onMouseEvent");
- event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [300, 300, 250], this, "onMouseEvent");
+ event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [400, 300, 250], this, "onMouseEvent");
+ event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [400, 300, 250], this, "onMouseEvent");
}
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
From c72617b03361d1a2c53a7f99c2609665ae5364ee Mon Sep 17 00:00:00 2001
From: nightwing
Date: Wed, 12 Mar 2014 03:34:52 +0400
Subject: [PATCH 4/8] fix sticky selection if editor loaded into iframe
---
lib/ace/mouse/mouse_handler.js | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js
index cac4ce42..04e694e4 100644
--- a/lib/ace/mouse/mouse_handler.js
+++ b/lib/ace/mouse/mouse_handler.js
@@ -112,6 +112,12 @@ var MouseHandler = function(editor) {
var self = this;
var onMouseMove = function(e) {
+ if (!e) return;
+ // if editor is loaded inside iframe, and mouseup event is outside
+ // we won't recieve it, so we cancel on first mousemove without button
+ if (useragent.isWebKit && !e.which && self.releaseMouse)
+ return self.releaseMouse();
+
self.x = e.clientX;
self.y = e.clientY;
mouseMoveHandler && mouseMoveHandler(e);
@@ -130,7 +136,7 @@ var MouseHandler = function(editor) {
}
self.isMousePressed = false;
self.$onCaptureMouseMove = self.releaseMouse = null;
- self.onMouseEvent("mouseup", e);
+ e && self.onMouseEvent("mouseup", e);
};
var onCaptureInterval = function() {
From 56895731705d46e91e926bc75defbc842315ac9e Mon Sep 17 00:00:00 2001
From: nightwing
Date: Wed, 12 Mar 2014 03:41:04 +0400
Subject: [PATCH 5/8] fix tests
---
lib/ace/ext/old_ie.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/ace/ext/old_ie.js b/lib/ace/ext/old_ie.js
index ce3f4e72..8b8ce977 100644
--- a/lib/ace/ext/old_ie.js
+++ b/lib/ace/ext/old_ie.js
@@ -104,7 +104,7 @@ patch(
);
patch(
- require("ace/mode/text").Mode.prototype, "getTokenizer",
+ require("../mode/text").Mode.prototype, "getTokenizer",
/Tokenizer/,
"TokenizerModule.Tokenizer"
);
From 498af4aab8293b4029a97af5fbbf71b326554188 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Wed, 12 Mar 2014 12:48:00 +0400
Subject: [PATCH 6/8] better fix for Array.slice on ie8
---
doc/site/js/main.js | 7 +------
index.html | 6 +++---
2 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/doc/site/js/main.js b/doc/site/js/main.js
index e6cd609c..b24383c0 100644
--- a/doc/site/js/main.js
+++ b/doc/site/js/main.js
@@ -161,12 +161,7 @@ function highlight() {
var highlighter = ace.require("ace/ext/static_highlight")
var dom = ace.require("ace/lib/dom")
function qsa(sel) {
- var items = document.querySelectorAll(sel);
- var result = [];
- for (var i = 0; i < items.length; i++) {
- result.push(items[i]);
- }
- return result;
+ return Array.apply(null, document.querySelectorAll(sel));
}
qsa("code[class]").forEach(function(el) {
diff --git a/index.html b/index.html
index 9c416582..46c41ce8 100644
--- a/index.html
+++ b/index.html
@@ -9,10 +9,10 @@
-
-
+
+
From 8cdb16659d9f0cd30fd95346cd70d2c73064bd06 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Thu, 13 Mar 2014 19:42:05 +0400
Subject: [PATCH 7/8] fix #1843 Double click to select word does not work for
Qt QWebView
---
lib/ace/mouse/default_handlers.js | 1 +
lib/ace/mouse/mouse_handler.js | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/ace/mouse/default_handlers.js b/lib/ace/mouse/default_handlers.js
index 6e97bc5d..8a9adcf7 100644
--- a/lib/ace/mouse/default_handlers.js
+++ b/lib/ace/mouse/default_handlers.js
@@ -181,6 +181,7 @@ function DefaultHandlers(mouseHandler) {
this.selectAllEnd =
this.selectByWordsEnd =
this.selectByLinesEnd = function() {
+ this.$clickSelection = null;
this.editor.unsetStyle("ace_selecting");
if (this.editor.renderer.scroller.releaseCapture) {
this.editor.renderer.scroller.releaseCapture();
diff --git a/lib/ace/mouse/mouse_handler.js b/lib/ace/mouse/mouse_handler.js
index 04e694e4..55b72389 100644
--- a/lib/ace/mouse/mouse_handler.js
+++ b/lib/ace/mouse/mouse_handler.js
@@ -129,7 +129,7 @@ var MouseHandler = function(editor) {
clearInterval(timerId);
onCaptureInterval();
self[self.state + "End"] && self[self.state + "End"](e);
- self.$clickSelection = null;
+ self.state = "";
if (renderer.$keepTextAreaAtCursor == null) {
renderer.$keepTextAreaAtCursor = true;
renderer.$moveTextAreaToCursor();
From 362a69228bfa89ff2caa3dfd655600d6dafb6837 Mon Sep 17 00:00:00 2001
From: nightwing
Date: Sun, 23 Mar 2014 18:56:39 +0400
Subject: [PATCH 8/8] fix typo
---
lib/ace/keyboard/textinput.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js
index 7cba4077..5c75b6e9 100644
--- a/lib/ace/keyboard/textinput.js
+++ b/lib/ace/keyboard/textinput.js
@@ -36,7 +36,7 @@ var useragent = require("../lib/useragent");
var dom = require("../lib/dom");
var lang = require("../lib/lang");
var BROKEN_SETDATA = useragent.isChrome < 18;
-var USE_IE_MIME_TIPE = useragent.isIE;
+var USE_IE_MIME_TYPE = useragent.isIE;
var TextInput = function(parentNode, host) {
var text = dom.createElement("textarea");
@@ -248,7 +248,7 @@ var TextInput = function(parentNode, host) {
return;
// using "Text" doesn't work on old webkit but ie needs it
// TODO are there other browsers that require "Text"?
- var mime = USE_IE_MIME_TIPE ? "Text" : "text/plain";
+ var mime = USE_IE_MIME_TYPE ? "Text" : "text/plain";
if (data) {
// Safari 5 has clipboardData object, but does not handle setData()
return clipboardData.setData(mime, data);