feat(mermaid): disable line wrapping by default

This commit is contained in:
Elian Doran 2025-03-22 02:36:47 +02:00
parent acf6d9dc4f
commit 91dca2df35
No known key found for this signature in database
4 changed files with 33 additions and 17 deletions

View File

@ -186,20 +186,28 @@ declare global {
attach(editor: TextEditor);
};
interface CodeMirrorOpts {
value: string;
viewportMargin: number;
indentUnit: number;
matchBrackets: boolean;
matchTags: { bothTags: boolean };
highlightSelectionMatches: {
showToken: boolean;
annotateScrollbar: boolean;
};
lineNumbers: boolean;
lineWrapping: boolean;
keyMap: "vim" | "default";
lint: boolean;
gutters: string[];
tabindex: number;
dragDrop: boolean;
placeholder: string;
}
var CodeMirror: {
(el: HTMLElement, opts: {
value: string;
viewportMargin: number;
indentUnit: number;
matchBrackets: boolean;
matchTags: { bothTags: boolean };
highlightSelectionMatches: {
showToken: boolean;
annotateScrollbar: boolean;
};
lineNumbers: boolean;
lineWrapping: boolean;
}): CodeMirrorInstance;
(el: HTMLElement, opts: CodeMirrorOpts): CodeMirrorInstance;
keyMap: {
default: Record<string, string>;
};

View File

@ -64,7 +64,7 @@ export default class AbstractCodeTypeWidget extends TypeWidget {
*
* @returns the extra options to be passed to the CodeMirror constructor.
*/
getExtraOpts() {
getExtraOpts(): Partial<CodeMirrorOpts> {
return {};
}

View File

@ -92,6 +92,7 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
super();
this.editorTypeWidget = new EditableCodeTypeWidget();
this.editorTypeWidget.isEnabled = () => true;
this.editorTypeWidget.getExtraOpts = this.buildEditorExtraOptions;
}
doRender(): void {
@ -139,13 +140,20 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
/**
* Called upon when the split between the preview and content pane is initialized. Can be used to add additional listeners if needed.
*
* @returns the additional split options.
*/
buildSplitExtraOptions(): Split.Options {
return {};
}
/**
* Called upon when the code editor is being initialized. Can be used to add additional options to the editor.
*/
buildEditorExtraOptions(): Partial<CodeMirrorOpts> {
return {
lineWrapping: false
};
}
setError(message: string | null | undefined) {
this.$errorContainer.toggleClass("hidden-ext", !message);
this.$preview.toggleClass("on-error", !!message);

View File

@ -38,7 +38,7 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget {
super.doRender();
}
getExtraOpts() {
getExtraOpts(): Partial<CodeMirrorOpts> {
return {
keyMap: options.is("vimKeymapEnabled") ? "vim" : "default",
lint: true,