Release 5.2.0
Commands rework and new hotkeys
New hotkeys functionality has been added to make registering commands and customizing key bindings easier (48023d0).
The defaultCommands() extension has now been deprecated and will be removed in the next major release. It has been replaced by the new editorCommands() extension which allows customizable key bindings and behaves almost identically when given the defaultKeymap. Note that The basicEditor() setup will continue to use defaultCommands() for backwards compatibility until the next major release. The example below shows how to use the new extension:
import { editorCommands, defaultKeymap } from "prism-code-editor/commands"
editor.addExtensions(editorCommands(defaultKeymap))Most commands part of defaultCommands() have how been extracted from the extension and are exported from prism-code-editor/commands. This makes it easy to make custom keymaps or to create command palettes. The commands include:
copySelectedLines()deleteSelectedLines()indentSelectedLines()insertLineAndIndent()insertTab()moveSelectedLines()scrollByOneLine()toggleComment()
editor.keyCommandMap has also been deprecated and will be removed in the next major release. Read the hotkeys guide to see how addEditorHotkey() can be used instead.
Improvements
- Added extra key bindings to the search widget (1a5ab1a)
- Added scroll up/down 1 line key binding for Mac to
defaultKeymap(a54dc41) - Optimized the
setSelection()utility (3f6aafd)