|
|
|
|
@ -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 NoteContextAwareWidget from "./note_context_aware_widget.js";
|
|
|
|
|
|
|
|
|
|
@ -10,16 +12,16 @@ const TPL = `
|
|
|
|
|
max-height: 40%;
|
|
|
|
|
position: relative;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.hidden-api-log {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.api-log-container {
|
|
|
|
|
overflow: auto;
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.close-api-log-button {
|
|
|
|
|
padding: 5px;
|
|
|
|
|
border: 1px solid var(--button-border-color);
|
|
|
|
|
@ -32,15 +34,19 @@ const TPL = `
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="bx bx-x close-api-log-button" title="${t("api_log.close")}"></div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<div class="api-log-container"></div>
|
|
|
|
|
</div>`;
|
|
|
|
|
|
|
|
|
|
export default class ApiLogWidget extends NoteContextAwareWidget {
|
|
|
|
|
|
|
|
|
|
private $logContainer!: JQuery<HTMLElement>;
|
|
|
|
|
private $closeButton!: JQuery<HTMLElement>;
|
|
|
|
|
|
|
|
|
|
isEnabled() {
|
|
|
|
|
return this.note && this.note.mime.startsWith("application/javascript;env=") && super.isEnabled();
|
|
|
|
|
return !!this.note && this.note.mime.startsWith("application/javascript;env=") && super.isEnabled();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
doRender() {
|
|
|
|
|
@ -52,11 +58,11 @@ export default class ApiLogWidget extends NoteContextAwareWidget {
|
|
|
|
|
this.$closeButton.on("click", () => this.toggle(false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async refreshWithNote(note) {
|
|
|
|
|
async refreshWithNote(note: FNote) {
|
|
|
|
|
this.$logContainer.empty();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apiLogMessagesEvent({ messages, noteId }) {
|
|
|
|
|
apiLogMessagesEvent({ messages, noteId }: EventData<"apiLogMessages">) {
|
|
|
|
|
if (!this.isNote(noteId)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -68,7 +74,7 @@ export default class ApiLogWidget extends NoteContextAwareWidget {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggle(show) {
|
|
|
|
|
toggle(show: boolean) {
|
|
|
|
|
this.$widget.toggleClass("hidden-api-log", !show);
|
|
|
|
|
}
|
|
|
|
|
}
|