summaryrefslogtreecommitdiff
path: root/common/content/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'common/content/editor.js')
-rw-r--r--common/content/editor.js34
1 files changed, 5 insertions, 29 deletions
diff --git a/common/content/editor.js b/common/content/editor.js
index e5513222..2de8cd33 100644
--- a/common/content/editor.js
+++ b/common/content/editor.js
@@ -68,37 +68,13 @@ var Editor = Module("editor", {
this.editor.setShouldTxnSetSelection(!val);
},
- pasteClipboard: function (clipboard, toStart) {
+ pasteClipboard: function pasteClipboard(clipboard) {
let elem = this.element;
- if (elem.setSelectionRange) {
- let text = dactyl.clipboardRead(clipboard);
- if (!text)
- return;
- if (isinstance(elem, [HTMLInputElement, XULTextBoxElement]))
- text = text.replace(/\n+/g, "");
-
- // This is a hacky fix - but it works.
- // <s-insert> in the bottom of a long textarea bounces up
- let top = elem.scrollTop;
- let left = elem.scrollLeft;
-
- let start = elem.selectionStart; // caret position
- let end = elem.selectionEnd;
- let value = elem.value.substring(0, start) + text + elem.value.substring(end);
- elem.value = value;
-
- if (/^(search|text)$/.test(elem.type))
- DOM(elem).editor.rootElement.firstChild.textContent = value;
+ let text = dactyl.clipboardRead(clipboard);
+ dactyl.assert(text && this.editor instanceof Ci.nsIPlaintextEditor);
- elem.selectionStart = Math.min(start + (toStart ? 0 : text.length), elem.value.length);
- elem.selectionEnd = elem.selectionStart;
-
- elem.scrollTop = top;
- elem.scrollLeft = left;
-
- DOM(elem).input();
- }
+ this.editor.insertText(text);
},
// count is optional, defaults to 1
@@ -138,7 +114,6 @@ var Editor = Module("editor", {
this.selection[select ? "extend" : "collapse"](node, pos);
},
-
mungeRange: function mungeRange(range, munger, selectEnd) {
let { editor } = this;
editor.beginPlaceHolderTransaction(null);
@@ -187,6 +162,7 @@ var Editor = Module("editor", {
},
findChar: function (key, count, backward) {
+ // TODO: Use extendRange, return range.
util.assert(DOM(this.element).isInput);