add based option for ace editor that copies on empty selection
This commit is contained in:
parent
4a647a3f26
commit
43133d67e9
40
src/index.js
40
src/index.js
@ -55,6 +55,7 @@ const langTools = ace.require("ace/ext/language_tools");
|
|||||||
editor.setOptions({
|
editor.setOptions({
|
||||||
enableBasicAutocompletion: true,
|
enableBasicAutocompletion: true,
|
||||||
enableLiveAutocompletion: true,
|
enableLiveAutocompletion: true,
|
||||||
|
copyWithEmptySelection: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
langTools.setCompleters([new GamelibCompleter(), new TextCompleter()]);
|
langTools.setCompleters([new GamelibCompleter(), new TextCompleter()]);
|
||||||
@ -221,42 +222,3 @@ saveKarlkoderButton.onclick = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
toggleSpriteEditorButton.addEventListener("click", () => spriteEditor.toggleEditor());
|
toggleSpriteEditorButton.addEventListener("click", () => spriteEditor.toggleEditor());
|
||||||
|
|
||||||
consoleInput.onkeydown = (ev) => {
|
|
||||||
if (ev.key !== "Enter") return;
|
|
||||||
|
|
||||||
const code = ev.target.value;
|
|
||||||
ev.target.value = "";
|
|
||||||
|
|
||||||
codeRunner.evaluateCode(code);
|
|
||||||
};
|
|
||||||
|
|
||||||
editor.commands.addCommand({
|
|
||||||
name: "cut",
|
|
||||||
bindKey: { win: "Ctrl-X" },
|
|
||||||
exec: function (editor) {
|
|
||||||
const cutLine = editor.selection.isEmpty();
|
|
||||||
const range = cutLine ? editor.selection.getLineRange() : editor.selection.getRange();
|
|
||||||
editor._emit("cut", range);
|
|
||||||
|
|
||||||
if (!range.isEmpty()) {
|
|
||||||
editor.session.remove(range);
|
|
||||||
}
|
|
||||||
editor.clearSelection();
|
|
||||||
},
|
|
||||||
scrollIntoView: "cursor",
|
|
||||||
multiSelectAction: "forEach",
|
|
||||||
readOnly: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
function copy(text) {
|
|
||||||
const elem = document.createElement("input");
|
|
||||||
elem.value = text;
|
|
||||||
elem.display = "none";
|
|
||||||
document.body.appendChild(elem);
|
|
||||||
|
|
||||||
elem.select();
|
|
||||||
document.execCommand("copy");
|
|
||||||
|
|
||||||
requestAnimationFrame(() => elem.remove());
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user