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 | 1x 1x 1x 1x | import joplin from "api";
import { encode } from "html-entities";
import { CustomVariable } from "../variables/types/base";
import { AUTO_FOCUS_SCRIPT } from "../utils/dialogHelpers";
export const setTemplateVariablesView = async (viewHandle: string, title: string, variables: Record<string, CustomVariable>): Promise<void> => {
await joplin.views.dialogs.addScript(viewHandle, "./views/webview.css");
const variablesFormInputHtml = Object.values(variables).map(variable => variable.toHTML());
// Add id for autofocus hack to the first input element
let formHtml = variablesFormInputHtml.join("");
formHtml = formHtml.replace(/<(input|select|textarea)(\s)/, "<$1 id=\"autofocus-target\"$2");
await joplin.views.dialogs.setHtml(
viewHandle,
`
<h2> ${encode(title)} </h2>
<form class="variablesForm" name="variables">
${formHtml}
</form>
${AUTO_FOCUS_SCRIPT}
`
);
await joplin.views.dialogs.setButtons(viewHandle, [{ id: "ok" }, { id: "cancel" }]);
}
|