mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
added help button to JS code notes to navigate to API docs
This commit is contained in:
parent
2d08eb7366
commit
17fe9a6a1b
@ -186,6 +186,7 @@ const TAB_ROW_TPL = `
|
|||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
position: relative;
|
position: relative;
|
||||||
top: -6px;
|
top: -6px;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.tab-row-widget .note-tab .note-tab-close:hover {
|
.tab-row-widget .note-tab .note-tab-close:hover {
|
||||||
|
@ -10,11 +10,25 @@ import treeService from "../../services/tree.js";
|
|||||||
const TPL = `
|
const TPL = `
|
||||||
<div class="note-detail-code note-detail-printable">
|
<div class="note-detail-code note-detail-printable">
|
||||||
<style>
|
<style>
|
||||||
|
.note-detail-code {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.trilium-api-docs-button {
|
||||||
|
/*display: none;*/
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.note-detail-code-editor {
|
.note-detail-code-editor {
|
||||||
min-height: 50px;
|
min-height: 50px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<button class="btn bx bx-help-circle trilium-api-docs-button icon-button floating-button"
|
||||||
|
title="Open Trilium API docs"></button>
|
||||||
|
|
||||||
<div class="note-detail-code-editor"></div>
|
<div class="note-detail-code-editor"></div>
|
||||||
|
|
||||||
<div style="display: flex; justify-content: space-evenly;">
|
<div style="display: flex; justify-content: space-evenly;">
|
||||||
@ -36,6 +50,16 @@ export default class EditableCodeTypeWidget extends TypeWidget {
|
|||||||
|
|
||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
|
this.$openTriliumApiDocsButton = this.$widget.find(".trilium-api-docs-button");
|
||||||
|
this.$openTriliumApiDocsButton.on("click", () => {
|
||||||
|
if (this.note.mime.endsWith("frontend")) {
|
||||||
|
window.open("https://zadam.github.io/trilium/frontend_api/FrontendScriptApi.html", "_blank");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
window.open("https://zadam.github.io/trilium/backend_api/BackendScriptApi.html", "_blank");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.$editor = this.$widget.find('.note-detail-code-editor');
|
this.$editor = this.$widget.find('.note-detail-code-editor');
|
||||||
this.$executeButton = this.$widget.find('.execute-button');
|
this.$executeButton = this.$widget.find('.execute-button');
|
||||||
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
|
this.$saveToNoteButton = this.$widget.find('.save-to-note-button');
|
||||||
@ -99,6 +123,8 @@ export default class EditableCodeTypeWidget extends TypeWidget {
|
|||||||
&& !note.getAllNotePaths().find(notePathArr => !notePathArr.includes("hidden"))
|
&& !note.getAllNotePaths().find(notePathArr => !notePathArr.includes("hidden"))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.$openTriliumApiDocsButton.toggle(note.mime.startsWith('application/javascript;env='));
|
||||||
|
|
||||||
const noteComplement = await this.noteContext.getNoteComplement();
|
const noteComplement = await this.noteContext.getNoteComplement();
|
||||||
|
|
||||||
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
await this.spacedUpdate.allowUpdateWithoutChange(() => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user