import NoteContextAwareWidget from "./note_context_aware_widget.js"; const TPL = `
`; export default class ApiLogWidget extends NoteContextAwareWidget { isEnabled() { return this.note && this.note.mime.startsWith('application/javascript;env=') && super.isEnabled(); } doRender() { this.$widget = $(TPL); this.toggle(false); this.$logContainer = this.$widget.find('.api-log-container'); this.$closeButton = this.$widget.find(".close-api-log-button"); this.$closeButton.on("click", () => this.toggle(false)); } async refreshWithNote(note) { this.$logContainer.empty(); } apiLogMessagesEvent({messages, noteId}) { if (!this.isNote(noteId)) { return; } this.toggle(true); for (const message of messages) { this.$logContainer.append(message).append($("
")); } } toggle(show) { this.$widget.toggleClass("hidden-api-log", !show); } }