mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-10-01 18:31:31 +08:00
chore(client/ts): port editable_code
This commit is contained in:
parent
cb7b25f054
commit
75afdbe093
@ -1,3 +1,5 @@
|
|||||||
|
import type { EventData } from "../../components/app_context.js";
|
||||||
|
import type FNote from "../../entities/fnote.js";
|
||||||
import { t } from "../../services/i18n.js";
|
import { t } from "../../services/i18n.js";
|
||||||
import keyboardActionService from "../../services/keyboard_actions.js";
|
import keyboardActionService from "../../services/keyboard_actions.js";
|
||||||
import options from "../../services/options.js";
|
import options from "../../services/options.js";
|
||||||
@ -10,7 +12,7 @@ const TPL = `
|
|||||||
position: relative;
|
position: relative;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.note-detail-code-editor {
|
.note-detail-code-editor {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
@ -21,6 +23,9 @@ const TPL = `
|
|||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
|
export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
|
||||||
|
|
||||||
|
private $editor!: JQuery<HTMLElement>;
|
||||||
|
|
||||||
static getType() {
|
static getType() {
|
||||||
return "editableCode";
|
return "editableCode";
|
||||||
}
|
}
|
||||||
@ -50,11 +55,11 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
|
|||||||
this.codeEditor.on("change", () => this.spacedUpdate.scheduleUpdate());
|
this.codeEditor.on("change", () => this.spacedUpdate.scheduleUpdate());
|
||||||
}
|
}
|
||||||
|
|
||||||
async doRefresh(note) {
|
async doRefresh(note: FNote) {
|
||||||
const blob = await this.note.getBlob();
|
const blob = await this.note?.getBlob();
|
||||||
|
|
||||||
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||||
this._update(note, blob.content);
|
this._update(note, blob?.content);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.show();
|
this.show();
|
||||||
@ -66,7 +71,7 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async executeWithCodeEditorEvent({ resolve, ntxId }) {
|
async executeWithCodeEditorEvent({ resolve, ntxId }: EventData<"executeWithCodeEditor">) {
|
||||||
if (!this.isNoteContext(ntxId)) {
|
if (!this.isNoteContext(ntxId)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user