Pre-release 1.1 is availabe for testing

This pre-release is more straightforward then the previous one and would be compatible with any other client (so you don't need to update all your clients).

The main changes are from our two GSoC candidates Naveen and Anjula who did a great job with the search engine update and support for keyboard shortcut. As of this release both features are now fully integrated into Joplin, so you can make use of advanced search features, such as filters and fuzzy search, and modify the keyboard shortcut in the config screen.

Another notable change is the switch to CodeMirror as the Markdown editor. Caleb has been making a lot of improvements on it over the past months and it has now all the features of the previous Markdown editor (Ace Editor) but with a more modern code base. It means certain bugs that were impossible to fix are now fixed (such as various font and unicode issues), and it will also be easier to integrate certain previously impossible features, most notably spell checking support.

The pre-release is available for download here:

9 Likes

I’ve run into some issues when testing and/adding new shortcuts. Here’s an example:

I’ve added a new menu item, toolbar button, and shortcut for ==marked text==. I used Cmd+Y, but noticed that the shortcut didn’t wotk, because it has already been in use by CodeMirror (redo).
As soon as I change the shortcut to Cmd+Shift+Y it worked. Btw, I can open a PR for the marked text stuff, if you want to add it.

So we should find a way to let the keymapper service know which keys are actually available.

Additionally we should add a global section, so that we can now allow people to show/hide Joplin with a global shortcut.

Normally the keyboard shortcut editor handles duplicates, so if you try to enter it should warn you with a small icon and shouldn’t allow you to save:

Yes I guess we should handle global shortcuts at some point.

No, I think I maybe expressed myself incorrectly. I was not talking about the UI. But after you mentioned it, I also looked into that.

In ElectronClient/gui/NoteEditor/NoteBody/CodeMirror/Editor.tsx the following shortcuts are defined.
I only found that out after I set the default for my new Mark menu item in ReactNativeClient/lib/services/KeymapService.ts.

	useEffect(() => {
		CodeMirror.keyMap.basic = {
			'Left': 'goCharLeft',
			'Right': 'goCharRight',
			'Up': 'goLineUp',
			'Down': 'goLineDown',
			'End': 'goLineRight',
			'Home': 'goLineLeftSmart',
			'PageUp': 'goPageUp',
			'PageDown': 'goPageDown',
			'Delete': 'delCharAfter',
			'Backspace': 'delCharBefore',
			'Shift-Backspace': 'delCharBefore',
			'Tab': 'smartListIndent',
			'Shift-Tab': 'smartListUnindent',
			'Enter': 'insertListElement',
			'Insert': 'toggleOverwrite',
			'Esc': 'singleSelection',
		};

		if (shim.isMac()) {
			CodeMirror.keyMap.default = {
				// MacOS
				'Cmd-A': 'selectAll',
				'Cmd-D': 'deleteLine',
				'Cmd-Z': 'undo',
				'Shift-Cmd-Z': 'redo',
				'Cmd-Y': 'redo',
				'Cmd-Home': 'goDocStart',
				'Cmd-Up': 'goDocStart',
				'Cmd-End': 'goDocEnd',
				'Cmd-Down': 'goDocEnd',
				'Cmd-Left': 'goLineLeft',
				'Cmd-Right': 'goLineRight',
				'Alt-Left': 'goGroupLeft',
				'Alt-Right': 'goGroupRight',
				'Alt-Backspace': 'delGroupBefore',
				'Alt-Delete': 'delGroupAfter',
				'Cmd-[': 'indentLess',
				'Cmd-]': 'indentMore',
				'Cmd-/': 'toggleComment',
				'Cmd-Opt-S': 'sortSelectedLines',
				'Opt-Up': 'swapLineUp',
				'Opt-Down': 'swapLineDown',

				'fallthrough': 'basic',
			};
		} else {
			CodeMirror.keyMap.default = {
				// Windows/linux
				'Ctrl-A': 'selectAll',
				'Ctrl-D': 'deleteLine',
				'Ctrl-Z': 'undo',
				'Shift-Ctrl-Z': 'redo',
				'Ctrl-Y': 'redo',
				'Ctrl-Home': 'goDocStart',
				'Ctrl-End': 'goDocEnd',
				'Ctrl-Up': 'goLineUp',
				'Ctrl-Down': 'goLineDown',
				'Ctrl-Left': 'goGroupLeft',
				'Ctrl-Right': 'goGroupRight',
				'Alt-Left': 'goLineStart',
				'Alt-Right': 'goLineEnd',
				'Ctrl-Backspace': 'delGroupBefore',
				'Ctrl-Delete': 'delGroupAfter',
				'Ctrl-[': 'indentLess',
				'Ctrl-]': 'indentMore',
				'Ctrl-/': 'toggleComment',
				'Ctrl-Alt-S': 'sortSelectedLines',
				'Alt-Up': 'swapLineUp',
				'Alt-Down': 'swapLineDown',

				'fallthrough': 'basic',
			};
		}
	}, []);

I can't use any of the shortcuts defined by CodeMirror. There was no warning/error when running the code.

The UI does not show them as unavailable either, because it only checks for ones defined by the Keymapper service and not by the editor.

I think we can make the CodeMirror editor use Keymap service to retrieve its keyboard shortcuts, instead of hardcoding these shortcuts in the editor logic. This would make the keyboard shortcut editor aware of these existing shortcuts, making error detection possible.

We can allow customizing CodeMirror shortcuts as well. It'll just need a small conversion layer as these CodeMirror keyboard shortcuts seems different from Electron Accelerators. However since the current keyboard shortcuts are self-documented with menu items assigned to them, this would break that pattern a bit.

Alternatively, maybe we can improve Keymap service in such a way that it's possible for plugins to extend the default keymap.

Is there a better way to handle this issue?

2 Likes

I'm not sure, I thought about a few different approaches. I'm still not sure which route to take.

Laurent did not reply to my previous reply, so I don't know what he thinks of it.

@anjula's proposal definitely makes sense. CodeMirror could get the shortcuts from the keymap service, and it's ok if they aren't self-documented for now.

Great. Since we now have a shortcut editor, we can also start adding shortcuts that we didn't add for previous feature requests. I'll try to go through the different requests/topics/issues and compile a list.

1 Like

@anjulalk @laurent coming back to that topic, since I want to add several shortcuts, I do have a few questions:

  • can I set a default shortcut to NULL, so that it will show up in the list of shortcuts, but is not active by default?
  • is the global part for shortcuts done or in the works?
  • what's the status of the CodeMirror <-> Keymap Service "project"
1 Like