mirror of
				https://github.com/TriliumNext/Notes.git
				synced 2025-10-31 21:11:30 +08:00 
			
		
		
		
	chore(code): reintroduce vim keybindings
This commit is contained in:
		
							parent
							
								
									e5fad63403
								
							
						
					
					
						commit
						9b958fc659
					
				| @ -45,13 +45,13 @@ export default class EditableCodeTypeWidget extends AbstractCodeTypeWidget { | ||||
|     getExtraOpts(): Partial<EditorConfig> { | ||||
|         return { | ||||
|             placeholder: t("editable_code.placeholder"), | ||||
|             vimKeybindings: options.is("vimKeymapEnabled"), | ||||
|             onContentChanged: () => this.spacedUpdate.scheduleUpdate() | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     // getExtraOpts(): Partial<CodeMirrorOpts> {
 | ||||
|     //     return {
 | ||||
|     //         keyMap: options.is("vimKeymapEnabled") ? "vim" : "default",
 | ||||
|     //         lint: true,
 | ||||
|     //         gutters: ["CodeMirror-lint-markers"],
 | ||||
|     //         tabindex: 300,
 | ||||
|  | ||||
| @ -31,6 +31,7 @@ | ||||
|     "@codemirror/legacy-modes": "6.5.1", | ||||
|     "@codemirror/search": "6.5.10", | ||||
|     "@codemirror/view": "6.36.7", | ||||
|     "@replit/codemirror-vim": "6.3.0", | ||||
|     "@ssddanbrown/codemirror-lang-smarty": "1.0.0", | ||||
|     "@ssddanbrown/codemirror-lang-twig": "1.0.0", | ||||
|     "codemirror-lang-hcl": "0.1.0", | ||||
|  | ||||
| @ -3,6 +3,7 @@ import { EditorView, highlightActiveLine, keymap, lineNumbers, placeholder, View | ||||
| import { defaultHighlightStyle, StreamLanguage, syntaxHighlighting, indentUnit, bracketMatching } from "@codemirror/language"; | ||||
| import { Compartment, type Extension } from "@codemirror/state"; | ||||
| import { highlightSelectionMatches } from "@codemirror/search"; | ||||
| import { vim } from "@replit/codemirror-vim"; | ||||
| import byMimeType from "./syntax_highlighting.js"; | ||||
| 
 | ||||
| type ContentChangedListener = () => void; | ||||
| @ -10,6 +11,7 @@ type ContentChangedListener = () => void; | ||||
| export interface EditorConfig extends EditorViewConfig { | ||||
|     placeholder?: string; | ||||
|     lineWrapping?: boolean; | ||||
|     vimKeybindings?: boolean; | ||||
|     onContentChanged?: ContentChangedListener; | ||||
| } | ||||
| 
 | ||||
| @ -23,7 +25,14 @@ export default class CodeMirror extends EditorView { | ||||
|         const languageCompartment = new Compartment(); | ||||
|         const historyCompartment = new Compartment(); | ||||
| 
 | ||||
|         let extensions = [ | ||||
|         let extensions: Extension[] = []; | ||||
| 
 | ||||
|         if (config.vimKeybindings) { | ||||
|             extensions.push(vim()); | ||||
|         } | ||||
| 
 | ||||
|         extensions = [ | ||||
|             ...extensions, | ||||
|             languageCompartment.of([]), | ||||
|             historyCompartment.of(history()), | ||||
|             syntaxHighlighting(defaultHighlightStyle, { fallback: true }), | ||||
| @ -36,8 +45,8 @@ export default class CodeMirror extends EditorView { | ||||
|                 ...defaultKeymap, | ||||
|                 ...historyKeymap, | ||||
|                 indentWithTab | ||||
|             ]), | ||||
|         ]; | ||||
|             ]) | ||||
|         ] | ||||
| 
 | ||||
|         if (Array.isArray(config.extensions)) { | ||||
|             extensions = [...extensions, ...config.extensions]; | ||||
|  | ||||
							
								
								
									
										20
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										20
									
								
								pnpm-lock.yaml
									
									
									
										generated
									
									
									
								
							| @ -1187,6 +1187,9 @@ importers: | ||||
|       '@codemirror/view': | ||||
|         specifier: 6.36.7 | ||||
|         version: 6.36.7 | ||||
|       '@replit/codemirror-vim': | ||||
|         specifier: 6.3.0 | ||||
|         version: 6.3.0(@codemirror/commands@6.8.1)(@codemirror/language@6.11.0)(@codemirror/search@6.5.10)(@codemirror/state@6.5.2)(@codemirror/view@6.36.7) | ||||
|       '@ssddanbrown/codemirror-lang-smarty': | ||||
|         specifier: 1.0.0 | ||||
|         version: 1.0.0 | ||||
| @ -4292,6 +4295,15 @@ packages: | ||||
|   '@radix-ui/rect@1.1.0': | ||||
|     resolution: {integrity: sha512-A9+lCBZoaMJlVKcRBz2YByCG+Cp2t6nAnMnNba+XiWxnj6r4JUFqfsgwocMBZU9LPtdxC6wB56ySYpc7LQIoJg==} | ||||
| 
 | ||||
|   '@replit/codemirror-vim@6.3.0': | ||||
|     resolution: {integrity: sha512-aTx931ULAMuJx6xLf7KQDOL7CxD+Sa05FktTDrtLaSy53uj01ll3Zf17JdKsriER248oS55GBzg0CfCTjEneAQ==} | ||||
|     peerDependencies: | ||||
|       '@codemirror/commands': 6.x.x | ||||
|       '@codemirror/language': 6.x.x | ||||
|       '@codemirror/search': 6.x.x | ||||
|       '@codemirror/state': 6.x.x | ||||
|       '@codemirror/view': 6.x.x | ||||
| 
 | ||||
|   '@rollup/plugin-commonjs@25.0.8': | ||||
|     resolution: {integrity: sha512-ZEZWTK5n6Qde0to4vS9Mr5x/0UZoqCxPVR9KRUjU4kA2sO7GEUn1fop0DAwpO6z0Nw/kJON9bDmSxdWxO/TT1A==} | ||||
|     engines: {node: '>=14.0.0'} | ||||
| @ -19393,6 +19405,14 @@ snapshots: | ||||
| 
 | ||||
|   '@radix-ui/rect@1.1.0': {} | ||||
| 
 | ||||
|   '@replit/codemirror-vim@6.3.0(@codemirror/commands@6.8.1)(@codemirror/language@6.11.0)(@codemirror/search@6.5.10)(@codemirror/state@6.5.2)(@codemirror/view@6.36.7)': | ||||
|     dependencies: | ||||
|       '@codemirror/commands': 6.8.1 | ||||
|       '@codemirror/language': 6.11.0 | ||||
|       '@codemirror/search': 6.5.10 | ||||
|       '@codemirror/state': 6.5.2 | ||||
|       '@codemirror/view': 6.36.7 | ||||
| 
 | ||||
|   '@rollup/plugin-commonjs@25.0.8(rollup@4.40.0)': | ||||
|     dependencies: | ||||
|       '@rollup/pluginutils': 5.1.4(rollup@4.40.0) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran