import mimeTypesService from "../../../services/mime_types.js"; import options from "../../../services/options.js"; import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; import OptionsTab from "./options_tab.js"; const TPL = `

Use vim keybindings in code notes (no ex mode)


Wrap lines in code notes


Automatic readonly size

Automatic readonly note size is the size after which notes will be displayed in a readonly mode (for performance reasons).

Available MIME types in the dropdown

`; export default class CodeNotesOptions extends OptionsTab { get tabTitle() { return "Code notes" } lazyRender() { this.$widget = $(TPL); this.$vimKeymapEnabled = this.$widget.find("#vim-keymap-enabled"); this.$vimKeymapEnabled.on('change', () => { const opts = { 'vimKeymapEnabled': this.$vimKeymapEnabled.is(":checked") ? "true" : "false" }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$codeLineWrapEnabled = this.$widget.find("#line-wrap-enabled"); this.$codeLineWrapEnabled.on('change', () => { const opts = { 'codeLineWrapEnabled': this.$codeLineWrapEnabled.is(":checked") ? "true" : "false" }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$mimeTypes = this.$widget.find("#options-mime-types"); this.$autoReadonlySizeCode = this.$widget.find("#auto-readonly-size-code"); this.$autoReadonlySizeCode.on('change', () => { const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeCode.val() }; server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); } async optionsLoaded(options) { this.$mimeTypes.empty(); this.$vimKeymapEnabled.prop("checked", options['vimKeymapEnabled'] === 'true'); this.$codeLineWrapEnabled.prop("checked", options['codeLineWrapEnabled'] === 'true'); this.$autoReadonlySizeCode.val(options['autoReadonlySizeCode']); let idCtr = 1; for (const mimeType of await mimeTypesService.getMimeTypes()) { const id = "code-mime-type-" + (idCtr++); this.$mimeTypes.append($("
  • ") .append($('') .attr("id", id) .attr("data-mime-type", mimeType.mime) .prop("checked", mimeType.enabled)) .on('change', () => this.save()) .append("   ") .append($('