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,8 +186,7 @@ declare global {
attach(editor: TextEditor); attach(editor: TextEditor);
}; };
var CodeMirror: { interface CodeMirrorOpts {
(el: HTMLElement, opts: {
value: string; value: string;
viewportMargin: number; viewportMargin: number;
indentUnit: number; indentUnit: number;
@ -199,7 +198,16 @@ declare global {
}; };
lineNumbers: boolean; lineNumbers: boolean;
lineWrapping: boolean; lineWrapping: boolean;
}): CodeMirrorInstance; keyMap: "vim" | "default";
lint: boolean;
gutters: string[];
tabindex: number;
dragDrop: boolean;
placeholder: string;
}
var CodeMirror: {
(el: HTMLElement, opts: CodeMirrorOpts): CodeMirrorInstance;
keyMap: { keyMap: {
default: Record<string, string>; 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. * @returns the extra options to be passed to the CodeMirror constructor.
*/ */
getExtraOpts() { getExtraOpts(): Partial<CodeMirrorOpts> {
return {}; return {};
} }

View File

@ -92,6 +92,7 @@ export default abstract class AbstractSplitTypeWidget extends TypeWidget {
super(); super();
this.editorTypeWidget = new EditableCodeTypeWidget(); this.editorTypeWidget = new EditableCodeTypeWidget();
this.editorTypeWidget.isEnabled = () => true; this.editorTypeWidget.isEnabled = () => true;
this.editorTypeWidget.getExtraOpts = this.buildEditorExtraOptions;
} }
doRender(): void { 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. * 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 { buildSplitExtraOptions(): Split.Options {
return {}; 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) { setError(message: string | null | undefined) {
this.$errorContainer.toggleClass("hidden-ext", !message); this.$errorContainer.toggleClass("hidden-ext", !message);
this.$preview.toggleClass("on-error", !!message); this.$preview.toggleClass("on-error", !!message);

View File

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