feat: add line wrapping
This commit is contained in:
@@ -250,6 +250,7 @@ export function useNewCodemirror(
|
|||||||
options: CodeMirrorOptions
|
options: CodeMirrorOptions
|
||||||
): { cursor: Ref<{ line: number; ch: number }> } {
|
): { cursor: Ref<{ line: number; ch: number }> } {
|
||||||
const language = new Compartment()
|
const language = new Compartment()
|
||||||
|
const lineWrapping = new Compartment()
|
||||||
|
|
||||||
const cachedCursor = ref({
|
const cachedCursor = ref({
|
||||||
line: 0,
|
line: 0,
|
||||||
@@ -298,6 +299,11 @@ export function useNewCodemirror(
|
|||||||
language.of(
|
language.of(
|
||||||
getEditorLanguage((options.extendedEditorConfig.mode as any) ?? "")
|
getEditorLanguage((options.extendedEditorConfig.mode as any) ?? "")
|
||||||
),
|
),
|
||||||
|
lineWrapping.of(
|
||||||
|
options.extendedEditorConfig.lineWrapping
|
||||||
|
? [EditorView.lineWrapping]
|
||||||
|
: []
|
||||||
|
),
|
||||||
keymap.of(defaultKeymap),
|
keymap.of(defaultKeymap),
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
@@ -336,6 +342,17 @@ export function useNewCodemirror(
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => options.extendedEditorConfig.lineWrapping,
|
||||||
|
(newMode) => {
|
||||||
|
dispatch({
|
||||||
|
effects: lineWrapping.reconfigure(
|
||||||
|
newMode ? [EditorView.lineWrapping] : []
|
||||||
|
),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => options.extendedEditorConfig.mode,
|
() => options.extendedEditorConfig.mode,
|
||||||
(newMode) => {
|
(newMode) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user