Skip to content

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Jul 25, 2018
1 parent c191b9d commit fc7f8b1
Show file tree
Hide file tree
Showing 10 changed files with 308 additions and 187 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -23,3 +23,4 @@ jam/
.git-ref
npm-debug.log
deps/
dist
7 changes: 6 additions & 1 deletion demo/kitchen-sink/demo.js
Expand Up @@ -424,11 +424,17 @@ optionsPanel.add({
events.forEach(function(name) {
text.addEventListener(name, addToLog, true);
});
function onMousedown(ev) {
if (ev.domEvent.target == text)
ev.$pos = editor.getCursorPosition();
}
text.detach = function() {
events.forEach(function(name) {
text.removeEventListener(name, addToLog, true);
});
editor.off("mousedown", onMousedown);
};
editor.on("mousedown", onMousedown);

var log = sp.$editors[1];
if (!this.session)
Expand Down Expand Up @@ -540,7 +546,6 @@ optionsPanelContainer.insertBefore(
require("ace/ext/language_tools");
env.editor.setOptions({
enableBasicAutocompletion: true,
enableLiveAutocompletion: false,
enableSnippets: true
});

Expand Down
4 changes: 3 additions & 1 deletion demo/kitchen-sink/styles.css
Expand Up @@ -57,10 +57,12 @@ body {
}*/
.text-input-debug {
height: 100px!important;
position: absolute;
position: absolute!important;
transform: none!important;
top: 0px!important;
left: 7px!important;
width: 260px!important;
z-index: 1000!important;
opacity: 1!important;
font-size: 1em!important;
}
67 changes: 38 additions & 29 deletions lib/ace/css/editor.css
@@ -1,3 +1,31 @@
/*
styles = []
for (var i = 1; i < 16; i++) {
styles.push(".ace_br" + i + "{" + (
["top-left", "top-right", "bottom-right", "bottom-left"]
).map(function(x, j) {
return i & (1<<j) ? "border-" + x + "-radius: 3px;" : ""
}).filter(Boolean).join(" ") + "}")
}
styles.join("\n")
*/
.ace_br1 {border-top-left-radius : 3px;}
.ace_br2 {border-top-right-radius : 3px;}
.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}
.ace_br4 {border-bottom-right-radius: 3px;}
.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}
.ace_br8 {border-bottom-left-radius : 3px;}
.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}


.ace_editor {
position: relative;
overflow: hidden;
Expand Down Expand Up @@ -148,7 +176,7 @@
font: inherit;
padding: 0 1px;
margin: 0 -1px;
text-indent: -1em;
contain: strict;
-ms-user-select: text;
-moz-user-select: text;
-webkit-user-select: text;
Expand All @@ -157,12 +185,19 @@
white-space: pre!important;
}
.ace_text-input.ace_composition {
background: inherit;
background: transparent;
color: inherit;
z-index: 1000;
opacity: 1;
text-indent: 0;
}
.ace_composition_placeholder { color: transparent }
.ace_composition_marker {
border-bottom: 1px solid;
position: absolute;
border-radius: 0;
margin-top: 1px;
}

[ace_nocontext=true] {
transform: none!important;
filter: none!important;
Expand Down Expand Up @@ -494,32 +529,6 @@
z-index: 8;
}

