most menu events mapped; cleanup
This commit is contained in:
@@ -10,7 +10,6 @@ export class AceEditorBase {
|
||||
@Input() editorSettings!: typeof EditorSettings;
|
||||
editor!: any;
|
||||
uuid!: string;
|
||||
fontSize: number = 12;
|
||||
cutBuffer: string = "";
|
||||
timerId: number = -1;
|
||||
|
||||
@@ -19,18 +18,51 @@ export class AceEditorBase {
|
||||
) {}
|
||||
|
||||
|
||||
protected search() {
|
||||
console.log(this.editor.getSession()["$modeId"])
|
||||
}
|
||||
|
||||
protected saveFile() {
|
||||
const text = this.editor.session.getValue();
|
||||
// window.fs.saveFile(text);
|
||||
}
|
||||
|
||||
protected saveFileAs() {
|
||||
const text = this.editor.session.getValue();
|
||||
window.fs.saveFileAs(text);
|
||||
}
|
||||
|
||||
protected zoomIn() {
|
||||
this.fontSize += 1;
|
||||
this.editorElm.nativeElement.style.fontSize = `${this.fontSize}px`;
|
||||
this.editor.setFontSize(
|
||||
parseInt(this.editor.getFontSize()) + 1
|
||||
)
|
||||
}
|
||||
|
||||
protected zoomOut() {
|
||||
this.fontSize -= 1;
|
||||
this.editorElm.nativeElement.style.fontSize = `${this.fontSize}px`;
|
||||
this.editor.setFontSize(
|
||||
parseInt(this.editor.getFontSize()) - 1
|
||||
)
|
||||
}
|
||||
|
||||
protected search() {
|
||||
console.log(this.editor.getSession()["$modeId"])
|
||||
protected cutText() {
|
||||
let cutText = this.editor.getSelectedText();
|
||||
this.editor.remove();
|
||||
navigator.clipboard.writeText(cutText).catch(() => {
|
||||
console.error("Unable to cut text...");
|
||||
});
|
||||
}
|
||||
|
||||
protected copyText() {
|
||||
let copyText = this.editor.getSelectedText();
|
||||
navigator.clipboard.writeText(copyText).catch(() => {
|
||||
console.error("Unable to copy text...");
|
||||
});
|
||||
}
|
||||
|
||||
protected pasteText() {
|
||||
navigator.clipboard.readText().then((pasteText) => {
|
||||
this.editor.insert(pasteText, true);
|
||||
});
|
||||
}
|
||||
|
||||
protected movelinesUp() {
|
||||
@@ -51,17 +83,15 @@ export class AceEditorBase {
|
||||
const cursorPosition = this.editor.getCursorPosition();
|
||||
let lineText = this.editor.session.getLine(cursorPosition.row);
|
||||
this.cutBuffer += `${lineText}\n`;
|
||||
this.editor.session.removeFullLines(cursorPosition.row, cursorPosition.row)
|
||||
|
||||
this.editor.session.removeFullLines(cursorPosition.row, cursorPosition.row)
|
||||
this.setBufferClearTimeout();
|
||||
}
|
||||
|
||||
protected pasteCutBuffer() {
|
||||
if (this.timerId) { clearTimeout(this.timerId); }
|
||||
|
||||
const cursorPosition = this.editor.getCursorPosition();
|
||||
this.editor.session.insert(cursorPosition, this.cutBuffer)
|
||||
|
||||
this.editor.insert(this.cutBuffer, true);
|
||||
this.setBufferClearTimeout();
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,20 @@ export class AceEditorComponent extends AceEditorBase {
|
||||
this.editor.session.destroy();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "saveFile",
|
||||
bindKey: {win: "ctrl-s", mac: "ctrl-s"},
|
||||
exec: () => {
|
||||
this.saveFile();
|
||||
},
|
||||
readOnly: true
|
||||
}, {
|
||||
name: "saveFileAs",
|
||||
bindKey: {win: "ctrl-shift-s", mac: "ctrl-shift-s"},
|
||||
exec: () => {
|
||||
this.saveFileAs();
|
||||
},
|
||||
readOnly: true
|
||||
}
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user