Skip to content

Commit

Permalink
added optional line wrapping!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Neonnaut committed Jul 16, 2024
1 parent c466d95 commit bca7903
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lexifer.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ <h1>Lexifer Online</h1>
<label for="verbose">Display all generation steps</label><br>
<input type="checkbox" id="lexiferDarkMode" />
<label for="lexiferDarkMode">Use dark mode</label><br>

<input type="checkbox" id="lexiferLineWrap" />
<label for="lexiferLineWrap">Wrap lines</label><br>
</fieldset>
</section>

Expand Down
13 changes: 12 additions & 1 deletion script/cm6.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21511,6 +21511,7 @@ var cm6 = (function (exports) {
}

const themeConfig = new Compartment();
const lineWrapConfig = new Compartment();

function createEditorState(initialContents, myTheme) {
let extensions = [
Expand All @@ -21531,7 +21532,8 @@ var cm6 = (function (exports) {
...historyKeymap,
]),
lexifer(),
themeConfig.of(themeIdentifier(myTheme))
themeConfig.of(themeIdentifier(myTheme)),
lineWrapConfig.of([])
];

return EditorState.create({
Expand Down Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions script/lexifer-buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
});

0 comments on commit bca7903

Please sign in to comment.