Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import joplin from "api"; import { encode } from "html-entities"; export interface DefaultTemplatesDisplayData { defaultNoteTemplateTitle: string | null; defaultTodoTemplateTitle: string | null; } export interface NotebookDefaultTemplatesDisplayData extends DefaultTemplatesDisplayData { notebookTitle: string; } const getDisplayableTitle = (title: string | null): string => { return title ? encode(title) : "<i>Not set</i>"; } const getHTMLForOverallDefaults = (globalDefaultTemplates: DefaultTemplatesDisplayData): string => { return ` <h3> Overall defaults </h3> <table> <tr> <th> Note </th> <th> To-do </th> </tr> <tr> <td>${getDisplayableTitle(globalDefaultTemplates.defaultNoteTemplateTitle)}</td> <td>${getDisplayableTitle(globalDefaultTemplates.defaultTodoTemplateTitle)}</td> </tr> </table> `; } const getHTMLForNotbookDefaults = (notebookDefaultTemplates: NotebookDefaultTemplatesDisplayData[]): string => { Iif (!notebookDefaultTemplates.length) return ""; return ` <h3> Notebook defaults </h3> <table> <tr> <th> Notebook </th> <th> Note </th> <th> To-do </th> </tr> ${notebookDefaultTemplates.map(rowDisplayData => { return ` <tr> <td>${getDisplayableTitle(rowDisplayData.notebookTitle)}</td> <td>${getDisplayableTitle(rowDisplayData.defaultNoteTemplateTitle)}</td> <td>${getDisplayableTitle(rowDisplayData.defaultTodoTemplateTitle)}</td> </tr> ` }).join("")} </table> `; } export const setDefaultTemplatesView = async (viewHandle: string, globalDefaultTemplates: DefaultTemplatesDisplayData, notebookDefaultTemplates: NotebookDefaultTemplatesDisplayData[]): Promise<void> => { await joplin.views.dialogs.addScript(viewHandle, "./views/webview.css"); await joplin.views.dialogs.setHtml( viewHandle, ` <h2> Default Templates </h2> ${getHTMLForOverallDefaults(globalDefaultTemplates)} ${getHTMLForNotbookDefaults(notebookDefaultTemplates)} ` ); await joplin.views.dialogs.setButtons(viewHandle, [{ id: "ok" }]); } |