You've already forked joplin
							
							
				mirror of
				https://github.com/laurent22/joplin.git
				synced 2025-10-31 00:07:48 +02:00 
			
		
		
		
	This commit is contained in:
		| @@ -1045,6 +1045,9 @@ packages/lib/services/UndoRedoService.js.map | ||||
| packages/lib/services/WhenClause.d.ts | ||||
| packages/lib/services/WhenClause.js | ||||
| packages/lib/services/WhenClause.js.map | ||||
| packages/lib/services/commands/EditorFocusUtil.d.ts | ||||
| packages/lib/services/commands/EditorFocusUtil.js | ||||
| packages/lib/services/commands/EditorFocusUtil.js.map | ||||
| packages/lib/services/commands/MenuUtils.d.ts | ||||
| packages/lib/services/commands/MenuUtils.js | ||||
| packages/lib/services/commands/MenuUtils.js.map | ||||
|   | ||||
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -1032,6 +1032,9 @@ packages/lib/services/UndoRedoService.js.map | ||||
| packages/lib/services/WhenClause.d.ts | ||||
| packages/lib/services/WhenClause.js | ||||
| packages/lib/services/WhenClause.js.map | ||||
| packages/lib/services/commands/EditorFocusUtil.d.ts | ||||
| packages/lib/services/commands/EditorFocusUtil.js | ||||
| packages/lib/services/commands/EditorFocusUtil.js.map | ||||
| packages/lib/services/commands/MenuUtils.d.ts | ||||
| packages/lib/services/commands/MenuUtils.js | ||||
| packages/lib/services/commands/MenuUtils.js.map | ||||
|   | ||||
| @@ -17,6 +17,7 @@ const HelpButton = require('../gui/HelpButton.min'); | ||||
| const { surroundKeywords, nextWhitespaceIndex, removeDiacritics } = require('@joplin/lib/string-utils.js'); | ||||
| const { mergeOverlappingIntervals } = require('@joplin/lib/ArrayUtils.js'); | ||||
| import markupLanguageUtils from '../utils/markupLanguageUtils'; | ||||
| import focusEditorIfEditorCommand from '@joplin/lib/services/commands/focusEditorIfEditorCommand'; | ||||
|  | ||||
| const PLUGIN_NAME = 'gotoAnything'; | ||||
|  | ||||
| @@ -379,6 +380,7 @@ class Dialog extends React.PureComponent<Props, State> { | ||||
|  | ||||
| 		if (item.type === BaseModel.TYPE_COMMAND) { | ||||
| 			void CommandService.instance().execute(item.id); | ||||
| 			void focusEditorIfEditorCommand(item.id, CommandService.instance()); | ||||
| 			return; | ||||
| 		} | ||||
|  | ||||
| @@ -526,8 +528,8 @@ class Dialog extends React.PureComponent<Props, State> { | ||||
| 				<div style={style.dialogBox}> | ||||
| 					{helpComp} | ||||
| 					<div style={style.inputHelpWrapper}> | ||||
| 						<input autoFocus type="text" style={style.input} ref={this.inputRef} value={this.state.query} onChange={this.input_onChange} onKeyDown={this.input_onKeyDown}/> | ||||
| 						<HelpButton onClick={this.helpButton_onClick}/> | ||||
| 						<input autoFocus type="text" style={style.input} ref={this.inputRef} value={this.state.query} onChange={this.input_onChange} onKeyDown={this.input_onKeyDown} /> | ||||
| 						<HelpButton onClick={this.helpButton_onClick} /> | ||||
| 					</div> | ||||
| 					{this.renderList()} | ||||
| 				</div> | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| import CommandService from '../CommandService'; | ||||
| import { stateUtils } from '../../reducer'; | ||||
| import focusEditorIfEditorCommand from './focusEditorIfEditorCommand'; | ||||
|  | ||||
| const separatorItem = { type: 'separator' }; | ||||
|  | ||||
| @@ -33,30 +34,6 @@ export default class ToolbarButtonUtils { | ||||
| 		return this.service_; | ||||
| 	} | ||||
|  | ||||
| 	// Editor commands will focus the editor after they're executed | ||||
| 	private isEditorCommand(commandName: string) { | ||||
| 		return (commandName.indexOf('editor.') === 0 || | ||||
| 				// These commands are grandfathered in, but in the future | ||||
| 				// all editor commands should start with "editor." | ||||
| 				// WARNING: Some commands such as textLink are not defined here | ||||
| 				// because they are more complex and handle focus manually | ||||
| 				commandName === 'textCopy' || | ||||
| 				commandName === 'textCut' || | ||||
| 				commandName === 'textPaste' || | ||||
| 				commandName === 'textSelectAll' || | ||||
| 				commandName === 'textBold' || | ||||
| 				commandName === 'textItalic' || | ||||
| 				commandName === 'textCode' || | ||||
| 				commandName === 'attachFile' || | ||||
| 				commandName === 'textNumberedList' || | ||||
| 				commandName === 'textBulletedList' || | ||||
| 				commandName === 'textCheckbox' || | ||||
| 				commandName === 'textHeading' || | ||||
| 				commandName === 'textHorizontalRule' || | ||||
| 				commandName === 'insertDateTime' | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	private commandToToolbarButton(commandName: string, whenClauseContext: any): ToolbarButtonInfo { | ||||
| 		const newEnabled = this.service.isEnabled(commandName, whenClauseContext); | ||||
| 		const newTitle = this.service.title(commandName); | ||||
| @@ -78,9 +55,7 @@ export default class ToolbarButtonUtils { | ||||
| 			enabled: newEnabled, | ||||
| 			onClick: async () => { | ||||
| 				void this.service.execute(commandName); | ||||
| 				if (this.isEditorCommand(commandName)) { | ||||
| 					void this.service.execute('editor.focus'); | ||||
| 				} | ||||
| 				void focusEditorIfEditorCommand(commandName, this.service); | ||||
| 			}, | ||||
| 			title: newTitle, | ||||
| 		}; | ||||
|   | ||||
| @@ -0,0 +1,8 @@ | ||||
| import CommandService from '../CommandService'; | ||||
| import isEditorCommand from './isEditorCommand'; | ||||
|  | ||||
| export default async function focusEditorIfEditorCommand(commandName: string, commandService: CommandService) { | ||||
| 	if (isEditorCommand(commandName)) { | ||||
| 		await commandService.execute('editor.focus'); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										25
									
								
								packages/lib/services/commands/isEditorCommand.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								packages/lib/services/commands/isEditorCommand.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| // Editor commands will focus the editor after they're executed | ||||
| export default function isEditorCommand(commandName: string) { | ||||
| 	if (!commandName) return false; | ||||
|  | ||||
| 	return (commandName.indexOf('editor.') === 0 || | ||||
|         // These commands are grandfathered in, but in the future | ||||
|         // all editor commands should start with "editor." | ||||
|         // WARNING: Some commands such as textLink are not defined here | ||||
|         // because they are more complex and handle focus manually | ||||
|         commandName === 'textCopy' || | ||||
|         commandName === 'textCut' || | ||||
|         commandName === 'textPaste' || | ||||
|         commandName === 'textSelectAll' || | ||||
|         commandName === 'textBold' || | ||||
|         commandName === 'textItalic' || | ||||
|         commandName === 'textCode' || | ||||
|         commandName === 'attachFile' || | ||||
|         commandName === 'textNumberedList' || | ||||
|         commandName === 'textBulletedList' || | ||||
|         commandName === 'textCheckbox' || | ||||
|         commandName === 'textHeading' || | ||||
|         commandName === 'textHorizontalRule' || | ||||
|         commandName === 'insertDateTime' | ||||
| 	); | ||||
| } | ||||
		Reference in New Issue
	
	Block a user