From 83c37fd41e93c1359917429e63741a2a1f32e67d Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 13 Jan 2013 20:48:43 +0400 Subject: [PATCH 1/5] #1202 scrollbar size is wrong when too broad selector is used --- lib/ace/lib/dom.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ace/lib/dom.js b/lib/ace/lib/dom.js index 04f8bf5f..34549916 100644 --- a/lib/ace/lib/dom.js +++ b/lib/ace/lib/dom.js @@ -210,13 +210,13 @@ else }; exports.scrollbarWidth = function(document) { - - var inner = exports.createElement("p"); + var inner = exports.createElement("ace_inner"); inner.style.width = "100%"; inner.style.minWidth = "0px"; inner.style.height = "200px"; + inner.style.display = "block"; - var outer = exports.createElement("div"); + var outer = exports.createElement("ace_outer"); var style = outer.style; style.position = "absolute"; @@ -225,10 +225,11 @@ exports.scrollbarWidth = function(document) { style.width = "200px"; style.minWidth = "0px"; style.height = "150px"; + style.display = "block"; outer.appendChild(inner); - var body = document.body || document.documentElement; + var body = document.documentElement; body.appendChild(outer); var noScrollbar = inner.offsetWidth; From 8551e0e043a3938c1ebba85c1dbcfdcbc5ce359e Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 25 Jan 2013 17:49:42 +0400 Subject: [PATCH 2/5] do not use id of placeholder text mode --- lib/ace/edit_session.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 21f9ec20..9ac41352 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -949,7 +949,6 @@ var EditSession = function(text, mode) { this.$onChangeMode = function(mode, $isPlaceholder) { if (this.$mode === mode) return; this.$mode = mode; - this.$modeId = mode.$id; this.$stopWorker(); @@ -980,6 +979,7 @@ var EditSession = function(text, mode) { if (!$isPlaceholder) { + this.$modeId = mode.$id; this.$setFolding(mode.foldingRules); this._emit("changeMode"); this.bgTokenizer.start(0); From 59de8b0ff4ea4f5545a025673f05df95cd221c16 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 25 Jan 2013 17:52:23 +0400 Subject: [PATCH 3/5] fix loading editor in iframe on ie9 --- lib/ace/keyboard/textinput.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 183260c9..3ad20179 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -63,7 +63,9 @@ var TextInput = function(parentNode, host) { var isSelectionEmpty = true; // FOCUS - var isFocused = document.activeElement === text; + // ie9 throws error if document.activeElement is accessed too soon + try { var isFocused = document.activeElement === text; } catch(e) {} + event.addListener(text, "blur", function() { host.onBlur(); isFocused = false; From 5c5e596435cb8104670356696a4ac91f372cb1ac Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 25 Jan 2013 18:30:45 +0400 Subject: [PATCH 4/5] fix #1209 Ctrl+C & Ctrl+X not working in Chrome-15 --- lib/ace/keyboard/textinput.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 3ad20179..6264eacb 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -35,6 +35,7 @@ var event = require("../lib/event"); var useragent = require("../lib/useragent"); var dom = require("../lib/dom"); var lang = require("../lib/lang"); +var BROKEN_SETDATA = useragent.isChrome < 18; var TextInput = function(parentNode, host) { var text = dom.createElement("textarea"); @@ -232,7 +233,7 @@ var TextInput = function(parentNode, host) { var clipboardData = e.clipboardData || window.clipboardData; - if (clipboardData) { + if (clipboardData && !BROKEN_SETDATA) { // Safari 5 has clipboardData object, but does not handle setData() var supported = clipboardData.setData("Text", data); if (supported) { @@ -262,7 +263,7 @@ var TextInput = function(parentNode, host) { } var clipboardData = e.clipboardData || window.clipboardData; - if (clipboardData) { + if (clipboardData && !BROKEN_SETDATA) { // Safari 5 has clipboardData object, but does not handle setData() var supported = clipboardData.setData("Text", data); if (supported) { From d437b63d194190a53ea7a1a77269dbb9618f3566 Mon Sep 17 00:00:00 2001 From: nightwing Date: Fri, 25 Jan 2013 18:39:18 +0400 Subject: [PATCH 5/5] position textarea with bottom/right since otherwise firefox 21+ scrolls editor out of view when textarea.focus is called --- lib/ace/css/editor.css | 8 +++++--- lib/ace/keyboard/textinput.js | 8 +++----- lib/ace/virtual_renderer.js | 19 ++++++++++--------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lib/ace/css/editor.css b/lib/ace/css/editor.css index c1dd818a..4b6c8e42 100644 --- a/lib/ace/css/editor.css +++ b/lib/ace/css/editor.css @@ -98,15 +98,17 @@ resize: none; outline: none; overflow: hidden; + font: inherit; } .ace_text-input.ace_composition { - background: #fff; - color: #000; + background: #f8f8f8; + color: #111; z-index: 1000; opacity: 1; border: solid lightgray 1px; - margin: -1px + margin: -1px; + padding: 0 1px; } .ace_layer { diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index 6264eacb..cda58170 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -51,7 +51,7 @@ var TextInput = function(parentNode, host) { text.autocapitalize = "off"; text.spellcheck = false; - text.style.top = "-2em"; + text.style.bottom = "-2em"; parentNode.insertBefore(text, parentNode.firstChild); var PLACEHOLDER = "\x01\x01"; @@ -350,12 +350,10 @@ var TextInput = function(parentNode, host) { host.onCompositionEnd(); }; + var syncComposition = lang.delayedCall(onCompositionUpdate, 50); event.addListener(text, "compositionstart", onCompositionStart); - if (useragent.isGecko) - event.addListener(text, "text", onCompositionUpdate); - else - event.addListener(text, "keyup", onCompositionUpdate); + event.addListener(text, useragent.isGecko ? "text" : "keyup", function(){syncComposition.schedule()}); event.addListener(text, "compositionend", onCompositionEnd); this.getElement = function() { diff --git a/lib/ace/virtual_renderer.js b/lib/ace/virtual_renderer.js index 75860d92..6192b133 100644 --- a/lib/ace/virtual_renderer.js +++ b/lib/ace/virtual_renderer.js @@ -566,28 +566,29 @@ var VirtualRenderer = function(container, theme) { this.$moveTextAreaToCursor = function() { if (!this.$keepTextAreaAtCursor) return; - + var config = this.layerConfig; var posTop = this.$cursorLayer.$pixelPos.top; var posLeft = this.$cursorLayer.$pixelPos.left; - posTop -= this.layerConfig.offset; + posTop -= config.offset; - if (posTop < 0 || posTop > this.layerConfig.height - this.lineHeight) + if (posTop < 0 || posTop > config.height - this.lineHeight) return; var w = this.characterWidth; - if (this.$composition) - w += this.textarea.scrollWidth; + if (this.$composition) { + var val = this.textarea.value.replace(/^\x01+/, ""); + w *= this.session.$getStringScreenWidth(val)[0]; + } posLeft -= this.scrollLeft; if (posLeft > this.$size.scrollerWidth - w) posLeft = this.$size.scrollerWidth - w; - if (this.showGutter) - posLeft += this.$gutterLayer.gutterWidth; + posLeft -= this.scrollBar.width; this.textarea.style.height = this.lineHeight + "px"; this.textarea.style.width = w + "px"; - this.textarea.style.left = posLeft + "px"; - this.textarea.style.top = posTop - 1 + "px"; + this.textarea.style.right = this.$size.scrollerWidth - posLeft - w + "px"; + this.textarea.style.bottom = this.$size.height - posTop - this.lineHeight + "px"; }; /**