From 90dffdc6ed53bab041431d0583646a333332915f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 31 Oct 2024 20:18:02 +0200 Subject: [PATCH] client: Enable preview for word wrap --- .../type_widgets/options/appearance/code_block.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/type_widgets/options/appearance/code_block.js b/src/public/app/widgets/type_widgets/options/appearance/code_block.js index 1e634238a..021e4619d 100644 --- a/src/public/app/widgets/type_widgets/options/appearance/code_block.js +++ b/src/public/app/widgets/type_widgets/options/appearance/code_block.js @@ -8,6 +8,11 @@ const SAMPLE_CODE = `\ const n = 10; greet(n); // Print "Hello World" for n times +/** + * Displays a "Hello World!" message for a given amount of times, on the standard console. The "Hello World!" text will be displayed once per line. + * + * @param {number} times The number of times to print the \`Hello World!\` message. + */ function greet(times) { for (let i = 0; i++; i < times) { console.log("Hello World!"); @@ -62,7 +67,7 @@ export default class CodeBlockOptions extends OptionsWidget { await server.put(`options/codeBlockTheme/${newTheme}`); }); - this.$wordWrap = this.$widget.find(".word-wrap"); + this.$wordWrap = this.$widget.find("input.word-wrap"); this.$wordWrap.on("change", () => this.updateCheckboxOption("codeBlockWordWrap", this.$wordWrap)); // Set up preview @@ -75,6 +80,7 @@ export default class CodeBlockOptions extends OptionsWidget { }); sampleEl.html(highlightedText.value); }); + this.$sampleWrapper = this.$widget.find(".note-detail-readonly-text"); } async optionsLoaded(options) { @@ -88,5 +94,6 @@ export default class CodeBlockOptions extends OptionsWidget { } this.$themeSelect.val(options.codeBlockTheme); this.setCheckboxState(this.$wordWrap, options.codeBlockWordWrap); + this.$widget.closest(".note-detail-printable").toggleClass("word-wrap", options.codeBlockWordWrap); } } \ No newline at end of file