From bca7903f2b76f69e8f12272a2f4c9ea3ee668215 Mon Sep 17 00:00:00 2001 From: Neonnaut Date: Wed, 17 Jul 2024 00:57:29 +1000 Subject: [PATCH] added optional line wrapping!!! --- lexifer.html | 3 ++- script/cm6.bundle.js | 13 ++++++++++++- script/lexifer-buttons.js | 12 ++++++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/lexifer.html b/lexifer.html index 05eb461..687179b 100644 --- a/lexifer.html +++ b/lexifer.html @@ -66,7 +66,8 @@

Lexifer Online



- + +
diff --git a/script/cm6.bundle.js b/script/cm6.bundle.js index c2a0d97..eb4176f 100644 --- a/script/cm6.bundle.js +++ b/script/cm6.bundle.js @@ -21511,6 +21511,7 @@ var cm6 = (function (exports) { } const themeConfig = new Compartment(); + const lineWrapConfig = new Compartment(); function createEditorState(initialContents, myTheme) { let extensions = [ @@ -21531,7 +21532,8 @@ var cm6 = (function (exports) { ...historyKeymap, ]), lexifer(), - themeConfig.of(themeIdentifier(myTheme)) + themeConfig.of(themeIdentifier(myTheme)), + lineWrapConfig.of([]) ]; return EditorState.create({ @@ -21561,6 +21563,15 @@ var cm6 = (function (exports) { }); } + function changeEditorLineWrap(myEditor, wrapping) { + myEditor.dispatch({ + effects: [lineWrapConfig.reconfigure( + wrapping ? EditorView.lineWrapping : [] + )] + }); + } + + exports.changeEditorLineWrap = changeEditorLineWrap; exports.changeEditorTheme = changeEditorTheme; exports.createEditorState = createEditorState; exports.createEditorView = createEditorView; diff --git a/script/lexifer-buttons.js b/script/lexifer-buttons.js index 971346e..c9b854b 100644 --- a/script/lexifer-buttons.js +++ b/script/lexifer-buttons.js @@ -109,9 +109,21 @@ $(window).on('load', function () { $("#lexiferDarkMode").click(function () { if ($("#lexiferDarkMode").is(':checked')) { + view.dispatch({ + lineWrapping: true + }) + + cm6.changeEditorTheme(view, "dark"); } else { cm6.changeEditorTheme(view, "light"); } }); + $("#lexiferLineWrap").click(function () { + if ($("#lexiferLineWrap").is(':checked')) { + cm6.changeEditorLineWrap(view, true); + } else { + cm6.changeEditorLineWrap(view, false); + } + }); }); \ No newline at end of file