/*
styles = []
for (var i = 1; i < 16; i++) {
styles.push(".ace_br" + i + "{" + (
["top-left", "top-right", "bottom-right", "bottom-left"]
).map(function(x, j) {
return i & (1<<j) ? "border-" + x + "-radius: 3px;" : ""
}).filter(Boolean).join(" ") + "}")
}
styles.join("\n")
*/
.ace_br1 {border-top-left-radius : 3px;}
.ace_br2 {border-top-right-radius : 3px;}
.ace_br3 {border-top-left-radius : 3px; border-top-right-radius: 3px;}
.ace_br4 {border-bottom-right-radius: 3px;}
.ace_br5 {border-top-left-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br6 {border-top-right-radius : 3px; border-bottom-right-radius: 3px;}
.ace_br7 {border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px;}
.ace_br8 {border-bottom-left-radius : 3px;}
.ace_br9 {border-top-left-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br10{border-top-right-radius : 3px; border-bottom-left-radius: 3px;}
.ace_br11{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br12{border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br13{border-top-left-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br14{border-top-right-radius : 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}
.ace_br15{border-top-left-radius : 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;}

.ace_text-input-ios {
position: absolute !important;
Expand Down
49 changes: 39 additions & 10 deletions lib/ace/editor.js
Expand Up @@ -145,21 +145,21 @@ Editor.$uid = 0;

this.curOp = null;
this.prevOp = {};
this.startOperation = function(commadEvent) {
this.startOperation = function(commandEvent) {
if (this.curOp) {
if (!commadEvent || this.curOp.command)
if (!commandEvent || this.curOp.command)
return;
this.prevOp = this.curOp;
}
if (!commadEvent) {
if (!commandEvent) {
this.previousCommand = null;
commadEvent = {};
commandEvent = {};
}

this.$opResetTimer.schedule();
this.curOp = this.session.curOp = {
command: commadEvent.command || {},
args: commadEvent.args,
command: commandEvent.command || {},
args: commandEvent.args,
scrollTop: this.renderer.scrollTop
};
this.curOp.selectionBefore = this.selection.toJSON();
Expand Down Expand Up @@ -1062,8 +1062,36 @@ Editor.$uid = 0;
mode.autoOutdent(lineState, session, cursor.row);
};

this.onTextInput = function(text) {
this.keyBinding.onTextInput(text);
this.onTextInput = function(text, composition) {
if (!composition)
return this.keyBinding.onTextInput(text);

this.startOperation({command: { name: "insertstring" }});
var applyComposition = this.applyComposition.bind(this, text, composition);
if (this.selection.rangeCount)
this.forEachSelection(applyComposition);
else
applyComposition();
this.endOperation();
};

this.applyComposition = function(text, composition) {
if (composition.extendLeft || composition.extendRight) {
var r = this.selection.getRange();
r.start.column -= composition.extendLeft;
r.end.column += composition.extendRight;
this.selection.setRange(r);
if (!text && !r.isEmpty())
this.remove();
}
if (text || !this.selection.isEmpty())
this.insert(text, true);
if (composition.restoreStart || composition.restoreEnd) {
var r = this.selection.getRange();
r.start.column -= composition.restoreStart;
r.end.column -= composition.restoreEnd;
this.selection.setRange(r);
}
};

this.onCommandKey = function(e, hashId, keyCode) {
Expand Down Expand Up @@ -1894,8 +1922,8 @@ Editor.$uid = 0;
};
};

this.onCompositionStart = function(text) {
this.renderer.showComposition(this.getCursorPosition());
this.onCompositionStart = function(compositionState) {
this.renderer.showComposition(compositionState);
};

this.onCompositionUpdate = function(text) {
Expand Down Expand Up @@ -2812,6 +2840,7 @@ config.defineOptions(Editor.prototype, "editor", {
theme: "renderer",
hasCssTransforms: "renderer",
maxPixelHeight: "renderer",
useTextareaForIME: "renderer",

scrollSpeed: "$mouseHandler",
dragDelay: "$mouseHandler",
Expand Down
3 changes: 3 additions & 0 deletions lib/ace/ext/options.js
Expand Up @@ -153,6 +153,9 @@ var optionGroups = {
"Fade Fold Widgets": {
path: "fadeFoldWidgets"
},
"Use textarea for IME": {
path: "useTextareaForIME"
},
"Merge Undo Deltas": {
path: "mergeUndoDeltas",
items: [
Expand Down

0 comments on commit fc7f8b1

Please sign in to comment.